Skip to content
across-protocolPublic

About

Smart contracts for Across protocol

Resources

Stars

159 stars

Watchers

14 watching

Forks

Latest commit

 

History

1,031 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Across-logo

Contains smart contract suite to enable instant token transfers between any two networks. Relays are backstopped by liquidity held in a central HubPool on Ethereum, which also serves as the cross-chain administrator of all contracts in the system. SpokePool contracts are deployed to any network that wants to originate token deposits or be the final destination for token transfers, and they are all governed by the HubPool on Ethereum.

These contracts have been continuously audited by OpenZeppelin and the audit reports can be found here.

Understanding Upgradeability

The SpokePool contracts are UUPSUpgradeable Proxy contracts which means that their addresses will always be the same but their implementation code can change.

All SpokePools can be upgraded if the "admin" of the contract calls upgradeTo. The SpokePool's admin is set by implementing the _requireAdminSender() virtual function in the child contract. For example here are the Arbitrum and Optimism implementations of the admin check.

All SpokePools are implemented such that the admin is the HubPool, and therefore we describe the SpokePools as having "cross-chain ownership". The owner of the HubPool can call this function to send a cross-chain execution of upgradeTo on any SpokePool in order to upgrade it.

This script is useful for creating the calldata to execute a cross-chain upgrade via the HubPool.

Deployed Contract Versions

The latest contract deployments can be found in /broadcast/deployed-addresses.json (auto-generated by yarn extract-addresses).

Requirements

This repository assumes you have Node installed, using the CI version 24.23.0 or a later patched Node 24 release. Depending on what you want to do with the repo you might also need foundry and anchor to also be installed. If you have build issues please ensure these are both installed first.

Use Node 24 for SVM development. Anchor.toml pins Anchor 1.1.2 and Agave 4.1.2; install these versions instead of selecting a moving latest toolchain. Internal Anchor client types use @anchor-lang/core 1.1.2. These types are not npm exports; downstream clients generate their own types from the published JSON or use the SDK. For the 6.0.0 release, coordinate the SDK/relayer package updates and Anchor import changes with the program and canonical IDL upgrade. Legacy Program.at/fetchIdl readers do not follow the new metadata address. Artifact generation restores the canonical event-authority PDA seeds omitted by Anchor 1.1's IDL output, preserving typed account resolution and Codama async builders. This metadata does not change program bytes.

SVM JSON interfaces

The npm package exposes these stable JSON paths for downstream Anchor clients and Codama generation:

@across-protocol/contracts/svm/idl/svm_spoke.json
@across-protocol/contracts/svm/idl/multicall_handler.json
@across-protocol/contracts/svm/idl/sponsored_cctp_src_periphery.json

svm_spoke is the V5 interface. multicall_handler and sponsored_cctp_src_periphery are legacy compatibility interfaces for existing quote construction and event indexing; they are not used by V5 flows.

For example, load the Spoke IDL directly:

const spokeIdl = require("@across-protocol/contracts/svm/idl/svm_spoke.json")

Pin an exact contracts package version and commit your lockfile, together with compatible versions of your client generator and runtime. IDLs are versioned with the npm package; metadata.version identifies the program's declared version and is not the npm release version. Consumers can generate clients from the installed JSON without a contracts checkout or Rust, Anchor CLI, or Foundry. Select the deployed program address for your environment; installing a package does not deploy or upgrade programs.

The Spoke IDL includes the Rust-derived V5AdapterInput, AcrossDepositJitParams, and V5FillJit schemas carried inside opaque instruction bytes. Event-authority PDA seeds are preserved for account resolution. Circle owns the MessageTransmitterV2 and TokenMessengerMinterV2 schemas. They have no stable /svm/idl/ exports here; downstream generators should use reviewed, commit-pinned IDLs from Circle's repository, with the source revision recorded and compatibility checked against the intended deployment. The reviewed Circle V2 snapshots in idls/ remain internal inputs for contracts tests and scripts. SDK owns downstream Circle generation; consumers may also generate locally from a reviewed upstream pin.

