Skip to content

Commit

Permalink
Merge pull request #57 from OffchainLabs/develop
Browse files Browse the repository at this point in the history
release: 1.1.0
  • Loading branch information
gzeoneth authored Oct 26, 2023
2 parents a1cdec7 + 5e55e14 commit 7ebe29f
Show file tree
Hide file tree
Showing 93 changed files with 8,190 additions and 1,290 deletions.
7 changes: 7 additions & 0 deletions .env.sample.goerli
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ROLLUP_CREATOR_ADDRESS=""
ARBISCAN_API_KEY=""
## deployer key
DEVNET_PRIVKEY=""

## optional - address of already deployed ERC20 token which shall be used as rollup's fee token
FEE_TOKEN_ADDRESS=""
25 changes: 25 additions & 0 deletions .github/workflows/contract-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ on:
- develop

jobs:
test-unit:
name: Test unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Setup node/yarn
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install packages
run: yarn

- name: Run unit tests
run: forge test
tests:
name: Contract tests
runs-on: ubuntu-8
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ deployments/
/test/prover/proofs/*.json
/test/prover/spec-proofs/*.json
/test/storage/*-old.dot
scripts/config.ts
forge-cache/
out/
.env
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ coverage/**
deployments/**
src/lib/abi/**
.nyc_output
out/**
lib/**
2 changes: 1 addition & 1 deletion deploy/SequencerInbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = async hre => {
const { deploy } = deployments
const { deployer } = await getNamedAccounts()

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

module.exports.tags = ['SequencerInbox']
Expand Down
2 changes: 1 addition & 1 deletion deploy/SequencerInboxStubCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async hre => {
}
await deploy('SequencerInboxStub', {
from: deployer,
args: [bridge.address, deployer, maxTime],
args: [bridge.address, deployer, maxTime, 117964],
})
}

Expand Down
14 changes: 14 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[profile.default]
src = 'src'
out = 'out'
libs = ['node_modules', 'lib']
test = 'test/foundry'
cache_path = 'forge-cache'
optimizer = true
optimizer_runs = 20000
via_ir = false

[fmt]
number_underscore = 'thousands'
line_length = 100
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
25 changes: 25 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import '@typechain/hardhat'
import 'solidity-coverage'
import 'hardhat-gas-reporter'
import 'hardhat-ignore-warnings'
import dotenv from 'dotenv'

dotenv.config()

const solidity = {
compilers: [
Expand Down Expand Up @@ -89,6 +92,12 @@ module.exports = {
? [process.env['DEVNET_PRIVKEY']]
: [],
},
sepolia: {
url: 'https://sepolia.infura.io/v3/' + process.env['INFURA_KEY'],
accounts: process.env['DEVNET_PRIVKEY']
? [process.env['DEVNET_PRIVKEY']]
: [],
},
rinkeby: {
url: 'https://rinkeby.infura.io/v3/' + process.env['INFURA_KEY'],
accounts: process.env['DEVNET_PRIVKEY']
Expand All @@ -107,6 +116,12 @@ module.exports = {
? [process.env['DEVNET_PRIVKEY']]
: [],
},
arbSepolia: {
url: 'https://sepolia-rollup.arbitrum.io/rpc',
accounts: process.env['DEVNET_PRIVKEY']
? [process.env['DEVNET_PRIVKEY']]
: [],
},
arb1: {
url: 'https://arb1.arbitrum.io/rpc',
accounts: process.env['MAINNET_PRIVKEY']
Expand All @@ -127,11 +142,13 @@ module.exports = {
apiKey: {
mainnet: process.env['ETHERSCAN_API_KEY'],
goerli: process.env['ETHERSCAN_API_KEY'],
sepolia: process.env['ETHERSCAN_API_KEY'],
rinkeby: process.env['ETHERSCAN_API_KEY'],
arbitrumOne: process.env['ARBISCAN_API_KEY'],
arbitrumTestnet: process.env['ARBISCAN_API_KEY'],
nova: process.env['NOVA_ARBISCAN_API_KEY'],
arbGoerliRollup: process.env['ARBISCAN_API_KEY'],
arbSepolia: process.env['ARBISCAN_API_KEY'],
},
customChains: [
{
Expand All @@ -150,6 +167,14 @@ module.exports = {
browserURL: 'https://goerli.arbiscan.io/',
},
},
{
network: 'arbSepolia',
chainId: 421614,
urls: {
apiURL: 'https://sepolia-explorer.arbitrum.io/api',
browserURL: 'https://sepolia-explorer.arbitrum.io/',
},
},
],
},
mocha: {
Expand Down
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at e8a047
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arbitrum/nitro-contracts",
"version": "1.0.2",
"version": "1.1.0",
"description": "Layer 2 precompiles and rollup for Arbitrum Nitro",
"author": "Offchain Labs, Inc.",
"license": "BUSL-1.1",
Expand All @@ -9,12 +9,15 @@
"url": "git+https://github.com/offchainlabs/nitro-contracts.git"
},
"files": [
"src/"
"src/",
"build/contracts/src",
"build/contracts/@openzeppelin"
],
"bugs": {
"url": "https://github.com/offchainlabs/nitro-contracts/issues"
},
"scripts": {
"prepublishOnly": "hardhat clean && hardhat compile",
"build": "hardhat compile",
"lint:test": "eslint ./test",
"solhint": "solhint -f table src/**/*.sol",
Expand All @@ -24,15 +27,22 @@
"build:0.7": "INTERFACE_TESTER_SOLC_VERSION=0.7.0 yarn run build",
"test:compatibility": "yarn run build:0.6 && yarn run build:0.7",
"test:storage": "./test/storage/test.bash",
"postinstall": "patch-package"
"test:e2e": "hardhat test test/e2e/*.ts",
"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"
},
"dependencies": {
"@offchainlabs/upgrade-executor": "1.1.0-beta.0",
"@openzeppelin/contracts": "4.5.0",
"@openzeppelin/contracts-upgradeable": "4.5.2",
"patch-package": "^6.4.7"
},
"private": false,
"devDependencies": {
"@arbitrum/sdk": "^3.1.3",
"@ethersproject/providers": "^5.7.2",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
Expand All @@ -45,6 +55,7 @@
"@typescript-eslint/eslint-plugin-tslint": "^5.27.1",
"@typescript-eslint/parser": "^5.14.0",
"chai": "^4.3.4",
"dotenv": "^16.3.1",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-mocha": "^9.0.0",
Expand Down
5 changes: 5 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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/
33 changes: 33 additions & 0 deletions scripts/config.ts.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ethers } from 'ethers'

