diff --git a/core/rawdb/accessors_skipped_txs.go b/core/rawdb/accessors_skipped_txs.go index 3481a955c8b3..528088bae272 100644 --- a/core/rawdb/accessors_skipped_txs.go +++ b/core/rawdb/accessors_skipped_txs.go @@ -199,6 +199,16 @@ func WriteSkippedTransaction(db ethdb.Database, tx *types.Transaction, traces *t } } +// ResetSkippedTransactionTracesByHash resets the traces stored in local db, by reading the tx and its associated fields, +// and overwritting it with empty trace +func ResetSkippedTransactionTracesByHash(db ethdb.Database, txHash common.Hash) { + stx := ReadSkippedTransaction(db, txHash) + if stx == nil { + return + } + writeSkippedTransaction(db, stx.Tx, nil, stx.Reason, stx.BlockNumber, stx.BlockHash) +} + // SkippedTransactionIterator is a wrapper around ethdb.Iterator that // allows us to iterate over skipped transaction hashes in the database. // It implements an interface similar to ethdb.Iterator. diff --git a/eth/api.go b/eth/api.go index da85be18481e..dd523a09ed48 100644 --- a/eth/api.go +++ b/eth/api.go @@ -817,3 +817,26 @@ func (api *ScrollAPI) GetSkippedTransactionHashes(ctx context.Context, from uint return hashes, nil } + +// ResetSkippedTransactionsTraces resets the traces for skipped txs stored in db, and returns the list of reset transaction hashes. +// The skipped txs to reset are specified by the two indices provided (inclusive). +func (api *ScrollAPI) ResetSkippedTransactionsTraces(ctx context.Context, from uint64, to uint64) ([]common.Hash, error) { + hashes, err := api.GetSkippedTransactionHashes(ctx, from, to) + if err != nil { + return nil, err + } + + for _, hash := range hashes { + log.Info("resetting skipped tx's traces", "txHash", hash) + api.ResetSkippedTransactionTracesByHash(ctx, hash) + log.Info("reset skipped tx's traces done", "txHash", hash) + } + + return hashes, nil +} + +// ResetSkippedTransactionTracesByHash resets a specified skipped tx's traces stored in db. +func (api *ScrollAPI) ResetSkippedTransactionTracesByHash(ctx context.Context, hash common.Hash) error { + rawdb.ResetSkippedTransactionTracesByHash(api.eth.ChainDb(), hash) + return nil +} diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 04fc46cb421d..49301320f680 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -903,6 +903,16 @@ web3._extend({ call: 'scroll_getSkippedTransactionHashes', params: 2 }), + new web3._extend.Method({ + name: 'resetSkippedTransactionsTraces', + call: 'scroll_resetSkippedTransactionsTraces', + params: 2 + }), + new web3._extend.Method({ + name: 'resetSkippedTransactionTracesByHash', + call: 'scroll_resetSkippedTransactionTracesByHash', + params: 1 + }), new web3._extend.Method({ name: 'estimateL1DataFee', call: 'scroll_estimateL1DataFee',