Skip to content

Commit

Permalink
fix to set HostConsensusStateProof in ConnectionOpenAck
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jan 17, 2024
1 parent 8cd3208 commit 4557b3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func createConnectionStep(src, dst *ProvableChain) (*RelayMsgs, error) {
if len(srcUpdateHeaders) > 0 {
out.Dst = append(out.Dst, dst.Path().UpdateClients(srcUpdateHeaders, addr)...)
}
out.Dst = append(out.Dst, dst.Path().ConnAck(src.Path(), srcCsRes, srcConn, srcConsRes, addr))
out.Dst = append(out.Dst, dst.Path().ConnAck(src.Path(), srcCsRes, srcConn, srcConsRes, dstHostConsProof, addr))

// Handshake has started on dst end (2 steps done), relay `connOpenAck` and `updateClient` to src end
case srcConn.Connection.State == conntypes.INIT && dstConn.Connection.State == conntypes.TRYOPEN:
Expand All @@ -202,7 +202,7 @@ func createConnectionStep(src, dst *ProvableChain) (*RelayMsgs, error) {
if len(dstUpdateHeaders) > 0 {
out.Src = append(out.Src, src.Path().UpdateClients(dstUpdateHeaders, addr)...)
}
out.Src = append(out.Src, src.Path().ConnAck(dst.Path(), dstCsRes, dstConn, dstConsRes, addr))
out.Src = append(out.Src, src.Path().ConnAck(dst.Path(), dstCsRes, dstConn, dstConsRes, srcHostConsProof, addr))

// Handshake has confirmed on dst (3 steps done), relay `connOpenConfirm` and `updateClient` to src end
case srcConn.Connection.State == conntypes.TRYOPEN && dstConn.Connection.State == conntypes.OPEN:
Expand Down
8 changes: 7 additions & 1 deletion core/pathEnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ func (pe *PathEnd) ConnAck(
dstClientState *clienttypes.QueryClientStateResponse,
dstConnState *conntypes.QueryConnectionResponse,
dstConsState *clienttypes.QueryConsensusStateResponse,
hostConsensusStateProof []byte,
signer sdk.AccAddress,
) sdk.Msg {
cs, err := clienttypes.UnpackClientState(dstClientState.ClientState)
if err != nil {
panic(err)
}
return conntypes.NewMsgConnectionOpenAck(
msg := conntypes.NewMsgConnectionOpenAck(
pe.ConnectionID,
dst.ConnectionID,
cs,
Expand All @@ -146,6 +147,11 @@ func (pe *PathEnd) ConnAck(
conntypes.ExportedVersionsToProto(conntypes.GetCompatibleVersions())[0],
signer.String(),
)
msg.HostConsensusStateProof = hostConsensusStateProof
if err = msg.ValidateBasic(); err != nil {
panic(err)
}
return msg
}

// ConnConfirm creates a MsgConnectionOpenAck
Expand Down

0 comments on commit 4557b3e

Please sign in to comment.