-
Notifications
You must be signed in to change notification settings - Fork 451
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
Make chainspec extendable by plugins #7540
Merged
Merged
Changes from 42 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
2ada5d8
Custom chainspec engine
deffrian d9d4f2a
Optimism & add more types to decoder
deffrian d61acc3
Update src/Nethermind/Nethermind.Config/ConfigSourceHelper.cs
deffrian 6ea1a10
Update src/Nethermind/Nethermind.Config/ConfigSourceHelper.cs
deffrian 33f8a6c
Small fixes
deffrian f7b8e32
Update src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecParame…
deffrian 32cbfa4
Small fixes
deffrian 70d2227
Custom chainspec engine
deffrian da4313b
Optimism & add more types to decoder
deffrian 3c39505
Update src/Nethermind/Nethermind.Config/ConfigSourceHelper.cs
deffrian c44f8e8
Update src/Nethermind/Nethermind.Config/ConfigSourceHelper.cs
deffrian 7f8ae03
Small fixes
deffrian be56036
Update src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecParame…
deffrian b6f1a53
Small fixes
deffrian bed5240
Merge remote-tracking branch 'origin/refactor/chainspec-v2' into refa…
deffrian 4b5d291
NethDev
deffrian 777c49a
Clique
deffrian 4261b1e
Fix tests
deffrian 2946160
Runner tests
deffrian 6d0ece3
Merge branch 'master' into refactor/chainspec-v2
deffrian ddbcc2d
Fix build
deffrian 15cb899
Ethash & switch to json serialization
deffrian a9dd55e
Fix tests
deffrian c3d296f
Merge branch 'master' into refactor/chainspec-v2
deffrian 67d89e1
Aura
deffrian 7705a5c
Merge branch 'master' into refactor/chainspec-v2
deffrian 0a7f661
Fix build
deffrian dde5690
Merge branch 'master' into refactor/chainspec-v2
deffrian 18ce8a2
Fix tests
deffrian 931b4ac
Fix merge tests
deffrian 8e9ab40
Merge branch 'master' into refactor/chainspec-v2
deffrian 300dd01
AuraParameters
deffrian d488037
Remove comments
deffrian 5c40e24
TODOs
deffrian 24c91c1
Fix spec tests
deffrian afef052
Merge branch 'master' into refactor/chainspec-v2
deffrian 407de4f
Fix Taiko
deffrian e39085b
Formatting & tests
deffrian 728ee3a
EngineName
deffrian 7e3e146
TODO
deffrian 3a004be
Merge branch 'master' into refactor/chainspec-v2
deffrian 5030e93
Fix suggestions
deffrian 92d7253
refactors
LukaszRozmej c7b4d63
more refactors
LukaszRozmej fed3fdd
fix for strings
LukaszRozmej bbff932
Remove TestSealEngineType.cs and JsonConverter
deffrian 27de2f5
Merge branch 'master' into refactor/chainspec-v2
deffrian d0b5b08
Rollback JsonConverter removal
deffrian 9ea7527
Handle null
deffrian c9c38bf
Remove DifficultyBombDelaysConverter
deffrian 69d8c21
Merge branch 'master' into refactor/chainspec-v2
deffrian 98c8178
Make discovery of ChainSpecEngineParameters explicit
LukaszRozmej 18a3619
Merge branch 'master' into refactor/chainspec-v2
deffrian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
94 changes: 94 additions & 0 deletions
94
src/Nethermind/Nethermind.AuRa.Test/ChainSpecLoaderTest.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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using FluentAssertions; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Extensions; | ||
using Nethermind.Serialization.Json; | ||
using Nethermind.Specs; | ||
using Nethermind.Specs.ChainSpecStyle; | ||
using NUnit.Framework; | ||
|
||
namespace Nethermind.AuRa.Test; | ||
|
||
public class ChainSpecLoaderTest | ||
{ | ||
private static ChainSpec LoadChainSpec(string path) | ||
{ | ||
ChainSpecLoader chainSpecLoader = new(new EthereumJsonSerializer()); | ||
ChainSpec chainSpec = chainSpecLoader.LoadFromFile(path); | ||
return chainSpec; | ||
} | ||
|
||
[Test] | ||
public void Can_load_gnosis() | ||
{ | ||
string path = Path.Combine(TestContext.CurrentContext.WorkDirectory, "../../../../", "Chains/gnosis.json"); | ||
ChainSpec chainSpec = LoadChainSpec(path); | ||
|
||
Assert.That(chainSpec.Parameters.Eip1559BaseFeeInitialValue, Is.EqualTo(1.GWei()), $"fork base fee"); | ||
Assert.That(chainSpec.NetworkId, Is.EqualTo(100), $"{nameof(chainSpec.NetworkId)}"); | ||
Assert.That(chainSpec.Name, Is.EqualTo("GnosisChain"), $"{nameof(chainSpec.Name)}"); | ||
Assert.That(chainSpec.SealEngineType, Is.EqualTo(SealEngineType.AuRa), "engine"); | ||
|
||
int berlinGnosisBlockNumber = 16101500; | ||
chainSpec.Parameters.Eip2565Transition.Should().Be(berlinGnosisBlockNumber); | ||
chainSpec.Parameters.Eip2929Transition.Should().Be(berlinGnosisBlockNumber); | ||
chainSpec.Parameters.Eip2930Transition.Should().Be(berlinGnosisBlockNumber); | ||
|
||
chainSpec.Parameters.TerminalTotalDifficulty.ToString() | ||
.Should().Be("8626000000000000000000058750000000000000000000"); | ||
|
||
var auraParams = chainSpec.EngineChainSpecParametersProvider.GetChainSpecParameters<AuRaChainSpecEngineParameters>(); | ||
|
||
auraParams.WithdrawalContractAddress.ToString(true) | ||
.Should().Be("0x0B98057eA310F4d31F2a452B414647007d1645d9"); | ||
} | ||
|
||
[Test] | ||
public void Can_load_chiado() | ||
{ | ||
string path = Path.Combine(TestContext.CurrentContext.WorkDirectory, "../../../../", "Chains/chiado.json"); | ||
ChainSpec chainSpec = LoadChainSpec(path); | ||
|
||
Assert.That(chainSpec.Parameters.Eip1559BaseFeeInitialValue, Is.EqualTo(1.GWei()), $"fork base fee"); | ||
Assert.That(chainSpec.NetworkId, Is.EqualTo(10200), $"{nameof(chainSpec.NetworkId)}"); | ||
Assert.That(chainSpec.Name, Is.EqualTo("chiado"), $"{nameof(chainSpec.Name)}"); | ||
Assert.That(chainSpec.SealEngineType, Is.EqualTo(SealEngineType.AuRa), "engine"); | ||
|
||
chainSpec.Parameters.TerminalTotalDifficulty.ToString() | ||
.Should().Be("231707791542740786049188744689299064356246512"); | ||
|
||
var auraParams = chainSpec.EngineChainSpecParametersProvider.GetChainSpecParameters<AuRaChainSpecEngineParameters>(); | ||
|
||
auraParams.WithdrawalContractAddress.ToString(true) | ||
.Should().Be("0xb97036A26259B7147018913bD58a774cf91acf25"); | ||
|
||
chainSpec.ShanghaiTimestamp.Should().Be(ChiadoSpecProvider.ShanghaiTimestamp); | ||
chainSpec.ShanghaiTimestamp.Should().Be(ChiadoSpecProvider.Instance.TimestampFork); | ||
} | ||
|
||
[Test] | ||
public void Can_load_posdao_with_rewriteBytecode() | ||
{ | ||
// TODO: modexp 2565 | ||
string path = Path.Combine(TestContext.CurrentContext.WorkDirectory, "Specs/posdao.json"); | ||
ChainSpec chainSpec = LoadChainSpec(path); | ||
IDictionary<long, IDictionary<Address, byte[]>> expected = new Dictionary<long, IDictionary<Address, byte[]>> | ||
{ | ||
{ | ||
21300000, new Dictionary<Address, byte[]>() | ||
{ | ||
{new Address("0x1234000000000000000000000000000000000001"), Bytes.FromHexString("0x111")}, | ||
{new Address("0x1234000000000000000000000000000000000002"), Bytes.FromHexString("0x222")}, | ||
} | ||
} | ||
}; | ||
|
||
var auraParams = chainSpec.EngineChainSpecParametersProvider.GetChainSpecParameters<AuRaChainSpecEngineParameters>(); | ||
|
||
auraParams.RewriteBytecode.Should().BeEquivalentTo(expected); | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context on this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know. This is from the original test