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

Commit b6ed720

Browse files
authored
Allow nil state override set in gas.EstimateInput (#349)
1 parent 68c0c1b commit b6ed720

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

pkg/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (i *Client) EstimateUserOperationGas(
177177
}
178178

179179
// Estimate gas limits
180-
vg, cg, err := i.getGasEstimate(epAddr, userOp, state.WithZeroAddressOverride(sos))
180+
vg, cg, err := i.getGasEstimate(epAddr, userOp, sos)
181181
if err != nil {
182182
l.Error(err, "eth_estimateUserOperationGas error")
183183
return nil, err

pkg/entrypoint/execution/trace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TraceSimulateHandleOp(in *TraceInput) (*TraceOutput, error) {
100100
}
101101
opts := utils.TraceCallOpts{
102102
Tracer: tracer.Loaded.BundlerExecutionTracer,
103-
StateOverrides: in.Sos,
103+
StateOverrides: state.WithZeroAddressOverride(in.Sos),
104104
}
105105
if err := in.Rpc.CallContext(context.Background(), &res, "debug_traceCall", &req, "latest", &opts); err != nil {
106106
return nil, err

pkg/entrypoint/simulation/tracevalidation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TraceSimulateValidation(in *TraceInput) (*TraceOutput, error) {
6363
}
6464
opts := utils.TraceCallOpts{
6565
Tracer: tracer.Loaded.BundlerCollectorTracer,
66-
StateOverrides: state.WithZeroAddressOverride(state.OverrideSet{}),
66+
StateOverrides: state.WithZeroAddressOverride(nil),
6767
}
6868
if err := in.Rpc.CallContext(context.Background(), &res, "debug_traceCall", &req, "latest", &opts); err != nil {
6969
return nil, err

pkg/state/zeroaddr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ var (
1414
// WithZeroAddressOverride takes a set and appends an override for the zero address to have a balance equal to
1515
// max uint96.
1616
func WithZeroAddressOverride(os OverrideSet) OverrideSet {
17+
if os == nil {
18+
os = OverrideSet{}
19+
}
20+
1721
bal := hexutil.Big(*maxUint96)
1822
os[common.HexToAddress("0x")] = OverrideAccount{
1923
Balance: &bal,

pkg/state/zeroaddr_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ func TestWithZeroAddressOverride(t *testing.T) {
2121
t.Fatalf("got %s, want %s", oa.Balance.ToInt().String(), maxUint96.String())
2222
}
2323
}
24+
25+
func TestWithZeroAddressOverrideNil(t *testing.T) {
26+
os := WithZeroAddressOverride(nil)
27+
if oa, ok := os[common.HexToAddress("0x")]; !ok {
28+
t.Fatal("OverrideSet does not contain OverrideAccount")
29+
} else if oa.Balance.ToInt().String() != maxUint96.String() {
30+
t.Fatalf("got %s, want %s", oa.Balance.ToInt().String(), maxUint96.String())
31+
}
32+
}

0 commit comments

Comments
 (0)