Skip to content

Commit

Permalink
fix(blob | nodebuilder/da): Revert custom marshaling for blob.Proof (
Browse files Browse the repository at this point in the history
…#3204)

Reverts a change introduced in
#3146 that
unintentionally broke `blob.Proof` serialisation.

Resolves #3173
  • Loading branch information
renaynay authored Mar 5, 2024
1 parent f843183 commit 32bc7a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
27 changes: 0 additions & 27 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,6 @@ type Proof []*nmt.Proof

func (p Proof) Len() int { return len(p) }

func (p Proof) MarshalJSON() ([]byte, error) {
proofs := make([]string, 0, len(p))
for _, proof := range p {
proofBytes, err := proof.MarshalJSON()
if err != nil {
return nil, err
}
proofs = append(proofs, string(proofBytes))
}
return json.Marshal(proofs)
}

func (p *Proof) UnmarshalJSON(b []byte) error {
var proofs []string
if err := json.Unmarshal(b, &proofs); err != nil {
return err
}
for _, proof := range proofs {
var nmtProof nmt.Proof
if err := nmtProof.UnmarshalJSON([]byte(proof)); err != nil {
return err
}
*p = append(*p, &nmtProof)
}
return nil
}

// equal is a temporary method that compares two proofs.
// should be removed in BlobService V1.
func (p Proof) equal(input Proof) error {
Expand Down
5 changes: 3 additions & 2 deletions nodebuilder/da/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package da
import (
"context"
"encoding/binary"
"encoding/json"
"fmt"
"strings"

Expand Down Expand Up @@ -83,7 +84,7 @@ func (s *Service) GetProofs(ctx context.Context, ids []da.ID, namespace da.Names
if err != nil {
return nil, err
}
proofs[i], err = proof.MarshalJSON()
proofs[i], err = json.Marshal(proof)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -153,7 +154,7 @@ func (s *Service) Validate(
proofs := make([]*blob.Proof, len(ids))
for i, daProof := range daProofs {
blobProof := &blob.Proof{}
err := blobProof.UnmarshalJSON(daProof)
err := json.Unmarshal(daProof, blobProof)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 32bc7a9

Please sign in to comment.