Skip to content
Draft
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
24 changes: 12 additions & 12 deletions chains/solana/contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions chains/solana/contracts/programs/base-token-pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "base-token-pool"
version = "1.6.0"
version = "1.6.1-candidate"
description = "Created with Anchor"
edition = "2021"

Expand All @@ -19,9 +19,14 @@ default = []
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
anchor-spl = "0.29.0"
solana-program = "1.17.25" # pin solana to 1.17
spl-math = { version = "0.2.0", features = [ "no-entrypoint" ] }
rmn_remote = {path = "../rmn-remote", features = ["cpi"]}
spl-math = { version = "0.2.0", features = ["no-entrypoint"] }
rmn_remote = { version = "1.6.1-candidate", path = "../rmn-remote", features = [
"cpi",
] }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("solana"))', 'cfg(feature, values("anchor-debug", "custom-panic"))']
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("anchor-debug", "custom-panic"))',
]
19 changes: 13 additions & 6 deletions chains/solana/contracts/programs/burnmint-token-pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "burnmint-token-pool"
version = "1.6.0"
version = "1.6.1-candidate"
description = "Created with Anchor"
edition = "2021"

Expand All @@ -19,14 +19,21 @@ default = []
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
anchor-spl = "0.29.0"
solana-program = "1.17.25" # pin solana to 1.17
spl-math = { version = "0.2.0", features = [ "no-entrypoint" ] }
base-token-pool = { version = "1.6.0", path = "../base-token-pool/", features = ["no-entrypoint"] }
rmn_remote = {path = "../rmn-remote", features = ["cpi"]}
ccip_common = {path = "../ccip-common"}
spl-math = { version = "0.2.0", features = ["no-entrypoint"] }
base-token-pool = { version = "1.6.1-candidate", path = "../base-token-pool/", features = [
"no-entrypoint",
] }
rmn_remote = { version = "1.6.1-candidate", path = "../rmn-remote", features = [
"cpi",
] }
ccip_common = { version = "1.6.1-candidate", path = "../ccip-common" }

[build-dependencies]
build_commit = { path = "../../crates/build-commit" }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("solana"))', 'cfg(feature, values("anchor-debug", "custom-panic"))']
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("anchor-debug", "custom-panic"))',
]
9 changes: 6 additions & 3 deletions chains/solana/contracts/programs/ccip-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ccip_common"
version = "0.1.1"
version = "1.6.1-candidate"
edition = "2021"

[lib]
Expand All @@ -17,11 +17,14 @@ cpi = ["no-entrypoint"]
default = ["no-entrypoint"]

[dependencies]
solana-program = "1.17.25" # pin solana to 1.17
solana-program = "1.17.25" # pin solana to 1.17
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
anchor-spl = "0.29.0"
ethnum = "1.5"

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("solana"))', 'cfg(feature, values("anchor-debug", "custom-panic"))']
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("anchor-debug", "custom-panic"))',
]
5 changes: 5 additions & 0 deletions chains/solana/contracts/programs/ccip-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ pub enum CommonCcipError {
InvalidEVMAddress,
#[msg("Invalid SVM address")]
InvalidSVMAddress,
#[msg("Invalid TVM address")]
InvalidTVMAddress,
#[msg("Invalid Aptos address")]
InvalidAptosAddress,
}

// https://github.com/smartcontractkit/chainlink/blob/ff8a597fd9df653f8967427498eaa5a04b19febb/contracts/src/v0.8/ccip/libraries/Internal.sol#L276
pub const CHAIN_FAMILY_SELECTOR_EVM: u32 = 0x2812d52c;
pub const CHAIN_FAMILY_SELECTOR_SVM: u32 = 0x1e10bdc4;
pub const CHAIN_FAMILY_SELECTOR_TVM: u32 = 0x647e2ba9;
pub const CHAIN_FAMILY_SELECTOR_APTOS: u32 = 0xac77ffec;

// Duplicates the router ID to declare router accounts that must be visible from the common crate,
// avoiding a circular dependency. This means this crate may only declare accounts that belong
Expand Down
88 changes: 88 additions & 0 deletions chains/solana/contracts/programs/ccip-common/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,38 @@ pub fn validate_svm_address(address: &[u8], address_must_be_nonzero: bool) -> Re
.map_err(|_| CommonCcipError::InvalidSVMAddress.into())
}

/// 36-byte TON address raw format:
/// - [0] flags
/// - [1] workchain_id
/// - [2..34) account_id (32 bytes)
/// - [34..36) crc16 (ignored here)
pub fn validate_tvm_address(address: &[u8]) -> Result<()> {
require_eq!(address.len(), 36, CommonCcipError::InvalidTVMAddress);

// account_id starts at offset 2 and is 32 bytes long
let account_id: &[u8; 32] = address[2..34]
.try_into()
.expect("slice length is guaranteed to be 32");

require!(
account_id.iter().any(|b| *b != 0),
CommonCcipError::InvalidTVMAddress
);

Ok(())
}

