-
Notifications
You must be signed in to change notification settings - Fork 7
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
solana: porting over contracts #366
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7ecc431
solana: porting over contracts
aalu1418 7d87424
cleanup gitignore
aalu1418 1a727bc
add solana build cache
aalu1418 cddd38b
enable tests
aalu1418 cff49ff
enable linting
aalu1418 31f3cdd
fix lint
aalu1418 32eed4b
reorganize tests
aalu1418 17dcb3a
use ccip-onchain-solana team as codeowner
aalu1418 7845f3a
Update chains/solana/.gitignore
aalu1418 d5ac8e1
move contracts/generated -> gobindings
aalu1418 0c48ef9
add readme
aalu1418 cc1877e
Merge branch 'main' into solana/init-ccip-contracts
aalu1418 5ca5f26
go fmt
aalu1418 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
name: Solana | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
concurrency: | ||
group: solana-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
working-directory: ./chains/solana | ||
|
||
jobs: | ||
get_anchor_version: | ||
name: Get Anchor Version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
anchor_version: ${{ steps.anchorversion.outputs.anchor }} | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
- name: Get Anchor Version | ||
id: anchorversion | ||
run: | | ||
anchor=$(make anchor_version) | ||
echo "anchor=${anchor}" >>$GITHUB_OUTPUT | ||
|
||
build_solana: | ||
name: cache build artifacts | ||
runs-on: ubuntu-latest-8cores-32GB | ||
needs: [get_anchor_version] | ||
steps: | ||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
- name: cache docker build image | ||
id: cache-image | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
lookup-only: true | ||
path: chains/solana/contracts/docker-build.tar | ||
key: ${{ runner.os }}-solana-build-${{ needs.get_anchor_version.outputs.anchor_version }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Cache cargo target dir | ||
id: cache-target | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # 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' | ||
run: | | ||
cd contracts | ||
docker buildx build . -t ccip-solana:build --build-arg ANCHOR_CLI=${{ needs.get_anchor_version.outputs.anchor_version }} | ||
docker save -o docker-build.tar ccip-solana | ||
- name: build & save contract compilation artifacts | ||
if: steps.cache-target.outputs.cache-hit != 'true' | ||
run: | | ||
docker run -v "$(pwd)/":/solana ccip-solana:build bash -c "\ | ||
set -eoux pipefail &&\ | ||
RUSTUP_HOME=\"/root/.rustup\" &&\ | ||
FORCE_COLOR=1 &&\ | ||
cd /solana/contracts &&\ | ||
anchor build &&\ | ||
chmod -R 755 ./target" | ||
|
||
rust: | ||
name: rust tests | ||
runs-on: ubuntu-latest | ||
needs: [get_anchor_version, build_solana] | ||
steps: | ||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
- name: Cache cargo target dir | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
fail-on-cache-miss: true | ||
path: chains/solana/contracts/target | ||
key: ${{ runner.os }}-solana-contract-artifacts-${{ hashFiles('**/Cargo.lock') }} | ||
- name: cache docker build image | ||
id: cache-image | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
fail-on-cache-miss: true | ||
path: chains/solana/contracts/docker-build.tar | ||
key: ${{ runner.os }}-solana-build-${{ needs.get_anchor_version.outputs.anchor_version }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: load cached image | ||
run: | | ||
docker load --input contracts/docker-build.tar | ||
- name: run tests | ||
run: | | ||
docker run -v "$(pwd)/":/solana ccip-solana:build bash -c "\ | ||
set -eoux pipefail &&\ | ||
RUSTUP_HOME=\"/root/.rustup\" &&\ | ||
FORCE_COLOR=1 &&\ | ||
cd /solana/contracts &&\ | ||
anchor build &&\ | ||
cargo check &&\ | ||
cargo clippy -- -D warnings &&\ | ||
cargo test --workspace" | ||
|
||
go: | ||
name: go tests | ||
runs-on: ubuntu-latest-8cores-32GB | ||
needs: [get_anchor_version, build_solana] | ||
steps: | ||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
- name: Cache cargo target dir | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
fail-on-cache-miss: true | ||
path: chains/solana/contracts/target | ||
key: ${{ runner.os }}-solana-contract-artifacts-${{ hashFiles('**/Cargo.lock') }} | ||
- name: cache docker build image | ||
id: cache-image | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
fail-on-cache-miss: true | ||
path: chains/solana/contracts/docker-build.tar | ||
key: ${{ runner.os }}-solana-build-${{ needs.get_anchor_version.outputs.anchor_version }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: load cached image | ||
run: | | ||
docker load --input contracts/docker-build.tar | ||
- name: Setup go | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version-file: "./chains/solana/go.mod" | ||
check-latest: true | ||
cache-dependency-path: "./chains/solana/go.sum" | ||
- name: Install gotestloghelper | ||
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest | ||
- name: Install Solana CLI | ||
run: | | ||
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)" # always use latest stable release from solana | ||
echo "PATH=$HOME/.local/share/solana/install/active_release/bin:$PATH" >> $GITHUB_ENV | ||
- name: build + test | ||
run: | | ||
set -eoux pipefail | ||
# compile artifacts | ||
docker run -v "$(pwd)/":/solana ccip-solana:build bash -c "\ | ||
set -eoux pipefail &&\ | ||
RUSTUP_HOME=\"/root/.rustup\" &&\ | ||
FORCE_COLOR=1 &&\ | ||
cd /solana/contracts &&\ | ||
anchor build" | ||
make go-tests | ||
|
||
lint: | ||
name: lint + check artifacts | ||
runs-on: ubuntu-latest | ||
needs: [get_anchor_version, build_solana] | ||
steps: | ||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
- name: Cache cargo target dir | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
fail-on-cache-miss: true | ||
path: chains/solana/contracts/target | ||
key: ${{ runner.os }}-solana-contract-artifacts-${{ hashFiles('**/Cargo.lock') }} | ||
- name: cache docker build image | ||
id: cache-image | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
fail-on-cache-miss: true | ||
path: chains/solana/contracts/docker-build.tar | ||
key: ${{ runner.os }}-solana-build-${{ needs.get_anchor_version.outputs.anchor_version }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: load cached image | ||
run: | | ||
docker load --input contracts/docker-build.tar | ||
- name: Setup go | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version-file: "./chains/solana/go.mod" | ||
check-latest: true | ||
cache-dependency-path: "./chains/solana/go.sum" | ||
- name: check artifacts | ||
run: | | ||
set -eoux pipefail | ||
# compile artifacts | ||
docker run -v "$(pwd)/":/solana ccip-solana:build bash -c "\ | ||
set -eoux pipefail &&\ | ||
RUSTUP_HOME=\"/root/.rustup\" &&\ | ||
FORCE_COLOR=1 &&\ | ||
cd /solana/contracts &&\ | ||
rm -rf target/idl &&\ | ||
anchor build" | ||
|
||
go install github.com/gagliardetto/anchor-go@v0.2.3 | ||
./scripts/anchor-go-gen.sh | ||
make format | ||
git diff --exit-code | ||
- name: Install linter | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2 | ||
- name: Run linter | ||
run: make lint-go | ||
- name: Print lint report artifact | ||
if: failure() | ||
shell: bash | ||
run: cat ./golangci-lint-report.xml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# 2024-12-04 - The codeowners file is correct | ||
* @smartcontractkit/ccip-offchain | ||
|
||
# solana development ownership | ||
/chains/solana @smartcontractkit/ccip-onchain-solana |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.direnv | ||
*.DS_Store | ||
**/*.rs.bk | ||
.idea | ||
.vscode/ | ||
|
||
# ignore target folders except IDLs | ||
contracts/target/* | ||
!contracts/target/idl/ | ||
contracts/programs/*/target | ||
contracts/.anchor | ||
# keypair used by anchor/anchor test | ||
contracts/id.json | ||
# ignore all except shared localnet keys | ||
contracts/artifacts/* | ||
!contracts/artifacts/localnet/ | ||
test-ledger | ||
|
||
# Test & linter reports | ||
.test_summary/ | ||
*report.xml | ||
*report.json | ||
*.out | ||
*coverage* | ||
eslint-report.json | ||
.run.id | ||
override*.toml | ||
# go work files | ||
go.work* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
run: | ||
timeout: 15m0s | ||
linters: | ||
enable: | ||
- exhaustive | ||
- exportloopref | ||
- revive | ||
- goimports | ||
- gosec | ||
- misspell | ||
- rowserrcheck | ||
- errorlint | ||
- unconvert | ||
- sqlclosecheck | ||
- noctx | ||
- whitespace | ||
- depguard | ||
- containedctx | ||
- fatcontext | ||
- mirror | ||
- loggercheck | ||
linters-settings: | ||
exhaustive: | ||
default-signifies-exhaustive: true | ||
goimports: | ||
local-prefixes: github.com/smartcontractkit/chainlink-ccip/chains/solana | ||
golint: | ||
min-confidence: 1.0 | ||
gosec: | ||
excludes: | ||
- G101 | ||
- G104 | ||
# - G204 | ||
# - G304 | ||
# - G404 | ||
govet: | ||
enable: | ||
- shadow | ||
settings: | ||
printf: | ||
# Additionally check custom logger | ||
funcs: | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Debugf | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Infof | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Warnf | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Errorf | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Panicf | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Fatalf | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).AssumptionViolationf | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Tracef | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Criticalf | ||
errorlint: | ||
# Allow formatting of errors without %w | ||
errorf: false | ||
revive: | ||
confidence: 0.8 | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: exported | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
# - name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
# - name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
- name: waitgroup-by-value | ||
- name: unconditional-recursion | ||
- name: struct-tag | ||
# - name: string-format | ||
- name: string-of-int | ||
- name: range-val-address | ||
- name: range-val-in-closure | ||
- name: modifies-value-receiver | ||
- name: modifies-parameter | ||
- name: identical-branches | ||
- name: get-return | ||
# - name: flag-parameter | ||
- name: early-return | ||
- name: defer | ||
- name: constant-logical-expr | ||
# - name: confusing-naming | ||
# - name: confusing-results | ||
- name: bool-literal-in-expr | ||
- name: atomic | ||
depguard: | ||
rules: | ||
main: | ||
list-mode: lax | ||
deny: | ||
- pkg: "cosmossdk.io/errors" | ||
desc: Use the standard library instead | ||
- pkg: "github.com/ethereum/go-ethereum" | ||
desc: This is chain must be isolated from ethereum | ||
- pkg: "github.com/go-gorm/gorm" | ||
desc: Use github.com/jmoiron/sqlx directly instead | ||
- pkg: "github.com/gofrs/uuid" | ||
desc: Use github.com/google/uuid instead | ||
- pkg: "github.com/pkg/errors" | ||
desc: Use the standard library instead, for example https://pkg.go.dev/errors#Join | ||
- pkg: "github.com/satori/go.uuid" | ||
desc: Use github.com/google/uuid instead | ||
- pkg: "github.com/test-go/testify/assert" | ||
desc: Use github.com/stretchr/testify/assert instead | ||
- pkg: "github.com/test-go/testify/mock" | ||
desc: Use github.com/stretchr/testify/mock instead | ||
- pkg: "github.com/test-go/testify/require" | ||
desc: Use github.com/stretchr/testify/require instead | ||
- pkg: "go.uber.org/multierr" | ||
desc: Use the standard library instead, for example https://pkg.go.dev/errors#Join | ||
- pkg: "gopkg.in/guregu/null.v1" | ||
desc: Use gopkg.in/guregu/null.v4 instead | ||
- pkg: "gopkg.in/guregu/null.v2" | ||
desc: Use gopkg.in/guregu/null.v4 instead | ||
- pkg: "gopkg.in/guregu/null.v3" | ||
desc: Use gopkg.in/guregu/null.v4 instead | ||
- pkg: github.com/go-gorm/gorm | ||
desc: Use github.com/jmoiron/sqlx directly instead | ||
loggercheck: | ||
# Check that *w logging functions have even number of args (i.e., well formed key-value pairs). | ||
rules: | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Debugw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Infow | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Warnw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Errorw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Panicw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Fatalw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).AssumptionViolationw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Tracew | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Criticalw | ||
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).With | ||
issues: | ||
exclude-rules: | ||
- path: test | ||
text: "^G404:" | ||
linters: | ||
- gosec | ||
- path: _test.go | ||
text: "G115:" # ignore integer overflow in test conversions | ||
linters: | ||
- gosec |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we migrate the
.pre-commit-config.yaml
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just the minimum set to keep developing - if you want to migrate it, you're definitely welcome to make another PR :)