Skip to content

Commit 9b458e7

Browse files
committed
polkadot update v.0.9.42
1 parent 6266ad6 commit 9b458e7

File tree

41 files changed

+1742
-1227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1742
-1227
lines changed

Cargo.lock

Lines changed: 1495 additions & 954 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

balances-tx-payment/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ pallet-encointer-balances = { path = "../balances", default-features = false }
1111
pallet-encointer-ceremonies = { path = "../ceremonies", default-features = false }
1212

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

2020

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

2828
[features]

balances-tx-payment/rpc/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ encointer-primitives = { path = "../../primitives" }
1717
encointer-rpc = { path = "../../rpc" }
1818

1919
# substrate deps
20-
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
21-
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.37" }
22-
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
23-
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
24-
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
25-
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
26-
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
27-
sp-rpc = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
28-
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
20+
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
21+
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" }
22+
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
23+
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
24+
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
25+
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
26+
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
27+
sp-rpc = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
28+
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }

balances-tx-payment/rpc/runtime-api/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ encointer-primitives = { path = "../../../primitives", default-features = false
1010

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

1717
[features]
1818
default = ["std"]

balances-tx-payment/rpc/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ use sp_api::{Decode, Encode, ProvideRuntimeApi};
3131
use sp_blockchain::HeaderBackend;
3232
use sp_core::Bytes;
3333
use sp_rpc::number::NumberOrHex;
34-
use sp_runtime::{
35-
generic::BlockId,
36-
traits::{Block as BlockT, MaybeDisplay},
37-
};
34+
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};
3835
use std::sync::Arc;
3936

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

9693
let encoded_len = encoded_xt.len() as u32;
9794

