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

eth_simulateV1 - Add BlockSimulator feature #7941

Merged

Conversation

Gabriel-Trintinalia
Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia commented Nov 27, 2024

Pull Request Description

This pull request introduces a new Block Simulation feature that allows users to simulate multiple transaction calls sequentially, overriding the state and block values for the execution context.

Key Features:

  • State Override Reuse: This feature reuses the State override classes and parameters that were implemented for eth_call in PR #7892.
  • Block Overrides Implementation: It also implements block override classes that will be used in issue #7822.
  • Base Implementation for eth_simulateV1: This PR serves as the base implementation for the eth_simulateV1 method.
  • BlockSimulationService: A new BlockSimulationService is introduced, providing plugins with the flexibility to simulate blocks like Besu's TransactionSimulator.

Spec: ethereum/execution-apis#484

TODO:

  • Implement the eth_simulateV1 JSON-RPC method to handle block simulation requests as outlined in issue #6203. The implementation was initially included in this PR but was split for easier review.
  • Add logs and transfer logs.
  • Support withdrawals.
  • Add tons of tests

Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review December 11, 2024 11:02
Copy link
Contributor

@pinges pinges left a comment

Choose a reason for hiding this comment

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

Added a few questions


private final boolean validation;

public BlockStateCall(
Copy link
Contributor

Choose a reason for hiding this comment

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

should that be BlockStateCalls?

final List<? extends BlockStateCall> blockStateCalls,
final MutableWorldState worldState) {
List<BlockSimulationResult> simulationResults = new ArrayList<>();
for (BlockStateCall blockStateCall : blockStateCalls) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When you are simulating multiple blocks, does it make sense that each of the blockStateCalls has it's own blockOverrides?

Gabriel-Trintinalia and others added 6 commits December 13, 2024 13:52
…rServiceImpl.java

Co-authored-by: Stefan Pingel <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
…saction/BlockSimulationResult.java

Co-authored-by: Stefan Pingel <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
…saction/BlockSimulationResult.java

Co-authored-by: Stefan Pingel <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
…saction/BlockSimulationResult.java

Co-authored-by: Stefan Pingel <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Copy link
Contributor

@Matilda-Clerke Matilda-Clerke left a comment

Choose a reason for hiding this comment

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

Can't comment too much the changes themselves, but added a few about generic stuff

blockSimulator.process(blockHeader, Collections.emptyList());

assertNotNull(results);
verify(worldStateArchive).getMutable(any(BlockHeader.class), eq(false));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It's usually best to verify mock calls before asserting the results, since incorrect or unexpected calls can produce incorrect results and verifying before asserting can help catch this with less investigation

Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
@Gabriel-Trintinalia Gabriel-Trintinalia changed the title Implement eth_simulateV1 - Add Block simulator feature eth_simulateV1 - Add BlockSimulator feature Dec 18, 2024
Copy link
Contributor

@Matilda-Clerke Matilda-Clerke left a comment

Choose a reason for hiding this comment

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

LGTM, but I'll leave unapproved for the others to approved

Copy link
Contributor

@jframe jframe left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

prob worth a changelog? or wait for the RPC

import java.util.List;

/** This class represents the result of simulating the processing of a block. */
public class PluginBlockSimulationResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

why PluginBlockSimulationResult - how does this relate to BlockSimulationResult

@Gabriel-Trintinalia Gabriel-Trintinalia enabled auto-merge (squash) December 19, 2024 04:21
@Gabriel-Trintinalia Gabriel-Trintinalia merged commit a03c98b into hyperledger:main Dec 19, 2024
43 checks passed
garyschulte pushed a commit that referenced this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linea helps L2s using besu mainnet RPC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants