From dc2289eadae09919446b81ab0d692415cbef824c Mon Sep 17 00:00:00 2001 From: matkt Date: Tue, 10 Oct 2023 19:06:13 +0200 Subject: [PATCH] add method to disable root verification for T8n and not Reference tests (#6013) * add method to disable root verification for T8n and not Reference tests Signed-off-by: Karim TAAM --- .../hyperledger/besu/evmtool/T8nExecutor.java | 6 +- .../state-test/blockhash-zero-state-root.json | 104 ------------------ .../BonsaiReferenceTestWorldState.java | 8 +- 3 files changed, 11 insertions(+), 107 deletions(-) delete mode 100644 ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/state-test/blockhash-zero-state-root.json diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java index 388d7a9460b..a93b66e4348 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java @@ -33,7 +33,6 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; -import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; @@ -42,6 +41,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; +import org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestEnv; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules; @@ -238,7 +238,9 @@ static T8nResult runTest( ReferenceTestProtocolSchedules.create( new StubGenesisConfigOptions().chainId(BigInteger.valueOf(chainId))); - final MutableWorldState worldState = initialWorldState.copy(); + final BonsaiReferenceTestWorldState worldState = + (BonsaiReferenceTestWorldState) initialWorldState.copy(); + worldState.disableRootHashVerification(); final ProtocolSchedule protocolSchedule = referenceTestProtocolSchedules.getByName(fork); if (protocolSchedule == null) { diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/state-test/blockhash-zero-state-root.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/state-test/blockhash-zero-state-root.json deleted file mode 100644 index 444f8298379..00000000000 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/state-test/blockhash-zero-state-root.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "cli": [ - "state-test", - "stdin", - "--trace", - "--trace.memory", - "--trace.stack", - "--trace.returndata", - "--notime" - ], - "stdin": { - "00000936-mixed-1": { - "env": { - "currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "currentDifficulty": "0x20000", - "currentRandom": "0x0000000000000000000000000000000000000000000000000000000000020000", - "currentGasLimit": "0x26e1f476fe1e22", - "currentNumber": "0x2", - "currentTimestamp": "0x3e8", - "previousHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "currentBaseFee": "0x10" - }, - "pre": { - "0x00000000000000000000000000000000000000f1": { - "code": "0x600060016001600260026101f461ffff5817907c78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b991383610389895f8a5b82723e3d6d5ff042148d326c1898713a76759ca27383404148083e7788908f409e38766cfafe083134530b5279797ef56394faa3183b3780475932387ea37a326494ff1b6b57018c79f07a9ba492a256543f0b6a813b316835b15385077d9e8d32f18c3bb159fab11734a363999e7e940a9c19699da08a82a3ff6743b13f44206194321d026490411a938b35f47cf31b91a1ff397b7c6d879f119915176f3699801bf0766b62fd855b60607d6f133f35fa40307e150a096ea35041306b9330f23441473018055f44698e928a109b02f38f515386177e819161487a5bfa7951f5317183fa743d7587f479009c8b4813089d8d3cf37e3a9b6170528b84f296f07433363a766a64529d8c62ff859c0852173e875685ff15123594f13418966f483a999990109b1694511007477171068aa03a561b8df4743642452039a43c391c3e0033f4615ab1f37cb10293387613024673187c1d5b731c3e53a19080b03e6b94755580876f7a6bf0f238f0991c775172893e7b14449e8c050968b032a29bf13265657d11386d9f8c6f360670fa1116178909f59a369c7c005f8d1464527365f0fd5b818499a2469a0b173f42478294f11c8b40567d8b9f72f43594028d67b17893668a999d8d205014687a6a9b09198bfe87a144313895a208183c8b4060a392387a5106f235a019f36d336f6034f5fe006df413a090791c3c6c52b181f047457a8a73f294f401467a79048060113b1b20fd87078a78a273368c116741128c9a715b085312949c15460b9b8613587c79365b643a67106d840b51a0009e3f893f893236527d540b14403a866d6a147df465a03a8a62489a1d7f680962036b716111f45572367e887606f282820b3d7c178af5f3846a60f2999290f3f3847882f19362113e668f19a07bfffa8aa4374793a28401fe34fd93551a7a721256130789707767a408847307067a85fe3cf1f58a64f0368d38413299f083941885867d18308e0835b054531793087b8c970490597203978d1a8a1b6ba459621b8a8d8313655711563e31073e3c3d6056337299089a94415468097df1425a91f209b13d77f493425041f4ff6718441445463c519771069e727ef59214b19b0b5a3a3b3aa01b6c963da1638117323d637c92443e97795a438593155f73123417fd7b01397b7f4587b1727a011a12450903fa62f182b168920b945a57f28a2078665088593458137d75729f8898800953933056867c1d48441839128c6238f39d3c01149b9859b1958e0b806c81966302f03407a0f5047d778c52018b20f5f13e5b7255544632708064318b31fd0b7b420b3659761da06a17584554453d4363a27c8f767941619d628b75934051", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000000a", - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x000000000000000000000000000000000000000000000000000000000000000a", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x0000000000000000000000000000000000000000000000000000000000000002", - "0x0000000000000000000000000000000000000000000000000000000000000005": "0x0000000000000000000000000000000000000000000000000000000000000007", - "0x0000000000000000000000000000000000000000000000000000000000000008": "0x0000000000000000000000000000000000000000000000000000000000000011", - "0x0000000000000000000000000000000000000000000000000000000000000009": "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x000000000000000000000000000000000000000000000000000000000000000c": "0x0000000000000000000000000000000000000000000000000000000000000008" - }, - "balance": "0x0", - "nonce": "0x0" - }, - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "code": "0x", - "storage": {}, - "balance": "0xffffffffff", - "nonce": "0x0" - } - }, - "transaction": { - "gasPrice": "0x10", - "nonce": "0x0", - "to": "0x00000000000000000000000000000000000000f1", - "data": [ - "0xfe25cf37540066ffd30066af7690fad6d555e13067f5c3c16ced98a803e2b009db4ab89b243ac17b80386d12d621723c363e46aff1fcce9c084d" - ], - "gasLimit": [ - "0x7a1200" - ], - "value": [ - "0xdbbe" - ], - "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" - }, - "out": "0x", - "post": { - "Shanghai": [ - { - "hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "logs": "0x0000000000000000000000000000000000000000000000000000000000000000", - "indexes": { - "data": 0, - "gas": 0, - "value": 0 - } - } - ] - } - } - }, - "stdout": [ - {"pc":0,"op":96,"gas":"0x79bc70","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}, - {"pc":2,"op":96,"gas":"0x79bc6d","gasCost":"0x3","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"PUSH1"}, - {"pc":4,"op":96,"gas":"0x79bc6a","gasCost":"0x3","memSize":0,"stack":["0x0","0x1"],"depth":1,"refund":0,"opName":"PUSH1"}, - {"pc":6,"op":96,"gas":"0x79bc67","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1"],"depth":1,"refund":0,"opName":"PUSH1"}, - {"pc":8,"op":96,"gas":"0x79bc64","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2"],"depth":1,"refund":0,"opName":"PUSH1"}, - {"pc":10,"op":97,"gas":"0x79bc61","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2"],"depth":1,"refund":0,"opName":"PUSH2"}, - {"pc":13,"op":97,"gas":"0x79bc5e","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0x1f4"],"depth":1,"refund":0,"opName":"PUSH2"}, - {"pc":16,"op":88,"gas":"0x79bc5b","gasCost":"0x2","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0x1f4","0xffff"],"depth":1,"refund":0,"opName":"PC"}, - {"pc":17,"op":23,"gas":"0x79bc59","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0x1f4","0xffff","0x10"],"depth":1,"refund":0,"opName":"OR"}, - {"pc":18,"op":144,"gas":"0x79bc56","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0x1f4","0xffff"],"depth":1,"refund":0,"opName":"SWAP1"}, - {"pc":19,"op":124,"gas":"0x79bc53","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4"],"depth":1,"refund":0,"opName":"PUSH29"}, - {"pc":49,"op":131,"gas":"0x79bc50","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913"],"depth":1,"refund":0,"opName":"DUP4"}, - {"pc":50,"op":97,"gas":"0x79bc4d","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2"],"depth":1,"refund":0,"opName":"PUSH2"}, - {"pc":53,"op":137,"gas":"0x79bc4a","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389"],"depth":1,"refund":0,"opName":"DUP10"}, - {"pc":54,"op":95,"gas":"0x79bc47","gasCost":"0x2","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0"],"depth":1,"refund":0,"opName":"PUSH0"}, - {"pc":55,"op":138,"gas":"0x79bc45","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0"],"depth":1,"refund":0,"opName":"DUP11"}, - {"pc":56,"op":91,"gas":"0x79bc42","gasCost":"0x1","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1"],"depth":1,"refund":0,"opName":"JUMPDEST"}, - {"pc":57,"op":130,"gas":"0x79bc41","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1"],"depth":1,"refund":0,"opName":"DUP3"}, - {"pc":58,"op":114,"gas":"0x79bc3e","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0"],"depth":1,"refund":0,"opName":"PUSH19"}, - {"pc":78,"op":131,"gas":"0x79bc3b","gasCost":"0x3","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0","0x3e3d6d5ff042148d326c1898713a76759ca273"],"depth":1,"refund":0,"opName":"DUP4"}, - {"pc":79,"op":64,"gas":"0x79bc38","gasCost":"0x14","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0","0x3e3d6d5ff042148d326c1898713a76759ca273","0x0"],"depth":1,"refund":0,"opName":"BLOCKHASH"}, - {"pc":80,"op":65,"gas":"0x79bc24","gasCost":"0x2","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0","0x3e3d6d5ff042148d326c1898713a76759ca273","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"],"depth":1,"refund":0,"opName":"COINBASE"}, - {"pc":81,"op":72,"gas":"0x79bc22","gasCost":"0x2","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0","0x3e3d6d5ff042148d326c1898713a76759ca273","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d","0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b"],"depth":1,"refund":0,"opName":"BASEFEE"}, - {"pc":82,"op":8,"gas":"0x79bc20","gasCost":"0x8","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0","0x3e3d6d5ff042148d326c1898713a76759ca273","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d","0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b","0x10"],"depth":1,"refund":0,"opName":"ADDMOD"}, - {"pc":83,"op":62,"gas":"0x79bc18","gasCost":"0x0","memSize":0,"stack":["0x0","0x1","0x1","0x2","0x2","0xffff","0x1f4","0x78859e5b97166c486532b1595a673e9f9073643f1b519c6f18511b9913","0x2","0x389","0x0","0x0","0x1","0x0","0x3e3d6d5ff042148d326c1898713a76759ca273","0xb94f5374fce5edbc8e2a8697c15331677e6ebf1b"],"depth":1,"refund":0,"opName":"RETURNDATACOPY","error":"Out of bounds"}, - {"output":"","gasUsed":"0x7a1200","test":"00000936-mixed-1","fork":"Shanghai","d":0,"g":0,"v":0,"postHash":"0xd14c10ed22a1cfb642e374be985ac581c39f3969bd59249e0405aca3beb47a47","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","pass":false} - ] -} diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java index 0e23f5406af..ff8a33814cc 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java @@ -49,6 +49,8 @@ public class BonsaiReferenceTestWorldState extends BonsaiWorldState private final BonsaiReferenceTestWorldStateStorage refTestStorage; private final BonsaiPreImageProxy preImageProxy; + private boolean disableRootHashVerification; + protected BonsaiReferenceTestWorldState( final BonsaiReferenceTestWorldStateStorage worldStateStorage, final CachedMerkleTrieLoader cachedMerkleTrieLoader, @@ -87,7 +89,7 @@ public ReferenceTestWorldState copy() { */ @Override protected void verifyWorldStateRoot(final Hash calculatedStateRoot, final BlockHeader header) { - if (!header.getStateRoot().equals(Hash.ZERO)) { + if (!disableRootHashVerification) { super.verifyWorldStateRoot(calculatedStateRoot, header); } } @@ -125,6 +127,10 @@ public Stream streamAccounts(final Bytes32 startKeyHash, fina return this.refTestStorage.streamAccounts(this, startKeyHash, limit); } + public void disableRootHashVerification() { + disableRootHashVerification = true; + } + static class NoOpTrieLogManager implements TrieLogManager { private final Subscribers trieLogObservers = Subscribers.create(); private final TrieLogFactory trieLogFactory = new TrieLogFactoryImpl();