Merge pull request #10863 from ethereum/isoltestGasCosts

[isoltest] Add gas costs to function call expectations
This commit is contained in:
chriseth 2021-03-10 15:11:20 +01:00 committed by GitHub
commit 89946b15d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
147 changed files with 845 additions and 177 deletions

View File

@ -69,8 +69,10 @@ do
# run tests against hera ewasm evmc vm, only if OPTIMIZE == 0 and evm version is byzantium
EWASM_ARGS=""
[ "${EVM}" = "byzantium" ] && [ "${OPTIMIZE}" = "0" ] && EWASM_ARGS="--ewasm"
ENFORCE_GAS_ARGS=""
[ "${EVM}" = "istanbul" ] && ENFORCE_GAS_ARGS="--enforce-gas-cost"
[[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" SOLTEST_FLAGS="$SOLTEST_FLAGS $EWASM_ARGS" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh"
[[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" SOLTEST_FLAGS="$SOLTEST_FLAGS $ENFORCE_GAS_ARGS $EWASM_ARGS" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh"
STEP=$((STEP + 1))
done
done

View File

@ -103,6 +103,8 @@ CommonOptions::CommonOptions(std::string _caption):
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker")
("optimize", po::bool_switch(&optimize), "enables optimization")
("enforce-via-yul", po::bool_switch(&enforceViaYul), "Enforce compiling all tests via yul to see if additional tests can be activated.")
("enforce-gas-cost", po::bool_switch(&enforceGasTest), "Enforce checking gas cost in semantic tests.")
("enforce-gas-cost-min-value", po::value(&enforceGasTestMinValue), "Threshold value to enforce adding gas checks to a test.")
("abiencoderv1", po::bool_switch(&useABIEncoderV1), "enables abi encoder v1")
("show-messages", po::bool_switch(&showMessages), "enables message output")
("show-metadata", po::bool_switch(&showMetadata), "enables metadata output");
@ -120,7 +122,19 @@ void CommonOptions::validate() const
ConfigException,
"Invalid test path specified."
);
if (enforceGasTest)
{
assertThrow(
evmVersion() == langutil::EVMVersion{},
ConfigException,
"Gas costs can only be enforced on latest evm version."
);
assertThrow(
useABIEncoderV1 == false,
ConfigException,
"Gas costs can only be enforced on abi encoder v2."
);
}
}
bool CommonOptions::parse(int argc, char const* const* argv)

View File

@ -56,6 +56,8 @@ struct CommonOptions: boost::noncopyable
bool ewasm = false;
bool optimize = false;
bool enforceViaYul = false;
bool enforceGasTest = false;
u256 enforceGasTestMinValue = 100000;
bool disableSMT = false;
bool useABIEncoderV1 = false;
bool showMessages = false;

View File

@ -40,7 +40,9 @@ public:
std::string filename;
langutil::EVMVersion evmVersion;
std::vector<boost::filesystem::path> vmPaths;
bool enforceCompileViaYul;
bool enforceCompileViaYul = false;
bool enforceGasCost = false;
u256 enforceGasCostMinValue;
};
enum class TestResult { Success, Failure, FatalError };

View File

@ -71,7 +71,14 @@ int registerTests(
{
int numTestsAdded = 0;
fs::path fullpath = _basepath / _path;
TestCase::Config config{fullpath.string(), solidity::test::CommonOptions::get().evmVersion(), solidity::test::CommonOptions::get().vmPaths, _enforceViaYul};
TestCase::Config config{
fullpath.string(),
solidity::test::CommonOptions::get().evmVersion(),
solidity::test::CommonOptions::get().vmPaths,
_enforceViaYul,
solidity::test::CommonOptions::get().enforceGasTest,
solidity::test::CommonOptions::get().enforceGasTestMinValue
};
if (fs::is_directory(fullpath))
{
test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string());

View File

@ -45,12 +45,21 @@ using namespace boost::unit_test;
namespace fs = boost::filesystem;
SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVersion, vector<boost::filesystem::path> const& _vmPaths, bool enforceViaYul):
SemanticTest::SemanticTest(
string const& _filename,
langutil::EVMVersion _evmVersion,
vector<boost::filesystem::path> const& _vmPaths,
bool _enforceViaYul,
bool _enforceGasCost,
u256 _enforceGasCostMinValue
):
SolidityExecutionFramework(_evmVersion, _vmPaths),
EVMVersionRestrictedTestCase(_filename),
m_sources(m_reader.sources()),
m_lineOffset(m_reader.lineNumber()),
m_enforceViaYul(enforceViaYul)
m_enforceViaYul(_enforceViaYul),
m_enforceGasCost(_enforceGasCost),
m_enforceGasCostMinValue(_enforceGasCostMinValue)
{
string choice = m_reader.stringSetting("compileViaYul", "default");
if (choice == "also")
@ -105,6 +114,12 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer
parseExpectations(m_reader.stream());
soltestAssert(!m_tests.empty(), "No tests specified in " + _filename);
if (m_enforceGasCost)
{
m_compiler.setMetadataFormat(CompilerStack::MetadataFormat::NoMetadata);
m_compiler.setMetadataHash(CompilerStack::MetadataHash::None);
}
}
TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
@ -133,6 +148,7 @@ TestCase::TestResult SemanticTest::runTest(
)
{
bool success = true;
m_gasCostFailure = false;
if (_compileViaYul && _compileToEwasm)
selectVM(evmc_capabilities::EVMC_CAPABILITY_EWASM);
@ -203,6 +219,8 @@ TestCase::TestResult SemanticTest::runTest(
{
if (m_transactionSuccessful == test.call().expectations.failure)
success = false;
if (success && !checkGasCostExpectation(test, _compileViaYul))
m_gasCostFailure = true;
test.setFailure(!m_transactionSuccessful);
test.setRawBytes(bytes());
@ -239,6 +257,12 @@ TestCase::TestResult SemanticTest::runTest(
}
bool outputMismatch = (output != test.call().expectations.rawBytes());
if (!outputMismatch && !checkGasCostExpectation(test, _compileViaYul))
{
success = false;
m_gasCostFailure = true;
}
// Pre byzantium, it was not possible to return failure data, so we disregard
// output mismatch for those EVM versions.
if (test.call().expectations.failure && !m_transactionSuccessful && !m_evmVersion.supportsReturndata())
@ -270,7 +294,13 @@ TestCase::TestResult SemanticTest::runTest(
for (TestFunctionCall const& test: m_tests)
{
ErrorReporter errorReporter;
_stream << test.format(errorReporter, _linePrefix, false, _formatted) << endl;
_stream << test.format(
errorReporter,
_linePrefix,
TestFunctionCall::RenderMode::ExpectedValuesExpectedGas,
_formatted,
/* _interactivePrint */ true
) << endl;
_stream << errorReporter.format(_linePrefix, _formatted);
}
_stream << endl;
@ -278,7 +308,13 @@ TestCase::TestResult SemanticTest::runTest(
for (TestFunctionCall const& test: m_tests)
{
ErrorReporter errorReporter;
_stream << test.format(errorReporter, _linePrefix, true, _formatted) << endl;
_stream << test.format(
errorReporter,
_linePrefix,
m_gasCostFailure ? TestFunctionCall::RenderMode::ExpectedValuesActualGas : TestFunctionCall::RenderMode::ActualValuesExpectedGas,
_formatted,
/* _interactivePrint */ true
) << endl;
_stream << errorReporter.format(_linePrefix, _formatted);
}
AnsiColorized(_stream, _formatted, {BOLD, RED})
@ -300,6 +336,33 @@ TestCase::TestResult SemanticTest::runTest(
return TestResult::Success;
}
bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const
{
string setting =
(_compileViaYul ? "ir"s : "legacy"s) +
(m_optimiserSettings == OptimiserSettings::full() ? "Optimized" : "");
// We don't check gas if enforce gas cost is not active
// or test is run with abi encoder v1 only
// or gas used less than threshold for enforcing feature
// or setting is "ir" and it's not included in expectations
if (
!m_enforceGasCost ||
(
(setting == "ir" || m_gasUsed < m_enforceGasCostMinValue || m_gasUsed >= m_gas) &&
io_test.call().expectations.gasUsed.count(setting) == 0
)
)
return true;
solAssert(!m_runWithABIEncoderV1Only, "");
io_test.setGasCost(setting, m_gasUsed);
return
io_test.call().expectations.gasUsed.count(setting) > 0 &&
m_gasUsed == io_test.call().expectations.gasUsed.at(setting);
}
void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const
{
if (m_sources.sources.empty())
@ -347,7 +410,11 @@ void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool
void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) const
{
for (TestFunctionCall const& test: m_tests)
_stream << test.format("", true, false) << endl;
_stream << test.format(
"",
m_gasCostFailure ? TestFunctionCall::RenderMode::ExpectedValuesActualGas : TestFunctionCall::RenderMode::ActualValuesExpectedGas,
/* _highlight = */ false
) << endl;
}
void SemanticTest::printUpdatedSettings(ostream& _stream, string const& _linePrefix)

View File

@ -40,9 +40,25 @@ class SemanticTest: public SolidityExecutionFramework, public EVMVersionRestrict
{
public:
static std::unique_ptr<TestCase> create(Config const& _options)
{ return std::make_unique<SemanticTest>(_options.filename, _options.evmVersion, _options.vmPaths, _options.enforceCompileViaYul); }
{
return std::make_unique<SemanticTest>(
_options.filename,
_options.evmVersion,
_options.vmPaths,
_options.enforceCompileViaYul,
_options.enforceGasCost,
_options.enforceGasCostMinValue
);
}
explicit SemanticTest(std::string const& _filename, langutil::EVMVersion _evmVersion, std::vector<boost::filesystem::path> const& _vmPaths, bool _enforceViaYul = false);
explicit SemanticTest(
std::string const& _filename,
langutil::EVMVersion _evmVersion,
std::vector<boost::filesystem::path> const& _vmPaths,
bool _enforceViaYul = false,
bool _enforceGasCost = false,
u256 _enforceGasCostMinValue = 100000
);
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
void printSource(std::ostream &_stream, std::string const& _linePrefix = "", bool _formatted = false) const override;
@ -61,6 +77,7 @@ public:
private:
TestResult runTest(std::ostream& _stream, std::string const& _linePrefix, bool _formatted, bool _compileViaYul, bool _compileToEwasm);
bool checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const;
SourceMap m_sources;
std::size_t m_lineOffset;
std::vector<TestFunctionCall> m_tests;
@ -72,6 +89,10 @@ private:
bool m_allowNonExistingFunctions = false;
bool m_compileViaYulCanBeSet = false;
std::map<std::string, Builtin> m_builtins{};
bool m_gasCostFailure = false;
bool m_enforceGasCost = false;
u256 m_enforceGasCostMinValue;
};
}

View File

@ -24,3 +24,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb
// gas irOptimized: 194189
// gas legacy: 196426
// gas legacyOptimized: 193424

View File

@ -56,8 +56,14 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// compileViaYul: also
// ----
// test_bytes() ->
// gas irOptimized: 516922
// gas legacy: 466763
// gas legacyOptimized: 374537
// test_uint256() ->
// gas irOptimized: 712790
// gas legacy: 634592
// gas legacyOptimized: 499481

View File

@ -26,3 +26,6 @@ contract C {
// ----
// library: L
// f() -> 8, 7, 1, 2, 7, 12
// gas irOptimized: 172153
// gas legacy: 164775
// gas legacyOptimized: 162697

View File

@ -57,8 +57,14 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// compileViaYul: also
// ----
// test_bytes() ->
// gas irOptimized: 516922
// gas legacy: 466763
// gas legacyOptimized: 374537
// test_uint256() ->
// gas irOptimized: 712790
// gas legacy: 634592
// gas legacyOptimized: 499481

View File

@ -53,3 +53,6 @@ contract C {
// f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
// f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
// f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3
// gas irOptimized: 110858
// gas legacy: 111328
// gas legacyOptimized: 109206

View File

@ -30,3 +30,6 @@ contract C is B {
// compileViaYul: also
// ----
// test() -> 77
// gas irOptimized: 139834
// gas legacy: 156573
// gas legacyOptimized: 112983

View File

@ -38,3 +38,4 @@ contract C is B {
// compileViaYul: also
// ----
// test() -> 5, 10
// gas legacy: 100441

View File

@ -15,9 +15,12 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// compileViaYul: also
// ----
// 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: 227663
// gas legacy: 144300
// gas legacyOptimized: 124199

View File

@ -15,8 +15,14 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// compileViaYul: also
// ----
// h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324
// gas irOptimized: 172714
// gas legacy: 175929
// gas legacyOptimized: 172506
// i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224
// gas irOptimized: 107681
// gas legacy: 109868
// gas legacyOptimized: 107388

View File

@ -11,3 +11,6 @@ contract C {
// compileViaYul: also
// ----
// f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg"
// gas irOptimized: 130305
// gas legacy: 131690
// gas legacyOptimized: 130574

View File

@ -18,3 +18,4 @@ contract D {
// ----
// f() -> FAILURE, hex"4e487b71", 0x11
// g(), 100 wei -> 1
// gas legacy: 101718

View File

@ -14,6 +14,9 @@ contract Test {
// compileViaYul: also
// ----
// set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06
// gas irOptimized: 200205
// gas legacy: 278685
// gas legacyOptimized: 273734
// data(uint256,uint256): 0x02, 0x02 -> 0x09
// data(uint256,uint256): 0x05, 0x01 -> 0x11
// data(uint256,uint256): 0x06, 0x00 -> FAILURE

View File

@ -43,8 +43,15 @@ contract c {
// ----
// storage: empty
// test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710
// gas legacy: 110938
// gas legacyOptimized: 109691
// storage: nonempty
// test_long() -> 67
// gas irOptimized: 134832
// gas legacy: 213590
// gas legacyOptimized: 211011
// storage: nonempty
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020
// gas legacy: 176030
// gas legacyOptimized: 173470
// storage: nonempty

View File

@ -19,3 +19,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0
// gas irOptimized: 312920
// gas legacy: 483915
// gas legacyOptimized: 478508

View File

@ -15,4 +15,7 @@ contract c {
// ----
// getLength() -> 0
// set(): 1, 2 -> true
// gas irOptimized: 103213
// gas legacy: 103126
// gas legacyOptimized: 102966
// getLength() -> 68

View File

@ -22,4 +22,7 @@ contract c {
// compileViaYul: also
// ----
// store(uint256[9],uint8[3][]): 21, 22, 23, 24, 25, 26, 27, 28, 29, 0x140, 4, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33 -> 32
// gas irOptimized: 629040
// gas legacy: 817315
// gas legacyOptimized: 816813
// retrieve() -> 9, 28, 9, 28, 4, 3, 32

View File

@ -23,3 +23,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> true
// gas irOptimized: 112029
// gas legacy: 107335
// gas legacyOptimized: 105857

View File

@ -48,3 +48,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> true
// gas irOptimized: 253583
// gas legacy: 239061
// gas legacyOptimized: 235988

View File

@ -15,3 +15,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0
// gas irOptimized: 150551
// gas legacy: 138913
// gas legacyOptimized: 137448

View File

@ -42,5 +42,11 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0
// gas irOptimized: 112032
// gas legacy: 107306
// gas legacyOptimized: 105861
// g() -> 0
// h() -> 0
// h() -> 0
// gas irOptimized: 112057
// gas legacy: 107328
// gas legacyOptimized: 105903

View File

@ -21,3 +21,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000
// gas irOptimized: 247582
// gas legacy: 276683
// gas legacyOptimized: 275534

View File

@ -37,6 +37,12 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x02000202
// gas irOptimized: 2481131
// gas legacy: 2288641
// gas legacyOptimized: 2258654
// storage: empty
// clear() -> 0, 0
// gas irOptimized: 1856788
// gas legacy: 1727169
// gas legacyOptimized: 1698931
// storage: empty

View File

@ -15,3 +15,6 @@ contract c {
// compileViaYul: also
// ----
// test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10
// gas irOptimized: 611500
// gas legacy: 604268
// gas legacyOptimized: 603690

View File

@ -19,3 +19,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 5, 4
// gas irOptimized: 235646
// gas legacy: 237001
// gas legacyOptimized: 235316

View File

@ -23,3 +23,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 3, 4
// gas irOptimized: 195485
// gas legacy: 208853
// gas legacyOptimized: 200341

View File

@ -20,3 +20,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 5, 4
// gas irOptimized: 276032
// gas legacy: 264734
// gas legacyOptimized: 263160

View File

@ -14,3 +14,4 @@ contract c {
// compileViaYul: also
// ----
// test() -> 9, 4
// gas irOptimized: 100285

View File

@ -13,3 +13,5 @@ contract C {
// compileViaYul: also
// ----
// test() -> left(0x01), left(0x02)
// gas legacy: 154001
// gas legacyOptimized: 152385

View File

@ -14,7 +14,10 @@ contract c {
}
// ====
// compileViaYul: also
// compileToEwasm: also
// compileViaYul: also
// ----
// test() -> 8, 0
// gas irOptimized: 158935
// gas legacy: 153995
// gas legacyOptimized: 153403

View File

@ -19,4 +19,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 4, 5
// gas irOptimized: 282888
// gas legacy: 255936
// gas legacyOptimized: 254359
// storage: empty

View File

@ -17,3 +17,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3
// gas irOptimized: 170704
// gas legacy: 163978
// gas legacyOptimized: 158152

View File

@ -19,3 +19,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 223456
// gas legacy: 328106
// gas legacyOptimized: 308072

View File

@ -21,3 +21,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x04000000000000000000000000000000000000000000000000, 0x0, 0x0
// gas irOptimized: 109240
// gas legacy: 116651
// gas legacyOptimized: 107000

View File

@ -21,3 +21,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x0
// gas irOptimized: 290262
// gas legacy: 309353
// gas legacyOptimized: 307699

View File

@ -21,3 +21,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x00
// gas irOptimized: 269636
// gas legacy: 269681
// gas legacyOptimized: 268753

View File

@ -38,6 +38,10 @@ contract c {
// compileViaYul: true
// ----
// test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65
// gas irOptimized: 179776
// test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65
// gas irOptimized: 155253
// test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65
// gas irOptimized: 133521
// test4(uint256[2][2]): 23, 42, 23, 42 -> 65
// gas irOptimized: 107882

View File

@ -40,6 +40,12 @@ contract Test {
// compileViaYul: also
// ----
// test() -> 24
// gas irOptimized: 217774
// gas legacy: 215533
// gas legacyOptimized: 214947
// test1() -> 3
// test2() -> 6
// test3() -> 24
// test3() -> 24
// gas irOptimized: 124684
// gas legacy: 122795
// gas legacyOptimized: 121883

View File

@ -16,4 +16,5 @@ contract C {
// ====
// compileViaYul: true
// ----
// f((uint128, uint64, uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12
// f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12
// gas irOptimized: 123327

View File

@ -18,4 +18,5 @@ contract C {
// ====
// compileViaYul: true
// ----
// f() -> 10, 11, 12
// f() -> 10, 11, 12
// gas irOptimized: 122695

View File

@ -22,4 +22,5 @@ contract C {
// ====
// compileViaYul: true
// ----
// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1
// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1
// gas irOptimized: 354585

View File

@ -26,3 +26,4 @@ contract C {
// compileViaYul: true
// ----
// f() -> 3, 3, 3, 1
// gas irOptimized: 189829

View File

@ -11,7 +11,10 @@ contract C {
}
}
// ====
// compileViaYul: also
// compileToEwasm: also
// compileViaYul: also
// ----
// f() -> 1, 2, 3
// gas irOptimized: 135092
// gas legacy: 134419
// gas legacyOptimized: 125440

View File

@ -12,6 +12,9 @@ contract Test {
// compileViaYul: also
// ----
// set(uint24[]): 0x20, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -> 18
// gas irOptimized: 121147
// gas legacy: 125815
// gas legacyOptimized: 123617
// data(uint256): 7 -> 8
// data(uint256): 15 -> 16
// data(uint256): 18 -> FAILURE

View File

@ -7,7 +7,13 @@ contract c {
// compileViaYul: also
// ----
// set(uint256): 1, 2 -> true
// gas irOptimized: 103365
// gas legacy: 103491
// gas legacyOptimized: 103135
// set(uint256): 2, 2, 3, 4, 5 -> true
// gas irOptimized: 164052
// gas legacy: 164121
// gas legacyOptimized: 163765
// storage: nonempty
// copy(uint256,uint256): 1, 2 -> true
// storage: nonempty

View File

@ -19,8 +19,25 @@ contract c {
// ----
// f(uint256): 0 -> 0x20, 0x00
// f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00
// gas irOptimized: 222684
// gas legacy: 255464
// gas legacyOptimized: 250931
// f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671
// gas irOptimized: 233443
// gas legacy: 267931
// gas legacyOptimized: 263260
// f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 242278
// gas legacy: 277538
// gas legacyOptimized: 272747
// f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992
// gas irOptimized: 356428
// gas legacy: 423428
// gas legacyOptimized: 414737
// f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000
// gas legacy: 106445
// gas legacyOptimized: 104350
// f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968
// gas irOptimized: 817738
// gas legacy: 954517
// gas legacyOptimized: 937258

View File

@ -11,3 +11,6 @@ contract C {
// compileViaYul: also
// ----
// f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1
// gas irOptimized: 108100
// gas legacy: 105365
// gas legacyOptimized: 105149

View File

@ -37,6 +37,10 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000
// gas irOptimized: 172892
// gas legacy: 174794
// gas legacyOptimized: 174182
// g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000
// gas legacy: 100595
// h() -> 0x40, 0x60, 0x00, 0x00
// storage: empty

View File

@ -48,3 +48,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0xff
// gas irOptimized: 137428
// gas legacy: 137645
// gas legacyOptimized: 134372

View File

@ -18,3 +18,6 @@ contract C {
// compileViaYul: also
// ----
// test() -> 7
// gas irOptimized: 134482
// gas legacy: 211296
// gas legacyOptimized: 211087

View File

@ -18,8 +18,10 @@ contract C {
}
// ====
// compileViaYul: also
// compileToEwasm: also
// compileViaYul: also
// ----
// one() -> 3
// gas legacy: 154760
// gas legacyOptimized: 154597
// two() -> FAILURE, hex"4e487b71", 0x51

View File

@ -9,6 +9,9 @@ contract c {
// compileViaYul: also
// ----
// set(): 1, 2, 3, 4, 5 -> true
// gas irOptimized: 163861
// gas legacy: 163756
// gas legacyOptimized: 163595
// storage: nonempty
// reset() -> true
// storage: empty

View File

@ -20,3 +20,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 3
// gas irOptimized: 175292
// gas legacy: 179707
// gas legacyOptimized: 178734

View File

@ -19,3 +19,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
// gas irOptimized: 218149
// gas legacy: 223725
// gas legacyOptimized: 222886

View File

@ -13,3 +13,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
// gas irOptimized: 198780
// gas legacy: 199159
// gas legacyOptimized: 198128

View File

@ -20,3 +20,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
// gas irOptimized: 218149
// gas legacy: 223730
// gas legacyOptimized: 222891

View File

@ -26,3 +26,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 11, 0x0c, 1, 0x15, 22, 4
// gas irOptimized: 292660
// gas legacy: 296916
// gas legacyOptimized: 283163

View File

@ -15,3 +15,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> 2, 3, 4
// gas irOptimized: 240441
// gas legacy: 241549
// gas legacyOptimized: 236002

View File

@ -20,3 +20,6 @@ contract C {
// compileViaYul: also
// ----
// f() -> "A", 8, 4, "B"
// gas irOptimized: 170583
// gas legacy: 121398
// gas legacyOptimized: 115494

View File

@ -18,3 +18,6 @@ contract c {
// compileViaYul: also
// ----
// test1() -> true
// gas irOptimized: 534222
// gas legacy: 613377
// gas legacyOptimized: 606202

View File

@ -16,3 +16,4 @@ contract C {
// compileViaYul: also
// ----
// f() -> 0, 0, 0
// gas irOptimized: 101935

View File

@ -16,6 +16,9 @@ contract c {
// ----
// storage: empty
// fill() ->
// gas irOptimized: 536238
// gas legacy: 504373
// gas legacyOptimized: 499648
// storage: nonempty
// halfClear() ->
// storage: nonempty

View File

@ -44,6 +44,9 @@ contract c {
// ----
// getLengths() -> 0, 0
// setLengths(uint256,uint256): 48, 49 ->
// gas irOptimized: 276446
// gas legacy: 308271
// gas legacyOptimized: 300117
// getLengths() -> 48, 49
// setIDStatic(uint256): 11 ->
// getID(uint256): 2 -> 11

View File

@ -18,6 +18,9 @@ contract c {
// ----
// storage: empty
// fill() -> 8
// gas irOptimized: 181164
// gas legacy: 165456
// gas legacyOptimized: 164387
// storage: nonempty
// clear() ->
// storage: empty

View File

@ -8,11 +8,14 @@ contract c {
function clear() public { delete data; }
}
// ====
// compileViaYul: also
// compileToEwasm: also
// compileViaYul: also
// ----
// storage: empty
// fill() ->
// gas irOptimized: 423997
// gas legacy: 429460
// gas legacyOptimized: 425520
// storage: nonempty
// clear() ->
// storage: empty

View File

@ -21,3 +21,6 @@ contract B {
// compileViaYul: also
// ----
// f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004
// gas irOptimized: 179491
// gas legacy: 264410
// gas legacyOptimized: 134899

View File

@ -45,3 +45,6 @@ contract C {
// compileViaYul: also
// ----
// test() -> 5, 6, 7
// gas irOptimized: 360048
// gas legacy: 500424
// gas legacyOptimized: 307615

View File

@ -25,4 +25,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 1, 2, 3
// gas irOptimized: 2556862
// gas legacy: 2416722
// gas legacyOptimized: 2405396
// storage: empty

View File

@ -20,4 +20,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 38, 28, 18
// gas irOptimized: 539280
// gas legacy: 454080
// gas legacyOptimized: 443170
// storage: empty

View File

@ -20,4 +20,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> 20, 10
// gas irOptimized: 374378
// gas legacy: 320859
// gas legacyOptimized: 314681
// storage: empty

View File

@ -12,3 +12,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000
// gas irOptimized: 163882
// gas legacy: 245809
// gas legacyOptimized: 242597

View File

@ -18,4 +18,7 @@ contract c {
// compileViaYul: also
// ----
// test() -> true
// gas irOptimized: 461007
// gas legacy: 552064
// gas legacyOptimized: 533000
// storage: empty

View File

@ -17,4 +17,7 @@ contract c {
// compileViaYul: also
// ----
// test() ->
// gas irOptimized: 302445
// gas legacy: 372763
// gas legacyOptimized: 366764
// storage: empty

View File

@ -12,3 +12,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 161233
// gas legacy: 243287
// gas legacyOptimized: 240324

View File

@ -18,3 +18,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 5, 4, 3, 3
// gas irOptimized: 116397
// gas legacy: 111938
// gas legacyOptimized: 110528

View File

@ -14,3 +14,6 @@ contract C {
// compileViaYul: also
// ----
// f(uint120[]): 0x20, 3, 1, 2, 3 -> 1
// gas irOptimized: 116603
// gas legacy: 116886
// gas legacyOptimized: 116701

View File

@ -16,3 +16,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 1, 2, 3, 4
// gas irOptimized: 112771
// gas legacy: 107098
// gas legacyOptimized: 106362

View File

@ -22,3 +22,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 2, 3, 4, 5
// gas irOptimized: 147411
// gas legacy: 190684
// gas legacyOptimized: 188256

View File

@ -17,4 +17,7 @@ contract c {
// ====
// compileViaYul: also
// ----
// test((uint16, uint16, uint16[3], uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5
// test((uint16,uint16,uint16[3],uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5
// gas irOptimized: 148672
// gas legacy: 152444
// gas legacyOptimized: 146666

View File

@ -17,3 +17,6 @@ contract c {
// compileViaYul: also
// ----
// test() -> 0
// gas irOptimized: 398636
// gas legacy: 565428
// gas legacyOptimized: 552330

View File

@ -29,10 +29,16 @@ contract C {
// ----
// l() -> 0
// f(uint256,uint256): 42, 64 ->
// gas irOptimized: 202798
// gas legacy: 163034
// gas legacyOptimized: 157045
// l() -> 1
// ll(uint256): 0 -> 43
// a(uint256,uint256): 0, 42 -> 64
// f(uint256,uint256): 84, 128 ->
// gas irOptimized: 299014
// gas legacy: 222080
// gas legacyOptimized: 210631
// l() -> 2
// ll(uint256): 1 -> 85
// a(uint256,uint256): 0, 42 -> 64

View File

@ -23,6 +23,9 @@ contract C {
// ----
// l() -> 0
// g(uint256): 70 ->
// gas irOptimized: 433788
// gas legacy: 419791
// gas legacyOptimized: 415338
// l() -> 70
// a(uint256): 69 -> left(69)
// f() ->

View File

@ -26,3 +26,6 @@ contract Main {
// compileViaYul: also
// ----
// f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1
// gas irOptimized: 117287
// gas legacy: 127152
// gas legacyOptimized: 113679

View File

@ -26,3 +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: 472538
// gas legacy: 570900
// gas legacyOptimized: 436164

View File

@ -26,3 +26,6 @@ contract Creator {
// compileViaYul: also
// ----
// f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h"
// gas irOptimized: 335246
// gas legacy: 414850
// gas legacyOptimized: 290276

View File

@ -19,3 +19,4 @@ contract C {
// compileViaYul: also
// ----
// f() -> 16
// gas legacy: 104744

View File

@ -19,3 +19,6 @@ contract C {
// compileViaYul: also
// ----
// f(), 2000 ether -> true
// gas irOptimized: 123853
// gas legacy: 123226
// gas legacyOptimized: 123092

View File

@ -178,19 +178,33 @@ contract DepositContract is IDepositContract, ERC165 {
// compileViaYul: also
// ----
// constructor()
// gas irOptimized: 1813459
// gas legacy: 2558004
// gas legacyOptimized: 1806764
// supportsInterface(bytes4): 0x0 -> 0
// supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 #
// supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id #
// supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id #
// get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e
// get_deposit_count() -> 0x20, 8, 0
// # TODO: check balance and logs after each deposit #
// gas irOptimized: 107589
// gas legacy: 128065
// gas legacyOptimized: 100398
// get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit #
// deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input #
// get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e
// gas irOptimized: 107589
// gas legacy: 128065
// gas legacyOptimized: 100398
// get_deposit_count() -> 0x20, 8, 0
// deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 #
// get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438
// gas irOptimized: 107599
// gas legacy: 128075
// gas legacyOptimized: 100411
// get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000
// deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac #
// get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee
// gas irOptimized: 107599
// gas legacy: 128075
// gas legacyOptimized: 100411
// get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000

View File

@ -288,11 +288,14 @@ contract Test {
/// testMul() -> true
//
// ====
// compileViaYul: also
// EVMVersion: >=constantinople
// compileViaYul: also
// ----
// library: Pairing
// f() -> true
// g() -> true
// pair() -> true
// verifyTx() -> true
// gas irOptimized: 146496
// gas legacy: 130571
// gas legacyOptimized: 100187

View File

@ -5,7 +5,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// compileToEwasm: also
// compileViaYul: also
// ----
// f() -> FAILURE

View File

@ -15,3 +15,4 @@ contract D {
// compileViaYul: also
// ----
// f() -> 2
// gas legacy: 101554

View File

@ -13,3 +13,4 @@ contract D {
// compileViaYul: also
// ----
// f() -> 2
// gas legacy: 101527

View File

@ -14,15 +14,21 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// constructor(), 20 wei
// gas irOptimized: 232551
// gas legacy: 285485
// gas legacyOptimized: 177957
// f(uint256): 20 -> 1370859564726510389319704988634906228201275401179
// x() -> 1
// f(uint256): 20 -> FAILURE
// x() -> 1
// stack(uint256): 1023 -> FAILURE
// gas irOptimized: 835314
// gas legacy: 981671
// gas legacyOptimized: 824895
// x() -> 1
// stack(uint256): 10 -> 693016686122178122849713379390321835634789309880
// x() -> 2

View File

@ -20,6 +20,9 @@ contract test {
// compileViaYul: also
// ----
// set(uint8,uint8,uint8,uint8,uint8): 1, 21, 22, 42, 43 -> 0, 0, 0, 0
// gas irOptimized: 110993
// gas legacy: 111406
// gas legacyOptimized: 107981
// get(uint8): 1 -> 21, 22, 42, 43
// set(uint8,uint8,uint8,uint8,uint8): 1, 10, 30, 11, 31 -> 21, 22, 42, 43
// get(uint8): 1 -> 10, 30, 11, 31

Some files were not shown because too many files have changed in this diff Show More