Skip to content

Commit

Permalink
add the eigenDA header flag
Browse files Browse the repository at this point in the history
add test and bypass condition in formCallDataHash

update eigenDA data variable name and fix comment

add test to ensure invalid bytesets are still invalid

cleaned up

all tests passing, interface updated, fmt

update blob source

reorder params in addSequencerL2BatchFromEigenDA for cleaner sequencer message parsing code on the go side

have state updates emit OwnerFunctionCalled

fix nits

fix old test

implement verifyEigenDACommitment

update executeReadPreimage

data validation, but now stack too deep

add variable scoping

add G2TAU constant

wrote test using commitment generated by eigenDA utils

parsing working as expected, tests fixed

builds with @eigenda

add new mocks

bump contract package versions

new stub with v2.0.0 of eigen npm package, alias OZ for expected path

more mocks
  • Loading branch information
afkbyte authored and teddyknox committed May 29, 2024
1 parent 1cab72f commit 6bd3cf1
Show file tree
Hide file tree
Showing 24 changed files with 2,165 additions and 2,763 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/eigenda"]
path = lib/eigenda
url = https://github.com/Layr-Labs/eigenda
11 changes: 11 additions & 0 deletions deploy/EigenDAServiceManagerStubCreator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = async hre => {
const { deployments, getNamedAccounts, ethers } = hre
const { deploy } = deployments
const { deployer } = await getNamedAccounts()

await deploy('EigenDAServiceManagerStub', { from: deployer, args: [] })
}

module.exports.tags = ['EigenDAServiceManagerStub', 'test']
module.exports.dependencies = []

8 changes: 6 additions & 2 deletions deploy/SequencerInbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ module.exports = async hre => {
const blobBasefeeReader = await ethers.getContract('BlobBasefeeReader')
const dataHashReader = await ethers.getContract('DataHashReader')

await deploy('SequencerInbox', { from: deployer, args: [117964] })
const EigenDARollupUtils = await ethers.getContract('EigenDARollupUtils')



await deploy('SequencerInbox', { from: deployer, args: [117964], libraries: { EigenDARollupUtils: EigenDARollupUtils.address } })
}

module.exports.tags = ['SequencerInbox']
module.exports.dependencies = []
module.exports.dependencies = ['EigenDARollupUtils']
16 changes: 15 additions & 1 deletion deploy/SequencerInboxStubCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ module.exports = async hre => {
delaySeconds: 10000,
futureSeconds: 10000,
}

const eigenDAServiceManager = await ethers.getContract('EigenDAServiceManagerStub')

// constructor(
// IBridge bridge_,
// address sequencer_,
// ISequencerInbox.MaxTimeVariation memory maxTimeVariation_,
// uint256 maxDataSize_,
// IReader4844 reader4844_,
// IEigenDAServiceManager eigenDAServiceManager_,
// bool isUsingFeeToken_
// )

await deploy('SequencerInboxStub', {
from: deployer,
args: [
Expand All @@ -23,10 +36,11 @@ module.exports = async hre => {
maxTime,
117964,
reader4844.address,
eigenDAServiceManager.address,
false,
],
})
}

module.exports.tags = ['SequencerInboxStub', 'test']
module.exports.dependencies = ['BridgeStub']
module.exports.dependencies = ['BridgeStub', 'EigenDAServiceManagerStub']
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache_path = 'forge-cache/sol'
optimizer = true
optimizer_runs = 100
via_ir = false
solc_version = '0.8.9'
solc_version = '0.8.12'

