Skip to content

Commit

Permalink
polkadot update v.0.9.42
Browse files Browse the repository at this point in the history
  • Loading branch information
OverOrion committed Jun 5, 2023
1 parent 6266ad6 commit 9b458e7
Show file tree
Hide file tree
Showing 41 changed files with 1,742 additions and 1,227 deletions.
2,449 changes: 1,495 additions & 954 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions balances-tx-payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ pallet-encointer-balances = { path = "../balances", default-features = false }
pallet-encointer-ceremonies = { path = "../ceremonies", default-features = false }

# substrate dependencies
frame-support = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
pallet-asset-tx-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
frame-support = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
pallet-asset-tx-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }


[dev-dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
rstest = "0.12.0"
scale-info = { version = "2.0.1", default-features = false }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
test-utils = { path = "../test-utils" }

[features]
Expand Down
18 changes: 9 additions & 9 deletions balances-tx-payment/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ encointer-primitives = { path = "../../primitives" }
encointer-rpc = { path = "../../rpc" }

# substrate deps
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-rpc = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-rpc = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
6 changes: 3 additions & 3 deletions balances-tx-payment/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ encointer-primitives = { path = "../../../primitives", default-features = false

# substrate deps
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }

[features]
default = ["std"]
Expand Down
15 changes: 6 additions & 9 deletions balances-tx-payment/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ use sp_api::{Decode, Encode, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_core::Bytes;
use sp_rpc::number::NumberOrHex;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, MaybeDisplay},
};
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};
use std::sync::Arc;

#[rpc(client, server)]
Expand Down Expand Up @@ -91,7 +88,7 @@ where
at: Option<Block::Hash>,
) -> RpcResult<FeeDetails<NumberOrHex>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let encoded_len = encoded_xt.len() as u32;

