Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Optionally bypass state root verification in reference test worldstate #5960

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,7 @@ public void persist(final BlockHeader blockHeader) {
// then persist the TrieLog for that transition.
// If specified but not a direct descendant simply store the new block hash.
if (blockHeader != null) {
if (!newWorldStateRootHash.equals(blockHeader.getStateRoot())) {
throw new RuntimeException(
"World State Root does not match expected value, header "
+ blockHeader.getStateRoot().toHexString()
+ " calculated "
+ newWorldStateRootHash.toHexString());
}
verifyWorldStateRoot(newWorldStateRootHash, blockHeader);
saveTrieLog =
() -> {
trieLogManager.saveTrieLog(localCopy, newWorldStateRootHash, blockHeader, this);
Expand Down Expand Up @@ -432,6 +426,16 @@ public void persist(final BlockHeader blockHeader) {
}
}

protected void verifyWorldStateRoot(final Hash calculatedStateRoot, final BlockHeader header) {
if (!calculatedStateRoot.equals(header.getStateRoot())) {
throw new RuntimeException(
"World State Root does not match expected value, header "
+ header.getStateRoot().toHexString()
+ " calculated "
+ calculatedStateRoot.toHexString());
}
}

@Override
public WorldUpdater updater() {
return accumulator;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"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}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ public ReferenceTestWorldState copy() {
layerCopy, cachedMerkleTrieLoader, trieLogManager, preImageProxy);
}

/**
* If the supplied header has a non-zero state root, verify. Else we assume that stateroot is an
* output instead of an input for this reference test and we bypass the state root check.
*
* <p>Besu reference-test style test cases should supply a stateroot to verify to prevent bonsai
* regressions.
*
* @param calculatedStateRoot state root calculated during bonsai persist step.
* @param header supplied reference test block header.
*/
@Override
protected void verifyWorldStateRoot(final Hash calculatedStateRoot, final BlockHeader header) {
if (!header.getStateRoot().equals(Hash.ZERO)) {
super.verifyWorldStateRoot(calculatedStateRoot, header);
}
}

@JsonCreator
public static BonsaiReferenceTestWorldState create(
final Map<String, ReferenceTestWorldState.AccountMock> accounts) {
Expand Down
Loading