mirror of https://github.com/hyperledger/besu
Ref tests 10.4 (#3835)
10.4 revision of reference tests has notable changes * Nonce can be up to 2^64-1, with some opcode and validity interactions specced in eip-2681 * Wei fields can be up to 2^256, tests check for rollover * VM Tests were removed * Legacy Tests were removed * Reference tests make it clear that transactions with a maxPriorityFee of zero are valid. Perhaps useless, but still valid. * Adding validation hooks in the out-of-chain test execution. These validations are caught in full-chain execution, just not in conveniently places for integration testing. * This does not transaction tests support for the "merge" fork, as the release notes marked it as an "upcoming" feature. Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> Co-authored-by: Diego López León <dieguitoll@gmail.com> Co-authored-by: Daniel Lehrner <daniel.lehrner@consensys.net>pull/3865/head
parent
950673c798
commit
d88bb5867f
@ -1,167 +0,0 @@ |
||||
/* |
||||
* Copyright ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.vm; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
import static org.junit.Assume.assumeTrue; |
||||
|
||||
import org.hyperledger.besu.ethereum.chain.BadBlockManager; |
||||
import org.hyperledger.besu.ethereum.core.MutableWorldState; |
||||
import org.hyperledger.besu.ethereum.core.PrivacyParameters; |
||||
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs; |
||||
import org.hyperledger.besu.ethereum.mainnet.MutableProtocolSchedule; |
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; |
||||
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; |
||||
import org.hyperledger.besu.ethereum.referencetests.EnvironmentInformation; |
||||
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; |
||||
import org.hyperledger.besu.ethereum.referencetests.VMReferenceTestCaseSpec; |
||||
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; |
||||
import org.hyperledger.besu.evm.frame.MessageFrame; |
||||
import org.hyperledger.besu.evm.internal.EvmConfiguration; |
||||
import org.hyperledger.besu.evm.tracing.OperationTracer; |
||||
import org.hyperledger.besu.testutil.JsonTestParameters; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.ArrayDeque; |
||||
import java.util.Collection; |
||||
import java.util.Optional; |
||||
import java.util.OptionalInt; |
||||
|
||||
import org.junit.runner.RunWith; |
||||
import org.junit.runners.Parameterized; |
||||
import org.junit.runners.Parameterized.Parameters; |
||||
|
||||
/** The VM operation testing framework entry point. */ |
||||
@RunWith(Parameterized.class) |
||||
public class VMReferenceTest extends AbstractRetryingTest { |
||||
|
||||
/** The path where all of the VM test configuration files live. */ |
||||
private static final String[] TEST_CONFIG_FILE_DIR_PATHS = { |
||||
"LegacyTests/Constantinople/VMTests/vmArithmeticTest", |
||||
"LegacyTests/Constantinople/VMTests/vmBitwiseLogicOperation", |
||||
"LegacyTests/Constantinople/VMTests/vmBlockInfoTest", |
||||
"LegacyTests/Constantinople/VMTests/vmEnvironmentalInfo", |
||||
"LegacyTests/Constantinople/VMTests/vmIOandFlowOperations", |
||||
"LegacyTests/Constantinople/VMTests/vmLogTest", |
||||
"LegacyTests/Constantinople/VMTests/vmPushDupSwapTest", |
||||
"LegacyTests/Constantinople/VMTests/vmRandomTest", |
||||
"LegacyTests/Constantinople/VMTests/vmSha3Test", |
||||
"LegacyTests/Constantinople/VMTests/vmTests", |
||||
"LegacyTests/Constantinople/VMTests/vmSystemOperations" |
||||
}; |
||||
|
||||
// The ignored test cases fall into two categories:
|
||||
//
|
||||
// 1. Incorrect Test Cases: The VMTests have known bugs with accessing
|
||||
// non-existent accounts. This corresponds to test cases involving
|
||||
// the BALANCE, EXTCODESIZE, EXTCODECOPY, and SELFDESTRUCT operations.
|
||||
//
|
||||
// 2. Test Cases for CALL, CALLCODE, and CALLCREATE: The VMTests do not
|
||||
// fully test these operations and the mocking does not add much value.
|
||||
// Additionally, the GeneralStateTests provide coverage of these
|
||||
// operations so the proper functionality does get tested somewhere.
|
||||
private static final String[] IGNORED_TESTS = { |
||||
"push32AndSuicide", "suicide", "suicide0", "suicideNotExistingAccount", "suicideSendEtherToMe", |
||||
}; |
||||
private static final Optional<BigInteger> CHAIN_ID = Optional.of(BigInteger.ONE); |
||||
|
||||
private final VMReferenceTestCaseSpec spec; |
||||
|
||||
@Parameters(name = "Name: {0}") |
||||
public static Collection<Object[]> getTestParametersForConfig() { |
||||
return JsonTestParameters.create(VMReferenceTestCaseSpec.class) |
||||
.ignore(IGNORED_TESTS) |
||||
.generate(TEST_CONFIG_FILE_DIR_PATHS); |
||||
} |
||||
|
||||
public VMReferenceTest( |
||||
final String name, final VMReferenceTestCaseSpec spec, final boolean runTest) { |
||||
this.spec = spec; |
||||
assumeTrue("Test " + name + " was ignored", runTest); |
||||
} |
||||
|
||||
@Override |
||||
protected void runTest() { |
||||
final MutableWorldState worldState = new DefaultMutableWorldState(spec.getInitialWorldState()); |
||||
final EnvironmentInformation execEnv = spec.getExec(); |
||||
|
||||
final ProtocolSpec protocolSpec = |
||||
MainnetProtocolSpecs.frontierDefinition( |
||||
OptionalInt.empty(), OptionalInt.empty(), false, EvmConfiguration.DEFAULT) |
||||
.privacyParameters(PrivacyParameters.DEFAULT) |
||||
.privateTransactionValidatorBuilder(() -> new PrivateTransactionValidator(CHAIN_ID)) |
||||
.badBlocksManager(new BadBlockManager()) |
||||
.build(new MutableProtocolSchedule(CHAIN_ID)); |
||||
|
||||
final ReferenceTestBlockchain blockchain = |
||||
new ReferenceTestBlockchain(execEnv.getBlockHeader().getNumber()); |
||||
final MessageFrame frame = |
||||
MessageFrame.builder() |
||||
.type(MessageFrame.Type.MESSAGE_CALL) |
||||
.messageFrameStack(new ArrayDeque<>()) |
||||
.worldUpdater(worldState.updater()) |
||||
.initialGas(spec.getExec().getGas()) |
||||
.contract(execEnv.getAccountAddress()) |
||||
.address(execEnv.getAccountAddress()) |
||||
.originator(execEnv.getOriginAddress()) |
||||
.gasPrice(execEnv.getGasPrice()) |
||||
.inputData(execEnv.getData()) |
||||
.sender(execEnv.getCallerAddress()) |
||||
.value(execEnv.getValue()) |
||||
.apparentValue(execEnv.getValue()) |
||||
.code(execEnv.getCode()) |
||||
.blockValues(execEnv.getBlockHeader()) |
||||
.depth(execEnv.getDepth()) |
||||
.completer(c -> {}) |
||||
.miningBeneficiary(execEnv.getBlockHeader().getCoinbase()) |
||||
.blockHashLookup(new BlockHashLookup(execEnv.getBlockHeader(), blockchain)) |
||||
.maxStackSize(MessageFrame.DEFAULT_MAX_STACK_SIZE) |
||||
.build(); |
||||
|
||||
// This is normally set inside the containing message executing the code.
|
||||
frame.setState(MessageFrame.State.CODE_EXECUTING); |
||||
|
||||
protocolSpec.getEvm().runToHalt(frame, OperationTracer.NO_TRACING); |
||||
|
||||
if (spec.isExceptionHaltExpected()) { |
||||
assertThat(frame.getState() == MessageFrame.State.EXCEPTIONAL_HALT) |
||||
.withFailMessage("VM should have exceptionally halted") |
||||
.isTrue(); |
||||
} else { |
||||
// This is normally performed when the message processor executing the VM
|
||||
// executes to completion successfully.
|
||||
frame.getWorldUpdater().commit(); |
||||
|
||||
assertThat(frame.getState() == MessageFrame.State.EXCEPTIONAL_HALT) |
||||
.withFailMessage( |
||||
"VM should not have exceptionally halted with " + frame.getExceptionalHaltReason()) |
||||
.isFalse(); |
||||
assertThat(frame.getOutputData()) |
||||
.withFailMessage("VM output differs") |
||||
.isEqualTo(spec.getOut()); |
||||
assertThat(worldState.rootHash()) |
||||
.withFailMessage("Final world state differs") |
||||
.isEqualTo(spec.getFinalWorldState().rootHash()); |
||||
|
||||
final long actualGas = frame.getRemainingGas(); |
||||
final long expectedGas = spec.getFinalGas(); |
||||
final long difference = |
||||
(expectedGas > actualGas) ? expectedGas - actualGas : actualGas - expectedGas; |
||||
assertThat(actualGas) |
||||
.withFailMessage("Final gas does not match, with difference of %s", difference) |
||||
.isEqualTo(expectedGas); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,187 @@ |
||||
{ |
||||
"HighGasPrice" : { |
||||
"_info" : { |
||||
"comment" : "", |
||||
"filling-rpc-server" : "evm version 1.10.16-unstable-0f893109-20220105", |
||||
"filling-tool-version" : "retesteth-0.2.2-testinfo+commit.01c6aac2.Linux.g++", |
||||
"generatedTestHash" : "399ed11fc62af31e9c3dc126828160c15b9c2422373ef7f68a628017a9693a63", |
||||
"lllcversion" : "Version: 0.5.14-develop.2021.11.27+commit.401d5358.Linux.g++", |
||||
"solidity" : "Version: 0.8.5+commit.a4f2e591.Linux.g++", |
||||
"source" : "src/GeneralStateTestsFiller/stTransactionTest/HighGasPriceFiller.yml", |
||||
"sourceHash" : "b3c0dfeeca0bb9616669d0bdd0996e24c71febd2579d14e9ec42914e9f096a44" |
||||
}, |
||||
"env" : { |
||||
"currentBaseFee" : "0x0a", |
||||
"currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", |
||||
"currentDifficulty" : "0x020000", |
||||
"currentGasLimit" : "0x05500000", |
||||
"currentNumber" : "0x01", |
||||
"currentTimestamp" : "0x03e8", |
||||
"previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" |
||||
}, |
||||
"post" : { |
||||
"Berlin" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"Byzantium" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"Constantinople" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"ConstantinopleFix" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"EIP150" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"EIP158" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"Frontier" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"Homestead" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"Istanbul" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
], |
||||
"London" : [ |
||||
{ |
||||
"expectException" : "TR_NoFunds", |
||||
"hash" : "0x1751725d1aad5298768fbcf64069b2c1b85aeaffcc561146067d6beedd08052a", |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
||||
"txbytes" : "0xf87e809f031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c82520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d001801ca039b081ab7094dff1b3ac79cbf8e381adc9f7a4e16290d7abc42dd006e5e062c5a033af00e26e5eb4431dcad601b2c8bf12d51eef2bd037d14681f22692ffab1ccd" |
||||
} |
||||
] |
||||
}, |
||||
"pre" : { |
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { |
||||
"balance" : "0x3b9aca00", |
||||
"code" : "0x", |
||||
"nonce" : "0x00", |
||||
"storage" : { |
||||
} |
||||
}, |
||||
"0xd0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0" : { |
||||
"balance" : "0x00", |
||||
"code" : "0x", |
||||
"nonce" : "0x00", |
||||
"storage" : { |
||||
} |
||||
} |
||||
}, |
||||
"transaction" : { |
||||
"data" : [ |
||||
"0x" |
||||
], |
||||
"gasLimit" : [ |
||||
"0x5208" |
||||
], |
||||
"gasPrice" : "0x031eea408f8e1799cb883da2927b1336521d73c2c14accfebb70d5c5af006c", |
||||
"nonce" : "0x00", |
||||
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", |
||||
"sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", |
||||
"to" : "0xd0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0", |
||||
"value" : [ |
||||
"0x01" |
||||
] |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@ |
||||
{ |
||||
"this-file-is": bogus! |
||||
} |
@ -1 +1 @@ |
||||
Subproject commit 1587f40e7f606140822307d47e88c8d09acc907a |
||||
Subproject commit a380655e5ffab1a5ea0f4d860224bdb19013f06a |
Loading…
Reference in new issue