Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit 345df12

Browse files
authored
Merge branch 'main' into ethenotethan--update-example-env-sepolia-addresses
2 parents 2906093 + 2d185a7 commit 345df12

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

docs/help_out.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ GLOBAL OPTIONS:
1919
Cert Verifier (V1 only)
2020

2121
--eigenda.cert-verification-disabled Whether to verify certificates received from EigenDA disperser. (default: false) [$EIGENDA_PROXY_EIGENDA_CERT_VERIFICATION_DISABLED]
22+
--eigenda.cert-verifier-v1 value Address of EigenDACertVerifierV1 contract. Only necessary if using custom quorums/thresholds
23+
for certificate verification. If no address is provided then the default
24+
EigenDAServiceManager parameters will be uesd. [$EIGENDA_PROXY_EIGENDA_CERT_VERIFIER_V1]
2225

2326
EigenDA V1 Client
2427

store/generated_key/eigenda/verify/cert.go

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/Layr-Labs/eigenda-proxy/common/consts"
1212
"github.com/Layr-Labs/eigenda/api/grpc/disperser"
13+
v1_verifier_binding "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDACertVerifierV1"
1314
edsm_binding "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager"
1415
binding "github.com/Layr-Labs/eigenda/contracts/bindings/IEigenDACertVerifierLegacy"
1516
"github.com/Layr-Labs/eigensdk-go/logging"
@@ -22,6 +23,13 @@ import (
2223
"golang.org/x/exp/slices"
2324
)
2425

