From a1aa9d2d90f2f7e7390408e9005d62c7159d4bd4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 27 Oct 2021 17:26:44 +0200 Subject: [PATCH 1/4] Skip extcodesize check if return data is expected. --- Changelog.md | 1 + libsolidity/codegen/ExpressionCompiler.cpp | 18 +- .../codegen/ir/IRGeneratorForStatements.cpp | 20 +- .../output.json | 190 ++++++++++++++++++ .../output.json | 32 +-- .../abi_encode_calldata_slice.sol | 4 +- .../struct/struct_storage_ptr.sol | 2 +- .../abi_encode_calldata_slice.sol | 4 +- ...2_in_function_inherited_in_v1_contract.sol | 2 +- ...ode_v2_in_modifier_used_in_v1_contract.sol | 2 +- .../abiEncoderV2/calldata_array.sol | 2 +- .../arithmetics/check_var_init.sol | 2 +- .../array/fixed_arrays_as_return_type.sol | 2 +- .../array/function_array_cross_calls.sol | 2 +- .../semanticTests/array/reusing_memory.sol | 2 +- .../constructor/arrays_in_constructors.sol | 2 +- .../bytes_in_constructors_packer.sol | 2 +- .../constructor_function_complex.sol | 2 +- .../freeFunctions/new_operator.sol | 2 +- .../creation_function_call_no_args.sol | 2 +- .../functionCall/failed_create.sol | 4 +- .../functionTypes/store_function.sol | 2 +- .../immutable/multi_creation.sol | 2 +- .../address_overload_resolution.sol | 4 +- ...d_function_calldata_calldata_interface.sol | 2 +- ...ted_function_calldata_memory_interface.sol | 2 +- .../inheritance/member_notation_ctor.sol | 4 +- .../interface_inheritance_conversions.sol | 4 +- .../salted_create_with_value.sol | 2 +- .../semanticTests/smoke/alignment.sol | 2 +- .../various/code_access_content.sol | 2 +- .../various/code_access_create.sol | 2 +- .../various/external_types_in_calls.sol | 2 +- .../skip_dynamic_types_for_structs.sol | 2 +- .../various/staticcall_for_view_and_pure.sol | 6 +- 35 files changed, 270 insertions(+), 67 deletions(-) diff --git a/Changelog.md b/Changelog.md index f02004437..54088143b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ Language Features: Compiler Features: + * Code Generator: Skip existence check for external contract if return data is expected. In this case, the ABI decoder will revert if the contract does not exist. * Commandline Interface: Accept nested brackets in step sequences passed to ``--yul-optimizations``. * Commandline Interface: Add ``--debug-info`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code. * Commandline Interface: Use different colors when printing errors, warnings and infos. diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 731cf1a41..07d37c4c5 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -2630,9 +2630,21 @@ void ExpressionCompiler::appendExternalFunctionCall( // Check the target contract exists (has code) for non-low-level calls. if (funKind == FunctionType::Kind::External || funKind == FunctionType::Kind::DelegateCall) { - m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO; - m_context.appendConditionalRevert(false, "Target contract does not contain code"); - existenceChecked = true; + size_t encodedHeadSize = 0; + for (auto const& t: returnTypes) + encodedHeadSize += t->decodingType()->calldataHeadSize(); + // We do not need to check extcodesize if we expect return data, since if there is no + // code, the call will return empty data and the ABI decoder will revert. + if ( + encodedHeadSize == 0 || + !haveReturndatacopy || + m_context.revertStrings() >= RevertStrings::Debug + ) + { + m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO; + m_context.appendConditionalRevert(false, "Target contract does not contain code"); + existenceChecked = true; + } } if (_functionType.gasSet()) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 6d7ee86f5..85b21bbdc 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -2451,8 +2451,10 @@ void IRGeneratorForStatements::appendExternalFunctionCall( appendCode() << "mstore(add(" << m_utils.allocateUnboundedFunction() << "() , " << to_string(returnInfo.estimatedReturnSize) << "), 0)\n"; } - Whiskers templ(R"(if iszero(extcodesize(
)) { () } - + Whiskers templ(R"( + + if iszero(extcodesize(
)) { () } + // storage for arguments and returned data let := () mstore(, ()) @@ -2477,6 +2479,18 @@ void IRGeneratorForStatements::appendExternalFunctionCall( } )"); templ("revertNoCode", m_utils.revertReasonIfDebugFunction("Target contract does not contain code")); + + // We do not need to check extcodesize if we expect return data: If there is no + // code, the call will return empty data and the ABI decoder will revert. + size_t encodedHeadSize = 0; + for (auto const& t: returnInfo.returnTypes) + encodedHeadSize += t->decodingType()->calldataHeadSize(); + bool const checkExtcodesize = + encodedHeadSize == 0 || + !m_context.evmVersion().supportsReturndata() || + m_context.revertStrings() >= RevertStrings::Debug; + templ("checkExtcodesize", checkExtcodesize); + templ("pos", m_context.newYulVariable()); templ("end", m_context.newYulVariable()); if (_functionCall.annotation().tryCall) @@ -2532,6 +2546,8 @@ void IRGeneratorForStatements::appendExternalFunctionCall( u256 gasNeededByCaller = evmasm::GasCosts::callGas(m_context.evmVersion()) + 10; if (funType.valueSet()) gasNeededByCaller += evmasm::GasCosts::callValueTransferGas; + if (!checkExtcodesize) + gasNeededByCaller += evmasm::GasCosts::callNewAccountGas; // we never know templ("gas", "sub(gas(), " + formatNumber(gasNeededByCaller) + ")"); } // Order is important here, STATICCALL might overlap with DELEGATECALL. diff --git a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json index 0c529109a..773637b32 100644 --- a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json @@ -289,6 +289,19 @@ sub_0: assembly { address /* \"C\":403:411 this.f() */ extcodesize + tag_40 + jumpi + /* \"C\":79:428 contract C... */ + dup2 + dup3 + revert + /* \"C\":403:411 this.f() */ + tag_40: + /* \"C\":79:428 contract C... */ + /* \"C\":403:407 this */ + address + /* \"C\":403:411 this.f() */ + extcodesize iszero tag_43 jumpi @@ -316,6 +329,8 @@ sub_0: assembly { tag_45 jumpi dup1 + tag_41 + tag_40 swap3 tag_47 jumpi @@ -344,12 +359,22 @@ sub_0: assembly { swap1 jump\t// out /* \"C\":403:411 this.f() */ + tag_41: + tag_40: tag_47: /* \"C\":79:428 contract C... */ swap1 swap2 pop /* \"C\":403:411 this.f() */ + dup2 + iszero + tag_42 + jumpi + dup2 + iszero + tag_41 + jumpi returndatasize /* \"C\":79:428 contract C... */ 0x1f @@ -366,6 +391,10 @@ sub_0: assembly { dup4 lt or + iszero + tag_43 + iszero + tag_42 tag_51 jumpi pop @@ -379,26 +408,56 @@ sub_0: assembly { /* \"C\":392:422 stateVar + this.f() + immutVar */ tag_50 /* \"C\":79:428 contract C... */ + mstore + 0x24 + dup7 + revert + tag_43: + mstore + 0x24 + dup7 + revert + tag_42: swap5 0x40 mstore /* \"C\":403:411 this.f() */ + tag_44 + tag_43 returndatasize dup2 add swap1 tag_7 jump\t// in + tag_44: + swap1 + tag_43: + swap1 tag_53: swap2 dup2 swap4 pop + tag_42: + /* \"C\":392:411 stateVar + this.f() */ + tag_45 + tag_41: + /* \"C\":392:411 stateVar + this.f() */ + tag_44 jump(tag_48) /* \"C\":79:428 contract C... */ tag_51: shl(0xe0, 0x4e487b71) dup2 + dup6 + tag_5 + jump\t// in + tag_45: + dup6 + tag_5 + jump\t// in + tag_44: mstore 0x41 /* \"C\":403:411 this.f() */ @@ -422,12 +481,30 @@ sub_0: assembly { pop pop pop + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_46 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_45 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ pop mload(0x40) swap1 returndatasize swap1 dup3 + tag_5 + jump\t// in + tag_46: + /* \"C\":336:337 _ */ + tag_5 + jump\t// in + tag_45: + /* \"C\":336:337 _ */ returndatacopy returndatasize swap1 @@ -453,6 +530,10 @@ sub_0: assembly { swap2 sub slt + iszero + tag_48 + iszero + tag_47 tag_55 jumpi mload @@ -464,6 +545,20 @@ sub_0: assembly { 0x00 dup1 revert + tag_48: + pop + mload + swap2 + swap1 + pop + jump\t// out + tag_47: + pop + mload + swap2 + swap1 + pop + jump\t// out auxdata: } @@ -799,6 +894,19 @@ sub_0: assembly { address /* \"C\":403:411 this.f() */ extcodesize + tag_40 + jumpi + /* \"D\":91:166 contract D is C(3)... */ + dup2 + dup3 + revert + /* \"C\":403:411 this.f() */ + tag_40: + /* \"D\":91:166 contract D is C(3)... */ + /* \"C\":403:407 this */ + address + /* \"C\":403:411 this.f() */ + extcodesize iszero tag_43 jumpi @@ -826,6 +934,8 @@ sub_0: assembly { tag_45 jumpi dup1 + tag_41 + tag_40 swap3 tag_47 jumpi @@ -854,12 +964,22 @@ sub_0: assembly { swap1 jump\t// out /* \"C\":403:411 this.f() */ + tag_41: + tag_40: tag_47: /* \"D\":91:166 contract D is C(3)... */ swap1 swap2 pop /* \"C\":403:411 this.f() */ + dup2 + iszero + tag_42 + jumpi + dup2 + iszero + tag_41 + jumpi returndatasize /* \"D\":91:166 contract D is C(3)... */ 0x1f @@ -876,6 +996,10 @@ sub_0: assembly { dup4 lt or + iszero + tag_43 + iszero + tag_42 tag_51 jumpi pop @@ -889,26 +1013,56 @@ sub_0: assembly { /* \"C\":392:422 stateVar + this.f() + immutVar */ tag_50 /* \"D\":91:166 contract D is C(3)... */ + mstore + 0x24 + dup7 + revert + tag_43: + mstore + 0x24 + dup7 + revert + tag_42: swap5 0x40 mstore /* \"C\":403:411 this.f() */ + tag_44 + tag_43 returndatasize dup2 add swap1 tag_7 jump\t// in + tag_44: + swap1 + tag_43: + swap1 tag_53: swap2 dup2 swap4 pop + tag_42: + /* \"C\":392:411 stateVar + this.f() */ + tag_45 + tag_41: + /* \"C\":392:411 stateVar + this.f() */ + tag_44 jump(tag_48) /* \"D\":91:166 contract D is C(3)... */ tag_51: shl(0xe0, 0x4e487b71) dup2 + dup6 + tag_5 + jump\t// in + tag_45: + dup6 + tag_5 + jump\t// in + tag_44: mstore 0x41 /* \"C\":403:411 this.f() */ @@ -931,6 +1085,16 @@ sub_0: assembly { swap4 pop pop + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_46 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_45 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ pop pop mload(0x40) @@ -938,6 +1102,14 @@ sub_0: assembly { returndatasize swap1 dup3 + tag_5 + jump\t// in + tag_46: + /* \"C\":336:337 _ */ + tag_5 + jump\t// in + tag_45: + /* \"C\":336:337 _ */ returndatacopy returndatasize swap1 @@ -963,6 +1135,10 @@ sub_0: assembly { swap2 sub slt + iszero + tag_48 + iszero + tag_47 tag_55 jumpi mload @@ -974,6 +1150,20 @@ sub_0: assembly { 0x00 dup1 revert + tag_48: + pop + mload + swap2 + swap1 + pop + jump\t// out + tag_47: + pop + mload + swap2 + swap1 + pop + jump\t// out auxdata: } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json index 6a105aadd..2acd68ff7 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json @@ -526,7 +526,6 @@ object \"C_54\" { let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data let _10 := allocate_unbounded() @@ -640,7 +639,7 @@ object \"C_54\" { case 0x26121ff0 { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) - let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_566(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_556(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) /// @src 0:79:435 \"contract C...\" let memPos := mload(64) return(memPos, sub(abi_encode_int256(memPos, ret), memPos)) @@ -664,7 +663,7 @@ object \"C_54\" { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) let memPos_3 := mload(64) - return(memPos_3, sub(abi_encode_int256_565(memPos_3), memPos_3)) + return(memPos_3, sub(abi_encode_int256_555(memPos_3), memPos_3)) } } revert(0, 0) @@ -673,7 +672,7 @@ object \"C_54\" { { if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } } - function abi_encode_int256_565(headStart) -> tail + function abi_encode_int256_555(headStart) -> tail { tail := add(headStart, 32) mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) @@ -690,7 +689,7 @@ object \"C_54\" { mstore(4, 0x11) revert(0, 0x24) } - function checked_add_int256_566(y) -> sum + function checked_add_int256_556(y) -> sum { if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() } sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ y) @@ -712,13 +711,6 @@ object \"C_54\" { let ret := add(_3, 1) sstore(_2, ret) /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(/** @src 0:410:414 \"this\" */ address())) - /// @src 0:410:418 \"this.f()\" - { - /// @src 0:79:435 \"contract C...\" - revert(_2, _2) - } - /// @src 0:410:418 \"this.f()\" let _4 := /** @src 0:79:435 \"contract C...\" */ mload(64) /// @src 0:410:418 \"this.f()\" mstore(_4, /** @src 0:79:435 \"contract C...\" */ shl(228, 0x026121ff)) @@ -1359,7 +1351,6 @@ object \"D_72\" { let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data let _10 := allocate_unbounded() @@ -1481,7 +1472,7 @@ object \"D_72\" { case 0x26121ff0 { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) - let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_566(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_556(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) /// @src 1:91:166 \"contract D is C(3)...\" let memPos := mload(64) return(memPos, sub(abi_encode_int256(memPos, ret), memPos)) @@ -1505,7 +1496,7 @@ object \"D_72\" { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) let memPos_3 := mload(64) - return(memPos_3, sub(abi_encode_int256_565(memPos_3), memPos_3)) + return(memPos_3, sub(abi_encode_int256_555(memPos_3), memPos_3)) } } revert(0, 0) @@ -1514,7 +1505,7 @@ object \"D_72\" { { if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } } - function abi_encode_int256_565(headStart) -> tail + function abi_encode_int256_555(headStart) -> tail { tail := add(headStart, 32) mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) @@ -1531,7 +1522,7 @@ object \"D_72\" { mstore(4, 0x11) revert(0, 0x24) } - function checked_add_int256_566(y) -> sum + function checked_add_int256_556(y) -> sum { if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() } sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ y) @@ -1553,13 +1544,6 @@ object \"D_72\" { let ret := add(_3, 1) sstore(_2, ret) /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(/** @src 0:410:414 \"this\" */ address())) - /// @src 0:410:418 \"this.f()\" - { - /// @src 1:91:166 \"contract D is C(3)...\" - revert(_2, _2) - } - /// @src 0:410:418 \"this.f()\" let _4 := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(64) /// @src 0:410:418 \"this.f()\" mstore(_4, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index ddd536a38..947f5cb23 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -61,9 +61,9 @@ contract C { // ---- // test_bytes() -> // gas irOptimized: 377545 -// gas legacy: 423563 +// gas legacy: 418955 // gas legacyOptimized: 331391 // test_uint256() -> // gas irOptimized: 528726 -// gas legacy: 591392 +// gas legacy: 586784 // gas legacyOptimized: 456137 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index 8fe170e91..886d9dfd9 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -27,5 +27,5 @@ contract C { // library: L // f() -> 8, 7, 1, 2, 7, 12 // gas irOptimized: 167580 -// gas legacy: 169475 +// gas legacy: 169347 // gas legacyOptimized: 167397 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 3a4a23fef..f75eecfb5 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -62,9 +62,9 @@ contract C { // ---- // test_bytes() -> // gas irOptimized: 377545 -// gas legacy: 423563 +// gas legacy: 418955 // gas legacyOptimized: 331391 // test_uint256() -> // gas irOptimized: 528726 -// gas legacy: 591392 +// gas legacy: 586784 // gas legacyOptimized: 456137 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol index b730f3588..49b93cbbc 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol @@ -33,5 +33,5 @@ contract C is B { // ---- // test() -> 77 // gas irOptimized: 120044 -// gas legacy: 155221 +// gas legacy: 155093 // gas legacyOptimized: 111678 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol index 7832ef601..28658089a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol @@ -41,4 +41,4 @@ contract C is B { // ---- // test() -> 5, 10 // gas irOptimized: 87578 -// gas legacy: 99137 +// gas legacy: 98881 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index bf42f8776..131430aa5 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -22,5 +22,5 @@ contract C { // f(uint256[][1]): 32, 32, 1, 42 -> true // f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true // gas irOptimized: 172204 -// gas legacy: 141900 +// gas legacy: 141644 // gas legacyOptimized: 121788 diff --git a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol index f8e4ca2a4..7e3edc127 100644 --- a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol +++ b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol @@ -18,4 +18,4 @@ contract D { // ---- // f() -> FAILURE, hex"4e487b71", 0x11 // g(), 100 wei -> 1 -// gas legacy: 101918 +// gas legacy: 101790 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol index 5e30621af..063e0bf9c 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -22,5 +22,5 @@ contract B { // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 // gas irOptimized: 130328 -// gas legacy: 235199 +// gas legacy: 234943 // gas legacyOptimized: 133119 diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index 95cb52f11..6edae7198 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -46,5 +46,5 @@ contract C { // ---- // test() -> 5, 6, 7 // gas irOptimized: 302321 -// gas legacy: 462080 +// gas legacy: 452172 // gas legacyOptimized: 294938 diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index 7d2b4d995..a8a534b92 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -27,5 +27,5 @@ contract Main { // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 // gas irOptimized: 113776 -// gas legacy: 126852 +// gas legacy: 126596 // gas legacyOptimized: 114079 diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index 63c2acbb5..7016e6c6e 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -27,5 +27,5 @@ contract Creator { // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 // gas irOptimized: 456873 -// gas legacy: 590939 +// gas legacy: 590683 // gas legacyOptimized: 448582 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index d4d41d80c..1aba4c7c4 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -27,5 +27,5 @@ contract Creator { // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" // gas irOptimized: 308702 -// gas legacy: 429173 +// gas legacy: 428917 // gas legacyOptimized: 298384 diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol index 78466f3f0..f1043f559 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol @@ -19,4 +19,4 @@ contract C { // compileViaYul: also // ---- // f() -> 16 -// gas legacy: 103744 +// gas legacy: 103488 diff --git a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol index 1694b64d5..0e89c7560 100644 --- a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol +++ b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol @@ -15,4 +15,4 @@ contract D { // compileViaYul: also // ---- // f() -> 2 -// gas legacy: 101754 +// gas legacy: 101626 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol index 8546c775e..0ab6fe0c3 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol @@ -13,4 +13,4 @@ contract D { // compileViaYul: also // ---- // f() -> 2 -// gas legacy: 101727 +// gas legacy: 101599 diff --git a/test/libsolidity/semanticTests/functionCall/failed_create.sol b/test/libsolidity/semanticTests/functionCall/failed_create.sol index b50890f55..49c6a80a9 100644 --- a/test/libsolidity/semanticTests/functionCall/failed_create.sol +++ b/test/libsolidity/semanticTests/functionCall/failed_create.sol @@ -19,7 +19,7 @@ contract C { // ---- // constructor(), 20 wei // gas irOptimized: 220113 -// gas legacy: 288299 +// gas legacy: 294569 // gas legacyOptimized: 177933 // f(uint256): 20 -> 1370859564726510389319704988634906228201275401179 // x() -> 1 @@ -27,7 +27,7 @@ contract C { // x() -> 1 // stack(uint256): 1023 -> FAILURE // gas irOptimized: 345821 -// gas legacy: 535367 +// gas legacy: 483942 // gas legacyOptimized: 354656 // x() -> 1 // stack(uint256): 10 -> 693016686122178122849713379390321835634789309880 diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index c2678a91d..9200bd120 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -29,5 +29,5 @@ contract C { // ---- // t() -> 9 // gas irOptimized: 99186 -// gas legacy: 159083 +// gas legacy: 158955 // gas legacyOptimized: 108916 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index cd5992ce6..d4300cfe1 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -30,7 +30,7 @@ contract C { // ---- // f() -> 3, 7, 5 // gas irOptimized: 127592 -// gas legacy: 151590 +// gas legacy: 151334 // gas legacyOptimized: 125422 // x() -> 7 // y() -> 5 diff --git a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol index 0dc9845f4..8c9c6195c 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -24,7 +24,7 @@ contract D { // ---- // f() -> 1 // gas irOptimized: 77164 -// gas legacy: 115012 +// gas legacy: 114884 // g() -> 5 // gas irOptimized: 77231 -// gas legacy: 115558 +// gas legacy: 115430 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol index e012accaf..7322e5f96 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -26,4 +26,4 @@ contract B { // ---- // g() -> 42 // gas irOptimized: 80945 -// gas legacy: 125609 +// gas legacy: 125481 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol index 4105577f0..9b5f9778c 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -26,5 +26,5 @@ contract B { // ---- // g() -> 42 // gas irOptimized: 111913 -// gas legacy: 185181 +// gas legacy: 185053 // gas legacyOptimized: 114726 diff --git a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol index 9a095cc21..a400531ca 100644 --- a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol +++ b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol @@ -22,6 +22,6 @@ contract A { // compileViaYul: also // ---- // g(int256): -1 -> -1 -// gas legacy: 103622 +// gas legacy: 103494 // g(int256): 10 -> 10 -// gas legacy: 103250 +// gas legacy: 103122 diff --git a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol index 11cb93832..5dfeb9a69 100644 --- a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol @@ -40,7 +40,7 @@ contract C { // gas irOptimized: 85640 // convertSubA() -> 1, 2 // gas irOptimized: 86395 -// gas legacy: 99303 +// gas legacy: 99047 // convertSubB() -> 1, 3 // gas irOptimized: 86338 -// gas legacy: 99237 +// gas legacy: 98981 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 17edaf3eb..2d1070e2a 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -23,5 +23,5 @@ contract A { // ---- // f(), 10 ether -> 3007, 3008, 3009 // gas irOptimized: 273275 -// gas legacy: 422885 +// gas legacy: 422501 // gas legacyOptimized: 287856 diff --git a/test/libsolidity/semanticTests/smoke/alignment.sol b/test/libsolidity/semanticTests/smoke/alignment.sol index 143473461..80c69bb43 100644 --- a/test/libsolidity/semanticTests/smoke/alignment.sol +++ b/test/libsolidity/semanticTests/smoke/alignment.sol @@ -27,5 +27,5 @@ contract D { // stateDecimal() -> right(42) // stateBytes() -> left(0x4200ef) // internalStateDecimal() -> 0x20 -// gas legacy: 101807 +// gas legacy: 101679 // update(bool,uint256,bytes32): false, -23, left(0x2300ef) -> false, -23, left(0x2300ef) diff --git a/test/libsolidity/semanticTests/various/code_access_content.sol b/test/libsolidity/semanticTests/various/code_access_content.sol index 3f8d56587..39ac71b54 100644 --- a/test/libsolidity/semanticTests/various/code_access_content.sol +++ b/test/libsolidity/semanticTests/various/code_access_content.sol @@ -42,4 +42,4 @@ contract C { // testRuntime() -> true // gas legacy: 101579 // testCreation() -> true -// gas legacy: 102137 +// gas legacy: 102009 diff --git a/test/libsolidity/semanticTests/various/code_access_create.sol b/test/libsolidity/semanticTests/various/code_access_create.sol index c32135fe5..ce0d6305d 100644 --- a/test/libsolidity/semanticTests/various/code_access_create.sol +++ b/test/libsolidity/semanticTests/various/code_access_create.sol @@ -26,4 +26,4 @@ contract C { // compileViaYul: also // ---- // test() -> 7 -// gas legacy: 102392 +// gas legacy: 102264 diff --git a/test/libsolidity/semanticTests/various/external_types_in_calls.sol b/test/libsolidity/semanticTests/various/external_types_in_calls.sol index 229e93fc1..1b50465b4 100644 --- a/test/libsolidity/semanticTests/various/external_types_in_calls.sol +++ b/test/libsolidity/semanticTests/various/external_types_in_calls.sol @@ -27,5 +27,5 @@ contract C { // compileViaYul: also // ---- // test() -> 9, 7 -// gas legacy: 130016 +// gas legacy: 129760 // t2() -> 9 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol index 8ef472136..25d7b3c78 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -23,5 +23,5 @@ contract C { // ---- // g() -> 2, 6 // gas irOptimized: 178953 -// gas legacy: 180890 +// gas legacy: 180762 // gas legacyOptimized: 179609 diff --git a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol index ab6d6e59a..cc910826b 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol @@ -36,12 +36,12 @@ contract D { // compileViaYul: also // ---- // f() -> 0x1 # This should work, next should throw # -// gas legacy: 103844 +// gas legacy: 103716 // fview() -> FAILURE // gas irOptimized: 98438627 -// gas legacy: 98438803 +// gas legacy: 98438801 // gas legacyOptimized: 98438596 // fpure() -> FAILURE // gas irOptimized: 98438627 -// gas legacy: 98438803 +// gas legacy: 98438801 // gas legacyOptimized: 98438597 From 31c504c5baa24898f71790e42f4a626c15dca3a1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 28 Oct 2021 12:35:06 +0200 Subject: [PATCH 2/4] Add test for extcodesize check. --- .../external_call_at_construction_time.sol | 28 +++++++++++++ .../external_call_to_nonexisting.sol | 36 +++++++++++++++++ ...ernal_call_to_nonexisting_debugstrings.sol | 39 +++++++++++++++++++ .../precompile_extcodesize_check.sol | 11 +++++- 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol create mode 100644 test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol create mode 100644 test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol diff --git a/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol b/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol new file mode 100644 index 000000000..d5b0d0974 --- /dev/null +++ b/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol @@ -0,0 +1,28 @@ +pragma solidity >= 0.6.0; + +// This tests skipping the extcodesize check. + +contract T { + constructor() { this.f(); } + function f() external {} +} +contract U { + constructor() { this.f(); } + function f() external returns (uint) {} +} + +contract C { + function f(uint c) external returns (uint) { + if (c == 0) new T(); + else if (c == 1) new U(); + return 1 + c; + } +} + +// ==== +// EVMVersion: >=byzantium +// compileViaYul: also +// ---- +// f(uint256): 0 -> FAILURE +// f(uint256): 1 -> FAILURE +// f(uint256): 2 -> 3 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol new file mode 100644 index 000000000..9546f1098 --- /dev/null +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol @@ -0,0 +1,36 @@ +// This tests skipping the extcodesize check. + +interface I { + function a() external pure; + function b() external; + function c() external payable; + function x() external returns (uint); + function y() external returns (string memory); +} +contract C { + I i = I(address(0xcafecafe)); + constructor() payable {} + function f(uint c) external returns (uint) { + if (c == 0) i.a(); + else if (c == 1) i.b(); + else if (c == 2) i.c(); + else if (c == 3) i.c{value: 1}(); + else if (c == 4) i.x(); + else if (c == 5) i.y(); + return 1 + c; + } +} + +// ==== +// compileViaYul: also +// ---- +// constructor(), 1 ether -> +// gas legacy: 465314 +// gas legacyOptimized: 510004 +// f(uint256): 0 -> FAILURE +// f(uint256): 1 -> FAILURE +// f(uint256): 2 -> FAILURE +// f(uint256): 3 -> FAILURE +// f(uint256): 4 -> FAILURE +// f(uint256): 5 -> FAILURE +// f(uint256): 6 -> 7 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol new file mode 100644 index 000000000..ca635d310 --- /dev/null +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol @@ -0,0 +1,39 @@ +pragma solidity >= 0.6.0; + +// This tests skipping the extcodesize check. + +interface I { + function a() external pure; + function b() external; + function c() external payable; + function x() external returns (uint); + function y() external returns (string memory); +} +contract C { + I i = I(address(0xcafecafe)); + constructor() payable {} + function f(uint c) external returns (uint) { + if (c == 0) i.a(); + else if (c == 1) i.b(); + else if (c == 2) i.c(); + else if (c == 3) i.c{value: 1}(); + else if (c == 4) i.x(); + else if (c == 5) i.y(); + return 1 + c; + } +} + +// ==== +// EVMVersion: >=byzantium +// compileViaYul: also +// revertStrings: debug +// ---- +// constructor(), 1 ether -> +// gas legacyOptimized: 510004 +// f(uint256): 0 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" +// f(uint256): 1 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" +// f(uint256): 2 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" +// f(uint256): 3 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" +// f(uint256): 4 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" +// f(uint256): 5 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" +// f(uint256): 6 -> 7 diff --git a/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol b/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol index 7a9025e26..c07adb909 100644 --- a/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol +++ b/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol @@ -1,13 +1,21 @@ interface Identity { function selectorAndAppendValue(uint value) external pure returns (uint); } +interface ReturnMoreData { + function f(uint value) external pure returns (uint, uint, uint); +} contract C { Identity constant i = Identity(address(0x0004)); function testHighLevel() external pure returns (bool) { - // Should fail because `extcodesize(4) = 0` + // Works because the extcodesize check is skipped + // and the precompiled contract returns actual data. i.selectorAndAppendValue(5); return true; } + function testHighLevel2() external pure returns (uint, uint, uint) { + // Fails because the identity contract does not return enough data. + return ReturnMoreData(address(4)).f(2); + } function testLowLevel() external view returns (uint value) { (bool success, bytes memory ret) = address(4).staticcall( @@ -23,3 +31,4 @@ contract C { // ---- // testHighLevel() -> FAILURE // testLowLevel() -> 0xc76596d400000000000000000000000000000000000000000000000000000000 +// testHighLevel2() -> FAILURE From f320a95dd9be698df9fa7a3c12a7efc1a22a1521 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 2 Nov 2021 12:04:31 +0100 Subject: [PATCH 3/4] Update documentation. --- docs/control-structures.rst | 11 ++++++++++- docs/introduction-to-smart-contracts.rst | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 49e66537d..84b65918d 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -114,10 +114,19 @@ otherwise, the ``value`` option would not be available. Due to the fact that the EVM considers a call to a non-existing contract to always succeed, Solidity uses the ``extcodesize`` opcode to check that the contract that is about to be called actually exists (it contains code) -and causes an exception if it does not. +and causes an exception if it does not. This check is skipped if the return +data will be decoded after the call and thus the ABI decoder will catch the +case of a non-existing contract. + Note that this check is not performed in case of :ref:`low-level calls ` which operate on addresses rather than contract instances. +.. note:: + Be careful when using high-level calls to + :ref:`precompiled contracts `, + since the compiler considers them non-existing according to the + above logic even though they execute code and can return data. + Function calls also cause exceptions if the called contract itself throws an exception or goes out of gas. diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index c22d4e6fa..d19a0decf 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -565,3 +565,24 @@ contracts, the Ether is forever lost. If you want to deactivate your contracts, you should instead **disable** them by changing some internal state which causes all functions to revert. This makes it impossible to use the contract, as it returns Ether immediately. + + +.. index:: ! precompiled contracts, ! precompiles, ! contract;precompiled + +.. _precompiledContracts: + +Precompiled Contracts +===================== + +There is a small set of contract addresses that are special: +The address range between ``1`` and (including) ``8`` contains +"precompiled contracts" that can be called as any other contract +but their behaviour (and their gas consumption) is not defined +by EVM code stored at that address (they do not contain code) +but instead is implemented in the EVM execution environment itself. + +Different EVM-compatible chains might use a different set of +precompiled contracts. It might also be possible that new +precompiled contracts are added to the Ethereum main chain in the future, +but you can reasonabyly expect them to always be in the range between +``1`` and ``0xffff`` (inclusive). \ No newline at end of file From 080c7245aebdb4e7ab1d2b2f3a6194244eda976f Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 4 Nov 2021 18:20:10 +0100 Subject: [PATCH 4/4] Update tests. --- .../output.json | 312 +++--------------- .../abi_encode_calldata_slice.sol | 8 +- .../struct/struct_storage_ptr.sol | 4 +- .../abi_encode_calldata_slice.sol | 8 +- ...2_in_function_inherited_in_v1_contract.sol | 4 +- ...ode_v2_in_modifier_used_in_v1_contract.sol | 2 +- .../abiEncoderV2/calldata_array.sol | 4 +- .../array/fixed_arrays_as_return_type.sol | 4 +- .../array/function_array_cross_calls.sol | 4 +- .../semanticTests/array/reusing_memory.sol | 4 +- .../constructor/arrays_in_constructors.sol | 4 +- .../bytes_in_constructors_packer.sol | 4 +- .../external_call_at_construction_time.sol | 2 - ...ernal_call_to_nonexisting_debugstrings.sol | 2 - .../functionCall/failed_create.sol | 8 +- .../precompile_extcodesize_check.sol | 4 +- .../functionTypes/store_function.sol | 4 +- .../immutable/multi_creation.sol | 4 +- .../address_overload_resolution.sol | 4 +- ...d_function_calldata_calldata_interface.sol | 2 +- ...ted_function_calldata_memory_interface.sol | 4 +- .../interface_inheritance_conversions.sol | 6 +- .../salted_create_with_value.sol | 4 +- .../skip_dynamic_types_for_structs.sol | 4 +- .../various/staticcall_for_view_and_pure.sol | 8 +- 25 files changed, 95 insertions(+), 323 deletions(-) diff --git a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json index 773637b32..1c3999afc 100644 --- a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json @@ -285,40 +285,18 @@ sub_0: assembly { dup2 dup2 sstore - /* \"C\":403:407 this */ - address - /* \"C\":403:411 this.f() */ - extcodesize - tag_40 - jumpi - /* \"C\":79:428 contract C... */ - dup2 - dup3 - revert - /* \"C\":403:411 this.f() */ - tag_40: - /* \"C\":79:428 contract C... */ - /* \"C\":403:407 this */ - address - /* \"C\":403:411 this.f() */ - extcodesize - iszero - tag_43 - jumpi - /* \"C\":79:428 contract C... */ mload(0x40) shl(0xe4, 0x026121ff) /* \"C\":403:411 this.f() */ dup2 mstore 0x20 - /* \"C\":79:428 contract C... */ + /* \"C\":403:407 this */ dup2 /* \"C\":403:411 this.f() */ 0x04 - /* \"C\":79:428 contract C... */ - dup2 /* \"C\":403:407 this */ + dup2 address /* \"C\":403:411 this.f() */ gas @@ -326,55 +304,43 @@ sub_0: assembly { swap2 dup3 iszero - tag_45 + tag_43 jumpi dup1 - tag_41 - tag_40 swap3 - tag_47 + tag_45 jumpi /* \"C\":304:341 modifier m()... */ - tag_48: + tag_46: /* \"C\":392:411 stateVar + this.f() */ pop pop - tag_49 + tag_47 swap1 /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_50 + tag_48 /* \"C\":392:411 stateVar + this.f() */ swap3 tag_5 jump\t// in - tag_49: + tag_47: /* \"C\":414:422 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") /* \"C\":392:422 stateVar + this.f() + immutVar */ swap1 tag_5 jump\t// in - tag_50: + tag_48: /* \"C\":304:341 modifier m()... */ swap1 jump\t// out /* \"C\":403:411 this.f() */ - tag_41: - tag_40: - tag_47: + tag_45: /* \"C\":79:428 contract C... */ swap1 swap2 pop /* \"C\":403:411 this.f() */ - dup2 - iszero - tag_42 - jumpi - dup2 - iszero - tag_41 - jumpi returndatasize /* \"C\":79:428 contract C... */ 0x1f @@ -391,73 +357,39 @@ sub_0: assembly { dup4 lt or - iszero - tag_43 - iszero - tag_42 - tag_51 + tag_49 jumpi pop swap2 /* \"C\":403:411 this.f() */ - tag_53 + tag_51 /* \"C\":392:411 stateVar + this.f() */ - tag_49 + tag_47 /* \"C\":79:428 contract C... */ swap3 /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_50 + tag_48 /* \"C\":79:428 contract C... */ - mstore - 0x24 - dup7 - revert - tag_43: - mstore - 0x24 - dup7 - revert - tag_42: swap5 0x40 mstore /* \"C\":403:411 this.f() */ - tag_44 - tag_43 returndatasize dup2 add swap1 tag_7 jump\t// in - tag_44: - swap1 - tag_43: - swap1 - tag_53: + tag_51: swap2 dup2 swap4 pop - tag_42: - /* \"C\":392:411 stateVar + this.f() */ - tag_45 - tag_41: - /* \"C\":392:411 stateVar + this.f() */ - tag_44 - jump(tag_48) + jump(tag_46) /* \"C\":79:428 contract C... */ - tag_51: + tag_49: shl(0xe0, 0x4e487b71) dup2 - dup6 - tag_5 - jump\t// in - tag_45: - dup6 - tag_5 - jump\t// in - tag_44: mstore 0x41 /* \"C\":403:411 this.f() */ @@ -475,53 +407,27 @@ sub_0: assembly { /* \"C\":79:428 contract C... */ revert /* \"C\":403:411 this.f() */ - tag_45: + tag_43: /* \"C\":79:428 contract C... */ swap4 pop pop pop - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_46 - /* \"C\":414:422 immutVar */ - immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":392:422 stateVar + this.f() + immutVar */ - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_45 - /* \"C\":414:422 immutVar */ - immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":392:422 stateVar + this.f() + immutVar */ pop mload(0x40) swap1 returndatasize swap1 dup3 - tag_5 - jump\t// in - tag_46: - /* \"C\":336:337 _ */ - tag_5 - jump\t// in - tag_45: - /* \"C\":336:337 _ */ returndatacopy returndatasize swap1 - revert - /* \"C\":403:411 this.f() */ - tag_43: - /* \"C\":79:428 contract C... */ - swap2 - pop - pop - dup1 revert tag_41: - tag_54 + tag_52 tag_3 jump\t// in - tag_54: + tag_52: jump(tag_42) tag_7: swap1 @@ -530,35 +436,17 @@ sub_0: assembly { swap2 sub slt - iszero - tag_48 - iszero - tag_47 - tag_55 + tag_53 jumpi mload swap1 jump\t// out - tag_55: + tag_53: pop pop 0x00 dup1 revert - tag_48: - pop - mload - swap2 - swap1 - pop - jump\t// out - tag_47: - pop - mload - swap2 - swap1 - pop - jump\t// out auxdata: } @@ -890,40 +778,18 @@ sub_0: assembly { dup2 dup2 sstore - /* \"C\":403:407 this */ - address - /* \"C\":403:411 this.f() */ - extcodesize - tag_40 - jumpi - /* \"D\":91:166 contract D is C(3)... */ - dup2 - dup3 - revert - /* \"C\":403:411 this.f() */ - tag_40: - /* \"D\":91:166 contract D is C(3)... */ - /* \"C\":403:407 this */ - address - /* \"C\":403:411 this.f() */ - extcodesize - iszero - tag_43 - jumpi - /* \"D\":91:166 contract D is C(3)... */ mload(0x40) shl(0xe4, 0x026121ff) /* \"C\":403:411 this.f() */ dup2 mstore 0x20 - /* \"D\":91:166 contract D is C(3)... */ + /* \"C\":403:407 this */ dup2 /* \"C\":403:411 this.f() */ 0x04 - /* \"D\":91:166 contract D is C(3)... */ - dup2 /* \"C\":403:407 this */ + dup2 address /* \"C\":403:411 this.f() */ gas @@ -931,55 +797,43 @@ sub_0: assembly { swap2 dup3 iszero - tag_45 + tag_43 jumpi dup1 - tag_41 - tag_40 swap3 - tag_47 + tag_45 jumpi /* \"C\":304:341 modifier m()... */ - tag_48: + tag_46: /* \"C\":392:411 stateVar + this.f() */ pop pop - tag_49 + tag_47 swap1 /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_50 + tag_48 /* \"C\":392:411 stateVar + this.f() */ swap3 tag_5 jump\t// in - tag_49: + tag_47: /* \"C\":414:422 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") /* \"C\":392:422 stateVar + this.f() + immutVar */ swap1 tag_5 jump\t// in - tag_50: + tag_48: /* \"C\":304:341 modifier m()... */ swap1 jump\t// out /* \"C\":403:411 this.f() */ - tag_41: - tag_40: - tag_47: + tag_45: /* \"D\":91:166 contract D is C(3)... */ swap1 swap2 pop /* \"C\":403:411 this.f() */ - dup2 - iszero - tag_42 - jumpi - dup2 - iszero - tag_41 - jumpi returndatasize /* \"D\":91:166 contract D is C(3)... */ 0x1f @@ -996,73 +850,39 @@ sub_0: assembly { dup4 lt or - iszero - tag_43 - iszero - tag_42 - tag_51 + tag_49 jumpi pop swap2 /* \"C\":403:411 this.f() */ - tag_53 + tag_51 /* \"C\":392:411 stateVar + this.f() */ - tag_49 + tag_47 /* \"D\":91:166 contract D is C(3)... */ swap3 /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_50 + tag_48 /* \"D\":91:166 contract D is C(3)... */ - mstore - 0x24 - dup7 - revert - tag_43: - mstore - 0x24 - dup7 - revert - tag_42: swap5 0x40 mstore /* \"C\":403:411 this.f() */ - tag_44 - tag_43 returndatasize dup2 add swap1 tag_7 jump\t// in - tag_44: - swap1 - tag_43: - swap1 - tag_53: + tag_51: swap2 dup2 swap4 pop - tag_42: - /* \"C\":392:411 stateVar + this.f() */ - tag_45 - tag_41: - /* \"C\":392:411 stateVar + this.f() */ - tag_44 - jump(tag_48) + jump(tag_46) /* \"D\":91:166 contract D is C(3)... */ - tag_51: + tag_49: shl(0xe0, 0x4e487b71) dup2 - dup6 - tag_5 - jump\t// in - tag_45: - dup6 - tag_5 - jump\t// in - tag_44: mstore 0x41 /* \"C\":403:411 this.f() */ @@ -1080,21 +900,11 @@ sub_0: assembly { /* \"D\":91:166 contract D is C(3)... */ revert /* \"C\":403:411 this.f() */ - tag_45: + tag_43: /* \"D\":91:166 contract D is C(3)... */ swap4 pop pop - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_46 - /* \"C\":414:422 immutVar */ - immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":392:422 stateVar + this.f() + immutVar */ - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_45 - /* \"C\":414:422 immutVar */ - immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":392:422 stateVar + this.f() + immutVar */ pop pop mload(0x40) @@ -1102,31 +912,15 @@ sub_0: assembly { returndatasize swap1 dup3 - tag_5 - jump\t// in - tag_46: - /* \"C\":336:337 _ */ - tag_5 - jump\t// in - tag_45: - /* \"C\":336:337 _ */ returndatacopy returndatasize swap1 - revert - /* \"C\":403:411 this.f() */ - tag_43: - /* \"D\":91:166 contract D is C(3)... */ - swap2 - pop - pop - dup1 revert tag_41: - tag_54 + tag_52 tag_3 jump\t// in - tag_54: + tag_52: jump(tag_42) tag_7: swap1 @@ -1135,35 +929,17 @@ sub_0: assembly { swap2 sub slt - iszero - tag_48 - iszero - tag_47 - tag_55 + tag_53 jumpi mload swap1 jump\t// out - tag_55: + tag_53: pop pop 0x00 dup1 revert - tag_48: - pop - mload - swap2 - swap1 - pop - jump\t// out - tag_47: - pop - mload - swap2 - swap1 - pop - jump\t// out auxdata: } diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index 947f5cb23..e54c39d32 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -60,10 +60,10 @@ contract C { // compileViaYul: also // ---- // test_bytes() -> -// gas irOptimized: 377545 +// gas irOptimized: 373483 // gas legacy: 418955 -// gas legacyOptimized: 331391 +// gas legacyOptimized: 326783 // test_uint256() -> -// gas irOptimized: 528726 +// gas irOptimized: 524664 // gas legacy: 586784 -// gas legacyOptimized: 456137 +// gas legacyOptimized: 451529 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index 886d9dfd9..19d9b1b9a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -26,6 +26,6 @@ contract C { // ---- // library: L // f() -> 8, 7, 1, 2, 7, 12 -// gas irOptimized: 167580 +// gas irOptimized: 167446 // gas legacy: 169347 -// gas legacyOptimized: 167397 +// gas legacyOptimized: 167269 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index f75eecfb5..53aeb8949 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -61,10 +61,10 @@ contract C { // compileViaYul: also // ---- // test_bytes() -> -// gas irOptimized: 377545 +// gas irOptimized: 373483 // gas legacy: 418955 -// gas legacyOptimized: 331391 +// gas legacyOptimized: 326783 // test_uint256() -> -// gas irOptimized: 528726 +// gas irOptimized: 524664 // gas legacy: 586784 -// gas legacyOptimized: 456137 +// gas legacyOptimized: 451529 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol index 49b93cbbc..953fa7945 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol @@ -32,6 +32,6 @@ contract C is B { // compileViaYul: also // ---- // test() -> 77 -// gas irOptimized: 120044 +// gas irOptimized: 119931 // gas legacy: 155093 -// gas legacyOptimized: 111678 +// gas legacyOptimized: 111550 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol index 28658089a..153118355 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol @@ -40,5 +40,5 @@ contract C is B { // compileViaYul: also // ---- // test() -> 5, 10 -// gas irOptimized: 87578 +// gas irOptimized: 87337 // gas legacy: 98881 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index 131430aa5..11fccbb61 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -21,6 +21,6 @@ contract C { // f(uint256[][1]): 32, 32, 0 -> true // f(uint256[][1]): 32, 32, 1, 42 -> true // f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true -// gas irOptimized: 172204 +// gas irOptimized: 171964 // gas legacy: 141644 -// gas legacyOptimized: 121788 +// gas legacyOptimized: 121532 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol index 063e0bf9c..3b0a73d00 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -21,6 +21,6 @@ contract B { // compileViaYul: also // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 -// gas irOptimized: 130328 +// gas irOptimized: 130097 // gas legacy: 234943 -// gas legacyOptimized: 133119 +// gas legacyOptimized: 132863 diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index 6edae7198..9c78c1207 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -45,6 +45,6 @@ contract C { // compileViaYul: also // ---- // test() -> 5, 6, 7 -// gas irOptimized: 302321 +// gas irOptimized: 290947 // gas legacy: 452172 -// gas legacyOptimized: 294938 +// gas legacyOptimized: 285017 diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index a8a534b92..ee1a57b1e 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -26,6 +26,6 @@ contract Main { // compileViaYul: also // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 -// gas irOptimized: 113776 +// gas irOptimized: 113581 // gas legacy: 126596 -// gas legacyOptimized: 114079 +// gas legacyOptimized: 113823 diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index 7016e6c6e..7885b24a3 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -26,6 +26,6 @@ contract Creator { // compileViaYul: also // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 -// gas irOptimized: 456873 +// gas irOptimized: 456668 // gas legacy: 590683 -// gas legacyOptimized: 448582 +// gas legacyOptimized: 448326 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index 1aba4c7c4..434b926fc 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -26,6 +26,6 @@ contract Creator { // compileViaYul: also // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" -// gas irOptimized: 308702 +// gas irOptimized: 308497 // gas legacy: 428917 -// gas legacyOptimized: 298384 +// gas legacyOptimized: 298128 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol b/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol index d5b0d0974..2fb2f266d 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol @@ -1,5 +1,3 @@ -pragma solidity >= 0.6.0; - // This tests skipping the extcodesize check. contract T { diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol index ca635d310..f426e628e 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol @@ -1,5 +1,3 @@ -pragma solidity >= 0.6.0; - // This tests skipping the extcodesize check. interface I { diff --git a/test/libsolidity/semanticTests/functionCall/failed_create.sol b/test/libsolidity/semanticTests/functionCall/failed_create.sol index 49c6a80a9..54cd9f06a 100644 --- a/test/libsolidity/semanticTests/functionCall/failed_create.sol +++ b/test/libsolidity/semanticTests/functionCall/failed_create.sol @@ -18,17 +18,17 @@ contract C { // compileViaYul: also // ---- // constructor(), 20 wei -// gas irOptimized: 220113 +// gas irOptimized: 218775 // gas legacy: 294569 -// gas legacyOptimized: 177933 +// gas legacyOptimized: 174699 // f(uint256): 20 -> 1370859564726510389319704988634906228201275401179 // x() -> 1 // f(uint256): 20 -> FAILURE // x() -> 1 // stack(uint256): 1023 -> FAILURE -// gas irOptimized: 345821 +// gas irOptimized: 296769 // gas legacy: 483942 -// gas legacyOptimized: 354656 +// gas legacyOptimized: 298807 // x() -> 1 // stack(uint256): 10 -> 693016686122178122849713379390321835634789309880 // x() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol b/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol index c07adb909..b82c5f9b7 100644 --- a/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol +++ b/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol @@ -26,9 +26,9 @@ contract C { } // ==== -// compileViaYul: also // EVMVersion: >=constantinople +// compileViaYul: also // ---- -// testHighLevel() -> FAILURE +// testHighLevel() -> true // testLowLevel() -> 0xc76596d400000000000000000000000000000000000000000000000000000000 // testHighLevel2() -> FAILURE diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index 9200bd120..dab82918a 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -28,6 +28,6 @@ contract C { // compileViaYul: also // ---- // t() -> 9 -// gas irOptimized: 99186 +// gas irOptimized: 99064 // gas legacy: 158955 -// gas legacyOptimized: 108916 +// gas legacyOptimized: 108788 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index d4300cfe1..2f74c17f5 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -29,8 +29,8 @@ contract C { // compileViaYul: also // ---- // f() -> 3, 7, 5 -// gas irOptimized: 127592 +// gas irOptimized: 127387 // gas legacy: 151334 -// gas legacyOptimized: 125422 +// gas legacyOptimized: 125166 // x() -> 7 // y() -> 5 diff --git a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol index 8c9c6195c..6a9ff7c31 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -23,8 +23,8 @@ contract D { // compileViaYul: also // ---- // f() -> 1 -// gas irOptimized: 77164 +// gas irOptimized: 77051 // gas legacy: 114884 // g() -> 5 -// gas irOptimized: 77231 +// gas irOptimized: 77106 // gas legacy: 115430 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol index 7322e5f96..ed28477b2 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -25,5 +25,5 @@ contract B { // compileViaYul: also // ---- // g() -> 42 -// gas irOptimized: 80945 +// gas irOptimized: 80813 // gas legacy: 125481 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol index 9b5f9778c..46992694e 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -25,6 +25,6 @@ contract B { // compileViaYul: also // ---- // g() -> 42 -// gas irOptimized: 111913 +// gas irOptimized: 111781 // gas legacy: 185053 -// gas legacyOptimized: 114726 +// gas legacyOptimized: 114598 diff --git a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol index 5dfeb9a69..95f831e24 100644 --- a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol @@ -37,10 +37,10 @@ contract C { // compileViaYul: also // ---- // convertParent() -> 1 -// gas irOptimized: 85640 +// gas irOptimized: 85524 // convertSubA() -> 1, 2 -// gas irOptimized: 86395 +// gas irOptimized: 86155 // gas legacy: 99047 // convertSubB() -> 1, 3 -// gas irOptimized: 86338 +// gas irOptimized: 86098 // gas legacy: 98981 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 2d1070e2a..e8fe01687 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -22,6 +22,6 @@ contract A { // compileViaYul: also // ---- // f(), 10 ether -> 3007, 3008, 3009 -// gas irOptimized: 273275 +// gas irOptimized: 272947 // gas legacy: 422501 -// gas legacyOptimized: 287856 +// gas legacyOptimized: 287472 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol index 25d7b3c78..cad181c8f 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -22,6 +22,6 @@ contract C { // compileViaYul: also // ---- // g() -> 2, 6 -// gas irOptimized: 178953 +// gas irOptimized: 178835 // gas legacy: 180762 -// gas legacyOptimized: 179609 +// gas legacyOptimized: 179481 diff --git a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol index cc910826b..1950f7a4d 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol @@ -38,10 +38,10 @@ contract D { // f() -> 0x1 # This should work, next should throw # // gas legacy: 103716 // fview() -> FAILURE -// gas irOptimized: 98438627 +// gas irOptimized: 98438625 // gas legacy: 98438801 -// gas legacyOptimized: 98438596 +// gas legacyOptimized: 98438594 // fpure() -> FAILURE -// gas irOptimized: 98438627 +// gas irOptimized: 98438626 // gas legacy: 98438801 -// gas legacyOptimized: 98438597 +// gas legacyOptimized: 98438595