Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrency access on the mempool from txquery and recheckTxs #1377

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node/block_processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (bp *BlockProcessor) CheckTx(ctx context.Context, tx *ktypes.Transaction, h
Authenticator: tx.Signature.Type,
}, readTx, tx)
if err != nil {
bp.log.Info("Transaction rejected", "tx", txHash, "err", err)
bp.log.Info("Transaction rejected", "tx", txHash, "err", err, "recheck", recheck)
return err
}

Expand Down
6 changes: 1 addition & 5 deletions node/consensus/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ func (ce *ConsensusEngine) recheckTx(ctx context.Context, tx *ktypes.Transaction
}
ce.stateInfo.mtx.RUnlock()

err := ce.blockProcessor.CheckTx(ctx, tx, height, timestamp, true)
if err != nil {
ce.log.Infof("recheckTx failed for tx %s, err: %s", tx, err)
}
return err
return ce.blockProcessor.CheckTx(ctx, tx, height, timestamp, true)
}

// BroadcastTx checks the Tx with the mempool and if the verification is successful, broadcasts the Tx to the network.
Expand Down
4 changes: 2 additions & 2 deletions node/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ type CheckFn func(ctx context.Context, tx *ktypes.Transaction) error
// RecheckTxs validates all transactions in the mempool using the provided check function,
// removing any that fail validation.
func (mp *Mempool) RecheckTxs(ctx context.Context, fn CheckFn) {
mp.mtx.RLock()
defer mp.mtx.RUnlock()
mp.mtx.Lock()
defer mp.mtx.Unlock()

for hash, tx := range mp.txns {
if err := fn(ctx, tx.Transaction); err != nil {
Expand Down