Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added .github/.DS_Store
Binary file not shown.
14 changes: 11 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ src = 'src/'
out = 'out'
libs = ['node_modules', 'lib']
test = 'test/foundry'
cache_path = 'forge-cache/sol'
cache_path = 'forge-cache/sol'
optimizer = true
optimizer_runs = 20000
via_ir = false
solc_version = '0.8.9'
remappings = [
'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/',
]

[profile.yul]
src = 'yul'
out = 'out/yul'
libs = ['node_modules', 'lib']
cache_path = 'forge-cache/yul'
cache_path = 'forge-cache/yul'
remappings = []
auto_detect_remappings = false

[fmt]
number_underscore = 'thousands'
line_length = 100
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
32 changes: 31 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ module.exports = {
? [process.env['DEVNET_PRIVKEY']]
: [],
},
// for mainnet
"base-mainnet": {
url: 'https://mainnet.base.org',
accounts: [process.env['DEVNET_PRIVKEY'] as string],
gasPrice: 1000000000,
},
// for Sepolia testnet
"base-sepolia": {
url: "https://sepolia.base.org",
accounts: [process.env['DEVNET_PRIVKEY'] as string],
gasPrice: 1000000000,
},
rinkeby: {
url: 'https://rinkeby.infura.io/v3/' + process.env['INFURA_KEY'],
accounts: process.env['DEVNET_PRIVKEY']
Expand Down Expand Up @@ -150,6 +162,8 @@ module.exports = {
nova: process.env['NOVA_ARBISCAN_API_KEY'],
arbGoerliRollup: process.env['ARBISCAN_API_KEY'],
arbSepolia: process.env['ARBISCAN_API_KEY'],
"base-sepolia": process.env['ETHERSCAN_API_KEY'],
"base-mainnet": process.env['ETHERSCAN_API_KEY'],
},
customChains: [
{
Expand All @@ -172,10 +186,26 @@ module.exports = {
network: 'arbSepolia',
chainId: 421614,
urls: {
apiURL: 'https://sepolia-explorer.arbitrum.io/api',
apiURL: 'https://api-sepolia.arbiscan.io/api',
browserURL: 'https://sepolia-explorer.arbitrum.io/',
},
},
{
network: 'base-mainnet',
chainId: 8453,
urls: {
apiUrl: 'https://api.basescan.org/api',
browserURL: 'https://base.blockscout.com/',
},
},
{
network: 'base-sepolia',
chainId: 84532,
urls: {
apiUrl: 'https://api-sepolia.basescan.org/api',
browserURL: 'https://sepolia.basescan.org/',
},
}
],
},
mocha: {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"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",
"upgrade-sequencer": "hardhat run scripts/upgradeSequencer.ts",
"upgrade-avail-bridge": "hardhat run scripts/modifyAvailBridge.ts"
},
"dependencies": {
"@offchainlabs/upgrade-executor": "1.1.0-beta.0",
Expand Down
5 changes: 0 additions & 5 deletions remappings.txt

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/config.ts.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ export const config = {
'0x1234123412341234123412341234123412341234',
'0x1234512345123451234512345123451234512345',
],
batchPoster: '0x1234123412341234123412341234123412341234',
batchPosters: ['0x1234123412341234123412341234123412341234'],
batchPosterManager: '0x1234123412341234123412341234123412341234',
}
3 changes: 2 additions & 1 deletion scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export async function deployUpgradeExecutor(signer: any): Promise<Contract> {
)
const connectedFactory: ContractFactory = upgradeExecutorFac.connect(signer)
const upgradeExecutor = await connectedFactory.deploy()
console.log(`New upgradeExecutor created at address:`, upgradeExecutor.address)
return upgradeExecutor
}

Expand Down Expand Up @@ -180,7 +181,7 @@ export async function deployAllContracts(
}

