@@ -10,6 +10,7 @@ import (
1010 "strings"
1111
1212 "github.com/scroll-tech/da-codec/encoding"
13+ "github.com/scroll-tech/go-ethereum/common"
1314 "github.com/scroll-tech/go-ethereum/log"
1415 "github.com/urfave/cli/v2"
1516
@@ -40,12 +41,6 @@ var seedFlag = cli.Int64Flag{
4041 Value : 0 ,
4142}
4243
43- var codecFlag = cli.IntFlag {
44- Name : "codec" ,
45- Usage : "codec version, valid from 6, default(auto) is 0" ,
46- Value : 0 ,
47- }
48-
4944func parseThreeIntegers (value string ) (int , int , int , error ) {
5045 // Split the input string by comma
5146 parts := strings .Split (value , "," )
@@ -84,10 +79,21 @@ func parseThreeIntegers(value string) (int, int, int, error) {
8479 return values [0 ], values [1 ], values [2 ], nil
8580}
8681
82+ type fetchConfig struct {
83+ // node url.
84+ Endpoint string `json:"endpoint"`
85+ // The L2MessageQueue contract address deployed on layer 2 chain.
86+ L2MessageQueueAddress common.Address `json:"l2_message_queue_address"`
87+ // The WithdrawTrieRootSlot in L2MessageQueue contract.
88+ WithdrawTrieRootSlot common.Hash `json:"withdraw_trie_root_slot,omitempty"`
89+ }
90+
8791// load a comptabile type of config for rollup
8892type config struct {
8993 DBConfig * database.Config `json:"db_config"`
94+ FetchConfig * fetchConfig `json:"fetch_config,omitempty"`
9095 ValidiumMode bool `json:"validium_mode"`
96+ CodecVersion int `json:"codec_version"`
9197}
9298
9399func init () {
@@ -97,7 +103,7 @@ func init() {
97103 app .Name = "integration-test-tool"
98104 app .Usage = "The Scroll L2 Integration Test Tool"
99105 app .Version = version .Version
100- app .Flags = append (app .Flags , & codecFlag , & seedFlag , & outputNumFlag , & outputPathFlag )
106+ app .Flags = append (app .Flags , & seedFlag , & outputNumFlag , & outputPathFlag )
101107 app .Flags = append (app .Flags , utils .CommonFlags ... )
102108 app .Before = func (ctx * cli.Context ) error {
103109 if err := utils .LogSetup (ctx ); err != nil {
@@ -135,9 +141,8 @@ func action(ctx *cli.Context) error {
135141 return fmt .Errorf ("specify begin and end block number" )
136142 }
137143
138- codecFl := ctx .Int (codecFlag .Name )
139- if codecFl != 0 {
140- switch codecFl {
144+ if cfg .CodecVersion != 0 {
145+ switch cfg .CodecVersion {
141146 case 6 :
142147 codecCfg = encoding .CodecV6
143148 case 7 :
@@ -147,7 +152,7 @@ func action(ctx *cli.Context) error {
147152 case 9 :
148153 codecCfg = encoding .CodecV9
149154 default :
150- return fmt .Errorf ("invalid codec version %d" , codecFl )
155+ return fmt .Errorf ("invalid codec version %d" , cfg . CodecVersion )
151156 }
152157 log .Info ("set codec" , "version" , codecCfg )
153158 }
@@ -161,6 +166,14 @@ func action(ctx *cli.Context) error {
161166 return fmt .Errorf ("invalid begin block number: %w" , err )
162167 }
163168
169+ var import_blocks []* encoding.Block
170+ if cfg .FetchConfig != nil {
171+ import_blocks , err = fetchAndStoreBlocks (ctx .Context , beginBlk , endBlk )
172+ if err != nil {
173+ return err
174+ }
175+ }
176+
164177 chkNum , batchNum , bundleNum , err := parseThreeIntegers (ctx .String (outputNumFlag .Name ))
165178 if err != nil {
166179 return err
@@ -174,7 +187,7 @@ func action(ctx *cli.Context) error {
174187
175188 outputPath := ctx .String (outputPathFlag .Name )
176189 log .Info ("output" , "Seed" , seed , "file" , outputPath )
177- ret , err := importData (ctx .Context , beginBlk , endBlk , chkNum , batchNum , bundleNum , seed )
190+ ret , err := importData (ctx .Context , beginBlk , endBlk , import_blocks , chkNum , batchNum , bundleNum , seed )
178191 if err != nil {
179192 return err
180193 }
0 commit comments