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

State/refac release #39

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5ddb742
Bump version to 1.17.0-unstable
kamilchodola Feb 9, 2023
e8155a8
Sepolia Shanghai configs (#5280)
MarekM25 Feb 13, 2023
036bae8
Adjust to prysm batch size (#5286)
MarekM25 Feb 13, 2023
985cbcd
Updating Fast Sync config files (#5273)
github-actions[bot] Feb 13, 2023
43975ca
Updating Fast Sync config files (#5301)
github-actions[bot] Feb 17, 2023
dd2f236
Bump to 1.17.0 version
kamilchodola Feb 17, 2023
a40a551
Mark `engine_getPayloadBodiesBy*` methods as optional capabilities (#…
rubo Feb 27, 2023
db320c5
Revert "Disable eth68 for now because spec is not final (#5140)" (#5356)
marcindsobczak Mar 2, 2023
1a74245
Goerli Shapella Configs (#5366)
MarekM25 Mar 6, 2023
4d0787c
Updating Fast Sync config files (#5340)
github-actions[bot] Feb 27, 2023
039c611
Bump version to 1.17.1
kamilchodola Mar 6, 2023
120f4c8
Updating Fast Sync config files (#5369)
github-actions[bot] Mar 6, 2023
0ac071c
Fix/bad blocks v5 (#5411)
MarekM25 Mar 9, 2023
f3fc20a
Updating Fast Sync config files (#5420)
github-actions[bot] Mar 13, 2023
4faa731
Bump version to 1.17.2
kamilchodola Mar 14, 2023
0255cdd
Updating Fast Sync config files (#5469)
github-actions[bot] Mar 21, 2023
00d6918
Mainnet Shapella Configs (#5455)
MarekM25 Mar 20, 2023
35320a5
Bump version to 1.17.3
kamilchodola Mar 21, 2023
671d60a
Updating Fast Sync config files (#5491)
github-actions[bot] Mar 23, 2023
028e84f
remove codeDb
tanishqjasoria Dec 27, 2022
d9979c6
allow access to state and storage through WorldState
tanishqjasoria Dec 28, 2022
edcb69d
merge the UpdateCode and UpdateCodeHash function into InsertCode
tanishqjasoria Jan 2, 2023
74eb4c3
use a composite state provider
tanishqjasoria Jan 3, 2023
a95c320
define new IWorld interface - combining state and storage provider
tanishqjasoria Jan 6, 2023
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
4 changes: 4 additions & 0 deletions src/Nethermind/Chains/foundation.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@
"eip3198Transition": "0xC5D488",
"eip3529Transition": "0xC5D488",
"eip3541Transition": "0xC5D488",
"eip3651TransitionTimestamp": "0x64373057",
"eip3855TransitionTimestamp": "0x64373057",
"eip3860TransitionTimestamp": "0x64373057",
"eip4895TransitionTimestamp": "0x64373057",
"terminalTotalDifficulty": "C70D808A128D7380000"
},
"genesis": {
Expand Down
22 changes: 13 additions & 9 deletions src/Nethermind/Chains/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@
"eip1884Transition": "0x17D433",
"eip2028Transition": "0x17D433",
"eip2200Transition": "0x17D433",
"eip2565Transition": "0x441064",
"eip2929Transition": "0x441064",
"eip2930Transition": "0x441064",
"eip1559Transition": "0x4D3FCD",
"eip3198Transition": "0x4D3FCD",
"eip3529Transition": "0x4D3FCD",
"eip3541Transition": "0x4D3FCD",
"terminalTotalDifficulty": "A4A470",
"gasLimitBoundDivisor": "0x400",
"eip2565Transition": "0x441064",
"eip2929Transition": "0x441064",
"eip2930Transition": "0x441064",
"eip1559Transition": "0x4D3FCD",
"eip3198Transition": "0x4D3FCD",
"eip3529Transition": "0x4D3FCD",
"eip3541Transition": "0x4D3FCD",
"eip3651TransitionTimestamp": "0x6410F460",
"eip3855TransitionTimestamp": "0x6410F460",
"eip3860TransitionTimestamp": "0x6410F460",
"eip4895TransitionTimestamp": "0x6410F460",
"terminalTotalDifficulty": "A4A470",
"gasLimitBoundDivisor": "0x400",
"maxCodeSize": "0x6000",
"maxCodeSizeTransition": "0x0",
"maximumExtraDataSize": "0xffff",
Expand Down
6 changes: 5 additions & 1 deletion src/Nethermind/Chains/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@
"eip3529Transition": "0x0",
"eip3541Transition": "0x0",
"terminalTotalDifficulty": "3C6568F12E8000",
"mergeForkIdTransition": "0x1A7ACB"
"mergeForkIdTransition": "0x1A7ACB",
"eip4895TransitionTimestamp": "0x63FD7D60",
"eip3855TransitionTimestamp": "0x63FD7D60",
"eip3651TransitionTimestamp": "0x63FD7D60",
"eip3860TransitionTimestamp": "0x63FD7D60"
},
"genesis": {
"seal": {
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Copyright>Demerzel Solutions Limited</Copyright>
<Product>Nethermind</Product>
<SourceRevisionId Condition="'$(Commit)' != ''">$(Commit.Substring(0, 8))</SourceRevisionId>
<VersionPrefix>1.16.1</VersionPrefix>
<VersionPrefix>1.17.3</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

Expand Down
25 changes: 9 additions & 16 deletions src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch?
IEthereumEcdsa ecdsa = new EthereumEcdsa(specProvider.ChainId, _logManager);

TrieStore trieStore = new(stateDb, _logManager);
IStateProvider stateProvider = new StateProvider(trieStore, codeDb, _logManager);
IWorldState stateProvider = new WorldState(trieStore, codeDb, _logManager);
MemDb blockInfoDb = new MemDb();
IBlockTree blockTree = new BlockTree(new MemDb(), new MemDb(), blockInfoDb, new ChainLevelInfoRepository(blockInfoDb), specProvider, NullBloomStorage.Instance, _logManager);
ITransactionComparerProvider transactionComparerProvider = new TransactionComparerProvider(specProvider, blockTree);
Expand All @@ -127,7 +127,6 @@ protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch?
IHeaderValidator headerValidator = new HeaderValidator(blockTree, Sealer, specProvider, _logManager);
IUnclesValidator unclesValidator = new UnclesValidator(blockTree, headerValidator, _logManager);
IBlockValidator blockValidator = new BlockValidator(txValidator, headerValidator, unclesValidator, specProvider, _logManager);
IStorageProvider storageProvider = new StorageProvider(trieStore, stateProvider, _logManager);
IVirtualMachine virtualMachine = new VirtualMachine(
blockhashProvider,
specProvider,
Expand All @@ -141,12 +140,10 @@ protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch?
new TransactionProcessor(
specProvider,
stateProvider,
storageProvider,
virtualMachine,
_logManager),
stateProvider),
stateProvider,
storageProvider,
receiptStorage,
NullWitnessCollector.Instance,
_logManager);
Expand All @@ -159,7 +156,7 @@ protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch?
_logManager,
BlockchainProcessor.Options.NoReceipts);

InitializeTestState(test, stateProvider, storageProvider, specProvider);
InitializeTestState(test, stateProvider, specProvider);

List<(Block Block, string ExpectedException)> correctRlp = new();
for (int i = 0; i < test.Blocks.Length; i++)
Expand Down Expand Up @@ -264,7 +261,7 @@ protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch?
await blockchainProcessor.StopAsync(true);
stopwatch?.Stop();

List<string> differences = RunAssertions(test, blockTree.RetrieveHeadBlock(), storageProvider, stateProvider);
List<string> differences = RunAssertions(test, blockTree.RetrieveHeadBlock(), stateProvider);
// if (differences.Any())
// {
// BlockTrace blockTrace = blockchainProcessor.TraceBlock(blockTree.BestSuggested.Hash);
Expand All @@ -281,36 +278,32 @@ protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch?
);
}

private void InitializeTestState(BlockchainTest test, IStateProvider stateProvider, IStorageProvider storageProvider, ISpecProvider specProvider)
private void InitializeTestState(BlockchainTest test, IWorldState stateProvider, ISpecProvider specProvider)
{
foreach (KeyValuePair<Address, AccountState> accountState in
((IEnumerable<KeyValuePair<Address, AccountState>>)test.Pre ?? Array.Empty<KeyValuePair<Address, AccountState>>()))
{
foreach (KeyValuePair<UInt256, byte[]> storageItem in accountState.Value.Storage)
{
storageProvider.Set(new StorageCell(accountState.Key, storageItem.Key), storageItem.Value);
stateProvider.Set(new StorageCell(accountState.Key, storageItem.Key), storageItem.Value);
}

stateProvider.CreateAccount(accountState.Key, accountState.Value.Balance);
Keccak codeHash = stateProvider.UpdateCode(accountState.Value.Code);
stateProvider.UpdateCodeHash(accountState.Key, codeHash, specProvider.GenesisSpec);
stateProvider.InsertCode(accountState.Key, accountState.Value.Code, specProvider.GenesisSpec);
for (int i = 0; i < accountState.Value.Nonce; i++)
{
stateProvider.IncrementNonce(accountState.Key);
}
}

storageProvider.Commit();
stateProvider.Commit(specProvider.GenesisSpec);

storageProvider.CommitTrees(0);
stateProvider.CommitTree(0);

storageProvider.Reset();
stateProvider.Reset();
}

private List<string> RunAssertions(BlockchainTest test, Block headBlock, IStorageProvider storageProvider, IStateProvider stateProvider)
private List<string> RunAssertions(BlockchainTest test, Block headBlock, IWorldState stateProvider)
{
if (test.PostStateRoot != null)
{
Expand Down Expand Up @@ -379,7 +372,7 @@ private List<string> RunAssertions(BlockchainTest test, Block headBlock, IStorag

foreach (KeyValuePair<UInt256, byte[]> clearedStorage in clearedStorages)
{
byte[] value = !stateProvider.AccountExists(acountAddress) ? Bytes.Empty : storageProvider.Get(new StorageCell(acountAddress, clearedStorage.Key));
byte[] value = !stateProvider.AccountExists(acountAddress) ? Bytes.Empty : stateProvider.Get(new StorageCell(acountAddress, clearedStorage.Key));
if (!value.IsZero())
{
differences.Add($"{acountAddress} storage[{clearedStorage.Key}] exp: 0x00, actual: {value.ToHexString(true)}");
Expand All @@ -388,7 +381,7 @@ private List<string> RunAssertions(BlockchainTest test, Block headBlock, IStorag

foreach (KeyValuePair<UInt256, byte[]> storageItem in accountState.Storage)
{
byte[] value = !stateProvider.AccountExists(acountAddress) ? Bytes.Empty : storageProvider.Get(new StorageCell(acountAddress, storageItem.Key)) ?? new byte[0];
byte[] value = !stateProvider.AccountExists(acountAddress) ? Bytes.Empty : stateProvider.Get(new StorageCell(acountAddress, storageItem.Key)) ?? new byte[0];
if (!Bytes.AreEqual(storageItem.Value, value))
{
differences.Add($"{acountAddress} storage[{storageItem.Key}] exp: {storageItem.Value.ToHexString(true)}, actual: {value.ToHexString(true)}");
Expand Down
19 changes: 6 additions & 13 deletions src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
}

TrieStore trieStore = new(stateDb, _logManager);
StateProvider stateProvider = new(trieStore, codeDb, _logManager);
IWorldState stateProvider = new WorldState(trieStore, codeDb, _logManager);
IBlockhashProvider blockhashProvider = new TestBlockhashProvider();
IStorageProvider storageProvider = new StorageProvider(trieStore, stateProvider, _logManager);
IVirtualMachine virtualMachine = new VirtualMachine(
blockhashProvider,
specProvider,
Expand All @@ -76,11 +75,10 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
TransactionProcessor transactionProcessor = new(
specProvider,
stateProvider,
storageProvider,
virtualMachine,
_logManager);

InitializeTestState(test, stateProvider, storageProvider, specProvider);
InitializeTestState(test, stateProvider, specProvider);

BlockHeader header = new(test.PreviousHash, Keccak.OfAnEmptySequenceRlp, test.CurrentCoinbase,
test.CurrentDifficulty, test.CurrentNumber, test.CurrentGasLimit, test.CurrentTimestamp, Array.Empty<byte>());
Expand Down Expand Up @@ -121,34 +119,29 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
return testResult;
}

private static void InitializeTestState(GeneralStateTest test, StateProvider stateProvider,
IStorageProvider storageProvider, ISpecProvider specProvider)
private static void InitializeTestState(GeneralStateTest test, IWorldState stateProvider, ISpecProvider specProvider)
{
foreach (KeyValuePair<Address, AccountState> accountState in test.Pre)
{
foreach (KeyValuePair<UInt256, byte[]> storageItem in accountState.Value.Storage)
{
storageProvider.Set(new StorageCell(accountState.Key, storageItem.Key),
stateProvider.Set(new StorageCell(accountState.Key, storageItem.Key),
storageItem.Value.WithoutLeadingZeros().ToArray());
}

stateProvider.CreateAccount(accountState.Key, accountState.Value.Balance);
Keccak codeHash = stateProvider.UpdateCode(accountState.Value.Code);
stateProvider.UpdateCodeHash(accountState.Key, codeHash, specProvider.GenesisSpec);
stateProvider.InsertCode(accountState.Key, accountState.Value.Code, specProvider.GenesisSpec);
stateProvider.SetNonce(accountState.Key, accountState.Value.Nonce);
}

storageProvider.Commit();
stateProvider.Commit(specProvider.GenesisSpec);

storageProvider.CommitTrees(0);
stateProvider.CommitTree(0);

storageProvider.Reset();
stateProvider.Reset();
}

private List<string> RunAssertions(GeneralStateTest test, IStateProvider stateProvider)
private List<string> RunAssertions(GeneralStateTest test, IWorldState stateProvider)
{
List<string> differences = new();
if (test.PostHash != stateProvider.StateRoot)
Expand Down
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.Abi.Contracts/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace Nethermind.Consensus.AuRa.Contracts
/// Base class for contracts that will be interacted by the node engine.
/// </summary>
/// <remarks>
/// This class is intended to be inherited and concrete contract class should provide contract specific methods to be able for the node to use the contract.
///
/// This class is intended to be inherited and concrete contract class should provide contract specific methods to be able for the node to use the contract.
///
/// There are 3 main ways a node can interact with contract:
/// 1. It can <see cref="GenerateTransaction{T}(Nethermind.Abi.AbiFunctionDescription,Nethermind.Core.Address,object[])"/> that will be added to a block.
/// 2. It can <see cref="Call(Nethermind.Core.BlockHeader,Nethermind.Abi.AbiFunctionDescription,Nethermind.Core.Address,object[])"/> contract and modify current state of execution.
Expand All @@ -27,7 +27,7 @@ namespace Nethermind.Consensus.AuRa.Contracts
public abstract partial class Contract
{
/// <summary>
/// Default gas limit of transactions generated from contract.
/// Default gas limit of transactions generated from contract.
/// </summary>
public const long DefaultContractGasLimit = 1_600_000L;

Expand Down Expand Up @@ -182,7 +182,7 @@ protected bool TryCall(BlockHeader header, AbiFunctionDescription function, Addr
/// Creates <see cref="Address.SystemUser"/> account if its not in current state.
/// </summary>
/// <param name="stateProvider">State provider.</param>
protected void EnsureSystemAccount(IStateProvider stateProvider)
protected void EnsureSystemAccount(IWorldState stateProvider)
{
if (!stateProvider.AccountExists(Address.SystemUser))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AccountAbstractionPeerManagerTests
private IBlockTree _blockTree = Substitute.For<IBlockTree>();
private ILogger _logger = Substitute.For<ILogger>();
private ILogFinder _logFinder = Substitute.For<ILogFinder>();
private IStateProvider _stateProvider = Substitute.For<IStateProvider>();
private IWorldState _stateProvider = Substitute.For<IWorldState>();
private ISpecProvider _specProvider = Substitute.For<ISpecProvider>();
private readonly ISigner _signer = Substitute.For<ISigner>();
private readonly string[] _entryPointContractAddress = { "0x8595dd9e0438640b5e1254f9df579ac12a86865f", "0x96cc609c8f5458fb8a7da4d94b678e38ebf3d04e" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ protected override BlockProcessor CreateBlockProcessor()
NoBlockRewards.Instance,
new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State),
State,
Storage,
ReceiptStorage,
NullWitnessCollector.Instance,
LogManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ public async Task Should_execute_well_formed_op_successfully_if_codehash_not_cha
chain.SendUserOperation(entryPointAddress[0], op);
if (changeCodeHash)
{
Keccak codeHash = chain.State.UpdateCode(Bytes.Concat(chain.State.GetCode(walletAddress[0]!), 0x00));
chain.State.UpdateCodeHash(walletAddress[0]!, codeHash, chain.SpecProvider.GenesisSpec);
chain.State.InsertCode(walletAddress[0]!, Bytes.Concat(chain.State.GetCode(walletAddress[0]!), 0x00), chain.SpecProvider.GenesisSpec);
chain.State.Commit(chain.SpecProvider.GenesisSpec);
chain.State.RecalculateStateRoot();
chain.State.CommitTree(chain.BlockTree.Head!.Number);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class UserOperationPoolTests
private IBlockTree _blockTree = Substitute.For<IBlockTree>();
private IReceiptFinder _receiptFinder = Substitute.For<IReceiptFinder>();
private ILogFinder _logFinder = Substitute.For<ILogFinder>();
private IStateProvider _stateProvider = Substitute.For<IStateProvider>();
private IWorldState _stateProvider = Substitute.For<IWorldState>();
private ISpecProvider _specProvider = Substitute.For<ISpecProvider>();
private readonly ISigner _signer = Substitute.For<ISigner>();
private readonly Keccak _userOperationEventTopic = new("0x33fd4d1f25a5461bea901784a6571de6debc16cd0831932c22c6969cd73ba994");
Expand Down
Loading