@@ -214,46 +214,52 @@ func (ex *Executor) makeDANode(ctx context.Context, bridgeInfo opchildtypes.Brid
214
214
}
215
215
216
216
func (ex * Executor ) getProcessedHeights (ctx context.Context , bridgeId uint64 ) (l1ProcessedHeight int64 , l2ProcessedHeight int64 , processedOutputIndex uint64 , batchProcessedHeight int64 , err error ) {
217
- // get the bridge start height from the host
218
- l1ProcessedHeight , err = ex .host .QueryCreateBridgeHeight (ctx , bridgeId )
219
- if err != nil {
220
- return 0 , 0 , 0 , 0 , err
217
+ var outputL1BlockNumber int64
218
+ // get the last submitted output height before the start height from the host
219
+ if ex .cfg .L2StartHeight != 0 {
220
+ output , err := ex .host .QueryOutputByL2BlockNumber (ctx , bridgeId , ex .cfg .L2StartHeight )
221
+ if err != nil {
222
+ return 0 , 0 , 0 , 0 , err
223
+ } else if output != nil {
224
+ outputL1BlockNumber = types .MustUint64ToInt64 (output .OutputProposal .L1BlockNumber )
225
+ l2ProcessedHeight = types .MustUint64ToInt64 (output .OutputProposal .L2BlockNumber )
226
+ processedOutputIndex = output .OutputIndex
227
+ }
221
228
}
222
229
223
- l1Sequence , err := ex .child .QueryNextL1Sequence (ctx , 0 )
224
- if err != nil {
225
- return 0 , 0 , 0 , 0 , err
226
- }
230
+ if ex .cfg .L1StartHeight == 0 {
231
+ // get the bridge start height from the host
232
+ l1ProcessedHeight , err = ex .host .QueryCreateBridgeHeight (ctx , bridgeId )
233
+ if err != nil {
234
+ return 0 , 0 , 0 , 0 , err
235
+ }
227
236
228
- // query l1Sequence tx height
229
- depositTxHeight , err := ex .host .QueryDepositTxHeight (ctx , bridgeId , l1Sequence )
230
- if err != nil {
231
- return 0 , 0 , 0 , 0 , err
232
- } else if depositTxHeight == 0 && l1Sequence > 1 {
233
- // query l1Sequence - 1 tx height
234
- depositTxHeight , err = ex .host .QueryDepositTxHeight (ctx , bridgeId , l1Sequence - 1 )
237
+ l1Sequence , err := ex .child .QueryNextL1Sequence (ctx , 0 )
235
238
if err != nil {
236
239
return 0 , 0 , 0 , 0 , err
237
240
}
238
- }
239
- if depositTxHeight >= 1 && depositTxHeight - 1 > l1ProcessedHeight {
240
- l1ProcessedHeight = depositTxHeight - 1
241
- }
242
241
243
- // get the last submitted output height before the start height from the host
244
- if ex .cfg .L2StartHeight != 0 {
245
- output , err := ex .host .QueryOutputByL2BlockNumber (ctx , bridgeId , ex .cfg .L2StartHeight )
242
+ // query l1Sequence tx height
243
+ depositTxHeight , err := ex .host .QueryDepositTxHeight (ctx , bridgeId , l1Sequence )
246
244
if err != nil {
247
245
return 0 , 0 , 0 , 0 , err
248
- } else if output != nil {
249
- l1BlockNumber := types .MustUint64ToInt64 (output .OutputProposal .L1BlockNumber )
250
- if l1BlockNumber < l1ProcessedHeight {
251
- l1ProcessedHeight = l1BlockNumber
246
+ } else if depositTxHeight == 0 && l1Sequence > 1 {
247
+ // query l1Sequence - 1 tx height
248
+ depositTxHeight , err = ex .host .QueryDepositTxHeight (ctx , bridgeId , l1Sequence - 1 )
249
+ if err != nil {
250
+ return 0 , 0 , 0 , 0 , err
252
251
}
253
- l2ProcessedHeight = types .MustUint64ToInt64 (output .OutputProposal .L2BlockNumber )
254
- processedOutputIndex = output .OutputIndex
255
252
}
253
+ if depositTxHeight > l1ProcessedHeight {
254
+ l1ProcessedHeight = depositTxHeight
255
+ }
256
+ if outputL1BlockNumber < l1ProcessedHeight {
257
+ l1ProcessedHeight = outputL1BlockNumber
258
+ }
259
+ } else {
260
+ l1ProcessedHeight = ex .cfg .L1StartHeight
256
261
}
262
+ l1ProcessedHeight --
257
263
258
264
if ex .cfg .BatchStartHeight > 0 {
259
265
batchProcessedHeight = ex .cfg .BatchStartHeight - 1
0 commit comments