Skip to content

Commit

Permalink
merge upstream changes and fix failing inbox test
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed Jul 2, 2024
2 parents 24f58bb + 2f8d2cc commit 63bdd82
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/contract-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a

- name: Setup node/yarn
uses: actions/setup-node@v3
Expand All @@ -34,7 +34,7 @@ jobs:
run: yarn

- name: Build
run: forge test
run: forge test --fork-url https://rpc.holesky.ethpandaops.io/
tests:
name: Contract tests
runs-on: ubuntu-8
Expand Down
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ optimizer = true
optimizer_runs = 100
via_ir = false
solc_version = '0.8.12'
fs_permissions = [{ access = "read", path = "./"}]

[profile.yul]
src = 'yul'
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@
"postinstall": "patch-package",
"deploy-factory": "hardhat run scripts/deployment.ts",
"deploy-eth-rollup": "hardhat run scripts/createEthRollup.ts",
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts"
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts",
"deploy-blob": "yarn ts-node scripts/disperseBlob.ts"
},
"dependencies": {
"@eigenda/eigenda-utils": "2.0.0",
"@grpc/grpc-js": "^1.8.22",
"@grpc/proto-loader": "^0.7.13",
"@offchainlabs/upgrade-executor": "1.1.0-beta.0",
"@openzeppelin-upgrades/contracts": "npm:@openzeppelin/contracts-upgradeable@4.7",
"@openzeppelin/contracts": "4.7",
"@openzeppelin/contracts-upgradeable": "4.7",
"google-protobuf": "^3.21.2",
"patch-package": "^6.4.7"
},
"private": false,
Expand All @@ -62,6 +66,7 @@
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/chai": "^4.3.0",
"@types/google-protobuf": "^3.15.12",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.5",
"@typescript-eslint/eslint-plugin": "^5.14.0",
Expand Down
4 changes: 1 addition & 3 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,8 @@ interface ISequencerInbox is IDelayedMessageProvider {
function setBatchPosterManager(address newBatchPosterManager) external;

/// @notice Allows the rollup owner to sync the rollup address
// function updateRollupAddress() external;
function updateRollupAddress() external;

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

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

Expand Down
17 changes: 14 additions & 3 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {IERC20Bridge} from "./IERC20Bridge.sol";
import {IRollupManager} from "./RollupManager.sol";
import {IEigenDAServiceManager} from "@eigenda/eigenda-utils/interfaces/IEigenDAServiceManager.sol";


/**
* @title Accepts batches from the sequencer and adds them to the rollup inbox.
* @notice Contains the inbox accumulator which is the ordering of all data and transactions to be processed by the rollup.
Expand All @@ -62,6 +63,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox

IBridge public bridge;

address public eigenDAServiceManager;
address public eigenDARollupManager;

/// @inheritdoc ISequencerInbox
uint256 public constant HEADER_LENGTH = 40;

Expand Down Expand Up @@ -133,9 +137,6 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
// True if the chain this SequencerInbox is deployed on uses custom fee token
bool public immutable isUsingFeeToken;

address public eigenDAServiceManager;
address public eigenDARollupManager;

constructor(
uint256 _maxDataSize,
IReader4844 reader4844_,
Expand Down Expand Up @@ -424,6 +425,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
// verify that the blob was actually included before continuing
IRollupManager(eigenDARollupManager).verifyBlob(blobHeader, IEigenDAServiceManager(eigenDAServiceManager), blobVerificationProof);


// NOTE: to retrieve need the following
// see: https://github.com/Layr-Labs/eigenda/blob/master/api/docs/retriever.md#blobrequest
// batch header hash -> can get by computing hash(blobVerificationproof.batchMetadata.batchheader)
Expand Down Expand Up @@ -815,6 +817,15 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
emit OwnerFunctionCalled(8);
}

/// @notice Allows the rollup owner to sync the rollup address
function updateRollupAddress() external {
if (msg.sender != IOwnable(rollup).owner())
revert NotOwner(msg.sender, IOwnable(rollup).owner());
IOwnable newRollup = bridge.rollup();
if (rollup == newRollup) revert RollupNotChanged();
rollup = newRollup;
}

function isValidKeysetHash(bytes32 ksHash) external view returns (bool) {
return dasKeySetInfo[ksHash].isValidKeyset;
}
Expand Down
4 changes: 2 additions & 2 deletions test/foundry/BridgeCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ contract BridgeCreatorTest is Test {
BridgeCreator.BridgeContracts ethBasedTemplates =
BridgeCreator.BridgeContracts({
bridge: new Bridge(),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, 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, rollupManager, true),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true),
inbox: new ERC20Inbox(MAX_DATA_SIZE),
rollupEventInbox: new ERC20RollupEventInbox(),
outbox: new ERC20Outbox()
Expand Down
13 changes: 11 additions & 2 deletions test/foundry/ERC20Outbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ contract ERC20OutboxTest is AbsOutboxTest {

function setUp() public {
// deploy token, bridge and outbox
nativeToken = new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this));

// hardcoded proof in tests assume that this contract is deployed at the repsective address
IERC20 nativeTokenCode = new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this));
nativeToken = IERC20(0xFEfC6BAF87cF3684058D62Da40Ff3A795946Ab06);
vm.etch(address(nativeToken), address(nativeTokenCode).code);
deal(address(nativeToken), address(this), 1_000_000);

bridge = IBridge(TestUtil.deployProxy(address(new ERC20Bridge())));
erc20Bridge = ERC20Bridge(address(bridge));
outbox = IOutbox(TestUtil.deployProxy(address(new ERC20Outbox())));
Expand Down Expand Up @@ -51,7 +57,10 @@ contract ERC20OutboxTest is AbsOutboxTest {
);

// create msg receiver on L1
ERC20L2ToL1Target target = new ERC20L2ToL1Target();
// hardcoded proof in tests assume that this contract is deployed at the repsective address
ERC20L2ToL1Target targetCode = new ERC20L2ToL1Target();
ERC20L2ToL1Target target = ERC20L2ToL1Target(0x87B2d08110B7D50861141D7bBDd49326af3Ecb31);
vm.etch(address(target), address(targetCode).code);
target.setOutbox(address(outbox));

//// execute transaction
Expand Down
46 changes: 30 additions & 16 deletions test/foundry/RollupCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ contract RollupCreatorTest is Test {
BridgeCreator.BridgeContracts public ethBasedTemplates =
BridgeCreator.BridgeContracts({
bridge: new Bridge(),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, dummyEigenDAServiceManager, rollupManager, false),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, 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, rollupManager, true),
sequencerInbox: new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true),
inbox: new ERC20Inbox(MAX_DATA_SIZE),
rollupEventInbox: new ERC20RollupEventInbox(),
outbox: new ERC20Outbox()
Expand Down Expand Up @@ -126,18 +126,23 @@ contract RollupCreatorTest is Test {
address[] memory validators = new address[](2);
validators[0] = makeAddr("validator1");
validators[1] = makeAddr("validator2");

RollupCreator.RollupDeploymentParams memory deployParams = RollupCreator
.RollupDeploymentParams({
config: config,
batchPosters: batchPosters,
validators: validators,
maxDataSize: MAX_DATA_SIZE,
nativeToken: address(0),
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager
});

address eigenDASvcManager = makeAddr("eigenDASvcManager");
address eigenDARollupManager = makeAddr("rollupManager");

RollupCreator.RollupDeploymentParams memory deployParams = RollupCreator.RollupDeploymentParams({
config: config,
batchPosters: batchPosters,
validators: validators,
maxDataSize: MAX_DATA_SIZE,
nativeToken: address(0),
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager,
eigenDAServiceManager: eigenDASvcManager,
eigenDARollupManager: eigenDARollupManager
});

address rollupAddress = rollupCreator.createRollup{value: factoryDeploymentFunds}(
deployParams
);
Expand Down Expand Up @@ -283,6 +288,9 @@ contract RollupCreatorTest is Test {
validators[0] = makeAddr("validator1");
validators[1] = makeAddr("validator2");

address eigenDASvcManager = makeAddr("eigenDASvcManager");
address eigenDARollupManager = makeAddr("rollupManager");

RollupCreator.RollupDeploymentParams memory deployParams = RollupCreator
.RollupDeploymentParams({
config: config,
Expand All @@ -292,7 +300,9 @@ contract RollupCreatorTest is Test {
nativeToken: nativeToken,
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager
batchPosterManager: batchPosterManager,
eigenDAServiceManager: eigenDASvcManager,
eigenDARollupManager: eigenDARollupManager
});

address rollupAddress = rollupCreator.createRollup(deployParams);
Expand Down Expand Up @@ -435,6 +445,8 @@ contract RollupCreatorTest is Test {
address[] memory validators = new address[](2);
validators[0] = makeAddr("validator1");
validators[1] = makeAddr("validator2");
address eigenDASvcManager = makeAddr("eigenDASvcManager");
address eigenDARollupManager = makeAddr("rollupManager");

RollupCreator.RollupDeploymentParams memory deployParams = RollupCreator
.RollupDeploymentParams({
Expand All @@ -445,7 +457,9 @@ contract RollupCreatorTest is Test {
nativeToken: address(0),
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager
batchPosterManager: batchPosterManager,
eigenDAServiceManager: eigenDASvcManager,
eigenDARollupManager: eigenDARollupManager
});
address rollupAddress = rollupCreator.createRollup{value: factoryDeploymentFunds}(
deployParams
Expand Down
Loading

0 comments on commit 63bdd82

Please sign in to comment.