Skip to content

Commit

Permalink
Merge branch 'develop' into cre/contract-only-test-env
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann committed Feb 13, 2025
2 parents b131d07 + 41a6cb0 commit 39b7cba
Show file tree
Hide file tree
Showing 61 changed files with 1,811 additions and 1,385 deletions.
8 changes: 2 additions & 6 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
only-modules:
description: Set to 'true' to only cache modules
default: "false"
cache-version:
cache-version:
description: Set this to cache bust
default: "1"
build-cache-version:
Expand Down Expand Up @@ -97,7 +97,7 @@ runs:
- uses: actions/cache/restore@v4
name: Cache Go Build Outputs (restore)
# For certain events, we don't necessarily want to create a build cache, but we will benefit from restoring from one.
# For certain events, we don't necessarily want to create a build cache, but we will benefit from restoring from one.
if: ${{ inputs.only-modules == 'false' && (github.event_name == 'merge_group' || inputs.restore-build-cache-only == 'true') }}
with:
path: |
Expand All @@ -106,8 +106,6 @@ runs:
restore-keys: |
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-develop
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-
- uses: actions/cache@v4
# don't save cache on merge queue events
Expand All @@ -121,5 +119,3 @@ runs:
restore-keys: |
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-develop
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-
93 changes: 52 additions & 41 deletions .github/actions/setup-solana/build-contracts/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Solana build contracts
description: Build Solana contracts
inputs:
github-token:
description: "The Github token to use for authentication"
required: true
default: ${{ github.token }}

