Skip to content

Commit

Permalink
Merge pull request #2 from Layr-Labs/epociask--rollup-manager-contract
Browse files Browse the repository at this point in the history
feat: Rollup manager
  • Loading branch information
epociask authored May 31, 2024
2 parents c455ef1 + 9c99910 commit 051f6f8
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 15 deletions.
76 changes: 76 additions & 0 deletions src/bridge/RollupManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.9;

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



interface IRollupManager {

function verifyBlob(
IEigenDAServiceManager.BlobHeader calldata blobHeader,
IEigenDAServiceManager eigenDAServiceManager,
EigenDARollupUtils.BlobVerificationProof calldata blobVerificationProof
) external view;

function openCommitment(
uint256 point,
uint256 evaluation,
BN254.G1Point memory tau,
BN254.G1Point memory commitment,
BN254.G2Point memory proof
) external view returns(bool);

}


contract EigenDADummyManager {

function verifyBlob(
IEigenDAServiceManager.BlobHeader calldata,
IEigenDAServiceManager,
EigenDARollupUtils.BlobVerificationProof calldata
) external view {
return ;
}

function openCommitment(
uint256 point,
uint256 evaluation,
BN254.G1Point memory tau,
BN254.G1Point memory commitment,
BN254.G2Point memory proof
) internal view returns(bool) {

return EigenDARollupUtils.openCommitment(point, evaluation, tau, commitment, proof);
}
}

contract EigenDARollupManager {
using BN254 for BN254.G1Point;

function verifyBlob(
IEigenDAServiceManager.BlobHeader calldata blobHeader,
IEigenDAServiceManager eigenDAServiceManager,
EigenDARollupUtils.BlobVerificationProof calldata blobVerificationProof
) external view {
return EigenDARollupUtils.verifyBlob(blobHeader, eigenDAServiceManager, blobVerificationProof);
}

function openCommitment(
uint256 point,
uint256 evaluation,
BN254.G1Point memory tau,
BN254.G1Point memory commitment,
BN254.G2Point memory proof
) external view returns(bool) {

return EigenDARollupUtils.openCommitment(point, evaluation, tau, commitment, proof);
}
}
7 changes: 5 additions & 2 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {GasRefundEnabled} from "../libraries/GasRefundEnabled.sol";
import "../libraries/ArbitrumChecker.sol";
import {IERC20Bridge} from "./IERC20Bridge.sol";

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

