Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add holesky configs and chainspec #6034

Merged
merged 4 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,062 changes: 1,062 additions & 0 deletions src/Nethermind/Chains/holesky.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Core/BlockchainIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static class BlockchainIds
public const int Chiado = 10200;
public const int Volta = 73799;
public const int Sepolia = 11155111;
public const int Holesky = 17000;

public static string GetBlockchainName(ulong networkId)
{
Expand Down
14 changes: 14 additions & 0 deletions src/Nethermind/Nethermind.Runner/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Holesky": {
"commandName": "Project",
"commandLineArgs": "-c holesky -dd %NETHERMIND_DATA_DIR%",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Holesky (archive)": {
"commandName": "Project",
"commandLineArgs": "-c holesky_archive -dd %NETHERMIND_DATA_DIR%",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Kovan": {
"commandName": "Project",
"commandLineArgs": "-c kovan -dd %NETHERMIND_DATA_DIR% --JsonRpc.Enabled true",
Expand Down
30 changes: 30 additions & 0 deletions src/Nethermind/Nethermind.Runner/configs/holesky.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Init": {
"ChainSpecPath": "chainspec/holesky.json",
"GenesisHash": "0xff9006519a8ce843ac9c28549d24211420b546e12ce2d170c77a8cca7964f23d",
"BaseDbPath": "nethermind_db/holesky",
"LogFileName": "holesky.logs.txt"
},
"Sync": {
"FastSync": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+SnapSync true?
I guess we have to add pivot, probably genesis block in this case. I haven't checked how pivots work with genesis though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check here
#6034 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, please make sure any network can work without pivots. I am not so sure about it. It would be nice to know not only in holesky context

},
"Metrics": {
"NodeName": "Holesky"
},
"Blocks": {
"TargetBlockGasLimit": 30000000
},
"JsonRpc": {
"Enabled": true,
"Timeout": 20000,
"Host": "127.0.0.1",
"Port": 8545,
"EngineHost": "127.0.0.1",
"EnginePort": 8551,
"EngineEnabledModules": "net;eth;subscribe;engine;web3;client"
},
"Merge": {
"Enabled": true,
"FinalTotalDifficulty": "0"
}
}
33 changes: 33 additions & 0 deletions src/Nethermind/Nethermind.Runner/configs/holesky_archive.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"Init": {
"ChainSpecPath": "chainspec/holesky.json",
"GenesisHash": "0xff9006519a8ce843ac9c28549d24211420b546e12ce2d170c77a8cca7964f23d",
"BaseDbPath": "nethermind_db/holesky_archive",
"LogFileName": "holesky_archive.logs.txt"
},
"Metrics": {
"NodeName": "Holesky Archive"
},
"Blocks": {
"TargetBlockGasLimit": 30000000
},
"Receipt": {
"TxLookupLimit": 0
},
"Pruning": {
"Mode": "None"
},
"JsonRpc": {
"Enabled": true,
"Timeout": 20000,
"Host": "127.0.0.1",
"Port": 8545,
"EngineHost": "127.0.0.1",
"EnginePort": 8551,
"EngineEnabledModules": "net;eth;subscribe;engine;web3;client"
},
"Merge": {
"Enabled": true,
"FinalTotalDifficulty": "0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,33 @@ public void Sepolia_loads_properly()
t => ValidateSlotByTimestamp(t, SepoliaSpecProvider.BeaconChainGenesisTimestamp).Should().BeTrue());
}

[Test]
public void Holesky_loads_properly()
{
ChainSpec chainSpec = LoadChainSpecFromChainFolder("holesky");
ChainSpecBasedSpecProvider provider = new(chainSpec);
ISpecProvider hardCodedSpec = HoleskySpecProvider.Instance;

List<ForkActivation> forkActivationsToTest = new()
{
new ForkActivation(0, HoleskySpecProvider.GenesisTimestamp),
new ForkActivation(1, HoleskySpecProvider.ShanghaiTimestamp),
new ForkActivation(3, HoleskySpecProvider.ShanghaiTimestamp + 24),
new ForkActivation(4, HoleskySpecProvider.CancunTimestamp),
new ForkActivation(5, HoleskySpecProvider.CancunTimestamp + 12),
};

CompareSpecProviders(hardCodedSpec, provider, forkActivationsToTest);
Assert.That(provider.TerminalTotalDifficulty, Is.EqualTo(hardCodedSpec.TerminalTotalDifficulty));
Assert.That(provider.GenesisSpec.Eip1559TransitionBlock, Is.EqualTo(0));
Assert.That(provider.GenesisSpec.DifficultyBombDelay, Is.EqualTo(0));
Assert.That(provider.ChainId, Is.EqualTo(BlockchainIds.Holesky));
Assert.That(provider.NetworkId, Is.EqualTo(BlockchainIds.Holesky));

//GetTransitionTimestamps(chainSpec.Parameters).Should().AllSatisfy(
// t => ValidateSlotByTimestamp(t, HoleskySpecProvider.GenesisTimestamp).Should().BeTrue());
}

