From eaf752444d2d1ec2dbd0dc85089686bc0c885f2c Mon Sep 17 00:00:00 2001 From: viveksharmapoudel Date: Thu, 6 Jul 2023 15:22:13 +0545 Subject: [PATCH] fix: issue in types --- relayer/chains/icon/provider_test.go | 6 ++---- relayer/chains/icon/types/types.go | 14 +++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/relayer/chains/icon/provider_test.go b/relayer/chains/icon/provider_test.go index 2a6dd0957..a9b12b65c 100644 --- a/relayer/chains/icon/provider_test.go +++ b/relayer/chains/icon/provider_test.go @@ -434,7 +434,7 @@ func TestUpdateClientHeader(t *testing.T) { p := GetMockIconProvider(2, "dddd") - height := int64(201) + height := int64(401) header, _ := p.GetBtpHeader(height) proofContext, _ := p.GetProofContextByHeight(height - 1) @@ -458,15 +458,13 @@ func TestUpdateClientHeader(t *testing.T) { // NextProofContext: signedHeader.Header.NextProofContext, } networkSection := types.NewNetworkSection(&btpLocalHeader) - fmt.Printf("newtworkSection :%x \n", networkSection.Encode()) + fmt.Printf("newtworkSection :%x \n", networkSection.Hash()) decision := types.NewNetworkTypeSectionDecision(getSrcNetworkId(3), 1, height, btpLocalHeader.Round, types.NetworkTypeSection{ NextProofContextHash: btpLocalHeader.NextProofContextHash, NetworkSectionsRoot: GetNetworkSectionRoot(&btpLocalHeader), }) - fmt.Println("decision value: ") - isValid, err := VerifyBtpProof(decision, signedHeader.Signatures, proofContext) assert.NoError(t, err) diff --git a/relayer/chains/icon/types/types.go b/relayer/chains/icon/types/types.go index 5c2aff985..a2fff12fd 100644 --- a/relayer/chains/icon/types/types.go +++ b/relayer/chains/icon/types/types.go @@ -567,14 +567,14 @@ type NetworkSection struct { func NewNetworkSection( header *BTPBlockHeader, ) *NetworkSection { - messageSn := (header.UpdateNumber - header.MessageCount) << 1 - if header.NextProofContext != nil { - messageSn |= 1 - } + // messageSn := (header.UpdateNumber + header.MessageCount) << 1 + // if header.NextProofContext != nil { + // messageSn |= 1 + // } return &NetworkSection{ Nid: int64(header.NetworkID), - MessageSn: uint64(messageSn), + MessageSn: uint64(header.UpdateNumber), Prev: header.PrevNetworkSectionHash, MessageCount: int64(header.MessageCount), MessageRoot: header.MessageRoot, @@ -622,7 +622,7 @@ func (h *NetworkTypeSectionDecision) Encode() []byte { } func (h *NetworkTypeSectionDecision) Hash() []byte { - return relayer_common.Sha3keccak256(codec.RLP.MustMarshalToBytes(h)) + return relayer_common.Sha3keccak256(h.Encode()) } func (h *NetworkTypeSection) Encode() []byte { @@ -630,5 +630,5 @@ func (h *NetworkTypeSection) Encode() []byte { } func (h *NetworkTypeSection) Hash() []byte { - return (codec.RLP.MustMarshalToBytes(h)) + return relayer_common.Sha3keccak256(h.Encode()) }