From fad0ff1e8c912b7a55971b21f594c8cfe4deb74a Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Fri, 1 Oct 2021 09:15:31 +0800 Subject: [PATCH 1/3] add compact --- Cargo.lock | 6 +-- modules/cdp-engine/src/lib.rs | 1 + modules/cdp-treasury/src/lib.rs | 8 ++-- modules/collator-selection/src/lib.rs | 4 +- modules/dex/src/lib.rs | 20 +++++----- modules/evm/src/lib.rs | 49 +++++++++++++----------- modules/homa-lite/src/lib.rs | 16 +++++--- modules/homa-validator-list/src/lib.rs | 2 + modules/honzon/src/lib.rs | 2 +- modules/incentives/src/lib.rs | 12 +++++- modules/loans/src/lib.rs | 2 + modules/nft/src/lib.rs | 4 +- modules/nominees-election/src/lib.rs | 4 ++ modules/polkadot-bridge/src/lib.rs | 53 ++++++++++++++++++++------ modules/session-manager/src/lib.rs | 4 +- modules/staking-pool/src/lib.rs | 3 ++ node/e2e-tests/Cargo.toml | 2 +- node/e2e-tests/test-runner/Cargo.toml | 2 +- runtime/integration-tests/Cargo.toml | 2 +- 19 files changed, 129 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e53b44c62..356e91798 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2315,7 +2315,7 @@ checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" [[package]] name = "e2e-tests" -version = "1.2.2" +version = "1.5.0" dependencies = [ "acala-cli", "acala-primitives", @@ -9788,7 +9788,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.2.2" +version = "1.5.0" dependencies = [ "acala-primitives", "acala-service", @@ -12653,7 +12653,7 @@ dependencies = [ [[package]] name = "test-runner" -version = "1.2.2" +version = "1.5.0" dependencies = [ "env_logger 0.7.1", "frame-system", diff --git a/modules/cdp-engine/src/lib.rs b/modules/cdp-engine/src/lib.rs index 0ab51122d..4debc17c7 100644 --- a/modules/cdp-engine/src/lib.rs +++ b/modules/cdp-engine/src/lib.rs @@ -81,6 +81,7 @@ pub struct RiskManagementParams { /// Maximum total debit value generated from it, when reach the hard /// cap, CDP's owner cannot issue more stablecoin under the collateral /// type. + #[codec(compact)] pub maximum_total_debit_value: Balance, /// Extra interest rate per sec, `None` value means not set diff --git a/modules/cdp-treasury/src/lib.rs b/modules/cdp-treasury/src/lib.rs index 55b64d9e1..3571c1cf0 100644 --- a/modules/cdp-treasury/src/lib.rs +++ b/modules/cdp-treasury/src/lib.rs @@ -166,7 +166,7 @@ pub mod module { impl Pallet { #[pallet::weight(T::WeightInfo::extract_surplus_to_treasury())] #[transactional] - pub fn extract_surplus_to_treasury(origin: OriginFor, amount: Balance) -> DispatchResult { + pub fn extract_surplus_to_treasury(origin: OriginFor, #[pallet::compact] amount: Balance) -> DispatchResult { T::UpdateOrigin::ensure_origin(origin)?; T::Currency::transfer( T::GetStableCurrencyId::get(), @@ -182,8 +182,8 @@ pub mod module { pub fn auction_collateral( origin: OriginFor, currency_id: CurrencyId, - amount: Balance, - target: Balance, + #[pallet::compact] amount: Balance, + #[pallet::compact] target: Balance, splited: bool, ) -> DispatchResult { T::UpdateOrigin::ensure_origin(origin)?; @@ -209,7 +209,7 @@ pub mod module { pub fn set_expected_collateral_auction_size( origin: OriginFor, currency_id: CurrencyId, - size: Balance, + #[pallet::compact] size: Balance, ) -> DispatchResult { T::UpdateOrigin::ensure_origin(origin)?; ExpectedCollateralAuctionSize::::insert(currency_id, size); diff --git a/modules/collator-selection/src/lib.rs b/modules/collator-selection/src/lib.rs index 947feb463..1b714e7b2 100644 --- a/modules/collator-selection/src/lib.rs +++ b/modules/collator-selection/src/lib.rs @@ -303,7 +303,7 @@ pub mod pallet { } #[pallet::weight(T::WeightInfo::set_desired_candidates())] - pub fn set_desired_candidates(origin: OriginFor, max: u32) -> DispatchResult { + pub fn set_desired_candidates(origin: OriginFor, #[pallet::compact] max: u32) -> DispatchResult { T::UpdateOrigin::ensure_origin(origin)?; if max > T::MaxCandidates::get() { Err(Error::::MaxCandidatesExceeded)?; @@ -314,7 +314,7 @@ pub mod pallet { } #[pallet::weight(T::WeightInfo::set_candidacy_bond())] - pub fn set_candidacy_bond(origin: OriginFor, bond: BalanceOf) -> DispatchResult { + pub fn set_candidacy_bond(origin: OriginFor, #[pallet::compact] bond: BalanceOf) -> DispatchResult { T::UpdateOrigin::ensure_origin(origin)?; >::put(&bond); Self::deposit_event(Event::NewCandidacyBond(bond)); diff --git a/modules/dex/src/lib.rs b/modules/dex/src/lib.rs index c01509d5e..28c8fe533 100644 --- a/modules/dex/src/lib.rs +++ b/modules/dex/src/lib.rs @@ -463,11 +463,11 @@ pub mod module { origin: OriginFor, currency_id_a: CurrencyId, currency_id_b: CurrencyId, - min_contribution_a: Balance, - min_contribution_b: Balance, - target_provision_a: Balance, - target_provision_b: Balance, - not_before: T::BlockNumber, + #[pallet::compact] min_contribution_a: Balance, + #[pallet::compact] min_contribution_b: Balance, + #[pallet::compact] target_provision_a: Balance, + #[pallet::compact] target_provision_b: Balance, + #[pallet::compact] not_before: T::BlockNumber, ) -> DispatchResult { T::ListingOrigin::ensure_origin(origin)?; @@ -526,11 +526,11 @@ pub mod module { origin: OriginFor, currency_id_a: CurrencyId, currency_id_b: CurrencyId, - min_contribution_a: Balance, - min_contribution_b: Balance, - target_provision_a: Balance, - target_provision_b: Balance, - not_before: T::BlockNumber, + #[pallet::compact] min_contribution_a: Balance, + #[pallet::compact] min_contribution_b: Balance, + #[pallet::compact] target_provision_a: Balance, + #[pallet::compact] target_provision_b: Balance, + #[pallet::compact] not_before: T::BlockNumber, ) -> DispatchResult { T::ListingOrigin::ensure_origin(origin)?; let trading_pair = diff --git a/modules/evm/src/lib.rs b/modules/evm/src/lib.rs index 2838d1bce..3f61fd138 100644 --- a/modules/evm/src/lib.rs +++ b/modules/evm/src/lib.rs @@ -222,6 +222,7 @@ pub mod module { #[derive(Clone, Eq, PartialEq, RuntimeDebug, Encode, Decode)] pub struct AccountInfo { + #[codec(compact)] pub nonce: T::Index, pub contract_info: Option, } @@ -234,7 +235,9 @@ pub mod module { #[derive(Clone, Copy, Eq, PartialEq, RuntimeDebug, Encode, Decode, MaxEncodedLen)] pub struct CodeInfo { + #[codec(compact)] pub code_size: u32, + #[codec(compact)] pub ref_count: u32, } @@ -243,8 +246,10 @@ pub mod module { /// Account definition used for genesis block construction. pub struct GenesisAccount { /// Account nonce. + #[codec(compact)] pub nonce: Index, /// Account balance. + #[codec(compact)] pub balance: Balance, /// Full account storage. pub storage: BTreeMap, @@ -488,10 +493,10 @@ pub mod module { origin: OriginFor, action: TransactionAction, input: Vec, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, - _valid_until: T::BlockNumber, // checked by tx validation logic + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, + #[pallet::compact] _valid_until: T::BlockNumber, // checked by tx validation logic ) -> DispatchResultWithPostInfo { match action { TransactionAction::Call(target) => Self::call(origin, target, input, value, gas_limit, storage_limit), @@ -513,9 +518,9 @@ pub mod module { origin: OriginFor, target: EvmAddress, input: Vec, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let source = T::AddressMapping::get_or_create_evm_address(&who); @@ -561,9 +566,9 @@ pub mod module { from: EvmAddress, target: EvmAddress, input: Vec, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; @@ -622,9 +627,9 @@ pub mod module { pub fn create( origin: OriginFor, init: Vec, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let source = T::AddressMapping::get_or_create_evm_address(&who); @@ -659,9 +664,9 @@ pub mod module { origin: OriginFor, init: Vec, salt: H256, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let source = T::AddressMapping::get_or_create_evm_address(&who); @@ -694,9 +699,9 @@ pub mod module { pub fn create_network_contract( origin: OriginFor, init: Vec, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, ) -> DispatchResultWithPostInfo { T::NetworkContractOrigin::ensure_origin(origin)?; @@ -735,9 +740,9 @@ pub mod module { origin: OriginFor, target: EvmAddress, init: Vec, - value: BalanceOf, - gas_limit: u64, - storage_limit: u32, + #[pallet::compact] value: BalanceOf, + #[pallet::compact] gas_limit: u64, + #[pallet::compact] storage_limit: u32, ) -> DispatchResultWithPostInfo { T::NetworkContractOrigin::ensure_origin(origin)?; diff --git a/modules/homa-lite/src/lib.rs b/modules/homa-lite/src/lib.rs index 2d8defab9..7e39a7c21 100644 --- a/modules/homa-lite/src/lib.rs +++ b/modules/homa-lite/src/lib.rs @@ -153,7 +153,7 @@ pub mod module { /// - `amount`: The amount of Staking currency to be exchanged. #[pallet::weight(< T as Config >::WeightInfo::mint())] #[transactional] - pub fn mint(origin: OriginFor, amount: Balance) -> DispatchResult { + pub fn mint(origin: OriginFor, #[pallet::compact] amount: Balance) -> DispatchResult { let who = ensure_signed(origin)?; // Ensure the amount is above the minimum, after the MintFee is deducted. ensure!( @@ -220,7 +220,10 @@ pub mod module { /// conversion rate. #[pallet::weight(< T as Config >::WeightInfo::set_total_staking_currency())] #[transactional] - pub fn set_total_staking_currency(origin: OriginFor, staking_total: Balance) -> DispatchResult { + pub fn set_total_staking_currency( + origin: OriginFor, + #[pallet::compact] staking_total: Balance, + ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; ensure!(!staking_total.is_zero(), Error::::InvalidTotalStakingCurrency); @@ -238,7 +241,10 @@ pub mod module { /// by. #[pallet::weight(< T as Config >::WeightInfo::adjust_total_staking_currency())] #[transactional] - pub fn adjust_total_staking_currency(origin: OriginFor, by_amount: AmountOf) -> DispatchResult { + pub fn adjust_total_staking_currency( + origin: OriginFor, + #[pallet::compact] by_amount: AmountOf, + ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; let mut current_staking_total = Self::total_staking_currency(); @@ -275,7 +281,7 @@ pub mod module { /// - `new_cap`: The new cap for staking currency. #[pallet::weight(< T as Config >::WeightInfo::set_minting_cap())] #[transactional] - pub fn set_minting_cap(origin: OriginFor, new_cap: Balance) -> DispatchResult { + pub fn set_minting_cap(origin: OriginFor, #[pallet::compact] new_cap: Balance) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; StakingCurrencyMintCap::::put(new_cap); @@ -290,7 +296,7 @@ pub mod module { /// - `xcm_dest_weight`: The new weight for XCM transfers. #[pallet::weight(< T as Config >::WeightInfo::set_xcm_dest_weight())] #[transactional] - pub fn set_xcm_dest_weight(origin: OriginFor, xcm_dest_weight: Weight) -> DispatchResult { + pub fn set_xcm_dest_weight(origin: OriginFor, #[pallet::compact] xcm_dest_weight: Weight) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; XcmDestWeight::::put(xcm_dest_weight); diff --git a/modules/homa-validator-list/src/lib.rs b/modules/homa-validator-list/src/lib.rs index dfc51f5d3..5c03bf3c9 100644 --- a/modules/homa-validator-list/src/lib.rs +++ b/modules/homa-validator-list/src/lib.rs @@ -88,8 +88,10 @@ impl WeightInfo for () { #[derive(Encode, Decode, Clone, Copy, RuntimeDebug, Default, PartialEq, MaxEncodedLen)] pub struct Guarantee { /// The total tokens the validator has in insurance + #[codec(compact)] total: Balance, /// The number of tokens that are actively bonded for insurance + #[codec(compact)] bonded: Balance, /// The number of tokens that are in the process of unbonding for insurance unbonding: Option<(Balance, BlockNumber)>, diff --git a/modules/honzon/src/lib.rs b/modules/honzon/src/lib.rs index 7bec46d9d..f9282295b 100644 --- a/modules/honzon/src/lib.rs +++ b/modules/honzon/src/lib.rs @@ -162,7 +162,7 @@ pub mod module { pub fn close_loan_has_debit_by_dex( origin: OriginFor, currency_id: CurrencyId, - max_collateral_amount: Balance, + #[pallet::compact] max_collateral_amount: Balance, maybe_path: Option>, ) -> DispatchResult { let who = ensure_signed(origin)?; diff --git a/modules/incentives/src/lib.rs b/modules/incentives/src/lib.rs index f2bc00bba..78759f225 100644 --- a/modules/incentives/src/lib.rs +++ b/modules/incentives/src/lib.rs @@ -233,7 +233,11 @@ pub mod module { /// - `amount`: amount to stake #[pallet::weight(::WeightInfo::deposit_dex_share())] #[transactional] - pub fn deposit_dex_share(origin: OriginFor, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { + pub fn deposit_dex_share( + origin: OriginFor, + lp_currency_id: CurrencyId, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { let who = ensure_signed(origin)?; Self::do_deposit_dex_share(&who, lp_currency_id, amount)?; Ok(()) @@ -247,7 +251,11 @@ pub mod module { /// - `amount`: amount to unstake #[pallet::weight(::WeightInfo::withdraw_dex_share())] #[transactional] - pub fn withdraw_dex_share(origin: OriginFor, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { + pub fn withdraw_dex_share( + origin: OriginFor, + lp_currency_id: CurrencyId, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { let who = ensure_signed(origin)?; Self::do_withdraw_dex_share(&who, lp_currency_id, amount)?; Ok(()) diff --git a/modules/loans/src/lib.rs b/modules/loans/src/lib.rs index 5d757ff4d..8e8559756 100644 --- a/modules/loans/src/lib.rs +++ b/modules/loans/src/lib.rs @@ -47,8 +47,10 @@ pub use module::*; #[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug, Default, MaxEncodedLen)] pub struct Position { /// The amount of collateral. + #[codec(compact)] pub collateral: Balance, /// The amount of debit. + #[codec(compact)] pub debit: Balance, } diff --git a/modules/nft/src/lib.rs b/modules/nft/src/lib.rs index d30fc7673..111fba152 100644 --- a/modules/nft/src/lib.rs +++ b/modules/nft/src/lib.rs @@ -90,6 +90,7 @@ impl Decode for Properties { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct ClassData { /// Deposit reserved to create token class + #[codec(compact)] pub deposit: Balance, /// Class properties pub properties: Properties, @@ -101,6 +102,7 @@ pub struct ClassData { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct TokenData { /// Deposit reserved to create token + #[codec(compact)] pub deposit: Balance, /// Token attributes pub attributes: Attributes, @@ -262,7 +264,7 @@ pub mod module { class_id: ClassIdOf, metadata: CID, attributes: Attributes, - quantity: u32, + #[pallet::compact] quantity: u32, ) -> DispatchResult { let who = ensure_signed(origin)?; let to = T::Lookup::lookup(to)?; diff --git a/modules/nominees-election/src/lib.rs b/modules/nominees-election/src/lib.rs index e41a65e9a..bd3af70f5 100644 --- a/modules/nominees-election/src/lib.rs +++ b/modules/nominees-election/src/lib.rs @@ -48,8 +48,10 @@ pub use weights::WeightInfo; #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen)] pub struct UnlockChunk { /// Amount of funds to be unlocked. + #[codec(compact)] value: Balance, /// Era number at which point it'll be unlocked. + #[codec(compact)] era: EraIndex, } @@ -62,9 +64,11 @@ where /// The total amount of the account's balance that we are currently /// accounting for. It's just `active` plus all the `unlocking` /// balances. + #[codec(compact)] pub total: Balance, /// The total amount of the account's balance that will be at stake in /// any forthcoming rounds. + #[codec(compact)] pub active: Balance, /// Any balance that is becoming free, which may eventually be /// transferred out of the account. diff --git a/modules/polkadot-bridge/src/lib.rs b/modules/polkadot-bridge/src/lib.rs index 478768b67..f693478e7 100644 --- a/modules/polkadot-bridge/src/lib.rs +++ b/modules/polkadot-bridge/src/lib.rs @@ -39,8 +39,10 @@ pub use module::*; #[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, Default)] pub struct SubAccountStatus { /// Bonded amount + #[codec(compact)] pub bonded: Balance, /// Free amount + #[codec(compact)] pub available: Balance, /// Unbonding list pub unbonding: Unbonding, @@ -114,7 +116,11 @@ pub mod module { impl Pallet { #[pallet::weight(10_000)] #[transactional] - pub fn set_mock_reward_rate(origin: OriginFor, account_index: u32, reward_rate: Rate) -> DispatchResult { + pub fn set_mock_reward_rate( + origin: OriginFor, + #[pallet::compact] account_index: u32, + reward_rate: Rate, + ) -> DispatchResult { ensure_root(origin)?; SubAccounts::::mutate(account_index, |status| { status.mock_reward_rate = reward_rate; @@ -124,7 +130,11 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn simulate_bond_extra(origin: OriginFor, account_index: u32, amount: Balance) -> DispatchResult { + pub fn simulate_bond_extra( + origin: OriginFor, + #[pallet::compact] account_index: u32, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { ensure_root(origin)?; Self::sub_account_bond_extra(account_index, amount)?; Ok(()) @@ -132,7 +142,11 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn simulate_unbond(origin: OriginFor, account_index: u32, amount: Balance) -> DispatchResult { + pub fn simulate_unbond( + origin: OriginFor, + #[pallet::compact] account_index: u32, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { ensure_root(origin)?; Self::sub_account_unbond(account_index, amount)?; Ok(()) @@ -140,7 +154,11 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn simulate_rebond(origin: OriginFor, account_index: u32, amount: Balance) -> DispatchResult { + pub fn simulate_rebond( + origin: OriginFor, + #[pallet::compact] account_index: u32, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { ensure_signed(origin)?; Self::sub_account_rebond(account_index, amount)?; Ok(()) @@ -148,7 +166,10 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn simulate_withdraw_unbonded(origin: OriginFor, account_index: u32) -> DispatchResult { + pub fn simulate_withdraw_unbonded( + origin: OriginFor, + #[pallet::compact] account_index: u32, + ) -> DispatchResult { // ignore because we don't care who send the message let _ = ensure_signed(origin)?; Self::sub_account_withdraw_unbonded(account_index); @@ -157,7 +178,11 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn simulate_payout_stakers(origin: OriginFor, account_index: u32, era: EraIndex) -> DispatchResult { + pub fn simulate_payout_stakers( + origin: OriginFor, + #[pallet::compact] account_index: u32, + #[pallet::compact] era: EraIndex, + ) -> DispatchResult { ensure_signed(origin)?; Self::payout_stakers(account_index, era); Ok(()) @@ -167,8 +192,8 @@ pub mod module { #[transactional] pub fn simulate_transfer_to_sub_account( origin: OriginFor, - account_index: u32, - amount: Balance, + #[pallet::compact] account_index: u32, + #[pallet::compact] amount: Balance, ) -> DispatchResult { let who = ensure_signed(origin)?; Self::transfer_to_sub_account(account_index, &who, amount)?; @@ -179,9 +204,9 @@ pub mod module { #[transactional] pub fn simualte_receive_from_sub_account( origin: OriginFor, - account_index: u32, + #[pallet::compact] account_index: u32, to: ::Source, - amount: Balance, + #[pallet::compact] amount: Balance, ) -> DispatchResult { ensure_root(origin)?; let to = T::Lookup::lookup(to)?; @@ -191,7 +216,11 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn simulate_slash_sub_account(origin: OriginFor, account_index: u32, amount: Balance) -> DispatchResult { + pub fn simulate_slash_sub_account( + origin: OriginFor, + #[pallet::compact] account_index: u32, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { ensure_root(origin)?; SubAccounts::::mutate(account_index, |status| { status.bonded = status.bonded.saturating_sub(amount); @@ -201,7 +230,7 @@ pub mod module { #[pallet::weight(10_000)] #[transactional] - pub fn force_era(origin: OriginFor, at: T::BlockNumber) -> DispatchResult { + pub fn force_era(origin: OriginFor, #[pallet::compact] at: T::BlockNumber) -> DispatchResult { ensure_root(origin)?; if at > >::block_number() { ForcedEra::::put(at); diff --git a/modules/session-manager/src/lib.rs b/modules/session-manager/src/lib.rs index dd22062bc..e6b34a3f4 100644 --- a/modules/session-manager/src/lib.rs +++ b/modules/session-manager/src/lib.rs @@ -151,8 +151,8 @@ pub mod module { #[pallet::weight(T::WeightInfo::schedule_session_duration())] pub fn schedule_session_duration( origin: OriginFor, - start_session: SessionIndex, - duration: T::BlockNumber, + #[pallet::compact] start_session: SessionIndex, + #[pallet::compact] duration: T::BlockNumber, ) -> DispatchResult { ensure_root(origin)?; diff --git a/modules/staking-pool/src/lib.rs b/modules/staking-pool/src/lib.rs index 49c7fb542..97ae070ed 100644 --- a/modules/staking-pool/src/lib.rs +++ b/modules/staking-pool/src/lib.rs @@ -80,10 +80,13 @@ impl Default for Phase { #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, Default)] pub struct Ledger { /// The amount of total bonded. + #[codec(compact)] pub bonded: Balance, /// The amount of total unbonding to free pool. + #[codec(compact)] pub unbonding_to_free: Balance, /// The amount of free pool. + #[codec(compact)] pub free_pool: Balance, /// The amount to unbond when next era beginning. pub to_unbond_next_era: (Balance, Balance), diff --git a/node/e2e-tests/Cargo.toml b/node/e2e-tests/Cargo.toml index 1b267dac0..fb0c8aeab 100644 --- a/node/e2e-tests/Cargo.toml +++ b/node/e2e-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "e2e-tests" -version = "1.2.2" +version = "1.5.0" authors = ["Acala Developers"] edition = "2018" diff --git a/node/e2e-tests/test-runner/Cargo.toml b/node/e2e-tests/test-runner/Cargo.toml index 56213e049..6d14a399c 100644 --- a/node/e2e-tests/test-runner/Cargo.toml +++ b/node/e2e-tests/test-runner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-runner" -version = "1.2.2" +version = "1.5.0" authors = ["Acala Developers"] edition = "2018" diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml index c49215705..a3903e08b 100644 --- a/runtime/integration-tests/Cargo.toml +++ b/runtime/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.2.2" +version = "1.5.0" authors = ["Acala Developers"] edition = "2018" From 04e8a36724d463f43aeaaeb82236774c33a5ad7f Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Fri, 1 Oct 2021 09:46:46 +0800 Subject: [PATCH 2/3] revert codec(compact) --- modules/auction-manager/src/lib.rs | 3 --- modules/cdp-engine/src/lib.rs | 1 - modules/evm/src/lib.rs | 5 ----- modules/homa-lite/src/lib.rs | 5 +---- modules/homa-validator-list/src/lib.rs | 2 -- modules/loans/src/lib.rs | 2 -- modules/nft/src/lib.rs | 2 -- modules/nominees-election/src/lib.rs | 4 ---- modules/polkadot-bridge/src/lib.rs | 2 -- modules/staking-pool/src/lib.rs | 3 --- 10 files changed, 1 insertion(+), 28 deletions(-) diff --git a/modules/auction-manager/src/lib.rs b/modules/auction-manager/src/lib.rs index eb51d70bc..0f154a341 100644 --- a/modules/auction-manager/src/lib.rs +++ b/modules/auction-manager/src/lib.rs @@ -74,16 +74,13 @@ pub struct CollateralAuctionItem { /// Collateral type for sale currency_id: CurrencyId, /// Initial collateral amount for sale - #[codec(compact)] initial_amount: Balance, /// Current collateral amount for sale - #[codec(compact)] amount: Balance, /// Target sales amount of this auction /// if zero, collateral auction will never be reverse stage, /// otherwise, target amount is the actual payment amount of active /// bidder - #[codec(compact)] target: Balance, /// Auction start time start_time: BlockNumber, diff --git a/modules/cdp-engine/src/lib.rs b/modules/cdp-engine/src/lib.rs index 4debc17c7..0ab51122d 100644 --- a/modules/cdp-engine/src/lib.rs +++ b/modules/cdp-engine/src/lib.rs @@ -81,7 +81,6 @@ pub struct RiskManagementParams { /// Maximum total debit value generated from it, when reach the hard /// cap, CDP's owner cannot issue more stablecoin under the collateral /// type. - #[codec(compact)] pub maximum_total_debit_value: Balance, /// Extra interest rate per sec, `None` value means not set diff --git a/modules/evm/src/lib.rs b/modules/evm/src/lib.rs index 3f61fd138..1de1a302c 100644 --- a/modules/evm/src/lib.rs +++ b/modules/evm/src/lib.rs @@ -222,7 +222,6 @@ pub mod module { #[derive(Clone, Eq, PartialEq, RuntimeDebug, Encode, Decode)] pub struct AccountInfo { - #[codec(compact)] pub nonce: T::Index, pub contract_info: Option, } @@ -235,9 +234,7 @@ pub mod module { #[derive(Clone, Copy, Eq, PartialEq, RuntimeDebug, Encode, Decode, MaxEncodedLen)] pub struct CodeInfo { - #[codec(compact)] pub code_size: u32, - #[codec(compact)] pub ref_count: u32, } @@ -246,10 +243,8 @@ pub mod module { /// Account definition used for genesis block construction. pub struct GenesisAccount { /// Account nonce. - #[codec(compact)] pub nonce: Index, /// Account balance. - #[codec(compact)] pub balance: Balance, /// Full account storage. pub storage: BTreeMap, diff --git a/modules/homa-lite/src/lib.rs b/modules/homa-lite/src/lib.rs index 7e39a7c21..23b937e7b 100644 --- a/modules/homa-lite/src/lib.rs +++ b/modules/homa-lite/src/lib.rs @@ -241,10 +241,7 @@ pub mod module { /// by. #[pallet::weight(< T as Config >::WeightInfo::adjust_total_staking_currency())] #[transactional] - pub fn adjust_total_staking_currency( - origin: OriginFor, - #[pallet::compact] by_amount: AmountOf, - ) -> DispatchResult { + pub fn adjust_total_staking_currency(origin: OriginFor, by_amount: AmountOf) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; let mut current_staking_total = Self::total_staking_currency(); diff --git a/modules/homa-validator-list/src/lib.rs b/modules/homa-validator-list/src/lib.rs index 5c03bf3c9..dfc51f5d3 100644 --- a/modules/homa-validator-list/src/lib.rs +++ b/modules/homa-validator-list/src/lib.rs @@ -88,10 +88,8 @@ impl WeightInfo for () { #[derive(Encode, Decode, Clone, Copy, RuntimeDebug, Default, PartialEq, MaxEncodedLen)] pub struct Guarantee { /// The total tokens the validator has in insurance - #[codec(compact)] total: Balance, /// The number of tokens that are actively bonded for insurance - #[codec(compact)] bonded: Balance, /// The number of tokens that are in the process of unbonding for insurance unbonding: Option<(Balance, BlockNumber)>, diff --git a/modules/loans/src/lib.rs b/modules/loans/src/lib.rs index 8e8559756..5d757ff4d 100644 --- a/modules/loans/src/lib.rs +++ b/modules/loans/src/lib.rs @@ -47,10 +47,8 @@ pub use module::*; #[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug, Default, MaxEncodedLen)] pub struct Position { /// The amount of collateral. - #[codec(compact)] pub collateral: Balance, /// The amount of debit. - #[codec(compact)] pub debit: Balance, } diff --git a/modules/nft/src/lib.rs b/modules/nft/src/lib.rs index 111fba152..a283cca78 100644 --- a/modules/nft/src/lib.rs +++ b/modules/nft/src/lib.rs @@ -90,7 +90,6 @@ impl Decode for Properties { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct ClassData { /// Deposit reserved to create token class - #[codec(compact)] pub deposit: Balance, /// Class properties pub properties: Properties, @@ -102,7 +101,6 @@ pub struct ClassData { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct TokenData { /// Deposit reserved to create token - #[codec(compact)] pub deposit: Balance, /// Token attributes pub attributes: Attributes, diff --git a/modules/nominees-election/src/lib.rs b/modules/nominees-election/src/lib.rs index bd3af70f5..e41a65e9a 100644 --- a/modules/nominees-election/src/lib.rs +++ b/modules/nominees-election/src/lib.rs @@ -48,10 +48,8 @@ pub use weights::WeightInfo; #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen)] pub struct UnlockChunk { /// Amount of funds to be unlocked. - #[codec(compact)] value: Balance, /// Era number at which point it'll be unlocked. - #[codec(compact)] era: EraIndex, } @@ -64,11 +62,9 @@ where /// The total amount of the account's balance that we are currently /// accounting for. It's just `active` plus all the `unlocking` /// balances. - #[codec(compact)] pub total: Balance, /// The total amount of the account's balance that will be at stake in /// any forthcoming rounds. - #[codec(compact)] pub active: Balance, /// Any balance that is becoming free, which may eventually be /// transferred out of the account. diff --git a/modules/polkadot-bridge/src/lib.rs b/modules/polkadot-bridge/src/lib.rs index f693478e7..7cbe03ee2 100644 --- a/modules/polkadot-bridge/src/lib.rs +++ b/modules/polkadot-bridge/src/lib.rs @@ -39,10 +39,8 @@ pub use module::*; #[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, Default)] pub struct SubAccountStatus { /// Bonded amount - #[codec(compact)] pub bonded: Balance, /// Free amount - #[codec(compact)] pub available: Balance, /// Unbonding list pub unbonding: Unbonding, diff --git a/modules/staking-pool/src/lib.rs b/modules/staking-pool/src/lib.rs index 97ae070ed..49c7fb542 100644 --- a/modules/staking-pool/src/lib.rs +++ b/modules/staking-pool/src/lib.rs @@ -80,13 +80,10 @@ impl Default for Phase { #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, Default)] pub struct Ledger { /// The amount of total bonded. - #[codec(compact)] pub bonded: Balance, /// The amount of total unbonding to free pool. - #[codec(compact)] pub unbonding_to_free: Balance, /// The amount of free pool. - #[codec(compact)] pub free_pool: Balance, /// The amount to unbond when next era beginning. pub to_unbond_next_era: (Balance, Balance), From 0e76a3a8df08a4f5961dfbf2f4c79d0ab05d5931 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Fri, 1 Oct 2021 09:49:28 +0800 Subject: [PATCH 3/3] add codec(compact) --- modules/auction-manager/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/auction-manager/src/lib.rs b/modules/auction-manager/src/lib.rs index 0f154a341..eb51d70bc 100644 --- a/modules/auction-manager/src/lib.rs +++ b/modules/auction-manager/src/lib.rs @@ -74,13 +74,16 @@ pub struct CollateralAuctionItem { /// Collateral type for sale currency_id: CurrencyId, /// Initial collateral amount for sale + #[codec(compact)] initial_amount: Balance, /// Current collateral amount for sale + #[codec(compact)] amount: Balance, /// Target sales amount of this auction /// if zero, collateral auction will never be reverse stage, /// otherwise, target amount is the actual payment amount of active /// bidder + #[codec(compact)] target: Balance, /// Auction start time start_time: BlockNumber,