pub fn validate_aptos_address(address: &[u8]) -> Result<()> {
require_eq!(address.len(), 32, CommonCcipError::InvalidAptosAddress);

require!(
address.iter().any(|b| *b != 0),
CommonCcipError::InvalidAptosAddress
);

Ok(())
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -519,4 +551,60 @@ mod tests {
let result = load_v1_token_admin_registry(&account_info);
assert!(result.is_err());
}

#[test]
fn validate_tvm_address_accepts_len_36_nonzero_account_id() {
// 36-byte TON address raw format:
// [0] flags, [1] workchain_id, [2..34) account_id (32 bytes), [34..36) crc16
let mut addr = [0u8; 36];
addr[0] = 1;
addr[1] = 2;
addr[2] = 1; // make account_id non-zero
validate_tvm_address(&addr).unwrap();
}

#[test]
fn validate_tvm_address_rejects_wrong_len() {
let addr = [1u8; 35];
assert_eq!(
validate_tvm_address(&addr).unwrap_err(),
CommonCcipError::InvalidTVMAddress.into()
);
}

#[test]
fn validate_tvm_address_rejects_zero_account_id() {
let mut addr = [0u8; 36];
addr[0] = 1;
addr[1] = 2;
// account_id is all-zero
assert_eq!(
validate_tvm_address(&addr).unwrap_err(),
CommonCcipError::InvalidTVMAddress.into()
);
}

#[test]
fn validate_aptos_address_accepts_len_32_nonzero() {
let addr = [1u8; 32];
validate_aptos_address(&addr).unwrap();
}

#[test]
fn validate_aptos_address_rejects_wrong_len() {
let addr = [1u8; 31];
assert_eq!(
validate_aptos_address(&addr).unwrap_err(),
CommonCcipError::InvalidAptosAddress.into()
);
}

#[test]
fn validate_aptos_address_rejects_all_zero() {
let addr = [0u8; 32];
assert_eq!(
validate_aptos_address(&addr).unwrap_err(),
CommonCcipError::InvalidAptosAddress.into()
);
}
}
17 changes: 12 additions & 5 deletions chains/solana/contracts/programs/ccip-offramp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ccip_offramp"
version = "0.1.1"
version = "1.6.1-candidate"
description = "Created with Anchor"
edition = "2021"

Expand All @@ -21,9 +21,13 @@ anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
anchor-spl = "0.29.0"
bytemuck = "1.7"
ethnum = "1.5"
fee_quoter = {path = "../fee-quoter", features = ["cpi"]}
rmn_remote = {path = "../rmn-remote", features = ["cpi"]}
ccip_common = {path = "../ccip-common"}
fee_quoter = { version = "1.6.1-candidate", path = "../fee-quoter", features = [
"cpi",
] }
rmn_remote = { version = "1.6.1-candidate", path = "../rmn-remote", features = [
"cpi",
] }
ccip_common = { version = "1.6.1-candidate", path = "../ccip-common" }

[dev-dependencies]
hex = "0.4.3"
Expand All @@ -33,4 +37,7 @@ build_commit = { path = "../../crates/build-commit" }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("solana"))', 'cfg(feature, values("anchor-debug", "custom-panic", "custom-heap"))']
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("anchor-debug", "custom-panic", "custom-heap"))',
]
17 changes: 12 additions & 5 deletions chains/solana/contracts/programs/ccip-router/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ccip_router"
version = "0.1.1"
version = "1.6.1-candidate"
description = "Created with Anchor"
edition = "2021"
build = "build.rs"
Expand All @@ -22,9 +22,13 @@ anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
anchor-spl = "0.29.0"
bytemuck = "1.7"
ethnum = "1.5"
fee_quoter = {path = "../fee-quoter", features = ["cpi"]}
rmn_remote = {path = "../rmn-remote", features = ["cpi"]}
ccip_common = {path = "../ccip-common"}
fee_quoter = { version = "1.6.1-candidate", path = "../fee-quoter", features = [
"cpi",
] }
rmn_remote = { version = "1.6.1-candidate", path = "../rmn-remote", features = [
"cpi",
] }
ccip_common = { version = "1.6.1-candidate", path = "../ccip-common" }

[dev-dependencies]
hex = "0.4.3"
Expand All @@ -34,4 +38,7 @@ build_commit = { path = "../../crates/build-commit" }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("solana"))', 'cfg(feature, values("anchor-debug", "custom-panic"))']
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("anchor-debug", "custom-panic"))',
]
Loading
Loading