Skip to content

Commit

Permalink
Add debug logs when discarding atomic txs (#335)
Browse files Browse the repository at this point in the history
* add logs

* fix tests

* fix typo

* clean up logs

* remove from atomic backends

* cleanup

* final cleanup

* switch

* error -> err
  • Loading branch information
anusha-ctrl authored Sep 13, 2023
1 parent 5034cf3 commit 4b1944b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ func (vm *VM) preBatchOnFinalizeAndAssemble(header *types.Header, state *state.S
rules := vm.chainConfig.AvalancheRules(header.Number, header.Time)
if err := vm.verifyTx(tx, header.ParentHash, header.BaseFee, state, rules); err != nil {
// Discard the transaction from the mempool on failed verification.
log.Debug("discarding tx from mempool on failed verification", "txID", tx.ID(), "err", err)
vm.mempool.DiscardCurrentTx(tx.ID())
state.RevertToSnapshot(snapshot)
continue
Expand All @@ -783,6 +784,7 @@ func (vm *VM) preBatchOnFinalizeAndAssemble(header *types.Header, state *state.S
if err != nil {
// Discard the transaction from the mempool and error if the transaction
// cannot be marshalled. This should never happen.
log.Debug("discarding tx due to unmarshal err", "txID", tx.ID(), "err", err)
vm.mempool.DiscardCurrentTx(tx.ID())
return nil, nil, nil, fmt.Errorf("failed to marshal atomic transaction %s due to %w", tx.ID(), err)
}
Expand Down Expand Up @@ -854,6 +856,7 @@ func (vm *VM) postBatchOnFinalizeAndAssemble(header *types.Header, state *state.
// valid, but we discard it early here based on the assumption that the proposed
// block will most likely be accepted.
// Discard the transaction from the mempool on failed verification.
log.Debug("discarding tx due to overlapping input utxos", "txID", tx.ID())
vm.mempool.DiscardCurrentTx(tx.ID())
continue
}
Expand All @@ -864,6 +867,7 @@ func (vm *VM) postBatchOnFinalizeAndAssemble(header *types.Header, state *state.
// if it fails verification here.
// Note: prior to this point, we have not modified [state] so there is no need to
// revert to a snapshot if we discard the transaction prior to this point.
log.Debug("discarding tx from mempool due to failed verification", "txID", tx.ID(), "err", err)
vm.mempool.DiscardCurrentTx(tx.ID())
state.RevertToSnapshot(snapshot)
continue
Expand All @@ -884,6 +888,7 @@ func (vm *VM) postBatchOnFinalizeAndAssemble(header *types.Header, state *state.
if err != nil {
// If we fail to marshal the batch of atomic transactions for any reason,
// discard the entire set of current transactions.
log.Debug("discarding txs due to error marshaling atomic transactions", "err", err)
vm.mempool.DiscardCurrentTxs()
return nil, nil, nil, fmt.Errorf("failed to marshal batch of atomic transactions due to %w", err)
}
Expand Down Expand Up @@ -1166,6 +1171,7 @@ func (vm *VM) buildBlock(_ context.Context) (snowman.Block, error) {
// Note: the status of block is set by ChainState
blk, err := vm.newBlock(block)
if err != nil {
log.Debug("discarding txs due to error making new block", "err", err)
vm.mempool.DiscardCurrentTxs()
return nil, err
}
Expand Down

0 comments on commit 4b1944b

Please sign in to comment.