diff --git a/core/sbundle_sim.go b/core/sbundle_sim.go index 17ce6959a..a90fddc8b 100644 --- a/core/sbundle_sim.go +++ b/core/sbundle_sim.go @@ -28,6 +28,8 @@ type SimBundleResult struct { GasUsed uint64 MevGasPrice *uint256.Int BodyLogs []SimBundleBodyLogs + Revert []byte + ExecError string } type SimBundleBodyLogs struct { @@ -80,10 +82,12 @@ func SimBundle(config *params.ChainConfig, bc *BlockChain, author *common.Addres if el.Tx != nil { statedb.SetTxContext(el.Tx.Hash(), txIdx) txIdx++ - receipt, err := ApplyTransaction(config, bc, author, gp, statedb, header, el.Tx, usedGas, cfg, nil) + receipt, result, err := ApplyTransactionWithResult(config, bc, author, gp, statedb, header, el.Tx, usedGas, cfg) if err != nil { return res, err } + res.Revert = result.Revert() + res.ExecError = result.Err.Error() if receipt.Status != types.ReceiptStatusSuccessful && !el.CanRevert { return res, ErrTxFailed } @@ -96,6 +100,13 @@ func SimBundle(config *params.ChainConfig, bc *BlockChain, author *common.Addres if err != nil { return res, err } + // basically return first exec error if exists, helpful for single-tx sbundles + if len(res.Revert) == 0 { + res.Revert = innerRes.Revert + } + if len(res.ExecError) == 0 { + res.ExecError = innerRes.ExecError + } res.GasUsed += innerRes.GasUsed if logs { res.BodyLogs = append(res.BodyLogs, SimBundleBodyLogs{BundleLogs: innerRes.BodyLogs}) diff --git a/internal/ethapi/sbundle_api.go b/internal/ethapi/sbundle_api.go index a7dab3c34..446db5484 100644 --- a/internal/ethapi/sbundle_api.go +++ b/internal/ethapi/sbundle_api.go @@ -187,6 +187,8 @@ type SimMevBundleResponse struct { RefundableValue hexutil.U256 `json:"refundableValue"` GasUsed hexutil.Uint64 `json:"gasUsed"` BodyLogs []core.SimBundleBodyLogs `json:"logs,omitempty"` + ExecError string `json:"execError,omitempty"` + Revert hexutil.Bytes `json:"revert,omitempty"` } type SimMevBundleAuxArgs struct { @@ -276,6 +278,8 @@ func (api *MevAPI) SimBundle(ctx context.Context, args SendMevBundleArgs, aux Si result.Success = true result.BodyLogs = bundleRes.BodyLogs } + result.ExecError = bundleRes.ExecError + result.Revert = bundleRes.Revert result.StateBlock = hexutil.Uint64(parentHeader.Number.Uint64()) result.MevGasPrice = hexutil.U256(*bundleRes.MevGasPrice) result.Profit = hexutil.U256(*bundleRes.TotalProfit)