Skip to content

Commit 2d45e62

Browse files
authored
Merge branch 'main' into tt/testBuild
2 parents a45b5fe + f156d12 commit 2d45e62

File tree

103 files changed

+4424
-2780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+4424
-2780
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Test binary, built with `go test -c`
1010
*.test
11-
carpenter
11+
/cmd/carpenter/carpenter
1212

1313
# Test & linter reports
1414
*report.xml

chains/solana/contracts/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chains/solana/contracts/programs/burnmint-token-pool/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ solana-program = "1.17.25" # pin solana to 1.17
2222
spl-math = { version = "0.2.0", features = [ "no-entrypoint" ] }
2323
base-token-pool = { version = "0.1.0-dev", path = "../base-token-pool/", features = ["no-entrypoint"] }
2424
rmn_remote = {path = "../rmn-remote", features = ["cpi"]}
25+
ccip_common = {path = "../ccip-common"}

chains/solana/contracts/programs/burnmint-token-pool/src/context.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anchor_spl::{
44
token_interface::{Mint, TokenAccount},
55
};
66
use base_token_pool::common::*;
7+
use ccip_common::seed;
78

89
use crate::{ChainConfig, State};
910

@@ -99,7 +100,6 @@ pub struct TokenOfframp<'info> {
99100
// Token pool accounts ------------------
100101
// consistent set + token pool program
101102
#[account(
102-
mut,
103103
seeds = [POOL_STATE_SEED, mint.key().as_ref()],
104104
bump,
105105
)]
@@ -136,15 +136,15 @@ pub struct TokenOfframp<'info> {
136136

137137
/// CHECK: This account is just used in the CPI to the RMN Remote program
138138
#[account(
139-
seeds = [rmn_remote::context::seed::CURSES],
139+
seeds = [seed::CURSES],
140140
bump,
141141
seeds::program = state.config.rmn_remote,
142142
)]
143143
pub rmn_remote_curses: UncheckedAccount<'info>,
144144

145145
/// CHECK: This account is just used in the CPI to the RMN Remote program
146146
#[account(
147-
seeds = [rmn_remote::context::seed::CONFIG],
147+
seeds = [seed::CONFIG],
148148
bump,
149149
seeds::program = state.config.rmn_remote,
150150
)]
@@ -165,7 +165,6 @@ pub struct TokenOnramp<'info> {
165165
// Token pool accounts ------------------
166166
// consistent set + token pool program
167167
#[account(
168-
mut,
169168
seeds = [POOL_STATE_SEED, mint.key().as_ref()],
170169
bump,
171170
)]
@@ -195,15 +194,15 @@ pub struct TokenOnramp<'info> {
195194

196195
/// CHECK: This account is just used in the CPI to the RMN Remote program
197196
#[account(
198-
seeds = [rmn_remote::context::seed::CURSES],
197+
seeds = [seed::CURSES],
199198
bump,
200199
seeds::program = state.config.rmn_remote,
201200
)]
202201
pub rmn_remote_curses: UncheckedAccount<'info>,
203202

204203
/// CHECK: This account is just used in the CPI to the RMN Remote program
205204
#[account(
206-
seeds = [rmn_remote::context::seed::CONFIG],
205+
seeds = [seed::CONFIG],
207206
bump,
208207
seeds::program = state.config.rmn_remote,
209208
)]
@@ -254,7 +253,6 @@ pub struct SetChainRateLimit<'info> {
254253
pub chain_config: Account<'info, ChainConfig>,
255254
#[account(mut, constraint = authority.key() == state.config.owner || authority.key() == state.config.rate_limit_admin)]
256255
pub authority: Signer<'info>,
257-
pub system_program: Program<'info, System>,
258256
}
259257

