Skip to content

fix(svm): upgrade post-audit to pristine program ids #1054

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ resolution = true
skip-lint = false

[programs.localnet]
multicall_handler = "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h"
svm_spoke = "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq"
multicall_handler = "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be"
svm_spoke = "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru"
test = "8tsEfDSiE4WUMf97oyyyasLAvWwjeRZb2GByh4w7HckA"

[programs.devnet]
multicall_handler = "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h"
svm_spoke = "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq"

[programs.mainnet]
multicall_handler = "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h"
svm_spoke = "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq"
multicall_handler = "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be"
svm_spoke = "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru"

[registry]
url = "https://api.apr.dev"
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ 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 SOLANA_VERSION=$(grep -A 2 'name = "solana-program"' Cargo.lock | grep 'version' | head -n 1 | cut -d'"' -f2)
```

For the initial deployment also need these:
Expand All @@ -95,6 +96,7 @@ export SVM_CHAIN_ID=$(cast to-dec $(cast shr $(cast shl $(cast keccak solana-dev
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
Expand All @@ -103,11 +105,14 @@ Deploy the program and set the upgrade authority to the multisig:

```shell
solana program deploy \
--url $RPC_URL target/deploy/$PROGRAM.so \
--url $RPC_URL \
--keypair $KEYPAIR \
--program-id target/deploy/$PROGRAM-keypair.json \
--max-len $MAX_LEN \
--with-compute-unit-price 50000 \
--max-sign-attempts 100
--max-sign-attempts 100 \
--use-rpc \
target/deploy/$PROGRAM.so
solana program set-upgrade-authority \
--url $RPC_URL \
--keypair $KEYPAIR \
Expand Down Expand Up @@ -215,6 +220,7 @@ solana-verify verify-from-repo \
--url $RPC_URL \
--program-id $PROGRAM_ID \
--library-name $PROGRAM \
--base-image "solanafoundation/solana-verifiable-build:$SOLANA_VERSION" \
https://github.com/across-protocol/contracts
```

Expand All @@ -225,6 +231,7 @@ solana-verify export-pda-tx \
--url $RPC_URL \
--program-id $PROGRAM_ID \
--library-name $PROGRAM \
--base-image "solanafoundation/solana-verifiable-build:$SOLANA_VERSION" \
--uploader $MULTISIG \
https://github.com/across-protocol/contracts
```
Expand Down
10 changes: 5 additions & 5 deletions deployments/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"Cher_Adapter": { "address": "0x0c9d064523177dBB55CFE52b9D0c485FBFc35FD2", "blockNumber": 21597341 },
"Lens_Adapter": { "address": "0x63AC22131eD457aeCbD63e6c4C7eeC7BBC74fF1F", "blockNumber": 22167069 },
"DoctorWho_Adapter": { "address": "0xFADcC43096756e1527306FD92982FEbBe3c629Fa", "blockNumber": 21773451 },
"Solana_Adapter": { "address": "0x1E22A3146439C68A2d247448372AcAEe9E201AB1", "blockNumber": 22566473 }
"Solana_Adapter": { "address": "0x9F788694934fD2Ed34D5340B9a76EB34f2bFD7B3", "blockNumber": 22595936 }
},
"10": {
"SpokePool": { "address": "0x6f26Bf09B1C792e3228e5467807a900A503c0281", "blockNumber": 93903076 },
Expand Down Expand Up @@ -226,12 +226,12 @@
},
"34268394551451": {
"SvmSpoke": {
"address": "JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq",
"blockNumber": 317101505
"address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru",
"blockNumber": 349354195
},
"MulticallHandler": {
"address": "Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h",
"blockNumber": 317112562
"address": "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be",
"blockNumber": 349358090
},
"MessageTransmitter": {
"address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd",
Expand Down
20 changes: 10 additions & 10 deletions deployments/mainnet/Solana_Adapter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0x1E22A3146439C68A2d247448372AcAEe9E201AB1",
"address": "0x9F788694934fD2Ed34D5340B9a76EB34f2bFD7B3",
"abi": [
{
"inputs": [
Expand Down Expand Up @@ -328,29 +328,29 @@
"type": "function"
}
],
"transactionHash": "0x940c1e4bf26e94e657bc1e1344d3c2aea44e80a051837b75812283668a23c3a7",
"transactionHash": "0x5256d567a2ce4cbc96f04cb3b0885fad53fd48d163b67a79d9dfeaaba21f6fc3",
"receipt": {
"to": null,
"from": "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D",
"contractAddress": "0x1E22A3146439C68A2d247448372AcAEe9E201AB1",
"transactionIndex": 72,
"contractAddress": "0x9F788694934fD2Ed34D5340B9a76EB34f2bFD7B3",
"transactionIndex": 22,
"gasUsed": "1034334",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x66dae79469e26570eb7960c9b1daa884ca592e1085f00879f1012d1e5e309022",
"transactionHash": "0x940c1e4bf26e94e657bc1e1344d3c2aea44e80a051837b75812283668a23c3a7",
"blockHash": "0x60c1b45973d5aba6a92d540aa1c8b879817b8a1a3cafcb9b20ce4ba474c44dd1",
"transactionHash": "0x5256d567a2ce4cbc96f04cb3b0885fad53fd48d163b67a79d9dfeaaba21f6fc3",
"logs": [],
"blockNumber": 22566473,
"cumulativeGasUsed": "5278156",
"blockNumber": 22595936,
"cumulativeGasUsed": "4109786",
"status": 1,
"byzantium": true
},
"args": [
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"0xBd3fa81B58Ba92a82136038B25aDec7066af3155",
"0x0a992d191deec32afe36203ad87d7d289a738f81",
"0xff09aa2d3eb1bc9da19e82264930e13d3993e1160f3039ef21afd1565376efca",
"0xb7664086de37ee70821c10445b162f2c7ec8795bd0800c1462949e2328d1dd5a",
"0xc6fa7af3bedbad3a3d65f36aabc97431b1bbe4c2d2f6e0e47ca60203452f5d61",
"0xe11ef405ee6e9a6497fb8209d04040216281c57264730415648de979f6cec7fa"
"0xf5d9ddc2b5d994277e15ea380117a3f8ef04ce1e37e2c678c3be4d11b2a5d034"
],
"numDeployments": 1,
"solcInputHash": "335735b51fb84a31677c4bf77e2b5d68",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@across-protocol/contracts",
"version": "4.0.12",
"version": "4.0.14-alpha.3",
"author": "UMA Team",
"license": "AGPL-3.0-only",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion programs/multicall-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ security_txt! {

// If changing the program ID, make sure to check that the resulting handler_signer PDA has the highest bump of 255 so
// to minimize the compute cost when finding the PDA.
declare_id!("Fk1RpqsfeWt8KnFCTW9NQVdVxYvxuqjGn6iPB9wrmM8h");
declare_id!("HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be");

#[program]
pub mod multicall_handler {
Expand Down
2 changes: 1 addition & 1 deletion programs/svm-spoke/src/common/relay_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct RelayData {
pub exclusive_relayer: Pubkey,
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
pub input_amount: [u8; 32],
pub output_amount: u64,
pub origin_chain_id: u64,
pub deposit_id: [u8; 32],
Expand Down
2 changes: 2 additions & 0 deletions programs/svm-spoke/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub enum CommonError {
InsufficientSpokePoolBalanceToExecuteLeaf,
#[msg("Invalid exclusive relayer!")]
InvalidExclusiveRelayer,
#[msg("Invalid output token!")]
InvalidOutputToken,
}

// SVM specific errors.
Expand Down
6 changes: 3 additions & 3 deletions programs/svm-spoke/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct FundsDeposited {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
pub output_amount: u64,
pub output_amount: [u8; 32],
pub destination_chain_id: u64,
pub deposit_id: [u8; 32],
pub quote_timestamp: u32,
Expand Down Expand Up @@ -71,7 +71,7 @@ pub struct RelayExecutionEventInfo {
pub struct FilledRelay {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
pub input_amount: [u8; 32],
pub output_amount: u64,
pub repayment_chain_id: u64,
pub origin_chain_id: u64,
Expand All @@ -91,7 +91,7 @@ pub struct FilledRelay {
pub struct RequestedSlowFill {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
pub input_amount: [u8; 32],
pub output_amount: u64,
pub origin_chain_id: u64,
pub deposit_id: [u8; 32],
Expand Down
22 changes: 9 additions & 13 deletions programs/svm-spoke/src/instructions/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ use crate::{

#[event_cpi]
#[derive(Accounts)]
#[instruction(
depositor: Pubkey,
recipient: Pubkey,
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
destination_chain_id: u64
)]
#[instruction(depositor: Pubkey, recipient: Pubkey, input_token: Pubkey)]
pub struct Deposit<'info> {
#[account(mut)]
pub signer: Signer<'info>,
Expand Down Expand Up @@ -82,7 +74,7 @@ pub fn _deposit(
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
deposit_id: [u8; 32],
Expand All @@ -95,6 +87,10 @@ pub fn _deposit(
let state = &mut ctx.accounts.state;
let current_time = get_current_time(state)?;

if output_token == Pubkey::default() {
return err!(CommonError::InvalidOutputToken);
}

if current_time.checked_sub(quote_timestamp).unwrap_or(u32::MAX) > state.deposit_quote_time_buffer {
return err!(CommonError::InvalidQuoteTimestamp);
}
Expand Down Expand Up @@ -156,7 +152,7 @@ pub fn deposit(
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
quote_timestamp: u32,
Expand Down Expand Up @@ -208,7 +204,7 @@ pub fn deposit_now(
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
fill_deadline_offset: u32,
Expand Down Expand Up @@ -260,7 +256,7 @@ pub fn unsafe_deposit(
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
deposit_nonce: u64,
Expand Down
13 changes: 9 additions & 4 deletions programs/svm-spoke/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ security_txt! {
auditors: "OpenZeppelin"
}

declare_id!("JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq");
declare_id!("DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru");

// External programs from idls directory (requires anchor run generateExternalTypes).
declare_program!(message_transmitter);
Expand Down Expand Up @@ -217,6 +217,7 @@ pub mod svm_spoke {
/// amount will be sent to the relayer on their repayment chain of choice as a refund following an optimistic
/// challenge window in the HubPool, less a system fee.
/// - output_amount: The amount of output tokens that the relayer will send to the recipient on the destination.
/// This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side.
/// - destination_chain_id: The destination chain identifier where the fill should be made.
/// - exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the exclusivity
/// deadline timestamp. This must be a valid, non-zero address if the exclusivity deadline is greater than the
Expand All @@ -238,7 +239,7 @@ pub mod svm_spoke {
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
quote_timestamp: u32,
Expand Down Expand Up @@ -272,7 +273,7 @@ pub mod svm_spoke {
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
fill_deadline_offset: u32,
Expand Down Expand Up @@ -308,7 +309,7 @@ pub mod svm_spoke {
input_token: Pubkey,
output_token: Pubkey,
input_amount: u64,
output_amount: u64,
output_amount: [u8; 32],
destination_chain_id: u64,
exclusive_relayer: Pubkey,
deposit_nonce: u64,
Expand Down Expand Up @@ -391,6 +392,7 @@ pub mod svm_spoke {
/// token on the repayment chain will be sent as a refund to the caller.
/// - output_token: The token that the caller will send to the recipient on this chain.
/// - input_amount: This amount, less a system fee, will be sent to the caller on their repayment chain.
/// This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side
/// - output_amount: The amount of output tokens that the caller will send to the recipient.
/// - origin_chain_id: The origin chain identifier.
/// - exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the
Expand Down Expand Up @@ -715,6 +717,9 @@ pub mod svm_spoke {
/// - proof: Inclusion proof for this leaf in slow relay root in root bundle.
/// Note: slow_fill_leaf, _root_bundle_id, and proof are optional parameters. If None for any of these is passed,
/// the caller must load them via the instruction_params account.
/// Note: When verifying the slow fill leaf, the relay data is hashed using AnchorSerialize::serialize that encodes
/// output token amounts to little-endian format while input token amount preserves its big-endian encoding as it
/// is passed as [u8; 32] array.
pub fn execute_slow_relay_leaf<'info>(
ctx: Context<'_, '_, '_, 'info, ExecuteSlowRelayLeaf<'info>>,
_relay_hash: [u8; 32],
Expand Down
4 changes: 2 additions & 2 deletions programs/svm-spoke/src/utils/delegate_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct DepositSeedData<'a> {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
pub output_amount: u64,
pub output_amount: [u8; 32],
pub destination_chain_id: u64,
pub exclusive_relayer: Pubkey,
pub quote_timestamp: u32,
Expand All @@ -29,7 +29,7 @@ pub struct DepositNowSeedData<'a> {
pub input_token: Pubkey,
pub output_token: Pubkey,
pub input_amount: u64,
pub output_amount: u64,
pub output_amount: [u8; 32],
pub destination_chain_id: u64,
pub exclusive_relayer: Pubkey,
pub fill_deadline_offset: u32,
Expand Down
4 changes: 3 additions & 1 deletion scripts/svm/buildHelpers/buildSolanaVerify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ else
CARGO_OPTIONS=""
fi

SOLANA_VERSION=$(grep -A 2 'name = "solana-program"' Cargo.lock | grep 'version' | head -n 1 | cut -d'"' -f2)

for program in programs/*; do
[ -d "$program" ] || continue

dir_name=$(basename "$program")
program_name=${dir_name//-/_}

echo "Running verified build for $program_name"
solana-verify build --library-name "$program_name" -- $CARGO_OPTIONS
solana-verify build --library-name "$program_name" --base-image "solanafoundation/solana-verifiable-build:$SOLANA_VERSION" -- $CARGO_OPTIONS

# We don't need keypair files from the verified build and they cause permission issues on CI when Swatinem/rust-cache
# tries to delete them.
Expand Down
2 changes: 1 addition & 1 deletion scripts/svm/closeRelayerPdas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function closeFillPda(eventData: any, seed: BN): Promise<void> {
exclusiveRelayer: new PublicKey(eventData.exclusiveRelayer),
inputToken: new PublicKey(eventData.inputToken),
outputToken: new PublicKey(eventData.outputToken),
inputAmount: new BN(eventData.inputAmount),
inputAmount: eventData.inputAmount,
outputAmount: new BN(eventData.outputAmount),
originChainId: new BN(eventData.originChainId),
depositId: eventData.depositId,
Expand Down
Loading
Loading