Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 764495f

Browse files
authored
disable MT in DS Tool (#3714)
1 parent 9fb57c9 commit 764495f

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

tools/datastreamer/config/default.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package config
33
// DefaultValues is the default configuration
44
const DefaultValues = `
55
[Online]
6-
URI = "zkevm-sequencer:6900"
6+
URI = "localhost:6900"
77
StreamType = 1
88
99
[Offline]
1010
Port = 6901
11-
Filename = "datastreamer.bin"
12-
Version = 1
11+
Filename = "datastream.bin"
12+
Version = 3
1313
ChainID = 1440
14+
WriteTimeout = "5s"
1415
UpgradeEtrogBatchNumber = 0
1516
1617
[StateDB]
@@ -22,13 +23,9 @@ Port = "5432"
2223
EnableLog = false
2324
MaxConns = 200
2425
25-
[Executor]
26-
URI = "zkevm-prover:50071"
27-
MaxGRPCMessageSize = 100000000
28-
2926
[MerkleTree]
30-
URI = "zkevm-prover:50061"
31-
MaxThreads = 20
27+
URI = "localhost:50061"
28+
MaxThreads = 0
3229
CacheFile = ""
3330
3431
[Log]

tools/datastreamer/config/tool.config.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Port = 6901
77
Filename = "datastream.bin"
88
Version = 3
99
ChainID = 1440
10-
WriteTimeout = "5s"
1110
UpgradeEtrogBatchNumber = 0
1211

1312
[StateDB]
@@ -21,7 +20,7 @@ MaxConns = 200
2120

2221
[MerkleTree]
2322
URI = "localhost:50061"
24-
MaxThreads = 20
23+
MaxThreads = 0
2524
CacheFile = "merkle_tree_cache.json"
2625

2726
[Log]

tools/datastreamer/main.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,21 @@ func generate(cliCtx *cli.Context) error {
222222
stateDBStorage := pgstatestorage.NewPostgresStorage(state.Config{}, stateSqlDB)
223223
log.Debug("Connected to the database")
224224

225-
mtDBServerConfig := merkletree.Config{URI: c.MerkleTree.URI}
226-
var mtDBCancel context.CancelFunc
227-
mtDBServiceClient, mtDBClientConn, mtDBCancel := merkletree.NewMTDBServiceClient(cliCtx.Context, mtDBServerConfig)
228-
defer func() {
229-
mtDBCancel()
230-
mtDBClientConn.Close()
231-
}()
232-
stateTree := merkletree.NewStateTree(mtDBServiceClient)
233-
log.Debug("Connected to the merkle tree")
225+
var stateTree *merkletree.StateTree
226+
227+
if c.MerkleTree.MaxThreads > 0 {
228+
mtDBServerConfig := merkletree.Config{URI: c.MerkleTree.URI}
229+
var mtDBCancel context.CancelFunc
230+
mtDBServiceClient, mtDBClientConn, mtDBCancel := merkletree.NewMTDBServiceClient(cliCtx.Context, mtDBServerConfig)
231+
defer func() {
232+
mtDBCancel()
233+
mtDBClientConn.Close()
234+
}()
235+
stateTree = merkletree.NewStateTree(mtDBServiceClient)
236+
log.Debug("Connected to the merkle tree")
237+
} else {
238+
log.Debug("Merkle tree disabled")
239+
}
234240

235241
stateDB := state.NewState(state.Config{}, stateDBStorage, nil, stateTree, nil, nil, nil)
236242

@@ -288,7 +294,7 @@ func generate(cliCtx *cli.Context) error {
288294
wg.Wait()
289295

290296
// Convert imStateRoots to a json and save it to a file
291-
if c.MerkleTree.CacheFile != "" {
297+
if c.MerkleTree.CacheFile != "" && c.MerkleTree.MaxThreads > 0 {
292298
jsonFile, _ := json.Marshal(imStateRoots)
293299
err = os.WriteFile(c.MerkleTree.CacheFile, jsonFile, 0644) // nolint:gosec, gomnd
294300
if err != nil {

0 commit comments

Comments
 (0)