diff --git a/src/Nethermind/Nethermind.Blockchain.Test/IntegrationTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/IntegrationTests.cs index 3e57a62042d..6847196b918 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/IntegrationTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/IntegrationTests.cs @@ -66,7 +66,7 @@ public async Task Can_process_mined_blocks() MemDb receiptsDb = new MemDb(); MemDb traceDb = new MemDb(); TxPool txPool = new TxPool(NullTxStorage.Instance, Timestamp.Default, ecdsa, specProvider, new TxPoolConfig(), logManager); - IReceiptStorage receiptStorage = new PersistentReceiptStorage(receiptsDb, specProvider, logManager); + IReceiptStorage receiptStorage = new PersistentReceiptStorage(receiptsDb, NullDb.Instance, specProvider, logManager); BlockTree blockTree = new BlockTree(new MemDb(), new MemDb(), new MemDb(), specProvider, txPool, logManager); Timestamp timestamp = new Timestamp(); DifficultyCalculator difficultyCalculator = new DifficultyCalculator(specProvider); diff --git a/src/Nethermind/Nethermind.Blockchain.Test/ReceiptStorageTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/ReceiptStorageTests.cs index 3397a3ee051..f5c6fb77e8f 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/ReceiptStorageTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/ReceiptStorageTests.cs @@ -47,7 +47,7 @@ public void should_add_and_fetch_receipt_from_in_memory_storage() [Test] public void should_add_and_fetch_receipt_from_persistent_storage() - => TestAddAndGetReceipt(new PersistentReceiptStorage(new MemDb(), _specProvider, LimboLogs.Instance)); + => TestAddAndGetReceipt(new PersistentReceiptStorage(new MemDb(), NullDb.Instance, _specProvider, LimboLogs.Instance)); private void TestAddAndGetReceipt(IReceiptStorage storage) { diff --git a/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs b/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs index caabbbcf29c..d5640d2ca15 100644 --- a/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs +++ b/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs @@ -29,13 +29,15 @@ namespace Nethermind.Blockchain.Receipts public class PersistentReceiptStorage : IReceiptStorage { private readonly IDb _database; + private readonly IDb _headersFixDb; private readonly ISpecProvider _specProvider; private readonly ILogger _logger; - public PersistentReceiptStorage(IDb database, ISpecProvider specProvider, ILogManager logManager) + public PersistentReceiptStorage(IDb receiptsDb, IDb headersFixDb, ISpecProvider specProvider, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); - _database = database ?? throw new ArgumentNullException(nameof(database)); + _database = receiptsDb ?? throw new ArgumentNullException(nameof(receiptsDb)); + _headersFixDb = headersFixDb ?? throw new ArgumentNullException(nameof(headersFixDb)); _specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); byte[] lowestBytes = _database.Get(Keccak.Zero); @@ -45,6 +47,10 @@ public PersistentReceiptStorage(IDb database, ISpecProvider specProvider, ILogMa public TxReceipt Find(Keccak hash) { var receiptData = _database.Get(hash); + if (receiptData == null) + { + receiptData = _headersFixDb.Get(hash); + } return receiptData == null ? null diff --git a/src/Nethermind/Nethermind.Runner/Config/IInitConfig.cs b/src/Nethermind/Nethermind.Runner/Config/IInitConfig.cs index 5a1d76cca0e..771164a3ad2 100644 --- a/src/Nethermind/Nethermind.Runner/Config/IInitConfig.cs +++ b/src/Nethermind/Nethermind.Runner/Config/IInitConfig.cs @@ -93,5 +93,7 @@ public interface IInitConfig : IConfig [ConfigItem(Description = "If set to 'false' then transaction receipts will not be stored in the database.", DefaultValue = "true")] bool StoreReceipts { get; set; } + + bool EnableRc7Fix { get; set; } } } \ No newline at end of file diff --git a/src/Nethermind/Nethermind.Runner/Config/InitConfig.cs b/src/Nethermind/Nethermind.Runner/Config/InitConfig.cs index 39510b624fe..1f82e677dcb 100644 --- a/src/Nethermind/Nethermind.Runner/Config/InitConfig.cs +++ b/src/Nethermind/Nethermind.Runner/Config/InitConfig.cs @@ -45,5 +45,6 @@ public class InitConfig : IInitConfig public bool StoreTraces { get; set; } = false; public bool StoreReceipts { get; set; } = false; + public bool EnableRc7Fix { get; set; } = false; } } \ No newline at end of file diff --git a/src/Nethermind/Nethermind.Runner/Runners/EthereumRunner.cs b/src/Nethermind/Nethermind.Runner/Runners/EthereumRunner.cs index d4d68c5f384..25f068d6cb8 100644 --- a/src/Nethermind/Nethermind.Runner/Runners/EthereumRunner.cs +++ b/src/Nethermind/Nethermind.Runner/Runners/EthereumRunner.cs @@ -422,7 +422,8 @@ private async Task InitBlockchain() _ethereumEcdsa, _specProvider, _txPoolConfig, _logManager); - _receiptStorage = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _specProvider, _logManager); + var _rc7FixDb = _initConfig.EnableRc7Fix ? _dbProvider.HeadersDb : NullDb.Instance; + _receiptStorage = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _rc7FixDb, _specProvider, _logManager); // IDbProvider debugRecorder = new RocksDbProvider(Path.Combine(_dbBasePath, "debug"), dbConfig); // _dbProvider = new RpcDbProvider(_jsonSerializer, new BasicJsonRpcClient(KnownRpcUris.NethVm1, _jsonSerializer, _logManager), _logManager, debugRecorder);