-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
39 deletions.
There are no files selected for viewing
69 changes: 34 additions & 35 deletions
69
src/Nethermind/Nethermind.Specs.Test/CustomSpecProvider.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,60 +1,59 @@ | ||
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Int256; | ||
using Nethermind.Specs.ChainSpecStyle; | ||
using Nethermind.Specs.Forks; | ||
|
||
namespace Nethermind.Specs.Test | ||
namespace Nethermind.Specs.Test; | ||
|
||
public class CustomSpecProvider : SpecProviderBase, ISpecProvider | ||
{ | ||
public class CustomSpecProvider : SpecProviderBase, ISpecProvider | ||
{ | ||
private ForkActivation? _theMergeBlock = null; | ||
private ForkActivation? _theMergeBlock = null; | ||
|
||
public ulong NetworkId { get; } | ||
public ulong ChainId { get; } | ||
public ulong NetworkId { get; } | ||
public ulong ChainId { get; } | ||
|
||
public CustomSpecProvider(params (ForkActivation Activation, IReleaseSpec Spec)[] transitions) : this(TestBlockchainIds.NetworkId, TestBlockchainIds.ChainId, transitions) | ||
{ | ||
} | ||
public CustomSpecProvider(params (ForkActivation Activation, IReleaseSpec Spec)[] transitions) : this(TestBlockchainIds.NetworkId, TestBlockchainIds.ChainId, transitions) | ||
{ | ||
} | ||
|
||
public CustomSpecProvider(ulong networkId, ulong chainId, params (ForkActivation Activation, IReleaseSpec Spec)[] transitions) | ||
{ | ||
NetworkId = networkId; | ||
ChainId = chainId; | ||
public CustomSpecProvider(ulong networkId, ulong chainId, params (ForkActivation Activation, IReleaseSpec Spec)[] transitions) | ||
{ | ||
NetworkId = networkId; | ||
ChainId = chainId; | ||
|
||
(ForkActivation Activation, IReleaseSpec Spec)[] orderedTransitions = transitions.OrderBy(r => r.Activation).ToArray(); | ||
(ForkActivation Activation, IReleaseSpec Spec)[] orderedTransitions = transitions.OrderBy(r => r.Activation).ToArray(); | ||
|
||
if (orderedTransitions.or) | ||
LoadTransitions(orderedTransitions); | ||
TransitionActivations = orderedTransitions.Select(t => t.Activation).ToArray(); | ||
} | ||
TransitionActivations = orderedTransitions.Select(t => t.Activation).ToArray(); | ||
} | ||
|
||
public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalDifficulty = null) | ||
{ | ||
if (blockNumber is not null) | ||
_theMergeBlock = (ForkActivation)blockNumber; | ||
if (terminalTotalDifficulty is not null) | ||
TerminalTotalDifficulty = terminalTotalDifficulty; | ||
} | ||
public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalDifficulty = null) | ||
{ | ||
if (blockNumber is not null) | ||
_theMergeBlock = (ForkActivation)blockNumber; | ||
if (terminalTotalDifficulty is not null) | ||
TerminalTotalDifficulty = terminalTotalDifficulty; | ||
} | ||
|
||
public ForkActivation? MergeBlockNumber => _theMergeBlock; | ||
public ForkActivation? MergeBlockNumber => _theMergeBlock; | ||
|
||
public ulong TimestampFork { get; set; } = ISpecProvider.TimestampForkNever; | ||
public UInt256? TerminalTotalDifficulty { get; set; } | ||
public ulong TimestampFork { get; set; } = ISpecProvider.TimestampForkNever; | ||
public UInt256? TerminalTotalDifficulty { get; set; } | ||
|
||
public long? DaoBlockNumber | ||
public long? DaoBlockNumber | ||
{ | ||
get | ||
{ | ||
get | ||
{ | ||
(ForkActivation forkActivation, IReleaseSpec? daoRelease) = _blockTransitions.SingleOrDefault(t => t.Spec == Dao.Instance); | ||
return daoRelease is not null ? forkActivation.BlockNumber : null; | ||
} | ||
(ForkActivation forkActivation, IReleaseSpec? daoRelease) = _blockTransitions.SingleOrDefault(t => t.Spec == Dao.Instance); | ||
return daoRelease is not null ? forkActivation.BlockNumber : null; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
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