26+
// SecurityParamReader is an interface used reading quorums and thresholds from either
27+
// the EigenDAServiceManager or EigenDACertVerifierV1 contracts
28+
type SecurityParamReader interface {
29+
QuorumAdversaryThresholdPercentages(opts *bind.CallOpts) ([]byte, error)
30+
QuorumNumbersRequired(opts *bind.CallOpts) ([]uint8, error)
31+
}
32+
2533
// CertVerifier verifies the DA certificate against on-chain EigenDA contracts
2634
// to ensure disperser returned fields haven't been tampered with
2735
type CertVerifier struct {
@@ -34,9 +42,12 @@ type CertVerifier struct {
3442
// (typically 64 blocks in happy case).
3543
ethConfirmationDepth uint64
3644
waitForFinalization bool
37-
manager *edsm_binding.ContractEigenDAServiceManagerCaller
38-
ethClient *ethclient.Client
39-
// The two fields below are fetched from the EigenDAServiceManager contract in the constructor.
45+
svcManagerCaller *edsm_binding.ContractEigenDAServiceManagerCaller
46+
47+
securityParamReader SecurityParamReader
48+
ethClient *ethclient.Client
49+
// The two fields below are fetched from the EigenDAServiceManager contract or
50+
// the EigenDACertVerifierV1 (if configured) in the constructor.
4051
// They are used to verify the quorums in the received certificates.
4152
// See getQuorumParametersAtLatestBlock for more details.
4253
quorumsRequired []uint8
@@ -57,20 +68,36 @@ func NewCertVerifier(cfg *Config, log logging.Logger) (*CertVerifier, error) {
5768
return nil, fmt.Errorf("failed to dial ETH RPC node: %s", err.Error())
5869
}
5970

60-
// construct caller binding
61-
m, err := edsm_binding.NewContractEigenDAServiceManagerCaller(common.HexToAddress(cfg.SvcManagerAddr), client)
71+
// construct caller bindings
72+
svcManagerCaller, err := edsm_binding.NewContractEigenDAServiceManagerCaller(
73+
common.HexToAddress(cfg.SvcManagerAddr), client)
6274
if err != nil {
6375
return nil, err
6476
}
6577

66-
quorumsRequired, quorumAdversaryThresholds, err := getQuorumParametersAtLatestBlock(m)
78+
// If the user has specified a custom cert verifier, use it.
79+
var securityParamReader SecurityParamReader = svcManagerCaller
80+
if cfg.CertVerifierV1Addr != "" {
81+
log.Infof("Using custom EigenDACertVerifierV1 contract for cert verification at address: %s", cfg.CertVerifierV1Addr)
82+
certVerifierCallerV1, err := v1_verifier_binding.NewContractEigenDACertVerifierV1Caller(
83+
common.HexToAddress(cfg.CertVerifierV1Addr), client,
84+
)
85+
if err != nil {
86+
return nil, fmt.Errorf("failed to create EigenDACertVerifierV1 caller: %w", err)
87+
}
88+
89+
securityParamReader = certVerifierCallerV1
90+
}
91+
92+
quorumsRequired, quorumAdversaryThresholds, err := getQuorumParametersAtLatestBlock(securityParamReader)
6793
if err != nil {
6894
return nil, fmt.Errorf("failed to fetch quorum parameters from EigenDAServiceManager: %w", err)
6995
}
7096

7197
return &CertVerifier{
7298
log: log,
73-
manager: m,
99+
svcManagerCaller: svcManagerCaller,
100+
securityParamReader: securityParamReader,
74101
ethConfirmationDepth: cfg.EthConfirmationDepth,
75102
ethClient: client,
76103
quorumsRequired: quorumsRequired,
@@ -198,7 +225,7 @@ func (cv *CertVerifier) retrieveBatchMetadataHash(
198225
batchID uint32,
199226
blockNumber *big.Int,
200227
) ([32]byte, error) {
201-
onchainHash, err := cv.manager.BatchIdToBatchMetadataHash(
228+
onchainHash, err := cv.svcManagerCaller.BatchIdToBatchMetadataHash(
202229
&bind.CallOpts{Context: ctx, BlockNumber: blockNumber},
203230
batchID,
204231
)
@@ -228,17 +255,17 @@ func (cv *CertVerifier) retrieveBatchMetadataHash(
228255
// in the past,
229256
// which was not ideal. So we decided to make these parameters immutable, and cache them here.
230257
func getQuorumParametersAtLatestBlock(
231-
manager *edsm_binding.ContractEigenDAServiceManagerCaller,
258+
reader SecurityParamReader,
232259
) ([]uint8, map[uint8]uint8, error) {
233260
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
234261
defer cancel()
235-
requiredQuorums, err := manager.QuorumNumbersRequired(&bind.CallOpts{Context: ctx})
262+
requiredQuorums, err := reader.QuorumNumbersRequired(&bind.CallOpts{Context: ctx})
236263
if err != nil {
237264
return nil, nil, fmt.Errorf("failed to fetch QuorumNumbersRequired from EigenDAServiceManager: %w", err)
238265
}
239266
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
240267
defer cancel()
241-
thresholds, err := manager.QuorumAdversaryThresholdPercentages(&bind.CallOpts{Context: ctx})
268+
thresholds, err := reader.QuorumAdversaryThresholdPercentages(&bind.CallOpts{Context: ctx})
242269
if err != nil {
243270
return nil, nil, fmt.Errorf(
244271
"failed to fetch QuorumAdversaryThresholdPercentages from EigenDAServiceManager: %w",

store/generated_key/eigenda/verify/cli.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
)
1212

1313
var (
14+
EigenDACertVerifierV1FlagName = withFlagPrefix("cert-verifier-v1")
15+
1416
// cert verification flags
1517
CertVerificationDisabledFlagName = withFlagPrefix("cert-verification-disabled")
1618

@@ -43,6 +45,14 @@ func VerifierCLIFlags(envPrefix, category string) []cli.Flag {
4345
Value: false,
4446
Category: category,
4547
},
48+
&cli.StringFlag{
49+
Name: EigenDACertVerifierV1FlagName,
50+
Usage: `Address of EigenDACertVerifierV1 contract. Only necessary if using custom quorums/thresholds
51+
for certificate verification. If no address is provided then the default
52+
EigenDAServiceManager parameters will be uesd.`,
53+
EnvVars: []string{withEnvPrefix(envPrefix, "CERT_VERIFIER_V1")},
54+
Category: category,
55+
},
4656
}
4757
}
4858

@@ -119,6 +129,7 @@ func ReadConfig(ctx *cli.Context, clientConfigV1 common.ClientConfigV1) Config {
119129
// reuse some configs from the eigenda client
120130
RPCURL: clientConfigV1.EdaClientCfg.EthRpcUrl,
121131
SvcManagerAddr: clientConfigV1.EdaClientCfg.SvcManagerAddr,
132+
CertVerifierV1Addr: ctx.String(EigenDACertVerifierV1FlagName),
122133
EthConfirmationDepth: clientConfigV1.EdaClientCfg.WaitForConfirmationDepth,
123134
WaitForFinalization: clientConfigV1.EdaClientCfg.WaitForFinalization,
124135
}

store/generated_key/eigenda/verify/verifier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Config struct {
3030
// below fields are only required if VerifyCerts is true
3131
RPCURL string
3232
SvcManagerAddr string
33+
CertVerifierV1Addr string // used if enabling custom quorums/thresholds
3334
EthConfirmationDepth uint64
3435
WaitForFinalization bool
3536
MaxBlobSizeBytes uint64

0 commit comments

Comments
 (0)