Skip to content

Commit

Permalink
Merge branch 'main' of github.com:smartcontractkit/chainlink-ccip int…
Browse files Browse the repository at this point in the history
…o cl33-07
  • Loading branch information
b-gopalswami committed Jan 10, 2025
2 parents a3acd67 + 516f05d commit b9a20ab
Show file tree
Hide file tree
Showing 95 changed files with 3,416 additions and 1,606 deletions.
24 changes: 3 additions & 21 deletions chains/solana/contracts/programs/ccip-router/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ use anchor_spl::token::spl_token::native_mint;
use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
use solana_program::sysvar::instructions;

use crate::ocr3base::Ocr3Report;
use crate::program::CcipRouter;
use crate::state::{CommitReport, Config, ExternalExecutionConfig, Nonce};
use crate::{
BillingTokenConfig, BillingTokenConfigWrapper, CcipRouterError, DestChain,
ExecutionReportSingleChain, GlobalState, ReportContext, Solana2AnyMessage, SourceChain,
ExecutionReportSingleChain, GlobalState, Solana2AnyMessage, SourceChain,
};

pub const ANCHOR_DISCRIMINATOR: usize = 8;
Expand Down Expand Up @@ -78,23 +77,6 @@ pub struct GasPriceUpdate {
pub usd_per_unit_gas: [u8; 28], // EVM uses u224, 1e18 USD per smallest unit (e.g. wei) of destination chain gas
}

impl Ocr3Report for CommitInput {
fn hash(&self, ctx: &ReportContext) -> [u8; 32] {
use anchor_lang::solana_program::hash;
let mut buffer: Vec<u8> = Vec::new();
self.serialize(&mut buffer).unwrap();
let report_len = self.len() as u16; // u16 > max tx size, u8 may have overflow
hash::hashv(&[&report_len.to_le_bytes(), &buffer, &ctx.as_bytes()]).to_bytes()
}

fn len(&self) -> usize {
4 + (32 + 28) * self.price_updates.token_price_updates.len() + // token_price_updates
4 + (8 + 28) * self.price_updates.gas_price_updates.len() + // gas_price_updates
self.merkle_root.len()
// + 4 + 65 * self.rmn_signatures.len()
}
}

#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
// Struct to hold a merkle root and an interval for a source chain
pub struct MerkleRoot {
Expand All @@ -106,7 +88,7 @@ pub struct MerkleRoot {
}

impl MerkleRoot {
fn len(&self) -> usize {
pub fn len(&self) -> usize {
8 + // source chain selector
4 + self.on_ramp_address.len() + // on ramp address
8 + // min msg nr
Expand Down Expand Up @@ -605,7 +587,7 @@ pub struct CcipSend<'info> {
}

#[derive(Accounts)]
#[instruction(report_context: ReportContext, report: CommitInput)]
#[instruction(_report_context_byte_words: [[u8; 32]; 3], report: CommitInput)]
pub struct CommitReportContext<'info> {
#[account(
seeds = [CONFIG_SEED],
Expand Down
12 changes: 12 additions & 0 deletions chains/solana/contracts/programs/ccip-router/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,15 @@ 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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@ use crate::{
AcceptOwnership, AddBillingTokenConfig, AddChainSelector, BillingTokenConfig, CcipRouterError,
DestChainAdded, DestChainConfig, DestChainConfigUpdated, DestChainState, FeeTokenAdded,
FeeTokenDisabled, FeeTokenEnabled, FeeTokenRemoved, Ocr3ConfigInfo, OcrPluginType,
RemoveBillingTokenConfig, SetOcrConfig, SetTokenBillingConfig, SourceChainAdded,
SourceChainConfig, SourceChainConfigUpdated, SourceChainState, TimestampedPackedU224,
TokenBilling, TransferOwnership, UpdateBillingTokenConfig, UpdateConfigCCIPRouter,
UpdateDestChainSelectorConfig, UpdateSourceChainSelectorConfig, WithdrawBilledFunds,
FEE_BILLING_SIGNER_SEEDS,
OwnershipTransferRequested, OwnershipTransferred, RemoveBillingTokenConfig, SetOcrConfig,
SetTokenBillingConfig, SourceChainAdded, SourceChainConfig, SourceChainConfigUpdated,
SourceChainState, TimestampedPackedU224, TokenBilling, TransferOwnership,
UpdateBillingTokenConfig, UpdateConfigCCIPRouter, UpdateDestChainSelectorConfig,
UpdateSourceChainSelectorConfig, WithdrawBilledFunds, FEE_BILLING_SIGNER_SEEDS,
};

use super::fee_quoter::do_billing_transfer;
use super::ocr3base::ocr3_set;

pub fn transfer_ownership(ctx: Context<TransferOwnership>, proposed_owner: Pubkey) -> Result<()> {
let mut config = ctx.accounts.config.load_mut()?;
require!(
proposed_owner != config.owner,
CcipRouterError::InvalidInputs
);
emit!(OwnershipTransferRequested {
from: config.owner,
to: proposed_owner,
});
config.proposed_owner = proposed_owner;
Ok(())
}

pub fn accept_ownership(ctx: Context<AcceptOwnership>) -> Result<()> {
let mut config = ctx.accounts.config.load_mut()?;
emit!(OwnershipTransferred {
from: config.owner,
to: config.proposed_owner,
});
config.owner = std::mem::take(&mut config.proposed_owner);
config.proposed_owner = Pubkey::new_from_array([0; 32]);
Ok(())
Expand Down Expand Up @@ -217,7 +226,8 @@ pub fn set_ocr_config(

let is_commit = plugin_type == OcrPluginType::Commit as u8;

config.ocr3[plugin_type as usize].set(
ocr3_set(
&mut config.ocr3[plugin_type as usize],
plugin_type,
Ocr3ConfigInfo {
config_digest: config_info.config_digest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ pub mod token_admin_registry;
mod fee_quoter;
mod merkle;
mod messages;
mod ocr3base;
mod ocr3impl;
mod pools;
Loading

0 comments on commit b9a20ab

Please sign in to comment.