Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit 206b256

Browse files
authored
Add estimate revert reason and txn hash to searcher mode logs (#353)
1 parent 06dc515 commit 206b256

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pkg/modules/builder/client.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func (b *BuilderClient) SetWaitTimeout(timeout time.Duration) {
6161
// that supports eth_sendBundle.
6262
func (b *BuilderClient) SendUserOperation() modules.BatchHandlerFunc {
6363
return func(ctx *modules.BatchHandlerCtx) error {
64-
// Estimate gas for handleOps() and drop all userOps that cause unexpected reverts.
6564
opts := transaction.Opts{
6665
EOA: b.eoa,
6766
Eth: b.eth,
@@ -76,18 +75,27 @@ func (b *BuilderClient) SendUserOperation() modules.BatchHandlerFunc {
7675
NoSend: true,
7776
WaitTimeout: b.waitTimeout,
7877
}
78+
// Estimate gas for handleOps() and drop all userOps that cause unexpected reverts.
79+
estRev := []string{}
7980
for len(ctx.Batch) > 0 {
8081
est, revert, err := transaction.EstimateHandleOpsGas(&opts)
8182

8283
if err != nil {
8384
return err
8485
} else if revert != nil {
8586
ctx.MarkOpIndexForRemoval(revert.OpIndex)
87+
estRev = append(estRev, revert.Reason)
8688
} else {
8789
opts.GasLimit = est
8890
break
8991
}
9092
}
93+
ctx.Data["estimate_revert_reasons"] = estRev
94+
95+
// No need to continue if the batch size is 0. Otherwise we would just be sending empty batches.
96+
if len(ctx.Batch) == 0 {
97+
return nil
98+
}
9199

92100
// Calculate the max base fee up to a future block number.
93101
bn, err := b.eth.BlockNumber(context.Background())
@@ -135,7 +143,11 @@ func (b *BuilderClient) SendUserOperation() modules.BatchHandlerFunc {
135143
}
136144

137145
// Wait for transaction to be included on-chain.
138-
_, err = transaction.Wait(txn, opts.Eth, opts.WaitTimeout)
139-
return err
146+
if _, err := transaction.Wait(txn, opts.Eth, opts.WaitTimeout); err != nil {
147+
return err
148+
}
149+
ctx.Data["txn_hash"] = txn.Hash().String()
150+
151+
return nil
140152
}
141153
}

pkg/modules/relay/relayer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *Relayer) SendUserOperation() modules.BatchHandlerFunc {
9191
break
9292
}
9393
}
94-
ctx.Data["relayer_est_revert_reasons"] = estRev
94+
ctx.Data["estimate_revert_reasons"] = estRev
9595

9696
// Call handleOps() with gas estimate. Any userOps that cause a revert at this stage will be
9797
// caught and dropped in the next iteration.

0 commit comments

Comments
 (0)