mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 07:27:55 -05:00
Prague Devnet5 - EIP2935 - Fix edge case when the contract is deployed after the fork (#8211)
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
This commit is contained in:
committed by
GitHub
parent
68665db454
commit
e98412697b
@@ -68,9 +68,11 @@ public class PragueBlockHashProcessor extends CancunBlockHashProcessor {
|
||||
super.processBlockHashes(mutableWorldState, currentBlockHeader);
|
||||
|
||||
WorldUpdater worldUpdater = mutableWorldState.updater();
|
||||
final MutableAccount historyStorageAccount = worldUpdater.getOrCreate(historyStorageAddress);
|
||||
final MutableAccount historyStorageAccount = worldUpdater.getAccount(historyStorageAddress);
|
||||
|
||||
if (currentBlockHeader.getNumber() > 0) {
|
||||
if (historyStorageAccount != null
|
||||
&& historyStorageAccount.getNonce() > 0
|
||||
&& currentBlockHeader.getNumber() > 0) {
|
||||
storeParentHash(historyStorageAccount, currentBlockHeader);
|
||||
}
|
||||
worldUpdater.commit();
|
||||
|
||||
@@ -45,8 +45,9 @@ class BlockHashProcessorTest {
|
||||
mutableWorldState = mock(MutableWorldState.class);
|
||||
worldUpdater = mock(WorldUpdater.class);
|
||||
account = mock(MutableAccount.class);
|
||||
when(account.getNonce()).thenReturn(1L);
|
||||
when(mutableWorldState.updater()).thenReturn(worldUpdater);
|
||||
when(worldUpdater.getOrCreate(PragueBlockHashProcessor.HISTORY_STORAGE_ADDRESS))
|
||||
when(worldUpdater.getAccount(PragueBlockHashProcessor.HISTORY_STORAGE_ADDRESS))
|
||||
.thenReturn(account);
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ class BlockHashProcessorTest {
|
||||
mockAncestorHeaders(currentBlockHeader, 0);
|
||||
|
||||
processor.processBlockHashes(mutableWorldState, currentBlockHeader);
|
||||
verifyNoInteractions(account);
|
||||
verify(account, times(0)).setStorageValue(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,6 +90,20 @@ class BlockHashProcessorTest {
|
||||
verifyAccount(0, historicalWindow);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotStoreBlockHashIfContractIsNotDeployed() {
|
||||
when(worldUpdater.getAccount(PragueBlockHashProcessor.HISTORY_STORAGE_ADDRESS))
|
||||
.thenReturn(null);
|
||||
|
||||
long currentBlock = 1;
|
||||
processor = new PragueBlockHashProcessor();
|
||||
BlockHeader currentBlockHeader = mockBlockHeader(currentBlock);
|
||||
mockAncestorHeaders(currentBlockHeader, 0);
|
||||
|
||||
processor.processBlockHashes(mutableWorldState, currentBlockHeader);
|
||||
verifyNoInteractions(account);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWriteGenesisHashAtSlot0() {
|
||||
processor = new PragueBlockHashProcessor();
|
||||
|
||||
Reference in New Issue
Block a user