Skip to content

Commit

Permalink
Merge branch 'main' into solana/example-receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed Jan 31, 2025
2 parents bf87960 + 6a49e4b commit 76ce883
Show file tree
Hide file tree
Showing 51 changed files with 2,986 additions and 1,364 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccip-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
GREAT_PR_DESCRIPTION_HERE
)
echo "$comment"
core_ref=$(echo "$comment" | grep -oE 'core ref: [a-f0-9]{40}' | cut -d' ' -f3 || true)
core_ref=$(echo "$comment" | grep -oE 'core ref:\s*[a-f0-9]{40}' | awk '{print $NF}' || true)
if [ -n "$core_ref" ]; then
echo "Overriding chainlink repository commit hash with: $core_ref"
echo "::set-output name=ref::$core_ref"
Expand Down
38 changes: 33 additions & 5 deletions chains/solana/contracts/programs/ccip-router/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use solana_program::sysvar::instructions;
use crate::program::CcipRouter;
use crate::state::{CommitReport, Config, Nonce};
use crate::{
BillingTokenConfig, BillingTokenConfigWrapper, CcipRouterError, DestChain,
BillingTokenConfig, BillingTokenConfigWrapper, CcipRouterError, DestChain, DestChainConfig,
ExecutionReportSingleChain, ExternalExecutionConfig, GlobalState, SVM2AnyMessage, SourceChain,
};

Expand Down Expand Up @@ -254,11 +254,10 @@ pub struct AcceptOwnership<'info> {
}

#[derive(Accounts)]
#[instruction(new_chain_selector: u64)]
#[instruction(new_chain_selector: u64, dest_chain_config: DestChainConfig)]
pub struct AddChainSelector<'info> {
/// Adding a chain selector implies initializing the state for a new chain,
/// hence the need to initialize two accounts.
#[account(
init,
seeds = [seed::SOURCE_CHAIN_STATE, new_chain_selector.to_le_bytes().as_ref()],
Expand All @@ -273,7 +272,7 @@ pub struct AddChainSelector<'info> {
seeds = [seed::DEST_CHAIN_STATE, new_chain_selector.to_le_bytes().as_ref()],
bump,
payer = authority,
space = ANCHOR_DISCRIMINATOR + DestChain::INIT_SPACE,
space = ANCHOR_DISCRIMINATOR + DestChain::INIT_SPACE + dest_chain_config.dynamic_space(),
)]
pub dest_chain_state: Account<'info, DestChain>,

Expand Down Expand Up @@ -312,8 +311,37 @@ pub struct UpdateSourceChainSelectorConfig<'info> {
}

#[derive(Accounts)]
#[instruction(new_chain_selector: u64)]
#[instruction(new_chain_selector: u64, dest_chain_config: DestChainConfig)]
pub struct UpdateDestChainSelectorConfig<'info> {
#[account(
mut,
seeds = [seed::DEST_CHAIN_STATE, new_chain_selector.to_le_bytes().as_ref()],
bump,
constraint = valid_version(dest_chain_state.version, MAX_CHAINSTATE_V) @ CcipRouterError::InvalidInputs,
realloc = ANCHOR_DISCRIMINATOR + DestChain::INIT_SPACE + dest_chain_config.dynamic_space(),
realloc::payer = authority,
// `realloc::zero = true` is only necessary in cases where an instruction is capable of reallocating
// *down* and then *up*, during a single execution. In any other cases (such as this), it's not
// necessary as the memory will be zero'd automatically on instruction entry.
realloc::zero = false
)]
pub dest_chain_state: Account<'info, DestChain>,

#[account(
seeds = [seed::CONFIG],
bump,
constraint = valid_version(config.load()?.version, MAX_CONFIG_V) @ CcipRouterError::InvalidInputs,
)]
pub config: AccountLoader<'info, Config>,

#[account(mut, address = config.load()?.owner @ CcipRouterError::Unauthorized)]
pub authority: Signer<'info>,
pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
#[instruction(new_chain_selector: u64)]
pub struct DisableDestChainSelectorConfig<'info> {
#[account(
mut,
seeds = [seed::DEST_CHAIN_STATE, new_chain_selector.to_le_bytes().as_ref()],
Expand Down
276 changes: 144 additions & 132 deletions chains/solana/contracts/programs/ccip-router/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,146 +5,158 @@ use crate::{
SourceChainConfig, TokenBilling,
};

#[event]
pub struct CCIPMessageSent {
pub dest_chain_selector: u64,
pub sequence_number: u64,
pub message: SVM2AnyRampMessage,
}

#[event]
pub struct CommitReportAccepted {
pub merkle_root: MerkleRoot,
pub price_updates: PriceUpdates,
}

#[event]
pub struct SkippedAlreadyExecutedMessage {
pub source_chain_selector: u64,
pub sequence_number: u64,
}

#[event]
pub struct AlreadyAttempted {
pub source_chain_selector: u64,
pub sequence_number: u64,
}

#[event]
pub struct ExecutionStateChanged {
pub source_chain_selector: u64,
pub sequence_number: u64,
pub message_id: [u8; 32],
pub message_hash: [u8; 32],
pub state: MessageExecutionState,
}

#[event]
pub struct PoolSet {
pub token: Pubkey,
pub previous_pool_lookup_table: Pubkey,
pub new_pool_lookup_table: Pubkey,
}

