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

feat: Add parent chain public decorator #119

Draft
wants to merge 54 commits into
base: add-publicActionsChildChain
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
542fa73
feat: fast-withdrawal setup script (#143)
TucksonDev Jul 15, 2024
a2e7af0
refactor: bump @arbitrum/sdk from 4.0.0-alpha.4 to 4.0.0 (#151)
spsjvc Jul 17, 2024
e34d989
chore: update yarn.lock
spsjvc Jul 19, 2024
1e5a32b
chore: bump version
spsjvc Jul 19, 2024
86486d7
ci: update node modules install action (#154)
spsjvc Aug 5, 2024
264c397
ci: ignore elliptic advisories (#156)
fionnachan Aug 6, 2024
2808ec1
fix: convert big number to hex string first (#158)
spsjvc Aug 7, 2024
886e0b2
docs: update readme
spsjvc Aug 7, 2024
6d8f9e0
chore: bump version
spsjvc Aug 7, 2024
4e12681
feat: handle generating abi from proxy (#159)
spsjvc Aug 8, 2024
19b5a52
feat: organize contracts by file and version (#160)
spsjvc Aug 8, 2024
85ded16
feat: add AEP fee routing utils with examples (#80)
TucksonDev Aug 9, 2024
7f072f0
test: update implementation address in assertion (#161)
spsjvc Aug 12, 2024
e52980a
chore: omit patch number from contract version
spsjvc Aug 12, 2024
8522dd8
feat: remove deprecated createRollupPrepareConfig (#163)
spsjvc Aug 13, 2024
3266be7
feat: add support for RollupCreator v2.1 (#153)
spsjvc Aug 13, 2024
414d08a
feat: add utils for wasm module root (#155)
spsjvc Aug 13, 2024
b52e6d7
feat: use consensus v31 wasm module root (#164)
spsjvc Aug 13, 2024
c65c346
chore: bump version
spsjvc Aug 14, 2024
45745e8
feat: add getConsensusVersion util (#166)
spsjvc Aug 14, 2024
011748c
feat: update wasm utils as consensus release utils (#167)
spsjvc Aug 14, 2024
9dc8568
chore: update token bridge contracts (#165)
spsjvc Aug 14, 2024
b4634ba
feat: reduce config options in prepareChainConfig (#169)
spsjvc Aug 14, 2024
9b33e2f
chore: update yarn.lock
spsjvc Aug 15, 2024
143d415
chore: bump version
spsjvc Aug 15, 2024
057a7f0
feat: add nitro contracts v2.1 abis (#168)
spsjvc Aug 15, 2024
5f2b6ff
fix: properly export contracts (#170)
spsjvc Aug 16, 2024
f82d01e
chore: bump version
spsjvc Aug 16, 2024
36fd6fe
fix: add fast confirmer as validator (#171)
TucksonDev Aug 16, 2024
ced5193
feat: add SequencerInbox getters (#114)
chrstph-dvx Aug 19, 2024
e14d272
ci: pin nitro testnode to release (#172)
spsjvc Aug 20, 2024
3586145
chore: ignore GHSA-952p-6rrq-rcjv advisory (#174)
spsjvc Aug 26, 2024
4b6abaf
fix: make createRollupPrepareTransaction work with v1.1 (#173)
spsjvc Aug 26, 2024
3170519
feat: add SequencerInbox setters (#117)
chrstph-dvx Aug 27, 2024
e937f3c
build: bump packages and remove advisories (#175)
fionnachan Aug 27, 2024
e100388
feat: export buildSetIsBatchPoster (#176)
chrstph-dvx Aug 27, 2024
4e61b48
chore: bump version
spsjvc Aug 28, 2024
95d0a78
Feat: Add v1 RollupAdminLogic getters
chrstph-dvx Jun 27, 2024
be07399
Fetch rollupAddress from sequencerInbox in getters
chrstph-dvx Jul 2, 2024
ab36d2d
Update cache key
chrstph-dvx Jul 10, 2024
c2e8a55
Feat: Add v1 ArbOwnerPublic getters
chrstph-dvx Jun 28, 2024
02e6fdf
Feat: Add v1 ArbGasInfo getters
chrstph-dvx Jun 28, 2024
d0925ab
Use proper case for getParentBaseFeeEstimate
chrstph-dvx Jul 1, 2024
fdc7501
Feat: Add v1 upgradeExecutor getters
chrstph-dvx Jun 28, 2024
81a09e5
Feat: Add v1 SequencerInbox setters
chrstph-dvx Jun 27, 2024
795894a
Feat: Add v1 RollupAdminLogic setters
chrstph-dvx Jun 27, 2024
2dfedf9
Fetch rollupAddress from sequencerInbox in setters
chrstph-dvx Jul 2, 2024
e5d1cb9
Feat: Add v1 ArbOwnerPublic setters
chrstph-dvx Jun 28, 2024
8a219dd
Rename setMaxTxGasLimit
chrstph-dvx Jul 1, 2024
3e8811c
Feat: Add v1 upgradeExecutor setters
chrstph-dvx Jun 28, 2024
5beddc0
Feat: Add v1 publicActionsChildChain
chrstph-dvx Jul 1, 2024
3c5a929
Update getParentBaseFeeEstimate unit test
chrstph-dvx Jul 1, 2024
a326949
Feat: Add v1 publicActions for parent chain
chrstph-dvx Jun 27, 2024
ef6ab80
Change chains for unit test
chrstph-dvx Jul 10, 2024
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BASESCAN_API_KEY=
NITRO_TESTNODE_DEPLOYER_PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659

NITRO_TESTNODE_L2_ROLLUP_OWNER_PRIVATE_KEY=0xdc04c5399f82306ec4b4d654a342f40e2e0620fe39950d967e1e574b32d4dd36
NITRO_TESTNODE_L2_TOKEN_BRIDGE_DEPLOYER_PRIVATE_KEY=0xadd3d9301e184194943ce6244aa25c90e73c5843db16a994d202091f97f5bb27
NITRO_TESTNODE_L2_TOKEN_BRIDGE_DEPLOYER_PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659

NITRO_TESTNODE_L3_ROLLUP_OWNER_PRIVATE_KEY=0xecdf21cb41c65afb51f91df408b7656e2c8739a5877f2814add0afd780cc210e
NITRO_TESTNODE_L3_TOKEN_BRIDGE_DEPLOYER_PRIVATE_KEY=0xadd3d9301e184194943ce6244aa25c90e73c5843db16a994d202091f97f5bb27
57 changes: 11 additions & 46 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,41 @@ env:
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}

jobs:
install:
name: 'Install'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

audit:
name: 'Audit'
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Run audit
run: yarn audit:ci

check-formatting:
name: 'Check Formatting'
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Check formatting with Prettier
run: yarn prettier:check

test-unit:
name: Test (Unit)
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Copy .env
run: cp ./.env.example ./.env
Expand All @@ -84,30 +61,18 @@ jobs:
test-integration:
name: Test (Integration)
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Set up the local node
uses: OffchainLabs/actions/run-nitro-test-node@main
uses: OffchainLabs/actions/run-nitro-test-node@feat-simplify
with:
nitro-testnode-ref: 1647de2c5f75ee0fbe5986e3f20d35bc75191ea6 # https://github.com/OffchainLabs/nitro-testnode/pull/42
# Use simple mode
no-simple: false
# RollupCreator on L1 is deployed by default
# RollupCreator on L2 is deployed with --l3node
l3-node: true
# L3 node with custom fee token when using --l3-fee-token
args: --l3-fee-token
nitro-testnode-ref: release
args: --tokenbridge --l3node --l3-token-bridge --l3-fee-token

- name: Copy .env
run: cp ./.env.example ./.env
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Arbitrum Orbit SDK

> [!WARNING]
> Disclaimer: This project is an Alpha release and should not be used in a production environment. We are working on getting it ready for mainnet deployments, meanwhile please use it at your own discretion.

TypeScript SDK for building [Arbitrum Orbit](https://arbitrum.io/orbit) chains.

## Installation

Make sure you are using Node v18 or greater.
Make sure you are using Node.js v18 or greater.

```bash
yarn add @arbitrum/orbit-sdk viem@^1.20.0
Expand Down
7 changes: 1 addition & 6 deletions audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@
// from: @arbitrum/token-bridge-contracts>@openzeppelin/contracts-upgradeable
// from: @arbitrum/nitro-contracts>@openzeppelin/contracts
// from: @arbitrum/token-bridge-contracts>@openzeppelin/contracts
"GHSA-9vx6-7xxf-x967",
// https://github.com/advisories/GHSA-grv7-fg5c-xmjg
// Uncontrolled resource consumption in braces
// eslint and hardhat dependency, only used in dev
// from: hardhat>braces & eslint>braces
"GHSA-grv7-fg5c-xmjg"
"GHSA-9vx6-7xxf-x967"
]
}
2 changes: 1 addition & 1 deletion examples/create-rollup-custom-fee-token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const createRollupConfig = createRollupPrepareDeploymentParamsConfig(parentChain
await createRollup({
params: {
config: createRollupConfig,
batchPoster,
batchPosters: [batchPoster],
validators: [validator],
nativeToken,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/create-rollup-custom-fee-token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function main() {
await createRollup({
params: {
config: createRollupConfig,
batchPoster,
batchPosters: [batchPoster],
validators: [validator],
nativeToken,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/create-rollup-custom-fee-token/low_level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function main() {
owner: deployer.address,
chainConfig,
}),
batchPoster,
batchPosters: [batchPoster],
validators: [validator],
nativeToken,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/create-rollup-eth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createRollupConfig = createRollupPrepareDeploymentParamsConfig(parentChain
await createRollup({
params: {
config: createRollupConfig,
batchPoster,
batchPosters: [batchPoster],
validators: [validator],
},
account: deployer,
Expand Down
2 changes: 1 addition & 1 deletion examples/create-rollup-eth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function main() {
await createRollup({
params: {
config: createRollupConfig,
batchPoster,
batchPosters: [batchPoster],
validators: [validator],
},
account: deployer,
Expand Down
2 changes: 1 addition & 1 deletion examples/create-rollup-eth/low_level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function main() {
owner: deployer.address,
chainConfig,
}),
batchPoster,
batchPosters: [batchPoster],
validators: [validator],
},
account: deployer.address,
Expand Down
18 changes: 18 additions & 0 deletions examples/setup-aep-fee-router/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Address of the Rollup contract
ROLLUP_ADDRESS=

# Private key of the account with executor privileges in the UpgradeExecutor admin contract for the chain
# (usually, the deployer of the chain)
CHAIN_OWNER_PRIVATE_KEY=

# Orbit chain configuration
ORBIT_CHAIN_ID=
ORBIT_CHAIN_RPC=

# Parent chain id
PARENT_CHAIN_ID=1

# Parent chain target address. It will receive 10% of the chain revenue on L1
# NOTE: This is the ParentToChildRewardRouter contract on Ethereum (https://etherscan.io/address/0x40Cd7D713D7ae463f95cE5d342Ea6E7F5cF7C999)
# that bridges the funds received to the Arbitrum Foundation Treasury Timelock contract on Arbitrum One (https://arbiscan.io/address/0xbFc1FECa8B09A5c5D3EFfE7429eBE24b9c09EF58)
PARENT_CHAIN_TARGET_ADDRESS=0x40Cd7D713D7ae463f95cE5d342Ea6E7F5cF7C999
57 changes: 57 additions & 0 deletions examples/setup-aep-fee-router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Arbitrum Orbit SDK

## Setup fee routing for Orbit chains settling to non-Arbitrum chains (including Ethereum)

This example script shows how to setup the appropriate fee routing to comply with the [Arbitrum Expansion Program](https://forum.arbitrum.foundation/t/the-arbitrum-expansion-program-and-developer-guild/20722) requirement of sharing 10% of the revenue back to the Arbitrum ecosystem.

The script performs the following operations:

1. Obtain all chain contracts (needed to execute the next steps)
2. Obtain the current fee collectors of the chain: Orbit base fee collector, Orbit surplus fee collector, Parent chain surplus fee collector
3. Deploy the ChildToParentRouter contract, configured to send the amounts received to the appropriate Arbitrum Foundation or Arbitrum DAO controlled address on the parent chain
4. Deploy a RewardDistributor contract for each different fee collector account, configured to distribute 90% of the amounts received to the current fee collector, and 10% to the ChildToParentRouter contract
5. Set each of the fee collectors to the RewardDistributor contracts

Note that if all three fee types are collected by the same address, only one RewardDistributor contract will be deployed that will collect all those fees.

## Variables needed

- ROLLUP_ADDRESS: address of the Rollup contract
- CHAIN_OWNER_PRIVATE_KEY: private key of the account with executor privileges in the UpgradeExecutor admin contract for the chain
- ORBIT_CHAIN_ID: chainId of the Orbit chain
- ORBIT_CHAIN_RPC: RPC of the Orbit chain
- PARENT_CHAIN_ID: chainId of the parent chain (should be a non-Arbitrum chain, including Ethereum)
- PARENT_CHAIN_TARGET_ADDRESS: address on the parent chain where 10% of the revenue will be sent to (more information below)

### What PARENT_CHAIN_TARGET_ADDRESS to use

When executing this script, the RewardDistributor contract will be configured to send 10% of the funds received (10% of the revenue of the chain) to the address specified in PARENT_CHAIN_TARGET_ADDRESS, in the parent chain.

The PARENT_CHAIN_TARGET_ADDRESS should be an address controlled by the Arbitrum Foundation or the Arbitrum DAO. For L2 Orbit chains settling to Ethereum that use ETH as the native gas token, this variable should be `0x40Cd7D713D7ae463f95cE5d342Ea6E7F5cF7C999`, which is a ParentToChildRewardRouter contract that sends its balance in ETH to the Arbitrum Foundation Treasury Timelock contract on Arbitrum One.

If your chain is an L2 Orbit chain that uses a different native gas token, or if it is an L3 Orbit chain that settles to a non-Arbitrum chain, you should set PARENT_CHAIN_TARGET_ADDRESS to a different address. Please reach out to the Arbitrum Foundation to get the appropriate address.

## Setup

1. Install dependencies

```bash
yarn install
```

2. Create .env file and add the env vars

```bash
cp .env.example .env
```

3. Run the example
```bash
yarn dev
```

## References

- [Arbitrum Expansion Program governance forum post](https://forum.arbitrum.foundation/t/the-arbitrum-expansion-program-and-developer-guild/20722)
- [ChildToParentRouter contract](https://github.com/OffchainLabs/fund-distribution-contracts/blob/main/src/FeeRouter/ChildToParentRewardRouter.sol)
- [RewardDistributor contract](https://github.com/OffchainLabs/fund-distribution-contracts/blob/main/src/RewardDistributor.sol)
Loading