Skip to content

Commit

Permalink
Fix node restart on gnosis-cancun (#6423)
Browse files Browse the repository at this point in the history
* first draft

* add more things

* fix metric

* fix

* add tests

* add serializers and tests

* simplification

* adjust network and rpc tests

* post-merge fixes

* enable eth68

* adjust tests

* fix

* Use blob gas instead of count

* Shuffle 4844 constants, add GetMaxBlobsPerBlock

* Replace `Keccak` with `Hash256`

* fix PeerInfoExtensions

* fix StateSyncDownloader

* fix GetNodeDataTrieNodeRecovery

* improve switching capabilities

* `WasProcessed = true` for Genesis `BlockInfo`

* Add tests

---------

Co-authored-by: Marcin Sobczak <marcindsobczak@gmail.com>
Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
Co-authored-by: Alexey Osipov <me@flcl.me>
  • Loading branch information
4 people committed Dec 28, 2023
1 parent 2a66d41 commit d8debc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Nethermind/Nethermind.Blockchain.Test/BlockTreeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1827,8 +1827,9 @@ public void Find_handles_invalid_blocks(Func<BlockTree, Hash256?, BlockTreeLooku
findFunction(blockTree, invalidBlock.Hash, lookupOptions).Should().Be(foundInvalid ? invalidBlock.Header : null);
}

[Test]
public void On_restart_loads_already_processed_genesis_block()
[TestCase(true)]
[TestCase(false)]
public void On_restart_loads_already_processed_genesis_block(bool wereProcessed)
{
TestMemDb blocksDb = new();
TestMemDb headersDb = new();
Expand Down Expand Up @@ -1897,7 +1898,7 @@ public void On_restart_loads_already_processed_genesis_block()
tree.SuggestBlock(genesis);
tree.Genesis.Should().NotBeNull();

tree.UpdateMainChain(ImmutableList.Create(genesis), true);
tree.UpdateMainChain(ImmutableList.Create(genesis), wereProcessed);

tree.SuggestBlock(second);
tree.SuggestBlock(third);
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Blockchain/BlockTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ void SetTotalDifficultyDeep(BlockHeader current)
{
current.TotalDifficulty = current.Difficulty;
BlockInfo blockInfo = new(current.Hash, current.Difficulty);
blockInfo.WasProcessed = true;
UpdateOrCreateLevel(current.Number, current.Hash, blockInfo);
}

Expand Down

0 comments on commit d8debc6

Please sign in to comment.