Skip to content

Commit

Permalink
fix to avoid referring to counterparty chain in update-elc command
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Nov 8, 2024
1 parent 9708e00 commit 15da7f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 2 additions & 5 deletions relay/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
11 changes: 8 additions & 3 deletions relay/lcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 15da7f1

Please sign in to comment.