[Test]
public void Rinkeby_loads_properly()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,31 @@ public void Can_load_sepolia()
chainSpec.ShanghaiTimestamp.Should().Be(1677557088);
}

[Test]
public void Can_load_holesky()
{
string path = Path.Combine(TestContext.CurrentContext.WorkDirectory, "../../../../", "Chains/holesky.json");
ChainSpec chainSpec = LoadChainSpec(path);

Assert.That(chainSpec.NetworkId, Is.EqualTo(17000), $"{nameof(chainSpec.NetworkId)}");
Assert.That(chainSpec.Name, Is.EqualTo("Holesky Testnet"), $"{nameof(chainSpec.Name)}");
Assert.That(chainSpec.DataDir, Is.EqualTo("holesky"), $"{nameof(chainSpec.DataDir)}");
Assert.That(chainSpec.SealEngineType, Is.EqualTo(SealEngineType.Ethash), "engine");

chainSpec.DaoForkBlockNumber.Should().Be(null);
chainSpec.TangerineWhistleBlockNumber.Should().Be(0);
chainSpec.SpuriousDragonBlockNumber.Should().Be(0);
chainSpec.ByzantiumBlockNumber.Should().Be(0);
chainSpec.ConstantinopleBlockNumber.Should().Be(0);
chainSpec.ConstantinopleFixBlockNumber.Should().Be(0);
chainSpec.IstanbulBlockNumber.Should().Be(0);
chainSpec.BerlinBlockNumber.Should().Be(0);
chainSpec.LondonBlockNumber.Should().Be(0);
chainSpec.ShanghaiTimestamp.Should().Be(HoleskySpecProvider.ShanghaiTimestamp);
chainSpec.ShanghaiTimestamp.Should().Be(HoleskySpecProvider.Instance.TimestampFork);
chainSpec.CancunTimestamp.Should().Be(HoleskySpecProvider.CancunTimestamp);
}

[Test]
public void Can_load_posdao_with_openethereum_pricing_transitions()
{
Expand Down
51 changes: 51 additions & 0 deletions src/Nethermind/Nethermind.Specs/HoleskySpecProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Core.Specs;
using Nethermind.Int256;
using Nethermind.Specs.Forks;

namespace Nethermind.Specs;

public class HoleskySpecProvider : ISpecProvider
{
public const ulong GenesisTimestamp = 0x65046360;
public const ulong ShanghaiTimestamp = 0x65047260;
public const ulong CancunTimestamp = 0x77359400;

private HoleskySpecProvider() { }

public IReleaseSpec GetSpec(ForkActivation forkActivation)
{
return forkActivation.Timestamp switch
{
null or < ShanghaiTimestamp => GenesisSpec,
< CancunTimestamp => Shanghai.Instance,
_ => Cancun.Instance
};
}

public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalDifficulty = null)
{
if (blockNumber is not null)
MergeBlockNumber = (ForkActivation)blockNumber;
if (terminalTotalDifficulty is not null)
TerminalTotalDifficulty = terminalTotalDifficulty;
}

public ulong NetworkId => BlockchainIds.Holesky;
public ulong ChainId => NetworkId;
public long? DaoBlockNumber => null;
public ForkActivation? MergeBlockNumber { get; private set; } = (0, GenesisTimestamp);
public ulong TimestampFork => ShanghaiTimestamp;
public UInt256? TerminalTotalDifficulty { get; private set; } = 0;
public IReleaseSpec GenesisSpec { get; } = London.Instance;
public ForkActivation[] TransitionActivations { get; } =
{
(1, ShanghaiTimestamp),
(2, CancunTimestamp)
};

public static readonly HoleskySpecProvider Instance = new();
}
8 changes: 7 additions & 1 deletion src/Nethermind/Nethermind.Specs/ReleaseSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public ReleaseSpec Clone()
public bool IsEip5656Enabled { get; set; }
public bool IsEip6780Enabled { get; set; }
public bool IsEip4788Enabled { get; set; }
public Address Eip4788ContractAddress { get; set; }

private Address _eip4788ContractAddress;
public Address Eip4788ContractAddress
{
get => IsEip4788Enabled ? _eip4788ContractAddress : null;
set => _eip4788ContractAddress = value;
}
}
}