-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix OP Stack header validation / Remove snapshot from snap-synced cha…
…ins (#7588)
- Loading branch information
1 parent
966113f
commit de191c0
Showing
9 changed files
with
84 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 25 additions & 3 deletions
28
src/Nethermind/Nethermind.Optimism/OptimismHeaderValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,43 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Nethermind.Blockchain; | ||
using Nethermind.Consensus; | ||
using Nethermind.Consensus.Messages; | ||
using Nethermind.Consensus.Validators; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Int256; | ||
using Nethermind.Logging; | ||
using Nethermind.Merge.Plugin; | ||
|
||
namespace Nethermind.Optimism; | ||
|
||
public class OptimismHeaderValidator( | ||
public class PreBedrockHeaderValidator( | ||
IBlockTree? blockTree, | ||
ISealValidator? sealValidator, | ||
ISpecProvider? specProvider, | ||
ILogManager? logManager) | ||
: HeaderValidator(blockTree, sealValidator, specProvider, logManager) | ||
ILogManager? logManager) : HeaderValidator(blockTree, sealValidator, specProvider, logManager) | ||
{ | ||
public override bool Validate(BlockHeader header, BlockHeader? parent, bool isUncle, [NotNullWhen(false)] out string? error) | ||
{ | ||
error = null; | ||
return ValidateParent(header, parent, ref error); | ||
} | ||
} | ||
|
||
public class OptimismHeaderValidator( | ||
IPoSSwitcher poSSwitcher, | ||
IBlockTree blockTree, | ||
ISealValidator sealValidator, | ||
ISpecProvider specProvider, | ||
ILogManager logManager) | ||
: MergeHeaderValidator( | ||
poSSwitcher, | ||
new PreBedrockHeaderValidator(blockTree, sealValidator, specProvider, logManager), | ||
blockTree, specProvider, sealValidator, logManager) | ||
{ | ||
protected override bool ValidateGasLimitRange(BlockHeader header, BlockHeader parent, IReleaseSpec spec, ref string? error) => true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Nethermind.Consensus; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Crypto; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Int256; | ||
using Nethermind.Optimism; | ||
|
||
public class OptimismPoSSwitcher(ISpecProvider specProvider, long bedrockBlockNumber) : IPoSSwitcher | ||
{ | ||
public UInt256? TerminalTotalDifficulty => specProvider.TerminalTotalDifficulty; | ||
|
||
public UInt256? FinalTotalDifficulty => TerminalTotalDifficulty; | ||
|
||
public bool TransitionFinished => true; | ||
|
||
public Hash256? ConfiguredTerminalBlockHash => null; | ||
|
||
public long? ConfiguredTerminalBlockNumber => null; | ||
|
||
public event EventHandler TerminalBlockReached { add { } remove { } } | ||
|
||
public void ForkchoiceUpdated(BlockHeader newHeadHash, Hash256 finalizedHash) { } | ||
|
||
public (bool IsTerminal, bool IsPostMerge) GetBlockConsensusInfo(BlockHeader header) | ||
{ | ||
return (header.Number == bedrockBlockNumber - 1, header.IsPostMerge = header.Number >= bedrockBlockNumber); | ||
} | ||
|
||
public bool HasEverReachedTerminalBlock() => true; | ||
|
||
public bool IsPostMerge(BlockHeader header) => GetBlockConsensusInfo(header).IsPostMerge; | ||
|
||
public bool TryUpdateTerminalBlock(BlockHeader header) => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters