Skip to content

Commit

Permalink
Merge branch 'develop' into cache-program-address
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth authored Jun 25, 2024
2 parents cc53496 + a6e8efa commit 40caf7c
Show file tree
Hide file tree
Showing 17 changed files with 1,671 additions and 13,668 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/contract-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,64 @@ jobs:

- name: Test 4844
run: yarn test:4844
test-e2e:
name: Test e2e
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: OffchainLabs/actions/run-nitro-test-node@main
with:
l3-node: true
no-token-bridge: true
no-l3-token-bridge: true
nitro-contracts-branch: '${{ github.head_ref }}'

- 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: Compile contracts
run: yarn build

- name: Run e2e tests
run: yarn test:e2e
test-e2e-custom-fee-token:
name: Test e2e custom fee token
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: OffchainLabs/actions/run-nitro-test-node@main
with:
l3-node: true
args: --l3-fee-token
no-token-bridge: true
no-l3-token-bridge: true
nitro-contracts-branch: '${{ github.head_ref }}'

- 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: Compile contracts
run: yarn build

- name: Run e2e tests
run: yarn test:e2e
3 changes: 2 additions & 1 deletion .github/workflows/slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ jobs:
- uses: actions/checkout@v4

- name: Run Slither
uses: crytic/slither-action@v0.3.1
uses: crytic/slither-action@v0.4.0
id: slither
with:
sarif: results.sarif
fail-on: medium
slither-args: --skip-assembly

- name: Upload SARIF file
if: always()
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ src/lib/abi/**
.nyc_output
out/**
lib/**
src/mocks/MultiCallTest.sol
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"deploy-factory": "hardhat run scripts/deployment.ts",
"deploy-eth-rollup": "hardhat run scripts/createEthRollup.ts",
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts",
"create-rollup-testnode": "hardhat run scripts/local-deployment/deployCreatorAndCreateRollup.ts"
"create-rollup-testnode": "hardhat run scripts/local-deployment/deployCreatorAndCreateRollup.ts",
"deploy-cachemanager-testnode": "hardhat run scripts/local-deployment/deployCacheManager.ts"
},
"dependencies": {
"@offchainlabs/upgrade-executor": "1.1.0-beta.0",
Expand Down
28 changes: 26 additions & 2 deletions scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import {
bytecode as UpgradeExecutorBytecode,
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
import { Toolkit4844 } from '../test/contract/toolkit4844'
import { ArbSys__factory } from '../build/types'
import { ARB_SYS_ADDRESS } from '@arbitrum/sdk/dist/lib/dataEntities/constants'
import { ArbOwner__factory, ArbSys__factory } from '../build/types'

const INIT_CACHE_SIZE = 536870912
const INIT_DECAY = 10322197911
const ARB_OWNER_ADDRESS = '0x0000000000000000000000000000000000000070'
const ARB_SYS_ADDRESS = '0x0000000000000000000000000000000000000064'

// Define a verification function
export async function verifyContract(
Expand Down Expand Up @@ -236,6 +240,26 @@ export async function deployAllContracts(
}
}

export async function deployAndSetCacheManager(
chainOwnerWallet: any,
verify: boolean = true
) {
const cacheManager = await deployContract(
'CacheManager',
chainOwnerWallet,
[INIT_CACHE_SIZE, INIT_DECAY],
verify
)

const arbOwner = ArbOwner__factory.connect(
ARB_OWNER_ADDRESS,
chainOwnerWallet
)
await (await arbOwner.addWasmCacheManager(cacheManager.address)).wait()

return cacheManager
}

// Check if we're deploying to an Arbitrum chain
export async function _isRunningOnArbitrum(signer: any): Promise<boolean> {
const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer)
Expand Down
17 changes: 0 additions & 17 deletions scripts/genNetwork.ts

This file was deleted.

32 changes: 32 additions & 0 deletions scripts/local-deployment/deployCacheManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { deployAndSetCacheManager } from '../deploymentUtils'

async function main() {
/// read env vars needed for deployment
let chainOwnerPrivKey = process.env.CHAIN_OWNER_PRIVKEY as string
if (!chainOwnerPrivKey) {
throw new Error('CHAIN_OWNER_PRIVKEY not set')
}

const childChainRpc = process.env.CHILD_CHAIN_RPC as string
if (!childChainRpc) {
throw new Error('CHILD_CHAIN_RPC not set')
}

const chainOwnerWallet = new ethers.Wallet(
chainOwnerPrivKey,
new ethers.providers.JsonRpcProvider(childChainRpc)
)

// deploy cache manager
const cacheManager = await deployAndSetCacheManager(chainOwnerWallet, false)
console.log('Cache manager deployed at:', cacheManager.address)
}

main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})
1 change: 0 additions & 1 deletion scripts/local-deployment/deployCreatorAndCreateRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async function main() {
if (!feeToken) {
feeToken = ethers.constants.AddressZero
}
console.log('Fee token address:', feeToken)

/// deploy templates and rollup creator
console.log('Deploy RollupCreator')
Expand Down
89 changes: 23 additions & 66 deletions scripts/testSetup.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
import { JsonRpcProvider } from '@ethersproject/providers'
import { L1Network, L2Network, addCustomNetwork } from '@arbitrum/sdk'
import { L1Network, L2Network } from '@arbitrum/sdk'
import { execSync } from 'child_process'
import { Bridge__factory } from '@arbitrum/sdk/dist/lib/abi/factories/Bridge__factory'
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'

export const config = {
arbUrl: 'http://localhost:8547',
ethUrl: 'http://localhost:8545',
export function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}

export const getCustomNetworks = async (
export const getLocalNetworks = async (
l1Url: string,
l2Url: string
): Promise<{
l1Network: L1Network
l2Network: Omit<L2Network, 'tokenBridge'> & { nativeToken: string }
l2Network: Omit<L2Network, 'tokenBridge'>
}> => {
const l1Provider = new JsonRpcProvider(l1Url)
const l2Provider = new JsonRpcProvider(l2Url)
let deploymentData: string

let data = {
bridge: '',
inbox: '',
'sequencer-inbox': '',
rollup: '',
}

let sequencerContainer = execSync(
'docker ps --filter "name=sequencer" --format "{{.Names}}"'
'docker ps --filter "name=l3node" --format "{{.Names}}"'
)
.toString()
.trim()

deploymentData = execSync(
`docker exec ${sequencerContainer} cat /config/deployment.json`
`docker exec ${sequencerContainer} cat /config/l3deployment.json`
).toString()

const parsedDeploymentData = JSON.parse(deploymentData) as {
data = JSON.parse(deploymentData) as {
bridge: string
inbox: string
['sequencer-inbox']: string
rollup: string
['native-erc20-token']: string
}

const rollup = RollupAdminLogic__factory.connect(
parsedDeploymentData.rollup,
l1Provider
)
const rollup = RollupAdminLogic__factory.connect(data.rollup, l1Provider)
const confirmPeriodBlocks = await rollup.confirmPeriodBlocks()

const bridge = Bridge__factory.connect(
parsedDeploymentData.bridge,
l1Provider
)
const bridge = Bridge__factory.connect(data.bridge, l1Provider)
const outboxAddr = await bridge.allowedOutboxList(0)

const l1NetworkInfo = await l1Provider.getNetwork()
Expand All @@ -63,17 +62,16 @@ export const getCustomNetworks = async (
isArbitrum: false,
}

const l2Network: Omit<L2Network, 'tokenBridge'> & { nativeToken: string } = {
const l2Network: Omit<L2Network, 'tokenBridge'> = {
chainID: l2NetworkInfo.chainId,
confirmPeriodBlocks: confirmPeriodBlocks.toNumber(),
ethBridge: {
bridge: parsedDeploymentData.bridge,
inbox: parsedDeploymentData.inbox,
bridge: data.bridge,
inbox: data.inbox,
outbox: outboxAddr,
rollup: parsedDeploymentData.rollup,
sequencerInbox: parsedDeploymentData['sequencer-inbox'],
rollup: data.rollup,
sequencerInbox: data['sequencer-inbox'],
},
nativeToken: parsedDeploymentData['native-erc20-token'],
explorerUrl: '',
isArbitrum: true,
isCustom: true,
Expand All @@ -88,45 +86,4 @@ export const getCustomNetworks = async (
l1Network,
l2Network,
}
}

export const setupNetworks = async (l1Url: string, l2Url: string) => {
const { l1Network, l2Network: coreL2Network } = await getCustomNetworks(
l1Url,
l2Url
)
const l2Network: L2Network & { nativeToken: string } = {
...coreL2Network,
tokenBridge: {
l1CustomGateway: '',
l1ERC20Gateway: '',
l1GatewayRouter: '',
l1MultiCall: '',
l1ProxyAdmin: '',
l1Weth: '',
l1WethGateway: '',

l2CustomGateway: '',
l2ERC20Gateway: '',
l2GatewayRouter: '',
l2Multicall: '',
l2ProxyAdmin: '',
l2Weth: '',
l2WethGateway: '',
},
}

addCustomNetwork({
customL1Network: l1Network,
customL2Network: l2Network,
})

return {
l1Network,
l2Network,
}
}

export function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}
}
Loading

0 comments on commit 40caf7c

Please sign in to comment.