Skip to content

Commit

Permalink
query create bridge height when only it needs
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha committed Jan 13, 2025
1 parent 63463aa commit f2153fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 9 additions & 6 deletions challenger/challenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1
if c.cfg.DisableAutoSetL1Height {
l1StartHeight = c.cfg.L1StartHeight
} else {
// get the bridge start height from the host
l1StartHeight, err = c.host.QueryCreateBridgeHeight(ctx, bridgeId)
if err != nil {
return 0, 0, 0, err
}

if l2StartHeight > 1 {
l1Sequence, err := c.child.QueryNextL1Sequence(ctx, l2StartHeight-1)
if err != nil {
Expand All @@ -290,6 +284,15 @@ func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1
l1StartHeight = outputL1Height + 1
}
}

// if l1 start height is not set, get the bridge start height from the host
if l1StartHeight == 0 {
// get the bridge start height from the host
l1StartHeight, err = c.host.QueryCreateBridgeHeight(ctx, bridgeId)
if err != nil {
return 0, 0, 0, err
}
}
}
return
}
Expand Down
14 changes: 8 additions & 6 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,6 @@ func (ex *Executor) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1S
if ex.cfg.DisableAutoSetL1Height {
l1StartHeight = ex.cfg.L1StartHeight
} else {
// get the bridge start height from the host
l1StartHeight, err = ex.host.QueryCreateBridgeHeight(ctx, bridgeId)
if err != nil {
return 0, 0, 0, 0, errors.Wrap(err, "failed to query create bridge height")
}

childNextL1Sequence, err := ex.child.QueryNextL1Sequence(ctx, 0)
if err != nil {
return 0, 0, 0, 0, errors.Wrap(err, "failed to query next l1 sequence")
Expand All @@ -238,6 +232,14 @@ func (ex *Executor) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1S
if outputL1Height != 0 && outputL1Height+1 < l1StartHeight {
l1StartHeight = outputL1Height + 1
}

// if l1 start height is not set, get the bridge start height from the host
if l1StartHeight == 0 {
l1StartHeight, err = ex.host.QueryCreateBridgeHeight(ctx, bridgeId)
if err != nil {
return 0, 0, 0, 0, errors.Wrap(err, "failed to query create bridge height")
}
}
}
}

Expand Down

0 comments on commit f2153fb

Please sign in to comment.