// Check if we're deploying to an Arbitrum chain
async function _isRunningOnArbitrum(signer: any): Promise<Boolean> {
export async function _isRunningOnArbitrum(signer: any): Promise<Boolean> {
const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer)
try {
await arbSys.arbOSVersion()
Expand Down
43 changes: 43 additions & 0 deletions scripts/modifyAvailBridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ethers } from "hardhat";
import { _isRunningOnArbitrum } from "./deploymentUtils";
import {
abi as UpgradeExecutorABI,
bytecode as UpgradeExecutorBytecode,
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
import { config } from "./config";

async function main () {
const ExecutorContract = "0x3b7800d1d946ab4B46ae986BA20F4CCe213D55b4";
const SequencerInboxProxy = "0x0B0a949e7390CB3D15055383A58ce93c9FB07B9F";
const AvailBridgeAddress = "0xa3e9e20875b7A7461C4829663497F7c2baB9E13b";

const sequencerInbox = await ethers.getContractFactory("SequencerInbox");
const sequencerInboxFactory = sequencerInbox.attach(SequencerInboxProxy);
const bridge = await sequencerInboxFactory.bridge();

console.log("avail Bridge:", await sequencerInboxFactory.availBridge());
console.log("bridge:", bridge);

const upgradeExecutorFac = await ethers.getContractFactory(
UpgradeExecutorABI,
UpgradeExecutorBytecode
)

const upgrade = await upgradeExecutorFac.attach(ExecutorContract);

var tx = await upgrade.executeCall(SequencerInboxProxy, sequencerInbox.interface.encodeFunctionData(
"setAvailBridgeAddress",
[AvailBridgeAddress]));

console.log("tx Hash:", tx.hash)

console.log("avail Bridge (modified):", await sequencerInboxFactory.availBridge());

}

main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})
3 changes: 2 additions & 1 deletion scripts/rollupCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ export async function createRollup(feeToken?: string) {
console.log('Calling createRollup to generate a new rollup ...')
const deployParams = {
config: config.rollupConfig,
batchPoster: config.batchPoster,
batchPosters: config.batchPosters,
validators: config.validators,
maxDataSize: maxDataSize,
nativeToken: feeToken,
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FER_PER_GAS,
batchPosterManager: config.batchPosterManager
}
const createRollupTx = await rollupCreator.createRollup(deployParams, {
value: feeCost,
Expand Down
53 changes: 53 additions & 0 deletions scripts/upgradeSequencer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ethers, run } from "hardhat"
import {
abi as UpgradeExecutorABI,
bytecode as UpgradeExecutorBytecode,
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
import { maxDataSize } from "./config";
import { _isRunningOnArbitrum, deployContract } from "./deploymentUtils";
import { Toolkit4844 } from "../test/contract/toolkit4844";


async function main() {
const ExecutorContract = "0x3b7800d1d946ab4B46ae986BA20F4CCe213D55b4";
const SequencerInboxProxy = "0x0B0a949e7390CB3D15055383A58ce93c9FB07B9F";
const ProxyAdmin = "0xd801c1DD86255e27C4af45571BabAC661Fc6Af86";
const [admin] = await ethers.getSigners();

const isOnArb = await _isRunningOnArbitrum(admin)
const reader4844 = isOnArb ? ethers.constants.AddressZero : (await Toolkit4844.deployReader4844(admin)).address

const proxyAdmin = await ethers.getContractFactory("ProxyAdmin");
const proxyAdminFactory = proxyAdmin.attach(ProxyAdmin);
const tx = await proxyAdminFactory.getProxyImplementation(SequencerInboxProxy)
console.log("implementation Address (Initial): ", tx)

const sequencerInbox = await deployContract('SequencerInbox', admin, [
maxDataSize,
reader4844,
false,
])
await sequencerInbox.deployed();
console.log("sequencerInbox contract implementation:", sequencerInbox.address)

const upgradeExecutorFactory = await ethers.getContractFactory(
UpgradeExecutorABI,
UpgradeExecutorBytecode
)

const upgrade = upgradeExecutorFactory.attach(ExecutorContract);

const upgradeTx = await upgrade.executeCall(ProxyAdmin, proxyAdmin.interface.encodeFunctionData("upgrade", [SequencerInboxProxy, sequencerInbox.address]));
console.log("upgrade Tx:", upgradeTx)

const implementationTx = await proxyAdminFactory.getProxyImplementation(SequencerInboxProxy)
console.log("implementation Address:", implementationTx)
}

main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})

Binary file added src/.DS_Store
Binary file not shown.
15 changes: 14 additions & 1 deletion src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
pragma solidity >=0.6.9 <0.9.0;
pragma experimental ABIEncoderV2;

import "../data-availability/IAvailDABridge.sol";
import "../data-availability/MerkleProofInput.sol";
import "../libraries/IGasRefunder.sol";
import "./IDelayedMessageProvider.sol";
import "./IBridge.sol";
Expand All @@ -28,6 +30,8 @@ interface ISequencerInbox is IDelayedMessageProvider {
IBridge.BatchDataLocation dataLocation
);

event validateBatchDataOverAvailDA(MerkleProofInput indexed merkleProofInput);

event OwnerFunctionCalled(uint256 indexed id);

/// @dev a separate event that emits batch data when this isn't easily accessible in the tx.input
Expand Down Expand Up @@ -65,6 +69,11 @@ interface ISequencerInbox is IDelayedMessageProvider {
// solhint-disable-next-line func-name-mixedcase
function DAS_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 a avail blobpointer message
// solhint-disable-next-line func-name-mixedcase
function AVAIL_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 a das message that employs a merklesization strategy
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
Expand Down Expand Up @@ -225,5 +234,9 @@ interface ISequencerInbox is IDelayedMessageProvider {

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

function initialize(IBridge bridge_, MaxTimeVariation calldata maxTimeVariation_) external;
function initialize(
IBridge bridge_,
MaxTimeVariation calldata maxTimeVariation_,
IAvailDABridge AvailBridge
) external;
}
Loading