Skip to content

Commit

Permalink
Merge pull request #35 from EspressoSystems/api-update
Browse files Browse the repository at this point in the history
Implement FetchBlockMerkleProof
  • Loading branch information
ImJeremyHe authored Apr 18, 2024
2 parents 2f01957 + cdd7305 commit cd65b1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 7 additions & 7 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func (c *Client) FetchRemainingHeadersForWindow(ctx context.Context, from uint64
return res, nil
}

// TODO: This is a stub for now until we have merkle proof snapshots implemented in the query service
func (c *Client) FetchBlockMerkleProof(l1Height uint64, hotshotHeight uint64) (types.HotShotBlockMerkleProof, error) {
mockProof := `{"proof":[]}`
return types.HotShotBlockMerkleProof{
Proof: json.RawMessage(mockProof),
L1Height: l1Height,
}, nil
// Fetches a block merkle proof at the snapshot rootHeight for the leaf at the provided HotShot height
func (c *Client) FetchBlockMerkleProof(ctx context.Context, rootHeight uint64, hotshotHeight uint64) (types.HotShotBlockMerkleProof, error) {
var res types.HotShotBlockMerkleProof
if err := c.get(ctx, &res, "state/blocks/%d+1/%d", rootHeight, hotshotHeight); err != nil {
return types.HotShotBlockMerkleProof{}, err
}
return res, nil
}

func (c *Client) FetchTransactionsInBlock(ctx context.Context, blockHeight uint64, namespace uint64) (TransactionsInBlock, error) {
Expand Down
5 changes: 1 addition & 4 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ type NamespaceProof = json.RawMessage

type BlockMerkleRoot = Commitment

type HotShotBlockMerkleProof struct {
Proof json.RawMessage
L1Height uint64
}
type HotShotBlockMerkleProof json.RawMessage

// Validates a block merkle proof, returning the validated HotShot block height. This is mocked until we have real
// merkle tree snapshot support.
Expand Down

0 comments on commit cd65b1e

Please sign in to comment.