Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blob)!: tendermint compatible commitment proof json marshall #3929

Open
wants to merge 8 commits into
base: feature/api-breaks
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions blob/commitment_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"fmt"

tmjson "github.com/tendermint/tendermint/libs/json"

"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/pkg/proof"
"github.com/celestiaorg/go-square/v2/inclusion"
Expand Down Expand Up @@ -153,3 +155,19 @@ func (commitmentProof *CommitmentProof) Verify(root []byte, subtreeRootThreshold
// verify row roots to data root proof
return commitmentProof.RowProof.VerifyProof(root), nil
}

// MarshalJSON marshals an CommitmentProof to JSON. Uses tendermint encoder for row proof for compatibility.
func (commitmentProof *CommitmentProof) MarshalJSON() ([]byte, error) {
// alias the type to avoid going into recursion loop
// because tmjson.Marshal invokes custom json Marshaling
type Alias CommitmentProof
return tmjson.Marshal((*Alias)(commitmentProof))
}

// UnmarshalJSON unmarshals an CommitmentProof from JSON. Uses tendermint decoder for row proof for compatibility.
func (commitmentProof *CommitmentProof) UnmarshalJSON(data []byte) error {
// alias the type to avoid going into recursion loop
// because tmjson.Unmarshal invokes custom json Unmarshaling
type Alias CommitmentProof
return tmjson.Unmarshal(data, (*Alias)(commitmentProof))
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (eh *ExtendedHeader) UnmarshalBinary(data []byte) error {
// Uses tendermint encoder for tendermint compatibility.
func (eh *ExtendedHeader) MarshalJSON() ([]byte, error) {
// alias the type to avoid going into recursion loop
// because tmjson.Marshal invokes custom json marshalling
// because tmjson.Marshal invokes custom json marshaling
type Alias ExtendedHeader
return tmjson.Marshal((*Alias)(eh))
}
Expand All @@ -239,7 +239,7 @@ func (eh *ExtendedHeader) MarshalJSON() ([]byte, error) {
// Uses tendermint decoder for tendermint compatibility.
func (eh *ExtendedHeader) UnmarshalJSON(data []byte) error {
// alias the type to avoid going into recursion loop
// because tmjson.Unmarshal invokes custom json unmarshalling
// because tmjson.Unmarshal invokes custom json unmarshaling
type Alias ExtendedHeader
return tmjson.Unmarshal(data, (*Alias)(eh))
}
Expand Down
Loading