Skip to content

Commit

Permalink
fix(op-geth): add new field in SimulateGaslessBundleResp (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
redhdx authored Oct 28, 2024
1 parent 5a039c4 commit e13806f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions core/types/bundle_gasless.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type GaslessTxSimResult struct {
}

type SimulateGaslessBundleResp struct {
ValidResults []GaslessTxSimResult
BasedBlockNumber int64
ValidResults []GaslessTxSimResult
GasReachedResults []GaslessTxSimResult
BasedBlockNumber int64
}
15 changes: 10 additions & 5 deletions miner/worker_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ func (w *worker) simulateBundle(
}

func (w *worker) simulateGaslessBundle(env *environment, bundle *types.Bundle) (*types.SimulateGaslessBundleResp, error) {
result := make([]types.GaslessTxSimResult, 0)
validResults := make([]types.GaslessTxSimResult, 0)
gasReachedResults := make([]types.GaslessTxSimResult, 0)

txIdx := 0
for _, tx := range bundle.Txs {
Expand All @@ -455,19 +456,23 @@ func (w *worker) simulateGaslessBundle(env *environment, bundle *types.Bundle) (
if err != nil {
env.state.RevertToSnapshot(snap)
env.gasPool.SetGas(gp)
log.Info("fail to simulate gasless bundle, skipped", "txHash", tx.Hash(), "err", err)
log.Error("fail to simulate gasless bundle, skipped", "txHash", tx.Hash(), "err", err)
if err == core.ErrGasLimitReached {
gasReachedResults = append(gasReachedResults, types.GaslessTxSimResult{Hash: tx.Hash()})
}
} else {
txIdx++
result = append(result, types.GaslessTxSimResult{
validResults = append(validResults, types.GaslessTxSimResult{
Hash: tx.Hash(),
GasUsed: receipt.GasUsed,
})
}
}

return &types.SimulateGaslessBundleResp{
ValidResults: result,
BasedBlockNumber: env.header.Number.Int64(),
ValidResults: validResults,
GasReachedResults: gasReachedResults,
BasedBlockNumber: env.header.Number.Int64(),
}, nil
}

Expand Down

0 comments on commit e13806f

Please sign in to comment.