Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 634ed48

Browse files
committed
Merge branch 'master' into anton/webrtc-transport
2 parents 27ef6c9 + cb450b6 commit 634ed48

File tree

47 files changed

+4237
-3032
lines changed

Some content is hidden

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

47 files changed

+4237
-3032
lines changed

bin/node/inspect/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ use sp_blockchain::HeaderBackend;
3333
use sp_core::hexdisplay::HexDisplay;
3434
use sp_runtime::{
3535
generic::BlockId,
36-
traits::{Block, Hash, HashFor, NumberFor},
36+
traits::{Block, Hash, HashingFor, NumberFor},
3737
};
3838
use std::{fmt, fmt::Debug, marker::PhantomData, str::FromStr};
3939

4040
/// A helper type for a generic block input.
4141
pub type BlockAddressFor<TBlock> =
42-
BlockAddress<<HashFor<TBlock> as Hash>::Output, NumberFor<TBlock>>;
42+
BlockAddress<<HashingFor<TBlock> as Hash>::Output, NumberFor<TBlock>>;
4343

4444
/// A Pretty formatter implementation.
4545
pub trait PrettyPrinter<TBlock: Block> {
@@ -166,7 +166,7 @@ impl<TBlock: Block, TPrinter: PrettyPrinter<TBlock>> Inspector<TBlock, TPrinter>
166166
/// Get a pretty-printed extrinsic.
167167
pub fn extrinsic(
168168
&self,
169-
input: ExtrinsicAddress<<HashFor<TBlock> as Hash>::Output, NumberFor<TBlock>>,
169+
input: ExtrinsicAddress<<HashingFor<TBlock> as Hash>::Output, NumberFor<TBlock>>,
170170
) -> Result<String, Error> {
171171
struct ExtrinsicPrinter<'a, A: Block, B>(A::Extrinsic, &'a B);
172172
impl<'a, A: Block, B: PrettyPrinter<A>> fmt::Display for ExtrinsicPrinter<'a, A, B> {

bin/node/rpc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ where
125125
P: TransactionPool + 'static,
126126
SC: SelectChain<Block> + 'static,
127127
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
128-
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
128+
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashingFor<Block>>,
129129
{
130130
use mmr_rpc::{Mmr, MmrApiServer};
131131
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};

bin/node/runtime/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,9 +1145,11 @@ impl pallet_asset_rate::Config for Runtime {
11451145
type UpdateOrigin = EnsureRoot<AccountId>;
11461146
type Balance = Balance;
11471147
type Currency = Balances;
1148-
type AssetId = u32;
1148+
type AssetKind = u32;
11491149
type RuntimeEvent = RuntimeEvent;
11501150
type WeightInfo = pallet_asset_rate::weights::SubstrateWeight<Runtime>;
1151+
#[cfg(feature = "runtime-benchmarks")]
1152+
type BenchmarkHelper = ();
11511153
}
11521154

11531155
parameter_types! {
@@ -1223,6 +1225,7 @@ parameter_types! {
12231225
pub const DepositPerByte: Balance = deposit(0, 1);
12241226
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
12251227
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
1228+
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
12261229
}
12271230

12281231
impl pallet_contracts::Config for Runtime {
@@ -1255,6 +1258,8 @@ impl pallet_contracts::Config for Runtime {
12551258
type Migrations = ();
12561259
#[cfg(feature = "runtime-benchmarks")]
12571260
type Migrations = (NoopMigration<1>, NoopMigration<2>);
1261+
type MaxDelegateDependencies = ConstU32<32>;
1262+
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
12581263
}
12591264

12601265
impl pallet_sudo::Config for Runtime {

client/api/src/backend.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use parking_lot::RwLock;
2525
use sp_consensus::BlockOrigin;
2626
use sp_core::offchain::OffchainStorage;
2727
use sp_runtime::{
28-
traits::{Block as BlockT, HashFor, NumberFor},
28+
traits::{Block as BlockT, HashingFor, NumberFor},
2929
Justification, Justifications, StateVersion, Storage,
3030
};
3131
use sp_state_machine::{
@@ -42,7 +42,7 @@ pub use sp_state_machine::{Backend as StateBackend, KeyValueStates};
4242
pub type StateBackendFor<B, Block> = <B as Backend<Block>>::State;
4343

4444
/// Extracts the transaction for the given state backend.
45-
pub type TransactionForSB<B, Block> = <B as StateBackend<HashFor<Block>>>::Transaction;
45+
pub type TransactionForSB<B, Block> = <B as StateBackend<HashingFor<Block>>>::Transaction;
4646

4747
/// Extracts the transaction for the given backend.
4848
pub type TransactionFor<B, Block> = TransactionForSB<StateBackendFor<B, Block>, Block>;
@@ -161,7 +161,7 @@ impl NewBlockState {
161161
/// Keeps hold if the inserted block state and data.
162162
pub trait BlockImportOperation<Block: BlockT> {
163163
/// Associated state backend type.
164-
type State: StateBackend<HashFor<Block>>;
164+
type State: StateBackend<HashingFor<Block>>;
165165

166166
/// Returns pending state.
167167
///
@@ -315,16 +315,16 @@ pub trait AuxStore {
315315
/// An `Iterator` that iterates keys in a given block under a prefix.
316316
pub struct KeysIter<State, Block>
317317
where
318-
State: StateBackend<HashFor<Block>>,
318+
State: StateBackend<HashingFor<Block>>,
319319
Block: BlockT,
320320
{
321-
inner: <State as StateBackend<HashFor<Block>>>::RawIter,
321+
inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
322322
state: State,
323323
}
324324

325325
impl<State, Block> KeysIter<State, Block>
326326
where
327-
State: StateBackend<HashFor<Block>>,
327+
State: StateBackend<HashingFor<Block>>,
328328
Block: BlockT,
329329
{
330330
/// Create a new iterator over storage keys.
@@ -361,7 +361,7 @@ where
361361
impl<State, Block> Iterator for KeysIter<State, Block>
362362
where
363363
Block: BlockT,
364-
State: StateBackend<HashFor<Block>>,
364+
State: StateBackend<HashingFor<Block>>,
365365
{
366366
type Item = StorageKey;
367367

@@ -373,17 +373,17 @@ where
373373
/// An `Iterator` that iterates keys and values in a given block under a prefix.
374374
pub struct PairsIter<State, Block>
375375
where
376-
State: StateBackend<HashFor<Block>>,
376+
State: StateBackend<HashingFor<Block>>,
377377
Block: BlockT,
378378
{
379-
inner: <State as StateBackend<HashFor<Block>>>::RawIter,
379+
inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
380380
state: State,
381381
}
382382

383383
impl<State, Block> Iterator for PairsIter<State, Block>
384384
where
385385
Block: BlockT,
386-
State: StateBackend<HashFor<Block>>,
386+
State: StateBackend<HashingFor<Block>>,
387387
{
388388
type Item = (StorageKey, StorageData);
389389

@@ -397,7 +397,7 @@ where
397397

398398
impl<State, Block> PairsIter<State, Block>
399399
where
400-
State: StateBackend<HashFor<Block>>,
400+
State: StateBackend<HashingFor<Block>>,
401401
Block: BlockT,
402402
{
403403
/// Create a new iterator over storage key and value pairs.
@@ -506,11 +506,11 @@ pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
506506
/// Associated blockchain backend type.
507507
type Blockchain: BlockchainBackend<Block>;
508508
/// Associated state backend type.
509-
type State: StateBackend<HashFor<Block>>
509+
type State: StateBackend<HashingFor<Block>>
510510
+ Send
511511
+ AsTrieBackend<
512-
HashFor<Block>,
513-
TrieBackendStorage = <Self::State as StateBackend<HashFor<Block>>>::TrieBackendStorage,
512+
HashingFor<Block>,
513+
TrieBackendStorage = <Self::State as StateBackend<HashingFor<Block>>>::TrieBackendStorage,
514514
>;
515515
/// Offchain workers local storage.
516516
type OffchainStorage: OffchainStorage;

client/api/src/in_mem.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use sp_core::{
2525
};
2626
use sp_runtime::{
2727
generic::BlockId,
28-
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor, Zero},
28+
traits::{Block as BlockT, HashingFor, Header as HeaderT, NumberFor, Zero},
2929
Justification, Justifications, StateVersion, Storage,
3030
};
3131
use sp_state_machine::{
@@ -479,9 +479,10 @@ impl<Block: BlockT> backend::AuxStore for Blockchain<Block> {
479479
/// In-memory operation.
480480
pub struct BlockImportOperation<Block: BlockT> {
481481
pending_block: Option<PendingBlock<Block>>,
482-
old_state: InMemoryBackend<HashFor<Block>>,
483-
new_state:
484-
Option<<InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction>,
482+
old_state: InMemoryBackend<HashingFor<Block>>,
483+
new_state: Option<
484+
<InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
485+
>,
485486
aux: Vec<(Vec<u8>, Option<Vec<u8>>)>,
486487
finalized_blocks: Vec<(Block::Hash, Option<Justification>)>,
487488
set_head: Option<Block::Hash>,
@@ -517,7 +518,7 @@ impl<Block: BlockT> BlockImportOperation<Block> {
517518
}
518519

519520
impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperation<Block> {
520-
type State = InMemoryBackend<HashFor<Block>>;
521+
type State = InMemoryBackend<HashingFor<Block>>;
521522

522523
fn state(&self) -> sp_blockchain::Result<Option<&Self::State>> {
523524
Ok(Some(&self.old_state))
@@ -539,7 +540,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
539540

540541
fn update_db_storage(
541542
&mut self,
542-
update: <InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction,
543+
update: <InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
543544
) -> sp_blockchain::Result<()> {
544545
self.new_state = Some(update);
545546
Ok(())
@@ -606,7 +607,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
606607
/// > **Warning**: Doesn't support all the features necessary for a proper database. Only use this
607608
/// > struct for testing purposes. Do **NOT** use in production.
608609
pub struct Backend<Block: BlockT> {
609-
states: RwLock<HashMap<Block::Hash, InMemoryBackend<HashFor<Block>>>>,
610+
states: RwLock<HashMap<Block::Hash, InMemoryBackend<HashingFor<Block>>>>,
610611
blockchain: Blockchain<Block>,
611612
import_lock: RwLock<()>,
612613
pinned_blocks: RwLock<HashMap<Block::Hash, i64>>,
@@ -661,7 +662,7 @@ impl<Block: BlockT> backend::AuxStore for Backend<Block> {
661662
impl<Block: BlockT> backend::Backend<Block> for Backend<Block> {
662663
type BlockImportOperation = BlockImportOperation<Block>;
663664
type Blockchain = Blockchain<Block>;
664-
type State = InMemoryBackend<HashFor<Block>>;
665+
type State = InMemoryBackend<HashingFor<Block>>;
665666
type OffchainStorage = OffchainStorage;
666667

667668
fn begin_operation(&self) -> sp_blockchain::Result<Self::BlockImportOperation> {

client/basic-authorship/src/basic_authorship.rs

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ where
304304
.propose_with(inherent_data, inherent_digests, deadline, block_size_limit)
305305
.await;
306306
if tx.send(res).is_err() {
307-
trace!(target: LOG_TARGET, "Could not send block production result to proposer!");
307+
trace!(
308+
target: LOG_TARGET,
309+
"Could not send block production result to proposer!"
310+
);
308311
}
309312
}),
310313
);
@@ -384,7 +387,10 @@ where
384387
for inherent in inherents {
385388
match block_builder.push(inherent) {
386389
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
387-
warn!(target: LOG_TARGET, "⚠️ Dropping non-mandatory inherent from overweight block.")
390+
warn!(
391+
target: LOG_TARGET,
392+
"⚠️ Dropping non-mandatory inherent from overweight block."
393+
)
388394
},
389395
Err(ApplyExtrinsicFailed(Validity(e))) if e.was_mandatory() => {
390396
error!(
@@ -393,7 +399,10 @@ where
393399
return Err(ApplyExtrinsicFailed(Validity(e)))
394400
},
395401
Err(e) => {
396-
warn!(target: LOG_TARGET, "❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e);
402+
warn!(
403+
target: LOG_TARGET,
404+
"❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e
405+
);
397406
},
398407
Ok(_) => {},
399408
}
@@ -449,9 +458,10 @@ where
449458

450459
let now = (self.now)();
451460
if now > deadline {
452-
debug!(target: LOG_TARGET,
461+
debug!(
462+
target: LOG_TARGET,
453463
"Consensus deadline reached when pushing block transactions, \
454-
proceeding with proposing."
464+
proceeding with proposing."
455465
);
456466
break EndProposingReason::HitDeadline
457467
}
@@ -465,21 +475,26 @@ where
465475
pending_iterator.report_invalid(&pending_tx);
466476
if skipped < MAX_SKIPPED_TRANSACTIONS {
467477
skipped += 1;
468-
debug!(target: LOG_TARGET,
478+
debug!(
479+
target: LOG_TARGET,
469480
"Transaction would overflow the block size limit, \
470-
but will try {} more transactions before quitting.",
481+
but will try {} more transactions before quitting.",
471482
MAX_SKIPPED_TRANSACTIONS - skipped,
472483
);
473484
continue
474485
} else if now < soft_deadline {
475-
debug!(target: LOG_TARGET,
486+
debug!(
487+
target: LOG_TARGET,
476488
"Transaction would overflow the block size limit, \
477-
but we still have time before the soft deadline, so \
478-
we will try a bit more."
489+
but we still have time before the soft deadline, so \
490+
we will try a bit more."
479491
);
480492
continue
481493
} else {
482-
debug!(target: LOG_TARGET, "Reached block size limit, proceeding with proposing.");
494+
debug!(
495+
target: LOG_TARGET,
496+
"Reached block size limit, proceeding with proposing."
497+
);
483498
break EndProposingReason::HitBlockSizeLimit
484499
}
485500
}
@@ -504,22 +519,28 @@ where
504519
so we will try a bit more before quitting."
505520
);
506521
} else {
507-
debug!(target: LOG_TARGET, "Reached block weight limit, proceeding with proposing.");
522+
debug!(
523+
target: LOG_TARGET,
524+
"Reached block weight limit, proceeding with proposing."
525+
);
508526
break EndProposingReason::HitBlockWeightLimit
509527
}
510528
},
511529
Err(e) => {
512530
pending_iterator.report_invalid(&pending_tx);
513-
debug!(target: LOG_TARGET, "[{:?}] Invalid transaction: {}", pending_tx_hash, e);
531+
debug!(
532+
target: LOG_TARGET,
533+
"[{:?}] Invalid transaction: {}", pending_tx_hash, e
534+
);
514535
unqueue_invalid.push(pending_tx_hash);
515536
},
516537
}
517538
};
518539

519540
if matches!(end_reason, EndProposingReason::HitBlockSizeLimit) && !transaction_pushed {
520-
warn!(target: LOG_TARGET,
521-
"Hit block size limit of `{}` without including any transaction!",
522-
block_size_limit,
541+
warn!(
542+
target: LOG_TARGET,
543+
"Hit block size limit of `{}` without including any transaction!", block_size_limit,
523544
);
524545
}
525546

client/block-builder/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use sp_blockchain::{ApplyExtrinsicFailed, Error};
3535
use sp_core::traits::CallContext;
3636
use sp_runtime::{
3737
legacy,
38-
traits::{Block as BlockT, Hash, HashFor, Header as HeaderT, NumberFor, One},
38+
traits::{Block as BlockT, Hash, HashingFor, Header as HeaderT, NumberFor, One},
3939
Digest,
4040
};
4141

@@ -85,7 +85,7 @@ impl From<bool> for RecordProof {
8585
/// backend to get the state of the block. Furthermore an optional `proof` is included which
8686
/// can be used to proof that the build block contains the expected data. The `proof` will
8787
/// only be set when proof recording was activated.
88-
pub struct BuiltBlock<Block: BlockT, StateBackend: backend::StateBackend<HashFor<Block>>> {
88+
pub struct BuiltBlock<Block: BlockT, StateBackend: backend::StateBackend<HashingFor<Block>>> {
8989
/// The actual block that was build.
9090
pub block: Block,
9191
/// The changes that need to be applied to the backend to get the state of the build block.
@@ -94,7 +94,7 @@ pub struct BuiltBlock<Block: BlockT, StateBackend: backend::StateBackend<HashFor
9494
pub proof: Option<StorageProof>,
9595
}
9696

97-
impl<Block: BlockT, StateBackend: backend::StateBackend<HashFor<Block>>>
97+
impl<Block: BlockT, StateBackend: backend::StateBackend<HashingFor<Block>>>
9898
BuiltBlock<Block, StateBackend>
9999
{
100100
/// Convert into the inner values.
@@ -236,7 +236,7 @@ where
236236

237237
debug_assert_eq!(
238238
header.extrinsics_root().clone(),
239-
HashFor::<Block>::ordered_trie_root(
239+
HashingFor::<Block>::ordered_trie_root(
240240
self.extrinsics.iter().map(Encode::encode).collect(),
241241
sp_runtime::StateVersion::V0,
242242
),

client/consensus/common/src/block_import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
use serde::{Deserialize, Serialize};
2222
use sp_runtime::{
23-
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor},
23+
traits::{Block as BlockT, HashingFor, Header as HeaderT, NumberFor},
2424
DigestItem, Justification, Justifications,
2525
};
2626
use std::{any::Any, borrow::Cow, collections::HashMap, sync::Arc};
@@ -121,7 +121,7 @@ pub struct BlockCheckParams<Block: BlockT> {
121121
/// Precomputed storage.
122122
pub enum StorageChanges<Block: BlockT, Transaction> {
123123
/// Changes coming from block execution.
124-
Changes(sp_state_machine::StorageChanges<Transaction, HashFor<Block>>),
124+
Changes(sp_state_machine::StorageChanges<Transaction, HashingFor<Block>>),
125125
/// Whole new state.
126126
Import(ImportedState<Block>),
127127
}

0 commit comments

Comments
 (0)