forked from matter-labs/era-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
EigenDA M1 - contracts #45
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e7d6011
Add eigenda to DAValidatorType
gianbelinche fde74aa
Add eigenda validator
gianbelinche b8d1542
Fix compilation
gianbelinche b60d5b5
Format code
gianbelinche cb029f5
Add Eigenda registry
gianbelinche 369f0f1
Format code
gianbelinche ec43b06
Resolve pending todos
gianbelinche 70e1914
Use deploy simple contract
gianbelinche 81b1ef1
Add dummy eigenda registry doc
gianbelinche b1fb64d
Fix typo
gianbelinche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
da-contracts/contracts/da-layers/eigenda/DummyEigenDARegistry.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
// This is the dummiest possible implementation, where the blobs are always assumed to be verified, | ||
// and you only need to pass the hash of the blob | ||
// In order to be production ready this contract lacks: | ||
// - Verification of the inclusion data | ||
// - Ownership checks | ||
// - Upgradability | ||
contract DummyEigenDARegistry { | ||
mapping(bytes => bytes32) public hashes; | ||
function isVerified(bytes calldata inclusion_data) external view returns (bool, bytes32) { | ||
return (true, hashes[inclusion_data]); | ||
} | ||
|
||
function verify(bytes calldata inclusion_data, bytes32 eigenDAHash) external { | ||
hashes[inclusion_data] = eigenDAHash; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
da-contracts/contracts/da-layers/eigenda/EigenDAL1Validator.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {IL1DAValidator, L1DAValidatorOutput} from "../../IL1DAValidator.sol"; | ||
import {OperatorDAInputTooSmall} from "../../DAContractsErrors.sol"; | ||
|
||
interface IEigenDABlobProofRegistry { | ||
function isVerified(bytes calldata inclusion_data) external view returns (bool, bytes32); | ||
} | ||
|
||
contract EigenDAL1Validator is IL1DAValidator { | ||
error InvalidValidatorOutputHash(); | ||
error ProofNotVerified(); | ||
|
||
IEigenDABlobProofRegistry public eigenDARegistry; | ||
|
||
constructor(address eigendaRegistryAddress) { | ||
eigenDARegistry = IEigenDABlobProofRegistry(eigendaRegistryAddress); | ||
} | ||
|
||
function checkDA( | ||
uint256, // _chainId | ||
uint256, // _batchNumber, | ||
bytes32 l2DAValidatorOutputHash, | ||
bytes calldata operatorDAInput, | ||
uint256 maxBlobsSupported | ||
) external override returns (L1DAValidatorOutput memory output) { | ||
if (operatorDAInput.length < 32) { | ||
revert OperatorDAInputTooSmall(operatorDAInput.length, 32); | ||
} | ||
bytes32 stateDiffHash = abi.decode(operatorDAInput[:32], (bytes32)); | ||
|
||
(bool isVerified, bytes32 eigenDAHash) = eigenDARegistry.isVerified(operatorDAInput[32:]); | ||
|
||
if (!isVerified) revert ProofNotVerified(); | ||
|
||
if (l2DAValidatorOutputHash != keccak256(abi.encodePacked(stateDiffHash, eigenDAHash))) | ||
revert InvalidValidatorOutputHash(); | ||
|
||
output.stateDiffHash = stateDiffHash; | ||
|
||
output.blobsLinearHashes = new bytes32[](maxBlobsSupported); | ||
output.blobsOpeningCommitments = new bytes32[](maxBlobsSupported); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
l2-contracts/contracts/data-availability/EigenDAL2Validator.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't we restrict this function so only the owner of it can modify the
hashes
map?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.
This is a dummy implementation, so the idea is to leave it as simple as possible.
The real Registry should implement that though
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.
I think we should add it anyway.