This repository was archived by the owner on Oct 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-48
lines changed Expand file tree Collapse file tree 2 files changed +21
-48
lines changed Original file line number Diff line number Diff line change @@ -3,44 +3,26 @@ package checks
3
3
import (
4
4
"github.com/ethereum/go-ethereum/common"
5
5
"github.com/ethereum/go-ethereum/crypto"
6
- "golang.org/x/sync/errgroup"
7
6
)
8
7
9
8
type codeHash struct {
10
9
Address common.Address `json:"address"`
11
10
Hash common.Hash `json:"hash"`
12
11
}
13
12
14
- func getCodeHashAsync (addr common.Address , gc GetCodeFunc , c chan codeHash ) func () error {
15
- return func () error {
13
+ func getCodeHashes (ic []common.Address , gc GetCodeFunc ) ([]codeHash , error ) {
14
+ ret := []codeHash {}
15
+
16
+ for _ , addr := range ic {
16
17
bytecode , err := gc (addr )
17
18
if err != nil {
18
- c <- codeHash {}
19
- return err
19
+ return ret , err
20
20
}
21
21
22
- ch := codeHash {
22
+ ret = append ( ret , codeHash {
23
23
Address : addr ,
24
24
Hash : crypto .Keccak256Hash (bytecode ),
25
- }
26
- c <- ch
27
- return nil
28
- }
29
- }
30
-
31
- func getCodeHashes (ic []common.Address , gc GetCodeFunc ) ([]codeHash , error ) {
32
- g := new (errgroup.Group )
33
- c := make (chan codeHash )
34
- ret := []codeHash {}
35
-
36
- for _ , addr := range ic {
37
- g .Go (getCodeHashAsync (addr , gc , c ))
38
- }
39
- for range ic {
40
- ret = append (ret , <- c )
41
- }
42
- if err := g .Wait (); err != nil {
43
- return ret , err
25
+ })
44
26
}
45
27
46
28
return ret , nil
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ package checks
4
4
5
5
import (
6
6
"math/big"
7
- "sync"
8
7
"time"
9
8
10
9
"github.com/dgraph-io/badger/v3"
@@ -137,32 +136,24 @@ func (s *Standalone) SimulateOp() modules.UserOpHandlerFunc {
137
136
func (s * Standalone ) CodeHashes () modules.BatchHandlerFunc {
138
137
return func (ctx * modules.BatchHandlerCtx ) error {
139
138
gc := getCodeWithEthClient (s .eth )
140
- g := new (errgroup.Group )
141
- mu := & sync.Mutex {}
142
- fn := func (i int , op * userop.UserOperation ) func () error {
143
- return func () error {
144
- chs , err := getSavedCodeHashes (s .db , op .GetUserOpHash (ctx .EntryPoint , ctx .ChainID ))
145
- if err != nil {
146
- return err
147
- }
148
139
149
- changed , err := hasCodeHashChanges (chs , gc )
150
- if err != nil {
151
- return err
152
- }
153
- if changed {
154
- mu .Lock ()
155
- ctx .MarkOpIndexForRemoval (i )
156
- mu .Unlock ()
157
- }
158
- return nil
140
+ end := len (ctx .Batch ) - 1
141
+ for i := end ; i >= 0 ; i -- {
142
+ op := ctx .Batch [i ]
143
+ chs , err := getSavedCodeHashes (s .db , op .GetUserOpHash (ctx .EntryPoint , ctx .ChainID ))
144
+ if err != nil {
145
+ return err
159
146
}
160
- }
161
147
162
- for i , op := range ctx .Batch {
163
- g .Go (fn (i , op ))
148
+ changed , err := hasCodeHashChanges (chs , gc )
149
+ if err != nil {
150
+ return err
151
+ }
152
+ if changed {
153
+ ctx .MarkOpIndexForRemoval (i )
154
+ }
164
155
}
165
- return g . Wait ()
156
+ return nil
166
157
}
167
158
}
168
159
You can’t perform that action at this time.
0 commit comments