Skip to content

Commit

Permalink
build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ak88 committed Aug 28, 2024
1 parent 0da8f10 commit e043ac7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Mev/MevPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public BundlePool BundlePool
getFromApi.TxValidator!,
getFromApi.SpecProvider!,
_mevConfig,
getFromApi.ChainHeadStateProvider!,
getFromApi.WorldState!,
getFromApi.LogManager,
getFromApi.EthereumEcdsa!);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Nethermind/Nethermind.Mev/Source/BundlePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Nethermind.Logging;
using Nethermind.Mev.Data;
using Nethermind.Mev.Execution;
using Nethermind.State;
using Nethermind.TxPool;
using Nethermind.TxPool.Collections;

Expand All @@ -28,7 +29,7 @@ public class BundlePool : IBundlePool, ISimulatedBundleSource, IDisposable
private readonly ITimestamper _timestamper;
private readonly ITxValidator _txValidator;
private readonly IMevConfig _mevConfig;
private readonly IAccountStateProvider _stateProvider;
private readonly IReadOnlyStateProvider _stateProvider;
private readonly ISpecProvider _specProvider;
private readonly IBlockTree _blockTree;
private readonly IBundleSimulator _simulator;
Expand All @@ -51,7 +52,7 @@ public BundlePool(
ITxValidator txValidator,
ISpecProvider specProvider,
IMevConfig mevConfig,
IAccountStateProvider stateProvider,
IReadOnlyStateProvider stateProvider,
ILogManager logManager,
IEthereumEcdsa ecdsa)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Core.Specs;
using System;

namespace Nethermind.State
{
public static class IReadOnlyStateProviderExtensions
{
public static byte[] GetCode(this IReadOnlyStateProvider stateProvider, Address address)
{
stateProvider.TryGetAccount(address, out AccountStruct account);
return !account.HasCode ? Array.Empty<byte>() : stateProvider.GetCode(account.CodeHash) ?? Array.Empty<byte>();
}

public static bool IsInvalidContractSender(this IReadOnlyStateProvider stateProvider, IReleaseSpec spec, Address address) =>
spec.IsEip3607Enabled && stateProvider.HasCode(address) && !Eip7702Constants.IsDelegatedCode(GetCode(stateProvider, address));

}
}
11 changes: 1 addition & 10 deletions src/Nethermind/Nethermind.State/IWorldStateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@ namespace Nethermind.State
{
public static class WorldStateExtensions
{
public static byte[] GetCode(this IWorldState stateProvider, Address address)
{
stateProvider.TryGetAccount(address, out AccountStruct account);
return !account.HasCode ? Array.Empty<byte>() : stateProvider.GetCode(account.CodeHash) ?? Array.Empty<byte>();
}

public static void InsertCode(this IWorldState worldState, Address address, ReadOnlyMemory<byte> code, IReleaseSpec spec, bool isGenesis = false)
{
Hash256 codeHash = code.Length == 0 ? Keccak.OfAnEmptyString : Keccak.Compute(code.Span);
worldState.InsertCode(address, codeHash, code, spec, isGenesis);
}

public static bool IsInvalidContractSender(this IWorldState stateProvider, IReleaseSpec spec, Address address) =>
spec.IsEip3607Enabled && stateProvider.HasCode(address) && !Eip7702Constants.IsDelegatedCode(GetCode(stateProvider, address));


public static string DumpState(this IWorldState stateProvider)
{
TreeDumper dumper = new();
Expand Down

0 comments on commit e043ac7

Please sign in to comment.