From 15da7f12be9328af1d5b37e3396659c14716e81f Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Sat, 9 Nov 2024 00:07:44 +0900 Subject: [PATCH] fix to avoid referring to counterparty chain in `update-elc` command Signed-off-by: Jun Kimura --- relay/cmd.go | 7 ++----- relay/lcp.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/relay/cmd.go b/relay/cmd.go index dc31b09..d446089 100644 --- a/relay/cmd.go +++ b/relay/cmd.go @@ -192,15 +192,12 @@ func updateELCCmd(ctx *config.Context) *cobra.Command { return err } var ( - target *core.ProvableChain - counterparty *core.ProvableChain + target *core.ProvableChain ) if viper.GetBool(flagSrc) { target = c[src] - counterparty = c[dst] } else { target = c[dst] - counterparty = c[src] } prover := target.Prover.(*Prover) var elcClientID string @@ -209,7 +206,7 @@ func updateELCCmd(ctx *config.Context) *cobra.Command { } else { elcClientID = prover.config.ElcClientId } - out, err := prover.doUpdateELC(elcClientID, counterparty) + out, err := prover.doUpdateELC(elcClientID) if err != nil { return err } diff --git a/relay/lcp.go b/relay/lcp.go index 3c9dcca..5c248c9 100644 --- a/relay/lcp.go +++ b/relay/lcp.go @@ -555,9 +555,14 @@ type UpdateELCResult struct { Messages []*lcptypes.UpdateStateProxyMessage `json:"messages"` } -func (pr *Prover) doUpdateELC(elcClientID string, counterparty core.FinalityAwareChain) (*UpdateELCResult, error) { - if err := pr.UpdateEKIfNeeded(context.TODO(), counterparty); err != nil { - return nil, err +func (pr *Prover) doUpdateELC(elcClientID string) (*UpdateELCResult, error) { + if pr.activeEnclaveKey == nil { + eki, err := pr.selectNewEnclaveKey(context.TODO()) + if err != nil { + return nil, err + } + pr.getLogger().Info("use a new enclave key", "enclave_key", hex.EncodeToString(eki.EnclaveKeyAddress)) + pr.activeEnclaveKey = eki } pr.getLogger().Info("try to update the ELC client", "elc_client_id", elcClientID) updates, err := pr.updateELC(elcClientID, false)