Skip to content

Commit

Permalink
Merge pull request #14278 from smartcontractkit/ccip/capabilities-deb…
Browse files Browse the repository at this point in the history
…ug-contracts-fmt

Merge CCIP V1.6 [CCIP-2946]
  • Loading branch information
securejavier authored Aug 30, 2024
2 parents b36e731 + 45d97f6 commit 7eec696
Show file tree
Hide file tree
Showing 233 changed files with 27,890 additions and 20,149 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-plums-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#updated move latest capabilities code from ccip repo to chainlink repo [CCIP-2946]
11 changes: 9 additions & 2 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ jobs:
- cmd: go_core_tests
id: core_unit
os: ubuntu22.04-32cores-128GB
printResults: true
- cmd: go_core_ccip_deployment_tests
id: core_unit
os: ubuntu22.04-32cores-128GB
printResults: true
- cmd: go_core_race_tests
id: core_race
# use 64cores for overnight runs only due to massive number of runs from PRs
Expand Down Expand Up @@ -177,9 +182,11 @@ jobs:
CL_DATABASE_URL: ${{ env.DB_URL }}
run: ./tools/bin/${{ matrix.type.cmd }} ./...
- name: Print Filtered Test Results
if: ${{ failure() && matrix.type.cmd == 'go_core_tests' && needs.filter.outputs.changes == 'true' && steps.run-tests.conclusion == 'failure' }}
if: ${{ failure() && needs.filter.outputs.changes == 'true' && steps.run-tests.conclusion == 'failure' }}
run: |
cat output.txt | gotestloghelper -ci
if [[ "${{ matrix.type.printResults }}" == "true" ]]; then
cat output.txt | gotestloghelper -ci
fi
- name: Print Races
id: print-races
if: ${{ failure() && matrix.type.cmd == 'go_core_race_tests' && needs.filter.outputs.changes == 'true' }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ override*.toml
.venv/

ocr_soak_report.csv

vendor/*
6 changes: 3 additions & 3 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ packages:
outpkg: mock_contracts
interfaces:
CommitStoreInterface:
github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry:
github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter:
config:
dir: core/gethwrappers/ccip/mocks/
filename: price_registry_interface.go
filename: fee_quoter_interface.go
outpkg: mock_contracts
interfaces:
PriceRegistryInterface:
FeeQuoterInterface:
github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface:
config:
dir: core/gethwrappers/ccip/mocks/
Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/quick-olives-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': minor
---

#updated move latest ccip contracts code from ccip repo to chainlink repo [CCIP-2946]
37 changes: 37 additions & 0 deletions contracts/.husky/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Husky git hooks
The folder contains [husky](https://github.com/typicode/husky) git hooks that automate pre-commit and pre-push commands.

## Setup

Create an `.env` file in this folder to enable hooks:

```sh
# Can be left blank to compile everything
FOUNDRY_PROFILE=ccip
HUSKY_ENABLE_PUSH_HOOKS=true
HUSKY_ENABLE_COMMIT_HOOKS=true
UPSTREAM_BRANCH=origin/ccip-develop
```

```sh
# Automatically ran after pnpm install
pnpm prepare
```

### Script procedure

The setup is done via the `prepare.sh` script, which installs husky and enables the hooks.

The prepare step is skipped if we are in CI. This is checked via the `CI=true` flag, which is always set to true on GitHub actions.

## Hooks & Scripts

### Pre-commit
Runs [lint-staged](https://github.com/lint-staged/lint-staged), which automatically detects `.sol` file changes and applies `forge fmt` only on the changed files.

Configured in `package.json` in the `lint-staged` field.

### Pre-push
Runs forge build, test, solhint and optionally suggests to generate snapshots and wrappers.

Due to a [git workflow limitation](https://stackoverflow.com/questions/21334493/git-commit-in-pre-push-hook), generating wrappers & snapshots requires resubmitting the push (via `--no-verify` or by skiping the snapshot / wrappers).
14 changes: 14 additions & 0 deletions contracts/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

source contracts/.husky/.env

# Only run hook on enabled
if ! [[ $HUSKY_ENABLE_COMMIT_HOOKS == "true" && -n $UPSTREAM_BRANCH ]]; then
exit 0
fi

cd contracts

# Run lint steps
pnpm lint-staged -v
47 changes: 47 additions & 0 deletions contracts/.husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -e

source contracts/.husky/.env

# Only run hook on enabled
if ! [[ $HUSKY_ENABLE_PUSH_HOOKS == "true" && -n $UPSTREAM_BRANCH ]]; then
exit 0
fi

# Skip on no changes
current_branch=$(git branch --show-current)
changes_root=$(git diff --name-only $UPSTREAM_BRANCH...$current_branch -- "contracts/")

if ! [[ -n $changes_root ]]; then
echo "Pre-push hook for contracts skipped - no changes detected"
exit 0
fi

cd contracts

FOUNDRY_PROFILE=$FOUNDRY_PROFILE forge build
FOUNDRY_PROFILE=$FOUNDRY_PROFILE forge test
pnpm solhint

# Skip interactive commands if interactive mode (/dev/tty) is unavailable
# https://stackoverflow.com/a/69088164
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
read -n1 -p "Re-generate snapshots & wrappers? (Y/n)" snapshot_answer < /dev/tty
echo $snapshot_answer

if [ "$snapshot_answer" != "${snapshot_answer#[Yy]}" ] ;then
# Create gas snapshot & commit gas snapshot
make snapshot
make wrappers

git add ./gas-snapshots
git add ../core/gethwrappers

# Check if commit is successful (non-empty)
if git commit -m "chore: update gas snapshots and wrappers"; then
# The commit is not included - need to push again (https://stackoverflow.com/questions/21334493/git-commit-in-pre-push-hook)
printf "\033[0;31m Snapshot commit created - run git push again \033[1;33m(skip snapshot, or use the --no-verify push option)\n"
exit 1
fi
fi
fi
19 changes: 19 additions & 0 deletions contracts/.husky/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

# Detect if in CI to skip hooks
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if [[ $CI == "true" ]]; then
exit 0
fi

# Skip hooks creation if unconfigured
if ! [ -f .husky/.env ]; then
printf "\033[1;33mNo .env file found in contracts/.husky, skipping hooks setup.\e[0m\n"
exit 0
fi

cd ../
chmod +x ./contracts/.husky/*.sh
pnpm husky ./contracts/.husky
echo "Husky hooks prepared."
20 changes: 20 additions & 0 deletions contracts/.husky/verify-changeset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

# Determine the current branch
current_branch=$(git branch --show-current)
upstream_branch="origin/ccip-develop"

# Compare the directory against the upstream branch
changes_root=$(git diff --name-only $upstream_branch...$current_branch -- ".changeset")

if ! [ -n "$changes_root" ]; then
printf "\033[1;33mRoot changeset changes not found, Consider running pnpm changeset in the root directory if there is significant off-chain impact.\e[0m\n"
fi

changes_contracts=$(git diff --name-only $upstream_branch...$current_branch -- "contracts/.changeset")

if ! [ -n "$changes_contracts" ]; then
printf "\033[0;31mContracts changeset changes not found, Make sure to run & commit \033[1;33mpnpm changeset\033[0;31m in the contracts directory.\n"
exit 1
fi
4 changes: 4 additions & 0 deletions contracts/.solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@
# Always ignore vendor
./src/v0.8/vendor
./node_modules/

# Ignore RMN contracts temporarily
./src/v0.8/ccip/RMNRemote.sol
./src/v0.8/ccip/RMNHome.sol
10 changes: 10 additions & 0 deletions contracts/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ wrappers-all: pnpmdep mockery abigen ## Recompiles solidity contracts and their
# go_generate contains a call to compile all contracts before generating wrappers
go generate ../core/gethwrappers/go_generate.go

# Use this to generate compiled JSON artifacts for gauntlet-plus-plus.
# This is currently only used for CCIP.
# example: make artifact-generate contract=LockReleaseTokenPoolAndProxy solcversion=0.8.24 artifactpath=../../gauntlet-plus-plus/packages-ethereum/operations-ccip/src/artifacts/1.5.0/lock-release-token-pool-and-proxy.json
artifact-generate: export FOUNDRY_PROFILE=ccip
.PHONY: artifact-generate
artifact-generate:
chmod +x ./scripts/generate_compiled_json_ccip.sh
./scripts/generate_compiled_json_ccip.sh $(contract) $(solcversion) $(artifactpath)


help:
@echo ""
@echo " .__ .__ .__ .__ __"
Expand Down
Loading

0 comments on commit 7eec696

Please sign in to comment.