Skip to content

Commit

Permalink
Update env changes to reduce redundancy and make control flow easier …
Browse files Browse the repository at this point in the history
…to follow
  • Loading branch information
Wazzymandias committed Aug 23, 2023
1 parent ca7e7a7 commit 811b294
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions miner/env_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,30 +142,23 @@ func (c *envChanges) commitBundle(bundle *types.SimulatedBundle, chData chainDat
}
receipt, _, err := c.commitTx(tx, chData)

if err != nil {
switch {
case err != nil:
isRevertibleTx := bundle.OriginalBundle.RevertingHash(txHash)
// if drop enabled, and revertible tx has error on commit, we skip the transaction and continue with next one
if algoConf.DropRevertibleTxOnErr && isRevertibleTx {
log.Trace("Found error on commit for revertible tx, but discard on err is enabled so skipping.",
"tx", txHash, "err", err)
continue
} else {
bundleErr = err
}
log.Trace("Bundle tx error", "bundle", bundle.OriginalBundle.Hash, "tx", txHash, "err", err)
bundleErr = err
break
}

if bundleErr != nil {
break
}

if receipt != nil {
case receipt != nil:
if receipt.Status == types.ReceiptStatusFailed && !bundle.OriginalBundle.RevertingHash(txHash) {
// if transaction reverted and isn't specified as reverting hash, return error
log.Trace("Bundle tx failed", "bundle", bundle.OriginalBundle.Hash, "tx", txHash, "err", err)
bundleErr = errors.New("bundle tx revert")
}
} else {
case receipt == nil && err == nil:
// NOTE: The expectation is that a receipt is only nil if an error occurred.
// If there is no error but receipt is nil, there is likely a programming error.
bundleErr = errors.New("invalid receipt when no error occurred")
Expand Down

0 comments on commit 811b294

Please sign in to comment.