Skip to content

Commit

Permalink
Merge branch 'master' into fix/improve-loop-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jul 26, 2024
2 parents 1485d62 + fc19284 commit 925457b
Show file tree
Hide file tree
Showing 40 changed files with 1,679 additions and 149 deletions.
7 changes: 7 additions & 0 deletions FUNDING.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"drips": {
"ethereum": {
"ownedBy": "0x70CCBE10F980d80b7eBaab7D2E3A73e87D67B775"
}
}
}
21 changes: 15 additions & 6 deletions docs/built-in-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Vyper has three built-ins for contract creation; all three contract creation bui
x: uint256 = 123
success, response = raw_call(
_target,
_abi_encode(x, method_id=method_id("someMethodName(uint256)")),
abi_encode(x, method_id=method_id("someMethodName(uint256)")),
max_outsize=32,
value=msg.value,
revert_on_failure=False
Expand Down Expand Up @@ -1023,7 +1023,7 @@ Utilities
>>> ExampleContract.foo()
0xa9059cbb

.. py:function:: _abi_encode(*args, ensure_tuple: bool = True) -> Bytes[<depends on input>]
.. py:function:: abi_encode(*args, ensure_tuple: bool = True) -> Bytes[<depends on input>]
Takes a variable number of args as input, and returns the ABIv2-encoded bytestring. Used for packing arguments to raw_call, EIP712 and other cases where a consistent and efficient serialization method is needed.
Once this function has seen more use we provisionally plan to put it into the ``ethereum.abi`` namespace.
Expand All @@ -1041,7 +1041,7 @@ Utilities
def foo() -> Bytes[132]:
x: uint256 = 1
y: Bytes[32] = b"234"
return _abi_encode(x, y, method_id=method_id("foo()"))
return abi_encode(x, y, method_id=method_id("foo()"))
.. code-block:: vyper
Expand All @@ -1052,15 +1052,18 @@ Utilities
"0000000000000000000000000000000000000000000000000000000000000003"
"3233340000000000000000000000000000000000000000000000000000000000"
.. note::
Prior to v0.4.0, this function was named ``_abi_encode``.


.. py:function:: _abi_decode(b: Bytes, output_type: type_, unwrap_tuple: bool = True) -> Any
.. py:function:: abi_decode(b: Bytes, output_type: type_, unwrap_tuple: bool = True) -> Any
Takes a byte array as input, and returns the decoded values according to the specified output types. Used for unpacking ABIv2-encoded values.
Once this function has seen more use we provisionally plan to put it into the ``ethereum.abi`` namespace.

* ``b``: A byte array of a length that is between the minimum and maximum ABIv2 size bounds of the ``output type``.
* ``output_type``: Name of the output type, or tuple of output types, to be decoded.
* ``unwrap_tuple``: If set to True, the input is decoded as a tuple even if only one output type is specified. In other words, ``_abi_decode(b, Bytes[32])`` gets decoded as ``(Bytes[32],)``. This is the convention for ABIv2-encoded values generated by Vyper and Solidity functions. Except for very specific use cases, this should be set to True. Must be a literal.
* ``unwrap_tuple``: If set to True, the input is decoded as a tuple even if only one output type is specified. In other words, ``abi_decode(b, Bytes[32])`` gets decoded as ``(Bytes[32],)``. This is the convention for ABIv2-encoded values generated by Vyper and Solidity functions. Except for very specific use cases, this should be set to True. Must be a literal.

Returns the decoded value(s), with type as specified by `output_type`.

Expand All @@ -1071,9 +1074,12 @@ Utilities
def foo(someInput: Bytes[128]) -> (uint256, Bytes[32]):
x: uint256 = empty(uint256)
y: Bytes[32] = empty(Bytes[32])
x, y = _abi_decode(someInput, (uint256, Bytes[32]))
x, y = abi_decode(someInput, (uint256, Bytes[32]))
return x, y
.. note::
Prior to v0.4.0, this function was named ``_abi_decode``.


.. py:function:: print(*args, hardhat_compat=False) -> None
Expand All @@ -1084,3 +1090,6 @@ Utilities
.. note::

Issuing of the static call is *NOT* mode-dependent (that is, it is not removed from production code), although the compiler will issue a warning whenever ``print`` is used.

.. warning::
In Vyper, as of v0.4.0, the order of argument evaluation of builtins is not defined. That means that the compiler may choose to reorder evaluation of arguments. For example, ``extract32(x(), y())`` may yield unexpected results if ``x()`` and ``y()`` both touch the same data. For this reason, it is best to avoid calling functions with side-effects inside of builtins. For more information, see `GHSA-g2xh-c426-v8mf <https://github.com/vyperlang/vyper/security/advisories/GHSA-g2xh-c426-v8mf>`_ and `issue #4019 <https://github.com/vyperlang/vyper/issues/4019>`_.
32 changes: 27 additions & 5 deletions docs/compiling-a-contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ The following example describes the expected input format of ``vyper-json``. (Co
// devdoc - Natspec developer documentation
// evm.bytecode.object - Bytecode object
// evm.bytecode.opcodes - Opcodes list
// evm.bytecode.sourceMap - Source mapping (useful for debugging)
// evm.deployedBytecode.object - Deployed bytecode object
// evm.deployedBytecode.opcodes - Deployed opcodes list
// evm.deployedBytecode.sourceMap - Solidity-style source mapping
// evm.deployedBytecode.sourceMapFull - Deployed source mapping (useful for debugging)
// evm.deployedBytecode.sourceMap - Deployed source mapping (useful for debugging)
// evm.methodIdentifiers - The list of function hashes
//
// Using `evm`, `evm.bytecode`, etc. will select every target part of that output.
Expand Down Expand Up @@ -388,15 +388,37 @@ The following example describes the output format of ``vyper-json``. Comments ar
// The bytecode as a hex string.
"object": "00fe",
// Opcodes list (string)
"opcodes": ""
"opcodes": "",
// The deployed source mapping.
"sourceMap": {
"breakpoints": [],
"error_map": {},
"pc_ast_map": {},
"pc_ast_map_item_keys": [],
"pc_breakpoints": [],
"pc_jump_map": {},
"pc_pos_map": {},
// The deployed source mapping as a string.
"pc_pos_map_compressed": ""
}
},
"deployedBytecode": {
// The deployed bytecode as a hex string.
"object": "00fe",
// Deployed opcodes list (string)
"opcodes": "",
// The deployed source mapping as a string.
"sourceMap": ""
// The deployed source mapping.
"sourceMap": {
"breakpoints": [],
"error_map": {},
"pc_ast_map": {},
"pc_ast_map_item_keys": [],
"pc_breakpoints": [],
"pc_jump_map": {},
"pc_pos_map": {},
// The deployed source mapping as a string.
"pc_pos_map_compressed": ""
}
},
// The list of function hashes
"methodIdentifiers": {
Expand Down
7 changes: 5 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
Vyper
#####

Vyper is a contract-oriented, pythonic programming language that targets the `Ethereum Virtual Machine (EVM) <https://ethereum.org/learn/#ethereum-basics>`_.
Vyper is a contract-oriented, Pythonic programming language that targets the `Ethereum Virtual Machine (EVM) <https://ethereum.org/learn/#ethereum-basics>`_.
It prioritizes user safety, encourages clear coding practices via language design and efficient execution. In other words, Vyper code is safe, clear and efficient!

Principles and Goals
====================

* **Security**: It should be possible and natural to build secure smart-contracts in Vyper.
* **Language and compiler simplicity**: The language and the compiler implementation should strive to be simple.
* **Auditability**: Vyper code should be maximally human-readable. Furthermore, it should be maximally difficult to write misleading code. Simplicity for the reader is more important than simplicity for the writer, and simplicity for readers with low prior experience with Vyper (and low prior experience with programming in general) is particularly important.
* **Auditability**: Vyper code should be maximally human-readable.
Furthermore, it should be maximally difficult to write misleading code.
Simplicity for the reader is more important than simplicity for the writer, and simplicity for readers with low prior experience with Vyper (and low prior experience with programming in general) is particularly important.

Because of this Vyper provides the following features:

Expand Down
Loading

0 comments on commit 925457b

Please sign in to comment.