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

Commit 545c506

Browse files
authored
1 parent c076254 commit 545c506

File tree

5 files changed

+494
-73
lines changed

5 files changed

+494
-73
lines changed

abi/entrypoint.json

Lines changed: 116 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,40 @@
2929
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
3030
{
3131
"components": [
32+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
3233
{
3334
"internalType": "uint256",
34-
"name": "paymasterStake",
35+
"name": "unstakeDelaySec",
3536
"type": "uint256"
36-
},
37+
}
38+
],
39+
"internalType": "struct IStakeManager.StakeInfo",
40+
"name": "senderInfo",
41+
"type": "tuple"
42+
},
43+
{
44+
"components": [
45+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
46+
{
47+
"internalType": "uint256",
48+
"name": "unstakeDelaySec",
49+
"type": "uint256"
50+
}
51+
],
52+
"internalType": "struct IStakeManager.StakeInfo",
53+
"name": "factoryInfo",
54+
"type": "tuple"
55+
},
56+
{
57+
"components": [
58+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
3759
{
3860
"internalType": "uint256",
39-
"name": "paymasterUnstakeDelay",
61+
"name": "unstakeDelaySec",
4062
"type": "uint256"
4163
}
4264
],
43-
"internalType": "struct IEntryPoint.PaymasterInfo",
65+
"internalType": "struct IStakeManager.StakeInfo",
4466
"name": "paymasterInfo",
4567
"type": "tuple"
4668
}
@@ -55,18 +77,40 @@
5577
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
5678
{
5779
"components": [
80+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
5881
{
5982
"internalType": "uint256",
60-
"name": "paymasterStake",
83+
"name": "unstakeDelaySec",
6184
"type": "uint256"
62-
},
85+
}
86+
],
87+
"internalType": "struct IStakeManager.StakeInfo",
88+
"name": "senderInfo",
89+
"type": "tuple"
90+
},
91+
{
92+
"components": [
93+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
6394
{
6495
"internalType": "uint256",
65-
"name": "paymasterUnstakeDelay",
96+
"name": "unstakeDelaySec",
6697
"type": "uint256"
6798
}
6899
],
69-
"internalType": "struct IEntryPoint.PaymasterInfo",
100+
"internalType": "struct IStakeManager.StakeInfo",
101+
"name": "factoryInfo",
102+
"type": "tuple"
103+
},
104+
{
105+
"components": [
106+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
107+
{
108+
"internalType": "uint256",
109+
"name": "unstakeDelaySec",
110+
"type": "uint256"
111+
}
112+
],
113+
"internalType": "struct IStakeManager.StakeInfo",
70114
"name": "paymasterInfo",
71115
"type": "tuple"
72116
},
@@ -78,24 +122,58 @@
78122
"type": "address"
79123
},
80124
{
81-
"internalType": "uint256",
82-
"name": "aggregatorStake",
83-
"type": "uint256"
84-
},
85-
{
86-
"internalType": "uint256",
87-
"name": "aggregatorUnstakeDelay",
88-
"type": "uint256"
125+
"components": [
126+
{ "internalType": "uint256", "name": "stake", "type": "uint256" },
127+
{
128+
"internalType": "uint256",
129+
"name": "unstakeDelaySec",
130+
"type": "uint256"
131+
}
132+
],
133+
"internalType": "struct IStakeManager.StakeInfo",
134+
"name": "stakeInfo",
135+
"type": "tuple"
89136
}
90137
],
91-
"internalType": "struct IEntryPoint.AggregationInfo",
92-
"name": "aggregationInfo",
138+
"internalType": "struct IEntryPoint.AggregatorStakeInfo",
139+
"name": "aggregatorInfo",
93140
"type": "tuple"
94141
}
95142
],
96143
"name": "SimulationResultWithAggregation",
97144
"type": "error"
98145
},
146+
{
147+
"anonymous": false,
148+
"inputs": [
149+
{
150+
"indexed": true,
151+
"internalType": "bytes32",
152+
"name": "userOpHash",
153+
"type": "bytes32"
154+
},
155+
{
156+
"indexed": true,
157+
"internalType": "address",
158+
"name": "sender",
159+
"type": "address"
160+
},
161+
{
162+
"indexed": false,
163+
"internalType": "address",
164+
"name": "factory",
165+
"type": "address"
166+
},
167+
{
168+
"indexed": false,
169+
"internalType": "address",
170+
"name": "paymaster",
171+
"type": "address"
172+
}
173+
],
174+
"name": "AccountDeployed",
175+
"type": "event"
176+
},
99177
{
100178
"anonymous": false,
101179
"inputs": [
@@ -115,6 +193,19 @@
115193
"name": "Deposited",
116194
"type": "event"
117195
},
196+
{
197+
"anonymous": false,
198+
"inputs": [
199+
{
200+
"indexed": false,
201+
"internalType": "address",
202+
"name": "aggregator",
203+
"type": "address"
204+
}
205+
],
206+
"name": "SignatureAggregatorChanged",
207+
"type": "event"
208+
},
118209
{
119210
"anonymous": false,
120211
"inputs": [
@@ -213,21 +304,21 @@
213304
},
214305
{
215306
"indexed": false,
216-
"internalType": "uint256",
217-
"name": "actualGasCost",
218-
"type": "uint256"
307+
"internalType": "bool",
308+
"name": "success",
309+
"type": "bool"
219310
},
220311
{
221312
"indexed": false,
222313
"internalType": "uint256",
223-
"name": "actualGasPrice",
314+
"name": "actualGasCost",
224315
"type": "uint256"
225316
},
226317
{
227318
"indexed": false,
228-
"internalType": "bool",
229-
"name": "success",
230-
"type": "bool"
319+
"internalType": "uint256",
320+
"name": "actualGasUsed",
321+
"type": "uint256"
231322
}
232323
],
233324
"name": "UserOperationEvent",

internal/config/values.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func GetValues() *Values {
4343
// Default variables
4444
viper.SetDefault("erc4337_bundler_port", 4337)
4545
viper.SetDefault("erc4337_bundler_data_directory", "/tmp/stackup_bundler")
46-
viper.SetDefault("erc4337_bundler_supported_entry_points", "0x1D9a2CB3638C2FC8bF9C01D088B79E75CD188b17")
46+
viper.SetDefault("erc4337_bundler_supported_entry_points", "0x78d4f01f56b982a3B03C4E127A5D3aFa8EBee686")
4747
viper.SetDefault("erc4337_bundler_max_verification_gas", 1500000)
4848
viper.SetDefault("erc4337_bundler_gin_mode", gin.ReleaseMode)
4949

pkg/entrypoint/bindings.go

Lines changed: 304 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/entrypoint/reverts.go

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,39 @@ import (
1111
"github.com/ethereum/go-ethereum/rpc"
1212
)
1313

14-
type PaymasterInfo struct {
15-
PaymasterStake *big.Int `json:"paymasterStake"`
16-
PaymasterUnstakeDelay *big.Int `json:"paymasterUnstakeDelay"`
14+
type StakeInfo struct {
15+
Stake *big.Int `json:"stake"`
16+
UnstakeDelaySec *big.Int `json:"unstakeDelaySec"`
1717
}
1818

1919
type SimulationResultRevert struct {
2020
PreOpGas *big.Int
2121
Prefund *big.Int
2222
Deadline *big.Int
23-
PaymasterInfo *PaymasterInfo
23+
SenderInfo *StakeInfo
24+
FactoryInfo *StakeInfo
25+
PaymasterInfo *StakeInfo
2426
}
2527

28+
var (
29+
stakeInfoType = []abi.ArgumentMarshaling{
30+
{Name: "stake", Type: "uint256"},
31+
{Name: "unstakeDelaySec", Type: "uint256"},
32+
}
33+
)
34+
2635
func simulationResult() abi.Error {
2736
uint256, _ := abi.NewType("uint256", "uint256", nil)
28-
paymasterInfo, _ := abi.NewType("tuple", "PaymasterInfo", []abi.ArgumentMarshaling{
29-
{Name: "paymasterStake", Type: "uint256"},
30-
{Name: "paymasterUnstakeDelay", Type: "uint256"},
31-
})
37+
senderInfo, _ := abi.NewType("tuple", "SenderInfo", stakeInfoType)
38+
factoryInfo, _ := abi.NewType("tuple", "FactoryInfo", stakeInfoType)
39+
paymasterInfo, _ := abi.NewType("tuple", "PaymasterInfo", stakeInfoType)
40+
3241
return abi.NewError("SimulationResult", abi.Arguments{
3342
{Name: "preOpGas", Type: uint256},
3443
{Name: "prefund", Type: uint256},
3544
{Name: "deadline", Type: uint256},
45+
{Name: "senderInfo", Type: senderInfo},
46+
{Name: "factoryInfo", Type: factoryInfo},
3647
{Name: "paymasterInfo", Type: paymasterInfo},
3748
})
3849
}
@@ -58,8 +69,8 @@ func newSimulationResultRevert(err error) (*SimulationResultRevert, error) {
5869
if !ok {
5970
return nil, errors.New("simulationResult: cannot assert type: args is not of type []any")
6071
}
61-
if len(args) != 4 {
62-
return nil, fmt.Errorf("simulationResult: invalid args length: expected 4, got %d", len(args))
72+
if len(args) != 6 {
73+
return nil, fmt.Errorf("simulationResult: invalid args length: expected 6, got %d", len(args))
6374
}
6475

6576
preOpGas, ok := args[0].(*big.Int)
@@ -77,12 +88,29 @@ func newSimulationResultRevert(err error) (*SimulationResultRevert, error) {
7788
return nil, errors.New("simulationResult: cannot assert type: deadline is not of type *big.Int")
7889
}
7990

80-
pmi, err := json.Marshal(args[3])
91+
senderInfo := &StakeInfo{}
92+
si, err := json.Marshal(args[3])
93+
if err != nil {
94+
return nil, fmt.Errorf("simulationResult: %s", err)
95+
}
96+
if err := json.Unmarshal(si, senderInfo); err != nil {
97+
return nil, fmt.Errorf("simulationResult: %s", err)
98+
}
99+
100+
factoryInfo := &StakeInfo{}
101+
fi, err := json.Marshal(args[4])
81102
if err != nil {
82103
return nil, fmt.Errorf("simulationResult: %s", err)
83104
}
105+
if err := json.Unmarshal(fi, factoryInfo); err != nil {
106+
return nil, fmt.Errorf("simulationResult: %s", err)
107+
}
84108

85-
paymasterInfo := &PaymasterInfo{}
109+
paymasterInfo := &StakeInfo{}
110+
pmi, err := json.Marshal(args[5])
111+
if err != nil {
112+
return nil, fmt.Errorf("simulationResult: %s", err)
113+
}
86114
if err := json.Unmarshal(pmi, paymasterInfo); err != nil {
87115
return nil, fmt.Errorf("simulationResult: %s", err)
88116
}
@@ -91,6 +119,8 @@ func newSimulationResultRevert(err error) (*SimulationResultRevert, error) {
91119
PreOpGas: preOpGas,
92120
Prefund: prefund,
93121
Deadline: deadline,
122+
SenderInfo: senderInfo,
123+
FactoryInfo: factoryInfo,
94124
PaymasterInfo: paymasterInfo,
95125
}, nil
96126
}

pkg/entrypoint/simulation.go

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ var (
2222
// A dummy private key used to build *bind.TransactOpts for simulation.
2323
dummyPk, _ = crypto.GenerateKey()
2424

25-
// Pre number marker represents account validation.
26-
accountNumberLevel = "0"
25+
// Up to the first number marker represents factory validation.
26+
factoryNumberLevel = "0"
2727

28-
// Post number marker represents paymaster validation.
29-
paymasterNumberLevel = "1"
28+
// After the first number marker and before the second represents account validation.
29+
accountNumberLevel = "1"
30+
31+
// After the second number marker represents paymaster validation.
32+
paymasterNumberLevel = "2"
3033

3134
// Only one create2 opcode is allowed if these two conditions are met:
3235
// 1. op.initcode.length != 0
@@ -127,32 +130,40 @@ func TraceSimulateValidation(
127130
return err
128131
}
129132

130-
var accountOpCodes, paymasterOpCodes tracer.Counts
131-
if len(res.NumberLevels) == 1 {
132-
accountOpCodes = res.NumberLevels[accountNumberLevel].Opcodes
133-
paymasterOpCodes = make(tracer.Counts)
134-
} else if len(res.NumberLevels) == 2 {
135-
accountOpCodes = res.NumberLevels[accountNumberLevel].Opcodes
136-
paymasterOpCodes = res.NumberLevels[paymasterNumberLevel].Opcodes
137-
} else {
133+
var factoryOpCodes, accountOpCodes, paymasterOpCodes tracer.Counts
134+
if len(res.NumberLevels) != 3 {
138135
return fmt.Errorf("unexpected tracing result for op: %s", op.GetUserOpHash(entryPoint, chainID))
139136
}
137+
factoryOpCodes = res.NumberLevels[factoryNumberLevel].Opcodes
138+
accountOpCodes = res.NumberLevels[accountNumberLevel].Opcodes
139+
paymasterOpCodes = res.NumberLevels[paymasterNumberLevel].Opcodes
140+
141+
for opcode := range factoryOpCodes {
142+
if bannedOpCodes.Contains(opcode) {
143+
return fmt.Errorf("factory contains banned opcode: %s", opcode)
144+
}
145+
}
140146

141-
for key := range accountOpCodes {
142-
if bannedOpCodes.Contains(key) {
143-
return fmt.Errorf("account contains banned opcode: %s", key)
147+
for opcode := range accountOpCodes {
148+
if bannedOpCodes.Contains(opcode) {
149+
return fmt.Errorf("account contains banned opcode: %s", opcode)
144150
}
145151
}
146152

147-
for key := range paymasterOpCodes {
148-
if bannedOpCodes.Contains(key) {
149-
return fmt.Errorf("paymaster contains banned opcode: %s", key)
153+
for opcode := range paymasterOpCodes {
154+
if bannedOpCodes.Contains(opcode) {
155+
return fmt.Errorf("paymaster contains banned opcode: %s", opcode)
150156
}
151157
}
152158

153-
create2Count, ok := accountOpCodes[create2OpCode]
159+
create2Count, ok := factoryOpCodes[create2OpCode]
154160
if ok && (create2Count > 1 || len(op.InitCode) == 0) {
155-
return fmt.Errorf("account with too many %s", create2OpCode)
161+
return fmt.Errorf("factory with too many %s", create2OpCode)
162+
}
163+
164+
_, ok = accountOpCodes[create2OpCode]
165+
if ok {
166+
return fmt.Errorf("account uses banned %s opcode: %s", create2OpCode, op.Sender.String())
156167
}
157168

158169
_, ok = paymasterOpCodes[create2OpCode]

0 commit comments

Comments
 (0)