runs:
using: composite
Expand All @@ -22,52 +27,58 @@ runs:
git checkout $short_revision
echo "CHAINLINK_CCIP_COMMIT_SHORT=${short_revision}" >> $GITHUB_ENV
- name: Get Anchor Version
id: get_anchor_version
echo "ARTIFACT_NAME=solana-ccip-${short_revision}" >> $GITHUB_ENV
- name: Check if artifact exists
id: check_artifact
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
cd chainlink-ccip/chains/solana
anchor=$(make anchor_version)
echo "ANCHOR_VERSION=${anchor}" >> $GITHUB_ENV
- name: cache docker build image
id: cache-image
uses: actions/cache@v4 # v4.0.2
with:
lookup-only: true
path: chains/solana/contracts/docker-build.tar
key: ${{ runner.os }}-solana-build-${{ env.ANCHOR_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo target dir
id: cache-target
uses: actions/cache@v4 # v4.0.2
with:
lookup-only: true
path: chains/solana/contracts/target
key: ${{ runner.os }}-solana-contract-artifacts-${{ hashFiles('**/Cargo.lock') }}
- name: build & save image
if: steps.cache-image.outputs.cache-hit != 'true'
ARTIFACT_RESPONSE=$(gh api repos/${{ github.repository }}/actions/artifacts?name=${{ env.ARTIFACT_NAME }})
ARTIFACT_FOUND=false
for artifact in $(echo "$ARTIFACT_RESPONSE" | jq -r '.artifacts[] | @json'); do
# Extract relevant fields directly from JSON
ARTIFACT_NAME=$(echo "$artifact" | jq -r '.name')
ARTIFACT_EXPIRED=$(echo "$artifact" | jq -r '.expired')
ARTIFACT_DOWNLOAD_URL=$(echo "$artifact" | jq -r '.archive_download_url')
if [[ "$ARTIFACT_NAME" == "${{ env.ARTIFACT_NAME }}" && "$ARTIFACT_EXPIRED" == false ]]; then
# First non-expired artifact found, set variables and break loop
echo "Artifact found"
echo "exists=true" >> $GITHUB_ENV
echo "ARTIFACT_DOWNLOAD_URL=$ARTIFACT_DOWNLOAD_URL" >> $GITHUB_ENV
ARTIFACT_FOUND=true
break
fi
done
if [[ "$ARTIFACT_FOUND" == false ]]; then
echo "Artifact not found or expired"
echo "exists=false" >> $GITHUB_ENV
fi
- name: Download artifact if it exists
if: env.exists == 'true'
shell: bash
run: |
cd chainlink-ccip/chains/solana/contracts
docker buildx build . -t ccip-solana:build --build-arg ANCHOR_CLI=${{ env.ANCHOR_VERSION }}
docker save -o docker-build.tar ccip-solana
- name: build & save contract compilation artifacts
if: steps.cache-target.outputs.cache-hit != 'true'
curl -L -H "Authorization: token ${{ inputs.github-token }}" -o artifact.zip ${{ env.ARTIFACT_DOWNLOAD_URL }}
unzip artifact.zip -d /home/runner/work/chainlink/chainlink/deployment/ccip/changeset/internal/solana_contracts
- name: Build artifact if not found
if: env.exists == 'false'
shell: bash
run: |
cd chainlink-ccip/chains/solana
docker run -v "$(pwd)/contracts":/solana/contracts ccip-solana:build bash -c "\
set -eoux pipefail &&\
RUSTUP_HOME=\"/root/.rustup\" &&\
FORCE_COLOR=1 &&\
cd /solana/contracts &&\
anchor build &&\
chmod -R 755 ./target"
- name: move built contracts to test folder
shell: bash
run: |
# copy the built contracts so they can be used in the chainlink tests
make docker-build-contracts
# copy the built contracts so they can be used in the chainlink tests
mkdir -p /home/runner/work/chainlink/chainlink/deployment/ccip/changeset/internal/solana_contracts
cp chainlink-ccip/chains/solana/contracts/target/deploy/*.so /home/runner/work/chainlink/chainlink/deployment/ccip/changeset/internal/solana_contracts
# save the revision of the built chainlink-ccip solana contracts
echo ${{ env.CHAINLINK_CCIP_COMMIT_SHORT }} > /home/runner/work/chainlink/chainlink/deployment/ccip/changeset/internal/solana_contracts/.solana_contracts_rev
cp contracts/target/deploy/*.so /home/runner/work/chainlink/chainlink/deployment/ccip/changeset/internal/solana_contracts
- name: Upload artifact (if newly built)
if: env.exists == 'false'
continue-on-error: true # don't fail if the upload fails, it might conflict with another job
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: chainlink-ccip/chains/solana/contracts/target/deploy/*.so

6 changes: 6 additions & 0 deletions .github/workflows/ci-core-partial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ jobs:

- name: Build Solana artifacts
uses: ./.github/actions/setup-solana/build-contracts
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup wasmd
uses: ./.github/actions/setup-wasmd
Expand Down Expand Up @@ -217,6 +219,8 @@ jobs:

- name: Build Solana artifacts
uses: ./.github/actions/setup-solana/build-contracts
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup wasmd
uses: ./.github/actions/setup-wasmd
Expand Down Expand Up @@ -266,6 +270,8 @@ jobs:

- name: Build Solana artifacts
uses: ./.github/actions/setup-solana/build-contracts
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup wasmd
uses: ./.github/actions/setup-wasmd
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ jobs:
# do not build for core tests, core 'integration' tests, or fuzz tests
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' && matrix.type.build-solana-artifacts != 'false' }}
uses: ./.github/actions/setup-solana/build-contracts
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup wasmd
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/flakeguard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ jobs:

- name: Build Solana artifacts
uses: ./.github/actions/setup-solana/build-contracts
with:
github-token: ${{ secrets.GH_TOKEN }}

- name: Setup wasmd
uses: ./.github/actions/setup-wasmd
Expand Down
13 changes: 7 additions & 6 deletions deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
Expand Down Expand Up @@ -39,13 +40,13 @@ func Test_NewAcceptOwnershipChangeset(t *testing.T) {
require.NoError(t, err)

// compose the transfer ownership and accept ownership changesets
_, err = commonchangeset.ApplyChangesets(t, e.Env, timelockContracts, []commonchangeset.ChangesetApplication{
_, err = commonchangeset.Apply(t, e.Env, timelockContracts,
// note this doesn't have proposals.
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.TransferToMCMSWithTimelock),
Config: testhelpers.GenTestTransferOwnershipConfig(e, allChains, state),
},
})
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(commonchangeset.TransferToMCMSWithTimelock),
testhelpers.GenTestTransferOwnershipConfig(e, allChains, state),
),
)
require.NoError(t, err)

testhelpers.AssertTimelockOwnership(t, e, allChains, state)
Expand Down
32 changes: 16 additions & 16 deletions deployment/ccip/changeset/cs_accept_admin_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ func TestAcceptAdminRoleChangeset_Validations(t *testing.T) {

for _, test := range tests {
t.Run(test.Msg, func(t *testing.T) {
_, err := commonchangeset.ApplyChangesets(t, e, timelockContracts, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(changeset.AcceptAdminRoleChangeset),
Config: test.Config,
},
})
_, err := commonchangeset.Apply(t, e, timelockContracts,
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(changeset.AcceptAdminRoleChangeset),
test.Config,
),
)
require.Error(t, err)
require.ErrorContains(t, err, test.ErrStr)
})
Expand Down Expand Up @@ -143,10 +143,10 @@ func TestAcceptAdminRoleChangeset_Execution(t *testing.T) {
registryOnA := state.Chains[selectorA].TokenAdminRegistry
registryOnB := state.Chains[selectorB].TokenAdminRegistry

e, err = commonchangeset.ApplyChangesets(t, e, timelockContracts, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(changeset.ProposeAdminRoleChangeset),
Config: changeset.TokenAdminRegistryChangesetConfig{
e, err = commonchangeset.Apply(t, e, timelockContracts,
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(changeset.ProposeAdminRoleChangeset),
changeset.TokenAdminRegistryChangesetConfig{
MCMS: mcmsConfig,
Pools: map[uint64]map[changeset.TokenSymbol]changeset.TokenPoolInfo{
selectorA: map[changeset.TokenSymbol]changeset.TokenPoolInfo{
Expand All @@ -163,10 +163,10 @@ func TestAcceptAdminRoleChangeset_Execution(t *testing.T) {
},
},
},
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.AcceptAdminRoleChangeset),
Config: changeset.TokenAdminRegistryChangesetConfig{
),
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(changeset.AcceptAdminRoleChangeset),
changeset.TokenAdminRegistryChangesetConfig{
MCMS: mcmsConfig,
Pools: map[uint64]map[changeset.TokenSymbol]changeset.TokenPoolInfo{
selectorA: map[changeset.TokenSymbol]changeset.TokenPoolInfo{
Expand All @@ -183,8 +183,8 @@ func TestAcceptAdminRoleChangeset_Execution(t *testing.T) {
},
},
},
},
})
),
)
require.NoError(t, err)

configOnA, err := registryOnA.GetTokenConfig(nil, tokens[selectorA].Address)
Expand Down
Loading

0 comments on commit 39b7cba

Please sign in to comment.