Skip to content

Commit f15ccb8

Browse files
committed
Add blob verifier
1 parent b25f258 commit f15ccb8

File tree

5 files changed

+42
-40
lines changed

5 files changed

+42
-40
lines changed

da-contracts/contracts/da-layers/eigenda/DummyEigenDABridge.sol

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,23 @@ pragma solidity 0.8.24;
55
import {IEigenDABridge} from "./IEigenDABridge.sol";
66
import {IImplementation} from "./IImplementation.sol";
77
import {DummyImplementation} from "./DummyImplementation.sol";
8-
import {IEigenDABatchMetadataStorage} from "@eigenda/eigenda-utils/interfaces/IEigenDABatchMetadataStorage.sol";
8+
import {IBlobVerifier} from "./IBlobVerifier.sol";
99

1010
contract DummyEigenDABridge is IEigenDABridge {
1111
IImplementation public implementationContract;
12-
IEigenDABatchMetadataStorage public eigenDaServiceManager;
12+
IBlobVerifier public eigenBlobVerifier;
1313

14-
constructor(address _eigenDaServiceManager) {
14+
constructor(address _eigenBlobVerifier) {
1515
implementationContract = new DummyImplementation();
16-
eigenDaServiceManager = IEigenDABatchMetadataStorage(_eigenDaServiceManager);
16+
eigenBlobVerifier = IBlobVerifier(_eigenBlobVerifier);
1717
}
1818

1919
function implementation() external view returns (IImplementation) {
2020
return implementationContract;
2121
}
2222

23-
function hashBatchMetadata(BatchMetadata calldata batchMetadata) external pure returns (bytes32) {
24-
return keccak256(abi.encodePacked(keccak256(abi.encode(batchMetadata.batchHeader)),batchMetadata.signatoryRecordHash,batchMetadata.confirmationBlockNumber));
25-
}
26-
2723
function verifyBlobLeaf(MerkleProofInput calldata merkleProof) external view returns (bool) {
28-
// Inspired by eigenlayer contracts Merkle.verifyInclusionKeccak
29-
// https://github.com/Layr-Labs/eigenlayer-contracts/blob/3f3f83bd194b3bdc77d06d8fe6b101fafc3bcfd5/src/contracts/libraries/Merkle.sol
30-
bytes32 hashedBatchMetadata = this.hashBatchMetadata(merkleProof.blobVerificationProof.batchMetadata);
31-
require(hashedBatchMetadata == IEigenDABatchMetadataStorage(eigenDaServiceManager).batchIdToBatchMetadataHash(merkleProof.blobVerificationProof.batchId), "invalid batch metadata");
32-
uint256 index = merkleProof.blobVerificationProof.blobIndex;
33-
bytes memory inclusionProof = merkleProof.blobVerificationProof.inclusionProof;
34-
require(inclusionProof.length % 32 == 0, "proof length not multiple of 32");
35-
bytes32 computedHash = merkleProof.leaf;
36-
uint256 length = inclusionProof.length;
37-
for (uint256 i = 32; i <= length; i += 32) {
38-
if (index % 2 == 0) {
39-
// if ith bit of index is 0, then computedHash is a left sibling
40-
assembly {
41-
mstore(0x00, computedHash)
42-
mstore(0x20, mload(add(inclusionProof, i)))
43-
computedHash := keccak256(0x00, 0x40)
44-
index := div(index, 2)
45-
}
46-
} else {
47-
// if ith bit of index is 1, then computedHash is a right sibling
48-
assembly {
49-
mstore(0x00, mload(add(inclusionProof, i)))
50-
mstore(0x20, computedHash)
51-
computedHash := keccak256(0x00, 0x40)
52-
index := div(index, 2)
53-
}
54-
}
55-
}
56-
require(computedHash == merkleProof.blobVerificationProof.batchMetadata.batchHeader.blobHeadersRoot, "invalid proof");
24+
eigenBlobVerifier.verifyBlobV1(merkleProof.blobHeader, merkleProof.blobVerificationProof);
5725
return true;
5826
}
5927
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity 0.8.24;
4+
5+
import {IEigenDABridge} from "./IEigenDABridge.sol";
6+
7+
interface IBlobVerifier {
8+
function verifyBlobV1(
9+
IEigenDABridge.BlobHeader calldata blobHeader,
10+
IEigenDABridge.BlobVerificationProof calldata blobVerificationProof
11+
) external view;
12+
}

da-contracts/contracts/da-layers/eigenda/IEigenDABridge.sol

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,26 @@ interface IEigenDABridge {
2727
bytes quorumIndices;
2828
}
2929

30+
struct QuorumBlobParam {
31+
uint8 quorumNumber;
32+
uint8 adversaryThresholdPercentage;
33+
uint8 confirmationThresholdPercentage;
34+
uint32 chunkLength;
35+
}
36+
37+
struct G1Point {
38+
uint256 X;
39+
uint256 Y;
40+
}
41+
42+
struct BlobHeader {
43+
G1Point commitment;
44+
uint32 dataLength;
45+
QuorumBlobParam[] quorumBlobParams;
46+
}
47+
3048
struct MerkleProofInput {
31-
bytes32 leaf;
49+
BlobHeader blobHeader;
3250
BlobVerificationProof blobVerificationProof;
3351
}
3452

l1-contracts/deploy-scripts/DeployL1.s.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ contract DeployL1Script is Script, DeployUtils {
212212
}
213213

214214
if (config.contracts.eigenDAL1Validator == address(0)) {
215-
address eigenDAServiceManagerAddress = address(0);
216-
address eigendaBridge = deployViaCreate2(Utils.readDummyEigenDABridgeBytecode(), abi.encode(eigenDAServiceManagerAddress));
215+
address eigendaBridge = deployViaCreate2(Utils.readDummyEigenDABridgeBytecode(), abi.encode(config.contracts.eigenDABlobVerifier));
217216
addresses.daAddresses.eigenDAL1Validator = deployViaCreate2(
218217
Utils.readEigenDAL1ValidatorBytecode(),
219218
abi.encode(eigendaBridge)

l1-contracts/deploy-scripts/DeployUtils.s.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ struct ContractsConfig {
167167
bytes32 defaultAAHash;
168168
address availL1DAValidator;
169169
address eigenDAL1Validator;
170+
address eigenDABlobVerifier;
170171
}
171172

172173
struct TokensConfig {
@@ -246,6 +247,10 @@ contract DeployUtils is Script {
246247
config.contracts.eigenDAL1Validator = toml.readAddress("$.contracts.eigenda_l1_validator");
247248
}
248249

250+
if (vm.keyExistsToml(toml, "$.contracts.eigenda_blob_verifier_addr")) {
251+
config.contracts.eigenDABlobVerifier = toml.readAddress("$.contracts.eigenda_blob_verifier_addr");
252+
}
253+
249254
config.tokens.tokenWethAddress = toml.readAddress("$.tokens.token_weth_address");
250255
}
251256

0 commit comments

Comments
 (0)