From 536bed6cd9d525e95dbc69d0f5aeaf935048434c Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Tue, 3 Sep 2024 14:00:09 +1200 Subject: [PATCH 01/14] allow signed migration (#2803) --- runtime/karura/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 80604e2116..ff56511ef8 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1837,6 +1837,10 @@ impl orml_parameters::Config for Runtime { type WeightInfo = (); } +frame_support::ord_parameter_types! { + pub const MigController: AccountId = AccountId::from(hex_literal::hex!("ec68c9ec1f6233f3d8169e06e2c94df703c45c05eef923169bf2703b08797315")); +} + parameter_types! { // The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high) pub MigrationSignedDepositPerItem: Balance = dollar(KAR); @@ -1848,7 +1852,7 @@ impl pallet_state_trie_migration::Config for Runtime { // An origin that can control the whole pallet: should be Root, or a part of your council. type ControlOrigin = EnsureRootOrTwoThirdsTechnicalCommittee; // specific account for the migration, can trigger the signed migrations. - type SignedFilter = frame_support::traits::NeverEnsureOrigin; + type SignedFilter = frame_system::EnsureSignedBy; type RuntimeEvent = RuntimeEvent; type Currency = Balances; type RuntimeHoldReason = RuntimeHoldReason; From 1c6302fe6f7cf7c1fe6813a1f7c336c31570f5ec Mon Sep 17 00:00:00 2001 From: wangjj9219 <183318287@qq.com> Date: Wed, 11 Sep 2024 12:53:35 +0800 Subject: [PATCH 02/14] Limit process redeem requests (#2806) * limit process redeem requests * fix benchmarks * update --- modules/homa/src/lib.rs | 35 ++++++---- modules/homa/src/mock.rs | 3 +- modules/homa/src/tests.rs | 79 ++++++++++++++++++++-- modules/homa/src/weights.rs | 10 ++- runtime/acala/src/lib.rs | 1 + runtime/acala/src/weights/module_homa.rs | 4 +- runtime/common/src/precompile/mock.rs | 1 + runtime/karura/src/lib.rs | 1 + runtime/karura/src/weights/module_homa.rs | 4 +- runtime/mandala/src/benchmarking/homa.rs | 24 +++++-- runtime/mandala/src/lib.rs | 1 + runtime/mandala/src/weights/module_homa.rs | 4 +- 12 files changed, 138 insertions(+), 29 deletions(-) diff --git a/modules/homa/src/lib.rs b/modules/homa/src/lib.rs index ccba0cb274..42694fc29b 100644 --- a/modules/homa/src/lib.rs +++ b/modules/homa/src/lib.rs @@ -156,6 +156,10 @@ pub mod module { /// The XcmInterface to manage the staking of sub-account on relaychain. type XcmInterface: HomaSubAccountXcm; + /// The limit for process redeem requests when bump era. + #[pallet::constant] + type ProcessRedeemRequestsLimit: Get; + /// Weight information for the extrinsics in this module. type WeightInfo: WeightInfo; @@ -383,14 +387,14 @@ pub mod module { fn on_initialize(_: BlockNumberFor) -> Weight { let bump_era_number = Self::era_amount_should_to_bump(T::RelayChainBlockNumber::current_block_number()); if !bump_era_number.is_zero() { - let _ = Self::bump_current_era(bump_era_number); + let res = Self::bump_current_era(bump_era_number); debug_assert_eq!( TotalStakingBonded::::get(), StakingLedgers::::iter().fold(Zero::zero(), |total_bonded: Balance, (_, ledger)| { total_bonded.saturating_add(ledger.bonded) }) ); - ::WeightInfo::on_initialize_with_bump_era() + ::WeightInfo::on_initialize_with_bump_era(res.unwrap_or_default()) } else { ::WeightInfo::on_initialize() } @@ -659,10 +663,12 @@ pub mod module { } #[pallet::call_index(8)] - #[pallet::weight(< T as Config >::WeightInfo::on_initialize_with_bump_era())] - pub fn force_bump_current_era(origin: OriginFor, bump_amount: EraIndex) -> DispatchResult { + #[pallet::weight(< T as Config >::WeightInfo::on_initialize_with_bump_era(T::ProcessRedeemRequestsLimit::get()))] + pub fn force_bump_current_era(origin: OriginFor, bump_amount: EraIndex) -> DispatchResultWithPostInfo { T::GovernanceOrigin::ensure_origin(origin)?; - Self::bump_current_era(bump_amount) + + let res = Self::bump_current_era(bump_amount); + Ok(Some(T::WeightInfo::on_initialize_with_bump_era(res.unwrap_or_default())).into()) } /// Execute fast match for specific redeem requests, require completely matched. @@ -1067,17 +1073,18 @@ pub mod module { /// Process redeem requests and subaccounts do unbond on relaychain by XCM message. #[transactional] - pub fn process_redeem_requests(new_era: EraIndex) -> DispatchResult { + pub fn process_redeem_requests(new_era: EraIndex) -> Result { let era_index_to_expire = new_era + T::BondingDuration::get(); let total_bonded = TotalStakingBonded::::get(); let mut total_redeem_amount: Balance = Zero::zero(); let mut remain_total_bonded = total_bonded; + let mut handled_requests: u32 = 0; // iter RedeemRequests and insert to Unbondings if remain_total_bonded is enough. for (redeemer, (redeem_amount, _)) in RedeemRequests::::iter() { let redemption_amount = Self::convert_liquid_to_staking(redeem_amount)?; - if remain_total_bonded >= redemption_amount { + if remain_total_bonded >= redemption_amount && handled_requests < T::ProcessRedeemRequestsLimit::get() { total_redeem_amount = total_redeem_amount.saturating_add(redeem_amount); remain_total_bonded = remain_total_bonded.saturating_sub(redemption_amount); RedeemRequests::::remove(&redeemer); @@ -1090,6 +1097,8 @@ pub mod module { liquid_amount: redeem_amount, unbonding_staking_amount: redemption_amount, }); + + handled_requests += 1; } else { break; } @@ -1126,7 +1135,9 @@ pub mod module { } // burn total_redeem_amount. - Self::burn_liquid_currency(&Self::account_id(), total_redeem_amount) + Self::burn_liquid_currency(&Self::account_id(), total_redeem_amount)?; + + Ok(handled_requests) } /// Process nominate validators for subaccounts on relaychain. @@ -1163,7 +1174,7 @@ pub mod module { /// The rebalance will send XCM messages to relaychain. Once the XCM message is sent, /// the execution result cannot be obtained and cannot be rolled back. So the process /// of rebalance is not atomic. - pub fn bump_current_era(amount: EraIndex) -> DispatchResult { + pub fn bump_current_era(amount: EraIndex) -> Result { let previous_era = Self::relay_chain_current_era(); let new_era = previous_era.saturating_add(amount); RelayChainCurrentEra::::put(new_era); @@ -1171,14 +1182,14 @@ pub mod module { Self::deposit_event(Event::::CurrentEraBumped { new_era_index: new_era }); // Rebalance: - let res = || -> DispatchResult { + let res = || -> Result { TotalVoidLiquid::::put(0); Self::process_staking_rewards(new_era, previous_era)?; Self::process_scheduled_unbond(new_era)?; Self::process_to_bond_pool()?; - Self::process_redeem_requests(new_era)?; + let count = Self::process_redeem_requests(new_era)?; Self::process_nominate(new_era)?; - Ok(()) + Ok(count) }(); log::debug!( diff --git a/modules/homa/src/mock.rs b/modules/homa/src/mock.rs index d34c9f070a..51864f0cdb 100644 --- a/modules/homa/src/mock.rs +++ b/modules/homa/src/mock.rs @@ -23,7 +23,7 @@ use super::*; use frame_support::{ derive_impl, ord_parameter_types, parameter_types, - traits::{ConstU128, Nothing}, + traits::{ConstU128, ConstU32, Nothing}, }; use frame_system::{EnsureRoot, EnsureSignedBy}; use module_support::mocks::MockAddressMapping; @@ -216,6 +216,7 @@ impl Config for Runtime { type XcmInterface = MockHomaSubAccountXcm; type WeightInfo = (); type NominationsProvider = MockNominationsProvider; + type ProcessRedeemRequestsLimit = ConstU32<3>; } type Block = frame_system::mocking::MockBlock; diff --git a/modules/homa/src/tests.rs b/modules/homa/src/tests.rs index d09b969527..ef6f7fab31 100644 --- a/modules/homa/src/tests.rs +++ b/modules/homa/src/tests.rs @@ -1057,7 +1057,7 @@ fn process_redeem_requests_works() { ); // total_bonded is enough to process all redeem requests - assert_ok!(Homa::process_redeem_requests(1)); + assert_eq!(Homa::process_redeem_requests(1), Ok(1)); System::assert_has_event(RuntimeEvent::Homa(crate::Event::RedeemedByUnbond { redeemer: ALICE, era_index_when_unbond: 1, @@ -1106,7 +1106,7 @@ fn process_redeem_requests_works() { ); // total_bonded is not enough to process all redeem requests - assert_ok!(Homa::process_redeem_requests(2)); + assert_eq!(Homa::process_redeem_requests(2), Ok(2)); System::assert_has_event(RuntimeEvent::Homa(crate::Event::RedeemedByUnbond { redeemer: BOB, era_index_when_unbond: 2, @@ -1276,7 +1276,7 @@ fn bump_current_era_works() { // bump era to #1, // will process to_bond_pool. MockRelayBlockNumberProvider::set(100); - assert_ok!(Homa::bump_current_era(1)); + assert_eq!(Homa::bump_current_era(1), Ok(0)); System::assert_has_event(RuntimeEvent::Homa(crate::Event::CurrentEraBumped { new_era_index: 1 })); assert_eq!(Homa::last_era_bumped_block(), 100); assert_eq!(Homa::relay_chain_current_era(), 1); @@ -1307,7 +1307,7 @@ fn bump_current_era_works() { // bump era to #2, // accumulate staking reward and draw commission MockRelayBlockNumberProvider::set(200); - assert_ok!(Homa::bump_current_era(1)); + assert_eq!(Homa::bump_current_era(1), Ok(0)); System::assert_has_event(RuntimeEvent::Homa(crate::Event::CurrentEraBumped { new_era_index: 2 })); assert_eq!(Homa::last_era_bumped_block(), 200); assert_eq!(Homa::relay_chain_current_era(), 2); @@ -1358,7 +1358,7 @@ fn bump_current_era_works() { // bump era to #3, // will process redeem requests MockRelayBlockNumberProvider::set(300); - assert_ok!(Homa::bump_current_era(1)); + assert_eq!(Homa::bump_current_era(1), Ok(1)); System::assert_has_event(RuntimeEvent::Homa(crate::Event::CurrentEraBumped { new_era_index: 3 })); System::assert_has_event(RuntimeEvent::Homa(crate::Event::RedeemedByUnbond { redeemer: ALICE, @@ -1404,7 +1404,7 @@ fn bump_current_era_works() { // bump era to #31, // will process scheduled unbonded MockRelayBlockNumberProvider::set(3100); - assert_ok!(Homa::bump_current_era(28)); + assert_eq!(Homa::bump_current_era(28), Ok(0)); System::assert_has_event(RuntimeEvent::Homa(crate::Event::CurrentEraBumped { new_era_index: 31 })); assert_eq!(Homa::last_era_bumped_block(), 3100); assert_eq!(Homa::relay_chain_current_era(), 31); @@ -1483,3 +1483,70 @@ fn last_era_bumped_block_config_check_works() { assert_eq!(MockRelayBlockNumberProvider::current_block_number(), 100); }); } + +#[test] +fn process_redeem_requests_under_limit_works() { + ExtBuilder::default() + .balances(vec![ + (ALICE, LIQUID_CURRENCY_ID, 10_000_000), + (BOB, LIQUID_CURRENCY_ID, 10_000_000), + (CHARLIE, LIQUID_CURRENCY_ID, 10_000_000), + (DAVE, LIQUID_CURRENCY_ID, 10_000_000), + ]) + .build() + .execute_with(|| { + assert_ok!(Homa::reset_ledgers( + RuntimeOrigin::signed(HomaAdmin::get()), + vec![(0, Some(4_000_000), None)] + )); + ToBondPool::::put(4_000_000); + + assert_ok!(Homa::request_redeem(RuntimeOrigin::signed(ALICE), 5_000_000, false)); + assert_ok!(Homa::request_redeem(RuntimeOrigin::signed(BOB), 5_000_000, false)); + assert_ok!(Homa::request_redeem(RuntimeOrigin::signed(CHARLIE), 5_000_000, false)); + assert_ok!(Homa::request_redeem(RuntimeOrigin::signed(DAVE), 5_000_000, false)); + assert_eq!(Homa::redeem_requests(&ALICE), Some((5_000_000, false))); + assert_eq!(Homa::redeem_requests(&BOB), Some((5_000_000, false))); + assert_eq!(Homa::redeem_requests(&CHARLIE), Some((5_000_000, false))); + assert_eq!(Homa::redeem_requests(&DAVE), Some((5_000_000, false))); + assert_eq!(Homa::unbondings(&ALICE, 1 + BondingDuration::get()), 0); + assert_eq!(Homa::unbondings(&BOB, 1 + BondingDuration::get()), 0); + assert_eq!(Homa::unbondings(&CHARLIE, 1 + BondingDuration::get()), 0); + assert_eq!(Homa::unbondings(&DAVE, 1 + BondingDuration::get()), 0); + assert_eq!(Homa::get_total_bonded(), 4_000_000); + assert_eq!(Currencies::total_issuance(LIQUID_CURRENCY_ID), 40_000_000); + + // total_bonded is enough to process all redeem requests, but excceed limit + assert_eq!(Homa::process_redeem_requests(1), Ok(3)); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::RedeemedByUnbond { + redeemer: ALICE, + era_index_when_unbond: 1, + liquid_amount: 5_000_000, + unbonding_staking_amount: 1_000_000, + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::RedeemedByUnbond { + redeemer: BOB, + era_index_when_unbond: 1, + liquid_amount: 5_000_000, + unbonding_staking_amount: 1_000_000, + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::RedeemedByUnbond { + redeemer: CHARLIE, + era_index_when_unbond: 1, + liquid_amount: 5_000_000, + unbonding_staking_amount: 1_000_000, + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaUnbond { + sub_account_index: 0, + amount: 3_000_000, + })); + assert_eq!(Homa::redeem_requests(&ALICE), None); + assert_eq!(Homa::redeem_requests(&BOB), None); + assert_eq!(Homa::redeem_requests(&CHARLIE), None); + assert_eq!(Homa::redeem_requests(&DAVE), Some((5_000_000, false))); + assert_eq!(Homa::unbondings(&ALICE, 1 + BondingDuration::get()), 1_000_000); + assert_eq!(Homa::unbondings(&BOB, 1 + BondingDuration::get()), 1_000_000); + assert_eq!(Homa::unbondings(&CHARLIE, 1 + BondingDuration::get()), 1_000_000); + assert_eq!(Homa::unbondings(&DAVE, 1 + BondingDuration::get()), 0); + }); +} diff --git a/modules/homa/src/weights.rs b/modules/homa/src/weights.rs index 2d34c64745..ca603bceee 100644 --- a/modules/homa/src/weights.rs +++ b/modules/homa/src/weights.rs @@ -48,7 +48,7 @@ use sp_std::marker::PhantomData; /// Weight functions needed for module_homa. pub trait WeightInfo { fn on_initialize() -> Weight; - fn on_initialize_with_bump_era() -> Weight; + fn on_initialize_with_bump_era(n: u32,) -> Weight; fn mint() -> Weight; fn request_redeem() -> Weight; fn fast_match_redeems(n: u32, ) -> Weight; @@ -92,10 +92,12 @@ impl WeightInfo for AcalaWeight { // Storage: Homa RedeemRequests (r:2 w:1) // Storage: Homa Unbondings (r:1 w:1) // Storage: Homa TotalVoidLiquid (r:0 w:1) - fn on_initialize_with_bump_era() -> Weight { + fn on_initialize_with_bump_era(n: u32,) -> Weight { Weight::from_parts(253_506_000, 0) .saturating_add(T::DbWeight::get().reads(31 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(n as u64))) .saturating_add(T::DbWeight::get().writes(18 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(n as u64))) } // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Homa TotalStakingBonded (r:1 w:0) @@ -195,10 +197,12 @@ impl WeightInfo for () { Weight::from_parts(5_281_000, 0) .saturating_add(RocksDbWeight::get().reads(3 as u64)) } - fn on_initialize_with_bump_era() -> Weight { + fn on_initialize_with_bump_era(n: u32,) -> Weight { Weight::from_parts(253_506_000, 0) .saturating_add(RocksDbWeight::get().reads(31 as u64)) + .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(n as u64))) .saturating_add(RocksDbWeight::get().writes(18 as u64)) + .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(n as u64))) } fn mint() -> Weight { Weight::from_parts(88_950_000, 0) diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index d6645eb835..822db4ef5a 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -1594,6 +1594,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; + type ProcessRedeemRequestsLimit = ConstU32<2_000>; } parameter_types! { diff --git a/runtime/acala/src/weights/module_homa.rs b/runtime/acala/src/weights/module_homa.rs index 59d3143e06..a01452e04c 100644 --- a/runtime/acala/src/weights/module_homa.rs +++ b/runtime/acala/src/weights/module_homa.rs @@ -111,14 +111,16 @@ impl module_homa::WeightInfo for WeightInfo { // Proof: `Homa::Unbondings` (`max_values`: None, `max_size`: None, mode: `Measured`) // Storage: `Homa::TotalVoidLiquid` (r:0 w:1) // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn on_initialize_with_bump_era() -> Weight { + fn on_initialize_with_bump_era(n: u32,) -> Weight { // Proof Size summary in bytes: // Measured: `2961` // Estimated: `13851` // Minimum execution time: 298_418 nanoseconds. Weight::from_parts(305_164_000, 13851) .saturating_add(T::DbWeight::get().reads(32)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(18)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) } // Storage: `Homa::TotalStakingBonded` (r:1 w:0) // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) diff --git a/runtime/common/src/precompile/mock.rs b/runtime/common/src/precompile/mock.rs index d2f1b24f9e..c1ab61a648 100644 --- a/runtime/common/src/precompile/mock.rs +++ b/runtime/common/src/precompile/mock.rs @@ -743,6 +743,7 @@ impl module_homa::Config for Test { type XcmInterface = MockHomaSubAccountXcm; type WeightInfo = (); type NominationsProvider = (); + type ProcessRedeemRequestsLimit = ConstU32<2_000>; } parameter_type_with_key! { diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index ff56511ef8..af2b110964 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1619,6 +1619,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; + type ProcessRedeemRequestsLimit = ConstU32<2_000>; } parameter_types! { diff --git a/runtime/karura/src/weights/module_homa.rs b/runtime/karura/src/weights/module_homa.rs index 5e4a953179..498676d412 100644 --- a/runtime/karura/src/weights/module_homa.rs +++ b/runtime/karura/src/weights/module_homa.rs @@ -111,14 +111,16 @@ impl module_homa::WeightInfo for WeightInfo { // Proof: `Homa::Unbondings` (`max_values`: None, `max_size`: None, mode: `Measured`) // Storage: `Homa::TotalVoidLiquid` (r:0 w:1) // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn on_initialize_with_bump_era() -> Weight { + fn on_initialize_with_bump_era(n: u32,) -> Weight { // Proof Size summary in bytes: // Measured: `2962` // Estimated: `13852` // Minimum execution time: 314_492 nanoseconds. Weight::from_parts(320_994_000, 13852) .saturating_add(T::DbWeight::get().reads(34)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(19)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) } // Storage: `Homa::TotalStakingBonded` (r:1 w:0) // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) diff --git a/runtime/mandala/src/benchmarking/homa.rs b/runtime/mandala/src/benchmarking/homa.rs index 64b02c3e8d..e5ee43f6f8 100644 --- a/runtime/mandala/src/benchmarking/homa.rs +++ b/runtime/mandala/src/benchmarking/homa.rs @@ -16,7 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{AccountId, ActiveSubAccountsIndexList, Balance, Currencies, Homa, Rate, RelaychainDataProvider, Runtime}; +use crate::{ + AccountId, ActiveSubAccountsIndexList, Balance, Currencies, Homa, Rate, RedeemThreshold, RelaychainDataProvider, + Runtime, +}; use super::utils::{set_balance, LIQUID, STAKING}; use frame_benchmarking::{account, whitelisted_caller}; @@ -39,17 +42,24 @@ runtime_benchmarks! { } on_initialize_with_bump_era { + let n in 1 .. 50; let minter: AccountId = account("minter", 0, SEED); - let redeemer: AccountId = account("redeemer", 0, SEED); let sub_account_index = ActiveSubAccountsIndexList::get().first().unwrap().clone(); set_balance(STAKING, &minter, 1_000_000_000_000_000); - set_balance(LIQUID, &redeemer, 1_000_000_000_000_000 * 10); + + for i in 0 .. n { + let redeemer = account("redeemer", i, SEED); + set_balance(LIQUID, &redeemer, 1_000_000_000_000_000); + } + + // need to process unlocking Homa::reset_ledgers( RawOrigin::Root.into(), vec![(sub_account_index, Some(1_000_000_000_000_000), Some(vec![UnlockChunk{value: 1_000_000_000_000, era: 10}]))] )?; Homa::reset_current_era(RawOrigin::Root.into(), 9)?; + Homa::update_homa_params( RawOrigin::Root.into(), Some(10_000_000_000_000_000), @@ -61,8 +71,14 @@ runtime_benchmarks! { RelaychainDataProvider::::set_block_number(10); Homa::update_bump_era_params(RawOrigin::Root.into(), None, Some(1))?; + // need to process to bond Homa::mint(RawOrigin::Signed(minter).into(), 100_000_000_000_000)?; - Homa::request_redeem(RawOrigin::Signed(redeemer).into(), 5_000_000_000_000_000, true)?; + + // need to process redeem request + for i in 0 .. n { + let redeemer = account("redeemer", i, SEED); + Homa::request_redeem(RawOrigin::Signed(redeemer).into(), 100_000_000_000_000, false)?; + } }: { Homa::on_initialize(1) } diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 84d86267c6..95fc2e9213 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -1447,6 +1447,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; + type ProcessRedeemRequestsLimit = ConstU32<2_000>; } parameter_types! { diff --git a/runtime/mandala/src/weights/module_homa.rs b/runtime/mandala/src/weights/module_homa.rs index 813bd2fd32..cd48d1deca 100644 --- a/runtime/mandala/src/weights/module_homa.rs +++ b/runtime/mandala/src/weights/module_homa.rs @@ -109,14 +109,16 @@ impl module_homa::WeightInfo for WeightInfo { // Proof: `Homa::Unbondings` (`max_values`: None, `max_size`: None, mode: `Measured`) // Storage: `Homa::TotalVoidLiquid` (r:0 w:1) // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn on_initialize_with_bump_era() -> Weight { + fn on_initialize_with_bump_era(n: u32,) -> Weight { // Proof Size summary in bytes: // Measured: `4057` // Estimated: `14947` // Minimum execution time: 207_924 nanoseconds. Weight::from_parts(215_712_000, 14947) .saturating_add(T::DbWeight::get().reads(31)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(18)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) } // Storage: `Homa::TotalStakingBonded` (r:1 w:0) // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) From 00ffcaebab7162e62cbcbf74556e22713bf0424c Mon Sep 17 00:00:00 2001 From: wangjj9219 <183318287@qq.com> Date: Sat, 14 Sep 2024 10:31:41 +0800 Subject: [PATCH 03/14] extend DEX precompile for bootstrap (#2805) * extend DEX precompile for bootstrap * format * update predeploy-contracts --- modules/dex/src/lib.rs | 208 ++++++--- modules/support/src/dex.rs | 74 +++- predeploy-contracts | 2 +- runtime/common/src/precompile/dex.rs | 626 ++++++++++++++++++++++++++- 4 files changed, 845 insertions(+), 65 deletions(-) diff --git a/modules/dex/src/lib.rs b/modules/dex/src/lib.rs index 92d1d25672..90888a1406 100644 --- a/modules/dex/src/lib.rs +++ b/modules/dex/src/lib.rs @@ -35,7 +35,7 @@ use frame_support::{pallet_prelude::*, transactional, PalletId}; use frame_system::pallet_prelude::*; -use module_support::{DEXIncentives, DEXManager, Erc20InfoMapping, ExchangeRate, Ratio, SwapLimit}; +use module_support::{DEXBootstrap, DEXIncentives, DEXManager, Erc20InfoMapping, ExchangeRate, Ratio, SwapLimit}; use orml_traits::{Happened, MultiCurrency, MultiCurrencyExtended}; use parity_scale_codec::MaxEncodedLen; use primitives::{Balance, CurrencyId, TradingPair}; @@ -757,40 +757,9 @@ pub mod module { currency_id_b: CurrencyId, ) -> DispatchResult { let _ = ensure_signed(origin)?; - let trading_pair = - TradingPair::from_currency_ids(currency_id_a, currency_id_b).ok_or(Error::::InvalidCurrencyId)?; - ensure!( - matches!( - Self::trading_pair_statuses(trading_pair), - TradingPairStatus::<_, _>::Disabled - ), - Error::::MustBeDisabled - ); - - // Make sure the trading pair has not been successfully ended provisioning. - ensure!( - InitialShareExchangeRates::::get(trading_pair) == Default::default(), - Error::::NotAllowedRefund - ); - ProvisioningPool::::try_mutate_exists(trading_pair, &owner, |maybe_contribution| -> DispatchResult { - if let Some((contribution_0, contribution_1)) = maybe_contribution.take() { - T::Currency::transfer(trading_pair.first(), &Self::account_id(), &owner, contribution_0)?; - T::Currency::transfer(trading_pair.second(), &Self::account_id(), &owner, contribution_1)?; - - // decrease ref count - frame_system::Pallet::::dec_consumers(&owner); - - Self::deposit_event(Event::RefundProvision { - who: owner.clone(), - currency_0: trading_pair.first(), - contribution_0, - currency_1: trading_pair.second(), - contribution_1, - }); - } - Ok(()) - }) + Self::do_refund_provision(&owner, currency_id_a, currency_id_b)?; + Ok(()) } /// Abort provision when it's don't meet the target and expired. @@ -859,7 +828,11 @@ impl Pallet { }) } - fn do_claim_dex_share(who: &T::AccountId, currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> DispatchResult { + fn do_claim_dex_share( + who: &T::AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + ) -> Result { let trading_pair = TradingPair::from_currency_ids(currency_id_a, currency_id_b).ok_or(Error::::InvalidCurrencyId)?; ensure!( @@ -870,38 +843,82 @@ impl Pallet { Error::::StillProvisioning ); - ProvisioningPool::::try_mutate_exists(trading_pair, who, |maybe_contribution| -> DispatchResult { - if let Some((contribution_0, contribution_1)) = maybe_contribution.take() { - let (exchange_rate_0, exchange_rate_1) = Self::initial_share_exchange_rates(trading_pair); - let shares_from_provision_0 = exchange_rate_0 - .checked_mul_int(contribution_0) - .ok_or(ArithmeticError::Overflow)?; - let shares_from_provision_1 = exchange_rate_1 - .checked_mul_int(contribution_1) - .ok_or(ArithmeticError::Overflow)?; - let shares_to_claim = shares_from_provision_0 - .checked_add(shares_from_provision_1) - .ok_or(ArithmeticError::Overflow)?; - - T::Currency::transfer( - trading_pair.dex_share_currency_id(), - &Self::account_id(), - who, - shares_to_claim, - )?; + let claimed_share = ProvisioningPool::::try_mutate_exists( + trading_pair, + who, + |maybe_contribution| -> Result { + if let Some((contribution_0, contribution_1)) = maybe_contribution.take() { + let (exchange_rate_0, exchange_rate_1) = Self::initial_share_exchange_rates(trading_pair); + let shares_from_provision_0 = exchange_rate_0 + .checked_mul_int(contribution_0) + .ok_or(ArithmeticError::Overflow)?; + let shares_from_provision_1 = exchange_rate_1 + .checked_mul_int(contribution_1) + .ok_or(ArithmeticError::Overflow)?; + let shares_to_claim = shares_from_provision_0 + .checked_add(shares_from_provision_1) + .ok_or(ArithmeticError::Overflow)?; - // decrease ref count - frame_system::Pallet::::dec_consumers(who); - } - Ok(()) - })?; + T::Currency::transfer( + trading_pair.dex_share_currency_id(), + &Self::account_id(), + who, + shares_to_claim, + )?; + + // decrease ref count + frame_system::Pallet::::dec_consumers(who); + + Ok(shares_to_claim) + } else { + Ok(Default::default()) + } + }, + )?; // clear InitialShareExchangeRates once it is all claimed if ProvisioningPool::::iter_prefix(trading_pair).next().is_none() { InitialShareExchangeRates::::remove(trading_pair); } - Ok(()) + Ok(claimed_share) + } + + fn do_refund_provision(who: &T::AccountId, currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> DispatchResult { + let trading_pair = + TradingPair::from_currency_ids(currency_id_a, currency_id_b).ok_or(Error::::InvalidCurrencyId)?; + ensure!( + matches!( + Self::trading_pair_statuses(trading_pair), + TradingPairStatus::<_, _>::Disabled + ), + Error::::MustBeDisabled + ); + + // Make sure the trading pair has not been successfully ended provisioning. + ensure!( + InitialShareExchangeRates::::get(trading_pair) == Default::default(), + Error::::NotAllowedRefund + ); + + ProvisioningPool::::try_mutate_exists(trading_pair, who, |maybe_contribution| -> DispatchResult { + if let Some((contribution_0, contribution_1)) = maybe_contribution.take() { + T::Currency::transfer(trading_pair.first(), &Self::account_id(), who, contribution_0)?; + T::Currency::transfer(trading_pair.second(), &Self::account_id(), who, contribution_1)?; + + // decrease ref count + frame_system::Pallet::::dec_consumers(who); + + Self::deposit_event(Event::RefundProvision { + who: who.clone(), + currency_0: trading_pair.first(), + contribution_0, + currency_1: trading_pair.second(), + contribution_1, + }); + } + Ok(()) + }) } fn do_add_provision( @@ -1544,3 +1561,74 @@ impl DEXManager for Pallet { ) } } + +impl DEXBootstrap for Pallet { + fn get_provision_pool(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance) { + if let Some(trading_pair) = TradingPair::from_currency_ids(currency_id_a, currency_id_b) { + if let TradingPairStatus::<_, _>::Provisioning(provision_parameters) = + Self::trading_pair_statuses(trading_pair) + { + let (total_provision_0, total_provision_1) = provision_parameters.accumulated_provision; + if currency_id_a == trading_pair.first() { + return (total_provision_0, total_provision_1); + } else { + return (total_provision_1, total_provision_0); + } + } + } + + (Zero::zero(), Zero::zero()) + } + + fn get_provision_pool_of( + who: &T::AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + ) -> (Balance, Balance) { + if let Some(trading_pair) = TradingPair::from_currency_ids(currency_id_a, currency_id_b) { + let (provision_0, provision_1) = Self::provisioning_pool(trading_pair, who); + if currency_id_a == trading_pair.first() { + (provision_0, provision_1) + } else { + (provision_1, provision_0) + } + } else { + (Zero::zero(), Zero::zero()) + } + } + + fn get_initial_share_exchange_rate(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance) { + if let Some(trading_pair) = TradingPair::from_currency_ids(currency_id_a, currency_id_b) { + let (exchange_rate_0, exchange_rate_1) = Self::initial_share_exchange_rates(trading_pair); + if currency_id_a == trading_pair.first() { + (exchange_rate_0.into_inner(), exchange_rate_1.into_inner()) + } else { + (exchange_rate_1.into_inner(), exchange_rate_0.into_inner()) + } + } else { + (Zero::zero(), Zero::zero()) + } + } + + fn add_provision( + who: &T::AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + contribution_a: Balance, + contribution_b: Balance, + ) -> DispatchResult { + Self::do_add_provision(who, currency_id_a, currency_id_b, contribution_a, contribution_b) + } + + fn claim_dex_share( + who: &T::AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + ) -> Result { + Self::do_claim_dex_share(who, currency_id_a, currency_id_b) + } + + fn refund_provision(who: &T::AccountId, currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> DispatchResult { + Self::do_refund_provision(who, currency_id_a, currency_id_b) + } +} diff --git a/modules/support/src/dex.rs b/modules/support/src/dex.rs index c07c6bac62..83f997373d 100644 --- a/modules/support/src/dex.rs +++ b/modules/support/src/dex.rs @@ -23,7 +23,7 @@ use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::H160; -use sp_runtime::{DispatchError, RuntimeDebug}; +use sp_runtime::{DispatchError, DispatchResult, RuntimeDebug}; use sp_std::{cmp::PartialEq, prelude::*, result::Result}; #[derive(RuntimeDebug, Encode, Decode, Clone, Copy, PartialEq, Eq, TypeInfo)] @@ -82,6 +82,34 @@ pub trait DEXManager { ) -> Result<(Balance, Balance), DispatchError>; } +pub trait DEXBootstrap: DEXManager { + fn get_provision_pool(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance); + + fn get_provision_pool_of( + who: &AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + ) -> (Balance, Balance); + + fn get_initial_share_exchange_rate(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance); + + fn add_provision( + who: &AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + contribution_a: Balance, + contribution_b: Balance, + ) -> DispatchResult; + + fn claim_dex_share( + who: &AccountId, + currency_id_a: CurrencyId, + currency_id_b: CurrencyId, + ) -> Result; + + fn refund_provision(who: &AccountId, currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> DispatchResult; +} + pub trait Swap where CurrencyId: Clone, @@ -250,3 +278,47 @@ where Ok(Default::default()) } } + +#[cfg(feature = "std")] +impl DEXBootstrap for () +where + Balance: Default, +{ + fn get_provision_pool(_currency_id_a: CurrencyId, _currency_id_b: CurrencyId) -> (Balance, Balance) { + Default::default() + } + + fn get_provision_pool_of( + _who: &AccountId, + _currency_id_a: CurrencyId, + _currency_id_b: CurrencyId, + ) -> (Balance, Balance) { + Default::default() + } + + fn get_initial_share_exchange_rate(_currency_id_a: CurrencyId, _currency_id_b: CurrencyId) -> (Balance, Balance) { + Default::default() + } + + fn add_provision( + _who: &AccountId, + _currency_id_a: CurrencyId, + _currency_id_b: CurrencyId, + _contribution_a: Balance, + _contribution_b: Balance, + ) -> DispatchResult { + Ok(()) + } + + fn claim_dex_share( + _who: &AccountId, + _currency_id_a: CurrencyId, + _currency_id_b: CurrencyId, + ) -> Result { + Ok(Default::default()) + } + + fn refund_provision(_who: &AccountId, _currency_id_a: CurrencyId, _currency_id_b: CurrencyId) -> DispatchResult { + Ok(()) + } +} diff --git a/predeploy-contracts b/predeploy-contracts index 95e0d858ac..2b2a8ba010 160000 --- a/predeploy-contracts +++ b/predeploy-contracts @@ -1 +1 @@ -Subproject commit 95e0d858ac4a748c5072e4ad55413c306d5bb5e1 +Subproject commit 2b2a8ba010c315b9f3ee4b103cc42bfe0dd067b2 diff --git a/runtime/common/src/precompile/dex.rs b/runtime/common/src/precompile/dex.rs index 2c29989c4e..bc6da01a3d 100644 --- a/runtime/common/src/precompile/dex.rs +++ b/runtime/common/src/precompile/dex.rs @@ -24,7 +24,7 @@ use module_evm::{ precompiles::Precompile, ExitRevert, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, }; -use module_support::{DEXManager, SwapLimit}; +use module_support::{DEXBootstrap, DEXManager, SwapLimit}; use num_enum::{IntoPrimitive, TryFromPrimitive}; use primitives::{Balance, CurrencyId}; use sp_runtime::{traits::Convert, RuntimeDebug}; @@ -53,12 +53,19 @@ pub enum Action { SwapWithExactTarget = "swapWithExactTarget(address,address[],uint256,uint256)", AddLiquidity = "addLiquidity(address,address,address,uint256,uint256,uint256)", RemoveLiquidity = "removeLiquidity(address,address,address,uint256,uint256,uint256)", + GetProvisionPool = "getProvisionPool(address,address)", + GetProvisionPoolOf = "getProvisionPoolOf(address,address,address)", + GetInitialShareExchangeRate = "getInitialShareExchangeRate(address,address)", + AddProvision = "addProvision(address,address,address,uint256,uint256)", + ClaimDexShare = "claimDexShare(address,address,address)", + RefundProvision = "refundProvision(address,address,address)", } impl Precompile for DEXPrecompile where Runtime: module_evm::Config + module_dex::Config + module_prices::Config, - module_dex::Pallet: DEXManager, + module_dex::Pallet: + DEXManager + DEXBootstrap, { fn execute(handle: &mut impl PrecompileHandle) -> PrecompileResult { let gas_cost = Pricer::::cost(handle)?; @@ -281,6 +288,151 @@ where output: Output::encode_error_msg("DEX RemoveLiquidity failed", e), })?; + Ok(PrecompileOutput { + exit_status: ExitSucceed::Returned, + output: vec![], + }) + } + Action::GetProvisionPool => { + let currency_id_a = input.currency_id_at(1)?; + let currency_id_b = input.currency_id_at(2)?; + log::debug!( + target: "evm", + "dex: get_provision_pool currency_id_a: {:?}, currency_id_b: {:?}", + currency_id_a, currency_id_b + ); + + let (balance_a, balance_b) = as DEXBootstrap< + Runtime::AccountId, + Balance, + CurrencyId, + >>::get_provision_pool(currency_id_a, currency_id_b); + + Ok(PrecompileOutput { + exit_status: ExitSucceed::Returned, + output: Output::encode_uint_tuple(vec![balance_a, balance_b]), + }) + } + Action::GetProvisionPoolOf => { + let who = input.account_id_at(1)?; + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + log::debug!( + target: "evm", + "dex: get_provision_pool_of who: {:?}, currency_id_a: {:?}, currency_id_b: {:?}", + who, currency_id_a, currency_id_b + ); + + let (balance_a, balance_b) = as DEXBootstrap< + Runtime::AccountId, + Balance, + CurrencyId, + >>::get_provision_pool_of(&who, currency_id_a, currency_id_b); + + Ok(PrecompileOutput { + exit_status: ExitSucceed::Returned, + output: Output::encode_uint_tuple(vec![balance_a, balance_b]), + }) + } + Action::GetInitialShareExchangeRate => { + let currency_id_a = input.currency_id_at(1)?; + let currency_id_b = input.currency_id_at(2)?; + log::debug!( + target: "evm", + "dex: get_provision_pool currency_id_a: {:?}, currency_id_b: {:?}", + currency_id_a, currency_id_b + ); + + let (exchange_rate_a, exchange_rate_b) = as DEXBootstrap< + Runtime::AccountId, + Balance, + CurrencyId, + >>::get_initial_share_exchange_rate( + currency_id_a, currency_id_b + ); + + Ok(PrecompileOutput { + exit_status: ExitSucceed::Returned, + output: Output::encode_uint_tuple(vec![exchange_rate_a, exchange_rate_b]), + }) + } + Action::AddProvision => { + let who = input.account_id_at(1)?; + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + let contribution_a = input.balance_at(4)?; + let contribution_b = input.balance_at(5)?; + + log::debug!( + target: "evm", + "dex: add_provision who: {:?}, currency_id_a: {:?}, currency_id_b: {:?}, contribution_a: {:?}, contribution_b: {:?}", + who, currency_id_a, currency_id_b, contribution_a, contribution_b, + ); + + as DEXBootstrap>::add_provision( + &who, + currency_id_a, + currency_id_b, + contribution_a, + contribution_b, + ) + .map_err(|e| PrecompileFailure::Revert { + exit_status: ExitRevert::Reverted, + output: Output::encode_error_msg("DEX AddProvision failed", e), + })?; + + Ok(PrecompileOutput { + exit_status: ExitSucceed::Returned, + output: vec![], + }) + } + Action::ClaimDexShare => { + let who = input.account_id_at(1)?; + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + + log::debug!( + target: "evm", + "dex: claim_dex_share who: {:?}, currency_id_a: {:?}, currency_id_b: {:?}", + who, currency_id_a, currency_id_b, + ); + + let claimed_share = as DEXBootstrap< + Runtime::AccountId, + Balance, + CurrencyId, + >>::claim_dex_share(&who, currency_id_a, currency_id_b) + .map_err(|e| PrecompileFailure::Revert { + exit_status: ExitRevert::Reverted, + output: Output::encode_error_msg("DEX ClaimDexShare failed", e), + })?; + + Ok(PrecompileOutput { + exit_status: ExitSucceed::Returned, + output: Output::encode_uint(claimed_share), + }) + } + Action::RefundProvision => { + let who = input.account_id_at(1)?; + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + + log::debug!( + target: "evm", + "dex: refund_provision who: {:?}, currency_id_a: {:?}, currency_id_b: {:?}", + who, currency_id_a, currency_id_b, + ); + + as DEXBootstrap>::refund_provision( + &who, + currency_id_a, + currency_id_b, + ) + .map_err(|e| PrecompileFailure::Revert { + exit_status: ExitRevert::Reverted, + output: Output::encode_error_msg("DEX RefundProvision failed", e), + })?; + Ok(PrecompileOutput { exit_status: ExitSucceed::Returned, output: vec![], @@ -435,6 +587,98 @@ where let weight = ::WeightInfo::remove_liquidity(); + Self::BASE_COST + .saturating_add(read_account) + .saturating_add(read_currency_a) + .saturating_add(read_currency_b) + .saturating_add(WeightToGas::convert(weight)) + } + Action::GetProvisionPool => { + let currency_id_a = input.currency_id_at(1)?; + let currency_id_b = input.currency_id_at(2)?; + let read_currency_a = InputPricer::::read_currency(currency_id_a); + let read_currency_b = InputPricer::::read_currency(currency_id_b); + + // DEX::TradingPairStatuses (r: 1) + let weight = ::DbWeight::get().reads(1); + + Self::BASE_COST + .saturating_add(read_currency_a) + .saturating_add(read_currency_b) + .saturating_add(WeightToGas::convert(weight)) + } + Action::GetProvisionPoolOf => { + let read_account = InputPricer::::read_accounts(1); + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + let read_currency_a = InputPricer::::read_currency(currency_id_a); + let read_currency_b = InputPricer::::read_currency(currency_id_b); + + // DEX::ProvisioningPool (r: 1) + let weight = ::DbWeight::get().reads(1); + + Self::BASE_COST + .saturating_add(read_account) + .saturating_add(read_currency_a) + .saturating_add(read_currency_b) + .saturating_add(WeightToGas::convert(weight)) + } + Action::GetInitialShareExchangeRate => { + let currency_id_a = input.currency_id_at(1)?; + let currency_id_b = input.currency_id_at(2)?; + let read_currency_a = InputPricer::::read_currency(currency_id_a); + let read_currency_b = InputPricer::::read_currency(currency_id_b); + + // DEX::InitialShareExchangeRates (r: 1) + let weight = ::DbWeight::get().reads(1); + + Self::BASE_COST + .saturating_add(read_currency_a) + .saturating_add(read_currency_b) + .saturating_add(WeightToGas::convert(weight)) + } + Action::AddProvision => { + let read_account = InputPricer::::read_accounts(1); + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + + let read_currency_a = InputPricer::::read_currency(currency_id_a); + let read_currency_b = InputPricer::::read_currency(currency_id_b); + + let weight = ::WeightInfo::add_provision(); + + Self::BASE_COST + .saturating_add(read_account) + .saturating_add(read_currency_a) + .saturating_add(read_currency_b) + .saturating_add(WeightToGas::convert(weight)) + } + Action::ClaimDexShare => { + let read_account = InputPricer::::read_accounts(1); + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + + let read_currency_a = InputPricer::::read_currency(currency_id_a); + let read_currency_b = InputPricer::::read_currency(currency_id_b); + + let weight = ::WeightInfo::claim_dex_share(); + + Self::BASE_COST + .saturating_add(read_account) + .saturating_add(read_currency_a) + .saturating_add(read_currency_b) + .saturating_add(WeightToGas::convert(weight)) + } + Action::RefundProvision => { + let read_account = InputPricer::::read_accounts(1); + let currency_id_a = input.currency_id_at(2)?; + let currency_id_b = input.currency_id_at(3)?; + + let read_currency_a = InputPricer::::read_currency(currency_id_a); + let read_currency_b = InputPricer::::read_currency(currency_id_b); + + let weight = ::WeightInfo::refund_provision(); + Self::BASE_COST .saturating_add(read_account) .saturating_add(read_currency_a) @@ -450,7 +694,9 @@ where mod tests { use super::*; - use crate::precompile::mock::{alice_evm_addr, new_test_ext, DexModule, RuntimeOrigin, Test, ALICE, AUSD, DOT}; + use crate::precompile::mock::{ + alice, alice_evm_addr, new_test_ext, run_to_block, Currencies, DexModule, RuntimeOrigin, Test, ALICE, AUSD, DOT, + }; use frame_support::{assert_noop, assert_ok}; use hex_literal::hex; use module_evm::{precompiles::tests::MockPrecompileHandle, Context, ExitRevert}; @@ -759,4 +1005,378 @@ mod tests { assert_eq!(resp.output, expected_output.to_vec()); }); } + + #[test] + fn get_provision_pool_works() { + new_test_ext().execute_with(|| { + let context = Context { + address: Default::default(), + caller: alice_evm_addr(), + apparent_value: Default::default(), + }; + + // getProvisionPool(address,address) -> 0x5859df34 + // DOT + // AUSD + let input = hex! {" + 5859df34 + 000000000000000000000000 0000000000000000000100000000000000000002 + 000000000000000000000000 0000000000000000000100000000000000000001 + "}; + + // 0 + // 0 + let expected_output = hex! {" + 00000000000000000000000000000000 00000000000000000000000000000000 + 00000000000000000000000000000000 00000000000000000000000000000000 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + assert_eq!(resp.output, expected_output.to_vec()); + + // list provision DOT/AUSD + assert_ok!(DexModule::list_provisioning( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 10, + 10, + 10_000, + 10_000, + 100_000 + )); + + assert_ok!(DexModule::add_provision( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 1_000, + 1_000_000, + )); + + // 1_000 + // 1_000_000 + let expected_output = hex! {" + 00000000000000000000000000000000 000000000000000000000000000003e8 + 00000000000000000000000000000000 000000000000000000000000000f4240 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + assert_eq!(resp.output, expected_output.to_vec()); + }); + } + + #[test] + fn get_provision_pool_of_works() { + new_test_ext().execute_with(|| { + // list provision DOT/AUSD + assert_ok!(DexModule::list_provisioning( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 10, + 10, + 10_000, + 10_000, + 100_000 + )); + + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + DOT, + 1_000_000_000 + )); + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + AUSD, + 1_000_000_000 + )); + assert_ok!(DexModule::add_provision( + RuntimeOrigin::signed(alice()), + DOT, + AUSD, + 1_000, + 1_000_000, + )); + + assert_eq!( + DexModule::get_provision_pool_of(&crate::precompile::mock::alice(), DOT, AUSD), + (1_000, 1_000_000) + ); + + let context = Context { + address: Default::default(), + caller: alice_evm_addr(), + apparent_value: Default::default(), + }; + + // getProvisionPoolOf(address,address,address) -> 0x8ef239cf + // alice + // DOT + // AUSD + let input = hex! {" + 8ef239cf + 000000000000000000000000 1000000000000000000000000000000000000001 + 000000000000000000000000 0000000000000000000100000000000000000002 + 000000000000000000000000 0000000000000000000100000000000000000001 + "}; + + // 1_000 + // 1_000_000 + let expected_output = hex! {" + 00000000000000000000000000000000 000000000000000000000000000003e8 + 00000000000000000000000000000000 000000000000000000000000000f4240 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + assert_eq!(resp.output, expected_output.to_vec()); + }); + } + + #[test] + fn get_initial_share_exchange_rate_works() { + new_test_ext().execute_with(|| { + // list provision DOT/AUSD + assert_ok!(DexModule::list_provisioning( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 10, + 10, + 10_000, + 10_000, + 100_000 + )); + + assert_ok!(DexModule::add_provision( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 1_000_000, + 4_000_000, + )); + + run_to_block(100_001); + assert_ok!(DexModule::end_provisioning(RuntimeOrigin::signed(ALICE), DOT, AUSD)); + + let context = Context { + address: Default::default(), + caller: alice_evm_addr(), + apparent_value: Default::default(), + }; + + // getInitialShareExchangeRate(address,address) -> 0x165c7c9a + // DOT + // AUSD + let input = hex! {" + 165c7c9a + 000000000000000000000000 0000000000000000000100000000000000000002 + 000000000000000000000000 0000000000000000000100000000000000000001 + "}; + + // 4_000_000_000_000_000_000 + // 1_000_000_000_000_000_000 + let expected_output = hex! {" + 00000000000000000000000000000000 00000000000000003782dace9d900000 + 00000000000000000000000000000000 00000000000000000de0b6b3a7640000 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + assert_eq!(resp.output, expected_output.to_vec()); + + // let hex_string: String = resp.output.iter().map(|byte| format!("{:02x}", + // byte)).collect(); assert_eq!(hex_string, ""); + }); + } + + #[test] + fn add_provision_works() { + new_test_ext().execute_with(|| { + // list provision DOT/AUSD + assert_ok!(DexModule::list_provisioning( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 10, + 10, + 10_000, + 10_000, + 100_000 + )); + + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + DOT, + 1_000_000_000 + )); + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + AUSD, + 1_000_000_000 + )); + + let context = Context { + address: Default::default(), + caller: alice_evm_addr(), + apparent_value: Default::default(), + }; + + // addProvision(address,address,address,uint256,uint256) -> 0x97a20516 + // alice + // DOT + // AUSD + // 1_000 + // 1_000_000 + let input = hex! {" + 97a20516 + 000000000000000000000000 1000000000000000000000000000000000000001 + 000000000000000000000000 0000000000000000000100000000000000000002 + 000000000000000000000000 0000000000000000000100000000000000000001 + 00000000000000000000000000000000 000000000000000000000000000003e8 + 00000000000000000000000000000000 000000000000000000000000000f4240 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + + assert_eq!( + DexModule::get_provision_pool_of(&crate::precompile::mock::alice(), DOT, AUSD), + (1_000, 1_000_000) + ); + }); + } + + #[test] + fn claim_dex_share_works() { + new_test_ext().execute_with(|| { + // list provision DOT/AUSD + assert_ok!(DexModule::list_provisioning( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 10, + 10, + 10_000, + 10_000, + 100_000 + )); + + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + DOT, + 1_000_000_000 + )); + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + AUSD, + 1_000_000_000 + )); + assert_ok!(DexModule::add_provision( + RuntimeOrigin::signed(alice()), + DOT, + AUSD, + 1_000_000, + 4_000_000, + )); + + run_to_block(100_001); + assert_ok!(DexModule::end_provisioning(RuntimeOrigin::signed(ALICE), DOT, AUSD)); + + let context = Context { + address: Default::default(), + caller: alice_evm_addr(), + apparent_value: Default::default(), + }; + + // claimDexShare(address,address,address) -> 0xf1e908f8 + // alice + // DOT + // AUSD + let input = hex! {" + f1e908f8 + 000000000000000000000000 1000000000000000000000000000000000000001 + 000000000000000000000000 0000000000000000000100000000000000000002 + 000000000000000000000000 0000000000000000000100000000000000000001 + "}; + + // 8_000_000 + let expected_output = hex! {" + 00000000000000000000000000000000 000000000000000000000000007a1200 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + assert_eq!(resp.output, expected_output.to_vec()); + }); + } + + #[test] + fn refund_provision_works() { + new_test_ext().execute_with(|| { + // list provision DOT/AUSD + assert_ok!(DexModule::list_provisioning( + RuntimeOrigin::signed(ALICE), + DOT, + AUSD, + 10, + 10, + 10_000, + 10_000, + 100_000 + )); + + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + DOT, + 1_000_000_000 + )); + assert_ok!(Currencies::update_balance( + RuntimeOrigin::root(), + alice(), + AUSD, + 1_000_000_000 + )); + assert_ok!(DexModule::add_provision( + RuntimeOrigin::signed(alice()), + DOT, + AUSD, + 1_000, + 1_000, + )); + + run_to_block(100_001); + assert_ok!(DexModule::abort_provisioning(RuntimeOrigin::signed(ALICE), DOT, AUSD)); + + let context = Context { + address: Default::default(), + caller: alice_evm_addr(), + apparent_value: Default::default(), + }; + + // refundProvision(address,address,address) -> 0xaa02e9d3 + // alice + // DOT + // AUSD + let input = hex! {" + aa02e9d3 + 000000000000000000000000 1000000000000000000000000000000000000001 + 000000000000000000000000 0000000000000000000100000000000000000002 + 000000000000000000000000 0000000000000000000100000000000000000001 + "}; + + let resp = DEXPrecompile::execute(&mut MockPrecompileHandle::new(&input, None, &context, false)).unwrap(); + assert_eq!(resp.exit_status, ExitSucceed::Returned); + }); + } } From 9c863e605416d033470f71e9f72adcd978115ef1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:04:22 +1200 Subject: [PATCH 04/14] Bump vite from 5.4.1 to 5.4.6 in /ts-tests (#2811) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.1 to 5.4.6. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v5.4.6/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.4.6/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ts-tests/yarn.lock | 176 ++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/ts-tests/yarn.lock b/ts-tests/yarn.lock index 454c7c626f..73d6004e7c 100644 --- a/ts-tests/yarn.lock +++ b/ts-tests/yarn.lock @@ -1662,114 +1662,114 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.21.0" +"@rollup/rollup-android-arm-eabi@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.21.3" conditions: os=android & cpu=arm languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-android-arm64@npm:4.21.0" +"@rollup/rollup-android-arm64@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-android-arm64@npm:4.21.3" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-darwin-arm64@npm:4.21.0" +"@rollup/rollup-darwin-arm64@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-darwin-arm64@npm:4.21.3" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-darwin-x64@npm:4.21.0" +"@rollup/rollup-darwin-x64@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-darwin-x64@npm:4.21.3" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.21.0" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.21.3" conditions: os=linux & cpu=arm & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm-musleabihf@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.21.0" +"@rollup/rollup-linux-arm-musleabihf@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.21.3" conditions: os=linux & cpu=arm & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.21.0" +"@rollup/rollup-linux-arm64-gnu@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.21.3" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.21.0" +"@rollup/rollup-linux-arm64-musl@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.21.3" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-powerpc64le-gnu@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.21.0" +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.21.3" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-riscv64-gnu@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.21.0" +"@rollup/rollup-linux-riscv64-gnu@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.21.3" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-s390x-gnu@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.21.0" +"@rollup/rollup-linux-s390x-gnu@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.21.3" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.21.0" +"@rollup/rollup-linux-x64-gnu@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.21.3" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.21.0" +"@rollup/rollup-linux-x64-musl@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.21.3" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.21.0" +"@rollup/rollup-win32-arm64-msvc@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.21.3" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.21.0" +"@rollup/rollup-win32-ia32-msvc@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.21.3" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.21.0": - version: 4.21.0 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.21.0" +"@rollup/rollup-win32-x64-msvc@npm:4.21.3": + version: 4.21.3 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.21.3" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -5484,10 +5484,10 @@ __metadata: languageName: node linkType: hard -"picocolors@npm:^1.0.1": - version: 1.0.1 - resolution: "picocolors@npm:1.0.1" - checksum: 10c0/c63cdad2bf812ef0d66c8db29583802355d4ca67b9285d846f390cc15c2f6ccb94e8cb7eb6a6e97fc5990a6d3ad4ae42d86c84d3146e667c739a4234ed50d400 +"picocolors@npm:^1.1.0": + version: 1.1.0 + resolution: "picocolors@npm:1.1.0" + checksum: 10c0/86946f6032148801ef09c051c6fb13b5cf942eaf147e30ea79edb91dd32d700934edebe782a1078ff859fb2b816792e97ef4dab03d7f0b804f6b01a0df35e023 languageName: node linkType: hard @@ -5553,14 +5553,14 @@ __metadata: languageName: node linkType: hard -"postcss@npm:^8.4.41": - version: 8.4.41 - resolution: "postcss@npm:8.4.41" +"postcss@npm:^8.4.43": + version: 8.4.47 + resolution: "postcss@npm:8.4.47" dependencies: nanoid: "npm:^3.3.7" - picocolors: "npm:^1.0.1" - source-map-js: "npm:^1.2.0" - checksum: 10c0/c1828fc59e7ec1a3bf52b3a42f615dba53c67960ed82a81df6441b485fe43c20aba7f4e7c55425762fd99c594ecabbaaba8cf5b30fd79dfec5b52a9f63a2d690 + picocolors: "npm:^1.1.0" + source-map-js: "npm:^1.2.1" + checksum: 10c0/929f68b5081b7202709456532cee2a145c1843d391508c5a09de2517e8c4791638f71dd63b1898dba6712f8839d7a6da046c72a5e44c162e908f5911f57b5f44 languageName: node linkType: hard @@ -5889,26 +5889,26 @@ __metadata: languageName: node linkType: hard -"rollup@npm:^4.13.0": - version: 4.21.0 - resolution: "rollup@npm:4.21.0" - dependencies: - "@rollup/rollup-android-arm-eabi": "npm:4.21.0" - "@rollup/rollup-android-arm64": "npm:4.21.0" - "@rollup/rollup-darwin-arm64": "npm:4.21.0" - "@rollup/rollup-darwin-x64": "npm:4.21.0" - "@rollup/rollup-linux-arm-gnueabihf": "npm:4.21.0" - "@rollup/rollup-linux-arm-musleabihf": "npm:4.21.0" - "@rollup/rollup-linux-arm64-gnu": "npm:4.21.0" - "@rollup/rollup-linux-arm64-musl": "npm:4.21.0" - "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.21.0" - "@rollup/rollup-linux-riscv64-gnu": "npm:4.21.0" - "@rollup/rollup-linux-s390x-gnu": "npm:4.21.0" - "@rollup/rollup-linux-x64-gnu": "npm:4.21.0" - "@rollup/rollup-linux-x64-musl": "npm:4.21.0" - "@rollup/rollup-win32-arm64-msvc": "npm:4.21.0" - "@rollup/rollup-win32-ia32-msvc": "npm:4.21.0" - "@rollup/rollup-win32-x64-msvc": "npm:4.21.0" +"rollup@npm:^4.20.0": + version: 4.21.3 + resolution: "rollup@npm:4.21.3" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.21.3" + "@rollup/rollup-android-arm64": "npm:4.21.3" + "@rollup/rollup-darwin-arm64": "npm:4.21.3" + "@rollup/rollup-darwin-x64": "npm:4.21.3" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.21.3" + "@rollup/rollup-linux-arm-musleabihf": "npm:4.21.3" + "@rollup/rollup-linux-arm64-gnu": "npm:4.21.3" + "@rollup/rollup-linux-arm64-musl": "npm:4.21.3" + "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.21.3" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.21.3" + "@rollup/rollup-linux-s390x-gnu": "npm:4.21.3" + "@rollup/rollup-linux-x64-gnu": "npm:4.21.3" + "@rollup/rollup-linux-x64-musl": "npm:4.21.3" + "@rollup/rollup-win32-arm64-msvc": "npm:4.21.3" + "@rollup/rollup-win32-ia32-msvc": "npm:4.21.3" + "@rollup/rollup-win32-x64-msvc": "npm:4.21.3" "@types/estree": "npm:1.0.5" fsevents: "npm:~2.3.2" dependenciesMeta: @@ -5948,7 +5948,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: 10c0/984beb858da245c5e3a9027d6d87e67ad6443f1b46eab07685b861d9e49da5856693265c62a6f8262c36d11c9092713a96a9124f43e6de6698eb84d77118496a + checksum: 10c0/a9f98366a451f1302276390de9c0c59b464d680946410f53c14e7057fa84642efbe05eca8d85076962657955d77bb4a2d2b6dd8b70baf58c3c4b56f565d804dd languageName: node linkType: hard @@ -6260,10 +6260,10 @@ __metadata: languageName: node linkType: hard -"source-map-js@npm:^1.2.0": - version: 1.2.0 - resolution: "source-map-js@npm:1.2.0" - checksum: 10c0/7e5f896ac10a3a50fe2898e5009c58ff0dc102dcb056ed27a354623a0ece8954d4b2649e1a1b2b52ef2e161d26f8859c7710350930751640e71e374fe2d321a4 +"source-map-js@npm:^1.2.1": + version: 1.2.1 + resolution: "source-map-js@npm:1.2.1" + checksum: 10c0/7bda1fc4c197e3c6ff17de1b8b2c20e60af81b63a52cb32ec5a5d67a20a7d42651e2cb34ebe93833c5a2a084377e17455854fee3e21e7925c64a51b6a52b0faf languageName: node linkType: hard @@ -6906,13 +6906,13 @@ __metadata: linkType: hard "vite@npm:^5.0.0": - version: 5.4.1 - resolution: "vite@npm:5.4.1" + version: 5.4.6 + resolution: "vite@npm:5.4.6" dependencies: esbuild: "npm:^0.21.3" fsevents: "npm:~2.3.3" - postcss: "npm:^8.4.41" - rollup: "npm:^4.13.0" + postcss: "npm:^8.4.43" + rollup: "npm:^4.20.0" peerDependencies: "@types/node": ^18.0.0 || >=20.0.0 less: "*" @@ -6944,7 +6944,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10c0/b9ea824f1a946aa494f756e6d9dd88869baa62ae5ba3071b32b6a20958fd622cb624c860bdd7daee201c83ca029feaf8bbe2d2a6e172a5d49308772f8899d86d + checksum: 10c0/5f87be3a10e970eaf9ac52dfab39cf9fff583036685252fb64570b6d7bfa749f6d221fb78058f5ef4b5664c180d45a8e7a7ff68d7f3770e69e24c7c68b958bde languageName: node linkType: hard From f38197f7b13894fda131965c5671064cd82d5d66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:14:58 +1200 Subject: [PATCH 05/14] Bump rollup from 4.21.3 to 4.22.4 in /ts-tests (#2812) Bumps [rollup](https://github.com/rollup/rollup) from 4.21.3 to 4.22.4. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.21.3...v4.22.4) --- updated-dependencies: - dependency-name: rollup dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ts-tests/yarn.lock | 136 ++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/ts-tests/yarn.lock b/ts-tests/yarn.lock index 73d6004e7c..27df30dfec 100644 --- a/ts-tests/yarn.lock +++ b/ts-tests/yarn.lock @@ -1662,114 +1662,114 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.21.3" +"@rollup/rollup-android-arm-eabi@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.22.4" conditions: os=android & cpu=arm languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-android-arm64@npm:4.21.3" +"@rollup/rollup-android-arm64@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-android-arm64@npm:4.22.4" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-darwin-arm64@npm:4.21.3" +"@rollup/rollup-darwin-arm64@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-darwin-arm64@npm:4.22.4" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-darwin-x64@npm:4.21.3" +"@rollup/rollup-darwin-x64@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-darwin-x64@npm:4.22.4" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.21.3" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.22.4" conditions: os=linux & cpu=arm & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm-musleabihf@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.21.3" +"@rollup/rollup-linux-arm-musleabihf@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.22.4" conditions: os=linux & cpu=arm & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.21.3" +"@rollup/rollup-linux-arm64-gnu@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.22.4" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.21.3" +"@rollup/rollup-linux-arm64-musl@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.22.4" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-powerpc64le-gnu@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.21.3" +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.4" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-riscv64-gnu@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.21.3" +"@rollup/rollup-linux-riscv64-gnu@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.22.4" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-s390x-gnu@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.21.3" +"@rollup/rollup-linux-s390x-gnu@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.22.4" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.21.3" +"@rollup/rollup-linux-x64-gnu@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.22.4" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.21.3" +"@rollup/rollup-linux-x64-musl@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.22.4" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.21.3" +"@rollup/rollup-win32-arm64-msvc@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.22.4" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.21.3" +"@rollup/rollup-win32-ia32-msvc@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.22.4" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.21.3": - version: 4.21.3 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.21.3" +"@rollup/rollup-win32-x64-msvc@npm:4.22.4": + version: 4.22.4 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.22.4" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -5890,25 +5890,25 @@ __metadata: linkType: hard "rollup@npm:^4.20.0": - version: 4.21.3 - resolution: "rollup@npm:4.21.3" - dependencies: - "@rollup/rollup-android-arm-eabi": "npm:4.21.3" - "@rollup/rollup-android-arm64": "npm:4.21.3" - "@rollup/rollup-darwin-arm64": "npm:4.21.3" - "@rollup/rollup-darwin-x64": "npm:4.21.3" - "@rollup/rollup-linux-arm-gnueabihf": "npm:4.21.3" - "@rollup/rollup-linux-arm-musleabihf": "npm:4.21.3" - "@rollup/rollup-linux-arm64-gnu": "npm:4.21.3" - "@rollup/rollup-linux-arm64-musl": "npm:4.21.3" - "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.21.3" - "@rollup/rollup-linux-riscv64-gnu": "npm:4.21.3" - "@rollup/rollup-linux-s390x-gnu": "npm:4.21.3" - "@rollup/rollup-linux-x64-gnu": "npm:4.21.3" - "@rollup/rollup-linux-x64-musl": "npm:4.21.3" - "@rollup/rollup-win32-arm64-msvc": "npm:4.21.3" - "@rollup/rollup-win32-ia32-msvc": "npm:4.21.3" - "@rollup/rollup-win32-x64-msvc": "npm:4.21.3" + version: 4.22.4 + resolution: "rollup@npm:4.22.4" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.22.4" + "@rollup/rollup-android-arm64": "npm:4.22.4" + "@rollup/rollup-darwin-arm64": "npm:4.22.4" + "@rollup/rollup-darwin-x64": "npm:4.22.4" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.22.4" + "@rollup/rollup-linux-arm-musleabihf": "npm:4.22.4" + "@rollup/rollup-linux-arm64-gnu": "npm:4.22.4" + "@rollup/rollup-linux-arm64-musl": "npm:4.22.4" + "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.22.4" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.22.4" + "@rollup/rollup-linux-s390x-gnu": "npm:4.22.4" + "@rollup/rollup-linux-x64-gnu": "npm:4.22.4" + "@rollup/rollup-linux-x64-musl": "npm:4.22.4" + "@rollup/rollup-win32-arm64-msvc": "npm:4.22.4" + "@rollup/rollup-win32-ia32-msvc": "npm:4.22.4" + "@rollup/rollup-win32-x64-msvc": "npm:4.22.4" "@types/estree": "npm:1.0.5" fsevents: "npm:~2.3.2" dependenciesMeta: @@ -5948,7 +5948,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: 10c0/a9f98366a451f1302276390de9c0c59b464d680946410f53c14e7057fa84642efbe05eca8d85076962657955d77bb4a2d2b6dd8b70baf58c3c4b56f565d804dd + checksum: 10c0/4c96b6e2e0c5dbe73b4ba899cea894a05115ab8c65ccff631fbbb944e2b3a9f2eb3b99c2dce3dd91b179647df1892ffc44ecee29381ccf155ba8000b22712a32 languageName: node linkType: hard From d89054fa07fa868cc483c70e3831dc491247973d Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Wed, 25 Sep 2024 10:37:07 +0800 Subject: [PATCH 06/14] Update evm patch (#2813) * patch https://github.com/rust-ethereum/evm/pull/264 * patch https://github.com/rust-ethereum/evm/pull/292 --- modules/evm/src/runner/state.rs | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/modules/evm/src/runner/state.rs b/modules/evm/src/runner/state.rs index 65d27e4600..14c821fe19 100644 --- a/modules/evm/src/runner/state.rs +++ b/modules/evm/src/runner/state.rs @@ -473,8 +473,8 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu (reason, maybe_address, return_data) } RuntimeKind::Call(code_address) => { - let return_data = - self.cleanup_for_call(code_address, &reason, runtime.inner.machine().return_value()); + let (reason, return_data) = + self.cleanup_for_call(code_address, reason, runtime.inner.machine().return_value()); (reason, None, return_data) } RuntimeKind::Execute => (reason, None, runtime.inner.machine().return_value()), @@ -1070,9 +1070,9 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu }) { return match result { Ok(PrecompileOutput { exit_status, output }) => { - // let _ = self.exit_substate(StackExitKind::Succeeded); - let e = self.exit_substate(StackExitKind::Succeeded); - try_or_fail!(e); + if let Err(e) = self.exit_substate(StackExitKind::Succeeded) { + return Capture::Exit((e.into(), Vec::new())); + } Capture::Exit((ExitReason::Succeed(exit_status), output)) } Err(PrecompileFailure::Error { exit_status }) => { @@ -1142,14 +1142,16 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu match self.state.metadata_mut().gasometer.record_deposit(out.len()) { Ok(()) => { - let code_len = out.len(); - self.state.set_code(address, out); - let exit_result = self.exit_substate(StackExitKind::Succeeded); if let Err(e) = - self.record_external_operation(crate::ExternalOperation::Write(U256::from(code_len))) + self.record_external_operation(crate::ExternalOperation::Write(U256::from(out.len()))) { + self.state.metadata_mut().gasometer.fail(); + let _ = self.exit_substate(StackExitKind::Failed); return (e.into(), None, Vec::new()); } + // Success requires storage to be collected successfully + self.state.set_code(address, out); + let exit_result = self.exit_substate(StackExitKind::Succeeded); if let Err(e) = exit_result { return (e.into(), None, Vec::new()); } @@ -1178,25 +1180,32 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu } } - fn cleanup_for_call(&mut self, code_address: H160, reason: &ExitReason, return_data: Vec) -> Vec { + fn cleanup_for_call( + &mut self, + code_address: H160, + reason: ExitReason, + return_data: Vec, + ) -> (ExitReason, Vec) { log::debug!(target: "evm", "Call execution using address {}: {:?}", code_address, reason); match reason { ExitReason::Succeed(_) => { - let _ = self.exit_substate(StackExitKind::Succeeded); - return_data + if let Err(e) = self.exit_substate(StackExitKind::Succeeded) { + return (e.into(), Vec::new()); + } + (reason, return_data) } ExitReason::Error(_) => { let _ = self.exit_substate(StackExitKind::Failed); - Vec::new() + (reason, Vec::new()) } ExitReason::Revert(_) => { let _ = self.exit_substate(StackExitKind::Reverted); - return_data + (reason, return_data) } ExitReason::Fatal(_) => { self.state.metadata_mut().gasometer.fail(); let _ = self.exit_substate(StackExitKind::Failed); - Vec::new() + (reason, Vec::new()) } } } From 65f2e01f22a961fe3a3eb907f4d425723c37cf8a Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Tue, 8 Oct 2024 13:16:11 +0800 Subject: [PATCH 07/14] Update to RUST-1.81.0 (#2814) * Update to RUST-1.81.0 * update orml * update TARPAULIN_VERSION * update --- .github/workflows/coverage.yml | 2 +- modules/aggregated-dex/src/lib.rs | 6 ++---- modules/dex/src/lib.rs | 4 +--- modules/evm/src/runner/stack.rs | 9 +++------ modules/evm/src/runner/state.rs | 2 +- modules/homa/src/lib.rs | 3 +-- modules/incentives/src/lib.rs | 4 ++-- modules/loans/src/mock.rs | 5 ++++- modules/loans/src/tests.rs | 3 --- orml | 2 +- runtime/acala/src/lib.rs | 12 ++++++------ runtime/common/src/xcm_impl.rs | 4 ++-- runtime/karura/src/lib.rs | 12 ++++++------ runtime/mandala/src/lib.rs | 11 +++++------ rust-toolchain.toml | 2 +- 15 files changed, 36 insertions(+), 45 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 893387c3d5..b47be97355 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -18,7 +18,7 @@ concurrency: cancel-in-progress: true env: - TARPAULIN_VERSION: 0.27.3 + TARPAULIN_VERSION: 0.31.2 CARGO_INCREMENTAL: 0 jobs: test: diff --git a/modules/aggregated-dex/src/lib.rs b/modules/aggregated-dex/src/lib.rs index 482a1a3a7d..f107d97d17 100644 --- a/modules/aggregated-dex/src/lib.rs +++ b/modules/aggregated-dex/src/lib.rs @@ -282,10 +282,8 @@ impl Pallet { match path { SwapPath::Dex(dex_path) => { // calculate the supply amount - let (supply_amount, _) = T::DEX::get_swap_amount( - dex_path, - SwapLimit::ExactTarget(Balance::max_value(), input_amount), - )?; + let (supply_amount, _) = + T::DEX::get_swap_amount(dex_path, SwapLimit::ExactTarget(Balance::MAX, input_amount))?; input_amount = supply_amount; } diff --git a/modules/dex/src/lib.rs b/modules/dex/src/lib.rs index 90888a1406..728dd33aac 100644 --- a/modules/dex/src/lib.rs +++ b/modules/dex/src/lib.rs @@ -818,12 +818,10 @@ impl Pallet { LiquidityPool::::try_mutate(trading_pair, |(pool_0, pool_1)| -> sp_std::result::Result { let old_pool_0 = *pool_0; let old_pool_1 = *pool_1; - f((pool_0, pool_1)).map(move |result| { + f((pool_0, pool_1)).inspect(move |_result| { if *pool_0 != old_pool_0 || *pool_1 != old_pool_1 { T::OnLiquidityPoolUpdated::happened(&(*trading_pair, *pool_0, *pool_1)); } - - result }) }) } diff --git a/modules/evm/src/runner/stack.rs b/modules/evm/src/runner/stack.rs index a31cc7ed37..e773f1eeaf 100644 --- a/modules/evm/src/runner/stack.rs +++ b/modules/evm/src/runner/stack.rs @@ -469,9 +469,8 @@ impl<'config> SubstrateStackSubstate<'config> { let target = self.metadata().target().expect("Storage target is none"); let storage = exited.metadata().storage_meter().used_storage(); - self.metadata.swallow_commit(exited.metadata).map_err(|e| { + self.metadata.swallow_commit(exited.metadata).inspect_err(|_e| { sp_io::storage::rollback_transaction(); - e })?; self.logs.append(&mut exited.logs); self.deletes.append(&mut exited.deletes); @@ -486,9 +485,8 @@ impl<'config> SubstrateStackSubstate<'config> { pub fn exit_revert(&mut self) -> Result<(), ExitError> { let mut exited = *self.parent.take().expect("Cannot discard on root substate"); mem::swap(&mut exited, self); - self.metadata.swallow_revert(exited.metadata).map_err(|e| { + self.metadata.swallow_revert(exited.metadata).inspect_err(|_e| { sp_io::storage::rollback_transaction(); - e })?; sp_io::storage::rollback_transaction(); @@ -498,9 +496,8 @@ impl<'config> SubstrateStackSubstate<'config> { pub fn exit_discard(&mut self) -> Result<(), ExitError> { let mut exited = *self.parent.take().expect("Cannot discard on root substate"); mem::swap(&mut exited, self); - self.metadata.swallow_discard(exited.metadata).map_err(|e| { + self.metadata.swallow_discard(exited.metadata).inspect_err(|_e| { sp_io::storage::rollback_transaction(); - e })?; sp_io::storage::rollback_transaction(); diff --git a/modules/evm/src/runner/state.rs b/modules/evm/src/runner/state.rs index 14c821fe19..45fdd8437a 100644 --- a/modules/evm/src/runner/state.rs +++ b/modules/evm/src/runner/state.rs @@ -811,7 +811,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu let mut stream = rlp::RlpStream::new_list(2); stream.append(&caller); stream.append(&nonce); - H256::from_slice(Keccak256::digest(&stream.out()).as_slice()).into() + H256::from_slice(Keccak256::digest(stream.out()).as_slice()).into() } CreateScheme::Fixed(naddress) => naddress, }; diff --git a/modules/homa/src/lib.rs b/modules/homa/src/lib.rs index 42694fc29b..4f150b1878 100644 --- a/modules/homa/src/lib.rs +++ b/modules/homa/src/lib.rs @@ -714,7 +714,7 @@ pub mod module { let mut ledger = maybe_ledger.take().unwrap_or_default(); let old_bonded_amount = ledger.bonded; - f(&mut ledger).map(move |result| { + f(&mut ledger).inspect(move |_result| { *maybe_ledger = if ledger == Default::default() { TotalStakingBonded::::mutate(|staking_balance| { *staking_balance = staking_balance.saturating_sub(old_bonded_amount) @@ -728,7 +728,6 @@ pub mod module { }); Some(ledger) }; - result }) }) } diff --git a/modules/incentives/src/lib.rs b/modules/incentives/src/lib.rs index b7a90da498..7114b2d5aa 100644 --- a/modules/incentives/src/lib.rs +++ b/modules/incentives/src/lib.rs @@ -32,8 +32,8 @@ //! //! Rewards accumulation: //! 1. Incentives: periodicly(AccumulatePeriod), accumulate fixed amount according to Incentive. -//! Rewards come from RewardsSource, please transfer enough tokens to RewardsSource before -//! start incentive plan. +//! Rewards come from RewardsSource, please transfer enough tokens to RewardsSource before start +//! incentive plan. #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] diff --git a/modules/loans/src/mock.rs b/modules/loans/src/mock.rs index a6dd7a8e3f..1f47b50294 100644 --- a/modules/loans/src/mock.rs +++ b/modules/loans/src/mock.rs @@ -277,6 +277,9 @@ impl ExtBuilder { } .assimilate_storage(&mut t) .unwrap(); - t.into() + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext } } diff --git a/modules/loans/src/tests.rs b/modules/loans/src/tests.rs index 7599dcbf3d..ec0baa72e0 100644 --- a/modules/loans/src/tests.rs +++ b/modules/loans/src/tests.rs @@ -57,7 +57,6 @@ fn check_update_loan_underflow_work() { #[test] fn adjust_position_should_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_eq!(Currencies::free_balance(BTC, &ALICE), 1000); // balance too low @@ -166,7 +165,6 @@ fn update_loan_should_work() { #[test] fn transfer_loan_should_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_ok!(LoansModule::update_loan(&ALICE, BTC, 400, 500)); assert_ok!(LoansModule::update_loan(&BOB, BTC, 100, 600)); assert_eq!(LoansModule::positions(BTC, &ALICE).debit, 500); @@ -190,7 +188,6 @@ fn transfer_loan_should_work() { #[test] fn confiscate_collateral_and_debit_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_ok!(LoansModule::update_loan(&BOB, BTC, 5000, 1000)); assert_eq!(Currencies::free_balance(BTC, &LoansModule::account_id()), 0); diff --git a/orml b/orml index 144a9625bc..7d608999cb 160000 --- a/orml +++ b/orml @@ -1 +1 @@ -Subproject commit 144a9625bc0cbd1afb81088f4d8a79a931811b49 +Subproject commit 7d608999cbcf79dbb1eb40de4b04a7366e2a8352 diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 822db4ef5a..11b2ae9f39 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -766,7 +766,7 @@ impl orml_oracle::Config for Runtime { type RootOperatorAccountId = RootOperatorAccountId; type Members = OperatorMembershipAcala; type MaxHasDispatchedSize = ConstU32<20>; - type WeightInfo = (); + type WeightInfo = weights::orml_oracle::WeightInfo; type MaxFeedValues = MaxFeedValues; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = BenchmarkHelper; @@ -805,7 +805,7 @@ parameter_type_with_key! { TokenSymbol::ACA | TokenSymbol::KBTC | TokenSymbol::KINT | - TokenSymbol::TAI => Balance::max_value() // unsupported + TokenSymbol::TAI => Balance::MAX // unsupported }, CurrencyId::DexShare(dex_share_0, _) => { let currency_id_0: CurrencyId = (*dex_share_0).into(); @@ -817,20 +817,20 @@ parameter_type_with_key! { } else if let CurrencyId::Erc20(address) = currency_id_0 { // LP token with erc20 AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(address)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) } else { Self::get(¤cy_id_0) } }, - CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance), + CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance), CurrencyId::StableAssetPoolToken(stable_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::DOT)), // the same as DOT CurrencyId::ForeignAsset(foreign_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, } }; diff --git a/runtime/common/src/xcm_impl.rs b/runtime/common/src/xcm_impl.rs index cfde56f8bf..502e261356 100644 --- a/runtime/common/src/xcm_impl.rs +++ b/runtime/common/src/xcm_impl.rs @@ -117,8 +117,8 @@ where /// Simple fee calculator that requires payment in a single fungible at a fixed rate. /// -/// - The `FixedRate` constant should be the concrete fungible ID and the amount of it -/// required for one second of weight. +/// - The `FixedRate` constant should be the concrete fungible ID and the amount of it required for +/// one second of weight. /// - The `TakeRevenue` trait is used to collecting xcm execution fee. /// - The `BuyWeightRate` trait is used to calculate ratio by location. pub struct FixedRateOfAsset, R: TakeRevenue, M: BuyWeightRate> { diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index af2b110964..88304685c8 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -775,7 +775,7 @@ impl orml_oracle::Config for Runtime { type RootOperatorAccountId = RootOperatorAccountId; type Members = OperatorMembershipAcala; type MaxHasDispatchedSize = ConstU32<20>; - type WeightInfo = (); + type WeightInfo = weights::orml_oracle::WeightInfo; type MaxFeedValues = MaxFeedValues; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = BenchmarkHelper; @@ -814,7 +814,7 @@ parameter_type_with_key! { TokenSymbol::DOT | TokenSymbol::LDOT | TokenSymbol::KAR | - TokenSymbol::TAP => Balance::max_value() // unsupported + TokenSymbol::TAP => Balance::MAX // unsupported }, CurrencyId::DexShare(dex_share_0, _) => { let currency_id_0: CurrencyId = (*dex_share_0).into(); @@ -826,20 +826,20 @@ parameter_type_with_key! { } else if let CurrencyId::Erc20(address) = currency_id_0 { // LP token with erc20 AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(address)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) } else { Self::get(¤cy_id_0) } }, - CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance), + CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance), CurrencyId::StableAssetPoolToken(stable_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::KSM)), // the same as KSM CurrencyId::ForeignAsset(foreign_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, } }; diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 95fc2e9213..f8ae36b0cc 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -861,7 +861,7 @@ parameter_type_with_key! { TokenSymbol::TAI => 10 * millicent(*currency_id), TokenSymbol::TAP => 10 * millicent(*currency_id), TokenSymbol::ACA | - TokenSymbol::KAR => Balance::max_value() // unsupported + TokenSymbol::KAR => Balance::MAX // unsupported }, CurrencyId::DexShare(dex_share_0, _) => { let currency_id_0: CurrencyId = (*dex_share_0).into(); @@ -873,20 +873,20 @@ parameter_type_with_key! { } else if let CurrencyId::Erc20(address) = currency_id_0 { // LP token with erc20 AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(address)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) } else { Self::get(¤cy_id_0) } }, - CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance), + CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance), CurrencyId::StableAssetPoolToken(stable_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::DOT)), // the same as DOT CurrencyId::ForeignAsset(foreign_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, } }; @@ -2682,7 +2682,6 @@ impl_runtime_apis! { } } -#[cfg(not(feature = "standalone"))] cumulus_pallet_parachain_system::register_validate_block!( Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b365e13a84..6d985f163a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.77.0" +channel = "1.81.0" components = ["rust-src", "rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] From fa648e18faa2d4df32386f436cd8074212c07e49 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Mon, 14 Oct 2024 12:41:30 +1300 Subject: [PATCH 08/14] 2.27.0 (#2815) --- Cargo.lock | 84 +++++++++++------------ modules/aggregated-dex/Cargo.toml | 2 +- modules/asset-registry/Cargo.toml | 2 +- modules/auction-manager/Cargo.toml | 2 +- modules/cdp-engine/Cargo.toml | 2 +- modules/cdp-treasury/Cargo.toml | 2 +- modules/collator-selection/Cargo.toml | 2 +- modules/currencies/Cargo.toml | 2 +- modules/currencies/runtime-api/Cargo.toml | 2 +- modules/dex-oracle/Cargo.toml | 2 +- modules/dex/Cargo.toml | 2 +- modules/earning/Cargo.toml | 2 +- modules/emergency-shutdown/Cargo.toml | 2 +- modules/evm-accounts/Cargo.toml | 2 +- modules/evm-bridge/Cargo.toml | 2 +- modules/evm-utility/Cargo.toml | 2 +- modules/evm-utility/macro/Cargo.toml | 2 +- modules/evm/Cargo.toml | 2 +- modules/evm/rpc/runtime-api/Cargo.toml | 2 +- modules/homa-validator-list/Cargo.toml | 2 +- modules/homa/Cargo.toml | 2 +- modules/honzon-bridge/Cargo.toml | 2 +- modules/honzon/Cargo.toml | 2 +- modules/idle-scheduler/Cargo.toml | 2 +- modules/incentives/Cargo.toml | 2 +- modules/liquid-crowdloan/Cargo.toml | 2 +- modules/loans/Cargo.toml | 2 +- modules/nft/Cargo.toml | 2 +- modules/nominees-election/Cargo.toml | 2 +- modules/prices/Cargo.toml | 2 +- modules/relaychain/Cargo.toml | 2 +- modules/session-manager/Cargo.toml | 2 +- modules/support/Cargo.toml | 2 +- modules/transaction-pause/Cargo.toml | 2 +- modules/transaction-payment/Cargo.toml | 2 +- modules/xcm-interface/Cargo.toml | 2 +- modules/xnft/Cargo.toml | 2 +- primitives/Cargo.toml | 2 +- runtime/acala/Cargo.toml | 2 +- runtime/acala/src/lib.rs | 2 +- runtime/common/Cargo.toml | 2 +- runtime/integration-tests/Cargo.toml | 2 +- runtime/karura/Cargo.toml | 2 +- runtime/karura/src/lib.rs | 2 +- runtime/mandala/Cargo.toml | 2 +- runtime/mandala/src/lib.rs | 2 +- 46 files changed, 87 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10512f1ab2..3300b7ea66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ [[package]] name = "acala-primitives" -version = "2.26.0" +version = "2.27.0" dependencies = [ "bstringify", "enumflags2", @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "acala-runtime" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-pallet-aura-ext", @@ -2837,7 +2837,7 @@ dependencies = [ [[package]] name = "karura-runtime" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-pallet-aura-ext", @@ -3250,7 +3250,7 @@ dependencies = [ [[package]] name = "mandala-runtime" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-pallet-aura-ext", @@ -3502,7 +3502,7 @@ dependencies = [ [[package]] name = "module-aggregated-dex" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3523,7 +3523,7 @@ dependencies = [ [[package]] name = "module-asset-registry" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3547,7 +3547,7 @@ dependencies = [ [[package]] name = "module-auction-manager" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3571,7 +3571,7 @@ dependencies = [ [[package]] name = "module-cdp-engine" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3603,7 +3603,7 @@ dependencies = [ [[package]] name = "module-cdp-treasury" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3627,7 +3627,7 @@ dependencies = [ [[package]] name = "module-collator-selection" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-benchmarking", @@ -3652,7 +3652,7 @@ dependencies = [ [[package]] name = "module-currencies" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "module-currencies-runtime-api" -version = "2.26.0" +version = "2.27.0" dependencies = [ "sp-api", "sp-core", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "module-dex" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3707,7 +3707,7 @@ dependencies = [ [[package]] name = "module-dex-oracle" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-benchmarking", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "module-earning" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3744,7 +3744,7 @@ dependencies = [ [[package]] name = "module-emergency-shutdown" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "module-evm" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "env_logger", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "module-evm-accounts" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3831,7 +3831,7 @@ dependencies = [ [[package]] name = "module-evm-bridge" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "ethereum-types", @@ -3857,7 +3857,7 @@ dependencies = [ [[package]] name = "module-evm-rpc-runtime-api" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "sp-api", @@ -3868,7 +3868,7 @@ dependencies = [ [[package]] name = "module-evm-utility" -version = "2.26.0" +version = "2.27.0" dependencies = [ "ethereum", "evm", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "module-evm-utility-macro" -version = "2.26.0" +version = "2.27.0" dependencies = [ "module-evm-utility", "proc-macro2", @@ -3890,7 +3890,7 @@ dependencies = [ [[package]] name = "module-homa" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-benchmarking", @@ -3914,7 +3914,7 @@ dependencies = [ [[package]] name = "module-homa-validator-list" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3935,7 +3935,7 @@ dependencies = [ [[package]] name = "module-honzon" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "module-honzon-bridge" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -3988,7 +3988,7 @@ dependencies = [ [[package]] name = "module-idle-scheduler" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4005,7 +4005,7 @@ dependencies = [ [[package]] name = "module-incentives" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "module-liquid-crowdloan" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4046,7 +4046,7 @@ dependencies = [ [[package]] name = "module-loans" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4068,7 +4068,7 @@ dependencies = [ [[package]] name = "module-nft" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-benchmarking", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "module-nominees-election" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4114,7 +4114,7 @@ dependencies = [ [[package]] name = "module-prices" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4132,7 +4132,7 @@ dependencies = [ [[package]] name = "module-relaychain" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-primitives-core", @@ -4149,7 +4149,7 @@ dependencies = [ [[package]] name = "module-session-manager" -version = "2.26.0" +version = "2.27.0" dependencies = [ "frame-support", "frame-system", @@ -4165,7 +4165,7 @@ dependencies = [ [[package]] name = "module-support" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4186,7 +4186,7 @@ dependencies = [ [[package]] name = "module-transaction-pause" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4208,7 +4208,7 @@ dependencies = [ [[package]] name = "module-transaction-payment" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "frame-support", @@ -4235,7 +4235,7 @@ dependencies = [ [[package]] name = "module-xcm-interface" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-primitives-core", @@ -4264,7 +4264,7 @@ dependencies = [ [[package]] name = "module-xnft" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-primitives-core", @@ -6446,7 +6446,7 @@ dependencies = [ [[package]] name = "runtime-common" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "cumulus-pallet-aura-ext", @@ -6517,7 +6517,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "2.26.0" +version = "2.27.0" dependencies = [ "acala-primitives", "acala-runtime", diff --git a/modules/aggregated-dex/Cargo.toml b/modules/aggregated-dex/Cargo.toml index d65b047b02..5a44cf5595 100644 --- a/modules/aggregated-dex/Cargo.toml +++ b/modules/aggregated-dex/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-aggregated-dex" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/asset-registry/Cargo.toml b/modules/asset-registry/Cargo.toml index 19bdf0f492..fe011b5e4c 100644 --- a/modules/asset-registry/Cargo.toml +++ b/modules/asset-registry/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-asset-registry" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/auction-manager/Cargo.toml b/modules/auction-manager/Cargo.toml index c24909cbee..a0f990ed84 100644 --- a/modules/auction-manager/Cargo.toml +++ b/modules/auction-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-auction-manager" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/cdp-engine/Cargo.toml b/modules/cdp-engine/Cargo.toml index e1c6ec4d02..0abedc52d0 100644 --- a/modules/cdp-engine/Cargo.toml +++ b/modules/cdp-engine/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-cdp-engine" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/cdp-treasury/Cargo.toml b/modules/cdp-treasury/Cargo.toml index d3c2b146f8..18d16a0ffe 100644 --- a/modules/cdp-treasury/Cargo.toml +++ b/modules/cdp-treasury/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-cdp-treasury" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/collator-selection/Cargo.toml b/modules/collator-selection/Cargo.toml index 68776bd5f0..75ead3a6b7 100644 --- a/modules/collator-selection/Cargo.toml +++ b/modules/collator-selection/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'module-collator-selection' -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/currencies/Cargo.toml b/modules/currencies/Cargo.toml index 9bb9f797b9..c2da1e99d7 100644 --- a/modules/currencies/Cargo.toml +++ b/modules/currencies/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-currencies" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/currencies/runtime-api/Cargo.toml b/modules/currencies/runtime-api/Cargo.toml index 080d907a5e..4161587184 100644 --- a/modules/currencies/runtime-api/Cargo.toml +++ b/modules/currencies/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-currencies-runtime-api" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/dex-oracle/Cargo.toml b/modules/dex-oracle/Cargo.toml index 65d1578925..a7c9f6fa20 100644 --- a/modules/dex-oracle/Cargo.toml +++ b/modules/dex-oracle/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-dex-oracle" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/dex/Cargo.toml b/modules/dex/Cargo.toml index 00b93e0e84..89739ab6ac 100644 --- a/modules/dex/Cargo.toml +++ b/modules/dex/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-dex" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/earning/Cargo.toml b/modules/earning/Cargo.toml index 942f7e8d69..5123b8f254 100644 --- a/modules/earning/Cargo.toml +++ b/modules/earning/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-earning" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/emergency-shutdown/Cargo.toml b/modules/emergency-shutdown/Cargo.toml index 2c1b4b8eea..9990ca56ef 100644 --- a/modules/emergency-shutdown/Cargo.toml +++ b/modules/emergency-shutdown/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-emergency-shutdown" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/evm-accounts/Cargo.toml b/modules/evm-accounts/Cargo.toml index b21beffbbb..bbcecae706 100644 --- a/modules/evm-accounts/Cargo.toml +++ b/modules/evm-accounts/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-evm-accounts" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/evm-bridge/Cargo.toml b/modules/evm-bridge/Cargo.toml index 2ab5284208..76a224b7a4 100644 --- a/modules/evm-bridge/Cargo.toml +++ b/modules/evm-bridge/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-evm-bridge" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/evm-utility/Cargo.toml b/modules/evm-utility/Cargo.toml index a29ad9626b..3e6fb2b5fc 100644 --- a/modules/evm-utility/Cargo.toml +++ b/modules/evm-utility/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-evm-utility" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/evm-utility/macro/Cargo.toml b/modules/evm-utility/macro/Cargo.toml index dcbecb0806..853924320b 100644 --- a/modules/evm-utility/macro/Cargo.toml +++ b/modules/evm-utility/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-evm-utility-macro" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/evm/Cargo.toml b/modules/evm/Cargo.toml index 5d7519bf74..c44084d92c 100644 --- a/modules/evm/Cargo.toml +++ b/modules/evm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-evm" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/evm/rpc/runtime-api/Cargo.toml b/modules/evm/rpc/runtime-api/Cargo.toml index b0371d8ab2..2e30127480 100644 --- a/modules/evm/rpc/runtime-api/Cargo.toml +++ b/modules/evm/rpc/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-evm-rpc-runtime-api" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/homa-validator-list/Cargo.toml b/modules/homa-validator-list/Cargo.toml index 632adfae58..4e1f90fdc5 100644 --- a/modules/homa-validator-list/Cargo.toml +++ b/modules/homa-validator-list/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-homa-validator-list" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/homa/Cargo.toml b/modules/homa/Cargo.toml index 73197d9958..526862b847 100644 --- a/modules/homa/Cargo.toml +++ b/modules/homa/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-homa" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/honzon-bridge/Cargo.toml b/modules/honzon-bridge/Cargo.toml index 482977c352..b702aa334d 100644 --- a/modules/honzon-bridge/Cargo.toml +++ b/modules/honzon-bridge/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-honzon-bridge" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/honzon/Cargo.toml b/modules/honzon/Cargo.toml index 0a92f49b7a..24421f878a 100644 --- a/modules/honzon/Cargo.toml +++ b/modules/honzon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-honzon" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/idle-scheduler/Cargo.toml b/modules/idle-scheduler/Cargo.toml index bc577feab7..f584bcab1e 100644 --- a/modules/idle-scheduler/Cargo.toml +++ b/modules/idle-scheduler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-idle-scheduler" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/incentives/Cargo.toml b/modules/incentives/Cargo.toml index 57e526a42a..a6ad819289 100644 --- a/modules/incentives/Cargo.toml +++ b/modules/incentives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-incentives" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/liquid-crowdloan/Cargo.toml b/modules/liquid-crowdloan/Cargo.toml index ac81b81e28..fcf5d50848 100644 --- a/modules/liquid-crowdloan/Cargo.toml +++ b/modules/liquid-crowdloan/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-liquid-crowdloan" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/loans/Cargo.toml b/modules/loans/Cargo.toml index 1ae77629dc..32190e0121 100644 --- a/modules/loans/Cargo.toml +++ b/modules/loans/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-loans" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/nft/Cargo.toml b/modules/nft/Cargo.toml index 0673f2f1f1..77430acb10 100644 --- a/modules/nft/Cargo.toml +++ b/modules/nft/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-nft" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/nominees-election/Cargo.toml b/modules/nominees-election/Cargo.toml index b8ae199e16..78433e466e 100644 --- a/modules/nominees-election/Cargo.toml +++ b/modules/nominees-election/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-nominees-election" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/prices/Cargo.toml b/modules/prices/Cargo.toml index be1b531072..a2dd41af92 100644 --- a/modules/prices/Cargo.toml +++ b/modules/prices/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-prices" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/relaychain/Cargo.toml b/modules/relaychain/Cargo.toml index 18822c1108..276de9ce50 100644 --- a/modules/relaychain/Cargo.toml +++ b/modules/relaychain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-relaychain" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/session-manager/Cargo.toml b/modules/session-manager/Cargo.toml index 5995d28211..de5d2e8c27 100644 --- a/modules/session-manager/Cargo.toml +++ b/modules/session-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-session-manager" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/support/Cargo.toml b/modules/support/Cargo.toml index b67b87ca50..133a83a648 100644 --- a/modules/support/Cargo.toml +++ b/modules/support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-support" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/transaction-pause/Cargo.toml b/modules/transaction-pause/Cargo.toml index c7f2f5a7a5..215536ef80 100644 --- a/modules/transaction-pause/Cargo.toml +++ b/modules/transaction-pause/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-transaction-pause" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/transaction-payment/Cargo.toml b/modules/transaction-payment/Cargo.toml index 407287aad4..0ade49dd2a 100644 --- a/modules/transaction-payment/Cargo.toml +++ b/modules/transaction-payment/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-transaction-payment" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/xcm-interface/Cargo.toml b/modules/xcm-interface/Cargo.toml index daad101452..3f7937f3a1 100644 --- a/modules/xcm-interface/Cargo.toml +++ b/modules/xcm-interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module-xcm-interface" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/modules/xnft/Cargo.toml b/modules/xnft/Cargo.toml index 64e16427b1..166f67507b 100644 --- a/modules/xnft/Cargo.toml +++ b/modules/xnft/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "module-xnft" description = "XCM NFT PoC" -version = "2.26.0" +version = "2.27.0" authors = ["Unique Network Developers"] edition = "2021" diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 7bf945a15e..2af726bba4 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "acala-primitives" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/runtime/acala/Cargo.toml b/runtime/acala/Cargo.toml index 6e33d40b4a..f8f2236dbd 100644 --- a/runtime/acala/Cargo.toml +++ b/runtime/acala/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "acala-runtime" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" build = "build.rs" diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 11b2ae9f39..b1cc163206 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -128,7 +128,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("acala"), impl_name: create_runtime_str!("acala"), authoring_version: 1, - spec_version: 2260, + spec_version: 2270, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 3, diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index e7e41167e8..6c5cd708e7 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-common" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml index 15e387bafe..d60c20504a 100644 --- a/runtime/integration-tests/Cargo.toml +++ b/runtime/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" diff --git a/runtime/karura/Cargo.toml b/runtime/karura/Cargo.toml index 512a9c0fea..a53e8b1d35 100644 --- a/runtime/karura/Cargo.toml +++ b/runtime/karura/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "karura-runtime" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" build = "build.rs" diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 88304685c8..b98bdf3ec1 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -132,7 +132,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("karura"), impl_name: create_runtime_str!("karura"), authoring_version: 1, - spec_version: 2260, + spec_version: 2270, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/runtime/mandala/Cargo.toml b/runtime/mandala/Cargo.toml index 0a02c3d6ad..947246dd95 100644 --- a/runtime/mandala/Cargo.toml +++ b/runtime/mandala/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mandala-runtime" -version = "2.26.0" +version = "2.27.0" authors = ["Acala Developers"] edition = "2021" build = "build.rs" diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index f8ae36b0cc..9d2b6b327f 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -132,7 +132,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mandala"), impl_name: create_runtime_str!("mandala"), authoring_version: 1, - spec_version: 2260, + spec_version: 2270, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 3, From d9652d6aa8859ceee7a2df643b0cc73a1fd47dc6 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Mon, 14 Oct 2024 14:57:58 +1300 Subject: [PATCH 09/14] ensure on_initialize_with_bump_era under block weight limit (#2816) * add test for on_initialize_with_bump_era to ensure the weight within block weight limit * reduce ProcessRedeemRequestsLimit --- Cargo.toml | 2 -- runtime/acala/src/lib.rs | 12 +++++++++++- runtime/karura/src/lib.rs | 12 +++++++++++- runtime/mandala/src/lib.rs | 12 +++++++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index be9b924392..04bec0853c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ -cargo-features = ["resolver"] - [workspace] members = [ "modules/*", diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index b1cc163206..dd9aaf10fa 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -1594,7 +1594,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; - type ProcessRedeemRequestsLimit = ConstU32<2_000>; + type ProcessRedeemRequestsLimit = ConstU32<1_000>; } parameter_types! { @@ -2719,4 +2719,14 @@ mod tests { If the limit is too strong, maybe consider increasing the limit", ); } + + #[test] + fn check_on_initialize_with_bump_era_weight() { + use module_homa::WeightInfo; + let weight = weights::module_homa::WeightInfo::::on_initialize_with_bump_era( + ::ProcessRedeemRequestsLimit::get(), + ); + let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2); + assert!(weight.all_lt(block_weight)); + } } diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index b98bdf3ec1..427001785f 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1619,7 +1619,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; - type ProcessRedeemRequestsLimit = ConstU32<2_000>; + type ProcessRedeemRequestsLimit = ConstU32<1_000>; } parameter_types! { @@ -2752,4 +2752,14 @@ mod tests { If the limit is too strong, maybe consider increasing the limit", ); } + + #[test] + fn check_on_initialize_with_bump_era_weight() { + use module_homa::WeightInfo; + let weight = weights::module_homa::WeightInfo::::on_initialize_with_bump_era( + ::ProcessRedeemRequestsLimit::get(), + ); + let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2); + assert!(weight.all_lt(block_weight)); + } } diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 9d2b6b327f..10595e4ded 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -1447,7 +1447,7 @@ impl module_homa::Config for Runtime { type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; type NominationsProvider = NomineesElection; - type ProcessRedeemRequestsLimit = ConstU32<2_000>; + type ProcessRedeemRequestsLimit = ConstU32<1_000>; } parameter_types! { @@ -2865,4 +2865,14 @@ mod tests { ); }); } + + #[test] + fn check_on_initialize_with_bump_era_weight() { + use module_homa::WeightInfo; + let weight = weights::module_homa::WeightInfo::::on_initialize_with_bump_era( + ::ProcessRedeemRequestsLimit::get(), + ); + let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2); + assert!(weight.all_lt(block_weight)); + } } From 8c19bd730f5bc8d908548bfb936d638af31882b3 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Mon, 14 Oct 2024 15:00:30 +1300 Subject: [PATCH 10/14] update upload-artifact version --- .github/workflows/extrinsic-ordering-check-from-bin.yml | 2 +- .github/workflows/extrinsic-ordering-check-on-release.yml | 2 +- .github/workflows/publish-release.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/extrinsic-ordering-check-from-bin.yml b/.github/workflows/extrinsic-ordering-check-from-bin.yml index 71ce8d5457..a33dda17e0 100644 --- a/.github/workflows/extrinsic-ordering-check-from-bin.yml +++ b/.github/workflows/extrinsic-ordering-check-from-bin.yml @@ -66,7 +66,7 @@ jobs: run: cat output.txt - name: Save output as artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ env.CHAIN }} path: | diff --git a/.github/workflows/extrinsic-ordering-check-on-release.yml b/.github/workflows/extrinsic-ordering-check-on-release.yml index 836df9e7c5..6c614dc9b9 100644 --- a/.github/workflows/extrinsic-ordering-check-on-release.yml +++ b/.github/workflows/extrinsic-ordering-check-on-release.yml @@ -72,7 +72,7 @@ jobs: run: cat output.txt - name: Save output as artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ env.CHAIN }} path: | diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index b4f1addfaf..c898690882 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -114,7 +114,7 @@ jobs: filename: ${{ steps.generate-note.outputs.release-note }} - name: Archive Artifacts for ${{ env.CHAIN }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ env.CHAIN }}-runtime path: | @@ -128,7 +128,7 @@ jobs: ${{ env.CHAIN }}-diff.txt - name: Upload wasm to pinata - uses: aquiladev/ipfs-action@v0.1.6 + uses: aquiladev/ipfs-action@v0.3.1 with: path: ${{ steps.srtool_build.outputs.wasm_compressed }} service: pinata From f79aa2bede9d7116ee8c40a6bd8898d62b40c807 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 17 Oct 2024 12:26:26 +0800 Subject: [PATCH 11/14] Update oracle.rs (#2820) In the ERC20 interface, the maximum number of decimals is 18, but it is better to use `saturating_sub` --- runtime/common/src/precompile/oracle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/precompile/oracle.rs b/runtime/common/src/precompile/oracle.rs index 4086f8bacb..03ec9e03ca 100644 --- a/runtime/common/src/precompile/oracle.rs +++ b/runtime/common/src/precompile/oracle.rs @@ -76,7 +76,7 @@ where } }; - let maybe_adjustment_multiplier = 10u128.checked_pow((18 - decimals).into()); + let maybe_adjustment_multiplier = 10u128.checked_pow((18u8.saturating_sub(decimals)).into()); let adjustment_multiplier = match maybe_adjustment_multiplier { Some(adjustment_multiplier) => adjustment_multiplier, None => { From 2767388834ba75a1d3730ccf698bf14cf047ba82 Mon Sep 17 00:00:00 2001 From: wangjj9219 <183318287@qq.com> Date: Wed, 23 Oct 2024 14:29:55 +0800 Subject: [PATCH 12/14] increase MaxProposalWeight (#2823) --- runtime/acala/src/lib.rs | 2 +- runtime/karura/src/lib.rs | 2 +- runtime/mandala/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index dd9aaf10fa..0dc11d8560 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -412,7 +412,7 @@ parameter_types! { pub const GeneralCouncilMotionDuration: BlockNumber = 3 * DAYS; pub const CouncilDefaultMaxProposals: u32 = 20; pub const CouncilDefaultMaxMembers: u32 = 30; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; + pub MaxProposalWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block; } impl pallet_collective::Config for Runtime { diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 427001785f..a62159dcbd 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -420,7 +420,7 @@ parameter_types! { pub const GeneralCouncilMotionDuration: BlockNumber = 3 * DAYS; pub const CouncilDefaultMaxProposals: u32 = 20; pub const CouncilDefaultMaxMembers: u32 = 30; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; + pub MaxProposalWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block; } impl pallet_collective::Config for Runtime { diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 10595e4ded..ac5527149d 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -379,7 +379,7 @@ parameter_types! { pub const GeneralCouncilMotionDuration: BlockNumber = 7 * DAYS; pub const CouncilDefaultMaxProposals: u32 = 100; pub const CouncilDefaultMaxMembers: u32 = 100; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; + pub MaxProposalWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block; } impl pallet_collective::Config for Runtime { From 5477ca9225c097a3cc266c4d28f7845dcfae36f5 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Sun, 3 Nov 2024 19:34:34 +1300 Subject: [PATCH 13/14] update readme --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8865c79d6e..cfa1ffc754 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![License](https://img.shields.io/github/license/AcalaNetwork/Acala?color=green)](https://github.com/AcalaNetwork/Acala/blob/master/LICENSE)
[![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2FAcalaNetwork)](https://twitter.com/AcalaNetwork) -[![Discord](https://img.shields.io/badge/Discord-gray?logo=discord)](https://www.acala.gg/) +[![Discord](https://img.shields.io/badge/Discord-gray?logo=discord)](https://discord.gg/xZfRD6rVfJ) [![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/AcalaOfficial) [![Discourse](https://img.shields.io/badge/Forum-gray?logo=discourse)](https://acala.discourse.group/) [![Medium](https://img.shields.io/badge/Medium-gray?logo=medium)](https://medium.com/acalanetwork) @@ -23,26 +23,26 @@ - [1. Introduction](#1-introduction) - [2. Overview](#2-overview) - - [2.1. aUSD and the Honzon stablecoin protocol](#21-ausd-and-the-honzon-stablecoin-protocol) - - [2.2. Acala Network Economic Model](#22-acala-network-economic-model) + - [2.1. aUSD and the Honzon stablecoin protocol](#21-ausd-and-the-honzon-stablecoin-protocol) + - [2.2. Acala Network Economic Model](#22-acala-network-economic-model) - [3. Building](#3-building) - - [NOTE](#note) + - [NOTE](#note) - [4. Run](#4-run) - [5. Development](#5-development) - [6. Bug Bounty :bug:](#6-bug-bounty-bug) - [7. Bench Bot](#7-bench-bot) - - [Generate module weights](#generate-module-weights) - - [Generate runtime weights](#generate-runtime-weights) - - [Bench Acala EVM+](#bench-acala-evm) + - [Generate module weights](#generate-module-weights) + - [Generate runtime weights](#generate-runtime-weights) + - [Bench Acala EVM+](#bench-acala-evm) - [8. Migration testing runtime](#8-migration-testing-runtime) - - [Try testing runtime](#try-testing-runtime) + - [Try testing runtime](#try-testing-runtime) - [9. Run local testnet with parachain-launch](#9-run-local-testnet-with-parachain-launch) - [10. Build For Release](#10-build-for-release) - [11. Setup Local EVM+ Test Environment](#11-setup-local-evm-test-environment) - - [Setting up local node](#setting-up-local-node) - - [Compile the node from source code:](#compile-the-node-from-source-code) - - [Run node using docker:](#run-node-using-docker) - - [Setting up eth-rpc-adapter](#setting-up-eth-rpc-adapter) + - [Setting up local node](#setting-up-local-node) + - [Compile the node from source code:](#compile-the-node-from-source-code) + - [Run node using docker:](#run-node-using-docker) + - [Setting up eth-rpc-adapter](#setting-up-eth-rpc-adapter) From 613470c47c65fb68e1de79e8991453d12c249740 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Fri, 8 Nov 2024 10:14:26 +1300 Subject: [PATCH 14/14] update readme --- README.md | 172 +++++------------------------------------------------- 1 file changed, 14 insertions(+), 158 deletions(-) diff --git a/README.md b/README.md index cfa1ffc754..42301f27df 100644 --- a/README.md +++ b/README.md @@ -22,82 +22,30 @@ - [1. Introduction](#1-introduction) -- [2. Overview](#2-overview) - - [2.1. aUSD and the Honzon stablecoin protocol](#21-ausd-and-the-honzon-stablecoin-protocol) - - [2.2. Acala Network Economic Model](#22-acala-network-economic-model) -- [3. Building](#3-building) +- [2. Building](#2-building) - [NOTE](#note) -- [4. Run](#4-run) -- [5. Development](#5-development) -- [6. Bug Bounty :bug:](#6-bug-bounty-bug) -- [7. Bench Bot](#7-bench-bot) +- [3. Run](#3-run) +- [4. Development](#4-development) +- [5. Bug Bounty :bug:](#5-bug-bounty-bug) +- [6. Bench Bot](#6-bench-bot) - [Generate module weights](#generate-module-weights) - [Generate runtime weights](#generate-runtime-weights) - [Bench Acala EVM+](#bench-acala-evm) -- [8. Migration testing runtime](#8-migration-testing-runtime) +- [7. Migration testing runtime](#7-migration-testing-runtime) - [Try testing runtime](#try-testing-runtime) -- [9. Run local testnet with parachain-launch](#9-run-local-testnet-with-parachain-launch) -- [10. Build For Release](#10-build-for-release) -- [11. Setup Local EVM+ Test Environment](#11-setup-local-evm-test-environment) - - [Setting up local node](#setting-up-local-node) - - [Compile the node from source code:](#compile-the-node-from-source-code) - - [Run node using docker:](#run-node-using-docker) - - [Setting up eth-rpc-adapter](#setting-up-eth-rpc-adapter) # 1. Introduction This project is initiated and facilitated by the Acala Foundation. Acala Foundation nurtures applications in the fields of decentralized finance protocols, particularly those that serve as open finance infrastructures such as stable currency and staking liquidity. The Acala Foundation is founded by [Laminar](https://laminar.one/) and [Polkawallet](https://polkawallet.io/), participants and contributors to the Polkadot ecosystem. The Acala Foundation welcomes more industry participants as it progresses. -# 2. Overview -The significance of cross-chain communication to the blockchain is like that of the internet to the intranet. Polkadot empowers a network of public, consortium and private blockchains, and enables true interoperability, economic and transactional scalability. A cross-chain stablecoin system will: -1. Create a sound, stable currency for low cost, borderless value transfer for all chains in the network -2. Enable commercial lending with predictable risk -3. Serve as a building block for more open finance services - -The Acala Dollar stablecoin (ticker: aUSD) is a multi-collateral-backed cryptocurrency, with value stable against US Dollar (aka. 1:1 aUSD to USD soft peg). It is completely decentralized, that it can be created using assets from blockchains connected to the Polkadot network including Ethereum and Bitcoin as collaterals, and can be used by any chains (or digital jurisdictions) within the Polkadot network and applications on those chains. - -By this nature, it is essential that the Acala Network eventually become community-owned with an economic model that can sustain its development and participation in the Polkadot network, as well as ensure its stability and security. The following section will provide a high-level overview of the following topics: -- aUSD and the Honzon stablecoin protocol -- the economic model and initial parachain offering - -## 2.1. aUSD and the Honzon stablecoin protocol -Every aUSD is backed in excess by a crypto asset, the mechanism of which is known as an over-collateralized debt position (or CDP). Together with a set of incentives, supply & demand balancing, and risk management mechanisms, as the core components of the Honzon stablecoin protocol on the Acala Network, the stability of the aUSD is ensured. The CDP mechanism design is inspired by the first decentralized stablecoin project MakerDAO, which has become the DeFi building block in the Ethereum ecosystem. Besides, the Honzon protocol enables many unique features - native multi-asset support, cross-chain stablecoin capability, automatic liquidation to increase responsiveness to risk, and pluggable oracle and auction house to improve modularity, just to name a few. - -The Honzon protocol contains the following components -- Multi Collateral Type -- Collateral Adapter -- Oracle and Prices -- Auction and Auction Manager -- CDP and CDP Engine -- Emergency shutdown -- Governance -- Honzon as an interface to other components - -Note: This section is still work in progress, we will update more information as we progress. Refer to the [Github Wiki](https://github.com/AcalaNetwork/Acala/wiki) for more details. - -## 2.2. Acala Network Economic Model -The Acala Network Token (ACA) features the following utilities, and the value of ACA token will accrue with the increased usage of the network and revenue from stability fees and liquidation penalties -1. As Network Utility Token: to pay for network fees and stability fees -2. As Governance Token: to vote for/against risk parameters and network change proposals -3. As Economic Capital: in case of liquidation without sufficient collaterals - -To enable cross-chain functionality, the Acala Network will connect to the Polkadot in one of the three ways: -1. as parathread - pay-as-you-go connection to Polkadot -2. as parachain - permanent connection for a given period -3. as an independent chain with a bridge back to Polkadot - -Becoming a parachain would be an ideal option to bootstrap the Acala Network, and maximize its benefits and reach to other chains and applications on the Polkadot network. To secure a parachain slot, the Acala Network will require supportive DOT holders to lock their DOTs to bid for a slot collectively - a process known as the Initial Parachain Offering (IPO). ACA tokens will be offered as a reward for those who participated in the IPO, as compensation for their opportunity cost of staking the DOTs. - -Note: This section is still work in progress, we will update more information as we progress. Refer to the [token economy working paper](https://github.com/AcalaNetwork/Acala-white-paper) for more details. - -# 3. Building +# 2. Building ## NOTE -To connect on the "Mandala TC6" network, you will want the version `~0.7.10` code which is in this repo. +The Acala client node is moved to [acala-node](https://github.com/AcalaNetwork/acala-node). This repo only contains the runtime code. This allow us to decouple the runtime release and client node release. -- **Mandala TC6** is in [Acala repo master branch](https://github.com/AcalaNetwork/Acala/tree/master/). +If you would like to build the client node, please refer to [acala-node](https://github.com/AcalaNetwork/acala-node). Install Rust: @@ -123,13 +71,7 @@ Install required tools and install git hooks: make init ``` -Build Mandala TC native code: - -```bash -make build-full -``` - -# 4. Run +# 3. Run You can start a development chain with: @@ -137,7 +79,7 @@ You can start a development chain with: make run ``` -# 5. Development +# 4. Development To type check: @@ -163,14 +105,12 @@ Update ORML make update ``` -__Note:__ All build command from Makefile are designed for local development purposes and hence have `SKIP_WASM_BUILD` enabled to speed up build time and use `--execution native` to only run use native execution mode. - -# 6. Bug Bounty :bug: +# 5. Bug Bounty :bug: The Bug Bounty Program includes only on-chain vulnerabilities that can lead to significant economic loss or instability of the network. You check details of the Bug Bounty or Submit a vulnerability here: https://immunefi.com/bounty/acala/ -# 7. Bench Bot +# 6. Bench Bot Bench bot can take care of syncing branch with `master` and generating WeightInfos for module or runtime. ## Generate module weights @@ -191,8 +131,7 @@ Bench bot will do the benchmarking, generate weights file and push changes into Comment on a PR `/bench evm` to benchmark Acala EVM+ and bench bot will generate precompile weights and GasToWeight ratio. - -# 8. Migration testing runtime +# 7. Migration testing runtime If modifying the storage, you should test the data migration before upgrading the runtime. ## Try testing runtime @@ -226,86 +165,3 @@ cargo run --features with-acala-runtime --features try-runtime -- try-runtime -- # Use a state snapshot to run the migration test. ./target/release/acala try-runtime --runtime ./target/release/wbuild/acala-runtime/acala_runtime.compact.compressed.wasm --chain=acala-dev on-runtime-upgrade snap -s acala-latest.snap ``` - -# 9. Run local testnet with [parachain-launch](https://github.com/open-web3-stack/parachain-launch) -Build RelayChain and Parachain local testnet to develop. - -```bash -cd launch - -# install dependencies -yarn - -# generate docker-compose.yml and genesis -# NOTE: If the docker image is not the latest, need to download it manually. -# e.g.: docker pull acala/karura-node:latest -# karura testnet: -yarn start generate -# karura-bifrost testnet: -yarn start generate --config=karura-bifrost.yml - -# start relaychain and parachain -cd output -# NOTE: If regenerate the output directory, need to rebuild the images. -docker-compose up -d --build - -# list all of the containers. -docker ps -a - -# track container logs -docker logs -f [container_id/container_name] - -# stop all of the containers. -docker-compose stop - -# remove all of the containers. -docker-compose rm - -# NOTE: If you want to clear the data and restart, you need to clear the volumes. -# remove volume -docker volume ls -docker volume rm [volume_name] -# prune all volumes -docker volume prune -``` - -# 10. Build For Release - -For release artifacts, a more optimized build config is used. -This config takes around 2x to 3x longer to build, but produces a more optimized binary to run. - -```bash -make build-release -``` - -# 11. Setup Local EVM+ Test Environment - -To set up a basic local network you need two things running locally, a node and the eth-rpc-adapter. Setup each service in their respective terminals and then you are free to use your favorite EVM tools locally! (ex: hardhat) - -## Setting up local node - -#### Compile the node from source code: - -```bash -make run -``` - -Note: You may need normal block production for certain workflow, use command below to run node without instant-sealing flag - -```bash -cargo run --features with-mandala-runtime -- --dev -lruntime=debug -``` - -#### Run node using docker: - -```bash -docker run -it --rm -p 9944:9944 -p 9933:9933 ghcr.io/acalanetwork/mandala-node:master --dev --ws-external --rpc-port=9933 --rpc-external --rpc-cors=all --rpc-methods=unsafe --tmp -levm=debug --instant-sealing -``` - -## Setting up eth-rpc-adapter - -```bash -npx @acala-network/eth-rpc-adapter -l 1 -``` - -Note: If your use case needs `eth_getLogs` rpc call, then you need to have a subquery instance to index the local chain. For this case, follow the tutorial found here: [Local Network Tutorial](https://evmdocs.acala.network/network/network-setup/local-development-network)