diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs
index 17f9f6ceb83..9269f06e27c 100644
--- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs
+++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs
@@ -29,6 +29,22 @@ namespace Nethermind.Consensus.AuRa.InitializationSteps
{
public static class TxAuRaFilterBuilders
{
+ ///
+ /// Filter decorator.
+ ///
+ /// Allow to create new filter based on original filter and a potential fallbackFilter if original filter was not used.
+ ///
+ ///
+ public delegate ITxFilter FilterDecorator(ITxFilter originalFilter, ITxFilter? fallbackFilter = null);
+
+ ///
+ /// Delegate factory method to create final filter for AuRa.
+ ///
+ ///
+ /// This is used to decorate original filter with in order to disable it post-merge.
+ ///
+ public static FilterDecorator CreateFilter { get; set; } = (x, _) => x;
+
private static ITxFilter CreateBaseAuRaTxFilter(
IMiningConfig miningConfig,
AuRaNethermindApi api,
@@ -40,7 +56,7 @@ private static ITxFilter CreateBaseAuRaTxFilter(
ITxFilter gasPriceTxFilter = minGasPriceTxFilter;
if (minGasPricesContractDataStore != null)
{
- gasPriceTxFilter = new MinGasPriceContractTxFilter(minGasPriceTxFilter, minGasPricesContractDataStore);
+ gasPriceTxFilter = CreateFilter(new MinGasPriceContractTxFilter(minGasPriceTxFilter, minGasPricesContractDataStore), minGasPriceTxFilter);
}
Address? registrar = api.ChainSpec?.Parameters.Registrar;
@@ -48,7 +64,7 @@ private static ITxFilter CreateBaseAuRaTxFilter(
{
RegisterContract registerContract = new(api.AbiEncoder, registrar, readOnlyTxProcessorSource);
CertifierContract certifierContract = new(api.AbiEncoder, registerContract, readOnlyTxProcessorSource);
- return new TxCertifierFilter(certifierContract, gasPriceTxFilter, specProvider, api.LogManager);
+ return CreateFilter(new TxCertifierFilter(certifierContract, gasPriceTxFilter, specProvider, api.LogManager));
}
return gasPriceTxFilter;
@@ -65,7 +81,7 @@ private static ITxFilter CreateBaseAuRaTxFilter(
{
RegisterContract registerContract = new(api.AbiEncoder, registrar, readOnlyTxProcessorSource);
CertifierContract certifierContract = new(api.AbiEncoder, registerContract, readOnlyTxProcessorSource);
- return new TxCertifierFilter(certifierContract, baseTxFilter, specProvider, api.LogManager);
+ return CreateFilter(new TxCertifierFilter(certifierContract, baseTxFilter, specProvider, api.LogManager));
}
return baseTxFilter;
@@ -81,7 +97,7 @@ private static ITxFilter CreateBaseAuRaTxFilter(
{
api.TxFilterCache ??= new PermissionBasedTxFilter.Cache();
- var txPermissionFilter = new PermissionBasedTxFilter(
+ var txPermissionFilter = CreateFilter(new PermissionBasedTxFilter(
new VersionedTransactionPermissionContract(api.AbiEncoder,
api.ChainSpec.Parameters.TransactionPermissionContract,
api.ChainSpec.Parameters.TransactionPermissionContractTransition ?? 0,
@@ -90,7 +106,7 @@ private static ITxFilter CreateBaseAuRaTxFilter(
api.LogManager,
api.SpecProvider),
api.TxFilterCache,
- api.LogManager);
+ api.LogManager));
return txPermissionFilter;
}
diff --git a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergePlugin.cs b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergePlugin.cs
index 874369a1007..3281446b56e 100644
--- a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergePlugin.cs
+++ b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergePlugin.cs
@@ -1,22 +1,10 @@
using Nethermind.Merge.Plugin;
using Nethermind.Consensus.Transactions;
-using Nethermind.Consensus.AuRa.Transactions;
-using Nethermind.Consensus.Producers;
using Nethermind.Consensus.Processing;
-using Nethermind.Evm.TransactionProcessing;
-using Nethermind.Consensus.AuRa.Contracts;
using Nethermind.Consensus.AuRa.InitializationSteps;
-using Nethermind.Consensus.AuRa.Contracts.DataStore;
-using Nethermind.Core;
using Nethermind.Db;
using Nethermind.Blockchain;
-using Nethermind.Blockchain.Data;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
-using Nethermind.Consensus;
-using Nethermind.Consensus.AuRa.Config;
using Nethermind.State;
-using Nethermind.Specs.ChainSpecStyle;
using System.Threading.Tasks;
using Nethermind.Api;
using Nethermind.Api.Extensions;
@@ -43,6 +31,10 @@ public override async Task Init(INethermindApi nethermindApi)
_auraApi = (AuRaNethermindApi)nethermindApi;
_auraApi.PoSSwitcher = _poSSwitcher;
_mergeConfig.Enabled = false; // set MergePlugin as disabled
+
+ // this runs before all init steps that use tx filters
+ TxAuRaFilterBuilders.CreateFilter = (originalFilter, fallbackFilter) =>
+ new AuRaMergeTxFilter(_poSSwitcher, originalFilter, fallbackFilter);
}
}
diff --git a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeTxFilter.cs b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeTxFilter.cs
new file mode 100644
index 00000000000..43565788657
--- /dev/null
+++ b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeTxFilter.cs
@@ -0,0 +1,26 @@
+using Nethermind.Core;
+using Nethermind.TxPool;
+using Nethermind.Consensus.Transactions;
+using Nethermind.Consensus;
+
+namespace Nethermind.Merge.AuRa
+{
+ public class AuRaMergeTxFilter : ITxFilter
+ {
+ private readonly IPoSSwitcher _poSSwitcher;
+ private readonly ITxFilter _preMergeTxFilter;
+ private readonly ITxFilter _postMergeTxFilter;
+
+ public AuRaMergeTxFilter(IPoSSwitcher poSSwitcher, ITxFilter preMergeTxFilter, ITxFilter? postMergeTxFilter = null)
+ {
+ _poSSwitcher = poSSwitcher;
+ _preMergeTxFilter = preMergeTxFilter;
+ _postMergeTxFilter = postMergeTxFilter ?? NullTxFilter.Instance;
+ }
+
+ public AcceptTxResult IsAllowed(Transaction tx, BlockHeader parentHeader) =>
+ _poSSwitcher.IsPostMerge(parentHeader)
+ ? _postMergeTxFilter.IsAllowed(tx, parentHeader)
+ : _preMergeTxFilter.IsAllowed(tx, parentHeader);
+ }
+}
diff --git a/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs b/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs
index 544ce3c02e2..5360257d8bd 100644
--- a/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs
+++ b/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs
@@ -58,9 +58,9 @@ public partial class MergePlugin : IConsensusWrapperPlugin, ISynchronizationPlug
protected IPoSSwitcher _poSSwitcher = NoPoS.Instance;
private IBeaconPivot? _beaconPivot;
private BeaconSync? _beaconSync;
- private IBlockCacheService _blockCacheService;
+ private IBlockCacheService _blockCacheService = null!;
private InvalidChainTracker.InvalidChainTracker? _invalidChainTracker;
- private IPeerRefresher _peerRefresher;
+ private IPeerRefresher _peerRefresher = null!;
private ManualBlockFinalizationManager _blockFinalizationManager = null!;
private IMergeBlockProductionPolicy? _mergeBlockProductionPolicy;
@@ -246,11 +246,11 @@ public Task InitRpcModules()
}
PayloadPreparationService payloadPreparationService = new(
- _postMergeBlockProducer,
- improvementContextFactory,
- _api.Sealer,
+ _postMergeBlockProducer,
+ improvementContextFactory,
+ _api.Sealer,
_api.TimerFactory,
- _api.LogManager,
+ _api.LogManager,
TimeSpan.FromSeconds(_mergeConfig.SecondsPerSlot));
IEngineRpcModule engineRpcModule = new EngineRpcModule(