Skip to content

Commit

Permalink
fix to create an ELC after building client state and consensus state
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jun 21, 2024
1 parent 7fe3bd5 commit 79d6a1d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions relay/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ func (pr *Prover) GetChainID() string {
// These states will be submitted to the counterparty chain as MsgCreateClient.
// If `height` is nil, the latest finalized height is selected automatically.
func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exported.ClientState, exported.ConsensusState, error) {
if res, err := pr.createELC(pr.config.ElcClientId, height); err != nil {
return nil, nil, fmt.Errorf("failed to create ELC: %w", err)
} else if res == nil {
pr.getLogger().Info("no need to create ELC", "elc_client_id", pr.config.ElcClientId)
}

ops, err := pr.GetOperators()
if err != nil {
return nil, nil, err
Expand All @@ -123,6 +117,7 @@ func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exporte
for _, op := range ops {
operators = append(operators, op.Bytes())
}

clientState := &lcptypes.ClientState{
LatestHeight: clienttypes.Height{},
Mrenclave: pr.config.GetMrenclave(),
Expand All @@ -135,6 +130,13 @@ func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exporte
OperatorsThresholdDenominator: pr.GetOperatorsThreshold().Denominator,
}
consensusState := &lcptypes.ConsensusState{}

if res, err := pr.createELC(pr.config.ElcClientId, height); err != nil {
return nil, nil, fmt.Errorf("failed to create ELC: %w", err)
} else if res == nil {
pr.getLogger().Info("no need to create ELC", "elc_client_id", pr.config.ElcClientId)
}

// NOTE after creates client, register an enclave key into the client state
return clientState, consensusState, nil
}
Expand Down

0 comments on commit 79d6a1d

Please sign in to comment.