Breaking npm package changes

The npm package @across-protocol/contracts@6.0.0 exposes the three JSON IDLs as its entire public SVM interface. Generate clients from these IDLs or use the SDK. The handwritten legacy multicall coders have no SDK replacement. V5 executes messages through Gateway command tapes.

Removed interface Replacement
Root *Client namespaces and dist/src/svm/clients/** SDK-owned clients or local generation from the three stable Across JSON paths
Root *Idl / *Anchor and dist/src/svm/assets/** Stable Across JSON plus consumer-owned types; reviewed upstream Circle JSON for Circle programs
Internal SVM domain types at dist/src/types/** Consumer-owned types using the published IDLs and validated SDK interfaces
Root SVM helpers and dist/src/svm/web3-v1/**, web3-v2/** Validated SDK helpers or equivalent consumer-owned implementations
MulticallHandlerCoder / AcrossPlusMessageCoder V5 Gateway command tapes for message execution; V4 Sponsored CCTP uses its dedicated periphery

All dist/src/svm/** and dist/src/types/** files are physically absent from the tarball. The package build excludes internal SVM domain types; tests and scripts still compile them through their own configurations. An explicit exports map rejects their deep imports, and the files allowlist excludes stale/internal output even when packing without build scripts. There is no catch-all dist entry point. Anchor, web3.js v1 and Borsh are development dependencies for internal code. Kit and Codama remain development dependencies only for the external packed-IDL consumer check.

This cleanup is SVM-only. The following EVM/shared APIs remain supported and published:

  • Root deployment lookup functions, DEPLOYMENTS, MerkleTree, EMPTY_MERKLE_ROOT, constants and getNodeUrl.
  • Explicit compatibility paths for dist/index, dist/src/DeploymentUtils and dist/utils/{index,MerkleTree,constants,network}, including extensionless, .js and .d.ts variants. The dist and dist/utils barrel aliases also remain; neither is a catch-all export.
  • Solidity sources at contracts/**/*.sol, ABIs at evm/abi/<Contract>.json, creation bytecode at evm/bin/<Contract>.bin (and the same under evm/test/ for test contracts), deployment data at dist/broadcast/deployed-addresses.json, and package.json.

The deployment JSON path retains an extensionless CommonJS alias. The EVM ABI, EVM bytecode and SVM IDL paths require their explicit extension.

EVM ABIs and bytecode are named by contract alone. The bytecode is 0x-prefixed hex, and is published only for contracts that can be deployed: an interface or an abstract contract has an ABI and no .bin file. Both were previously published together at dist/evm/artifacts/<SourceFile>.sol/<Contract>.json, following Foundry's layout; that path is no longer published.

Only contracts declared under contracts/ are published. A dependency's contracts, such as OpenZeppelin's ERC20, are not: take those from the dependency itself.

Contracts declared under contracts/test/ are for tests alone, and are published apart from the rest, at evm/test/abi/<Contract>.json and evm/test/bin/<Contract>.bin: mocks such as MockSpokePool, and the ERC1967Proxy that tests deploy a SpokePool behind. That proxy inherits OpenZeppelin's v4 proxy and behaves as it does, but its bytecode is not that of a proxy deployed by DeploymentUtils.sol. Nothing under evm/test/ is deployed in production. A contract's name is published in one of the two places and never both.

Filesystem access to published EVM artifacts remains supported. Consumers can resolve @across-protocol/contracts/package.json to locate the package root and read its artifact files directly. The parent build retired the deep paths dist/utils/utils and dist/src/consts in #1601.

An artifacts/data-only package is a separate follow-up. Moving shared Merkle utilities, constants, deployment lookup functions and other runtime helpers downstream requires an inventory of production, test, script and CI consumers, validated replacements and a coordinated breaking release. ACP-240 does not perform that migration.

Madrid, Indexer and the Quote API validated the package changes with SDK 5.0.0-svm-clients.9, which pins contracts 6.0.0-beta.6. Quote API retains its direct contracts 5.0.26 pin for EVM deployment lookups.

