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

Log calculated world state contents upon state root mismatch #8099

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

siladu
Copy link
Contributor

@siladu siladu commented Jan 10, 2025

PR description

When running EEST tests with our referenceTests runner, if we get a state root mismatch, then dump the world state contents to make it easy to see the "post state".

Together with this recently merged EEST change: ethereum/execution-spec-tests#1064
We should be able to do a direct comparison of the calculated versus expected post state.

"Collect" exceptions during trie log rolling validation and assert together with the state root.

Collect trielog rolling exceptions and display upon state root mismatch
Tidy up assertions and world state logging

Signed-off-by: Simon Dudley <[email protected]>
@siladu
Copy link
Contributor Author

siladu commented Jan 13, 2025

Example output

2025-01-13 21:39:28.183+10:00 | Test worker | ERROR | BonsaiReferenceTestWorldState | state root becomes invalid following a rollForward 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb != 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
java.lang.RuntimeException: state root becomes invalid following a rollForward 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb != 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
	at org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState.validateTrieLog(BonsaiReferenceTestWorldState.java:170) ~[main/:?]
	at org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState.validateStateRolling(BonsaiReferenceTestWorldState.java:153) ~[main/:?]
	at org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState.processExtraStateStorageFormatValidation(BonsaiReferenceTestWorldState.java:127) ~[main/:?]
	at org.hyperledger.besu.ethereum.vm.GeneralStateReferenceTestTools.executeTest(GeneralStateReferenceTestTools.java:193) ~[referenceTest/:?]
	at org.hyperledger.besu.ethereum.vm.executionspec.ExecutionSpecStateTest_36.execution(ExecutionSpecStateTest_36.java:39) ~[referenceTest/:?]
	...
2025-01-13 21:39:28.186+10:00 | Test worker | ERROR | BonsaiReferenceTestWorldState | state root becomes invalid following a rollForward 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb != 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
java.lang.RuntimeException: state root becomes invalid following a rollForward 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb != 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
	at org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState.validateTrieLog(BonsaiReferenceTestWorldState.java:170) ~[main/:?]
	at org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState.validateStateRolling(BonsaiReferenceTestWorldState.java:153) ~[main/:?]
	at org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState.processExtraStateStorageFormatValidation(BonsaiReferenceTestWorldState.java:129) ~[main/:?]
	at org.hyperledger.besu.ethereum.vm.GeneralStateReferenceTestTools.executeTest(GeneralStateReferenceTestTools.java:193) ~[referenceTest/:?]
	at org.hyperledger.besu.ethereum.vm.executionspec.ExecutionSpecStateTest_36.execution(ExecutionSpecStateTest_36.java:39) ~[referenceTest/:?]
	...
2025-01-13 21:39:28.190+10:00 | Test worker | ERROR | GeneralStateReferenceTestTools | Calculated world state: 
{
  "0x0000000000000000000000000000000000001000" : {
    "nonce" : "0x1",
    "balance" : "0x0",
    "code" : "0x00"
  },
  "0x0000000000000000000000000000000000001100" : {
    "nonce" : "0x1",
    "balance" : "0x0",
    "code" : "0x6000600060006000600073a94f5374fce5edbc8e2a8697c15331677e6ebf0b5af2600155600060006000600060006110005af2600155600160025500",
    "storage" : {
      "0x1" : "0x1",
      "0x2" : "0x1"
    }
  },
  "0x8a0a19589531694250d570040a0c4b74576919b8" : {
    "nonce" : "0x1",
    "balance" : "0x3635c9adc5de9876d8",
    "code" : "0x"
  }
}


Multiple Failures (3 failures)
-- failure 1 --Unexpected world state root hash; expected state: 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb, computed state: 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
at GeneralStateReferenceTestTools.lambda$executeTest$3(GeneralStateReferenceTestTools.java:208)
-- failure 2 --Additional exception during state validation: state root becomes invalid following a rollForward 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb != 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
at GeneralStateReferenceTestTools.lambda$executeTest$2(GeneralStateReferenceTestTools.java:210)
-- failure 3 --Additional exception during state validation: state root becomes invalid following a rollForward 0x84d4430711a86f40c722ae9c2b3571d3bbd411082f3c00dfecd5e1346e54ceeb != 0x514c205dff1215c9375e1e5125de3f1401ffec0b4851ad8087911980eaca7dfe
at GeneralStateReferenceTestTools.lambda$executeTest$2(GeneralStateReferenceTestTools.java:210)

@siladu siladu marked this pull request as ready for review January 13, 2025 11:51
@siladu siladu requested review from matkt and garyschulte January 13, 2025 11:51
Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good; I just added comments regarding how the world state is displayed.

.map(
e ->
Map.entry(
e.getKey().orElse(UInt256.ZERO),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

displaying zero is not true, I will prefer return Bytes.EMPTY in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me. Note, ZERO was somewhat following suit with

.sorted(Comparator.comparing(o -> o.getAddress().orElse(Address.ZERO).toHexString()))

if (!storageEntries.isEmpty()) {
accountJson.set("storage", storageJson);
}
worldStateJson.set(account.getAddress().orElse(Address.ZERO).toHexString(), accountJson);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, I don't think we will trigger this case but I will prefer to see that it was empty and no think that the address is the ZERO one

Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@siladu siladu enabled auto-merge (squash) January 14, 2025 11:02
@siladu siladu merged commit daf4aae into hyperledger:main Jan 14, 2025
43 checks passed
@siladu siladu deleted the state-tests-dump-world-state branch January 14, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants