Skip to content

Commit

Permalink
Fix block replay to work with Shanghai blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
  • Loading branch information
siladu committed Jan 18, 2023
1 parent a7c96ca commit f97e694
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public <T> Optional<T> beforeTransactionInBlock(
action.performAction(
transaction, header, blockchain, mutableWorldState, transactionProcessor));
} else {
final ProtocolSpec spec = protocolSchedule.getByBlockNumber(header.getNumber());
final ProtocolSpec spec = protocolSchedule.getByBlockHeader(header);
transactionProcessor.processTransaction(
blockchain,
mutableWorldState.updater(),
Expand All @@ -107,7 +107,7 @@ public <T> Optional<T> afterTransactionInBlock(
blockHash,
transactionHash,
(transaction, blockHeader, blockchain, worldState, transactionProcessor) -> {
final ProtocolSpec spec = protocolSchedule.getByBlockNumber(blockHeader.getNumber());
final ProtocolSpec spec = protocolSchedule.getByBlockHeader(blockHeader);
transactionProcessor.processTransaction(
blockchain,
worldState.updater(),
Expand Down Expand Up @@ -139,7 +139,7 @@ private <T> Optional<T> performActionWithBlock(
if (body == null) {
return Optional.empty();
}
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockNumber(header.getNumber());
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(header);
final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
final BlockHeader previous = blockchain.getBlockHeader(header.getParentHash()).orElse(null);
if (previous == null) {
Expand Down Expand Up @@ -172,7 +172,7 @@ private Optional<Block> getBlock(final Hash blockHash) {

private Optional<Block> getBadBlock(final Hash blockHash) {
final ProtocolSpec protocolSpec =
protocolSchedule.getByBlockNumber(blockchain.getChainHeadHeader().getNumber());
protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader());
return protocolSpec.getBadBlocksManager().getBadBlock(blockHash);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void setUp() throws Exception {
when(previousBlockHeader.getStateRoot()).thenReturn(Hash.ZERO);
when(worldStateArchive.getMutable(Hash.ZERO, null, false))
.thenReturn(Optional.of(mutableWorldState));
when(protocolSchedule.getByBlockNumber(12)).thenReturn(protocolSpec);
when(protocolSchedule.getByBlockHeader(blockHeader)).thenReturn(protocolSpec);
when(protocolSpec.getTransactionProcessor()).thenReturn(transactionProcessor);
when(protocolSpec.getMiningBeneficiaryCalculator()).thenReturn(BlockHeader::getCoinbase);
when(blockchain.getChainHeadHeader()).thenReturn(blockHeader);
Expand Down

0 comments on commit f97e694

Please sign in to comment.