Skip to content

Commit 32bc7a9

Browse files
authored
fix(blob | nodebuilder/da): Revert custom marshaling for blob.Proof (#3204)
Reverts a change introduced in #3146 that unintentionally broke `blob.Proof` serialisation. Resolves #3173
1 parent f843183 commit 32bc7a9

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

blob/blob.go

-27
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,6 @@ type Proof []*nmt.Proof
3939

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

42-
func (p Proof) MarshalJSON() ([]byte, error) {
43-
proofs := make([]string, 0, len(p))
44-
for _, proof := range p {
45-
proofBytes, err := proof.MarshalJSON()
46-
if err != nil {
47-
return nil, err
48-
}
49-
proofs = append(proofs, string(proofBytes))
50-
}
51-
return json.Marshal(proofs)
52-
}
53-
54-
func (p *Proof) UnmarshalJSON(b []byte) error {
55-
var proofs []string
56-
if err := json.Unmarshal(b, &proofs); err != nil {
57-
return err
58-
}
59-
for _, proof := range proofs {
60-
var nmtProof nmt.Proof
61-
if err := nmtProof.UnmarshalJSON([]byte(proof)); err != nil {
62-
return err
63-
}
64-
*p = append(*p, &nmtProof)
65-
}
66-
return nil
67-
}
68-
6942
// equal is a temporary method that compares two proofs.
7043
// should be removed in BlobService V1.
7144
func (p Proof) equal(input Proof) error {

nodebuilder/da/service.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package da
33
import (
44
"context"
55
"encoding/binary"
6+
"encoding/json"
67
"fmt"
78
"strings"
89

@@ -83,7 +84,7 @@ func (s *Service) GetProofs(ctx context.Context, ids []da.ID, namespace da.Names
8384
if err != nil {
8485
return nil, err
8586
}
86-
proofs[i], err = proof.MarshalJSON()
87+
proofs[i], err = json.Marshal(proof)
8788
if err != nil {
8889
return nil, err
8990
}
@@ -153,7 +154,7 @@ func (s *Service) Validate(
153154
proofs := make([]*blob.Proof, len(ids))
154155
for i, daProof := range daProofs {
155156
blobProof := &blob.Proof{}
156-
err := blobProof.UnmarshalJSON(daProof)
157+
err := json.Unmarshal(daProof, blobProof)
157158
if err != nil {
158159
return nil, err
159160
}

0 commit comments

Comments
 (0)