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

Commit 42b7da5

Browse files
authored
Support native bundlerCollectorTracer (#365)
1 parent 7a91dd3 commit 42b7da5

File tree

9 files changed

+65
-51
lines changed

9 files changed

+65
-51
lines changed

.github/workflows/compliance.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,10 @@ jobs:
4949
yarn install --frozen-lockfile && \
5050
yarn build
5151
52-
- name: Install Geth
53-
run: |
54-
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.12.2-bed84606.tar.gz && \
55-
tar -xvf geth-linux-amd64-1.12.2-bed84606.tar.gz
56-
5752
- name: Run Geth
5853
run: |
59-
cd geth-linux-amd64-1.12.2-bed84606 && \
60-
./geth \
54+
docker run -d --name node -p 8545:8545 \
55+
stackupwallet/go-ethereum:v1.13.11 \
6156
--verbosity 1 \
6257
--http.vhosts '*,localhost,host.docker.internal' \
6358
--http \
@@ -69,7 +64,7 @@ jobs:
6964
--dev \
7065
--allow-insecure-unlock \
7166
--rpc.allow-unprotected-txs \
72-
--miner.gaslimit 12000000 &
67+
--miner.gaslimit 12000000
7368
7469
- name: Install bundler dependencies
7570
run: go mod download
@@ -85,8 +80,8 @@ jobs:
8580
8681
- name: Fund bundler
8782
run: |
88-
cd geth-linux-amd64-1.12.2-bed84606 && \
89-
./geth \
83+
docker exec node \
84+
geth \
9085
--exec "eth.sendTransaction({from: eth.accounts[0], to: \"0x43378ff8C70109Ee4Dbe85aF34428ab0615EBd23\", value: web3.toWei(10000, \"ether\")})" \
9186
attach http://localhost:8545/
9287
@@ -96,6 +91,7 @@ jobs:
9691
ERC4337_BUNDLER_ETH_CLIENT_URL: http://localhost:8545/
9792
ERC4337_BUNDLER_PORT: 3000
9893
ERC4337_BUNDLER_DEBUG_MODE: true
94+
ERC4337_BUNDLER_NATIVE_BUNDLER_COLLECTOR_TRACER: bundlerCollectorTracer
9995
# This key is for testing purposes only. Do not use for anything else.
10096
ERC4337_BUNDLER_PRIVATE_KEY: c6cbc5ffad570fdad0544d1b5358a36edeb98d163b6567912ac4754e144d4edb
10197

.github/workflows/e2e.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,10 @@ jobs:
6262
path: ./contracts
6363
submodules: true
6464

65-
- name: Install Geth
66-
run: |
67-
sudo add-apt-repository -y ppa:ethereum/ethereum && \
68-
sudo apt-get update && \
69-
sudo apt-get install ethereum
70-
7165
- name: Run Geth
7266
run: |
73-
geth \
67+
docker run -d --name node -p 8545:8545 \
68+
stackupwallet/go-ethereum:v1.13.11 \
7469
--verbosity 1 \
7570
--http.vhosts '*,localhost,host.docker.internal' \
7671
--http \
@@ -82,7 +77,7 @@ jobs:
8277
--dev \
8378
--allow-insecure-unlock \
8479
--rpc.allow-unprotected-txs \
85-
--miner.gaslimit 12000000 &
80+
--miner.gaslimit 12000000
8681
8782
- name: Install all dependencies
8883
run: |
@@ -110,6 +105,7 @@ jobs:
110105
env:
111106
ERC4337_BUNDLER_ETH_CLIENT_URL: http://localhost:8545/
112107
ERC4337_BUNDLER_DEBUG_MODE: true
108+
ERC4337_BUNDLER_NATIVE_BUNDLER_COLLECTOR_TRACER: bundlerCollectorTracer
113109
# This key is for testing purposes only. Do not use for anything else.
114110
ERC4337_BUNDLER_PRIVATE_KEY: c6cbc5ffad570fdad0544d1b5358a36edeb98d163b6567912ac4754e144d4edb
115111

e2e/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ Assuming you have your environment properly setup, you can use the following com
6161
```bash
6262
yarn run test
6363
```
64+
65+
## Using native tracers for faster performance
66+
67+
For better performance, build Geth from source using the [ERC-4337 Execution Clients](https://github.com/stackup-wallet/erc-4337-execution-clients) repository. Run the built geth binary and reset the bundler with the following config:
68+
69+
```
70+
ERC4337_BUNDLER_NATIVE_BUNDLER_COLLECTOR_TRACER=bundlerCollectorTracer
71+
```

internal/config/values.go

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ import (
1515

1616
type Values struct {
1717
// Documented variables.
18-
PrivateKey string
19-
EthClientUrl string
20-
Port int
21-
DataDirectory string
22-
SupportedEntryPoints []common.Address
23-
MaxVerificationGas *big.Int
24-
MaxBatchGasLimit *big.Int
25-
MaxOpTTL time.Duration
26-
Beneficiary string
27-
ReputationConstants *entities.ReputationConstants
18+
PrivateKey string
19+
EthClientUrl string
20+
Port int
21+
DataDirectory string
22+
SupportedEntryPoints []common.Address
23+
MaxVerificationGas *big.Int
24+
MaxBatchGasLimit *big.Int
25+
MaxOpTTL time.Duration
26+
Beneficiary string
27+
NativeBundlerCollectorTracer string
28+
ReputationConstants *entities.ReputationConstants
2829

2930
// Searcher mode variables.
3031
EthBuilderUrls []string
@@ -113,6 +114,7 @@ func GetValues() *Values {
113114
_ = viper.BindEnv("erc4337_bundler_data_directory")
114115
_ = viper.BindEnv("erc4337_bundler_supported_entry_points")
115116
_ = viper.BindEnv("erc4337_bundler_beneficiary")
117+
_ = viper.BindEnv("erc4337_bundler_native_bundler_collector_tracer")
116118
_ = viper.BindEnv("erc4337_bundler_max_verification_gas")
117119
_ = viper.BindEnv("erc4337_bundler_max_batch_gas_limit")
118120
_ = viper.BindEnv("erc4337_bundler_max_op_ttl_seconds")
@@ -170,6 +172,7 @@ func GetValues() *Values {
170172
dataDirectory := viper.GetString("erc4337_bundler_data_directory")
171173
supportedEntryPoints := envArrayToAddressSlice(viper.GetString("erc4337_bundler_supported_entry_points"))
172174
beneficiary := viper.GetString("erc4337_bundler_beneficiary")
175+
nativeBundlerCollectorTracer := viper.GetString("erc4337_bundler_native_bundler_collector_tracer")
173176
maxVerificationGas := big.NewInt(int64(viper.GetInt("erc4337_bundler_max_verification_gas")))
174177
maxBatchGasLimit := big.NewInt(int64(viper.GetInt("erc4337_bundler_max_batch_gas_limit")))
175178
maxOpTTL := time.Second * viper.GetDuration("erc4337_bundler_max_op_ttl_seconds")
@@ -184,25 +187,26 @@ func GetValues() *Values {
184187
debugMode := viper.GetBool("erc4337_bundler_debug_mode")
185188
ginMode := viper.GetString("erc4337_bundler_gin_mode")
186189
return &Values{
187-
PrivateKey: privateKey,
188-
EthClientUrl: ethClientUrl,
189-
Port: port,
190-
DataDirectory: dataDirectory,
191-
SupportedEntryPoints: supportedEntryPoints,
192-
Beneficiary: beneficiary,
193-
MaxVerificationGas: maxVerificationGas,
194-
MaxBatchGasLimit: maxBatchGasLimit,
195-
MaxOpTTL: maxOpTTL,
196-
ReputationConstants: NewReputationConstantsFromEnv(),
197-
EthBuilderUrls: ethBuilderUrls,
198-
BlocksInTheFuture: blocksInTheFuture,
199-
OTELServiceName: otelServiceName,
200-
OTELCollectorHeaders: otelCollectorHeader,
201-
OTELCollectorUrl: otelCollectorUrl,
202-
OTELInsecureMode: otelInsecureMode,
203-
AltMempoolIPFSGateway: altMempoolIPFSGateway,
204-
AltMempoolIds: altMempoolIds,
205-
DebugMode: debugMode,
206-
GinMode: ginMode,
190+
PrivateKey: privateKey,
191+
EthClientUrl: ethClientUrl,
192+
Port: port,
193+
DataDirectory: dataDirectory,
194+
SupportedEntryPoints: supportedEntryPoints,
195+
Beneficiary: beneficiary,
196+
NativeBundlerCollectorTracer: nativeBundlerCollectorTracer,
197+
MaxVerificationGas: maxVerificationGas,
198+
MaxBatchGasLimit: maxBatchGasLimit,
199+
MaxOpTTL: maxOpTTL,
200+
ReputationConstants: NewReputationConstantsFromEnv(),
201+
EthBuilderUrls: ethBuilderUrls,
202+
BlocksInTheFuture: blocksInTheFuture,
203+
OTELServiceName: otelServiceName,
204+
OTELCollectorHeaders: otelCollectorHeader,
205+
OTELCollectorUrl: otelCollectorUrl,
206+
OTELInsecureMode: otelInsecureMode,
207+
AltMempoolIPFSGateway: altMempoolIPFSGateway,
208+
AltMempoolIds: altMempoolIds,
209+
DebugMode: debugMode,
210+
GinMode: ginMode,
207211
}
208212
}

internal/start/private.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func PrivateMode() {
115115
alt,
116116
conf.MaxVerificationGas,
117117
conf.MaxBatchGasLimit,
118+
conf.NativeBundlerCollectorTracer,
118119
conf.ReputationConstants,
119120
)
120121

internal/start/searcher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func SearcherMode() {
111111
alt,
112112
conf.MaxVerificationGas,
113113
conf.MaxBatchGasLimit,
114+
conf.NativeBundlerCollectorTracer,
114115
conf.ReputationConstants,
115116
)
116117

pkg/entrypoint/simulation/tracevalidation.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type TraceInput struct {
2727
EntryPoint common.Address
2828
Op *userop.UserOperation
2929
ChainID *big.Int
30+
Tracer string
3031
Stakes EntityStakes
3132
AltMempools *altmempools.Directory
3233
}
@@ -53,6 +54,10 @@ func TraceSimulateValidation(in *TraceInput) (*TraceOutput, error) {
5354
if err != nil {
5455
return nil, err
5556
}
57+
t := tracer.Loaded.BundlerCollectorTracer
58+
if in.Tracer != "" {
59+
t = in.Tracer
60+
}
5661

5762
var res tracer.BundlerCollectorReturn
5863
req := utils.TraceCallReq{
@@ -62,7 +67,7 @@ func TraceSimulateValidation(in *TraceInput) (*TraceOutput, error) {
6267
MaxFeePerGas: hexutil.Big(*in.Op.MaxFeePerGas),
6368
}
6469
opts := utils.TraceCallOpts{
65-
Tracer: tracer.Loaded.BundlerCollectorTracer,
70+
Tracer: t,
6671
StateOverrides: state.WithMaxBalanceOverride(common.HexToAddress("0x"), nil),
6772
}
6873
if err := in.Rpc.CallContext(context.Background(), &res, "debug_traceCall", &req, "latest", &opts); err != nil {

pkg/modules/checks/standalone.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Standalone struct {
3333
alt *altmempools.Directory
3434
maxVerificationGas *big.Int
3535
maxBatchGasLimit *big.Int
36+
tracer string
3637
repConst *entities.ReputationConstants
3738
}
3839

@@ -45,10 +46,11 @@ func New(
4546
alt *altmempools.Directory,
4647
maxVerificationGas *big.Int,
4748
maxBatchGasLimit *big.Int,
49+
tracer string,
4850
repConst *entities.ReputationConstants,
4951
) *Standalone {
5052
eth := ethclient.NewClient(rpc)
51-
return &Standalone{db, rpc, eth, ov, alt, maxVerificationGas, maxBatchGasLimit, repConst}
53+
return &Standalone{db, rpc, eth, ov, alt, maxVerificationGas, maxBatchGasLimit, tracer, repConst}
5254
}
5355

5456
// ValidateOpValues returns a UserOpHandler that runs through some first line sanity checks for new UserOps
@@ -109,6 +111,7 @@ func (s *Standalone) SimulateOp() modules.UserOpHandlerFunc {
109111
AltMempools: s.alt,
110112
Op: ctx.UserOp,
111113
ChainID: ctx.ChainID,
114+
Tracer: s.tracer,
112115
Stakes: simulation.EntityStakes{
113116
ctx.UserOp.Sender: ctx.GetSenderDepositInfo(),
114117
ctx.UserOp.GetFactory(): ctx.GetFactoryDepositInfo(),

pkg/tracer/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type CallFromEntryPointInfo struct {
3535
Opcodes Counts `json:"opcodes"`
3636
Access AccessMap `json:"access"`
3737
ContractSize ContractSizeMap `json:"contractSize"`
38-
ExtCodeAccessInfo ExtCodeAccessInfoMap `json:"ExtCodeAccessInfo"`
38+
ExtCodeAccessInfo ExtCodeAccessInfoMap `json:"extCodeAccessInfo"`
3939
OOG bool `json:"oog"`
4040
}
4141

0 commit comments

Comments
 (0)