-
Notifications
You must be signed in to change notification settings - Fork 202
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
V2 Blob Verification #781
V2 Blob Verification #781
Changes from all commits
f00c0f9
ea81dcf
ada0dc3
47b4201
7f713f3
aabe59e
9aafc47
c259dae
8136dee
31017e2
8937de0
6cfd640
2420319
d9cf91e
f903bdf
09422bc
c053a5d
895b131
8c8069b
623b250
e81c96b
76b4395
336f9e5
39cfd64
8931b05
dca5a2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.9; | ||
|
||
import {IEigenDABlobVerifier} from "../interfaces/IEigenDABlobVerifier.sol"; | ||
import {IEigenDAThresholdRegistry} from "../interfaces/IEigenDAThresholdRegistry.sol"; | ||
import {IEigenDABatchMetadataStorage} from "../interfaces/IEigenDABatchMetadataStorage.sol"; | ||
import {IEigenDASignatureVerifier} from "../interfaces/IEigenDASignatureVerifier.sol"; | ||
import {EigenDABlobVerificationUtils} from "../libraries/EigenDABlobVerificationUtils.sol"; | ||
import {OperatorStateRetriever} from "lib/eigenlayer-middleware/src/OperatorStateRetriever.sol"; | ||
import {IRegistryCoordinator} from "lib/eigenlayer-middleware/src/RegistryCoordinator.sol"; | ||
import {IEigenDARelayRegistry} from "../interfaces/IEigenDARelayRegistry.sol"; | ||
import "../interfaces/IEigenDAStructs.sol"; | ||
|
||
contract EigenDABlobVerifier is IEigenDABlobVerifier { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In lieu of all the renamings going on - does it make sense to call this contract a BlobVerifier? It's not actually verifying the blob but instead a tuple of different commitments which attest that the blob has been successfully aggregated and dispersed. Verifying the blob makes me think of providing a kzg witness proof generated from the blob and verifying against the data commitment which this contract doesn't do. |
||
|
||
IEigenDAThresholdRegistry public immutable eigenDAThresholdRegistry; | ||
IEigenDABatchMetadataStorage public immutable eigenDABatchMetadataStorage; | ||
IEigenDASignatureVerifier public immutable eigenDASignatureVerifier; | ||
IEigenDARelayRegistry public immutable eigenDARelayRegistry; | ||
|
||
OperatorStateRetriever public immutable operatorStateRetriever; | ||
IRegistryCoordinator public immutable registryCoordinator; | ||
|
||
constructor( | ||
IEigenDAThresholdRegistry _eigenDAThresholdRegistry, | ||
IEigenDABatchMetadataStorage _eigenDABatchMetadataStorage, | ||
IEigenDASignatureVerifier _eigenDASignatureVerifier, | ||
IEigenDARelayRegistry _eigenDARelayRegistry, | ||
OperatorStateRetriever _operatorStateRetriever, | ||
IRegistryCoordinator _registryCoordinator | ||
) { | ||
eigenDAThresholdRegistry = _eigenDAThresholdRegistry; | ||
eigenDABatchMetadataStorage = _eigenDABatchMetadataStorage; | ||
eigenDASignatureVerifier = _eigenDASignatureVerifier; | ||
eigenDARelayRegistry = _eigenDARelayRegistry; | ||
operatorStateRetriever = _operatorStateRetriever; | ||
registryCoordinator = _registryCoordinator; | ||
} | ||
|
||
///////////////////////// V1 /////////////////////////////// | ||
|
||
/** | ||
* @notice Verifies a the blob is valid for the required quorums | ||
* @param blobHeader The blob header to verify | ||
* @param blobVerificationProof The blob verification proof to verify the blob against | ||
*/ | ||
function verifyBlobV1( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do existing v1 integrations need to update and call this new method or can they continue using the old verify method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. old library will continue to work There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious why we need V1 verifications - anyone calling these functions will do so directly through the Service Manager wrapper (i.e, Verifier contracts in Nitro). Don't see how this enables or helps cross compatibility between V1 <--> V2. |
||
BlobHeader calldata blobHeader, | ||
BlobVerificationProof calldata blobVerificationProof | ||
) external view { | ||
EigenDABlobVerificationUtils._verifyBlobV1ForQuorums( | ||
eigenDAThresholdRegistry, | ||
eigenDABatchMetadataStorage, | ||
blobHeader, | ||
blobVerificationProof, | ||
quorumNumbersRequired() | ||
); | ||
} | ||
|
||
/** | ||
* @notice Verifies a batch of blobs for the required quorums | ||
* @param blobHeaders The blob headers to verify | ||
* @param blobVerificationProofs The blob verification proofs to verify the blobs against | ||
*/ | ||
function verifyBlobsV1( | ||
BlobHeader[] calldata blobHeaders, | ||
BlobVerificationProof[] calldata blobVerificationProofs | ||
) external view { | ||
EigenDABlobVerificationUtils._verifyBlobsV1ForQuorums( | ||
eigenDAThresholdRegistry, | ||
eigenDABatchMetadataStorage, | ||
blobHeaders, | ||
blobVerificationProofs, | ||
quorumNumbersRequired() | ||
); | ||
} | ||
|
||
///////////////////////// V2 /////////////////////////////// | ||
|
||
/** | ||
* @notice Verifies a blob for the base required quorums and the default security thresholds | ||
* @param batchHeader The batch header of the blob | ||
* @param blobVerificationProof The blob verification proof for the blob | ||
* @param nonSignerStakesAndSignature The nonSignerStakesAndSignature for the blob | ||
*/ | ||
function verifyBlobV2( | ||
BatchHeaderV2 calldata batchHeader, | ||
BlobVerificationProofV2 calldata blobVerificationProof, | ||
NonSignerStakesAndSignature calldata nonSignerStakesAndSignature | ||
0x0aa0 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+87
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on the rollup side we interpret this three element tuple as a certificate type. Is there any benefit to representing the EigenDA certificate type here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we implicitly use this term across our documentation and integrations - would be nice to have an explicit definition |
||
) external view { | ||
EigenDABlobVerificationUtils._verifyBlobV2ForQuorums( | ||
eigenDAThresholdRegistry, | ||
eigenDASignatureVerifier, | ||
eigenDARelayRegistry, | ||
batchHeader, | ||
blobVerificationProof, | ||
nonSignerStakesAndSignature, | ||
getDefaultSecurityThresholdsV2(), | ||
quorumNumbersRequired() | ||
); | ||
} | ||
|
||
/** | ||
* @notice Verifies a blob for the base required quorums and the default security thresholds | ||
* @param signedBatch The signed batch to verify the blob against | ||
* @param blobVerificationProof The blob verification proof for the blob | ||
*/ | ||
function verifyBlobV2FromSignedBatch( | ||
SignedBatch calldata signedBatch, | ||
BlobVerificationProofV2 calldata blobVerificationProof | ||
) external view { | ||
EigenDABlobVerificationUtils._verifyBlobV2ForQuorumsFromSignedBatch( | ||
eigenDAThresholdRegistry, | ||
eigenDASignatureVerifier, | ||
eigenDARelayRegistry, | ||
operatorStateRetriever, | ||
registryCoordinator, | ||
signedBatch, | ||
blobVerificationProof, | ||
getDefaultSecurityThresholdsV2(), | ||
quorumNumbersRequired() | ||
); | ||
} | ||
|
||
///////////////////////// HELPER FUNCTIONS /////////////////////////////// | ||
|
||
/** | ||
* @notice Returns the nonSignerStakesAndSignature for a given blob and signed batch | ||
* @param signedBatch The signed batch to get the nonSignerStakesAndSignature for | ||
*/ | ||
function getNonSignerStakesAndSignature( | ||
SignedBatch calldata signedBatch | ||
) external view returns (NonSignerStakesAndSignature memory) { | ||
return EigenDABlobVerificationUtils._getNonSignerStakesAndSignature( | ||
operatorStateRetriever, | ||
registryCoordinator, | ||
signedBatch.attestation | ||
); | ||
} | ||
|
||
/** | ||
* @notice Verifies the security parameters for a blob | ||
* @param blobParams The blob params to verify | ||
* @param securityThresholds The security thresholds to verify against | ||
*/ | ||
function verifyBlobSecurityParams( | ||
VersionedBlobParams memory blobParams, | ||
SecurityThresholds memory securityThresholds | ||
) external view { | ||
EigenDABlobVerificationUtils._verifyBlobSecurityParams(blobParams, securityThresholds); | ||
} | ||
|
||
/** | ||
* @notice Verifies the security parameters for a blob | ||
* @param version The version of the blob to verify | ||
* @param securityThresholds The security thresholds to verify against | ||
*/ | ||
function verifyBlobSecurityParams( | ||
uint16 version, | ||
SecurityThresholds memory securityThresholds | ||
) external view { | ||
EigenDABlobVerificationUtils._verifyBlobSecurityParams(getBlobParams(version), securityThresholds); | ||
} | ||
|
||
/// @notice Returns an array of bytes where each byte represents the adversary threshold percentage of the quorum at that index | ||
function quorumAdversaryThresholdPercentages() external view returns (bytes memory) { | ||
return eigenDAThresholdRegistry.quorumAdversaryThresholdPercentages(); | ||
} | ||
|
||
/// @notice Returns an array of bytes where each byte represents the confirmation threshold percentage of the quorum at that index | ||
function quorumConfirmationThresholdPercentages() external view returns (bytes memory) { | ||
return eigenDAThresholdRegistry.quorumConfirmationThresholdPercentages(); | ||
} | ||
|
||
/// @notice Returns an array of bytes where each byte represents the number of a required quorum | ||
function quorumNumbersRequired() public view returns (bytes memory) { | ||
return eigenDAThresholdRegistry.quorumNumbersRequired(); | ||
} | ||
|
||
function getQuorumAdversaryThresholdPercentage( | ||
uint8 quorumNumber | ||
) external view returns (uint8){ | ||
return eigenDAThresholdRegistry.getQuorumAdversaryThresholdPercentage(quorumNumber); | ||
} | ||
|
||
/// @notice Gets the confirmation threshold percentage for a quorum | ||
function getQuorumConfirmationThresholdPercentage( | ||
uint8 quorumNumber | ||
) external view returns (uint8){ | ||
return eigenDAThresholdRegistry.getQuorumConfirmationThresholdPercentage(quorumNumber); | ||
} | ||
|
||
/// @notice Checks if a quorum is required | ||
function getIsQuorumRequired( | ||
uint8 quorumNumber | ||
) external view returns (bool){ | ||
return eigenDAThresholdRegistry.getIsQuorumRequired(quorumNumber); | ||
} | ||
|
||
/// @notice Returns the blob params for a given blob version | ||
function getBlobParams(uint16 version) public view returns (VersionedBlobParams memory) { | ||
return eigenDAThresholdRegistry.getBlobParams(version); | ||
} | ||
|
||
/// @notice Gets the default security thresholds for V2 | ||
function getDefaultSecurityThresholdsV2() public view returns (SecurityThresholds memory) { | ||
return eigenDAThresholdRegistry.getDefaultSecurityThresholdsV2(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.9; | ||
|
||
import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; | ||
import {EigenDARelayRegistryStorage} from "./EigenDARelayRegistryStorage.sol"; | ||
import {IEigenDARelayRegistry} from "../interfaces/IEigenDARelayRegistry.sol"; | ||
import "../interfaces/IEigenDAStructs.sol"; | ||
|
||
/** | ||
* @title Registry for EigenDA relay keys | ||
* @author Layr Labs, Inc. | ||
*/ | ||
contract EigenDARelayRegistry is OwnableUpgradeable, EigenDARelayRegistryStorage, IEigenDARelayRegistry { | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addd natspec to interfaces and use @inheritdoc |
||
address _initialOwner | ||
) external initializer { | ||
_transferOwnership(_initialOwner); | ||
} | ||
|
||
function addRelayInfo(RelayInfo memory relayInfo) external onlyOwner returns (uint32) { | ||
relayKeyToInfo[nextRelayKey] = relayInfo; | ||
emit RelayAdded(relayInfo.relayAddress, nextRelayKey, relayInfo.relayURL); | ||
return nextRelayKey++; | ||
} | ||
|
||
function relayKeyToAddress(uint32 key) external view returns (address) { | ||
return relayKeyToInfo[key].relayAddress; | ||
} | ||
|
||
function relayKeyToUrl(uint32 key) external view returns (string memory) { | ||
return relayKeyToInfo[key].relayURL; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to hardcode the params for version 0 here if we're going to use the same values across all environments?