Use the matching GitHub release tag v6.0.0 to publish the npm package before the Across V5 Spoke upgrade. Record the tarball hash, IDL and generator pins, and matching binary archives in the release handoff. Keep Solana V5 writes disabled until the later svm_spoke upgrade and cutover checks.

Compatibility change from 6.0.0-beta.3: the test program's root TestIdl and TestAnchor exports and dist/src/svm/assets/idl/test.json, dist/src/svm/assets/test.js and dist/src/svm/assets/test.d.ts are removed. Tests that need these interfaces must generate them from the matching source tag; they are not production APIs.

For maintainers, yarn generate-svm-artifacts always generates production interfaces, even with IS_TEST=true. yarn generate-svm-test-idls writes test-feature and mock interfaces only under target/. The explicit /svm/idl/ entries in package.json allowlist the public Across IDLs. yarn build-ts exports those JSON files only to the stable paths. Internal Anchor types and Circle JSON are never copied into dist. npm pack and npm publish run the same prepack build, including EVM artifact export. Generate production artifacts first (and build EVM artifacts with yarn build-evm-foundry). Run yarn test-svm-idl-package to inspect a real tarball and generate/compile clients in an external fixture using only its IDLs. This check requires no validator or network access.

SVM binaries are a separate GitHub Releases channel: svm-verified-test-binaries.tar.gz contains test-feature binaries for downstream integration tests; svm-verified-production-binaries.tar.gz contains production binaries. Both archives contain target/deploy. Pin the release tag corresponding to the npm package version when pairing interfaces and binaries. Test-only IDLs and mock interfaces are not npm exports; tests needing those interfaces must generate them from the matching source tag. Test binaries must never be used for production deployment.

Build

yarn
yarn build # Will build all code. Compile solidity & rust (local toolchain), generate ts outputs
yarn build-verified # Will build all code. Compile solidity & rust (verified docker build), generate ts outputs

EVM builds and tests use the Foundry version pinned in .foundry-version; CI installs exactly that version via foundry-rs/foundry-toolchain. Run yarn pin-foundry to switch your local toolchain to it (a no-op when it already matches). Bump the pin by editing that file.

SVM local, verified, and real-Gateway builds fail on stack-overflow diagnostics even when the compiler exits successfully. The shared guard is scripts/svm/buildHelpers/runSbfBuild.sh; run yarn test-svm-build-guard to test it without a validator or Rust build. CI invalidates cached SVM builds when these build helpers change. Host IDL generation and Rust tests use Rust 1.97.1, pinned in the SVM setup action; use that version locally when reproducing CI artifacts. CI installs Agave, Anchor and solana-verify with scripts/svm/buildHelpers/installSvmTools.sh, which checks the Linux x86_64 release assets against the SHA-256 pins in verified-build.json on fresh downloads and cache hits alike. These host tools are separate from the release image's SBF compiler.

Test

yarn test # Run all unit tests without gas analysis, using local toolchain SVM build
yarn test-verified # Run all unit tests (without gas analysis) with verified SVM docker build
yarn test:gas-analytics # Run only tests that count gas costs
yarn test:report-gas # Run unit tests with gas reporting enabled
yarn test-evm # Only test EVM code
yarn test-svm # Only test SVM code (local toolchain build)
yarn test-svm-solana-verify # Only test SVM code (verified docker build)
yarn typecheck-tests # Typecheck all TypeScript tests without emitting files

The test typecheck uses tsconfig.test.json and requires internal Anchor assets and test-feature IDLs. Run yarn generate-svm-artifacts && yarn generate-svm-test-idls first. CI runs this check after preparing these artifacts, before the verified SVM build and runtime tests. The package build continues to use tsconfig.json.

Lint

yarn lint
yarn lint-js # Only lint Javascript
yarn lint-rust # Only lint rust
yarn lint-solidity # Only lint solidity
yarn lint-fix

Deploy and Verify

EVM

Foundry

forge build

forge script script/001DeployHubPool.s.sol:DeployHubPool --rpc-url ethereum --broadcast --verify -vvvv

