Skip to content

Commit a45b5fe

Browse files
authored
Merge branch 'main' into tt/testBuild
2 parents 02249a1 + a9ca545 commit a45b5fe

File tree

24 files changed

+306
-374
lines changed

24 files changed

+306
-374
lines changed

.github/workflows/solana-verified-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
build:
1616
runs-on: ubuntu-latest-8cores-32GB
1717
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
1821
- name: Get Long and Short SHAs
1922
id: get_sha
2023
run: |

chainconfig/chainconfig.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ type ChainConfig struct {
2727
// OptimisticConfirmations is the number of confirmations of a chain event before
2828
// it is considered optimistically confirmed (i.e not necessarily finalized).
2929
OptimisticConfirmations uint32 `json:"optimisticConfirmations"`
30+
31+
// ChainFeeDeviationDisabled is a flag to disable deviation-based reporting. If true, we will only report
32+
// prices based on the heartbeat.
33+
ChainFeeDeviationDisabled bool `json:"chainFeeDeviationDisabled"`
3034
}
3135

3236
func (cc ChainConfig) Validate() error {

chains/solana/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ anchor_version:
1313

1414
.PHONY: clippy
1515
clippy:
16-
cargo clippy --manifest-path ./contracts/programs/ccip-router/Cargo.toml
16+
cd ./contracts && cargo clippy -- -D warnings
1717

1818
.PHONY: gomods
1919
gomods: ## Install gomods

chains/solana/contracts/programs/access-controller/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ pub mod access_controller {
5252
proposed_owner: Pubkey,
5353
) -> Result<()> {
5454
let state = &mut *ctx.accounts.state.load_mut()?;
55+
require!(
56+
proposed_owner != Pubkey::default() && proposed_owner != state.owner,
57+
ErrorCode::InvalidInput
58+
);
5559
state.proposed_owner = proposed_owner;
5660
Ok(())
5761
}

chains/solana/contracts/programs/ccip-router/src/instructions/v1/pools.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ pub fn calculate_token_pool_account_indices(
1717
start_indices: &[u8],
1818
remaining_accounts_count: usize,
1919
) -> Result<(usize, usize)> {
20+
require!(
21+
i < start_indices.len(),
22+
CcipRouterError::InvalidInputsTokenIndices
23+
);
24+
2025
// account set = [start...end)
2126
let start: usize = start_indices[i] as usize;
2227
let end: usize = if i == start_indices.len() - 1 {
@@ -355,6 +360,10 @@ pub mod token_admin_registry_writable {
355360

356361
#[cfg(test)]
357362
mod tests {
363+
use crate::{
364+
instructions::v1::pools::calculate_token_pool_account_indices, CcipRouterError,
365+
};
366+
358367
use super::*;
359368
use solana_program::pubkey::Pubkey;
360369

@@ -422,5 +431,30 @@ pub mod token_admin_registry_writable {
422431
assert!(is(state, 128 + 56));
423432
assert!(is(state, 128 + 100));
424433
}
434+
435+
#[test]
436+
fn token_pool_indices_underflow_overflow() {
437+
let empty_start_indices: [u8; 0] = [];
438+
let full_start_indices = [1u8, 2, 3];
439+
let arbitrary_account_count = 5;
440+
441+
assert_eq!(
442+
calculate_token_pool_account_indices(
443+
0,
444+
&empty_start_indices,
445+
arbitrary_account_count
446+
),
447+
Err(CcipRouterError::InvalidInputsTokenIndices.into())
448+
);
449+
450+
assert_eq!(
451+
calculate_token_pool_account_indices(
452+
full_start_indices.len(),
453+
&full_start_indices,
454+
arbitrary_account_count
455+
),
456+
Err(CcipRouterError::InvalidInputsTokenIndices.into())
457+
);
458+
}
425459
}
426460
}

chains/solana/contracts/programs/example-ccip-receiver/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ impl BaseState {
325325
}
326326

327327
pub fn transfer_ownership(&mut self, owner: Pubkey, proposed_owner: Pubkey) -> Result<()> {
328+
require!(
329+
proposed_owner != self.owner && proposed_owner != Pubkey::default(),
330+
CcipReceiverError::InvalidProposedOwner
331+
);
328332
require_eq!(self.owner, owner, CcipReceiverError::OnlyOwner);
329333
self.proposed_owner = proposed_owner;
330334
Ok(())
@@ -386,6 +390,8 @@ pub enum CcipReceiverError {
386390
OnlyProposedOwner,
387391
#[msg("Caller is not allowed")]
388392
InvalidCaller,
393+
#[msg("Proposed owner is invalid")]
394+
InvalidProposedOwner,
389395
}
390396

391397
#[event]

chains/solana/contracts/programs/example-ccip-sender/src/state.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ impl BaseState {
2222
}
2323

2424
pub fn transfer_ownership(&mut self, owner: Pubkey, proposed_owner: Pubkey) -> Result<()> {
25+
require!(
26+
proposed_owner != self.owner && proposed_owner != Pubkey::default(),
27+
CcipSenderError::InvalidProposedOwner
28+
);
2529
require_eq!(self.owner, owner, CcipSenderError::OnlyOwner);
2630
self.proposed_owner = proposed_owner;
2731
Ok(())
@@ -106,6 +110,8 @@ pub enum CcipSenderError {
106110
OnlyOwner,
107111
#[msg("Address is not proposed_owner")]
108112
OnlyProposedOwner,
113+
#[msg("Proposed owner is invalid")]
114+
InvalidProposedOwner,
109115
}
110116

111117
#[cfg(test)]

chains/solana/contracts/programs/mcm/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ pub mod mcm {
9797
proposed_owner: Pubkey,
9898
) -> Result<()> {
9999
let config = &mut ctx.accounts.config;
100-
require!(proposed_owner != config.owner, McmError::InvalidInputs);
100+
require!(
101+
proposed_owner != config.owner && proposed_owner != Pubkey::default(),
102+
McmError::InvalidInputs
103+
);
101104
config.proposed_owner = proposed_owner;
102105
Ok(())
103106
}

chains/solana/contracts/programs/timelock/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,10 @@ pub mod timelock {
468468
proposed_owner: Pubkey,
469469
) -> Result<()> {
470470
let mut config = ctx.accounts.config.load_mut()?;
471-
require!(proposed_owner != config.owner, TimelockError::InvalidInput);
471+
require!(
472+
proposed_owner != config.owner && proposed_owner != Pubkey::default(),
473+
TimelockError::InvalidInput
474+
);
472475
config.proposed_owner = proposed_owner;
473476
Ok(())
474477
}

chains/solana/contracts/target/idl/example_ccip_receiver.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@
403403
"code": 6005,
404404
"name": "InvalidCaller",
405405
"msg": "Caller is not allowed"
406+
},
407+
{
408+
"code": 6006,
409+
"name": "InvalidProposedOwner",
410+
"msg": "Proposed owner is invalid"
406411
}
407412
]
408413
}

0 commit comments

Comments
 (0)