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

Add utility function to call verifyBlobV2 #1107

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
38 changes: 38 additions & 0 deletions api/clients/v2/verification/blob_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

commonv2 "github.com/Layr-Labs/eigenda/api/grpc/common/v2"
"github.com/Layr-Labs/eigenda/common"

disperser "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
Expand Down Expand Up @@ -74,3 +75,40 @@ func (v *BlobVerifier) VerifyBlobV2FromSignedBatch(

return nil
}

// VerifyBlobV2 calls the VerifyBlobV2 view function on the EigenDABlobVerifier contract
//
// This method returns nil if the blob is successfully verified. Otherwise, it returns an error.
//
// It is the responsibility of the caller to configure a timeout on the ctx, if a timeout is required.
litt3 marked this conversation as resolved.
Show resolved Hide resolved
func (v *BlobVerifier) VerifyBlobV2(
ctx context.Context,
// The header of the batch that the blob is contained in
batchHeader *commonv2.BatchHeader,
// Contains data pertaining to the blob's inclusion in the batch
blobVerificationProof *disperser.BlobVerificationInfo,
// Contains data that can be used to verify that the blob actually exists in the claimed batch
nonSignerStakesAndSignature verifierBindings.NonSignerStakesAndSignature,
) error {
convertedBatchHeader, err := verifierBindings.ConvertBatchHeader(batchHeader)
if err != nil {
return fmt.Errorf("convert batch header: %s", err)
}

convertedBlobVerificationProof, err := verifierBindings.ConvertVerificationProof(blobVerificationProof)
if err != nil {
return fmt.Errorf("convert blob verification proof: %s", err)
}

err = v.blobVerifierCaller.VerifyBlobV2(
&bind.CallOpts{Context: ctx},
*convertedBatchHeader,
*convertedBlobVerificationProof,
nonSignerStakesAndSignature)

if err != nil {
return fmt.Errorf("verify blob v2: %s", err)
}

return nil
}
4 changes: 2 additions & 2 deletions contracts/bindings/EigenDABlobVerifier/conversion_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func ConvertSignedBatch(inputBatch *disperserv2.SignedBatch) (*SignedBatch, error) {
convertedBatchHeader, err := convertBatchHeader(inputBatch.GetHeader())
convertedBatchHeader, err := ConvertBatchHeader(inputBatch.GetHeader())
if err != nil {
return nil, fmt.Errorf("convert batch header: %s", err)
}
Expand All @@ -31,7 +31,7 @@ func ConvertSignedBatch(inputBatch *disperserv2.SignedBatch) (*SignedBatch, erro
return outputSignedBatch, nil
}

func convertBatchHeader(inputHeader *commonv2.BatchHeader) (*BatchHeaderV2, error) {
func ConvertBatchHeader(inputHeader *commonv2.BatchHeader) (*BatchHeaderV2, error) {
var outputBatchRoot [32]byte

inputBatchRoot := inputHeader.GetBatchRoot()
Expand Down
Loading