@@ -102,7 +99,7 @@ where
10299
Some(format!("{e:?}")),
103100
))
104101
})?;
105-
let fee_details = api.query_fee_details(&at, uxt, encoded_len).map_err(|e| {
102+
let fee_details = api.query_fee_details(at, uxt, encoded_len).map_err(|e| {
106103
CallError::Custom(ErrorObject::owned(
107104
Error::RuntimeError.into(),
108105
"Unable to query fee details.",
@@ -123,7 +120,7 @@ where
123120
Ok(FeeDetails {
124121
inclusion_fee: if let Some(inclusion_fee) = fee_details.inclusion_fee {
125122
let base_fee = api
126-
.balance_to_asset_balance(&at, inclusion_fee.base_fee, asset_id)
123+
.balance_to_asset_balance(at, inclusion_fee.base_fee, asset_id)
127124
.map_err(|e| {
128125
runtime_api_error_into_rpc_error(e, "Unable to query fee details")
129126
})?
@@ -132,7 +129,7 @@ where
132129
})?;
133130

134131
let len_fee = api
135-
.balance_to_asset_balance(&at, inclusion_fee.len_fee, asset_id)
132+
.balance_to_asset_balance(at, inclusion_fee.len_fee, asset_id)
136133
.map_err(|e| {
137134
runtime_api_error_into_rpc_error(e, "Unable to query fee details")
138135
})?
@@ -141,7 +138,7 @@ where
141138
})?;
142139

143140
let adjusted_weight_fee = api
144-
.balance_to_asset_balance(&at, inclusion_fee.adjusted_weight_fee, asset_id)
141+
.balance_to_asset_balance(at, inclusion_fee.adjusted_weight_fee, asset_id)
145142
.map_err(|e| {
146143
runtime_api_error_into_rpc_error(e, "Unable to query fee details")
147144
})?

balances-tx-payment/src/balance_conversion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use crate::{AssetBalanceOf, AssetIdOf, BalanceOf};
1818
use core::marker::PhantomData;
1919
use encointer_primitives::{balances::EncointerBalanceConverter, communities::CommunityIdentifier};
20-
use frame_support::traits::tokens::BalanceConversion;
20+
use frame_support::traits::tokens::ConversionToAssetBalance;
2121
use pallet_encointer_balances::Pallet as BalancesPallet;
2222
use pallet_encointer_ceremonies::{Config as CeremoniesConfig, Pallet as CeremoniesPallet};
2323
use sp_runtime::traits::Convert;
@@ -52,7 +52,7 @@ pub fn apply_fee_conversion_factor(
5252

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

55-
impl<T> BalanceConversion<BalanceOf<T>, AssetIdOf<T>, AssetBalanceOf<T>>
55+
impl<T> ConversionToAssetBalance<BalanceOf<T>, AssetIdOf<T>, AssetBalanceOf<T>>
5656
for BalanceToCommunityBalance<T>
5757
where
5858
T: CeremoniesConfig + pallet_asset_tx_payment::Config,

balances-tx-payment/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ impl<T> HandleCredit<<T as frame_system::Config>::AccountId, pallet_encointer_ba
4343
for BurnCredit
4444
where
4545
T: frame_system::Config + pallet_encointer_balances::Config,
46+
pallet_encointer_balances::Pallet<T>:
47+
frame_support::traits::fungibles::Balanced<<T as frame_system::Config>::AccountId>,
4648
{
4749
fn handle_credit(
48-
_credit: fungibles::CreditOf<AccountIdOf<T>, pallet_encointer_balances::Pallet<T>>,
50+
_credit: fungibles::Credit<AccountIdOf<T>, pallet_encointer_balances::Pallet<T>>,
4951
) {
5052
// just doing nothing with the credit, will use the default implementation
5153
// of fungibles an decrease total issuance.

balances/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ scale-info = { version = "2.0.1", default-features = false }
1414
encointer-primitives = { path = "../primitives", default-features = false }
1515

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

2525

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

3131
[features]

balances/src/impl_fungibles.rs

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,12 @@
1515
// along with Encointer. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use super::*;
18-
use encointer_primitives::{balances::EncointerBalanceConverter, common::UnboundedPalletString};
19-
use frame_support::{
20-
inherent::Vec,
21-
traits::tokens::{DepositConsequence, WithdrawConsequence},
18+
use encointer_primitives::balances::EncointerBalanceConverter;
19+
use frame_support::traits::tokens::{
20+
DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence,
2221
};
2322
use sp_runtime::traits::{Convert, Zero};
2423

25-
// Implementation of this trait is just to satisfy the trait bounds of the
26-
// `pallet-asset-tx-payment`. It is not used in our case.
27-
impl<T: Config> fungibles::InspectMetadata<T::AccountId> for Pallet<T> {
28-
fn name(_asset: &Self::AssetId) -> Vec<u8> {
29-
UnboundedPalletString::from("Encointer").into()
30-
}
31-
32-
fn symbol(_asset: &Self::AssetId) -> Vec<u8> {
33-
UnboundedPalletString::from("ETR").into()
34-
}
35-
36-
fn decimals(_asset: &Self::AssetId) -> u8 {
37-
// Our BalanceType is I64F64 which is base2 fixpoint and therefore doesn't use decimals (which would be base10 fixpoint)
38-
// but in order to comply with this trait we need to define decimals nevertheless.
39-
// the smallest possible number is 2^-64 = 5.42101086242752217003726400434970855712890625 × 10^-20
40-
// and an upper bound is 2^63 + 1 = 9.223372036854775809 × 10^18
41-
// so we chose 18 decimals and lose some precision but can prevent overflows that way.
42-
// due to demurrage, that lost precision is meaningless anyway
43-
18u8
44-
}
45-
}
46-
4724
pub(crate) fn fungible(balance: BalanceType) -> u128 {
4825
EncointerBalanceConverter::convert(balance)
4926
}
@@ -72,10 +49,15 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
7249
fungible(Pallet::<T>::balance(asset, who))
7350
}
7451

52+
fn total_balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
53+
fungible(Pallet::<T>::balance(asset, who))
54+
}
55+
7556
fn reducible_balance(
7657
asset: Self::AssetId,
7758
who: &T::AccountId,
78-
_keep_alive: bool,
59+
_preservation: Preservation,
60+
_force: Fortitude,
7961
) -> Self::Balance {
8062
fungible(Pallet::<T>::balance(asset, who))
8163
}
@@ -84,7 +66,7 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
8466
asset: Self::AssetId,
8567
who: &T::AccountId,
8668
amount: Self::Balance,
87-
_mint: bool,
69+
_mint: Provenance,
8870
) -> DepositConsequence {
8971
if !<TotalIssuance<T>>::contains_key(asset) {
9072
return DepositConsequence::UnknownAsset
@@ -129,25 +111,25 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
129111
let balance = fungible(Pallet::<T>::balance(asset, who));
130112

131113
if balance.checked_sub(amount).is_none() {
132-
return NoFunds
114+
return WithdrawConsequence::BalanceLow
133115
}
134-
Success
116+
WithdrawConsequence::Success
135117
}
136118
}
137119

138120
impl<T: Config> fungibles::Unbalanced<T::AccountId> for Pallet<T> {
139-
fn set_balance(
121+
fn write_balance(
140122
asset: Self::AssetId,
141123
who: &T::AccountId,
142124
amount: Self::Balance,
143-
) -> DispatchResult {
125+
) -> Result<Option<Self::Balance>, sp_runtime::DispatchError> {
144126
let current_block = frame_system::Pallet::<T>::block_number();
145127
<Balance<T>>::insert(
146128
asset,
147129
who,
148130
BalanceEntry { principal: balance_type(amount), last_update: current_block },
149131
);
150-
Ok(())
132+
Ok(None)
151133
}
152134

153135
fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance) {
@@ -157,4 +139,5 @@ impl<T: Config> fungibles::Unbalanced<T::AccountId> for Pallet<T> {
157139
BalanceEntry { principal: balance_type(amount), last_update: current_block },
158140
);
159141
}
142+
fn handle_dust(_: fungibles::Dust<T::AccountId, Self>) {}
160143
}

balances/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pub mod pallet {
6262
use frame_system::pallet_prelude::*;
6363

6464
#[pallet::pallet]
65-
#[pallet::generate_store(pub(super) trait Store)]
6665
pub struct Pallet<T>(PhantomData<T>);
6766

6867
#[pallet::config]

0 commit comments

Comments
 (0)