Foundry (ZKSync)

To enable ZKSync support, the zksync fork of foundry must be installed (see here for instructions).

Also, the FOUNDRY_PROFILE environment variable must be set to zksync.

FOUNDRY_PROFILE=zksync forge script script/016DeployZkSyncSpokePool.s.sol:DeployZkSyncSpokePool --rpc-url zksync --broadcast --verify -vvvv

Alternatively, the yarn forge-script-zksync command can be used to deploy the contract.

yarn forge-script-zksync script/016DeployZkSyncSpokePool.s.sol:DeployZkSyncSpokePool --rpc-url zksync --broadcast --verify -vvvv

SVM

For CCTP V2 root/admin finalization, pause recovery and light-chain intent examples, see the Solana operational scripts guide.

V5 svm_spoke is configured for mainnet and local-validator testing. Its public-devnet deployment and supporting offchain infrastructure are not configured, so Anchor.toml has no devnet Spoke entry. The devnet deployment examples below require a separately configured deployment; the legacy devnet Spoke address is not a V5 target.

Before deploying for the first time make sure all program IDs in lib.rs and Anchor.toml are the same as listed when running anchor keys list. If not, update them to match the deployment keypairs under target/deploy/ and commit the changes.

V5 PDA addresses and bumps are pinned to the configured Spoke and Gateway IDs to avoid runtime derivation costs. If either program ID changes, update its dependent PDA constants and run cargo test -p svm-spoke --lib to check consistency.

Use solana-verify 0.5.1, matching CI, to build the verified Docker binaries. The build removes each previous binary before compilation and rejects missing or empty output; failed builds must not be used for deployment. Keep the stack-diagnostic guard enabled, since SBF compilers can report stack overflows with a successful exit status. On Linux, Docker can leave target/deploy owned by root. If the next verified build reports a permissions error, restore ownership from the repository root with sudo chown -R "$(id -u):$(id -g)" target/deploy, then rerun the build.

verified-build.json pins the release image by immutable digest: Agave 4.0.3, cargo-build-sbf 4.0.0, platform-tools 1.53, and SBF architecture v0. This release recipe is separate from the Agave 4.1.2 validator/development toolchain. It was selected because the pinned verifier's 0.5.1 image registry did not include Agave 4.1.2. Newer upstream images exist; updating this recipe requires rebuilding and testing the release binaries. Never infer the image from Solana SDK crate versions. yarn test-svm-solana-verify runs the full suite against test-feature binaries: it retains the mocked clock and per-test state seeds. yarn test-svm-production then rebuilds without that feature and tests seed-zero initialization, disabled test controls, Clock-sysvar expiry and event self-CPI in a fresh ledger. Deploy only the latter production artifacts; a test-feature build overwrites target/deploy and must never be deployed.

Validator tests share test/svm/provider.ts, which sets the connection, transaction confirmation and preflight commitments to confirmed. Use this provider for fixture writes and dependent transactions so simulations cannot run against a bank that predates the fixture state.

All workspace programs use Anchor 1.1.2. The Spoke retains the pre-upgrade V5 branch's custom error numbers; its IDL now exposes all four ranges from one enum. Sponsored CCTP's formerly overlapping enums now use Common 6000–6002, SVM 7000–7010 and CCTP 8000–8002. This changes error numbers in a new Sponsored CCTP build, not its existing deployment. Upgrading the source does not require redeploying retiring Sponsored CCTP or multicall programs. The bundled Sponsored CCTP IDL/client error tables describe that new build, not the existing deployment. For live or historical transactions from the old deployment, use the error name in the program logs and the matching release artifacts; numeric codes alone are ambiguous across its old enums.

Before an audited release, build from a clean checkout of the reviewed commit and record the commit, Cargo.lock, verified-build.json, enabled features (none for production), program IDs and executable hashes. Release Cargo profiles use lto = "fat", one codegen unit, and overflow checks. The lockfile pins the SBF dependency graph, including the Solana hash/secp256k1 crates. Verify reproducibility by comparing executable hashes; matching CLI versions alone does not prove byte-identical builds.

