-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sequence-numbers
- Loading branch information
Showing
18 changed files
with
785 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
chains/solana/contracts/programs/fee-quoter/src/instructions/interfaces.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::context::{ | ||
AcceptOwnership, AddBillingTokenConfig, AddDestChain, AddPriceUpdater, GasPriceUpdate, GetFee, | ||
RemovePriceUpdater, SetTokenTransferFeeConfig, TokenPriceUpdate, UpdateBillingTokenConfig, | ||
UpdateConfig, UpdateDestChainConfig, UpdatePrices, | ||
}; | ||
use crate::messages::{GetFeeResult, SVM2AnyMessage}; | ||
use crate::state::{BillingTokenConfig, CodeVersion, DestChainConfig, TokenTransferFeeConfig}; | ||
|
||
pub trait Public { | ||
fn get_fee<'info>( | ||
&self, | ||
ctx: Context<'_, '_, 'info, 'info, GetFee>, | ||
dest_chain_selector: u64, | ||
message: SVM2AnyMessage, | ||
) -> Result<GetFeeResult>; | ||
} | ||
|
||
pub trait Prices { | ||
fn update_prices<'info>( | ||
&self, | ||
ctx: Context<'_, '_, 'info, 'info, UpdatePrices<'info>>, | ||
token_updates: Vec<TokenPriceUpdate>, | ||
gas_updates: Vec<GasPriceUpdate>, | ||
) -> Result<()>; | ||
} | ||
|
||
pub trait Admin { | ||
fn transfer_ownership(&self, ctx: Context<UpdateConfig>, proposed_owner: Pubkey) -> Result<()>; | ||
|
||
fn accept_ownership(&self, ctx: Context<AcceptOwnership>) -> Result<()>; | ||
|
||
fn set_default_code_version( | ||
&self, | ||
ctx: Context<UpdateConfig>, | ||
code_version: CodeVersion, | ||
) -> Result<()>; | ||
|
||
fn add_billing_token_config( | ||
&self, | ||
ctx: Context<AddBillingTokenConfig>, | ||
config: BillingTokenConfig, | ||
) -> Result<()>; | ||
|
||
fn update_billing_token_config( | ||
&self, | ||
ctx: Context<UpdateBillingTokenConfig>, | ||
config: BillingTokenConfig, | ||
) -> Result<()>; | ||
|
||
fn add_dest_chain( | ||
&self, | ||
ctx: Context<AddDestChain>, | ||
chain_selector: u64, | ||
dest_chain_config: DestChainConfig, | ||
) -> Result<()>; | ||
|
||
fn disable_dest_chain( | ||
&self, | ||
ctx: Context<UpdateDestChainConfig>, | ||
chain_selector: u64, | ||
) -> Result<()>; | ||
|
||
fn update_dest_chain_config( | ||
&self, | ||
ctx: Context<UpdateDestChainConfig>, | ||
chain_selector: u64, | ||
dest_chain_config: DestChainConfig, | ||
) -> Result<()>; | ||
|
||
fn add_price_updater( | ||
&self, | ||
_ctx: Context<AddPriceUpdater>, | ||
price_updater: Pubkey, | ||
) -> Result<()>; | ||
|
||
fn remove_price_updater( | ||
&self, | ||
_ctx: Context<RemovePriceUpdater>, | ||
price_updater: Pubkey, | ||
) -> Result<()>; | ||
|
||
fn set_token_transfer_fee_config( | ||
&self, | ||
ctx: Context<SetTokenTransferFeeConfig>, | ||
chain_selector: u64, | ||
mint: Pubkey, | ||
cfg: TokenTransferFeeConfig, | ||
) -> Result<()>; | ||
} |
5 changes: 4 additions & 1 deletion
5
chains/solana/contracts/programs/fee-quoter/src/instructions/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
pub mod v1; | ||
mod interfaces; | ||
mod v1; | ||
|
||
pub mod router; |
47 changes: 47 additions & 0 deletions
47
chains/solana/contracts/programs/fee-quoter/src/instructions/router.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::state::CodeVersion; | ||
|
||
use super::interfaces::*; | ||
use super::v1; | ||
|
||
/** | ||
* This file routes traffic between multiple versions of our business logic, which can be upgraded in a | ||
* backwards-compatible way and so we can gradually shift traffic between versions (and rollback if there are issues). | ||
* This also supports flexible criteria on how to shift traffic between versions (e.g. per-lane, all at once, etc) | ||
* for each module (e.g. the criteria for admin actions may differ the criteria for public-facing interfaces). | ||
* | ||
* On any code changes to the business logic, a new version of the module should be created and leave the previous one | ||
* untouched. The new version should be added to the match statement below so that traffic can be progressively shifted, | ||
* and is possible to rollback easily via config changes without having to redeploy. | ||
* | ||
* As we currently have a single version, all branches lead to the same outcome, but the code is structured in a way | ||
* that is easy to extend to multiple versions. | ||
*/ | ||
|
||
pub fn public( | ||
lane_code_version: CodeVersion, | ||
default_code_version: CodeVersion, | ||
) -> &'static dyn Public { | ||
// The lane-specific code version takes precedence over the default code version. | ||
// If the lane just specifies using the default, then we use that one. | ||
match lane_code_version { | ||
CodeVersion::V1 => &v1::public::Impl, | ||
CodeVersion::Default => match default_code_version { | ||
CodeVersion::Default => &v1::public::Impl, | ||
CodeVersion::V1 => &v1::public::Impl, | ||
}, | ||
} | ||
} | ||
|
||
pub fn prices(code_version: CodeVersion) -> &'static dyn Prices { | ||
match code_version { | ||
CodeVersion::Default => &v1::prices::Impl, | ||
CodeVersion::V1 => &v1::prices::Impl, | ||
} | ||
} | ||
|
||
pub fn admin(code_version: CodeVersion) -> &'static dyn Admin { | ||
match code_version { | ||
CodeVersion::Default => &v1::admin::Impl, | ||
CodeVersion::V1 => &v1::admin::Impl, | ||
} | ||
} |
Oops, something went wrong.