Expand All @@ -102,7 +99,7 @@ where
Some(format!("{e:?}")),
))
})?;
let fee_details = api.query_fee_details(&at, uxt, encoded_len).map_err(|e| {
let fee_details = api.query_fee_details(at, uxt, encoded_len).map_err(|e| {
CallError::Custom(ErrorObject::owned(
Error::RuntimeError.into(),
"Unable to query fee details.",
Expand All @@ -123,7 +120,7 @@ where
Ok(FeeDetails {
inclusion_fee: if let Some(inclusion_fee) = fee_details.inclusion_fee {
let base_fee = api
.balance_to_asset_balance(&at, inclusion_fee.base_fee, asset_id)
.balance_to_asset_balance(at, inclusion_fee.base_fee, asset_id)
.map_err(|e| {
runtime_api_error_into_rpc_error(e, "Unable to query fee details")
})?
Expand All @@ -132,7 +129,7 @@ where
})?;

let len_fee = api
.balance_to_asset_balance(&at, inclusion_fee.len_fee, asset_id)
.balance_to_asset_balance(at, inclusion_fee.len_fee, asset_id)
.map_err(|e| {
runtime_api_error_into_rpc_error(e, "Unable to query fee details")
})?
Expand All @@ -141,7 +138,7 @@ where
})?;

let adjusted_weight_fee = api
.balance_to_asset_balance(&at, inclusion_fee.adjusted_weight_fee, asset_id)
.balance_to_asset_balance(at, inclusion_fee.adjusted_weight_fee, asset_id)
.map_err(|e| {
runtime_api_error_into_rpc_error(e, "Unable to query fee details")
})?
Expand Down
4 changes: 2 additions & 2 deletions balances-tx-payment/src/balance_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use crate::{AssetBalanceOf, AssetIdOf, BalanceOf};
use core::marker::PhantomData;
use encointer_primitives::{balances::EncointerBalanceConverter, communities::CommunityIdentifier};
use frame_support::traits::tokens::BalanceConversion;
use frame_support::traits::tokens::ConversionToAssetBalance;
use pallet_encointer_balances::Pallet as BalancesPallet;
use pallet_encointer_ceremonies::{Config as CeremoniesConfig, Pallet as CeremoniesPallet};
use sp_runtime::traits::Convert;
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn apply_fee_conversion_factor(

pub struct BalanceToCommunityBalance<T>(PhantomData<T>);

impl<T> BalanceConversion<BalanceOf<T>, AssetIdOf<T>, AssetBalanceOf<T>>
impl<T> ConversionToAssetBalance<BalanceOf<T>, AssetIdOf<T>, AssetBalanceOf<T>>
for BalanceToCommunityBalance<T>
where
T: CeremoniesConfig + pallet_asset_tx_payment::Config,
Expand Down
4 changes: 3 additions & 1 deletion balances-tx-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ impl<T> HandleCredit<<T as frame_system::Config>::AccountId, pallet_encointer_ba
for BurnCredit
where
T: frame_system::Config + pallet_encointer_balances::Config,
pallet_encointer_balances::Pallet<T>:
frame_support::traits::fungibles::Balanced<<T as frame_system::Config>::AccountId>,
{
fn handle_credit(
_credit: fungibles::CreditOf<AccountIdOf<T>, pallet_encointer_balances::Pallet<T>>,
_credit: fungibles::Credit<AccountIdOf<T>, pallet_encointer_balances::Pallet<T>>,
) {
// just doing nothing with the credit, will use the default implementation
// of fungibles an decrease total issuance.
Expand Down
16 changes: 8 additions & 8 deletions balances/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ scale-info = { version = "2.0.1", default-features = false }
encointer-primitives = { path = "../primitives", default-features = false }

# substrate deps
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
pallet-asset-tx-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-asset-tx-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }


[dev-dependencies]
approx = "0.5.1"
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
test-utils = { path = "../test-utils" }

[features]
Expand Down
49 changes: 16 additions & 33 deletions balances/src/impl_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,12 @@
// along with Encointer. If not, see <http://www.gnu.org/licenses/>.

use super::*;
use encointer_primitives::{balances::EncointerBalanceConverter, common::UnboundedPalletString};
use frame_support::{
inherent::Vec,
traits::tokens::{DepositConsequence, WithdrawConsequence},
use encointer_primitives::balances::EncointerBalanceConverter;
use frame_support::traits::tokens::{
DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence,
};
use sp_runtime::traits::{Convert, Zero};

// Implementation of this trait is just to satisfy the trait bounds of the
// `pallet-asset-tx-payment`. It is not used in our case.
impl<T: Config> fungibles::InspectMetadata<T::AccountId> for Pallet<T> {
fn name(_asset: &Self::AssetId) -> Vec<u8> {
UnboundedPalletString::from("Encointer").into()
}

fn symbol(_asset: &Self::AssetId) -> Vec<u8> {
UnboundedPalletString::from("ETR").into()
}

fn decimals(_asset: &Self::AssetId) -> u8 {
// Our BalanceType is I64F64 which is base2 fixpoint and therefore doesn't use decimals (which would be base10 fixpoint)
// but in order to comply with this trait we need to define decimals nevertheless.
// the smallest possible number is 2^-64 = 5.42101086242752217003726400434970855712890625 × 10^-20
// and an upper bound is 2^63 + 1 = 9.223372036854775809 × 10^18
// so we chose 18 decimals and lose some precision but can prevent overflows that way.
// due to demurrage, that lost precision is meaningless anyway
18u8
}
}

pub(crate) fn fungible(balance: BalanceType) -> u128 {
EncointerBalanceConverter::convert(balance)
}
Expand Down Expand Up @@ -72,10 +49,15 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
fungible(Pallet::<T>::balance(asset, who))
}

fn total_balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
fungible(Pallet::<T>::balance(asset, who))
}

fn reducible_balance(
asset: Self::AssetId,
who: &T::AccountId,
_keep_alive: bool,
_preservation: Preservation,
_force: Fortitude,
) -> Self::Balance {
fungible(Pallet::<T>::balance(asset, who))
}
Expand All @@ -84,7 +66,7 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
asset: Self::AssetId,
who: &T::AccountId,
amount: Self::Balance,
_mint: bool,
_mint: Provenance,
) -> DepositConsequence {
if !<TotalIssuance<T>>::contains_key(asset) {
return DepositConsequence::UnknownAsset
Expand Down Expand Up @@ -129,25 +111,25 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
let balance = fungible(Pallet::<T>::balance(asset, who));

if balance.checked_sub(amount).is_none() {
return NoFunds
return WithdrawConsequence::BalanceLow
}
Success
WithdrawConsequence::Success
}
}

impl<T: Config> fungibles::Unbalanced<T::AccountId> for Pallet<T> {
fn set_balance(
fn write_balance(
asset: Self::AssetId,
who: &T::AccountId,
amount: Self::Balance,
) -> DispatchResult {
) -> Result<Option<Self::Balance>, sp_runtime::DispatchError> {
let current_block = frame_system::Pallet::<T>::block_number();
<Balance<T>>::insert(
asset,
who,
BalanceEntry { principal: balance_type(amount), last_update: current_block },
);
Ok(())
Ok(None)
}

fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance) {
Expand All @@ -157,4 +139,5 @@ impl<T: Config> fungibles::Unbalanced<T::AccountId> for Pallet<T> {
BalanceEntry { principal: balance_type(amount), last_update: current_block },
);
}
fn handle_dust(_: fungibles::Dust<T::AccountId, Self>) {}
}
1 change: 0 additions & 1 deletion balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub mod pallet {
use frame_system::pallet_prelude::*;

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(PhantomData<T>);

#[pallet::config]
Expand Down
12 changes: 6 additions & 6 deletions balances/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ pub trait WeightInfo {
pub struct EncointerWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for EncointerWeight<T> {
fn transfer() -> Weight {
Weight::from_ref_time(88_000_000)
Weight::from_parts(88_000_000, 0u64)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
fn transfer_all() -> Weight {
Weight::from_ref_time(111_000_000)
Weight::from_parts(111_000_000, 0u64)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
}

fn set_fee_conversion_factor() -> Weight {
Weight::from_ref_time(16_300_000).saturating_add(T::DbWeight::get().writes(1))
Weight::from_parts(16_300_000, 0u64).saturating_add(T::DbWeight::get().writes(1))
}
}

// For tests
impl WeightInfo for () {
fn transfer() -> Weight {
Weight::from_ref_time(88_000_000)
Weight::from_parts(88_000_000, 0u64)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
}
fn transfer_all() -> Weight {
Weight::from_ref_time(111_000_000)
Weight::from_parts(111_000_000, 0u64)
.saturating_add(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(4))
}

fn set_fee_conversion_factor() -> Weight {
Weight::from_ref_time(16_300_000).saturating_add(RocksDbWeight::get().writes(1))
Weight::from_parts(16_300_000, 0u64).saturating_add(RocksDbWeight::get().writes(1))
}
}
12 changes: 6 additions & 6 deletions bazaar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ encointer-communities = { package = "pallet-encointer-communities", path = "../c
encointer-primitives = { path = "../primitives", default-features = false }

# substrate deps
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }


[dev-dependencies]
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
test-utils = { path = "../test-utils" }

[features]
Expand Down
Loading

0 comments on commit 9b458e7

Please sign in to comment.