chore(verifytx): Updating VerifyTx to Cache between Transactions (#137)
* updating mev lane with cleaner impl * nit * lint * updating anteverifytx to verify tx * nit * ignoring first height * tidy
This commit is contained in:
+16
-4
@@ -51,6 +51,8 @@ func (l *BaseLane) PrepareLane(
|
||||
"err", err,
|
||||
"num_txs_to_add", len(txsToInclude),
|
||||
"num_txs_to_remove", len(txsToRemove),
|
||||
"lane_max_block_size", limit.MaxTxBytes,
|
||||
"lane_max_gas_limit", limit.MaxGasLimit,
|
||||
)
|
||||
|
||||
return proposal, err
|
||||
@@ -61,6 +63,8 @@ func (l *BaseLane) PrepareLane(
|
||||
"lane", l.Name(),
|
||||
"num_txs_added", len(txsToInclude),
|
||||
"num_txs_removed", len(txsToRemove),
|
||||
"lane_max_block_size", limit.MaxTxBytes,
|
||||
"lane_max_gas_limit", limit.MaxGasLimit,
|
||||
)
|
||||
|
||||
return next(ctx, proposal)
|
||||
@@ -122,12 +126,20 @@ func (l *BaseLane) ProcessLane(
|
||||
return next(ctx, proposal)
|
||||
}
|
||||
|
||||
// AnteVerifyTx verifies that the transaction is valid respecting the ante verification logic of
|
||||
// VerifyTx verifies that the transaction is valid respecting the ante verification logic of
|
||||
// of the antehandler chain.
|
||||
func (l *BaseLane) AnteVerifyTx(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
|
||||
func (l *BaseLane) VerifyTx(ctx sdk.Context, tx sdk.Tx, simulate bool) error {
|
||||
if l.cfg.AnteHandler != nil {
|
||||
return l.cfg.AnteHandler(ctx, tx, simulate)
|
||||
// Only write to the context if the tx does not fail.
|
||||
catchCtx, write := ctx.CacheContext()
|
||||
if _, err := l.cfg.AnteHandler(catchCtx, tx, simulate); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
write()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return ctx, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
}
|
||||
|
||||
// Verify the transaction.
|
||||
if ctx, err = l.AnteVerifyTx(ctx, tx, false); err != nil {
|
||||
if err = l.VerifyTx(ctx, tx, false); err != nil {
|
||||
l.Logger().Info(
|
||||
"failed to verify tx",
|
||||
"tx_hash", txInfo.Hash,
|
||||
@@ -128,7 +128,7 @@ func (l *BaseLane) DefaultProcessLaneHandler() ProcessLaneHandler {
|
||||
return fmt.Errorf("transaction at index %d has a higher priority than %d", index, index-1)
|
||||
}
|
||||
|
||||
if _, err := l.AnteVerifyTx(ctx, tx, false); err != nil {
|
||||
if err := l.VerifyTx(ctx, tx, false); err != nil {
|
||||
return fmt.Errorf("failed to verify tx: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user