// 90% of Geth's 128KB tx size limit, leaving ~13KB for proving
// This need to be adjusted for Orbit chains
export const maxDataSize = 117964

export const config = {
rollupConfig: {
confirmPeriodBlocks: ethers.BigNumber.from('45818'),
extraChallengeTimeBlocks: ethers.BigNumber.from('200'),
stakeToken: ethers.constants.AddressZero,
baseStake: ethers.utils.parseEther('1'),
wasmModuleRoot:
'0xda4e3ad5e7feacb817c21c8d0220da7650fe9051ece68a3f0b1c5d38bbb27b21',
owner: '0x1234123412341234123412341234123412341234',
loserStakeEscrow: ethers.constants.AddressZero,
chainId: ethers.BigNumber.from('13331370'),
chainConfig:
'{"chainId":13331370,"homesteadBlock":0,"daoForkBlock":null,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"berlinBlock":0,"londonBlock":0,"clique":{"period":0,"epoch":0},"arbitrum":{"EnableArbOS":true,"AllowDebugPrecompiles":false,"DataAvailabilityCommittee":false,"InitialArbOSVersion":10,"InitialChainOwner":"0x1234123412341234123412341234123412341234","GenesisBlockNum":0}}',
genesisBlockNum: ethers.BigNumber.from('0'),
sequencerInboxMaxTimeVariation: {
delayBlocks: ethers.BigNumber.from('5760'),
futureBlocks: ethers.BigNumber.from('12'),
delaySeconds: ethers.BigNumber.from('86400'),
futureSeconds: ethers.BigNumber.from('3600'),
},
},
validators: [
'0x1234123412341234123412341234123412341234',
'0x1234512345123451234512345123451234512345',
],
batchPoster: '0x1234123412341234123412341234123412341234',
}
41 changes: 41 additions & 0 deletions scripts/createERC20Rollup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { Signer } from 'ethers'
import { createRollup } from './rollupCreation'
import { TestToken__factory } from '../build/types'

async function deployERC20Token(deployer: Signer): Promise<string> {
const factory = await new TestToken__factory(deployer).deploy(
ethers.utils.parseEther('1000000000')
)
const feeToken = await factory.deployed()

return feeToken.address
}

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

let customFeeTokenAddress = process.env.FEE_TOKEN_ADDRESS
if (!customFeeTokenAddress) {
console.log(
'FEE_TOKEN_ADDRESS env var not provided, deploying new ERC20 token'
)
customFeeTokenAddress = await deployERC20Token(deployer)
}
if (!ethers.utils.isAddress(customFeeTokenAddress)) {
throw new Error(
'Fee token address ' + customFeeTokenAddress + ' is not a valid address!'
)
}

console.log('Creating new rollup with', customFeeTokenAddress, 'as fee token')
await createRollup(customFeeTokenAddress)
}

main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})
13 changes: 13 additions & 0 deletions scripts/createEthRollup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import '@nomiclabs/hardhat-ethers'
import { createRollup } from './rollupCreation'

async function main() {
await createRollup()
}

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

0 comments on commit 7ebe29f

Please sign in to comment.