Skip to content

Commit

Permalink
CCIP-4737 compile using foundry (#15829)
Browse files Browse the repository at this point in the history
* compile using foundry

* gen wrappers based on Foundry output

* rename ARMProxy -> RMNProxy

* let shared use foundry compiled wrappers

* move shared compilation files out of ccip

* gen ccip wrappers

abis have changed in order, no bytecode diff

* align contract names with wrapper names

* remove ccip version of mock_v3_agg

* gen shared wrappers

* install Foundry in wrapper gen CI

* install foundry for CI and add changeset

bump shared compilation version to 0.8.24

* [Bot] Update changeset file with jira issues

* add foundry install to more CI steps

* make foundry action install Foundry

* move chain_reader_test to shared compile and set to 0.8.19

* set foundry root

* undo changes to shared tests

* gen aggregator_v3_interface from shared

* fix lint, changeset

* fix ref to action

---------

Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 1cebf39 commit 6e65dee
Show file tree
Hide file tree
Showing 92 changed files with 700 additions and 1,464 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-tigers-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal change gethwrapper to allow for foundry based gethwrapper generation
26 changes: 0 additions & 26 deletions .github/actions/detect-solidity-foundry-version/action.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/ci-core-partial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
with:
prod: "true"

- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry

- name: Setup Go
uses: ./.github/actions/setup-go
with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ jobs:
with:
prod: "true"

- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry

- name: Setup Go
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
uses: ./.github/actions/setup-go
Expand Down Expand Up @@ -480,6 +483,8 @@ jobs:
run: curl https://github.com/smartcontractkit/wsrpc/raw/main/cmd/protoc-gen-go-wsrpc/protoc-gen-go-wsrpc --output $HOME/go/bin/protoc-gen-go-wsrpc && chmod +x $HOME/go/bin/protoc-gen-go-wsrpc
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry
- name: make generate
run: |
make rm-mocked
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/solidity-foundry-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,8 @@ jobs:
with:
persist-credentials: false

- name: Extract Foundry version
id: extract-foundry-version
uses: ./.github/actions/detect-solidity-foundry-version
with:
working-directory: contracts
- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry

- name: Should skip code coverage report
id: skip-code-coverage
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.define-matrix.outputs.matrix }}
foundry-version: ${{ steps.extract-foundry-version.outputs.foundry-version }}
steps:
- name: Define test matrix
id: define-matrix
Expand Down Expand Up @@ -51,12 +50,6 @@ jobs:
with:
persist-credentials: false

- name: Extract Foundry version
id: extract-foundry-version
uses: ./.github/actions/detect-solidity-foundry-version
with:
working-directory: contracts

changes:
name: Detect changes
runs-on: ubuntu-latest
Expand Down Expand Up @@ -178,9 +171,7 @@ jobs:
${{ 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
with:
version: ${{ needs.define-matrix.outputs.foundry-version }}
uses: ./.github/actions/install-solidity-foundry

# If Solc version is not set in foundry.toml, then what `forge build` does is that it lazily-installs required solc versions
# using SVM. This is done in parallel, but SVM has a bug and is not thread-safe, which sometimes leads to `Text file busy` error.
Expand Down Expand Up @@ -347,9 +338,7 @@ jobs:
uses: ./.github/actions/setup-nodejs

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
with:
version: ${{ needs.define-matrix.outputs.foundry-version }}
uses: ./.github/actions/install-solidity-foundry

- name: Set up Python
uses: actions/setup-python@v5.2.0
Expand Down Expand Up @@ -626,9 +615,7 @@ jobs:

- name: Install Foundry
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-forge-fmt }}
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
with:
version: ${{ needs.define-matrix.outputs.foundry-version }}
uses: ./.github/actions/install-solidity-foundry

- name: Run Forge fmt
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-forge-fmt }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/solidity-wrappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
with:
prod: "true"

- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry

- name: Run native compile and generate wrappers
run: make wrappers-all
working-directory: ./contracts
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ jobs:
with:
go-version-file: "chainlink/go.mod"

- name: Install Foundry
uses: ./chainlink/.github/actions/install-solidity-foundry
with:
working-directory: chainlink/contracts

- name: Run native compile and generate wrappers
working-directory: ./chainlink/contracts
run: make wrappers-all
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ vendor/*

*.wasm
contracts/lcov.info
/cache
2 changes: 1 addition & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ packages:
FlagsInterface:
config:
mockname: Flags
github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface:
github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/aggregator_v3_interface:
config:
dir: core/services/vrf/mocks
filename: aggregator_v3_interface.go
Expand Down
10 changes: 10 additions & 0 deletions contracts/.changeset/cuddly-roses-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@chainlink/contracts': patch
---

#internal Generate gethwrappers through Foundry instead of solc-select via python


PR issue: CCIP-4737

Solidity Review issue: CCIP-3966
5 changes: 3 additions & 2 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ optimizer_runs = 500

# This profile should be used prior to any release to ensure the tests are passing with via-ir enabled. Enabling via-ir
# locally or in CI will slow down the compilation process, so it is not recommended to use it for everyday development.
[profile.ccip-viair]
[profile.ccip-compile]
solc_version = '0.8.26'
src = 'src/v0.8/ccip'
test = 'src/v0.8/ccip/test'
evm_version = 'paris'
optimizer_runs = 800
optimizer_runs = 80_000
via_ir = true

[profile.functions]
Expand Down Expand Up @@ -109,5 +109,6 @@ optimizer_runs = 1_000_000
src = 'src/v0.8/shared'
test = 'src/v0.8/shared/test'
solc_version = '0.8.24'
evm_version = 'paris'

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
8 changes: 4 additions & 4 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ARMProxy_constructor:test_Constructor() (gas: 302031)
ARMProxy_isCursed:test_IsCursed_GlobalCurseSubject() (gas: 89809)
ARMProxy_setARM:test_SetARM() (gas: 16599)
ARMProxy_setARM:test_SetARMzero() (gas: 11275)
BurnFromMintTokenPool_lockOrBurn:test_PoolBurn() (gas: 238950)
BurnFromMintTokenPool_lockOrBurn:test_setup() (gas: 24178)
BurnMintTokenPool_lockOrBurn:test_PoolBurn() (gas: 236872)
Expand Down Expand Up @@ -307,6 +303,10 @@ RMNHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive() (
RMNHome_revokeCandidate:test_revokeCandidate() (gas: 28085)
RMNHome_setCandidate:test_setCandidate() (gas: 590250)
RMNHome_setDynamicConfig:test_setDynamicConfig() (gas: 105498)
RMNProxy_constructor:test_Constructor() (gas: 302031)
RMNProxy_isCursed:test_IsCursed_GlobalCurseSubject() (gas: 89809)
RMNProxy_setARM:test_SetARM() (gas: 16599)
RMNProxy_setARM:test_SetARMzero() (gas: 11275)
RMNRemote_constructor:test_constructor() (gas: 8410)
RMNRemote_curse:test_curse() (gas: 149422)
RMNRemote_global_curses:test_isCursed_globalCurseSubject() (gas: 71707)
Expand Down
Loading

0 comments on commit 6e65dee

Please sign in to comment.