/**
Expand All @@ -63,6 +63,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
IBridge public bridge;

IEigenDAServiceManager public eigenDAServiceManager;
IRollupManager public eigenDARollupManager;

/// @inheritdoc ISequencerInbox
uint256 public constant HEADER_LENGTH = 40;
Expand Down Expand Up @@ -139,6 +140,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
uint256 _maxDataSize,
IReader4844 reader4844_,
IEigenDAServiceManager eigenDAServiceManager_,
IRollupManager eigenDARollupManager_,
bool _isUsingFeeToken
) {
maxDataSize = _maxDataSize;
Expand All @@ -149,6 +151,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
}
reader4844 = reader4844_;
eigenDAServiceManager = eigenDAServiceManager_;
eigenDARollupManager = eigenDARollupManager_;
isUsingFeeToken = _isUsingFeeToken;
}

Expand Down Expand Up @@ -422,7 +425,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
if (!isBatchPoster[msg.sender]) revert NotBatchPoster();

// verify that the blob was actually included before continuing
EigenDARollupUtils.verifyBlob(blobHeader, eigenDAServiceManager, blobVerificationProof);
eigenDARollupManager.verifyBlob(blobHeader, eigenDAServiceManager, blobVerificationProof);

// NOTE: to retrieve need the following
// see: https://github.com/Layr-Labs/eigenda/blob/master/api/docs/retriever.md#blobrequest
Expand Down
5 changes: 4 additions & 1 deletion src/mocks/SequencerInboxStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "../bridge/IEthBridge.sol";
import {INITIALIZATION_MSG_TYPE} from "../libraries/MessageTypes.sol";

import {IEigenDAServiceManager} from "@eigenda/eigenda-utils/interfaces/IEigenDAServiceManager.sol";
import {IRollupManager} from "../bridge/RollupManager.sol";

contract SequencerInboxStub is SequencerInbox {
constructor(
Expand All @@ -18,8 +19,10 @@ contract SequencerInboxStub is SequencerInbox {
uint256 maxDataSize_,
IReader4844 reader4844_,
IEigenDAServiceManager eigenDAServiceManager_,
IRollupManager eigenDARollupManager_,

bool isUsingFeeToken_
) SequencerInbox(maxDataSize_, reader4844_, eigenDAServiceManager_, isUsingFeeToken_) {
) SequencerInbox(maxDataSize_, reader4844_, eigenDAServiceManager_, eigenDARollupManager_, isUsingFeeToken_) {
bridge = bridge_;
rollup = IOwnable(msg.sender);
delayBlocks = uint64(maxTimeVariation_.delayBlocks);
Expand Down
5 changes: 3 additions & 2 deletions test/foundry/BridgeCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ contract BridgeCreatorTest is Test {
uint256 public constant MAX_DATA_SIZE = 117_964;
IReader4844 dummyReader4844 = IReader4844(address(137));
IEigenDAServiceManager dummyEigenDAServiceManager = IEigenDAServiceManager(address(138));
IRollupManager rollupManager = IRollupManager(address(139));

BridgeCreator.BridgeContracts ethBasedTemplates =
BridgeCreator.BridgeContracts({
bridge: new Bridge(),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, false),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false),
inbox: new Inbox(MAX_DATA_SIZE),
rollupEventInbox: new RollupEventInbox(),
outbox: new Outbox()
});
BridgeCreator.BridgeContracts erc20BasedTemplates =
BridgeCreator.BridgeContracts({
bridge: new ERC20Bridge(),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, true),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, true),
inbox: new ERC20Inbox(MAX_DATA_SIZE),
rollupEventInbox: new ERC20RollupEventInbox(),
outbox: new ERC20Outbox()
Expand Down
5 changes: 3 additions & 2 deletions test/foundry/RollupCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ contract RollupCreatorTest is Test {
DeployHelper public deployHelper;
IReader4844 dummyReader4844 = IReader4844(address(137));
IEigenDAServiceManager dummyEigenDAServiceManager = IEigenDAServiceManager(address(138));
IRollupManager rollupManager = IRollupManager(address(139));

// 1 gwei
uint256 public constant MAX_FEE_PER_GAS = 1_000_000_000;
Expand All @@ -37,15 +38,15 @@ contract RollupCreatorTest is Test {
BridgeCreator.BridgeContracts public ethBasedTemplates =
BridgeCreator.BridgeContracts({
bridge: new Bridge(),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, false),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false),
inbox: new Inbox(MAX_DATA_SIZE),
rollupEventInbox: new RollupEventInbox(),
outbox: new Outbox()
});
BridgeCreator.BridgeContracts public erc20BasedTemplates =
BridgeCreator.BridgeContracts({
bridge: new ERC20Bridge(),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, true),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, true),
inbox: new ERC20Inbox(MAX_DATA_SIZE),
rollupEventInbox: new ERC20RollupEventInbox(),
outbox: new ERC20Outbox()
Expand Down
18 changes: 10 additions & 8 deletions test/foundry/SequencerInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ contract SequencerInboxTest is Test {
address proxyAdmin = address(140);
IReader4844 dummyReader4844 = IReader4844(address(137));
IEigenDAServiceManager dummyEigenDAServiceManager = IEigenDAServiceManager(address(138));
IRollupManager rollupManager = IRollupManager(address(139));

uint256 public constant MAX_DATA_SIZE = 117_964;

Expand All @@ -74,6 +75,7 @@ contract SequencerInboxTest is Test {
maxDataSize,
isArbHosted ? IReader4844(address(0)) : dummyReader4844,
dummyEigenDAServiceManager,
rollupManager,
false
);
SequencerInbox seqInbox = SequencerInbox(
Expand Down Expand Up @@ -109,7 +111,7 @@ contract SequencerInboxTest is Test {
abi.encode(uint256(11))
);
SequencerInbox seqInboxImpl = new SequencerInbox(
maxDataSize, IReader4844(address(0)), dummyEigenDAServiceManager, true
maxDataSize, IReader4844(address(0)), dummyEigenDAServiceManager, rollupManager, true
);
SequencerInbox seqInbox = SequencerInbox(
address(new TransparentUpgradeableProxy(address(seqInboxImpl), proxyAdmin, ""))
Expand Down Expand Up @@ -354,7 +356,7 @@ contract SequencerInboxTest is Test {
/* solhint-disable func-name-mixedcase */
function testConstructor() public {
SequencerInbox seqInboxLogic =
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, false);
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false);
assertEq(seqInboxLogic.maxDataSize(), MAX_DATA_SIZE, "Invalid MAX_DATA_SIZE");
assertEq(seqInboxLogic.isUsingFeeToken(), false, "Invalid isUsingFeeToken");

Expand All @@ -363,7 +365,7 @@ contract SequencerInboxTest is Test {
assertEq(seqInboxProxy.isUsingFeeToken(), false, "Invalid isUsingFeeToken");

SequencerInbox seqInboxLogicFeeToken =
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, true);
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, true);
assertEq(seqInboxLogicFeeToken.maxDataSize(), MAX_DATA_SIZE, "Invalid MAX_DATA_SIZE");
assertEq(seqInboxLogicFeeToken.isUsingFeeToken(), true, "Invalid isUsingFeeToken");

Expand All @@ -379,7 +381,7 @@ contract SequencerInboxTest is Test {
_bridge.initialize(IOwnable(address(new RollupMock(rollupOwner))));

address seqInboxLogic = address(
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, false)
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false)
);
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation);
Expand All @@ -397,7 +399,7 @@ contract SequencerInboxTest is Test {
_bridge.initialize(IOwnable(address(new RollupMock(rollupOwner))), nativeToken);

address seqInboxLogic = address(
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, true)
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, true)
);
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation);
Expand All @@ -413,7 +415,7 @@ contract SequencerInboxTest is Test {
_bridge.initialize(IOwnable(address(new RollupMock(rollupOwner))));

address seqInboxLogic = address(
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, true)
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, true)
);
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));

Expand All @@ -429,7 +431,7 @@ contract SequencerInboxTest is Test {
_bridge.initialize(IOwnable(address(new RollupMock(rollupOwner))), nativeToken);

address seqInboxLogic = address(
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, false)
new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false)
);
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));

Expand Down Expand Up @@ -752,7 +754,7 @@ contract SequencerInboxTest is Test {
function testPostUpgradeInitAlreadyInit() public returns (SequencerInbox, SequencerInbox) {
(SequencerInbox seqInbox,) = deployRollup(false);
SequencerInbox seqInboxImpl =
new SequencerInbox(maxDataSize, dummyReader4844, dummyEigenDAServiceManager, false);
new SequencerInbox(maxDataSize, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false);

vm.expectRevert(abi.encodeWithSelector(AlreadyInit.selector));
vm.prank(proxyAdmin);
Expand Down

0 comments on commit 051f6f8

Please sign in to comment.