From f2153fb93f19816a339878901441046d7d7d07f6 Mon Sep 17 00:00:00 2001 From: sh-cha Date: Mon, 13 Jan 2025 13:52:58 +0900 Subject: [PATCH] query create bridge height when only it needs --- challenger/challenger.go | 15 +++++++++------ executor/executor.go | 14 ++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/challenger/challenger.go b/challenger/challenger.go index c03999c..a6d7c26 100644 --- a/challenger/challenger.go +++ b/challenger/challenger.go @@ -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 { @@ -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 } diff --git a/executor/executor.go b/executor/executor.go index 98de697..ecec8e7 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -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") @@ -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") + } + } } }