99
1010	"github.com/prometheus/client_golang/prometheus" 
1111	"github.com/scroll-tech/da-codec/encoding" 
12- 	"github.com/scroll-tech/go-ethereum/ethclient" 
1312	"github.com/scroll-tech/go-ethereum/log" 
1413	"github.com/urfave/cli/v2" 
1514
@@ -19,9 +18,7 @@ import (
1918	"scroll-tech/common/version" 
2019
2120	"scroll-tech/rollup/internal/config" 
22- 	"scroll-tech/rollup/internal/controller/relayer" 
23- 	"scroll-tech/rollup/internal/controller/watcher" 
24- 	rutils "scroll-tech/rollup/internal/utils" 
21+ 	"scroll-tech/rollup/internal/controller/blob_uploader" 
2522)
2623
2724var  app  * cli.App 
@@ -67,36 +64,12 @@ func action(ctx *cli.Context) error {
6764	registry  :=  prometheus .DefaultRegisterer 
6865	observability .Server (ctx , db )
6966
70- 	// Init l2geth connection 
71- 	l2client , err  :=  ethclient .Dial (cfg .L2Config .Endpoint )
72- 	if  err  !=  nil  {
73- 		log .Crit ("failed to connect l2 geth" , "config file" , cfgFile , "error" , err )
74- 	}
75- 
76- 	genesisPath  :=  ctx .String (utils .Genesis .Name )
77- 	genesis , err  :=  utils .ReadGenesis (genesisPath )
78- 	if  err  !=  nil  {
79- 		log .Crit ("failed to read genesis" , "genesis file" , genesisPath , "error" , err )
80- 	}
81- 
8267	// sanity check config 
83- 	if  cfg .L2Config .RelayerConfig .BatchSubmission  ==  nil  {
84- 		log .Crit ("cfg.L2Config.RelayerConfig.BatchSubmission must not be nil" )
85- 	}
86- 	if  cfg .L2Config .RelayerConfig .BatchSubmission .MinBatches  <  1  {
87- 		log .Crit ("cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MinBatches must be at least 1" )
88- 	}
89- 	if  cfg .L2Config .RelayerConfig .BatchSubmission .MaxBatches  <  1  {
90- 		log .Crit ("cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MaxBatches must be at least 1" )
91- 	}
92- 	if  cfg .L2Config .BatchProposerConfig .MaxChunksPerBatch  <=  0  {
93- 		log .Crit ("cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch must be greater than 0" )
94- 	}
95- 	if  cfg .L2Config .ChunkProposerConfig .MaxL2GasPerChunk  <=  0  {
96- 		log .Crit ("cfg.L2Config.ChunkProposerConfig.MaxL2GasPerChunk must be greater than 0" )
68+ 	if  cfg .L2Config .BlobUploaderConfig  ==  nil  {
69+ 		log .Crit ("cfg.L2Config.BlobUploaderConfig must not be nil" )
9770	}
9871
99- 	l2relayer , err  :=  relayer . NewLayer2Relayer (ctx .Context , l2client ,  db , cfg .L2Config .RelayerConfig ,  genesis . Config ,  relayer . ServiceTypeL2RollupRelayer , registry )
72+ 	blobUploader , err  :=  blob_uploader . NewBlobUploader (ctx .Context , db , cfg .L2Config .BlobUploaderConfig , registry )
10073	if  err  !=  nil  {
10174		log .Crit ("failed to create l2 relayer" , "config file" , cfgFile , "error" , err )
10275	}
@@ -106,31 +79,7 @@ func action(ctx *cli.Context) error {
10679		log .Crit ("min codec version must be greater than or equal to CodecV7" , "minCodecVersion" , minCodecVersion )
10780	}
10881
109- 	chunkProposer  :=  watcher .NewChunkProposer (subCtx , cfg .L2Config .ChunkProposerConfig , minCodecVersion , genesis .Config , db , registry )
110- 	batchProposer  :=  watcher .NewBatchProposer (subCtx , cfg .L2Config .BatchProposerConfig , minCodecVersion , genesis .Config , db , registry )
111- 	bundleProposer  :=  watcher .NewBundleProposer (subCtx , cfg .L2Config .BundleProposerConfig , minCodecVersion , genesis .Config , db , registry )
112- 
113- 	l2watcher  :=  watcher .NewL2WatcherClient (subCtx , l2client , cfg .L2Config .Confirmations , cfg .L2Config .L2MessageQueueAddress , cfg .L2Config .WithdrawTrieRootSlot , genesis .Config , db , registry )
114- 
115- 	// Watcher loop to fetch missing blocks 
116- 	go  utils .LoopWithContext (subCtx , 2 * time .Second , func (ctx  context.Context ) {
117- 		number , loopErr  :=  rutils .GetLatestConfirmedBlockNumber (ctx , l2client , cfg .L2Config .Confirmations )
118- 		if  loopErr  !=  nil  {
119- 			log .Error ("failed to get block number" , "err" , loopErr )
120- 			return 
121- 		}
122- 		l2watcher .TryFetchRunningMissingBlocks (number )
123- 	})
124- 
125- 	go  utils .Loop (subCtx , time .Duration (cfg .L2Config .ChunkProposerConfig .ProposeIntervalMilliseconds )* time .Millisecond , chunkProposer .TryProposeChunk )
126- 
127- 	go  utils .Loop (subCtx , time .Duration (cfg .L2Config .BatchProposerConfig .ProposeIntervalMilliseconds )* time .Millisecond , batchProposer .TryProposeBatch )
128- 
129- 	go  utils .Loop (subCtx , 10 * time .Second , bundleProposer .TryProposeBundle )
130- 
131- 	go  utils .Loop (subCtx , 2 * time .Second , l2relayer .ProcessPendingBatches )
132- 
133- 	go  utils .Loop (subCtx , 15 * time .Second , l2relayer .ProcessPendingBundles )
82+ 	go  utils .Loop (subCtx , 2 * time .Second , blobUploader .UploadBlobToS3 )
13483
13584	// Finish start all blob-uploader functions. 
13685	log .Info ("Start blob-uploader successfully" , "version" , version .Version )
@@ -145,7 +94,7 @@ func action(ctx *cli.Context) error {
14594	return  nil 
14695}
14796
148- // Run rollup relayer  cmd instance. 
97+ // Run blob uploader  cmd instance. 
14998func  Run () {
15099	if  err  :=  app .Run (os .Args ); err  !=  nil  {
151100		_ , _  =  fmt .Fprintln (os .Stderr , err )
0 commit comments