Skip to content

feat: add BlockReplayService as a block-level alternative to TraceService#9711

Draft
Gabriel-Trintinalia wants to merge 11 commits intohyperledger:mainfrom
Gabriel-Trintinalia:add-replay-service
Draft

feat: add BlockReplayService as a block-level alternative to TraceService#9711
Gabriel-Trintinalia wants to merge 11 commits intohyperledger:mainfrom
Gabriel-Trintinalia:add-replay-service

Conversation

@Gabriel-Trintinalia
Copy link
Contributor

The Trace Service currently replays individual transactions in isolation. This approach does not account for state changes that occur before transaction execution during block processing. This limitation makes transaction-level replay increasingly fragile as protocol complexity grows. This PR introduces a new BlockReplayService that replays blocks using the same execution path as Besu’s block processing logic.

Key characteristics:

  • Resolves the correct BlockProcessor from the protocol schedule for each block
  • Uses the exact pre-execution world state from the parent block
  • Executes the entire block, not individual transactions
  • Passes a WorldView to tracers, avoiding direct exposure of mutable state
  • Follows the same code paths as normal block execution, ensuring future compatibility with protocol upgrades

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>
Comment on lines 89 to 95
MutableWorldState worldState = getParentWorldState(blocks.getFirst());
beforeTracing.accept(worldState);

final List<BlockReplayResult> results = new ArrayList<>(blocks.size());

for (final Block block : blocks) {
worldState = getParentWorldState(block);
Copy link
Contributor

Choose a reason for hiding this comment

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

You must close each open World State to prevent a memory leak

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! Thanks!

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
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 worldstate part seems to be better now

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
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