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

Verkle/tree #24

Open
wants to merge 4 commits into
base: verkle/refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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 @@ -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
2 changes: 0 additions & 2 deletions src/Nethermind/Nethermind.Api/IApiWithBlockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ public interface IApiWithBlockchain : IApiWithStores, IBlockchainBridgeFactory
/// <remarks>
/// DO NOT USE OUTSIDE OF PROCESSING BLOCK CONTEXT!
/// </remarks>
IStateProvider? StateProvider { get; set; }
IKeyValueStoreWithBatching? MainStateDbWithCache { get; set; }
IReadOnlyStateProvider? ChainHeadStateProvider { get; set; }
IStateReader? StateReader { get; set; }
IStorageProvider? StorageProvider { get; set; }
IWorldState? WorldState { get; set; }
ITransactionProcessor? TransactionProcessor { get; set; }
ITrieStore? TrieStore { get; set; }
Expand Down
2 changes: 0 additions & 2 deletions src/Nethermind/Nethermind.Api/NethermindApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,9 @@ public ISealEngine SealEngine
public IPeerDifficultyRefreshPool? PeerDifficultyRefreshPool { get; set; }
public ISynchronizer? Synchronizer { get; set; }
public ISyncServer? SyncServer { get; set; }
public IStateProvider? StateProvider { get; set; }
public IWorldState? WorldState { get; set; }
public IReadOnlyStateProvider? ChainHeadStateProvider { get; set; }
public IStateReader? StateReader { get; set; }
public IStorageProvider? StorageProvider { get; set; }
public IStaticNodesManager? StaticNodesManager { get; set; }
public ITimestamper Timestamper { get; } = Core.Timestamper.Default;
public ITimerFactory TimerFactory { get; } = Core.Timers.TimerFactory.Default;
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.AuRa.Test/AuRaBlockProducerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private class Context
public ISealer Sealer { get; }
public IBlockTree BlockTree { get; }
public IBlockProcessingQueue BlockProcessingQueue { get; }
public IStateProvider StateProvider { get; }
public IWorldState StateProvider { get; }
public ITimestamper Timestamper { get; }
public IAuRaStepCalculator AuRaStepCalculator { get; }
public Address NodeAddress { get; }
Expand All @@ -58,7 +58,7 @@ public Context()
Sealer = Substitute.For<ISealer>();
BlockTree = Substitute.For<IBlockTree>();
BlockProcessingQueue = Substitute.For<IBlockProcessingQueue>();
StateProvider = Substitute.For<IStateProvider>();
StateProvider = Substitute.For<IWorldState>();
Timestamper = Substitute.For<ITimestamper>();
AuRaStepCalculator = Substitute.For<IAuRaStepCalculator>();
NodeAddress = TestItem.AddressA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ValidatorContractTests
private readonly Address _contractAddress = Address.FromNumber(long.MaxValue);
private IReadOnlyTransactionProcessor _transactionProcessor;
private IReadOnlyTxProcessorSource _readOnlyTxProcessorSource;
private IStateProvider _stateProvider;
private IWorldState _stateProvider;