unset IS_TEST # Ensures the production build is used (not the test feature)
yarn build-svm-solana-verify # Builds verified SVM binaries
yarn generate-svm-artifacts # Builds IDLs

Export required environment variables, e.g.:

export RPC_URL=https://api.devnet.solana.com
export KEYPAIR=~/.config/solana/dev-wallet.json
export PROGRAM=svm_spoke # Also repeat the deployment process for multicall_handler
export PROGRAM_ID=$(cat target/idl/$PROGRAM.json | jq -r ".address")
export MULTISIG= # Export the Squads vault, not the multisig address!
export BUILD_IMAGE=$(node -p 'require("./verified-build.json").image')

For the initial deployment also need these:

export SVM_CHAIN_ID=$(cast to-dec $(cast shr $(cast shl $(cast keccak solana-devnet) 208) 208))
export HUB_POOL=0x14224e63716afAcE30C9a417E0542281869f7d9e # This is for sepolia, update for mainnet
export DEPOSIT_QUOTE_TIME_BUFFER=3600
export FILL_DEADLINE_BUFFER=21600
export MAX_LEN=$(( 2 * $(stat -c %s target/deploy/$PROGRAM.so) )) # Reserve twice the size of the program for future upgrades

Initial deployment

Deploy the selected program and initialize its canonical IDL while $KEYPAIR holds upgrade authority:

solana program deploy \
  --url $RPC_URL \
  --keypair $KEYPAIR \
  --program-id target/deploy/$PROGRAM-keypair.json \
  --max-len $MAX_LEN \
  --with-compute-unit-price 100000 \
  --max-sign-attempts 100 \
  --use-rpc \
  target/deploy/$PROGRAM.so
anchor idl init \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR \
  --filepath target/idl/$PROGRAM.json \
  $PROGRAM_ID

Update and commit deployments/legacy-addresses.json with the deployed program ID and deployment slot.

Anchor 1.1.2 stores canonical IDLs in the separate Program Metadata program. Its authority follows the program upgrade authority; there is no separate anchor idl set-authority step. Initialize the canonical IDL and complete the applicable program setup below before transferring program authority. If Squads already holds authority, perform the canonical metadata write through Squads as described below.

For svm_spoke, initialize the state while $KEYPAIR is still the program's upgrade authority. The script makes $KEYPAIR the initial local owner, then transfers local ownership to $MULTISIG via --svmAdmin. Program upgrade authority is transferred separately after setup. See the initialization requirements.

anchor run initialize \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR -- \
  --chainId $SVM_CHAIN_ID \
  --remoteDomain 0 \
  --crossDomainAdmin $HUB_POOL \
  --svmAdmin $MULTISIG \
  --depositQuoteTimeBuffer $DEPOSIT_QUOTE_TIME_BUFFER \
  --fillDeadlineBuffer $FILL_DEADLINE_BUFFER

Create the vault for accepting deposits, e.g.:

export MINT=4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU # This is USDC on devnet, update with address for mainnet
anchor run createVault \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR -- \
  --originToken $MINT

For sponsored_cctp_src_periphery, initialize and set the minimum deposit amount for the supported burn token:

# Replace --quoteSigner with actual quote signer address
anchor run initializeSponsoredCctpSrc \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR -- \
  --quoteSigner 0x0000000000000000000000000000000000000000
# Below is USDC on devnet, replace --burnToken with mainnet burn token and --amount with required minimum deposit amount (raw value)
anchor run setMinimumDepositSponsoredCctpSrc \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR -- \
  --burnToken 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU \
  --amount 0

These sponsored CCTP scripts submit directly when $KEYPAIR holds upgrade authority. If authority has already been transferred to Squads, they simulate and export transactions for multisig execution instead. Execute and confirm the initialization transaction through Squads before running the minimum-deposit script, then execute its exported transaction through Squads as well; simulation alone does not update on-chain state.

After completing the setup for the selected program, transfer its upgrade authority to the multisig if $KEYPAIR still holds it:

solana program set-upgrade-authority \
  --url $RPC_URL \
  --keypair $KEYPAIR \
  --skip-new-upgrade-authority-signer-check \
  $PROGRAM_ID \
  --new-upgrade-authority $MULTISIG

Upgrades

Initiate the program upgrade:

solana program write-buffer \
  --url $RPC_URL \
  --keypair $KEYPAIR \
  --with-compute-unit-price 100000 \
  --max-sign-attempts 100 \
  --use-rpc \
  target/deploy/$PROGRAM.so
export BUFFER= # Export the logged buffer address from the command above
solana program set-buffer-authority \
  --url $RPC_URL \
  --keypair $KEYPAIR \
  $BUFFER \
  --new-buffer-authority $MULTISIG

Add the program ID to Squads multisig (https://devnet.squads.so/ for devnet and https://app.squads.so/ for mainnet) in the Developers/Programs section. Prepare the upgrade with the binary buffer address and refund recipient, and verify the buffer authority as prompted. Prepare the IDL update below before approving and executing the release.

Prepare an Anchor 1.1.2 Program Metadata buffer and transfer its authority to the Squads vault:

anchor idl create-buffer \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR \
  --filepath target/idl/$PROGRAM.json
export IDL_BUFFER= # Export the logged metadata buffer address
anchor idl set-buffer-authority \
  --provider.cluster $RPC_URL \
  --provider.wallet $KEYPAIR \
  --new-authority $MULTISIG \
  $IDL_BUFFER

Export the canonical IDL update using the official Program Metadata CLI. This replaces scripts/svm/squadsIdlUpgrade.ts for Anchor 1.1.2 programs:

export IDL_REFUND_RECIPIENT=$(solana-keygen pubkey "$KEYPAIR") # Refund the operator that funded the IDL buffer
npx --yes @solana-program/program-metadata@0.10.0 write idl "$PROGRAM_ID" --rpc "$RPC_URL" --buffer "$IDL_BUFFER" --export "$MULTISIG" --export-encoding base58 --tx-version legacy --single-extend-per-tx --close-buffer "$IDL_REFUND_RECIPIENT"

--export prints unsigned transactions without submitting them. $MULTISIG must be the Squads vault PDA that holds program and buffer authority, not the Squads multisig account. Transferring buffer authority does not reimburse the operator: --close-buffer returns that buffer's rent to the operator wallet above. The vault separately funds any canonical metadata account rent, so it needs sufficient SOL. The command creates the canonical metadata account if absent, including the first upgrade from Anchor 0.31, or updates it if it already exists.

For the first upgrade from Anchor 0.31, also prepare closure of the old canonical IDL while the old binary still supports its dispatcher. Check its authority with the old CLI; it must match the Squads vault used below. The legacy IDL authority is independent of the program upgrade authority.

export LEGACY_ANCHOR="$HOME/.avm/bin/anchor-0.31.1"
"$LEGACY_ANCHOR" idl authority --provider.cluster "$RPC_URL" "$PROGRAM_ID"
export LEGACY_IDL_REFUND_RECIPIENT= # Set the reviewed recipient of the old canonical IDL's rent
yarn ts-node scripts/svm/squadsIdlUpgrade.ts --programId "$PROGRAM_ID" --multisig "$MULTISIG" --closeIdl --closeRecipient "$LEGACY_IDL_REFUND_RECIPIENT"

This helper prints a single unsigned Base58 message containing only the legacy IDL close instruction. Import it before the binary upgrade instruction in the same Squads transaction. It closes the old canonical account, not the new Program Metadata buffer. Skip this step when no legacy IDL exists. Coordinate client updates first: old @coral-xyz/anchor readers stop fetching that IDL after closure.

In Squads, use Developers → Transaction Builder → Create Transaction → Add Instruction → Import as Base58 to import each printed transaction. Review the program ID, canonical metadata account, vault signer and buffer-rent recipient. Include the final IDL write and buffer closure with the binary upgrade in one reviewed transaction where possible. Extra transactions can be needed to create or grow the destination account; the uploaded buffer data does not need to be uploaded again. If the CLI prints multiple transactions, retain their order; --single-extend-per-tx limits account growth to 10 KiB per Squads execution. Execute any preparatory allocation/growth transactions before the final write, and do not combine those exports into one transaction. Then collect the required approvals and execute the release. If the binary upgrade and final IDL write must be separate, execute the IDL write immediately after the binary upgrade.

After execution, fetch the canonical IDL and compare its JSON content with the release artifact:

anchor idl fetch --provider.cluster "$RPC_URL" --commitment finalized --out /tmp/deployed-idl.json "$PROGRAM_ID"
jq -S . "target/idl/$PROGRAM.json" > /tmp/release-idl.sorted.json
jq -S . /tmp/deployed-idl.json > /tmp/deployed-idl.sorted.json
diff -u /tmp/release-idl.sorted.json /tmp/deployed-idl.sorted.json

Do not run anchor idl write-buffer directly from the operator wallet after Squads takes authority; the vault must authorize that write. scripts/svm/squadsIdlUpgrade.ts encodes the old Anchor 0.31 dispatcher instructions and remains usable only for legacy deployments with Anchor 0.31.1. It does not update Program Metadata accounts. Leaving the old IDL open does not block publication of the new one, but old clients continue reading stale data. The upgraded binary has no legacy IDL dispatcher, so it cannot update or close that account or recover its rent; doing so later would require another program upgrade restoring that functionality. The sequence above avoids leaving that stale account behind.

Verify

Start with verifying locally that the deployed program matches the source code of the public repository:

solana-verify verify-from-repo \
  --url $RPC_URL \
  --program-id $PROGRAM_ID \
   --library-name $PROGRAM \
   --base-image "$BUILD_IMAGE" \
  https://github.com/across-protocol/contracts

When prompted, don't yet upload the verification data to the blockchain as that should be done by the multisig. Proceed with creating the upload transaction and then import and sign/execute it in the Squads multisig:

solana-verify export-pda-tx \
  --url $RPC_URL \
  --program-id $PROGRAM_ID \
  --library-name $PROGRAM  \
  --base-image "$BUILD_IMAGE" \
  --uploader $MULTISIG \
  https://github.com/across-protocol/contracts

Note that the initial upload transaction might fail if the multisig vault does not have enough SOL for PDA creation. In that case, transfer the required funds to the multisig vault before executing the upload transaction.

Finally, submit the verification to OtterSec API (only works on mainnet):

solana-verify remote submit-job \
  --url $RPC_URL \
  --program-id $PROGRAM_ID \
  --uploader $MULTISIG

Miscellaneous topics

Slither

Slither is a Solidity static analysis framework written in Python 3. It runs a suite of vulnerability detectors, prints visual information about contract details, and provides an API to easily write custom analyses. Slither enables developers to find vulnerabilities, enhance their code comprehension, and quickly prototype custom analyses.

Spire-Contracts has been analyzed using Slither@0.9.2 and no major bugs was found. To rerun the analytics, run:

slither contracts/SpokePool.sol
\ --solc-remaps @=node_modules/@
\ --solc-args "--optimize --optimize-runs 1000000"
\ --filter-paths "node_modules"
\ --exclude naming-convention

You can replace SpokePool.sol with the specific contract you want to analyze.

ZK Sync Adapter

ZK EVM's typically require a special compiler to convert Solidity into code that can be run on the ZK VM.

There are special instructions for compiling and deploying contracts on zksync. The compile command will create artifacts-zk and cache-zk directories.

Compile

This step requires Docker Desktop to be running, as the solc docker image is fetched as a prerequisite.

yarn compile-zksync

License

All code in this repository is licensed under BUSL-1.1 unless specified differently in the file. Individual exceptions to this license can be made by Risk Labs, which holds the rights to this software and design. If you are interested in using the code or designs in a derivative work, feel free to reach out to licensing@risklabs.foundation.

About

Smart contracts for Across protocol

Resources

Stars

159 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages