Skip to content

Commit

Permalink
[DEVSVCS-518] Workflow Registry Contract (#14990)
Browse files Browse the repository at this point in the history
* workflow registry contract draft

* Added initial Foundry tests and other necessary scripts

* CI test matrix fix

* Prettier fixes, Hardhat fixes, add missing generation file

* Forge fmt and forge coverage with via-ir flag

* Ignore workflow from Prettier and use via-ir for coverage check

* switch from /** */ to /// in doc comments as set by the solidity tsar

* add more test cases

* set paris as evm environment in foundry profile

* port additional workflow registry contract work into core

* add changeset

* add workflow registry manager contract

* disable run-forge-fmt in solidity-foundry for workflow
https://smartcontract-it.atlassian.net/browse/DEVSVCS-518

* add additional tests per function for workflow registry

* fix additional registry tests

* remove hardhat config

* remove old workflow registry manager test

* add back hardhat config

* Update gethwrappers

* Potential fix for not running Hardhat for workflow registry

* tweak coverage

---------

Co-authored-by: Iva Brajer <[email protected]>
Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 15, 2024
1 parent dda65c4 commit cc04604
Show file tree
Hide file tree
Showing 60 changed files with 5,448 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ core/scripts/gateway @smartcontractkit/dev-services
# TODO: transmission folder, owner should be found
/contracts/src/v0.8/vrf @smartcontractkit/dev-services
/contracts/src/v0.8/keystone @smartcontractkit/keystone
/contracts/src/v0.8/workflow @smartcontractkit/dev-services

/core/gethwrappers/ccip @smartcontractkit/ccip-onchain
/core/gethwrappers/functions @smartcontractkit/dev-services
Expand All @@ -107,6 +108,7 @@ core/scripts/gateway @smartcontractkit/dev-services
/core/gethwrappers/llo-feeds @smartcontractkit/data-streams-engineers
/core/gethwrappers/operatorforwarder @smartcontractkit/data-feeds-engineers
/core/gethwrappers/shared @smartcontractkit/core-solidity
/core/gethwrappers/workflow @smartcontractkit/dev-services

# The following don't exist yet but should. They are already included here to allow the teams to
# set these folders up and own them immediately.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/solidity-foundry-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- "shared"
- "transmission"
- "vrf"
- "workflow"
commit_to_use:
type: string
description: 'commit SHA to use for artifact generation; if empty HEAD will be used'
Expand Down
63 changes: 38 additions & 25 deletions .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ jobs:
{ "name": "operatorforwarder", "setup": { "run-coverage": true, "min-coverage": 55.7, "run-gas-snapshot": true, "run-forge-fmt": false }},
{ "name": "shared", "setup": { "run-coverage": true, "extra-coverage-params": "--no-match-path='*CallWithExactGas*' --ir-minimum", "min-coverage": 32.6, "run-gas-snapshot": true, "run-forge-fmt": false }},
{ "name": "transmission", "setup": { "run-coverage": true, "min-coverage": 61.5, "run-gas-snapshot": true, "run-forge-fmt": false }},
{ "name": "vrf", "setup": { "run-coverage": false, "min-coverage": 98.5, "run-gas-snapshot": false, "run-forge-fmt": false }}
{ "name": "vrf", "setup": { "run-coverage": false, "min-coverage": 98.5, "run-gas-snapshot": false, "run-forge-fmt": false }},
{ "name": "workflow", "setup": { "run-coverage": true, "extra-coverage-params": "--ir-minimum", "min-coverage": 65.0, "run-gas-snapshot": false, "run-forge-fmt": true }}
]
EOF
Expand Down Expand Up @@ -73,7 +74,7 @@ jobs:
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
list-files: 'shell'
list-files: "shell"
filters: |
non_src:
- '.github/workflows/solidity-foundry.yml'
Expand Down Expand Up @@ -113,12 +114,14 @@ jobs:
- 'contracts/src/v0.8/vendor/**/*.sol'
transmission:
- 'contracts/src/v0.8/transmission/**/*.sol'
workflow:
- 'contracts/src/v0.8/workflow/**/*.sol'
- name: Detect non-test changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes-non-test
with:
list-files: 'shell'
list-files: "shell"
# This is a valid input, see https://github.com/dorny/paths-filter/pull/226
predicate-quantifier: every
filters: |
Expand Down Expand Up @@ -148,7 +151,8 @@ jobs:
# passing required check for PRs that don't have filtered changes.
steps:
- name: Checkout the repo
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
uses: actions/[email protected]
Expand All @@ -159,15 +163,17 @@ jobs:
# and not native Foundry. This is to make sure the dependencies
# stay in sync.
- name: Setup NodeJS
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
uses: ./.github/actions/setup-nodejs
with:
prod: "true"

- name: Install Foundry
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
Expand All @@ -179,7 +185,8 @@ jobs:
# In order to avoid it, in such cases we will extract all required solc versions manually and install them sequentially.
# More information: https://github.com/foundry-rs/foundry/issues/4736
- name: Check if Solc version is set in foundry.toml
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
shell: bash
Expand Down Expand Up @@ -228,7 +235,8 @@ jobs:
fi
- name: Run Forge build
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
run: |
Expand All @@ -240,7 +248,8 @@ jobs:
FOUNDRY_PROFILE: ${{ matrix.product.name }}

- name: Run Forge tests
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
run: |
Expand All @@ -251,7 +260,8 @@ jobs:
FOUNDRY_PROFILE: ${{ matrix.product.name }}

- name: Run Forge snapshot
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true')
&& matrix.product.setup.run-gas-snapshot }}
Expand All @@ -264,14 +274,16 @@ jobs:

# required for code coverage report generation
- name: Setup LCOV
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true')
&& matrix.product.setup.run-coverage }}
uses: hrishikesh-kadam/setup-lcov@f5da1b26b0dcf5d893077a3c4f29cf78079c841d # v1.0.0

- name: Run coverage for ${{ matrix.product.name }}
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true')
&& matrix.product.setup.run-coverage }}
Expand All @@ -287,15 +299,17 @@ jobs:
FOUNDRY_PROFILE: ${{ matrix.product.name }}

- name: Prune lcov report
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true')
&& matrix.product.setup.run-coverage }}
run: |
./contracts/scripts/lcov_prune ${{ matrix.product.name }} ./contracts/lcov.info ./contracts/lcov.info.pruned
- name: Report code coverage for ${{ matrix.product.name }}
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
if:
${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true')
&& matrix.product.setup.run-coverage }}
Expand All @@ -309,7 +323,7 @@ jobs:

# runs only if non-test contracts were modified; scoped only to modified or added contracts
analyze:
needs: [ changes, define-matrix ]
needs: [changes, define-matrix]
name: Run static analysis
if: needs.changes.outputs.not_test_sol_modified == 'true' && github.event_name != 'merge_group'
runs-on: ubuntu-22.04
Expand All @@ -335,13 +349,13 @@ jobs:
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.8'
python-version: "3.8"

- name: Install solc-select and solc
uses: smartcontractkit/.github/actions/setup-solc-select@b6e37806737eef87e8c9137ceeb23ef0bff8b1db # [email protected]
with:
to_install: '0.8.24'
to_use: '0.8.24'
to_install: "0.8.24"
to_use: "0.8.24"

- name: Install Slither
uses: smartcontractkit/.github/actions/setup-slither@b6e37806737eef87e8c9137ceeb23ef0bff8b1db # [email protected]
Expand Down Expand Up @@ -497,7 +511,6 @@ jobs:
fi
done
# actions that execute only if any existing contracts were modified end here

- name: Print Slither summary
shell: bash
run: |
Expand All @@ -511,9 +524,9 @@ jobs:
- name: Validate if all Slither run for all contracts
uses: smartcontractkit/.github/actions/validate-solidity-artifacts@094e8de69ca35d17f321cecc062cbeed12642ef5 # [email protected]
with:
validate_slither_reports: 'true'
validate_uml_diagrams: 'false'
slither_reports_path: 'contracts/slither-reports-current'
validate_slither_reports: "true"
validate_uml_diagrams: "false"
slither_reports_path: "contracts/slither-reports-current"
sol_files: ${{ needs.changes.outputs.not_test_sol_modified_files }}

- name: Upload Slither reports
Expand All @@ -533,14 +546,14 @@ jobs:
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Static analysis results'
comment-author: "github-actions[bot]"
body-includes: "Static analysis results"

- name: Extract job summary URL
id: job-summary-url
uses: pl-strflt/job-summary-url-action@df2d22c5351f73e0a187d20879854b8d98e6e001 # v1.0.0
with:
job: 'Run static analysis'
job: "Run static analysis"

- name: Build Slither reports artifacts URL
id: build-slither-artifact-url
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solidity-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
filters: |
src:
- 'contracts/src/!(v0.8/(ccip|functions|keystone|l2ep|liquiditymanager|llo-feeds|transmission|vrf)/**)/**/*'
- 'contracts/src/!(v0.8/(ccip|functions|keystone|l2ep|liquiditymanager|llo-feeds|transmission|vrf|workflow)/**)/**/*'
- 'contracts/test/**/*'
- 'contracts/package.json'
- 'contracts/pnpm-lock.yaml'
Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/neat-melons-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': minor
---

Add workflow registry contract to core in /dev folder
1 change: 1 addition & 0 deletions contracts/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LinkToken.json
typechain
**/vendor
src/v0.8/ccip/**
src/v0.8/workflow/**

# Ignore TS definition and map files
**/**.d.ts
Expand Down
2 changes: 1 addition & 1 deletion contracts/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ALL_FOUNDRY_PRODUCTS contains a list of all products that have a foundry
# profile defined and use the Foundry snapshots.
ALL_FOUNDRY_PRODUCTS = ccip functions keystone l2ep liquiditymanager llo-feeds operatorforwarder shared transmission
ALL_FOUNDRY_PRODUCTS = ccip functions keystone l2ep liquiditymanager llo-feeds operatorforwarder shared transmission workflow

# To make a snapshot for a specific product, either set the `FOUNDRY_PROFILE` env var
# or call the target with `FOUNDRY_PROFILE=product`
Expand Down
9 changes: 8 additions & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ solc_version = '0.8.19'
src = 'src/v0.8/transmission'
test = 'src/v0.8/transmission/test'

[profile.workflow]
optimizer_runs = 1_000_000
solc_version = '0.8.24'
src = 'src/v0.8/workflow'
test = 'src/v0.8/workflow/test'
via_ir = true # reconsider using the --via-ir flag if compilation takes too long
evm_version = 'paris'

[profile.shared]
optimizer_runs = 1_000_000
src = 'src/v0.8/shared'
test = 'src/v0.8/shared/test'
solc_version = '0.8.24'


# See more config options https://github.com/foundry-rs/foundry/tree/master/config
13 changes: 13 additions & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ let config = {
version: '0.8.19',
settings: COMPILER_SETTINGS,
},
'src/v0.8/workflow/dev/WorkflowRegistry.sol': {
version: '0.8.24',
settings: {
optimizer: {
enabled: true,
runs: 1000000, // see native_solc_compile_all_workflow
},
viaIR: true,
metadata: {
bytecodeHash: 'none',
},
},
},
},
},
mocha: {
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ python3 -m pip install --require-hashes -r $SCRIPTPATH/requirements.txt
# 6 and 7 are legacy contracts, for each other product we have a native_solc_compile_all_$product script
# These scripts can be run individually, or all together with this script.
# To add new CL products, simply write a native_solc_compile_all_$product script and add it to the list below.
for product in automation events_mock feeds functions keystone llo-feeds logpoller operatorforwarder shared transmission vrf ccip liquiditymanager
for product in automation events_mock feeds functions keystone llo-feeds logpoller operatorforwarder shared transmission vrf ccip liquiditymanager workflow
do
$SCRIPTPATH/native_solc_compile_all_$product
done
32 changes: 32 additions & 0 deletions contracts/scripts/native_solc_compile_all_workflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

echo " ┌──────────────────────────────────────────────┐"
echo " │ Compiling Workflow contracts... │"
echo " └──────────────────────────────────────────────┘"

SOLC_VERSION="0.8.24"
OPTIMIZE_RUNS=1000000

SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
python3 -m pip install --require-hashes -r "$SCRIPTPATH"/requirements.txt
solc-select install $SOLC_VERSION
solc-select use $SOLC_VERSION
export SOLC_VERSION=$SOLC_VERSION

ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )"

compileContract () {
local contract
contract=$(basename "$1" ".sol")

# TODO reconsider using the --via-ir flag if compilation takes too long
solc --overwrite --via-ir --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\
--evm-version paris \
"$ROOT"/contracts/src/v0.8/"$1"
}

compileContract workflow/dev/WorkflowRegistry.sol
Loading

0 comments on commit cc04604

Please sign in to comment.