[SetUp]
public void SetUp()
Expand All @@ -36,7 +36,7 @@ public void SetUp()
_transactionProcessor = Substitute.For<IReadOnlyTransactionProcessor>();
_readOnlyTxProcessorSource = Substitute.For<IReadOnlyTxProcessorSource>();
_readOnlyTxProcessorSource.Build(TestItem.KeccakA).Returns(_transactionProcessor);
_stateProvider = Substitute.For<IStateProvider>();
_stateProvider = Substitute.For<IWorldState>();
_stateProvider.StateRoot.Returns(TestItem.KeccakA);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Nethermind.AuRa.Test.Validators
{
public class ContractBasedValidatorTests
{
private IStateProvider _stateProvider;
private IWorldState _stateProvider;
private IAbiEncoder _abiEncoder;
private ILogManager _logManager;
private AuRaParameters.Validator _validator;
Expand All @@ -60,7 +60,7 @@ public void SetUp()
{
_validatorStore = new ValidatorStore(new MemDb());
_validSealerStrategy = new ValidSealerStrategy();
_stateProvider = Substitute.For<IStateProvider>();
_stateProvider = Substitute.For<IWorldState>();
_abiEncoder = Substitute.For<IAbiEncoder>();
_logManager = LimboLogs.Instance;
_blockTree = Substitute.For<IBlockTree>();
Expand Down Expand Up @@ -333,7 +333,7 @@ public static IEnumerable<TestCaseData> ConsecutiveInitiateChangeData
InitializeBlock = 3,
FinalizeBlock = 3
},
new()
new()
// this will not get finalized because of reorganisation
{
Addresses = GenerateValidators(2),
Expand All @@ -346,7 +346,7 @@ public static IEnumerable<TestCaseData> ConsecutiveInitiateChangeData
{
7, new ConsecutiveInitiateChangeTestParameters.ChainInfo()
{
BlockNumber = 5, //reorganisation to block 5 in order to invalidate last initiate change
BlockNumber = 5, //reorganisation to block 5 in order to invalidate last initiate change
ExpectedFinalizationCount = 0,
NumberOfSteps = 10,
}
Expand Down Expand Up @@ -447,7 +447,7 @@ public static IEnumerable<TestCaseData> ConsecutiveInitiateChangeData
{
7, new ConsecutiveInitiateChangeTestParameters.ChainInfo()
{
BlockNumber = 6, //reorganisation to block 6 in order to keep last initiate change
BlockNumber = 6, //reorganisation to block 6 in order to keep last initiate change
ExpectedFinalizationCount = 2,
NumberOfSteps = 10,
Validators = new List<ConsecutiveInitiateChangeTestParameters.ValidatorsInfo>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void Report_ignores_duplicates_in_same_block()
context.Validator.ReportMalicious(MaliciousMinerAddress, 100, Bytes.Empty, IReportingValidator.MaliciousCause.DuplicateStep); // ignored
context.Validator.ReportMalicious(MaliciousMinerAddress, 100, Bytes.Empty, IReportingValidator.MaliciousCause.SiblingBlocksInSameStep); // ignored
context.Validator.ReportMalicious(MaliciousMinerAddress, 100, Bytes.Empty, IReportingValidator.MaliciousCause.SiblingBlocksInSameStep); // ignored
context.Validator.ReportBenign(TestItem.AddressC, 100, IReportingValidator.BenignCause.FutureBlock); // sent
context.Validator.ReportBenign(TestItem.AddressC, 100, IReportingValidator.BenignCause.FutureBlock); // sent
context.Validator.ReportBenign(TestItem.AddressC, 100, IReportingValidator.BenignCause.FutureBlock); // ignored
context.Validator.ReportBenign(MaliciousMinerAddress, 101, IReportingValidator.BenignCause.FutureBlock); //sent
context.Validator.ReportBenign(MaliciousMinerAddress, 101, IReportingValidator.BenignCause.IncorrectProposer); //ignored
Expand Down Expand Up @@ -204,7 +204,7 @@ public TestContext(bool forSealing, ReportingContractBasedValidator.Cache cache

TxSender = Substitute.For<ITxSender>();
ITxPool txPool = Substitute.For<ITxPool>();
IStateProvider stateProvider = Substitute.For<IStateProvider>();
IWorldState stateProvider = Substitute.For<IWorldState>();
ISpecProvider specProvider = Substitute.For<ISpecProvider>();
stateProvider.GetNonce(ReportingValidatorContract.NodeAddress).Returns(UInt256.One);

Expand Down
10 changes: 3 additions & 7 deletions src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ public void Prepared_block_contains_author_field()
IDb stateDb = new MemDb();
IDb codeDb = new MemDb();
TrieStore trieStore = new(stateDb, LimboLogs.Instance);
IStateProvider stateProvider = new StateProvider(trieStore, codeDb, LimboLogs.Instance);
IStorageProvider storageProvider = new StorageProvider(trieStore, stateProvider, LimboLogs.Instance);
IWorldState worldState = new WorldState(trieStore, codeDb, LimboLogs.Instance);
IWorldState stateProvider = new WorldState(trieStore, codeDb, LimboLogs.Instance);
ITransactionProcessor transactionProcessor = Substitute.For<ITransactionProcessor>();
BlockProcessor processor = new(
RinkebySpecProvider.Instance,
TestBlockValidator.AlwaysValid,
NoBlockRewards.Instance,
new BlockProcessor.BlockValidationTransactionsExecutor(transactionProcessor, new WorldState(trieStore, codeDb, LimboLogs.Instance)),
worldState,
stateProvider,
NullReceiptStorage.Instance,
NullWitnessCollector.Instance,
LimboLogs.Instance);
Expand All @@ -72,7 +70,7 @@ public void Can_store_a_witness()
IDb codeDb = new MemDb();
var trieStore = new TrieStore(stateDb, LimboLogs.Instance);

IStateProvider stateProvider = new StateProvider(trieStore, codeDb, LimboLogs.Instance);
IWorldState stateProvider = new WorldState(trieStore, codeDb, LimboLogs.Instance);
IStorageProvider storageProvider = new StorageProvider(trieStore, stateProvider, LimboLogs.Instance);
ITransactionProcessor transactionProcessor = Substitute.For<ITransactionProcessor>();
IWitnessCollector witnessCollector = Substitute.For<IWitnessCollector>();
Expand Down Expand Up @@ -103,8 +101,6 @@ public void Recovers_state_on_cancel()
IDb stateDb = new MemDb();
IDb codeDb = new MemDb();
TrieStore trieStore = new(stateDb, LimboLogs.Instance);
IStateProvider stateProvider = new StateProvider(trieStore, codeDb, LimboLogs.Instance);
IStorageProvider storageProvider = new StorageProvider(trieStore, stateProvider, LimboLogs.Instance);
IWorldState worldState = new WorldState(trieStore, codeDb, LimboLogs.Instance);
ITransactionProcessor transactionProcessor = Substitute.For<ITransactionProcessor>();
BlockProcessor processor = new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task AuraTestBlockProducer_IsProducingBlocks_returns_expected_resul
Substitute.For<ITxSource>(),
Substitute.For<IBlockchainProcessor>(),
Substitute.For<IBlockProductionTrigger>(),
Substitute.For<IStateProvider>(),
Substitute.For<IWorldState>(),
Substitute.For<ISealer>(),
Substitute.For<IBlockTree>(),
Substitute.For<ITimestamper>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ProducerUnderTest(
ISealer sealer,
IBlockTree blockTree,
IBlockProductionTrigger blockProductionTrigger,
IStateProvider stateProvider,
IWorldState stateProvider,
IGasLimitCalculator gasLimitCalculator,
ITimestamper timestamper,
ILogManager logManager,
Expand Down Expand Up @@ -80,7 +80,7 @@ public void Time_passing_does_not_break_the_block()
NullSealEngine.Instance,
Build.A.BlockTree().TestObject,
Substitute.For<IBlockProductionTrigger>(),
Substitute.For<IStateProvider>(),
Substitute.For<IWorldState>(),
Substitute.For<IGasLimitCalculator>(),
timestamper,
LimboLogs.Instance,
Expand All @@ -103,7 +103,7 @@ public void Parent_timestamp_is_used_consistently()
NullSealEngine.Instance,
Build.A.BlockTree().TestObject,
Substitute.For<IBlockProductionTrigger>(),
Substitute.For<IStateProvider>(),
Substitute.For<IWorldState>(),
Substitute.For<IGasLimitCalculator>(),
timestamper,
LimboLogs.Instance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ public void Test()
NoPruning.Instance,
Archive.Instance,
LimboLogs.Instance);
StateProvider stateProvider = new(
trieStore,
dbProvider.RegisteredDbs[DbNames.Code],
LimboLogs.Instance);
StateReader stateReader = new(trieStore, dbProvider.GetDb<IDb>(DbNames.State), LimboLogs.Instance);
StorageProvider storageProvider = new(trieStore, stateProvider, LimboLogs.Instance);
WorldState worldState = new WorldState(trieStore, dbProvider.RegisteredDbs[DbNames.Code], LimboLogs.Instance);
BlockhashProvider blockhashProvider = new(blockTree, LimboLogs.Instance);
VirtualMachine virtualMachine = new(
Expand Down Expand Up @@ -90,7 +85,7 @@ public void Test()
DevBlockProducer devBlockProducer = new(
EmptyTxSource.Instance,
blockchainProcessor,
stateProvider,
worldState,
blockTree,
trigger,
timestamper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected bool TryCall(BlockHeader header, string functionName, Address sender,
/// 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 @@ -139,9 +139,6 @@ public On CreateNode(PrivateKey privateKey, bool withGenesisAlreadyProcessed = f
processor.Start();

IReadOnlyTrieStore minerTrieStore = trieStore.AsReadOnly();

StateProvider minerStateProvider = new(minerTrieStore, codeDb, nodeLogManager);
StorageProvider minerStorageProvider = new(minerTrieStore, minerStateProvider, nodeLogManager);
WorldState minerWorldState = new WorldState(minerTrieStore, codeDb, nodeLogManager);
VirtualMachine minerVirtualMachine = new(blockhashProvider, specProvider, nodeLogManager);
TransactionProcessor minerTransactionProcessor = new TransactionProcessor(goerliSpecProvider, minerWorldState, minerVirtualMachine, nodeLogManager);
Expand Down Expand Up @@ -171,7 +168,7 @@ public On CreateNode(PrivateKey privateKey, bool withGenesisAlreadyProcessed = f
CliqueBlockProducer blockProducer = new(
txPoolTxSource,
minerProcessor,
minerStateProvider,
minerWorldState,
blockTree,
_timestamper,
new CryptoRandom(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Sets_clique_block_producer_properly()
CliqueBlockProducer producer = new(
Substitute.For<ITxSource>(),
Substitute.For<IBlockchainProcessor>(),
Substitute.For<IStateProvider>(),
Substitute.For<IWorldState>(),
blockTree,
Substitute.For<ITimestamper>(),
Substitute.For<ICryptoRandom>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AuRaBlockProducer : BlockProducerBase
public AuRaBlockProducer(ITxSource txSource,
IBlockchainProcessor processor,
IBlockProductionTrigger blockProductionTrigger,
IStateProvider stateProvider,
IWorldState stateProvider,
ISealer sealer,
IBlockTree blockTree,
ITimestamper timestamper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public partial interface IValidatorContract

public sealed partial class ValidatorContract : CallableContract, IValidatorContract
{
private readonly IStateProvider _stateProvider;
private readonly IWorldState _stateProvider;
private readonly ISigner _signer;

private IConstantContract Constant { get; }
Expand All @@ -63,7 +63,7 @@ public ValidatorContract(
ITransactionProcessor transactionProcessor,
IAbiEncoder abiEncoder,
Address contractAddress,
IStateProvider stateProvider,
IWorldState stateProvider,
IReadOnlyTxProcessorSource readOnlyTxProcessorSource,
ISigner signer)
: base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)))
Expand Down
Loading