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

Commit 918ed58

Browse files
authored
Add support for Erigon client (#299)
1 parent ec64ad6 commit 918ed58

File tree

5 files changed

+49
-23
lines changed

5 files changed

+49
-23
lines changed

.github/workflows/compliance.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ jobs:
4949
5050
- name: Install Geth
5151
run: |
52-
sudo add-apt-repository -y ppa:ethereum/ethereum && \
53-
sudo apt-get update && \
54-
sudo apt-get install ethereum
52+
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.12.2-bed84606.tar.gz && \
53+
tar -xvf geth-linux-amd64-1.12.2-bed84606.tar.gz
5554
5655
- name: Run Geth
5756
run: |
58-
geth \
57+
cd geth-linux-amd64-1.12.2-bed84606 && \
58+
./geth \
5959
--verbosity 1 \
6060
--http.vhosts '*,localhost,host.docker.internal' \
6161
--http \
@@ -83,7 +83,8 @@ jobs:
8383
8484
- name: Fund bundler
8585
run: |
86-
geth \
86+
cd geth-linux-amd64-1.12.2-bed84606 && \
87+
./geth \
8788
--exec "eth.sendTransaction({from: eth.accounts[0], to: \"0x43378ff8C70109Ee4Dbe85aF34428ab0615EBd23\", value: web3.toWei(10000, \"ether\")})" \
8889
attach http://localhost:8545/
8990

pkg/entrypoint/execution/trace.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ type TraceInput struct {
2727
ChainID *big.Int
2828

2929
// Optional params for simulateHandleOps
30-
Target common.Address
31-
Data []byte
30+
Target common.Address
31+
Data []byte
32+
TraceFeeCap *big.Int
3233
}
3334

3435
type TraceOutput struct {
@@ -78,6 +79,10 @@ func TraceSimulateHandleOp(in *TraceInput) (*TraceOutput, error) {
7879
}
7980
auth.GasLimit = math.MaxUint64
8081
auth.NoSend = true
82+
mf := in.Op.MaxFeePerGas
83+
if in.TraceFeeCap != nil {
84+
mf = in.TraceFeeCap
85+
}
8186
tx, err := ep.SimulateHandleOp(auth, entrypoint.UserOperation(*in.Op), in.Target, in.Data)
8287
if err != nil {
8388
return nil, err
@@ -86,12 +91,14 @@ func TraceSimulateHandleOp(in *TraceInput) (*TraceOutput, error) {
8691

8792
var res tracer.BundlerExecutionReturn
8893
req := utils.TraceCallReq{
89-
From: common.HexToAddress("0x"),
90-
To: in.EntryPoint,
91-
Data: tx.Data(),
94+
From: common.HexToAddress("0x"),
95+
To: in.EntryPoint,
96+
Data: tx.Data(),
97+
MaxFeePerGas: hexutil.Big(*mf),
9298
}
9399
opts := utils.TraceCallOpts{
94-
Tracer: tracer.Loaded.BundlerExecutionTracer,
100+
Tracer: tracer.Loaded.BundlerExecutionTracer,
101+
StateOverrides: utils.DefaultStateOverrides,
95102
}
96103
if err := in.Rpc.CallContext(context.Background(), &res, "debug_traceCall", &req, "latest", &opts); err != nil {
97104
return nil, err

pkg/entrypoint/simulation/tracevalidation.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
mapset "github.com/deckarep/golang-set/v2"
1111
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1212
"github.com/ethereum/go-ethereum/common"
13+
"github.com/ethereum/go-ethereum/common/hexutil"
1314
"github.com/ethereum/go-ethereum/ethclient"
1415
"github.com/ethereum/go-ethereum/rpc"
1516
"github.com/stackup-wallet/stackup-bundler/pkg/entrypoint"
@@ -45,12 +46,14 @@ func TraceSimulateValidation(
4546

4647
var res tracer.BundlerCollectorReturn
4748
req := utils.TraceCallReq{
48-
From: common.HexToAddress("0x"),
49-
To: entryPoint,
50-
Data: tx.Data(),
49+
From: common.HexToAddress("0x"),
50+
To: entryPoint,
51+
Data: tx.Data(),
52+
MaxFeePerGas: hexutil.Big(*op.MaxFeePerGas),
5153
}
5254
opts := utils.TraceCallOpts{
53-
Tracer: tracer.Loaded.BundlerCollectorTracer,
55+
Tracer: tracer.Loaded.BundlerCollectorTracer,
56+
StateOverrides: utils.DefaultStateOverrides,
5457
}
5558
if err := rpc.CallContext(context.Background(), &res, "debug_traceCall", &req, "latest", &opts); err != nil {
5659
return nil, err

pkg/entrypoint/utils/tracing.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
package utils
22

33
import (
4+
"math"
5+
"math/big"
6+
47
"github.com/ethereum/go-ethereum/common"
58
"github.com/ethereum/go-ethereum/common/hexutil"
69
"github.com/ethereum/go-ethereum/crypto"
710
)
811

912
type TraceCallReq struct {
10-
From common.Address `json:"from"`
11-
To common.Address `json:"to"`
12-
Data hexutil.Bytes `json:"data"`
13+
From common.Address `json:"from"`
14+
To common.Address `json:"to"`
15+
Data hexutil.Bytes `json:"data"`
16+
MaxFeePerGas hexutil.Big `json:"maxFeePerGas"`
17+
}
18+
19+
type TraceStateOverrides struct {
20+
Balance hexutil.Big `json:"balance"`
1321
}
1422

1523
type TraceCallOpts struct {
16-
Tracer string `json:"tracer"`
24+
Tracer string `json:"tracer"`
25+
StateOverrides map[string]TraceStateOverrides `json:"stateOverrides"`
1726
}
1827

1928
var (
2029
// A dummy private key used to build *bind.TransactOpts for simulation.
2130
DummyPk, _ = crypto.GenerateKey()
31+
32+
// A default state override to ensure the zero address always has sufficient funds.
33+
DefaultStateOverrides = map[string]TraceStateOverrides{
34+
common.HexToAddress("0x").Hex(): {Balance: hexutil.Big(*big.NewInt(0).SetUint64(math.MaxUint64))},
35+
}
2236
)

pkg/gas/estimate.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ func EstimateGas(in *EstimateInput) (verificationGas uint64, callGas uint64, err
131131
return 0, 0, err
132132
}
133133
out, err := execution.TraceSimulateHandleOp(&execution.TraceInput{
134-
Rpc: in.Rpc,
135-
EntryPoint: in.EntryPoint,
136-
Op: simOp,
137-
ChainID: in.ChainID,
134+
Rpc: in.Rpc,
135+
EntryPoint: in.EntryPoint,
136+
Op: simOp,
137+
ChainID: in.ChainID,
138+
TraceFeeCap: in.Op.MaxFeePerGas,
138139
})
139140
if err != nil {
140141
return 0, 0, err

0 commit comments

Comments
 (0)