Skip to content

Commit

Permalink
Implement cert verifier address provider (#1368)
Browse files Browse the repository at this point in the history
Signed-off-by: litt3 <[email protected]>
  • Loading branch information
litt3 authored Mar 7, 2025
1 parent 1a23064 commit 8f43a4a
Show file tree
Hide file tree
Showing 28 changed files with 659 additions and 629 deletions.
28 changes: 28 additions & 0 deletions api/clients/v2/cert_verifier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package clients

import (
"context"

"github.com/Layr-Labs/eigenda/api/clients/v2/coretypes"
disperser "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
verifierBindings "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifier"
)

// ICertVerifier is an interface for interacting with the EigenDACertVerifier contract.
type ICertVerifier interface {
// VerifyCertV2 calls the VerifyCertV2 view function on the EigenDACertVerifier contract.
//
// This method returns nil if the cert is successfully verified. Otherwise, it returns an error.
VerifyCertV2(ctx context.Context, eigenDACert *coretypes.EigenDACert) error

// GetNonSignerStakesAndSignature calls the getNonSignerStakesAndSignature view function on the EigenDACertVerifier
// contract, and returns the resulting NonSignerStakesAndSignature object.
GetNonSignerStakesAndSignature(
ctx context.Context,
signedBatch *disperser.SignedBatch,
) (*verifierBindings.NonSignerStakesAndSignature, error)

// GetQuorumNumbersRequired queries the cert verifier contract for the configured set of quorum numbers that must
// be set in the BlobHeader, and verified in VerifyDACertV2 and verifyDACertV2FromSignedBatch
GetQuorumNumbersRequired(ctx context.Context) ([]uint8, error)
}
18 changes: 18 additions & 0 deletions api/clients/v2/cert_verifier_address_provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package clients

import (
"context"

"github.com/ethereum/go-ethereum/common"
)

// CertVerifierAddressProvider defines an object which can translate block number to cert verifier address
//
// This provider uses reference block number as a key, since updates to a cert verifier address in a running system are
// coordinated by defining the reference block number at which a new cert verifier address takes effect. Specifically,
// a blob shall be verified by the latest defined cert verifier contract with a reference block number key that doesn't
// exceed the reference block number of the blob's batch.
type CertVerifierAddressProvider interface {
// GetCertVerifierAddress returns the EigenDACertVerifierAddress that is active at the input reference block number
GetCertVerifierAddress(ctx context.Context, referenceBlockNumber uint64) (common.Address, error)
}
166 changes: 0 additions & 166 deletions api/clients/v2/config.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package verification
package coretypes

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package verification
package coretypes

import (
"math/big"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package verification
package coretypes

import (
"fmt"
Expand Down
52 changes: 26 additions & 26 deletions api/clients/v2/mock/cert_verifier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions api/clients/v2/payload_client_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package clients

import (
"github.com/Layr-Labs/eigenda/api/clients/codecs"
v2 "github.com/Layr-Labs/eigenda/core/v2"
)

// PayloadClientConfig contains configuration values that are needed by both PayloadRetriever and PayloadDisperser
type PayloadClientConfig struct {
// PayloadPolynomialForm is the initial form of a Payload after being encoded. The configured form does not imply
// any restrictions on the contents of a payload: it merely dictates how payload data is treated after being
// encoded.
//
// Since blobs sent to the disperser must be in coefficient form, the initial form of the encoded payload dictates
// what data processing must be performed during blob construction.
//
// The chosen form also dictates how the KZG commitment made to the blob can be used. If the encoded payload starts
// in PolynomialFormEval (meaning the data WILL be IFFTed before computing the commitment) then it will be possible
// to open points on the KZG commitment to prove that the field elements correspond to the commitment. If the
// encoded payload starts in PolynomialFormCoeff (meaning the data will NOT be IFFTed before computing the
// commitment) then it will not be possible to create a commitment opening: the blob will need to be supplied in its
// entirety to perform a verification that any part of the data matches the KZG commitment.
PayloadPolynomialForm codecs.PolynomialForm

// The BlobVersion to use when creating new blobs, or interpreting blob bytes.
//
// BlobVersion needs to point to a version defined in the threshold registry contract.
// https://github.com/Layr-Labs/eigenda/blob/3ed9ef6ed3eb72c46ce3050eb84af28f0afdfae2/contracts/src/interfaces/IEigenDAThresholdRegistry.sol#L6
BlobVersion v2.BlobVersion
}

// GetDefaultPayloadClientConfig creates a PayloadClientConfig with default values
func GetDefaultPayloadClientConfig() *PayloadClientConfig {
return &PayloadClientConfig{
PayloadPolynomialForm: codecs.PolynomialFormEval,
BlobVersion: 0,
}
}
Loading

0 comments on commit 8f43a4a

Please sign in to comment.