Skip to content

Commit 82fb185

Browse files
committed
add batch start with l2 height flag to sync with l2
1 parent 8129a29 commit 82fb185

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

executor/executor.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,11 @@ func (ex *Executor) getStartHeights() (l1StartHeight uint64, l2StartHeight uint6
211211
if ex.cfg.L2StartHeight != 0 {
212212
l1StartHeight, l2StartHeight, err = ex.host.QueryHeightsOfOutputTxWithL2BlockNumber(uint64(ex.cfg.L2StartHeight))
213213
}
214-
return l1StartHeight, l2StartHeight, uint64(ex.cfg.BatchStartHeight), err
214+
215+
if ex.cfg.BatchStartWithL2Height {
216+
batchStartHeight = l2StartHeight
217+
} else {
218+
batchStartHeight = uint64(ex.cfg.BatchStartHeight)
219+
}
220+
return l1StartHeight, l2StartHeight, batchStartHeight, err
215221
}

executor/types/config.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ type Config struct {
5757
// L2 starts from the last submitted output l2 block number + 1 before L2StartHeight.
5858
// L1 starts from the block number of the output tx + 1
5959
L2StartHeight int64 `json:"l2_start_height"`
60+
// BatchStartWithL2Height is the flag to start the batch same with the l2 height.
61+
// If the latest height stored in the db is not 0, this config is ignored.
62+
// If it is true, the batch will start from the last submitted output l2 block number + 1.
63+
BatchStartWithL2Height bool `json:"batch_start_with_l2_height"`
6064
// StartBatchHeight is the height to start the batch. If it is 0, it will start from the latest height.
6165
// If the latest height stored in the db is not 0, this config is ignored.
6266
BatchStartHeight int64 `json:"batch_start_height"`
@@ -97,8 +101,9 @@ func DefaultConfig() *Config {
97101
MaxChunkSize: 300000, // 300KB
98102
MaxSubmissionTime: 60 * 60, // 1 hour
99103

100-
L2StartHeight: 0,
101-
BatchStartHeight: 0,
104+
L2StartHeight: 0,
105+
BatchStartWithL2Height: false,
106+
BatchStartHeight: 0,
102107
}
103108
}
104109

0 commit comments

Comments
 (0)