Skip to content

Commit

Permalink
Integrate Cannon (#1712)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeal-eth authored Jul 13, 2022
1 parent be8ef36 commit ecce4b2
Show file tree
Hide file tree
Showing 37 changed files with 8,516 additions and 2,587 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# DO NOT EDIT MANUALLY! instead run `npm run build:ci`
# autogenerated by `.circleci/pack.js` from contents of `jobs` .yml files
version: 2.1
orbs:
rust: circleci/[email protected]
commands:
{{> commands}}
jobs:
Expand Down
79 changes: 52 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# DO NOT EDIT MANUALLY! instead run `npm run build:ci`
# autogenerated by `.circleci/pack.js` from contents of `jobs` .yml files
version: 2.1
orbs:
rust: circleci/[email protected]
commands:
cmd-wait-for-port:
parameters:
Expand Down Expand Up @@ -30,18 +32,31 @@ jobs:
name: Lint lockfile
command: |
lockfile-lint -p package-lock.json --type npm --allowed-hosts npm --validate-https --empty-hostname false
job-compile:
job-cannon:
working_directory: ~/repo
docker:
- image: synthetixio/docker-node:16.15-ubuntu
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_TOKEN
machine:
image: ubuntu-2204:2022.04.1
docker_layer_caching: true
steps:
- run: |
mkdir -p ~/.foundry/bin
curl https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/foundryup
chmod +x ~/.foundry/foundryup
~/.foundry/foundryup
echo 'export PATH="$PATH:$HOME/.foundry/bin"' >> $BASH_ENV
- checkout
- attach_workspace:
at: .
- run: npx hardhat compile --optimizer --fail-oversize
- run: node publish build --test-helpers
- run: npx hardhat cannon:build --file cannonfile.aggregator.toml
- run: npx hardhat cannon:build
- persist_to_workspace:
root: .
paths:
- build
- cannon
- publish/deployed
job-fork-tests-ovm:
working_directory: ~/repo
docker:
Expand All @@ -63,9 +78,9 @@ jobs:
command: |
NEW_CONTRACTS=$(node bin.js sips --layer=ovm --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l2 --compile --use-fork
npx hardhat test:integration:l2 --use-fork
else
npx hardhat test:integration:l2 --compile --deploy --use-sips --use-fork
npx hardhat test:integration:l2 --deploy --use-sips --use-fork
fi;
- store_test_results:
path: /tmp/junit/
Expand All @@ -92,9 +107,9 @@ jobs:
command: |
NEW_CONTRACTS=$(node bin.js sips --layer=base --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l1 --compile --use-fork --provider-port 9545
npx hardhat test:integration:l1 --use-fork --provider-port 9545
else
npx hardhat test:integration:l1 --compile --deploy --use-sips --use-fork --provider-port 9545
npx hardhat test:integration:l1 --deploy --use-sips --use-fork --provider-port 9545
fi;
- store_test_results:
path: /tmp/junit/
Expand All @@ -107,6 +122,12 @@ jobs:
docker_layer_caching: true
resource_class: large
steps:
- run: |
mkdir -p ~/.foundry/bin
curl https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/foundryup
chmod +x ~/.foundry/foundryup
~/.foundry/foundryup
echo 'export PATH="$PATH:$HOME/.foundry/bin"' >> $BASH_ENV
- checkout
- attach_workspace:
at: .
Expand All @@ -123,6 +144,14 @@ jobs:
key: v6-optimism-build-{{ checksum "package-lock.json" }}
paths:
- ./optimism
- run:
name: Run isolated layer 1 integration tests
command: |
npx hardhat test:integration:l1 --deploy
- run:
name: Run isolated layer 2 integration tests
command: |
npx hardhat test:integration:l2 --deploy
- run:
name: Start docker chains
background: true
Expand All @@ -133,14 +162,6 @@ jobs:
port: 8545
- cmd-wait-for-port:
port: 9545
- run:
name: Run isolated layer 1 integration tests
command: |
npx hardhat test:integration:l1 --compile --deploy --provider-port 9545
- run:
name: Run isolated layer 2 integration tests
command: |
npx hardhat test:integration:l2 --compile --deploy
- run:
name: Run dual layer 1 and layer 2 integration tests
command: |
Expand Down Expand Up @@ -254,13 +275,17 @@ jobs:
destination: slitherReport.txt
job-test-deploy-script:
working_directory: ~/repo
docker:
- image: synthetixio/docker-node:16.15-ubuntu
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_TOKEN
machine:
image: ubuntu-2204:2022.04.1
docker_layer_caching: true
resource_class: large
steps:
- run: |
mkdir -p ~/.foundry/bin
curl https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/foundryup
chmod +x ~/.foundry/foundryup
~/.foundry/foundryup
echo 'export PATH="$PATH:$HOME/.foundry/bin"' >> $BASH_ENV
- checkout
- attach_workspace:
at: .
Expand Down Expand Up @@ -425,7 +450,7 @@ workflows:
- job-lint:
requires:
- job-prepare
- job-compile:
- job-cannon:
requires:
- job-prepare
- job-static-analysis:
Expand All @@ -450,17 +475,17 @@ workflows:
- job-prepare
- job-fork-tests:
requires:
- job-prepare
- job-cannon
- job-fork-tests-ovm:
requires:
- job-prepare
- job-cannon
- job-simulate-release:
requires:
- job-prepare
- job-integration-tests:
name: job-integration-tests
requires:
- job-prepare
- job-cannon
- job-pack-browser:
requires:
- job-prepare
Expand Down
22 changes: 22 additions & 0 deletions .circleci/src/jobs/job-cannon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Builds a testing chain which is used for integration tests and downstream projects
{{> job-header-machine.yml}}
steps:
- run: |
mkdir -p ~/.foundry/bin
curl https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/foundryup
chmod +x ~/.foundry/foundryup
~/.foundry/foundryup
echo 'export PATH="$PATH:$HOME/.foundry/bin"' >> $BASH_ENV
- checkout
- attach_workspace:
at: .
- run: npx hardhat compile --optimizer --fail-oversize
- run: node publish build --test-helpers
- run: npx hardhat cannon:build --file cannonfile.aggregator.toml
- run: npx hardhat cannon:build
- persist_to_workspace:
root: .
paths:
- build
- cannon
- publish/deployed
7 changes: 0 additions & 7 deletions .circleci/src/jobs/job-compile.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .circleci/src/jobs/job-fork-tests-ovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ steps:
# Only compile and deploy when there are new contracts
NEW_CONTRACTS=$(node bin.js sips --layer=ovm --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l2 --compile --use-fork
npx hardhat test:integration:l2 --use-fork
else
npx hardhat test:integration:l2 --compile --deploy --use-sips --use-fork
npx hardhat test:integration:l2 --deploy --use-sips --use-fork
fi;
- store_test_results:
path: /tmp/junit/
Expand Down
4 changes: 2 additions & 2 deletions .circleci/src/jobs/job-fork-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ steps:
# Only compile and deploy when there are new contracts
NEW_CONTRACTS=$(node bin.js sips --layer=base --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l1 --compile --use-fork --provider-port 9545
npx hardhat test:integration:l1 --use-fork --provider-port 9545
else
npx hardhat test:integration:l1 --compile --deploy --use-sips --use-fork --provider-port 9545
npx hardhat test:integration:l1 --deploy --use-sips --use-fork --provider-port 9545
fi;
- store_test_results:
path: /tmp/junit/
Expand Down
23 changes: 15 additions & 8 deletions .circleci/src/jobs/job-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
{{=<% %>=}}
resource_class: large
steps:
# get foundry
- run: |
mkdir -p ~/.foundry/bin
curl https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/foundryup
chmod +x ~/.foundry/foundryup
~/.foundry/foundryup
echo 'export PATH="$PATH:$HOME/.foundry/bin"' >> $BASH_ENV
- checkout
- attach_workspace:
at: .
Expand All @@ -21,6 +28,14 @@ steps:
key: v6-optimism-build-{{ checksum "package-lock.json" }}
paths:
- ./optimism
- run:
name: Run isolated layer 1 integration tests
command: |
npx hardhat test:integration:l1 --deploy
- run:
name: Run isolated layer 2 integration tests
command: |
npx hardhat test:integration:l2 --deploy
- run:
name: Start docker chains
background: true
Expand All @@ -31,14 +46,6 @@ steps:
port: 8545
- cmd-wait-for-port:
port: 9545
- run:
name: Run isolated layer 1 integration tests
command: |
npx hardhat test:integration:l1 --compile --deploy --provider-port 9545
- run:
name: Run isolated layer 2 integration tests
command: |
npx hardhat test:integration:l2 --compile --deploy
- run:
name: Run dual layer 1 and layer 2 integration tests
command: |
Expand Down
9 changes: 8 additions & 1 deletion .circleci/src/jobs/job-test-deploy-script.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Validates that the deploy command is working as expected
{{> job-header-node.yml}}
{{> job-header-machine.yml}}
resource_class: large
steps:
# get foundry
- run: |
mkdir -p ~/.foundry/bin
curl https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/foundryup
chmod +x ~/.foundry/foundryup
~/.foundry/foundryup
echo 'export PATH="$PATH:$HOME/.foundry/bin"' >> $BASH_ENV
- checkout
- attach_workspace:
at: .
Expand Down
2 changes: 2 additions & 0 deletions .circleci/src/snippets/require-cannon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requires:
- job-cannon
8 changes: 4 additions & 4 deletions .circleci/src/workflows/workflow-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
{{> require-audit.yml}}
- job-lint:
{{> require-prepare.yml}}
- job-compile:
- job-cannon:
{{> require-prepare.yml}}
- job-static-analysis:
{{> require-prepare.yml}}
Expand All @@ -30,9 +30,9 @@ jobs:
# Fork tests
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- job-fork-tests:
{{> require-prepare.yml}}
{{> require-cannon.yml}}
- job-fork-tests-ovm:
{{> require-prepare.yml}}
{{> require-cannon.yml}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Simulate release on fork & test
Expand All @@ -45,7 +45,7 @@ jobs:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- job-integration-tests:
name: job-integration-tests
{{> require-prepare.yml}}
{{> require-cannon.yml}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Packaging
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ optimism
slither.sarif

.npm-cache

# cannon build files
cannon/
34 changes: 34 additions & 0 deletions cannonfile.aggregator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name = "chainlink"
version = "0.7-mock"
description = "Deploys a testing aggregator with a given rate dated into the future"

[setting.rate]
defaultValue = "1000000000000000000"

[setting.timestamp]
# by default, its dated into the future
defaultValue = "10000000000000"

[setting.decimals]
defaultValue = "6"

[setting.salt]
defaultValue = "default"

[contract.aggregator]
artifact = "MockAggregatorV2V3"
salt = "<%= settings.salt %>"

[invoke.set_decimals]
target = ["aggregator"]
func = "setDecimals"
args = ["<%= settings.decimals %>"]
depends = ["contract.aggregator"]

[invoke.set_answer]
target = ["aggregator"]

func = "setLatestAnswer"
args = ["<%= settings.rate %>", "<%= settings.timestamp %>"]

depends = ["contract.aggregator"]
Loading

0 comments on commit ecce4b2

Please sign in to comment.