Commit 7b25a75e authored by Liam Horne's avatar Liam Horne

Merge remote-tracking branch 'contracts/master'

parents fde84dd1 fb884373
root = true
# defaults
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.sol]
indent_size = 4
# name of the network to deploy to e.g., kovan or mainnet
CONTRACTS_TARGET_NETWORK=
# private key for the account that will execute the deploy
CONTRACTS_DEPLOYER_KEY=
# rpc url for the node that will receive deploy transactions
CONTRACTS_RPC_URL=
* @smartcontracts @ben-chain @maurelian
name: CI - contracts
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build-test-lint:
name: Run Contracts Test Suite on Node ${{matrix.node}}
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '10', '12', '14' ]
steps:
- uses: actions/checkout@v2
- name: Setup node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
# START DEPENDENCY CACHING
- name: Cache root deps
uses: actions/cache@v1
id: cache_base
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package.json') }}
# END DEPENDENCY CACHING
- name: Install Dependencies
run: yarn install
- name: Lint
run: yarn lint:check
- name: Build
run: |
yarn clean
yarn build
- name: Test
run: yarn test
name: Build & Push to DockerHub
on:
push:
branches:
- master
- testnet
- uat
jobs:
build:
name: Build & Push to DockerHub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_READ }}
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }} | docker login -u ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME}} --password-stdin
- name: Build and push Deployer image to DockerHub
run: |
git clone https://github.com/ethereum-optimism/docker.git \
$HOME/docker
cd $HOME/docker
BRANCH=${GITHUB_REF##*/}
./build.sh -s deployer -b $BRANCH
if [ $BRANCH == 'master' ]; then
docker push ethereumoptimism/deployer:latest
elif [[ $BRANCH == 'uat' || $BRANCH == 'testnet' ]]; then
docker push ethereumoptimism/deployer:$BRANCH
fi
- name: Logout of DockerHub
run: docker logout
name: Setup & Run Integration Test Suite
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: Setup & Run Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: |
git clone https://github.com/ethereum-optimism/optimism-integration.git \
$HOME/optimism-integration
cd $HOME/optimism-integration
sed -i -Ee's#git@github.com:([^/]*)/(.*).git#https://github.com/\1/\2.git#' .gitmodules
git submodule init
git submodule update
if [ -z $GITHUB_HEAD_REF ]; then
GITHUB_HEAD_REF=${GITHUB_REF##*/}
fi
GIT_COMMIT=$(git rev-parse HEAD | head -c 8)
REMOTE=${{ github.event.pull_request.head.repo.html_url }}
echo "optimism-integration $GIT_COMMIT"
if [ -z $REMOTE ]; then
./docker/build.sh -s deployer -b $GITHUB_HEAD_REF
else
./docker/build.sh -s deployer -b $GITHUB_HEAD_REF -r $REMOTE
fi
- name: Test
run: |
cd $HOME/optimism-integration
DEPLOYER_TAG=$GITHUB_HEAD_REF ./test.sh
name: Update submodules in integration repo
on:
push:
branches:
- master
jobs:
run:
name: Update submodules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.INTEGRATION_PUSH_ACTION }}
- name: Clone repo
run: |
git clone git@github.com:ethereum-optimism/optimism-integration.git $HOME/optimism-integration
cd $HOME/optimism-integration
git submodule init && git submodule update
REPO=$(echo $GITHUB_REPOSITORY | cut -d '/' -f2)
cd $HOME/optimism-integration/$REPO
git pull origin master
- name: Commit
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
cd $HOME/optimism-integration
REPO=$(echo $GITHUB_REPOSITORY | cut -d '/' -f2)
SHORT=$(echo $GITHUB_SHA | head -c 8)
git add $REPO
git commit -m "submodule bump: $REPO $SHORT"
git push origin master
name: Auto tag-release-publish
on:
push:
branches:
- master
jobs:
tag:
name: Create tag for new version
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.create_new_tag.outputs.tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: salsify/action-detect-and-tag-new-version@v2
id: create_new_tag
release:
name: Create release
runs-on: ubuntu-latest
needs: tag
if: needs.tag.outputs.tag_name
steps:
- uses: actions/checkout@v2
- uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.tag.outputs.tag_name }}
release_name: ${{ needs.tag.outputs.tag_name }}
draft: false
prerelease: false
npm-publish:
name: Build and publish
runs-on: ubuntu-latest
needs: tag
if: needs.tag.outputs.tag_name
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
docker:
name: Build & Push to DockerHub
runs-on: ubuntu-latest
needs: tag
if: needs.tag.outputs.tag_name
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }} | docker login -u ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME}} --password-stdin
- name: Clone the docker repo
run: |
git clone https://github.com/ethereum-optimism/docker.git \
$HOME/docker
- name: Build and push Deployer image to DockerHub
run: |
cd $HOME/docker
./build.sh -s deployer -b ${{ needs.tag.outputs.tag_name }}
docker push ethereumoptimism/deployer:${{ needs.tag.outputs.tag_name }}
- name: Extract State Dump from Deployer Image
run: docker run --rm --entrypoint cat ethereumoptimism/deployer:${{ steps.get_version.outputs.VERSION }} /opt/contracts/build/dumps/state-dump.latest.json > ${{ steps.get_version.outputs.VERSION }}.json
- name: Store state dump artifact for git job
uses: actions/upload-artifact@v2
with:
name: state-dump-artifact
path: ${{ steps.get_version.outputs.VERSION }}.json
- name: Logout of DockerHub
run: docker logout
git:
name: Commit State Dump
needs: [docker, tag]
runs-on: ubuntu-latest
if: needs.tag.outputs.tag_name
steps:
- uses: actions/checkout@v2
with:
repository: ethereum-optimism/regenesis
ssh-key: ${{ secrets.REGENESIS_DEPLOY_KEY }}
- name: Download State Dump Artifact
uses: actions/download-artifact@v2
with:
name: state-dump-artifact
path: ./tags
- name: Commit to Repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: master
commit_message: Add tagged state dump artfiact
commit_user_name: GitHub Action
commit_user_email: action@github.com
commit_author: Github Action <action@github.com>
node_modules/
artifacts/
artifacts-ovm/
cache/
cache-ovm/
yarn-error.log
build/
.DS_STORE
# Coverage output
coverage/
coverage.json
# Environment variables
.env
#!/usr/bin/env node
const path = require('path')
const { spawn } = require('child_process')
const dirtree = require('directory-tree')
const main = async () => {
const task = spawn(path.join(__dirname, 'deploy.ts'))
await new Promise((resolve) => {
task.on('exit', () => {
resolve()
})
})
// Stuff below this line is currently required for CI to work properly. We probably want to
// update our CI so this is no longer necessary. But I'm adding it for backwards compat so we can
// get the hardhat-deploy stuff merged. Woot.
const nicknames = {
'Lib_AddressManager': 'AddressManager',
'mockOVM_BondManager': 'OVM_BondManager'
}
const contracts = dirtree(
path.resolve(__dirname, `../deployments/custom`)
).children.filter((child) => {
return child.extension === '.json'
}).reduce((contracts, child) => {
const contractName = child.name.replace('.json', '')
const artifact = require(path.resolve(__dirname, `../deployments/custom/${child.name}`))
contracts[nicknames[contractName] || contractName] = artifact.address
return contracts
}, {})
// We *must* console.log here because CI will pipe the output of this script into an
// addresses.json file. Also something we should probably remove.
console.log(JSON.stringify(contracts, null, 2))
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.log(
JSON.stringify({ error: error.message, stack: error.stack }, null, 2)
)
process.exit(1)
})
......@@ -6,10 +6,12 @@
# development. The state dump can be found at
# `GET /state-dump.latest.json`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
PYTHON=${PYTHON:-python}
HOST=${HOST:-0.0.0.0}
PORT=${PORT:-8081}
DIRECTORY=dist/dumps
DIRECTORY=$DIR/../dist/dumps
if [ ! command -v $PYTHON&>/dev/null ]; then
echo "Please install python"
......
......@@ -41,6 +41,9 @@ const config: HardhatUserConfig = {
version: '0.7.6',
settings: {
optimizer: { enabled: true, runs: 200 },
metadata: {
bytecodeHash: 'none',
},
outputSelection: {
'*': {
'*': ['storageLayout'],
......
import './tasks/task-deploy'
/* Imports: External */
import { ethers } from 'ethers'
import { task } from 'hardhat/config'
import * as types from 'hardhat/internal/core/params/argumentTypes'
const DEFAULT_L1_BLOCK_TIME_SECONDS = 15
const DEFAULT_CTC_FORCE_INCLUSION_PERIOD_SECONDS = 60 * 60 * 24 * 30 // 30 days
const DEFAULT_CTC_MAX_TRANSACTION_GAS_LIMIT = 9_000_000
const DEFAULT_EM_MIN_TRANSACTION_GAS_LIMIT = 50_000
const DEFAULT_EM_MAX_TRANSACTION_GAS_LIMIT = 9_000_000
const DEFAULT_EM_MAX_GAS_PER_QUEUE_PER_EPOCH = 250_000_000
const DEFAULT_EM_SECONDS_PER_EPOCH = 0
const DEFAULT_EM_OVM_CHAIN_ID = 420
const DEFAULT_SCC_FRAUD_PROOF_WINDOW = 60 * 60 * 24 * 7 // 7 days
const DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW = 60 * 30 // 30 minutes
task('deploy')
.addOptionalParam(
'l1BlockTimeSeconds',
'Number of seconds on average between every L1 block.',
DEFAULT_L1_BLOCK_TIME_SECONDS,
types.int
)
.addOptionalParam(
'ctcForceInclusionPeriodSeconds',
'Number of seconds that the sequencer has to include transactions before the L1 queue.',
DEFAULT_CTC_FORCE_INCLUSION_PERIOD_SECONDS,
types.int
)
.addOptionalParam(
'ctcMaxTransactionGasLimit',
'Max gas limit for L1 queue transactions.',
DEFAULT_CTC_MAX_TRANSACTION_GAS_LIMIT,
types.int
)
.addOptionalParam(
'emMinTransactionGasLimit',
'Minimum allowed transaction gas limit.',
DEFAULT_EM_MIN_TRANSACTION_GAS_LIMIT,
types.int
)
.addOptionalParam(
'emMaxTransactionGasLimit',
'Maximum allowed transaction gas limit.',
DEFAULT_EM_MAX_TRANSACTION_GAS_LIMIT,
types.int
)
.addOptionalParam(
'emMaxGasPerQueuePerEpoch',
'Maximum gas allowed in a given queue for each epoch.',
DEFAULT_EM_MAX_GAS_PER_QUEUE_PER_EPOCH,
types.int
)
.addOptionalParam(
'emSecondsPerEpoch',
'Number of seconds in each epoch.',
DEFAULT_EM_SECONDS_PER_EPOCH,
types.int
)
.addOptionalParam(
'emOvmChainId',
'Chain ID for the L2 network.',
DEFAULT_EM_OVM_CHAIN_ID,
types.int
)
.addOptionalParam(
'sccFraudProofWindow',
'Number of seconds until a transaction is considered finalized.',
DEFAULT_SCC_FRAUD_PROOF_WINDOW,
types.int
)
.addOptionalParam(
'sccSequencerPublishWindow',
'Number of seconds that the sequencer is exclusively allowed to post state roots.',
DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW,
types.int
)
.addOptionalParam(
'ovmSequencerAddress',
'Address of the sequencer. Must be provided or this deployment will fail.',
undefined,
types.string
)
.addOptionalParam(
'ovmProposerAddress',
'Address of the account that will propose state roots. Must be provided or this deployment will fail.',
undefined,
types.string
)
.addOptionalParam(
'ovmRelayerAddress',
'Address of the message relayer. Must be provided or this deployment will fail.',
undefined,
types.string
)
.addOptionalParam(
'ovmAddressManagerOwner',
'Address that will own the Lib_AddressManager. Must be provided or this deployment will fail.',
undefined,
types.string
)
.setAction(async (args, hre: any, runSuper) => {
// Necessary because hardhat doesn't let us attach non-optional parameters to existing tasks.
const validateAddressArg = (argName: string) => {
if (args[argName] === undefined) {
throw new Error(
`argument for ${argName} is required but was not provided`
)
}
if (!ethers.utils.isAddress(args[argName])) {
throw new Error(
`argument for ${argName} is not a valid address: ${args[argName]}`
)
}
}
validateAddressArg('ovmSequencerAddress')
validateAddressArg('ovmProposerAddress')
validateAddressArg('ovmRelayerAddress')
validateAddressArg('ovmAddressManagerOwner')
args.ctcForceInclusionPeriodBlocks = Math.floor(
args.ctcForceInclusionPeriodSeconds / args.l1BlockTimeSeconds
)
hre.deployConfig = args
return runSuper(args)
})
../../prettier-config.json
\ No newline at end of file
{
"$schema": "http://json.schemastore.org/prettierrc",
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"arrowParens": "always"
}
......@@ -2,6 +2,7 @@
import { Contract } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider'
import { Signer } from '@ethersproject/abstract-signer'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
export const registerAddress = async ({
hre,
......@@ -50,7 +51,7 @@ export const deployAndRegister = async ({
args,
contract,
}: {
hre: any
hre: HardhatRuntimeEnvironment
name: string
args: any[]
contract?: string
......@@ -77,7 +78,7 @@ export const deployAndRegister = async ({
}
export const getDeployedContract = async (
hre: any,
hre: HardhatRuntimeEnvironment,
name: string,
options: {
iface?: string
......
......@@ -188,7 +188,7 @@ const test_nuisanceGas: TestDefinition = {
// This is because there is natural gas consumption between the ovmCALL(GAS/2) and ovmCREATE, which allots nuisance gas via _getNuisanceGasLimit.
// This means that the ovmCREATE exception, DOES consumes all nuisance gas allotted, but that allotment
// is less than the full OVM_TX_GAS_LIMIT / 2 which is alloted to the parent ovmCALL.
nuisanceGasLeft: 4184829,
nuisanceGasLeft: 4197042,
},
},
},
......
......@@ -2,6 +2,7 @@
"extends": "../../tslint.base.json",
"rules": {
"array-type": false,
"class-name": false
"class-name": false,
"prefer-conditional-expression": false
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment