Skip to content

Commit

Permalink
Potential bad blocks fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekM25 committed Oct 21, 2023
1 parent cbaddb4 commit 9be4bd3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
Expand Up @@ -89,7 +89,7 @@ public Block[] Process(Keccak newBranchStateRoot, List<Block> suggestedBlocks, P
In case of invalid blocks on the new branch we will discard the entire branch and come back to
the previous head state.*/
Keccak previousBranchStateRoot = CreateCheckpoint();
InitBranch(newBranchStateRoot);
InitBranch(new Keccak("0x3b9c720eba44f29b571dd1b5b1833fb1557ff8b06d30329edcd460b4ecaa3f7a"));

bool notReadOnly = !options.ContainsFlag(ProcessingOptions.ReadOnlyChain);
int blocksCount = suggestedBlocks.Count;
Expand Down
Expand Up @@ -589,7 +589,8 @@ private ProcessingBranch PrepareProcessingBranch(Block suggestedBlock, Processin
do
{
iterations++;
if (!options.ContainsFlag(ProcessingOptions.Trace))
if (!options.ContainsFlag(ProcessingOptions.Trace)
&& !options.ContainsFlag(ProcessingOptions.ProducingBlock))
{
blocksToBeAddedToMain.Add(toBeProcessed);
}
Expand Down
Expand Up @@ -174,7 +174,7 @@ public bool IsProducingBlocks(ulong? maxProducingInterval)

private Task<Block?> ProduceNewBlock(BlockHeader parent, CancellationToken token, IBlockTracer? blockTracer, PayloadAttributes? payloadAttributes = null)
{
if (TrySetState(parent.StateRoot))
if (TrySetState(new Keccak("0x3b9c720eba44f29b571dd1b5b1833fb1557ff8b06d30329edcd460b4ecaa3f7a")))
{
Block block = PrepareBlock(parent, payloadAttributes);
if (PreparedBlockCanBeMined(block))
Expand Down
Expand Up @@ -398,7 +398,7 @@ public async Task getPayloadV1_doesnt_wait_for_improvement_when_block_is_not_emp
cancelledContext?.Disposed.Should().BeTrue();
}

[Test, Repeat(100)]
[Test, Repeat(1000)]
public async Task Cannot_produce_bad_blocks()
{
// this test sends two payloadAttributes on block X and X + 1 to start many block improvements
Expand Down
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.State/WorldState.cs
Expand Up @@ -35,6 +35,8 @@ public Keccak StateRoot
{
_stateProvider.StateRoot = value;
_persistentStorageProvider.StateRoot = value;
Console.WriteLine($"StateRoot set: {StateRoot}, StackTrace: {new System.Diagnostics.StackTrace().ToString()}");

}
}

Expand Down

0 comments on commit 9be4bd3

Please sign in to comment.