From 8dbcb1a9050aa32294c3f4e5d0d3c1481f708a91 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 21 Sep 2023 16:21:01 +0200 Subject: [PATCH] fix: update nmt and fix blob proof serialization --- go.mod | 2 +- types/blob/blob.go | 36 ------------------------------------ 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/go.mod b/go.mod index 89ccf3f..7fc34ea 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/math v1.1.2 github.com/celestiaorg/go-fraud v0.2.0 github.com/celestiaorg/go-header v0.3.1 - github.com/celestiaorg/nmt v0.19.0 + github.com/celestiaorg/nmt v0.20.0 github.com/celestiaorg/rsmt2d v0.11.0 github.com/cometbft/cometbft v0.37.2 github.com/filecoin-project/go-jsonrpc v0.3.1 diff --git a/types/blob/blob.go b/types/blob/blob.go index 101ecd6..b81406e 100644 --- a/types/blob/blob.go +++ b/types/blob/blob.go @@ -43,42 +43,6 @@ type Proof []*nmt.Proof func (p Proof) Len() int { return len(p) } -type jsonProof struct { - Start int `json:"start"` - End int `json:"end"` - Nodes [][]byte `json:"nodes"` -} - -func (p *Proof) MarshalJSON() ([]byte, error) { - proofs := make([]jsonProof, 0, p.Len()) - for _, pp := range *p { - proofs = append(proofs, jsonProof{ - Start: pp.Start(), - End: pp.End(), - Nodes: pp.Nodes(), - }) - } - - return json.Marshal(proofs) -} - -func (p *Proof) UnmarshalJSON(data []byte) error { - var proofs []jsonProof - err := json.Unmarshal(data, &proofs) - if err != nil { - return err - } - - nmtProofs := make([]*nmt.Proof, len(proofs)) - for i, jProof := range proofs { - nmtProof := nmt.NewInclusionProof(jProof.Start, jProof.End, jProof.Nodes, NMTIgnoreMaxNamespace) - nmtProofs[i] = &nmtProof - } - - *p = nmtProofs - return nil -} - type jsonBlob struct { Namespace share.Namespace `json:"namespace"` Data []byte `json:"data"`