Skip to content

Commit 78b7021

Browse files
author
colinlyguo
committed
udpate
1 parent 670964e commit 78b7021

File tree

12 files changed

+204
-9
lines changed

12 files changed

+204
-9
lines changed

database/cmd/app/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func resetDB(ctx *cli.Context) error {
4242
}
4343

4444
var version int64
45-
err = migrate.Rollback(db.DB, &version)
45+
err = migrate.ResetDB(db.DB)
4646
if err != nil {
4747
return err
4848
}

rollup/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,32 @@ make rollup_bins
3333
./build/bin/gas_oracle --config ./conf/config.json
3434
./build/bin/rollup_relayer --config ./conf/config.json
3535
```
36+
37+
## How to run the proposer tool?
38+
39+
### Set the configs
40+
41+
1. Set genesis config to enable desired hardforks in [`proposer-tool-genesis.json`](./proposer-tool-genesis.json).
42+
2. Set proposer config in [`proposer-tool-config.json`](./proposer-tool-config.json) for data analysis.
43+
44+
### Start the proposer tool using docker-compose.
45+
46+
```
47+
cd rollup
48+
DOCKER_BUILDKIT=1 docker-compose -f docker-compose-proposer-tool.yml up -d
49+
```
50+
51+
> Note: The port 5432 of database is mapped to the host machine. You can use `psql` or any db clients to connect to the database.
52+
53+
> The DSN for the database is `postgres://postgres:postgres@db:5432/scroll?sslmode=disable`.
54+
55+
56+
### Reset env
57+
```
58+
docker-compose -f docker-compose-proposer-tool.yml down -v
59+
```
60+
61+
If you need to rebuild the images, removing the old images is necessary. You can do this by running the following command:
62+
```
63+
docker images | grep rollup | awk '{print $3}' | xargs docker rmi -f
64+
```

rollup/cmd/proposer_tool/app/app.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ package app
33
import (
44
"context"
55
"fmt"
6+
"math/big"
67
"os"
78
"os/signal"
89
"time"
910

1011
"github.com/prometheus/client_golang/prometheus"
1112
"github.com/scroll-tech/da-codec/encoding"
1213
"github.com/scroll-tech/go-ethereum/common"
14+
gethTypes "github.com/scroll-tech/go-ethereum/core/types"
15+
"github.com/scroll-tech/go-ethereum/ethclient"
1316
"github.com/scroll-tech/go-ethereum/log"
1417
"github.com/urfave/cli/v2"
1518

@@ -74,12 +77,33 @@ func action(ctx *cli.Context) error {
7477
}
7578
}()
7679

77-
blocks, err := orm.NewL2Block(dbForReplay).GetL2BlocksInRange(subCtx, cfg.L2Config.ReplayStartHeight, cfg.L2Config.ReplayStartHeight)
80+
// Init l2geth connection
81+
l2Client, err := ethclient.Dial(cfg.L2Config.Endpoint)
7882
if err != nil {
79-
log.Crit("failed to get l2 blocks", "start block", cfg.L2Config.ReplayStartHeight, "end block", cfg.L2Config.ReplayStartHeight, "error", err)
83+
log.Crit("failed to connect l2 geth", "config file", cfgFile, "error", err)
8084
}
8185

82-
chunk := &encoding.Chunk{Blocks: blocks}
86+
genesisHeader, err := l2Client.HeaderByNumber(subCtx, big.NewInt(0))
87+
if err != nil {
88+
return fmt.Errorf("failed to retrieve L2 genesis header: %v", err)
89+
}
90+
91+
genesisTime := genesisHeader.Time
92+
currentTime := uint64(time.Now().Unix())
93+
timeDrift := currentTime - genesisTime
94+
95+
cfg.L2Config.ChunkProposerConfig.ChunkTimeoutSec += timeDrift
96+
cfg.L2Config.BatchProposerConfig.BatchTimeoutSec += timeDrift
97+
cfg.L2Config.BundleProposerConfig.BundleTimeoutSec += timeDrift
98+
99+
chunk := &encoding.Chunk{
100+
Blocks: []*encoding.Block{{
101+
Header: genesisHeader,
102+
Transactions: nil,
103+
WithdrawRoot: common.Hash{},
104+
RowConsumption: &gethTypes.RowConsumption{},
105+
}},
106+
}
83107

84108
var dbChunk *orm.Chunk
85109
dbChunk, err = orm.NewChunk(db).InsertChunk(subCtx, chunk, encoding.CodecV0, rutils.ChunkMetrics{})

rollup/cmd/proposer_tool/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package main
22

3-
import "scroll-tech/rollup/cmd/rollup_relayer/app"
3+
import "scroll-tech/rollup/cmd/proposer_tool/app"
44

