-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into test/missingnodetest
- Loading branch information
Showing
83 changed files
with
1,576 additions
and
528 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Dependency review | ||
|
||
on: [pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
dependency-review: | ||
name: Dependency review | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
- name: Dependency review | ||
uses: actions/dependency-review-action@v4 | ||
with: | ||
fail-on-severity: high |
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
64 changes: 64 additions & 0 deletions
64
src/Nethermind/Nethermind.Consensus/Processing/OverridableTxProcessingEnv.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,64 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Nethermind.Blockchain; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Crypto; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Evm; | ||
using Nethermind.Evm.TransactionProcessing; | ||
using Nethermind.Logging; | ||
using Nethermind.State; | ||
|
||
namespace Nethermind.Consensus.Processing; | ||
|
||
public class OverridableTxProcessingEnv : ReadOnlyTxProcessingEnvBase, IOverridableTxProcessorSource | ||
{ | ||
private readonly Lazy<ITransactionProcessor> _transactionProcessorLazy; | ||
|
||
protected new OverridableWorldState StateProvider { get; } | ||
protected OverridableWorldStateManager WorldStateManager { get; } | ||
protected OverridableCodeInfoRepository CodeInfoRepository { get; } | ||
protected IVirtualMachine Machine { get; } | ||
protected ITransactionProcessor TransactionProcessor => _transactionProcessorLazy.Value; | ||
|
||
public OverridableTxProcessingEnv( | ||
OverridableWorldStateManager worldStateManager, | ||
IReadOnlyBlockTree readOnlyBlockTree, | ||
ISpecProvider specProvider, | ||
ILogManager? logManager, | ||
IWorldState? worldStateToWarmUp = null | ||
) : base(worldStateManager, readOnlyBlockTree, specProvider, logManager, worldStateToWarmUp) | ||
{ | ||
WorldStateManager = worldStateManager; | ||
StateProvider = (OverridableWorldState)base.StateProvider; | ||
CodeInfoRepository = new(new CodeInfoRepository((worldStateToWarmUp as IPreBlockCaches)?.Caches.PrecompileCache)); | ||
Machine = new VirtualMachine(BlockhashProvider, specProvider, CodeInfoRepository, logManager); | ||
_transactionProcessorLazy = new(CreateTransactionProcessor); | ||
} | ||
|
||
protected virtual ITransactionProcessor CreateTransactionProcessor() => | ||
new TransactionProcessor(SpecProvider, StateProvider, Machine, CodeInfoRepository, LogManager); | ||
|
||
IOverridableTxProcessingScope IOverridableTxProcessorSource.Build(Hash256 stateRoot) => Build(stateRoot); | ||
|
||
public OverridableTxProcessingScope Build(Hash256 stateRoot) | ||
{ | ||
Hash256 originalStateRoot = StateProvider.StateRoot; | ||
StateProvider.StateRoot = stateRoot; | ||
return new(CodeInfoRepository, TransactionProcessor, StateProvider, originalStateRoot); | ||
} | ||
|
||
IOverridableTxProcessingScope IOverridableTxProcessorSource.BuildAndOverride(BlockHeader header, Dictionary<Address, AccountOverride>? stateOverride) | ||
{ | ||
OverridableTxProcessingScope scope = Build(header.StateRoot ?? throw new ArgumentException($"Block {header.Hash} state root is null", nameof(header))); | ||
if (stateOverride != null) | ||
{ | ||
scope.WorldState.ApplyStateOverrides(scope.CodeInfoRepository, stateOverride, SpecProvider.GetSpec(header), header.Number); | ||
header.StateRoot = scope.WorldState.StateRoot; | ||
} | ||
return scope; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Nethermind/Nethermind.Consensus/Processing/OverridableTxProcessingScope.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,29 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Nethermind.Core.Crypto; | ||
using Nethermind.Evm; | ||
using Nethermind.Evm.TransactionProcessing; | ||
using Nethermind.State; | ||
|
||
namespace Nethermind.Consensus.Processing; | ||
|
||
public class OverridableTxProcessingScope( | ||
IOverridableCodeInfoRepository codeInfoRepository, | ||
ITransactionProcessor transactionProcessor, | ||
OverridableWorldState worldState, | ||
Hash256 originalStateRoot | ||
) : IOverridableTxProcessingScope | ||
{ | ||
public IOverridableCodeInfoRepository CodeInfoRepository => codeInfoRepository; | ||
public ITransactionProcessor TransactionProcessor => transactionProcessor; | ||
public IWorldState WorldState => worldState; | ||
|
||
public void Dispose() | ||
{ | ||
worldState.StateRoot = originalStateRoot; | ||
worldState.Reset(); | ||
worldState.ResetOverrides(); | ||
codeInfoRepository.ResetOverrides(); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/Nethermind/Nethermind.Evm/IOverridableCodeInfoRepository.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,15 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Evm.CodeAnalysis; | ||
using Nethermind.State; | ||
|
||
namespace Nethermind.Evm; | ||
|
||
public interface IOverridableCodeInfoRepository : ICodeInfoRepository | ||
{ | ||
void SetCodeOverwrite(IWorldState worldState, IReleaseSpec vmSpec, Address key, CodeInfo value, Address? redirectAddress = null); | ||
public void ResetOverrides(); | ||
} |
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.