[profile.yul]
src = 'yul'
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dotenv.config()
const solidity = {
compilers: [
{
version: '0.8.9',
version: '0.8.12',
settings: {
optimizer: {
enabled: true,
Expand Down
1 change: 1 addition & 0 deletions lib/eigenda
Submodule eigenda added at cd0155
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts"
},
"dependencies": {
"@eigenda/eigenda-utils": "2.0.0",
"@offchainlabs/upgrade-executor": "1.1.0-beta.0",
"@openzeppelin/contracts": "4.5.0",
"@openzeppelin/contracts-upgradeable": "4.5.2",
"@openzeppelin-upgrades/contracts": "npm:@openzeppelin/contracts-upgradeable@4.7",
"@openzeppelin/contracts": "4.7",
"@openzeppelin/contracts-upgradeable": "4.7",
"patch-package": "^6.4.7"
},
"private": false,
Expand Down
6 changes: 5 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/

@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/
eigenda/contracts/=lib/eigenda/contracts/src
eigenlayer-middleware/=lib/eigenda/contracts/lib/eigenlayer-middleware/src/
eigenlayer-core/=lib/eigenda/contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts/src/

24 changes: 8 additions & 16 deletions src/bridge/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ interface IBridge {
/// @notice This batch contains no data
NoData,
/// @notice The data can be found in the 4844 data blobs on this transaction
Blob
Blob,
/// @notice The data can be found in the EigenDA blob associated with this batch
EigenDA
}

struct TimeBounds {
Expand All @@ -42,10 +44,7 @@ interface IBridge {
);

event BridgeCallTriggered(
address indexed outbox,
address indexed to,
uint256 value,
bytes data
address indexed outbox, address indexed to, uint256 value, bytes data
);

event InboxToggle(address indexed inbox, bool enabled);
Expand Down Expand Up @@ -78,11 +77,9 @@ interface IBridge {

function sequencerReportedSubMessageCount() external view returns (uint256);

function executeCall(
address to,
uint256 value,
bytes calldata data
) external returns (bool success, bytes memory returnData);
function executeCall(address to, uint256 value, bytes calldata data)
external
returns (bool success, bytes memory returnData);

function delayedMessageCount() external view returns (uint256);

Expand All @@ -97,12 +94,7 @@ interface IBridge {
uint256 newMessageCount
)
external
returns (
uint256 seqMessageIndex,
bytes32 beforeAcc,
bytes32 delayedAcc,
bytes32 acc
);
returns (uint256 seqMessageIndex, bytes32 beforeAcc, bytes32 delayedAcc, bytes32 acc);

/**
* @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type
Expand Down
22 changes: 22 additions & 0 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import "../libraries/IGasRefunder.sol";
import "./IDelayedMessageProvider.sol";
import "./IBridge.sol";

import {EigenDARollupUtils} from "@eigenda/eigenda-utils/libraries/EigenDARollupUtils.sol";
import {IEigenDAServiceManager} from "@eigenda/eigenda-utils/interfaces/IEigenDAServiceManager.sol";

interface ISequencerInbox is IDelayedMessageProvider {
struct MaxTimeVariation {
uint256 delayBlocks;
Expand Down Expand Up @@ -83,6 +86,12 @@ interface ISequencerInbox is IDelayedMessageProvider {
// solhint-disable-next-line func-name-mixedcase
function ZERO_HEAVY_MESSAGE_HEADER_FLAG() external view returns (bytes1);

/// @dev If the first data byte after the header has this bit set,
/// then the batch data is an eigenDA message
/// See: https://github.com/Layr-Labs/nitro/blob/2ad088cb5943ec50ed8b521c4681561817a602c5/das/eigenda/eigenda.go
// solhint-disable-next-line func-name-mixedcase
function EIGENDA_MESSAGE_HEADER_FLAG() external view returns (bytes1);

function rollup() external view returns (IOwnable);

function isBatchPoster(address) external view returns (bool);
Expand Down Expand Up @@ -179,6 +188,16 @@ interface ISequencerInbox is IDelayedMessageProvider {
uint256 newMessageCount
) external;

function addSequencerL2BatchFromEigenDA(
uint256 sequenceNumber,
EigenDARollupUtils.BlobVerificationProof calldata blobVerificationProof,
IEigenDAServiceManager.BlobHeader calldata blobHeader,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount
) external;

// ---------- onlyRollupOrOwner functions ----------

/**
Expand Down Expand Up @@ -223,6 +242,9 @@ interface ISequencerInbox is IDelayedMessageProvider {
/// @notice Allows the rollup owner to sync the rollup address
function updateRollupAddress() external;

/// @notice Allows the rollup owner to update the eigenDAServiceManager address
function updateEigenDAServiceManager(address newEigenDAServiceManager) external;

// ---------- initializer ----------

function initialize(IBridge bridge_, MaxTimeVariation calldata maxTimeVariation_) external;
Expand Down
Loading

0 comments on commit 6bd3cf1

Please sign in to comment.