Skip to content

Conversation

@shemnon
Copy link
Contributor

@shemnon shemnon commented Feb 22, 2023

PR description

The EVMTool State test needs to ignore the previosHash field when it comes to calculating BlockHashes, and instead follow the reference test rule that the hash is the Keccack hash of the base-10 ascii number.

To "do it right" this involved refactoring BlockHashLookup to not drag along some caching rules.

Fixed Issue(s)

Fixes #5122

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Acceptance Tests (Non Mainnet)

  • I have considered running ./gradlew acceptanceTestNonMainnet locally if my PR affects non-mainnet modules.

Changelog

Copy link
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

Enjoyed reading the Java > 11 code :)


final WorldUpdater worldStateUpdater = worldState.updater();
final BlockHashLookup blockHashLookup = new BlockHashLookup(blockHeader, blockchain);
final BlockHashLookup blockHashLookup = new CachingBlockHashLookup(blockHeader, blockchain);
Copy link
Contributor

Choose a reason for hiding this comment

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

The scope of these changes make me a little nervous but I realise it is essentially just a rename, so should be good.

Copy link
Contributor Author

@shemnon shemnon Feb 24, 2023

Choose a reason for hiding this comment

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

Yea, either we rename the implementation or we rename the type. I went with the impl on the basis the impl can describe how it implements the interface. i.e. List / ArrayList.

mutableWorldState,
transactionProcessor))
.collect(Collectors.toList());
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

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

Glory be!

Comment on lines +54 to +55
} else if (chainedUpdater instanceof StackedUpdater<?, ?> stackedUpdater) {
stackedUpdater.markTransactionBoundary();
Copy link
Contributor

Choose a reason for hiding this comment

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

fancy ;)

Use the specified BlockHashes in t8n

Signed-off-by: Danno Ferrin <[email protected]>
Signed-off-by: Danno Ferrin <[email protected]>
@shemnon shemnon enabled auto-merge (squash) February 24, 2023 20:36
.map(
entry ->
Map.entry(
Long.decode(entry.getKey()), Hash.fromHexString(entry.getValue())))

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
@shemnon shemnon merged commit 5a7c639 into hyperledger:main Feb 24, 2023
elenduuche pushed a commit to elenduuche/besu that referenced this pull request Aug 16, 2023
Support two in-the-wild models of blockhash for testing. For state-tests
always use the keccak hash of the decimal text of the block number.
For t8n always use the blockHashes table in the env. No change to production
handling of blockhash. Refactored BlockHashLookup to split caching 
implementation from API.

Signed-off-by: Danno Ferrin <[email protected]>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
Support two in-the-wild models of blockhash for testing. For state-tests
always use the keccak hash of the decimal text of the block number.
For t8n always use the blockHashes table in the env. No change to production
handling of blockhash. Refactored BlockHashLookup to split caching 
implementation from API.

Signed-off-by: Danno Ferrin <[email protected]>
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.

evm: wrong result from blockhash operation

2 participants