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

disable MT in DS Tool #3714

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions tools/datastreamer/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package config
// DefaultValues is the default configuration
const DefaultValues = `
[Online]
URI = "zkevm-sequencer:6900"
URI = "localhost:6900"
StreamType = 1

[Offline]
Port = 6901
Filename = "datastreamer.bin"
Version = 1
Filename = "datastream.bin"
Version = 3
ChainID = 1440
WriteTimeout = "5s"
UpgradeEtrogBatchNumber = 0

[StateDB]
Expand All @@ -22,13 +23,9 @@ Port = "5432"
EnableLog = false
MaxConns = 200

[Executor]
URI = "zkevm-prover:50071"
MaxGRPCMessageSize = 100000000

[MerkleTree]
URI = "zkevm-prover:50061"
MaxThreads = 20
URI = "localhost:50061"
MaxThreads = 0
CacheFile = ""

[Log]
Expand Down
3 changes: 1 addition & 2 deletions tools/datastreamer/config/tool.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Port = 6901
Filename = "datastream.bin"
Version = 3
ChainID = 1440
WriteTimeout = "5s"
UpgradeEtrogBatchNumber = 0

[StateDB]
Expand All @@ -21,7 +20,7 @@ MaxConns = 200

[MerkleTree]
URI = "localhost:50061"
MaxThreads = 20
MaxThreads = 0
CacheFile = "merkle_tree_cache.json"

[Log]
Expand Down
26 changes: 16 additions & 10 deletions tools/datastreamer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,21 @@ func generate(cliCtx *cli.Context) error {
stateDBStorage := pgstatestorage.NewPostgresStorage(state.Config{}, stateSqlDB)
log.Debug("Connected to the database")

mtDBServerConfig := merkletree.Config{URI: c.MerkleTree.URI}
var mtDBCancel context.CancelFunc
mtDBServiceClient, mtDBClientConn, mtDBCancel := merkletree.NewMTDBServiceClient(cliCtx.Context, mtDBServerConfig)
defer func() {
mtDBCancel()
mtDBClientConn.Close()
}()
stateTree := merkletree.NewStateTree(mtDBServiceClient)
log.Debug("Connected to the merkle tree")
var stateTree *merkletree.StateTree

if c.MerkleTree.MaxThreads > 0 {
mtDBServerConfig := merkletree.Config{URI: c.MerkleTree.URI}
var mtDBCancel context.CancelFunc
mtDBServiceClient, mtDBClientConn, mtDBCancel := merkletree.NewMTDBServiceClient(cliCtx.Context, mtDBServerConfig)
defer func() {
mtDBCancel()
mtDBClientConn.Close()
}()
stateTree = merkletree.NewStateTree(mtDBServiceClient)
log.Debug("Connected to the merkle tree")
} else {
log.Debug("Merkle tree disabled")
}

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

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

// Convert imStateRoots to a json and save it to a file
if c.MerkleTree.CacheFile != "" {
if c.MerkleTree.CacheFile != "" && c.MerkleTree.MaxThreads > 0 {
jsonFile, _ := json.Marshal(imStateRoots)
err = os.WriteFile(c.MerkleTree.CacheFile, jsonFile, 0644) // nolint:gosec, gomnd
if err != nil {
Expand Down
Loading