Skip to content

Commit

Permalink
Merge pull request #35 from datachainlab/fix-update-elc
Browse files Browse the repository at this point in the history
Fix to avoid referring to counterparty chain in `update-elc` command

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Nov 8, 2024
2 parents 9708e00 + 15da7f1 commit 00d5747
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 00d5747

Please sign in to comment.