#[event]
pub struct AdministratorTransferRequested {
pub token: Pubkey,
pub current_admin: Pubkey,
pub new_admin: Pubkey,
}

#[event]
pub struct AdministratorTransferred {
pub token: Pubkey,
pub new_admin: Pubkey,
}

#[event]
pub struct FeeTokenAdded {
pub fee_token: Pubkey,
pub enabled: bool,
}

#[event]
pub struct FeeTokenEnabled {
pub fee_token: Pubkey,
}

#[event]
pub struct FeeTokenDisabled {
pub fee_token: Pubkey,
}

#[event]
pub struct FeeTokenRemoved {
pub fee_token: Pubkey,
}

#[event]
pub struct UsdPerUnitGasUpdated {
pub dest_chain: u64,
pub value: [u8; 28], // EVM uses u256 here
pub timestamp: i64, // EVM uses u256 here
}

#[event]
pub struct UsdPerTokenUpdated {
pub token: Pubkey,
pub value: [u8; 28], // EVM uses u256 here
pub timestamp: i64, // EVM uses u256 here
}

#[event]
pub mod events {

use super::*;

pub mod on_ramp {

use super::*;
#[event]
pub struct CCIPMessageSent {
pub dest_chain_selector: u64,
pub sequence_number: u64,
pub message: SVM2AnyRampMessage,
}
}

pub mod off_ramp {

use super::*;

#[event]
pub struct CommitReportAccepted {
pub merkle_root: MerkleRoot,
pub price_updates: PriceUpdates,
}

#[event]
pub struct SkippedAlreadyExecutedMessage {
pub source_chain_selector: u64,
pub sequence_number: u64,
}

#[event]
pub struct ExecutionStateChanged {
pub source_chain_selector: u64,
pub sequence_number: u64,
pub message_id: [u8; 32],
pub message_hash: [u8; 32],
pub state: MessageExecutionState,
}

#[event]
pub struct UsdPerUnitGasUpdated {
pub dest_chain: u64,
pub value: [u8; 28], // EVM uses u256 here
pub timestamp: i64, // EVM uses u256 here
}

#[event]
pub struct UsdPerTokenUpdated {
pub token: Pubkey,
pub value: [u8; 28], // EVM uses u256 here
pub timestamp: i64, // EVM uses u256 here
}
}

pub mod admin {
use super::*;

#[event]
pub struct FeeTokenAdded {
pub fee_token: Pubkey,
pub enabled: bool,
}

#[event]
pub struct FeeTokenEnabled {
pub fee_token: Pubkey,
}

#[event]
pub struct FeeTokenDisabled {
pub fee_token: Pubkey,
}

#[event]
pub struct FeeTokenRemoved {
pub fee_token: Pubkey,
}

#[event]
pub struct SourceChainConfigUpdated {
pub source_chain_selector: u64,
pub source_chain_config: SourceChainConfig,
}

#[event]
pub struct SourceChainAdded {
pub source_chain_selector: u64,
pub source_chain_config: SourceChainConfig,
}

#[event]
pub struct DestChainConfigUpdated {
pub dest_chain_selector: u64,
pub dest_chain_config: DestChainConfig,
}

#[event]
pub struct DestChainAdded {
pub dest_chain_selector: u64,
pub dest_chain_config: DestChainConfig,
}

#[event]
pub struct OwnershipTransferRequested {
pub from: Pubkey,
pub to: Pubkey,
}

#[event]
pub struct OwnershipTransferred {
pub from: Pubkey,
pub to: Pubkey,
}
}

pub mod token_admin_registry {

use super::*;
#[event]
pub struct PoolSet {
pub token: Pubkey,
pub previous_pool_lookup_table: Pubkey,
pub new_pool_lookup_table: Pubkey,
}

#[event]
pub struct AdministratorTransferRequested {
pub token: Pubkey,
pub current_admin: Pubkey,
pub new_admin: Pubkey,
}

#[event]
pub struct AdministratorTransferred {
pub token: Pubkey,
pub new_admin: Pubkey,
}
}
}

#[event]
// TODO: Check why this is not used
pub struct TokenTransferFeeConfigUpdated {
pub dest_chain_selector: u64,
pub token: Pubkey,
pub token_transfer_fee_config: TokenBilling,
}

#[event]
// TODO: Check why this is not used
pub struct PremiumMultiplierWeiPerEthUpdated {
pub token: Pubkey,
pub premium_multiplier_wei_per_eth: u64,
}

#[event]
pub struct SourceChainConfigUpdated {
pub source_chain_selector: u64,
pub source_chain_config: SourceChainConfig,
}

#[event]
pub struct SourceChainAdded {
pub source_chain_selector: u64,
pub source_chain_config: SourceChainConfig,
}

#[event]
pub struct DestChainConfigUpdated {
pub dest_chain_selector: u64,
pub dest_chain_config: DestChainConfig,
}

#[event]
pub struct DestChainAdded {
pub dest_chain_selector: u64,
pub dest_chain_config: DestChainConfig,
}

#[event]
pub struct AdministratorRegistered {
pub token_mint: Pubkey,
pub administrator: Pubkey,
}

#[event]
pub struct OwnershipTransferRequested {
pub from: Pubkey,
pub to: Pubkey,
}

#[event]
pub struct OwnershipTransferred {
pub from: Pubkey,
pub to: Pubkey,
}
Loading

0 comments on commit 76ce883

Please sign in to comment.