Skip to content
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

Deploy RollupCreator and document the process #13

Merged
merged 5 commits into from
Jul 25, 2024
Merged
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
3 changes: 3 additions & 0 deletions .env.sample.goerli
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ROLLUP_CREATOR_ADDRESS=""
ARBISCAN_API_KEY=""
ETHERSCAN_API_KEY=""
## deployer key
DEVNET_PRIVKEY=""
INFURA_KEY=""

## optional - address of already deployed ERC20 token which shall be used as rollup's fee token
FEE_TOKEN_ADDRESS=""
ESPRESSO_LIGHT_CLIENT_ADDRESS=""
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Arbitrum Nitro Rollup Contracts

This is the package with the smart contract code that powers Arbitrum Nitro.
This is the package with the smart contract code that powers Arbitrum Nitro and Espresso integration.
It includes the rollup and fraud proof smart contracts, as well as interfaces for interacting with precompiles.

For more information see https://developer.arbitrum.io/intro
## Deploy contracts to Sepolia

For the deployed addresses of these contracts for Arbitrum chains see https://developer.arbitrum.io/useful-addresses

For the token bridge contracts see https://github.com/OffchainLabs/token-bridge-contracts
### 1. Compile contracts

Compile these contracts locally by running

Expand All @@ -16,18 +14,40 @@ git clone https://github.com/offchainlabs/nitro-contracts
cd nitro-contracts
yarn install
yarn build
yarn build:forge
```

### 2. Setup environment variables and config files

Copy `.env.sample.goerli` to `.env` and fill in the values. Add an [Etherscan api key](https://docs.etherscan.io/getting-started/viewing-api-usage-statistics), [Infura api key](https://docs.infura.io/dashboard/create-api) and a private key which has some funds on sepolia.
This private key will be used to deploy the rollup. We have already deployed a `ROLLUP_CREATOR_ADDRESS` which has all the associated espresso contracts initialized.

If you want to deploy your own rollup creator, you can leave the `ROLLUP_CREATOR_ADDRESS` empty and follow the steps on step 3.

If you want to use the already deployed `RollupCreator`, you can update the `ROLLUP_CREATOR_ADDRESS` with the address of the deployed rollup creator [here](espresso-deployments/sepolia.json) and follow the steps on step 4 to create the rollup.

### 3. Deploy Rollup Creator and initialize the espresso contracts

Change the `config.ts.example` to `config.ts` and run the following command to deploy the rollup creator and initialize the espresso contracts.

`npx hardhat run scripts/deployment.ts --network sepolia`

This will deploy the rollup creator and initialize the espresso contracts.

### 4. Create the rollup

Change the `config.ts.example` to `config.ts` and run the following command to create the rollup if you haven't already done so.

`npx hardhat run scripts/createEthRollup.ts --network sepolia`

## Deployed contract addresses

Deployed contract addresses can be found in the [espress-deployments folder](./espresso-deployments/).

## License

Nitro is currently licensed under a [Business Source License](./LICENSE.md), similar to our friends at Uniswap and Aave, with an "Additional Use Grant" to ensure that everyone can have full comfort using and running nodes on all public Arbitrum chains.

The Additional Use Grant also permits the deployment of the Nitro software, in a permissionless fashion and without cost, as a new blockchain provided that the chain settles to either Arbitrum One or Arbitrum Nova.

For those that prefer to deploy the Nitro software either directly on Ethereum (i.e. an L2) or have it settle to another Layer-2 on top of Ethereum, the [Arbitrum Expansion Program (the "AEP")](https://docs.arbitrum.foundation/assets/files/Arbitrum%20Expansion%20Program%20Jan182024-4f08b0c2cb476a55dc153380fa3e64b0.pdf) was recently established. The AEP allows for the permissionless deployment in the aforementioned fashion provided that 10% of net revenue is contributed back to the Arbitrum community in accordance with the requirements of the AEP.

## Contact

Discord - [Arbitrum](https://discord.com/invite/5KE54JwyTs)

Twitter: [Arbitrum](https://twitter.com/arbitrum)
26 changes: 26 additions & 0 deletions espresso-deployments/sepolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"EthBridge": "0x3D65C887c92450f4FCd222F38813A3204269716e",
"EthSequencerInbox": "0xC2adA1144BB5BE16931F124656E0900566131e8E",
"EthInbox": "0x681Cc38E2C70Ca6b023a54e0dA41274796b4a87b",
"EthRollupEventInbox": "0xFE4d1d116bD0Dd6AD2e2A5f420C0D8eF91F0706f",
"EthOutbox": "0x81E0ca0C2c82f9a677b033eF410933eb11B3f6F7",
"ERC20Bridge": "0xf2e74929074d7c9b1947e232e0FA0D71DA733240",
"ERC20SequencerInbox": "0x2415292b8f15eD570E9925fFCB7C5E808926b0E2",
"ERC20Inbox": "0x0b6c993E93c371FbfC619FCA65dE5cBa99813644",
"ERC20RollupEventInbox": "0x3C4079c7FB37d27305A45106d3972705eddfc238",
"ERC20Outbox": "0xd01030a5dD5BD17757CcCA156e48b2Bc62d02B6e",
"BridgeCreator": "0x3D65C887c92450f4FCd222F38813A3204269716e",
"OneStepProver0": "0x685c80B73A7e47456b3b35A69625dFBB1B4546E3",
"OneStepProverMemory": "0xb08dD09B3f2C5Dd3630e88E22984F374BA8406c3",
"OneStepProverMath": "0x97f584bB16624dE35af1bbd96Eb9563EA65fC9D5",
"OneStepProverHostIo": "0xd685fe703891747626599039B6754665222a8A41",
"OneStepProofEntry": "0x34B5A7ea1d77D811710aA04F33a4465d8DDEc99c",
"ChallengeManager": "0x5EC02903570640E1f46d5053F3953BF5a61B5aD2",
"RollupAdminLogic": "0x7a78217012D7d9dCF3f80470688939779185bf8F",
"RollupUserLogic": "0x67C288C6D5633C32F060E90bFdc26e25ceB92913",
"UpgradeExecutor": "0xD6193d507Fa3a754CD7b3Fee78df5f2946A32C73",
"ValidatorUtils": "0x95B246395C4276Acc135194a6057e6260Dc9D651",
"ValidatorWalletCreator": "0xE23a9eBDbc3F34FaaFBb4B18F8fE5727620982eC",
"RollupCreator": "0xb89a5fE9C7AdF69E809dE385225e985eE7D8DDB2",
"DeployHelper": "0xc9E13351594F838AA31671060a425442805bf150"
}
6 changes: 5 additions & 1 deletion scripts/createEthRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import '@nomiclabs/hardhat-ethers'
import { createRollup } from './rollupCreation'

async function main() {
const feeToken = undefined
const rollupCreatorAddress = process.env.ROLLUP_CREATOR_ADDRESS
if (!rollupCreatorAddress) {
throw new Error('ROLLUP_CREATOR_ADDRESS not set')
}

let feeToken = process.env.FEE_TOKEN_ADDRESS as string
// if fee token is not set, then use address(0) to have ETH as fee token
if (!feeToken) {
feeToken = ethers.constants.AddressZero
}
const [signer] = await ethers.getSigners()

await createRollup(signer, false, rollupCreatorAddress, feeToken)
Expand Down
52 changes: 48 additions & 4 deletions scripts/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,65 @@
import { ethers } from 'hardhat'
import { ethers, network } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { deployAllContracts } from './deploymentUtils'
import { maxDataSize } from './config'
import fs from 'fs'

async function main() {
const [signer] = await ethers.getSigners()

try {
// Deploying all contracts
const espressoLightClientAddress = process.env.ESPRESSO_LIGHT_CLIENT_ADDRESS

if (!espressoLightClientAddress) {
console.warn(
'env var ESPRESSO_LIGHT_CLIENT_ADDRESS not set, it needs to be set to deploy the RollupCreator for the espresso integration'
)
}

const contracts = await deployAllContracts(
signer,
ethers.BigNumber.from(maxDataSize),
true
true,
espressoLightClientAddress
)

const contractAddresses = {
EthBridge: contracts.bridgeCreator.address,
EthSequencerInbox: contracts.ethSequencerInbox.address,
EthInbox: contracts.ethInbox.address,
EthRollupEventInbox: contracts.ethRollupEventInbox.address,
EthOutbox: contracts.ethOutbox.address,
ERC20Bridge: contracts.erc20Bridge.address,
ERC20SequencerInbox: contracts.erc20SequencerInbox.address,
ERC20Inbox: contracts.erc20Inbox.address,
ERC20RollupEventInbox: contracts.erc20RollupEventInbox.address,
ERC20Outbox: contracts.erc20Outbox.address,
BridgeCreator: contracts.bridgeCreator.address,
OneStepProver0: contracts.prover0.address,
OneStepProverMemory: contracts.proverMem.address,
OneStepProverMath: contracts.proverMath.address,
OneStepProverHostIo: contracts.proverHostIo.address,
OneStepProofEntry: contracts.osp.address,
ChallengeManager: contracts.challengeManager.address,
RollupAdminLogic: contracts.rollupAdmin.address,
RollupUserLogic: contracts.rollupUser.address,
UpgradeExecutor: contracts.upgradeExecutor.address,
ValidatorUtils: contracts.validatorUtils.address,
ValidatorWalletCreator: contracts.validatorWalletCreator.address,
RollupCreator: contracts.rollupCreator.address,
DeployHelper: contracts.deployHelper.address,
}

// save the contract name to address mapping in a json file
fs.writeFileSync(
`./espresso-deployments/${network.name}.json`,
JSON.stringify(contractAddresses, null, 2)
)

console.info('Contract addresses are saved in the deployments folder')

// Call setTemplates with the deployed contract addresses
console.log('Waiting for the Template to be set on the Rollup Creator')

await contracts.rollupCreator.setTemplates(
contracts.bridgeCreator.address,
contracts.osp.address,
Expand Down
10 changes: 10 additions & 0 deletions scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ export async function deployAllContracts(
)
const deployHelper = await deployContract('DeployHelper', signer, [], verify)
return {
ethBridge,
ethSequencerInbox,
ethInbox,
ethRollupEventInbox,
ethOutbox,
erc20Bridge,
erc20SequencerInbox,
erc20Inbox,
erc20RollupEventInbox,
erc20Outbox,
bridgeCreator,
prover0,
proverMem,
Expand Down
Loading