diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 722c26cc5d..c8441cdd19 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -47,7 +47,7 @@ jobs: run: > docker run --rm --user root --platform=linux/amd64 -e PACKAGE=${{ matrix.package }} -v /home/runner/.cargo:/cargo-home - -v ${{ github.workspace }}:/build paritytech/srtool:1.73.0-0.12.0 + -v ${{ github.workspace }}:/build paritytech/srtool:1.75.0-0.14.0 /srtool/build --app # Alternative way of running SRTool that allows for "script-like" execution, diff --git a/Cargo.lock b/Cargo.lock index 44c25cb1c0..43b3ced781 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2450,7 +2450,7 @@ dependencies = [ [[package]] name = "development-runtime" -version = "0.10.41" +version = "0.10.42" dependencies = [ "axelar-gateway-precompile", "cfg-primitives", diff --git a/libs/types/src/tokens.rs b/libs/types/src/tokens.rs index 755d328b41..9feb7b9510 100644 --- a/libs/types/src/tokens.rs +++ b/libs/types/src/tokens.rs @@ -452,7 +452,10 @@ pub mod usdc { pub const CURRENCY_ID_LP_ETH_GOERLI: CurrencyId = CurrencyId::ForeignAsset(100_001); pub const CURRENCY_ID_LP_BASE: CurrencyId = CurrencyId::ForeignAsset(100_002); pub const CURRENCY_ID_LP_ARB: CurrencyId = CurrencyId::ForeignAsset(100_003); - pub const CURRENCY_ID_LP_CELO: CurrencyId = CurrencyId::ForeignAsset(100_004); + + pub const CURRENCY_ID_LP_CELO_WORMHOLE: CurrencyId = CurrencyId::ForeignAsset(100_004); + pub const CURRENCY_ID_LP_CELO: CurrencyId = CurrencyId::ForeignAsset(100_006); + pub const LOCAL_ASSET_ID: LocalAssetId = LocalAssetId(1u32); pub const CURRENCY_ID_LOCAL: CurrencyId = CurrencyId::LocalAsset(LOCAL_ASSET_ID); diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index 79ce3288c0..33f1a39d56 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -1803,7 +1803,7 @@ parameter_types! { } impl pallet_order_book::Config for Runtime { - type AdminOrigin = EnsureRoot; + type AdminOrigin = EnsureAccountOrRootOr; type AssetRegistry = OrmlAssetRegistry; type BalanceIn = Balance; type BalanceOut = Balance; diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 29405b277f..e4c5c7c9a2 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -14,7 +14,8 @@ use cfg_primitives::{Balance, PoolId}; use cfg_types::tokens::{ usdc::{ CURRENCY_ID_AXELAR, CURRENCY_ID_DOT_NATIVE, CURRENCY_ID_LOCAL, CURRENCY_ID_LP_ARB, - CURRENCY_ID_LP_BASE, CURRENCY_ID_LP_CELO, CURRENCY_ID_LP_ETH, LOCAL_ASSET_ID, + CURRENCY_ID_LP_BASE, CURRENCY_ID_LP_CELO, CURRENCY_ID_LP_CELO_WORMHOLE, CURRENCY_ID_LP_ETH, + LOCAL_ASSET_ID, }, CurrencyId, LocalAssetId, }; @@ -31,6 +32,7 @@ frame_support::parameter_types! { pub const UsdcEth: CurrencyId = CURRENCY_ID_LP_ETH; pub const UsdcBase: CurrencyId = CURRENCY_ID_LP_BASE; pub const UsdcArb: CurrencyId = CURRENCY_ID_LP_ARB; + pub const UsdcCeloWormhole: CurrencyId = CURRENCY_ID_LP_CELO_WORMHOLE; pub const UsdcCelo: CurrencyId = CURRENCY_ID_LP_CELO; pub const MinOrderAmount: Balance = 10u128.pow(6); pub const AnnualTreasuryInflationPercent: u32 = 3; @@ -51,6 +53,8 @@ pub type UpgradeCentrifuge1025 = ( super::Runtime, LocalCurrencyIdUsdc, >, + // Register new canonical USDC on Celo + runtime_common::migrations::update_celo_usdcs::Migration, // Init local representation for all assets runtime_common::migrations::local_currency::translate_metadata::Migration< super::Runtime, diff --git a/runtime/common/src/migrations/mod.rs b/runtime/common/src/migrations/mod.rs index 95068e9243..791ab2cf44 100644 --- a/runtime/common/src/migrations/mod.rs +++ b/runtime/common/src/migrations/mod.rs @@ -19,3 +19,119 @@ pub mod nuke; pub mod orml_tokens; pub mod precompile_account_codes; pub mod transfer_allowlist_currency; + +pub mod update_celo_usdcs { + use cfg_primitives::Balance; + #[cfg(feature = "try-runtime")] + use cfg_types::tokens::LocalAssetId; + use cfg_types::tokens::{ + usdc::{CURRENCY_ID_LP_CELO, CURRENCY_ID_LP_CELO_WORMHOLE}, + CrossChainTransferability, CurrencyId, CustomMetadata, + }; + use frame_support::{traits::OnRuntimeUpgrade, weights::Weight}; + use hex_literal::hex; + use orml_traits::asset_registry::{AssetMetadata, Mutate}; + use sp_runtime::traits::Get; + #[cfg(feature = "try-runtime")] + use sp_std::{vec, vec::Vec}; + use xcm::v3::{ + Junction::{AccountKey20, GlobalConsensus, PalletInstance}, + Junctions::X3, + NetworkId::Ethereum, + }; + + const LOG_PREFIX: &str = "UpdateCeloUsdcs"; + + pub struct Migration(sp_std::marker::PhantomData); + + impl OnRuntimeUpgrade for Migration + where + T: orml_asset_registry::Config< + CustomMetadata = CustomMetadata, + AssetId = CurrencyId, + Balance = Balance, + >, + { + fn on_runtime_upgrade() -> Weight { + as Mutate>::register_asset( + Some(CURRENCY_ID_LP_CELO), + AssetMetadata { + decimals: 6, + name: "LP Celo Wrapped USDC ".as_bytes().to_vec(), + symbol: "LpCeloUSDC".as_bytes().to_vec(), + existential_deposit: 1000u128, + location: Some( + X3( + PalletInstance(103), + GlobalConsensus(Ethereum { chain_id: 42220 }), + AccountKey20 { + // https://www.circle.com/blog/usdc-now-available-on-celo + key: hex!("cebA9300f2b948710d2653dD7B07f33A8B32118C"), + network: None, + }, + ) + .into(), + ), + additional: CustomMetadata { + transferability: CrossChainTransferability::LiquidityPools, + mintable: false, + permissioned: false, + pool_currency: true, + local_representation: None, + }, + }, + ) + .map_err(|e| { + log::error!( + "{LOG_PREFIX} Failed to register new canonical Celo USDC due to error {:?}", + e + ); + }) + .ok(); + + log::info!("{LOG_PREFIX} Done registering new canonical Celo USDC currency"); + + as Mutate>::update_asset( + CURRENCY_ID_LP_CELO_WORMHOLE, + None, + Some("LP Celo Wrapped Wormhole USDC ".as_bytes().to_vec()), + Some("LpCeloWormUSDC ".as_bytes().to_vec()), + None, + None, + None, + ) + .map_err(|e| { + log::error!( + "{LOG_PREFIX} Failed to update wormhole Celo USDC due to error {:?}", + e + ); + }) + .ok(); + + log::info!("{LOG_PREFIX} Done updating wormhole Celo USDC currency"); + + T::DbWeight::get().writes(2) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::DispatchError> { + assert!(!orml_asset_registry::Metadata::::contains_key( + CURRENCY_ID_LP_CELO + )); + + log::info!("{LOG_PREFIX} PRE UPGRADE: Finished"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::DispatchError> { + assert!(orml_asset_registry::Metadata::::contains_key( + CURRENCY_ID_LP_CELO + )); + + log::info!("{LOG_PREFIX} POST UPGRADE: Finished"); + Ok(()) + } + } +} diff --git a/runtime/development/Cargo.toml b/runtime/development/Cargo.toml index 45286c5770..bd1983ea42 100644 --- a/runtime/development/Cargo.toml +++ b/runtime/development/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "development-runtime" -version = "0.10.41" +version = "0.10.42" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 8cbf06a96e..797fa8b8af 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -157,7 +157,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("centrifuge-devel"), impl_name: create_runtime_str!("centrifuge-devel"), authoring_version: 1, - spec_version: 1041, + spec_version: 1042, impl_version: 1, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, @@ -2039,7 +2039,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - crate::migrations::UpgradeDevelopment1041, + crate::migrations::UpgradeDevelopment1042, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/development/src/migrations.rs b/runtime/development/src/migrations.rs index 52b98c8e00..bf56c19a45 100644 --- a/runtime/development/src/migrations.rs +++ b/runtime/development/src/migrations.rs @@ -23,7 +23,7 @@ frame_support::parameter_types! { pub const AnnualTreasuryInflationPercent: u32 = 3; } -pub type UpgradeDevelopment1041 = ( +pub type UpgradeDevelopment1042 = ( // Register LocalUSDC runtime_common::migrations::local_currency::register::Migration< super::Runtime,