Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCIP-5323] Compile llo-feeds using forge instead of solc. #16718

Merged
merged 3 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions contracts/.changeset/smooth-humans-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': minor
---

#updated [CCIP-5323] Compile llo-feeds using forge instead of solc.
71 changes: 34 additions & 37 deletions contracts/scripts/native_solc_compile_all_llo-feeds
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,40 @@ echo " ┌───────────────────────
echo " │ Compiling Low Latency Oracle contracts... │"
echo " └──────────────────────────────────────────────┘"

SOLC_VERSION="0.8.19"
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 dir
contract=$(basename "$1" ".sol")
dir=$(dirname "$1")

solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$dir"/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\
"$ROOT"/contracts/src/v0.8/"$1"
PROJECT="llo-feeds"

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

compileContract() {
local contract
contract=$(basename "$2")
echo "Compiling" "$contract"

local command
command="forge build $CONTRACTS_DIR/src/v0.8/$PROJECT/"$1"/"$2.sol" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would imagine we still need the optimisation_runs & a fixed solc version in order to have a deterministic binary. We could perhaps move these to a configuration within the directory. We could potentially move away from deterministic binaries but it requires some thought.. some initial concerns would be:

  1. How can we determine the compiler settings for each chain, do we migrate this responsibility to tooling?
  2. Different developers using different compiler versions or settings might produce different bytecode, leading to confusion when comparing results.

Copy link
Collaborator Author

@pavel-raykov pavel-raykov Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, all the compile settings are controlled by the forge profiles https://github.com/smartcontractkit/chainlink/blob/develop/contracts/foundry.toml . Whenever you need a new setting you can either override the default profile, or you can create your own custom one and set it via the FOUNDRY_PROFILE environment variable.

--root $CONTRACTS_DIR \
--extra-output-files bin abi \
-o $CONTRACTS_DIR/solc/$PROJECT/$1/$contract"
$command
}
compileContract llo-feeds/v0.3.0/Verifier.sol
compileContract llo-feeds/v0.3.0/VerifierProxy.sol
compileContract llo-feeds/v0.3.0/FeeManager.sol
compileContract llo-feeds/v0.3.0/RewardManager.sol
compileContract llo-feeds/v0.4.0/DestinationVerifier.sol
compileContract llo-feeds/v0.4.0/DestinationVerifierProxy.sol
compileContract llo-feeds/v0.4.0/DestinationFeeManager.sol
compileContract llo-feeds/v0.4.0/DestinationRewardManager.sol
compileContract llo-feeds/v0.5.0/configuration/ChannelConfigStore.sol
compileContract llo-feeds/v0.5.0/configuration/Configurator.sol
compileContract llo-feeds/v0.5.0/Verifier.sol
compileContract llo-feeds/v0.5.0/VerifierProxy.sol
compileContract llo-feeds/v0.5.0/FeeManager.sol
compileContract llo-feeds/v0.5.0/RewardManager.sol

compileContract v0.3.0 Verifier
compileContract v0.3.0 VerifierProxy
compileContract v0.3.0 FeeManager
compileContract v0.3.0 RewardManager
compileContract v0.4.0 DestinationVerifier
compileContract v0.4.0 DestinationVerifierProxy
compileContract v0.4.0 DestinationFeeManager
compileContract v0.4.0 DestinationRewardManager
compileContract v0.5.0 configuration/ChannelConfigStore
compileContract v0.5.0 configuration/Configurator
compileContract v0.5.0 Verifier
compileContract v0.5.0 VerifierProxy
compileContract v0.5.0 FeeManager
compileContract v0.5.0 RewardManager

# Test | Mocks
compileContract llo-feeds/v0.3.0/test/mocks/ErroredVerifier.sol
compileContract llo-feeds/v0.3.0/test/mocks/ExposedVerifier.sol
compileContract llo-feeds/v0.5.0/configuration/test/mocks/ExposedConfigurator.sol
compileContract v0.3.0 test/mocks/ErroredVerifier
compileContract v0.3.0 test/mocks/ExposedVerifier
compileContract v0.5.0 configuration/test/mocks/ExposedConfigurator

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading