Skip to content

Commit

Permalink
Add option to not recover sender
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap committed Oct 29, 2024
1 parent 65e0158 commit 31b469f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public FullInfoReceiptFinder(IReceiptStorage receiptStorage, IReceiptsRecovery r

public Hash256 FindBlockHash(Hash256 txHash) => _receiptStorage.FindBlockHash(txHash);

public TxReceipt[] Get(Block block, bool recover = true)
public TxReceipt[] Get(Block block, bool recover = true, bool recoverSender = true)
{
var receipts = _receiptStorage.Get(block);
if (recover && _receiptsRecovery.TryRecover(block, receipts) == ReceiptsRecoveryResult.NeedReinsert)
if (recover && _receiptsRecovery.TryRecover(block, receipts, recoverSender) == ReceiptsRecoveryResult.NeedReinsert)
{
_receiptStorage.Insert(block, receipts);
}
Expand All @@ -41,7 +41,7 @@ public TxReceipt[] Get(Hash256 blockHash, bool recover = true)
if (recover && _receiptsRecovery.NeedRecover(receipts))
{
var block = _blockFinder.FindBlock(blockHash, BlockTreeLookupOptions.TotalDifficultyNotNeeded);
if (_receiptsRecovery.TryRecover(block, receipts) == ReceiptsRecoveryResult.NeedReinsert)
if (_receiptsRecovery.TryRecover(block, receipts, forceRecoverSender: false) == ReceiptsRecoveryResult.NeedReinsert)
{
_receiptStorage.Insert(block, receipts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Nethermind.Blockchain.Receipts
public interface IReceiptFinder
{
Hash256? FindBlockHash(Hash256 txHash);
TxReceipt[] Get(Block block, bool recover = true);
TxReceipt[] Get(Block block, bool recover = true, bool recoverSender = true);
TxReceipt[] Get(Hash256 blockHash, bool recover = true);
bool CanGetReceiptsByHash(long blockNumber);
bool TryGetReceiptsIterator(long blockNumber, Hash256 blockHash, out ReceiptsIterator iterator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Hash256 FindBlockHash(Hash256 txHash)
return receipt?.BlockHash;
}

public TxReceipt[] Get(Block block, bool recover = true) => Get(block.Hash);
public TxReceipt[] Get(Block block, bool recover = true, bool recoverSender = true) => Get(block.Hash);

public TxReceipt[] Get(Hash256 blockHash, bool recover = true) =>
_receipts.TryGetValue(blockHash, out TxReceipt[] receipts) ? receipts : Array.Empty<TxReceipt>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private NullReceiptStorage()

public void Insert(Block block, TxReceipt[] txReceipts, bool ensureCanonical) { }

public TxReceipt[] Get(Block block, bool recover = true) => Array.Empty<TxReceipt>();
public TxReceipt[] Get(Block block, bool recover = true, bool recoverSender = false) => Array.Empty<TxReceipt>();
public TxReceipt[] Get(Hash256 blockHash, bool recover = true) => Array.Empty<TxReceipt>();
public bool CanGetReceiptsByHash(long blockNumber) => true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private TxReceipt DeserializeReceiptObsolete(Hash256 hash, Span<byte> receiptDat
return null;
}

public TxReceipt[] Get(Block block, bool recover = true)
public TxReceipt[] Get(Block block, bool recover = true, bool recoverSender = true)
{
if (block.ReceiptsRoot == Keccak.EmptyTreeHash)
{
Expand All @@ -164,7 +164,7 @@ public TxReceipt[] Get(Block block, bool recover = true)

if (recover)
{
_receiptsRecovery.TryRecover(block, receipts);
_receiptsRecovery.TryRecover(block, receipts, forceRecoverSender: recoverSender);
_receiptsCache.Set(blockHash, receipts);
}

Expand Down Expand Up @@ -223,7 +223,7 @@ public TxReceipt[] Get(Hash256 blockHash, bool recover = true)
{
Block? block = _blockTree.FindBlock(blockHash);
if (block is null) return Array.Empty<TxReceipt>();
return Get(block, recover);
return Get(block, recover, false);
}

public bool CanGetReceiptsByHash(long blockNumber) => blockNumber >= MigratedBlockNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public TestReceiptStorage(IReceiptStorage inStorage, IReceiptStorage outStorage)

public Hash256 FindBlockHash(Hash256 txHash) => _inStorage.FindBlockHash(txHash);

public TxReceipt[] Get(Block block, bool recover = true) => _inStorage.Get(block, recover);
public TxReceipt[] Get(Block block, bool recover = true, bool recoverSender = true) => _inStorage.Get(block, recover, recoverSender);

public TxReceipt[] Get(Hash256 blockHash, bool recover = true) => _inStorage.Get(blockHash, recover);

Expand Down

0 comments on commit 31b469f

Please sign in to comment.