55
func main() {
66
app.Run()

rollup/conf/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
}
3333
},
3434
"l2_config": {
35-
"replay_start_height": 1000000,
3635
"confirmations": "0x1",
3736
"endpoint": "https://rpc.scroll.io",
3837
"l2_message_queue_address": "0x0000000000000000000000000000000000000000",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: postgres:14
6+
environment:
7+
- POSTGRES_USER=postgres
8+
- POSTGRES_PASSWORD=postgres
9+
- POSTGRES_DB=scroll
10+
ports:
11+
- "5432:5432"
12+
volumes:
13+
- postgres_data:/var/lib/postgresql/data
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U postgres"]
16+
interval: 5s
17+
timeout: 5s
18+
retries: 5
19+
20+
db-client:
21+
build:
22+
context: ..
23+
dockerfile: ./build/dockerfiles/db_cli.Dockerfile
24+
depends_on:
25+
db:
26+
condition: service_healthy
27+
command: ["reset", "--config", "/app/conf/proposer-tool-db-config.json"]
28+
volumes:
29+
- ./proposer-tool-db-config.json:/app/conf/proposer-tool-db-config.json
30+
31+
proposer-tool:
32+
build:
33+
context: ..
34+
dockerfile: ./rollup/proposer_tool.Dockerfile
35+
depends_on:
36+
db-client:
37+
condition: service_completed_successfully
38+
command: [
39+
"--config", "/app/conf/proposer-tool-config.json",
40+
"--genesis", "/app/conf/proposer-tool-genesis.json",
41+
"--min-codec-version", "4",
42+
"--log.debug", "--verbosity", "3"
43+
]
44+
volumes:
45+
- ./proposer-tool-config.json:/app/conf/proposer-tool-config.json
46+
- ./proposer-tool-genesis.json:/app/conf/proposer-tool-genesis.json
47+
restart: unless-stopped
48+
49+
volumes:
50+
postgres_data:

rollup/internal/config/l2.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ type L2Config struct {
2424
BatchProposerConfig *BatchProposerConfig `json:"batch_proposer_config"`
2525
// The bundle_proposer config
2626
BundleProposerConfig *BundleProposerConfig `json:"bundle_proposer_config"`
27-
28-
ReplayStartHeight uint64 `json:"replay_start_height"`
2927
}
3028

3129
// ChunkProposerConfig loads chunk_proposer configuration items.

rollup/internal/controller/watcher/chunk_proposer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ func (p *ChunkProposer) tryProposeEuclidTransitionChunk(blocks []*encoding.Block
445445
}
446446

447447
prevBlocks, err := p.l2BlockOrm.GetL2BlocksGEHeight(p.ctx, blocks[0].Header.Number.Uint64()-1, 1)
448-
if err != nil || len(prevBlocks) == 0 || prevBlocks[0].Header.Hash() != blocks[0].Header.ParentHash {
448+
if !p.toolFlag && (err != nil || len(prevBlocks) == 0 || prevBlocks[0].Header.Hash() != blocks[0].Header.ParentHash) {
449449
return false, fmt.Errorf("failed to get parent block: %w", err)
450450
}
451451

rollup/proposer-tool-config.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"l2_config": {
3+
"endpoint": "https://rpc.scroll.io",
4+
"chunk_proposer_config": {
5+
"max_block_num_per_chunk": 100,
6+
"max_tx_num_per_chunk": 100,
7+
"max_l2_gas_per_chunk": 20000000,
8+
"max_l1_commit_gas_per_chunk": 5000000,
9+
"max_l1_commit_calldata_size_per_chunk": 123740,
10+
"chunk_timeout_sec": 720000,
11+
"max_row_consumption_per_chunk": 1000000,
12+
"gas_cost_increase_multiplier": 1.2,
13+
"max_uncompressed_batch_bytes_size": 634693
14+
},
15+
"batch_proposer_config": {
16+
"max_l1_commit_gas_per_batch": 5000000,
17+
"max_l1_commit_calldata_size_per_batch": 123740,
18+
"batch_timeout_sec": 720000,
19+
"gas_cost_increase_multiplier": 1.2,
20+
"max_uncompressed_batch_bytes_size": 634693,
21+
"max_chunks_per_batch": 45
22+
},
23+
"bundle_proposer_config": {
24+
"max_batch_num_per_bundle": 45,
25+
"bundle_timeout_sec": 3600
26+
}
27+
},
28+
"db_config": {
29+
"driver_name": "postgres",
30+
"dsn": "postgres://postgres:postgres@db:5432/scroll?sslmode=disable",
31+
"maxOpenNum": 200,
32+
"maxIdleNum": 20
33+
},
34+
"db_config_for_replay": {
35+
"driver_name": "postgres",
36+
"dsn": "<mainnet read db config>",
37+
"maxOpenNum": 200,
38+
"maxIdleNum": 20
39+
}
40+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dsn": "postgres://postgres:postgres@db:5432/scroll?sslmode=disable",
3+
"driver_name": "postgres",
4+
"maxOpenNum": 200,
5+
"maxIdleNum": 20
6+
}

0 commit comments

Comments
 (0)