Skip to content

Commit

Permalink
Merge branch 'master' into flat_encoding_requests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjnrohit authored Nov 6, 2024
2 parents 4633e9d + 82c78e7 commit 7e827cd
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/Nethermind/Nethermind.Init/Steps/RegisterRpcModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,16 @@ public virtual async Task Execute(CancellationToken cancellationToken)

ManualPruningTrigger pruningTrigger = new();
_api.PruningTrigger.Add(pruningTrigger);
(IApiWithStores getFromApi, IApiWithBlockchain setInApi) = _api.ForInit;
AdminRpcModule adminRpcModule = new(
_api.BlockTree,
networkConfig,
_api.PeerPool,
_api.StaticNodesManager,
_api.Enode,
initConfig.BaseDbPath,
pruningTrigger);
pruningTrigger,
getFromApi.ChainSpec.Parameters);
rpcModuleProvider.RegisterSingle<IAdminRpcModule>(adminRpcModule);

StepDependencyException.ThrowIfNull(_api.TxPoolInfoProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Nethermind.Network;
using Nethermind.Network.Config;
using Nethermind.Serialization.Json;
using Nethermind.Specs.ChainSpecStyle;
using Nethermind.Stats.Model;
using NSubstitute;
using NUnit.Framework;
Expand Down Expand Up @@ -44,14 +45,20 @@ public void Setup()

IStaticNodesManager staticNodesManager = Substitute.For<IStaticNodesManager>();
Enode enode = new(_enodeString);
ChainSpec chainSpec = new()
{
Parameters = new ChainParameters()
};

_adminRpcModule = new AdminRpcModule(
_blockTree,
_networkConfig,
peerPool,
staticNodesManager,
enode,
_exampleDataDir,
new ManualPruningTrigger());
new ManualPruningTrigger(),
chainSpec.Parameters);

_serializer = new EthereumJsonSerializer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
using Nethermind.Core.Crypto;
using Nethermind.Network;
using Nethermind.Network.Config;
using Nethermind.Specs.ChainSpecStyle;
using Nethermind.Stats.Model;

namespace Nethermind.JsonRpc.Modules.Admin;

public class AdminRpcModule : IAdminRpcModule
{
private readonly ChainParameters _parameters;
private readonly IBlockTree _blockTree;
private readonly INetworkConfig _networkConfig;
private readonly IPeerPool _peerPool;
Expand All @@ -33,7 +35,8 @@ public AdminRpcModule(
IStaticNodesManager staticNodesManager,
IEnode enode,
string dataDir,
ManualPruningTrigger pruningTrigger)
ManualPruningTrigger pruningTrigger,
ChainParameters parameters)
{
_enode = enode ?? throw new ArgumentNullException(nameof(enode));
_dataDir = dataDir ?? throw new ArgumentNullException(nameof(dataDir));
Expand All @@ -42,6 +45,7 @@ public AdminRpcModule(
_networkConfig = networkConfig ?? throw new ArgumentNullException(nameof(networkConfig));
_staticNodesManager = staticNodesManager ?? throw new ArgumentNullException(nameof(staticNodesManager));
_pruningTrigger = pruningTrigger;
_parameters = parameters ?? throw new ArgumentNullException(nameof(parameters));

BuildNodeInfo();
}
Expand Down Expand Up @@ -71,6 +75,7 @@ private void UpdateEthProtocolInfo()
_nodeInfo.Protocols["eth"].NewtorkId = _blockTree.ChainId;
_nodeInfo.Protocols["eth"].HeadHash = _blockTree.HeadHash;
_nodeInfo.Protocols["eth"].GenesisHash = _blockTree.GenesisHash;
_nodeInfo.Protocols["eth"].Config = _parameters;
}

public async Task<ResultWrapper<string>> admin_addPeer(string enode, bool addToStaticNodes = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Nethermind.Core.Crypto;
using Nethermind.Int256;
using Nethermind.Specs.ChainSpecStyle;
using System.Text.Json.Serialization;

namespace Nethermind.JsonRpc.Modules.Admin
Expand All @@ -17,5 +18,7 @@ public class EthProtocolInfo
public Hash256 HeadHash { get; set; }
[JsonPropertyName("network")]
public ulong NewtorkId { get; set; }
[JsonPropertyName("config")]
public ChainParameters Config { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@ public class OptimismChainSpecEngineParameters : IChainSpecEngineParameters

public byte[]? Create2DeployerCode { get; set; }

public void AddTransitions(SortedSet<long> blockNumbers, SortedSet<ulong> timestamps)
{
ArgumentNullException.ThrowIfNull(BedrockBlockNumber);
ArgumentNullException.ThrowIfNull(RegolithTimestamp);
ArgumentNullException.ThrowIfNull(CanyonTimestamp);
ArgumentNullException.ThrowIfNull(EcotoneTimestamp);
ArgumentNullException.ThrowIfNull(FjordTimestamp);
ArgumentNullException.ThrowIfNull(GraniteTimestamp);
blockNumbers.Add(BedrockBlockNumber.Value);
timestamps.Add(RegolithTimestamp.Value);
timestamps.Add(CanyonTimestamp.Value);
timestamps.Add(EcotoneTimestamp.Value);
timestamps.Add(FjordTimestamp.Value);
timestamps.Add(GraniteTimestamp.Value);
}

public void ApplyToReleaseSpec(ReleaseSpec spec, long startBlock, ulong? startTimestamp)
{
ArgumentNullException.ThrowIfNull(CanyonBaseFeeChangeDenominator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static class Build
public static NethermindApi ContextWithMocks()
{
var api = new NethermindApi(Substitute.For<IConfigProvider>(), Substitute.For<IJsonSerializer>(), LimboLogs.Instance,
new ChainSpec())
new ChainSpec { Parameters = new ChainParameters(), })
{
Enode = Substitute.For<IEnode>(),
TxPool = Substitute.For<ITxPool>(),
Expand Down
11 changes: 8 additions & 3 deletions src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Logging;
Expand All @@ -12,10 +13,14 @@ public class OverlayTrieStore(IKeyValueStoreWithBatching? keyValueStore, IReadOn
public override bool IsPersisted(Hash256? address, in TreePath path, in ValueHash256 keccak) =>
base.IsPersisted(address, in path, in keccak) || store.IsPersisted(address, in path, in keccak);

public override TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash)
internal override TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash, bool isReadOnly)
{
TrieNode node = base.FindCachedOrUnknown(address, in path, hash);
return node.NodeType == NodeType.Unknown ? store.FindCachedOrUnknown(address, in path, hash) : node;
ArgumentNullException.ThrowIfNull(hash);

TrieNode node = base.FindCachedOrUnknown(address, in path, hash, isReadOnly);
return node.NodeType == NodeType.Unknown
? store.FindCachedOrUnknown(address, in path, hash) // no need to pass isReadOnly - IReadOnlyTrieStore overrides it as true
: node;
}

public override byte[]? LoadRlp(Hash256? address, in TreePath path, Hash256 hash, ReadFlags flags = ReadFlags.None) =>
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ public IReadOnlyTrieStore AsReadOnly(INodeStorage? store) =>

public bool IsNodeCached(Hash256? address, in TreePath path, Hash256? hash) => DirtyNodesIsNodeCached(new TrieStoreDirtyNodesCache.Key(address, path, hash));

public virtual TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash) =>
public TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash) =>
FindCachedOrUnknown(address, path, hash, false);

internal TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash, bool isReadOnly)
internal virtual TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash, bool isReadOnly)
{
ArgumentNullException.ThrowIfNull(hash);

Expand Down

0 comments on commit 7e827cd

Please sign in to comment.