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

EIP-2935 #6991

Closed
Closed

Conversation

Gabriel-Trintinalia
Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia commented Apr 23, 2024

PR description

fix #6531

  • Extract EIP-2935 from the verkle branch
  • Fix Engine Prague Acceptance tests
  • Implement tests for BlockHashOperation and HistoricalBlockHashProcessor

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review April 26, 2024 14:21
@Gabriel-Trintinalia Gabriel-Trintinalia changed the title WIP - EIP-2935 EIP-2935 Apr 26, 2024
Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

This is good, the requested changes are naming and contract addresses.

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
storeParentHash(account, currentBlockHeader);

BlockHeader ancestor =
blockchain.getBlockHeader(currentBlockHeader.getParentHash()).orElseThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

What will happen if an exception is thrown due to not finding a parent hash? Will Besu crash?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, should likely just replace this with a presence check, and no-op if it is missing

Copy link
Contributor

Choose a reason for hiding this comment

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

normally it's not possible to try import a block without having the parent it will be a critical issue. maybe we need to test to be sure the behavior is correct in this case and be sure we are considering the block as problematic to allow a retry ?

frame
.getWorldUpdater()
.get(HISTORY_STORAGE_ADDRESS)
.getStorageValue(UInt256.valueOf(soughtBlock % BLOCKHASH_OLD_WINDOW)));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should be doing soughtBlock % HISTORY_SERVE_WINDOW not soughtBlock % BLOCKHASH_OLD_WINDOW

Copy link
Contributor

Choose a reason for hiding this comment

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

I think jason is right here, we may need to add a test where the block being sought is > BLOCKHASH_OLD_WINDOW but < HISTORY_SERVE_WINDOW

Copy link
Contributor

Choose a reason for hiding this comment

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

The last information I had was that this EIP was not supposed to serve more than 256 block hashes with the block hash operation, but this may have changed and needs to be verified. @Gabriel-Trintinalia

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BLOCKHASH_OLD_WINDOW is the serving window pre-prague. HISTORY_SERVE_WINDOW is the new serving window. There was an error in that part. Fixed now

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.

It seems to be fine for me as it's similar to the verkle implementation that is currently working in a devnet.

We just need to be sure we are catching correctly the case where we don't have the parent header and try this feature with reference tests when it will be available

and check the block hash operation implementation

storeParentHash(account, currentBlockHeader);

BlockHeader ancestor =
blockchain.getBlockHeader(currentBlockHeader.getParentHash()).orElseThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

normally it's not possible to try import a block without having the parent it will be a critical issue. maybe we need to test to be sure the behavior is correct in this case and be sure we are considering the block as problematic to allow a retry ?

Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

Agree with jasons comments

storeParentHash(account, currentBlockHeader);

BlockHeader ancestor =
blockchain.getBlockHeader(currentBlockHeader.getParentHash()).orElseThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, should likely just replace this with a presence check, and no-op if it is missing

frame
.getWorldUpdater()
.get(HISTORY_STORAGE_ADDRESS)
.getStorageValue(UInt256.valueOf(soughtBlock % BLOCKHASH_OLD_WINDOW)));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think jason is right here, we may need to add a test where the block being sought is > BLOCKHASH_OLD_WINDOW but < HISTORY_SERVE_WINDOW

Gabriel-Trintinalia and others added 3 commits May 7, 2024 11:02
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

great work!

jflo added 3 commits May 8, 2024 12:57
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Copy link
Contributor

@shemnon shemnon left a comment

Choose a reason for hiding this comment

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

EVM implementation will cause problems with downstream users of the library. It should be refactored so the logic remains within the Block Hash Lookup function passed into the EVM, rather than bleeding into block hash operation logic. This is why the function was created.

@@ -29,45 +32,105 @@
/** The Block hash operation. */
public class BlockHashOperation extends AbstractFixedCostOperation {

private static final int MAX_RELATIVE_BLOCK = 255;
/** The HISTORY_STORAGE_ADDRESS */
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't like this implementation, as it forces design decisions onto downstream users of the library.

This logic should live in a new BlockHashLookup function that is wired in in the mainnet protocol schedule, rather than re-writing the operation based on a flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's a WIP of how I think it should work - main...shemnon:besu:eip-2935-danno

  • Move all block hash lookup out of the operation, the operation only delegates to the data rpovider
  • the data provider is part of the protocol spec
  • merge in the beacon and block hash processing into the same class
  • MainnetProtocolSpecs is where it all gets loaded in.

Signed-off-by: Justin Florentine <justin+github@florentine.us>
@jframe jframe dismissed their stale review May 9, 2024 03:34

Changes aren't needed

@shemnon
Copy link
Contributor

shemnon commented May 9, 2024

Changes are needed, it damages the utility of the standalone EVM library. Here's my WIP to retain this utility - main...shemnon:besu:eip-2935-danno

@shemnon
Copy link
Contributor

shemnon commented May 9, 2024

Here's a more fully worked version: #7080
I'll clean up the FIXMEs tomorrow. Acceptance and reference tests worked locally.

@shemnon
Copy link
Contributor

shemnon commented May 9, 2024

PR #7080 is ready to review. It includes the changes in this PR but also containing the changes the EVM needs to remain a standalone library. @Gabriel-Trintinalia

@Gabriel-Trintinalia
Copy link
Contributor Author

Closed in favour of #7080

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.

EIP-2935: Serve historical block hashes from state
5 participants