Skip to content

Commit

Permalink
Merge branch 'master' into feat/infer_expected_types
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Mar 13, 2024
2 parents d8169e5 + a9ee641 commit 45960ef
Show file tree
Hide file tree
Showing 42 changed files with 1,726 additions and 474 deletions.
21 changes: 7 additions & 14 deletions docs/compiling-a-contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,10 @@ When using the JSON interface, you can include the ``"evmVersion"`` key within t
Target Options
--------------

The following is a list of supported EVM versions, and changes in the compiler introduced with each version. Backward compatibility is not guaranteed between each version.
The following is a list of supported EVM versions, and changes in the compiler introduced with each version. Backward compatibility is not guaranteed between each version. In general, the compiler team maintains an informal policy that the compiler will support 3 years of hard fork rulesets, but this policy may be revisited as appropriate.


.. py:attribute:: istanbul
- The ``CHAINID`` opcode is accessible via ``chain.id``
- The ``SELFBALANCE`` opcode is used for calls to ``self.balance``
- Gas estimates changed for ``SLOAD`` and ``BALANCE``

.. py:attribute:: berlin
- Gas estimates changed for ``EXTCODESIZE``, ``EXTCODECOPY``, ``EXTCODEHASH``, ``SLOAD``, ``SSTORE``, ``CALL``, ``CALLCODE``, ``DELEGATECALL`` and ``STATICCALL``
- Functions marked with ``@nonreentrant`` are protected with different values (3 and 2) than contracts targeting pre-berlin.
- ``BASEFEE`` is accessible via ``block.basefee``
.. py:attribute:: london
.. py:attribute:: paris
Expand Down Expand Up @@ -247,7 +237,7 @@ The following example describes the expected input format of ``vyper-json``. Com
},
// Optional
"settings": {
"evmVersion": "shanghai", // EVM version to compile for. Can be istanbul, berlin, paris, shanghai (default) or cancun (experimental!).
"evmVersion": "shanghai", // EVM version to compile for. Can be london, paris, shanghai (default) or cancun (experimental!).
// optional, optimization mode
// defaults to "gas". can be one of "gas", "codesize", "none",
// false and true (the last two are for backwards compatibility).
Expand Down Expand Up @@ -275,11 +265,14 @@ The following example describes the expected input format of ``vyper-json``. Com
// evm.bytecode.opcodes - Opcodes list
// evm.deployedBytecode.object - Deployed bytecode object
// evm.deployedBytecode.opcodes - Deployed opcodes list
// evm.deployedBytecode.sourceMap - Deployed source mapping (useful for debugging)
// evm.deployedBytecode.sourceMap - Solidity-style source mapping
// evm.deployedBytecode.sourceMapFull - 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.
// Additionally, `*` can be used as a wildcard to request everything.
// Note that the sourceMapFull.pc_ast_map is the recommended source map to use;
// the other types are included for legacy and compatibility reasons.
//
"outputSelection": {
"*": ["evm.bytecode", "abi"], // Enable the abi and bytecode outputs for every single contract
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/builtins/codegen/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _padconvert(val_bits, direction, n, padding_byte=None):
"""
Takes the ABI representation of a value, and convert the padding if needed.
If fill_zeroes is false, the two halves of the bytestring are just swapped
and the dirty bytes remain dirty. If fill_zeroes is true, the the padding
and the dirty bytes remain dirty. If fill_zeroes is true, the padding
bytes get set to 0
"""
assert len(val_bits) == 32
Expand Down
5 changes: 1 addition & 4 deletions tests/functional/syntax/test_self_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ def __default__():
"""
settings = Settings(evm_version=evm_version)
opcodes = compiler.compile_code(code, output_formats=["opcodes"], settings=settings)["opcodes"]
if EVM_VERSIONS[evm_version] >= EVM_VERSIONS["istanbul"]:
assert "SELFBALANCE" in opcodes
else:
assert "SELFBALANCE" not in opcodes
assert "SELFBALANCE" in opcodes

c = get_contract_with_gas_estimation(code, evm_version=evm_version)
w3.eth.send_transaction({"to": c.address, "value": 1337})
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ast/nodes/test_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def x():
"""
)

assert vy_ast.compare_nodes(expected, mutated)
assert expected == mutated


def test_binary_length():
Expand Down
14 changes: 5 additions & 9 deletions tests/unit/ast/nodes/test_compare_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@ def test_compare_different_node_clases():
right = vyper_ast.body[0].value

assert left != right
assert not vy_ast.compare_nodes(left, right)


def test_compare_different_nodes_same_class():
vyper_ast = vy_ast.parse_to_ast("[1, 2]")
left, right = vyper_ast.body[0].value.elements

assert left != right
assert not vy_ast.compare_nodes(left, right)


def test_compare_different_nodes_same_value():
vyper_ast = vy_ast.parse_to_ast("[1, 1]")
left, right = vyper_ast.body[0].value.elements

assert left != right
assert vy_ast.compare_nodes(left, right)


def test_compare_complex_nodes_same_value():
vyper_ast = vy_ast.parse_to_ast("[{'foo':'bar', 43:[1,2,3]}, {'foo':'bar', 43:[1,2,3]}]")
left, right = vyper_ast.body[0].value.elements
def test_compare_similar_node():
# test equality without node_ids
left = vy_ast.Int(value=1)
right = vy_ast.Int(value=1)

assert left != right
assert vy_ast.compare_nodes(left, right)
assert left == right


def test_compare_same_node():
vyper_ast = vy_ast.parse_to_ast("42")
node = vyper_ast.body[0].value

assert node == node
assert vy_ast.compare_nodes(node, node)
7 changes: 0 additions & 7 deletions tests/unit/ast/nodes/test_from_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ def test_kwargs():
assert new_node.value == 666


def test_compare_nodes():
old_node = vy_ast.parse_to_ast("foo = 42")
new_node = vy_ast.Int.from_node(old_node, value=666)

assert not vy_ast.compare_nodes(old_node, new_node)


def test_new_node_has_no_parent():
old_node = vy_ast.parse_to_ast("foo = 42")
new_node = vy_ast.Int.from_node(old_node, value=666)
Expand Down
Loading

0 comments on commit 45960ef

Please sign in to comment.