Skip to content

Commit

Permalink
Update Foundry ir profiles (#224)
Browse files Browse the repository at this point in the history
This PR attempts to standardize the `via-ir` settings used throughout
the repo. We set consistent configs for the `ir` Foundry profile in each
of the sub-projects. In CI and the deploy scripts, we also switch to
using the `ir` Foundry profile instead of relying on `via-ir`.
  • Loading branch information
kevincheng96 authored Oct 1, 2024
1 parent 1afeb4e commit 7d4a98c
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 234 deletions.
411 changes: 206 additions & 205 deletions .gas-snapshot

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .github/workflows/gas-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
FOUNDRY_PROFILE: ci
FOUNDRY_PROFILE: ir

jobs:
snapshot-gas:
Expand All @@ -29,7 +29,7 @@ jobs:
run: |
set -euo pipefail
# grep -E '^test' -- skip over test results, just get diffs
forge snapshot --via-ir --diff \
forge snapshot --diff \
| grep -E '^test' \
| tee .gas-snapshot.new
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
FOUNDRY_PROFILE: ci
FOUNDRY_PROFILE: ir

jobs:
check:
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge build --via-ir --sizes
forge build --sizes
id: build

- name: Run Forge Format
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
FOUNDRY_PROFILE: ci
FOUNDRY_PROFILE: ir

jobs:
check:
Expand All @@ -30,12 +30,12 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge build --via-ir --sizes
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test --via-ir
forge test
id: test
env:
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
11 changes: 7 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[profile.default]
solc = "0.8.27"
evm_version = "cancun"

libs = [ "./lib" ]
bytecode_hash = "none"
cbor_metadata = false

# output intermediate representation
[profile.ir]
extra_output = ["ir"]
extra_output_files = ["ir"]
via_ir = true
optimizer = true
optimizer_runs = 100000000
extra_output = [ "ir" ]
extra_output_files = [ "ir" ]
2 changes: 1 addition & 1 deletion script/deploy-code-jar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
etherscan_args=""
fi

forge script --via-ir \
FOUNDRY_PROFILE=ir forge script \
$rpc_args \
$wallet_args \
$etherscan_args \
Expand Down
2 changes: 1 addition & 1 deletion script/deploy-quark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
etherscan_args=""
fi

forge script --via-ir \
FOUNDRY_PROFILE=ir forge script \
$rpc_args \
$wallet_args \
$etherscan_args \
Expand Down
2 changes: 1 addition & 1 deletion script/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ artifact_name="quark-out.${release_name}.zip"
artifact_note="Compiled ABI"

printf 'building full project...\n'
forge build --via-ir
FOUNDRY_PROFILE=ir forge build

printf 'preparing release archive "%s"...\n' ${release_name}
zip --recurse-paths "${artifact_name}" out/*
Expand Down
2 changes: 1 addition & 1 deletion script/update-snapshot.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

forge snapshot --via-ir
FOUNDRY_PROFILE=ir forge snapshot
9 changes: 7 additions & 2 deletions src/codejar/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[profile.default]
solc = "0.8.27"
evm_version = "cancun"

libs = [ "../../lib" ]

src = "src"
out = "out"
test = "../../test/codejar"

[profile.ir]
via_ir = true
optimizer = true
optimizer_runs = 100000000
extra_output = [ "ir" ]
extra_output_files = [ "ir" ]
11 changes: 9 additions & 2 deletions src/quark-core-scripts/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[profile.default]
solc = "0.8.27"
evm_version = "cancun"

libs = [ "../../lib" ]

src = "src"
out = "out"
test = "../../test/quark-core-scripts/"
bytecode_hash = "none"
cbor_metadata = false

[profile.ir]
via_ir = true
optimizer = true
optimizer_runs = 100000000
extra_output = [ "ir" ]
extra_output_files = [ "ir" ]
11 changes: 9 additions & 2 deletions src/quark-core/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[profile.default]
solc = "0.8.27"
evm_version = "cancun"

libs = [ "../../lib" ]

src = "src"
out = "out"
test = "../../test/quark-core"
bytecode_hash = "none"
cbor_metadata = false

[profile.ir]
via_ir = true
optimizer = true
optimizer_runs = 100000000
extra_output = [ "ir" ]
extra_output_files = [ "ir" ]
11 changes: 9 additions & 2 deletions src/quark-factory/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[profile.default]
solc = "0.8.27"
evm_version = "cancun"

libs = [ "../../lib" ]

src = "src"
out = "out"
test = "../../test/quark-factory/"
bytecode_hash = "none"
cbor_metadata = false

[profile.ir]
via_ir = true
optimizer = true
optimizer_runs = 100000000
extra_output = [ "ir" ]
extra_output_files = [ "ir" ]
10 changes: 4 additions & 6 deletions src/quark-proxy/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
[profile.default]
solc = "0.8.27"
evm_version = "cancun"

libs = [ "../../lib" ]

src = "src"
out = "out"
test = "../../test/quark-proxy"

# optimizer config
optimizer = true
optimizer_runs = 1
cbor_metadata = false
bytecode_hash = "none"

[profile.ir]
via_ir = true
optimizer = true
# We optimize for deployment cost over runtime gas efficiency
optimizer_runs = 1
extra_output = [ "ir" ]
extra_output_files = [ "ir" ]

0 comments on commit 7d4a98c

Please sign in to comment.