From f591a1fe44bced0f17edef9df43aaf13929e8508 Mon Sep 17 00:00:00 2001 From: litt <102969658+litt3@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:28:18 -0500 Subject: [PATCH] Add utility function to call verifyBlobV2 (#1107) Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com> --- api/clients/v2/verification/blob_verifier.go | 38 ++++++++++++++++++- .../EigenDABlobVerifier/conversion_utils.go | 4 +- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/api/clients/v2/verification/blob_verifier.go b/api/clients/v2/verification/blob_verifier.go index d6a11d350a..4dc8d4e06c 100644 --- a/api/clients/v2/verification/blob_verifier.go +++ b/api/clients/v2/verification/blob_verifier.go @@ -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" @@ -43,8 +44,6 @@ func NewBlobVerifier( // VerifyBlobV2FromSignedBatch calls the verifyBlobV2FromSignedBatch 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. func (v *BlobVerifier) VerifyBlobV2FromSignedBatch( ctx context.Context, // The signed batch that contains the blob being verified. This is obtained from the disperser, and is used @@ -74,3 +73,38 @@ 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. +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 +} diff --git a/contracts/bindings/EigenDABlobVerifier/conversion_utils.go b/contracts/bindings/EigenDABlobVerifier/conversion_utils.go index 9789387ffd..ff955af40f 100644 --- a/contracts/bindings/EigenDABlobVerifier/conversion_utils.go +++ b/contracts/bindings/EigenDABlobVerifier/conversion_utils.go @@ -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) } @@ -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()