-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(eigen-client-m1): Add dummy bridge #41
base: eigen-client-m1
Are you sure you want to change the base?
Changes from 7 commits
3781b1d
1a466cd
d62bd27
4b01c20
3e87c9b
7aa70a4
76d8d3b
72eaa62
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,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {IEigenDABridge} from "./IEigenDABridge.sol"; | ||
import {IVectorx} from "./IVectorx.sol"; | ||
import {DummyVectorX} from "./DummyVectorX.sol"; | ||
|
||
contract DummyEigenDABridge is IEigenDABridge { | ||
IVectorx public vectorxContract; | ||
|
||
constructor() { | ||
vectorxContract = new DummyVectorX(); | ||
} | ||
|
||
function vectorx() external view returns (IVectorx) { | ||
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. same here |
||
return vectorxContract; | ||
} | ||
|
||
function verifyBlobLeaf(bytes calldata) external view returns (bool) { | ||
return true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {IVectorx} from "./IVectorx.sol"; | ||
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. same here |
||
|
||
contract DummyVectorX is IVectorx { | ||
function rangeStartBlocks(bytes32) external view returns (uint32 startBlock) { | ||
return 1; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.24; | ||
|
||
import {IEigenDABridge} from "./IEigenDABridge.sol"; | ||
import {IVectorx} from "./IVectorx.sol"; | ||
|
||
abstract contract EigenDAAttestationLib { | ||
struct AttestationData { | ||
uint32 blockNumber; | ||
uint128 leafIndex; | ||
} | ||
|
||
IEigenDABridge public bridge; | ||
IVectorx public vectorx; | ||
|
||
/// @dev Mapping from attestation leaf to attestation data. | ||
/// It is necessary for recovery of the state from the onchain data. | ||
mapping(bytes32 => AttestationData) public attestations; | ||
|
||
error InvalidAttestationProof(); | ||
|
||
constructor(IEigenDABridge _bridge) { | ||
bridge = _bridge; | ||
vectorx = bridge.vectorx(); | ||
} | ||
|
||
function _attest(bytes memory input) internal virtual { | ||
if (!bridge.verifyBlobLeaf(input)) revert InvalidAttestationProof(); | ||
/*attestations[input.leaf] = AttestationData( | ||
vectorx.rangeStartBlocks(input.rangeHash) + uint32(input.dataRootIndex) + 1, | ||
uint128(input.leafIndex) | ||
);*/ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {IL1DAValidator, L1DAValidatorOutput} from "../../IL1DAValidator.sol"; | ||
import {ValL1DAWrongInputLength} from "../../DAContractsErrors.sol"; | ||
import {EigenDAAttestationLib} from "./EigenDAAttestationLib.sol"; | ||
import {IEigenDABridge} from "./IEigenDABridge.sol"; | ||
|
||
contract EigenDAL1Validator is IL1DAValidator, EigenDAAttestationLib { | ||
error InvalidValidatorOutputHash(); | ||
|
||
constructor(IEigenDABridge _eigendaBridge) EigenDAAttestationLib(_eigendaBridge) {} | ||
|
||
function checkDA( | ||
uint256, // _chainId | ||
uint256, // _batchNumber | ||
bytes32 l2DAValidatorOutputHash, // TODO: Maybe we don't need this | ||
Check failure on line 18 in da-contracts/contracts/da-layers/eigenda/EigenDAL1Validator.sol GitHub Actions / lint
Check failure on line 18 in da-contracts/contracts/da-layers/eigenda/EigenDAL1Validator.sol GitHub Actions / lint
|
||
bytes calldata operatorDAInput, | ||
uint256 maxBlobsSupported | ||
) external override returns (L1DAValidatorOutput memory output) { | ||
// TODO: Implement real validation logic. | ||
// For Validiums, we expect the operator to just provide the data for us. | ||
// We don't need to do any checks with regard to the l2DAValidatorOutputHash. | ||
if (operatorDAInput.length < 32) { | ||
revert ValL1DAWrongInputLength(operatorDAInput.length, 32); | ||
} | ||
bytes32 stateDiffHash = abi.decode(operatorDAInput[:32], (bytes32)); | ||
|
||
output.stateDiffHash = stateDiffHash; | ||
|
||
/*IEigenDABridge.MerkleProofInput memory input = abi.decode(operatorDAInput[32:], (IEigenDABridge.MerkleProofInput)); | ||
if (l2DAValidatorOutputHash != keccak256(abi.encodePacked(output.stateDiffHash, input.leaf))) | ||
revert InvalidValidatorOutputHash();*/ //TODO: Maybe we don't need this | ||
_attest(operatorDAInput[32:]); | ||
|
||
output.blobsLinearHashes = new bytes32[](maxBlobsSupported); | ||
output.blobsOpeningCommitments = new bytes32[](maxBlobsSupported); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.24; | ||
|
||
import {IVectorx} from "./IVectorx.sol"; | ||
|
||
interface IEigenDABridge { | ||
// solhint-disable-next-line gas-struct-packing | ||
struct Message { | ||
// single-byte prefix representing the message type | ||
bytes1 messageType; | ||
// address of message sender | ||
bytes32 from; | ||
// address of message receiver | ||
bytes32 to; | ||
// origin chain code | ||
uint32 originDomain; | ||
// destination chain code | ||
uint32 destinationDomain; | ||
// data being sent | ||
bytes data; | ||
// nonce | ||
uint64 messageId; | ||
} | ||
|
||
struct MerkleProofInput { | ||
// proof of inclusion for the data root | ||
bytes32[] dataRootProof; | ||
// proof of inclusion of leaf within blob/bridge root | ||
bytes32[] leafProof; | ||
// abi.encodePacked(startBlock, endBlock) of header range commitment on vectorx | ||
bytes32 rangeHash; | ||
// index of the data root in the commitment tree | ||
uint256 dataRootIndex; | ||
// blob root to check proof against, or reconstruct the data root | ||
bytes32 blobRoot; | ||
// bridge root to check proof against, or reconstruct the data root | ||
bytes32 bridgeRoot; | ||
// leaf being proven | ||
bytes32 leaf; | ||
// index of the leaf in the blob/bridge root tree | ||
uint256 leafIndex; | ||
} | ||
|
||
function vectorx() external view returns (IVectorx vectorx); | ||
function verifyBlobLeaf(bytes calldata input) external view returns (bool); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.24; | ||
|
||
interface IVectorx { | ||
function rangeStartBlocks(bytes32 rangeHash) external view returns (uint32 startBlock); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {IL2DAValidator} from "../interfaces/IL2DAValidator.sol"; | ||
import {StateDiffL2DAValidator} from "./StateDiffL2DAValidator.sol"; | ||
|
||
/// Rollup DA validator. It will publish data that would allow to use either calldata or blobs. | ||
contract EigenDAL2Validator is IL2DAValidator, StateDiffL2DAValidator { | ||
function validatePubdata( | ||
// The rolling hash of the user L2->L1 logs. | ||
bytes32, | ||
// The root hash of the user L2->L1 logs. | ||
bytes32, | ||
// The chained hash of the L2->L1 messages | ||
bytes32 _chainedMessagesHash, | ||
// The chained hash of uncompressed bytecodes sent to L1 | ||
bytes32 _chainedBytecodesHash, | ||
// Operator data, that is related to the DA itself | ||
bytes calldata _totalL2ToL1PubdataAndStateDiffs | ||
) external returns (bytes32 outputHash) { | ||
(bytes32 stateDiffHash, bytes calldata _totalPubdata, ) = _produceStateDiffPubdata( | ||
_chainedMessagesHash, | ||
_chainedBytecodesHash, | ||
_totalL2ToL1PubdataAndStateDiffs | ||
); | ||
|
||
bytes32 fullPubdataHash = keccak256(_totalPubdata); | ||
outputHash = keccak256(abi.encodePacked(stateDiffHash, fullPubdataHash)); | ||
} | ||
} |
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.
don't call it vectorx since it will not use it