Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Cancun the default EVM version #14907

Merged
merged 2 commits into from
Mar 13, 2024
Merged

Make Cancun the default EVM version #14907

merged 2 commits into from
Mar 13, 2024

Conversation

matheusaaguiar
Copy link
Collaborator

Closes #14905.

@matheusaaguiar matheusaaguiar self-assigned this Mar 5, 2024
@matheusaaguiar matheusaaguiar added this to the 0.8.25 milestone Mar 5, 2024
@matheusaaguiar matheusaaguiar marked this pull request as ready for review March 6, 2024 04:56
@cameel
Copy link
Member

cameel commented Mar 7, 2024

Gas diff:

File name IR optimized Legacy optimized Legacy
various/selfdestruct_post_cancun_redeploy.sol 14218% 13654% 15328%
various/selfdestruct_post_cancun_multiple_beneficiaries.sol
inlineAssembly/tstore_hidden_staticcall.sol
inlineAssembly/transient_storage_selfdestruct.sol
inlineAssembly/transient_storage_low_level_calls.sol
inlineAssembly/mcopy_as_identifier_pre_cancun.sol
inlineAssembly/blobhash_pre_cancun.sol
structs/copy_substructures_to_mapping.sol -0% -0% -0%
structs/copy_substructures_from_mapping.sol -0% -0% -0%
structs/copy_from_mapping.sol -0% -0% -0%
structs/copy_to_mapping.sol -0% -0% -0%
array/copying/function_type_array_to_storage.sol -0% -0% -0%
various/skip_dynamic_types_for_structs.sol -0% -0% -0%
array/pop/byte_array_pop_masking_long.sol -0% -0% -0%
abiencodedecode/abi_decode_simple_storage.sol -0% -0% -0%
abiEncoderV2/calldata_overlapped_dynamic_arrays.sol -0% -0% -0%
array/copying/copy_byte_array_in_struct_to_storage.sol -0% -0% -0%
array/copying/storage_memory_nested_bytes.sol -0% -0% -0%
salted_create/prediction_example.sol -1%
abiEncoderV2/storage_array_encoding.sol -0% -0% -0%
array/copying/bytes_storage_to_storage.sol -1% -0% -0%
externalContracts/strings.sol -1% -1% -1%
abiEncoderV2/calldata_array.sol -2%
abiEncoderV2/abi_encode_v2.sol -1% -1% -1%
externalContracts/FixedFeeRegistrar.sol -1% -1% -1%
functionCall/external_call_to_nonexisting_debugstrings.sol -1% -1% -1%
byte_array_to_storage_cleanup.sol -1% -1% -1%
externalContracts/base64.sol -2% -1% -1%
functionCall/external_call_to_nonexisting.sol -2% -2% -1%
externalContracts/deposit_contract.sol -2% -2% -1%
constructor/bytes_in_constructors_packer.sol -2% -2% -1%
constructor/bytes_in_constructors_unpacker.sol -3% -2% -2%
various/address_code.sol -4% -3% -2%
abiEncoderV2/abi_encode_calldata_slice.sol -4% -4% -3%
abiEncoderV1/abi_encode_calldata_slice.sol -4% -4% -3%
various/create_calldata.sol -5% -4% -3%
various/selfdestruct_post_cancun.sol -47% -54% -1%

Comment on lines 70 to +76
// tstoreNotAllowedStaticCall() -> true
// gas irOptimized: 98419720
// gas irOptimized code: 19000
// gas legacy: 98409086
// gas legacy code: 30000
// gas legacyOptimized: 98420962
// gas legacyOptimized code: 17800
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... the code cost here seems surprisingly low. I'd expect the deployment cost to be the biggest factor here. Given 200 gas per byte, this means code size of 85 bytes, 150 bytes and 89 bytes, respectively. So I guess it's plausible. Maybe it's just the other cost that seems off. How is this function eating almost 100 million gas? It does not loop or do anything that heavy except for the contract deployment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't noticed that. I will try to check where exactly it is getting that high cost.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. This looks highly suspicious so it would be great if we knew what's happening and if something is broken.

But that's just in case. This is not a blocker for the PR itself. I think it's unlikely that it's caused by it and it's probably that we're just seeing the effects of something else here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that 100000000 * 63 / 64 = 98437500

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! And 100000000 is the gas limit in our tests:

u256 const InitialGas = 100000000;

So mystery solved. Looks like a failed staticcall just eats all gas forwarded to it. I did not consider that this might happen in cases other than hitting an invalid opcode. Or is it simply because state-mutating opcodes are considered invalid within a staticcall?

Copy link
Member

@ekpyron ekpyron Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it just hits an invalid opcode and thus eats up all gas forwarded to it. (The same should happen for an sstore)

docs/using-the-compiler.rst Outdated Show resolved Hide resolved
@matheusaaguiar matheusaaguiar force-pushed the makeCancunDefault branch 2 times, most recently from 968d203 to 1396e78 Compare March 8, 2024 02:32
@cameel
Copy link
Member

cameel commented Mar 8, 2024

Overall, the PR looks fine and the only blocker are the failing external tests.

@r0qs
Copy link
Member

r0qs commented Mar 13, 2024

t_native_compile_ext_gp2 and t_native_test_ext_zeppelin are apparently using a old version of hardhat (since now we don't delete the package.json of those projects), so I guess we need to bump it to a version that supports the cancun hardfork option.

@cameel
Copy link
Member

cameel commented Mar 13, 2024

Note that this now contains the workaround from #14933 so they'll go in together and CI should pass.

@cameel cameel merged commit 759f5a7 into develop Mar 13, 2024
71 checks passed
@cameel cameel deleted the makeCancunDefault branch March 13, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Switch default EVM version to Cancun
4 participants