260258
#[derive(Accounts)]
@@ -320,5 +318,4 @@ pub struct DeleteChainConfig<'info> {
320318
pub chain_config: Account<'info, ChainConfig>,
321319
#[account(mut, address = state.config.owner)]
322320
pub authority: Signer<'info>,
323-
pub system_program: Program<'info, System>,
324321
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "ccip_common"
3+
version = "0.1.0-dev"
4+
edition = "2021"
5+
6+
[lib]
7+
crate-type = ["cdylib", "lib"]
8+
name = "ccip_common"
9+
10+
[features]
11+
no-entrypoint = []
12+
no-idl = []
13+
no-log-ix-name = []
14+
cpi = ["no-entrypoint"]
15+
# ccip-common is not to be deployed, so using the no-entrypoint feature
16+
# prevents global allocator conflicts with its dependees.
17+
default = ["no-entrypoint"]
18+
19+
[dependencies]
20+
solana-program = "1.17.25" # pin solana to 1.17
21+
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
22+
anchor-spl = "0.29.0"
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
use anchor_lang::prelude::*;
2+
use anchor_spl::associated_token::get_associated_token_address_with_program_id;
3+
use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
4+
use solana_program::address_lookup_table;
5+
6+
use crate::seed;
7+
use crate::CommonCcipError;
8+
9+
#[derive(Accounts)]
10+
#[instruction(token_receiver: Pubkey, chain_selector: u64, router: Pubkey, fee_quoter: Pubkey)]
11+
pub struct TokenAccountsValidationContext<'info> {
12+
#[account(
13+
constraint = user_token_account.key() == get_associated_token_address_with_program_id(
14+
&token_receiver.key(),
15+
&mint.key(),
16+
&token_program.key()
17+
) @ CommonCcipError::InvalidInputsTokenAccounts,
18+
)]
19+
pub user_token_account: InterfaceAccount<'info, TokenAccount>,
20+
21+
/// CHECK: Per chain token billing config PDA
22+
// billing: configured via CCIP fee quoter
23+
// chain config: configured via pool
24+
#[account(
25+
seeds = [
26+
seed::PER_CHAIN_PER_TOKEN_CONFIG,
27+
chain_selector.to_le_bytes().as_ref(),
28+
mint.key().as_ref(),
29+
],
30+
seeds::program = fee_quoter.key(),
31+
owner = fee_quoter.key() @ CommonCcipError::InvalidInputsTokenAccounts,
32+
bump
33+
)]
34+
pub token_billing_config: UncheckedAccount<'info>,
35+
36+
/// CHECK: Pool chain config PDA
37+
#[account(
38+
seeds = [
39+
seed::TOKEN_POOL_CONFIG,
40+
chain_selector.to_le_bytes().as_ref(),
41+
mint.key().as_ref(),
42+
],
43+
seeds::program = pool_program.key(),
44+
owner = pool_program.key() @ CommonCcipError::InvalidInputsPoolAccounts,
45+
bump
46+
)]
47+
pub pool_chain_config: UncheckedAccount<'info>,
48+
49+
/// CHECK: Lookup table
50+
#[account(owner = address_lookup_table::program::id() @ CommonCcipError::InvalidInputsLookupTableAccounts)]
51+
pub lookup_table: UncheckedAccount<'info>,
52+
53+
/// CHECK: Token admin registry PDA
54+
#[account(
55+
seeds = [seed::TOKEN_ADMIN_REGISTRY, mint.key().as_ref()],
56+
seeds::program = router.key(),
57+
bump,
58+
owner = router.key() @ CommonCcipError::InvalidInputsTokenAdminRegistryAccounts,
59+
)]
60+
pub token_admin_registry: UncheckedAccount<'info>,
61+
62+
/// CHECK: Pool program
63+
#[account(executable)]
64+
pub pool_program: UncheckedAccount<'info>,
65+
66+
/// CHECK: Pool config PDA
67+
#[account(
68+
seeds = [seed::CCIP_TOKENPOOL_CONFIG, mint.key().as_ref()],
69+
seeds::program = pool_program.key(),
70+
bump,
71+
owner = pool_program.key() @ CommonCcipError::InvalidInputsPoolAccounts
72+
)]
73+
pub pool_config: UncheckedAccount<'info>,
74+
75+
#[account(
76+
address = get_associated_token_address_with_program_id(
77+
&pool_signer.key(),
78+
&mint.key(),
79+
&token_program.key()
80+
) @ CommonCcipError::InvalidInputsTokenAccounts
81+
)]
82+
pub pool_token_account: InterfaceAccount<'info, TokenAccount>,
83+
84+
/// CHECK: Pool signer PDA
85+
#[account(
86+
seeds = [seed::CCIP_TOKENPOOL_SIGNER, mint.key().as_ref()],
87+
seeds::program = pool_program.key(),
88+
bump
89+
)]
90+
pub pool_signer: UncheckedAccount<'info>,
91+
92+
pub token_program: Interface<'info, TokenInterface>,
93+
94+
#[account(owner = token_program.key() @ CommonCcipError::InvalidInputsTokenAccounts)]
95+
pub mint: InterfaceAccount<'info, Mint>,
96+
97+
/// CHECK: Fee token config PDA
98+
#[account(
99+
seeds = [
100+
seed::FEE_BILLING_TOKEN_CONFIG,
101+
mint.key().as_ref()
102+
],
103+
seeds::program = fee_quoter.key(),
104+
owner = fee_quoter.key() @ CommonCcipError::InvalidInputsTokenAccounts,
105+
bump
106+
)]
107+
pub fee_token_config: UncheckedAccount<'info>,
108+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! Contains common logic used across ccip programs. Common logic is versioned independently:
2+
//! v1 of the common logic may not necessarily be used by v1 of each particular program.
3+
use anchor_lang::prelude::*;
4+
5+
pub mod context;
6+
pub mod seed;
7+
pub mod v1;
8+
9+
#[error_code]
10+
pub enum CommonCcipError {
11+
#[msg("The given sequence interval is invalid")]
12+
// offset error code so that they don't clash with other programs
13+
// (Anchor's base custom error code 6000 + offset 4000 = start at 10000)
14+
InvalidSequenceInterval = 4000,
15+
#[msg("Invalid pool accounts")]
16+
InvalidInputsPoolAccounts,
17+
#[msg("Invalid token accounts")]
18+
InvalidInputsTokenAccounts,
19+
#[msg("Invalid Token Admin Registry account")]
20+
InvalidInputsTokenAdminRegistryAccounts,
21+
#[msg("Invalid LookupTable account")]
22+
InvalidInputsLookupTableAccounts,
23+
#[msg("Invalid LookupTable account writable access")]
24+
InvalidInputsLookupTableAccountWritable,
25+
}
26+
27+
// Duplicates the router ID to declare router accounts that must be visible from the common crate,
28+
// avoiding a circular dependency. This means this crate may only declare accounts that belong
29+
// to the router, and no other program.
30+
declare_id!("Ccip842gzYHhvdDkSyi2YVCoAWPbYJoApMFzSxQroE9C");
31+
// null contract required for IDL + gobinding generation
32+
#[program]
33+
pub mod ccip_common {}
34+
35+
pub mod router_accounts {
36+
use super::*;
37+
38+
#[account]
39+
#[derive(InitSpace)]
40+
pub struct TokenAdminRegistry {
41+
pub version: u8,
42+
pub administrator: Pubkey,
43+
pub pending_administrator: Pubkey,
44+
pub lookup_table: Pubkey,
45+
// binary representation of indexes that are writable in token pool lookup table
46+
// lookup table can store 256 addresses
47+
pub writable_indexes: [u128; 2],
48+
pub mint: Pubkey,
49+
}
50+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Fixed seeds - different contexts must use different PDA seeds
2+
pub const CONFIG: &[u8] = b"config";
3+
pub const ALLOWED_PRICE_UPDATER: &[u8] = b"allowed_price_updater";
4+
pub const DEST_CHAIN: &[u8] = b"dest_chain";
5+
pub const FEE_BILLING_TOKEN_CONFIG: &[u8] = b"fee_billing_token_config";
6+
pub const PER_CHAIN_PER_TOKEN_CONFIG: &[u8] = b"per_chain_per_token_config";
7+
pub const SOURCE_CHAIN: &[u8] = b"source_chain_state";
8+
pub const COMMIT_REPORT: &[u8] = b"commit_report";
9+
pub const REFERENCE_ADDRESSES: &[u8] = b"reference_addresses";
10+
pub const STATE: &[u8] = b"state";
11+
pub const CURSES: &[u8] = b"curses";
12+
pub const DEST_CHAIN_STATE: &[u8] = b"dest_chain_state";
13+
pub const NONCE: &[u8] = b"nonce";
14+
pub const ALLOWED_OFFRAMP: &[u8] = b"allowed_offramp";
15+
16+
// arbitrary messaging signer
17+
pub const EXTERNAL_EXECUTION_CONFIG: &[u8] = b"external_execution_config";
18+
// token pool interaction signer
19+
pub const EXTERNAL_TOKEN_POOL: &[u8] = b"external_token_pools_signer";
20+
// signer for billing fee token transfer
21+
pub const FEE_BILLING_SIGNER: &[u8] = b"fee_billing_signer";
22+
23+
// token specific
24+
pub const TOKEN_ADMIN_REGISTRY: &[u8] = b"token_admin_registry";
25+
pub const CCIP_TOKENPOOL_CONFIG: &[u8] = b"ccip_tokenpool_config";
26+
pub const CCIP_TOKENPOOL_SIGNER: &[u8] = b"ccip_tokenpool_signer";
27+
pub const TOKEN_POOL_CONFIG: &[u8] = b"ccip_tokenpool_chainconfig";

0 commit comments

Comments
 (0)