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

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit e36cc59
Author: Chris Sosnin <[email protected]>
Date:   Mon Oct 10 10:06:44 2022 +0400

    Fix flaky test (#6131)

    * Split test + decrease test timeout

    * fmt

    * spellcheck

commit f85f96c
Author: girazoki <[email protected]>
Date:   Mon Oct 10 06:39:30 2022 +0200

    Add event to asset claim (#6029)

commit fb0dd8e
Author: Leszek Wiesner <[email protected]>
Date:   Mon Oct 10 00:23:54 2022 +0200

    Companion for 12109 (#5929)

    * Update following `pallet-vesting` configurable `WithdrawReasons`

    * Update lib.rs

    * Update lib.rs

    * Update lib.rs

    * update lockfile for {"substrate"}

    * fix warning

    Co-authored-by: Shawn Tabrizi <[email protected]>
    Co-authored-by: parity-processbot <>

commit 1c786b3
Author: Bastian Köcher <[email protected]>
Date:   Fri Oct 7 13:40:40 2022 +0200

    Companion for upgrading pin-project (#6118)

    * Companion for upgrading pin-project

    This will remove some warnings with the latest rustc nightly/stable.

    paritytech/substrate#12426

    * update lockfile for {"substrate"}

    Co-authored-by: parity-processbot <>

commit 3d6b563
Author: Sergej Sakac <[email protected]>
Date:   Thu Oct 6 19:20:58 2022 +0200

    Maximum value for `MultiplierUpdate` (#6021)

    * update multiplier

    * fix

    * update lockfile for {"substrate"}

    * fmt

    * fix typo

    Co-authored-by: parity-processbot <>

commit 09f340c
Author: Adrian Catangiu <[email protected]>
Date:   Thu Oct 6 12:58:39 2022 +0300

    service: use MmrRootProvider as custom BEEFY payload provider (companion for 12428) (#6112)

    * service: use MmrRootProvider as custom BEEFY payload provider

    * update lockfile for {"substrate"}

    Co-authored-by: parity-processbot <>

commit d12042f
Author: Branislav Kontur <[email protected]>
Date:   Thu Oct 6 10:03:34 2022 +0200

    Skip `unexpected metric type`

    * Dump more info for `unexpected metric type`

    * Skip `unexpected metric type`

commit 3646202
Author: Andronik <[email protected]>
Date:   Thu Oct 6 00:36:51 2022 +0200

    update kvdb & co (#6111)

    * toml changes

    * REVERTME: patch

    * adapt parachains db interface

    * fix Cargo.toml patch after master rebase

    * fix av-store

    * fix chain-selection

    * fix parachains-db?

    * Revert "fix Cargo.toml patch after master rebase"

    This reverts commit 3afcbf0.

    * Revert "REVERTME: patch"

    This reverts commit 464b717.

    * Use `Ok` imported from prelude

    Co-authored-by: Bastian Köcher <[email protected]>

    * update lockfile for {"substrate"}

    * Revert "update lockfile for {"substrate"}"

    This reverts commit fdc623d.

    * cargo update -p sp-io

    Co-authored-by: Bastian Köcher <[email protected]>
    Co-authored-by: parity-processbot <>

commit 7870daf
Author: Gavin Wood <[email protected]>
Date:   Wed Oct 5 22:17:59 2022 +0100

    Companion for #11649: Bound uses of `Call` (#5729)

    * Fixes

    * Clear out old weights

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Resolve merges

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Fix weight traits

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * polkadot runtime: Clippy

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * rococo runtime: update pallet configs

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Add preimage migration

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Add all migrations

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Democracy is not on Westend

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * [Migration] Refund stored multisig calls (#6075)

    * Add Preimages to referenda config

    Needed since Gov V2 just merged.

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Update weights

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Add multisig migration to Westend+Rococo

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Fix Executive syntax

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>

    * Bump Substrate

    Signed-off-by: Oliver Tale-Yazdi <[email protected]>
    Co-authored-by: Oliver Tale-Yazdi <[email protected]>
    Co-authored-by: parity-processbot <>
    Co-authored-by: Roman Useinov <[email protected]>

commit df4a1c3
Author: Alexander Theißen <[email protected]>
Date:   Wed Oct 5 15:15:07 2022 +0200

    Pass through `runtime-benchmark` feature (#6110)

commit 3eb61f8
Author: Keith Yeung <[email protected]>
Date:   Wed Oct 5 17:47:15 2022 +0800

    Properly migrate weights to v2 (#6091)

    * Create migration for config pallet

    * Use XcmWeight in XCM pallet extrinsics

    * Link to PR in doc comment

    * cargo fmt

    * Fix tests

    * Fix tests

    * Remove unused import

    * Update runtime/parachains/src/configuration/migration.rs

    Co-authored-by: Oliver Tale-Yazdi <[email protected]>

    * Add missing on_runtime_upgrade implementation

    * Use new migration API

    * cargo fmt

    * Fix log message

    Co-authored-by: Oliver Tale-Yazdi <[email protected]>

commit edd6499
Author: Chris Sosnin <[email protected]>
Date:   Wed Oct 5 11:48:50 2022 +0400

    Buffered connection management for collator-protocol (#6022)

    * Extract metrics into a separate module

    * Introduce validators buffer

    * Integrate buffer into the subsystem

    * Only reconnect on new advertisements

    * Test

    * comma

    * doc comment

    * Make capacity buffer compile time non-zero

    * Add doc comments

    * nits

    * remove derives

    * review

    * better naming

    * check timeout

    * Extract interval stream into lib

    * Ensure collator disconnects after timeout

    * spellcheck

    * rename buf

    * Remove double interval

    * Add a log on timeout

    * Cleanup buffer on timeout

commit c913107
Author: Robert Klotzner <[email protected]>
Date:   Tue Oct 4 18:47:52 2022 +0200

    Add unknown words (#6105)

commit ce430c2
Author: Robert Klotzner <[email protected]>
Date:   Tue Oct 4 18:02:05 2022 +0200

    Batch vote import in dispute-distribution (#5894)

    * Start work on batching in dispute-distribution.

    * Guide work.

    * More guide changes. Still very much WIP.

    * Finish guide changes.

    * Clarification

    * Adjust argument about slashing.

    * WIP: Add constants to receiver.

    * Maintain order of disputes.

    * dispute-distribuion sender Rate limit.

    * Cleanup

    * WIP: dispute-distribution receiver.

    - [ ] Rate limiting
    - [ ] Batching

    * WIP: Batching.

    * fmt

    * Update `PeerQueues` to maintain more invariants.

    * WIP: Batching.

    * Small cleanup

    * Batching logic.

    * Some integration work.

    * Finish.

    Missing: Tests

    * Typo.

    * Docs.

    * Report missing metric.

    * Doc pass.

    * Tests for waiting_queue.

    * Speed up some crypto by 10x.

    * Fix redundant import.

    * Add some tracing.

    * Better sender rate limit

    * Some tests.

    * Tests

    * Add logging to rate limiter

    * Update roadmap/implementers-guide/src/node/disputes/dispute-distribution.md

    Co-authored-by: Tsvetomir Dimitrov <[email protected]>

    * Update roadmap/implementers-guide/src/node/disputes/dispute-distribution.md

    Co-authored-by: Tsvetomir Dimitrov <[email protected]>

    * Update node/network/dispute-distribution/src/receiver/mod.rs

    Co-authored-by: Tsvetomir Dimitrov <[email protected]>

    * Review feedback.

    * Also log peer in log messages.

    * Fix indentation.

    * waker -> timer

    * Guide improvement.

    * Remove obsolete comment.

    * waker -> timer

    * Fix spell complaints.

    * Fix Cargo.lock

    Co-authored-by: Tsvetomir Dimitrov <[email protected]>

commit efb82ef
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Oct 4 11:28:21 2022 +0000

    Bump lru from 0.7.8 to 0.8.0 (#6060)

    * Bump lru from 0.7.8 to 0.8.0

    Bumps [lru](https://github.com/jeromefroe/lru-rs) from 0.7.8 to 0.8.0.
    - [Release notes](https://github.com/jeromefroe/lru-rs/releases)
    - [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md)
    - [Commits](jeromefroe/lru-rs@0.7.8...0.8.0)

    ---
    updated-dependencies:
    - dependency-name: lru
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * Change `LruCache` paramerter to `NonZeroUsize`

    * Change type of `session_cache_lru_size` to `NonZeroUsize`

    * Add expects instead of unwrap

    Co-authored-by: Bastian Köcher <[email protected]>

    * Use match to get rid of expects

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Sebastian Kunert <[email protected]>
    Co-authored-by: Bastian Köcher <[email protected]>

commit 60554e1
Author: Andrei Sandu <[email protected]>
Date:   Tue Oct 4 13:36:42 2022 +0300

    Keep sessions in window for the full unfinalized chain (#6054)

    * Impl dynamic window size. Keep sessions for unfinalized chain

    Signed-off-by: Andrei Sandu <[email protected]>

    * feedback

    Signed-off-by: Andrei Sandu <[email protected]>

    * Stretch also in contructor plus  tests

    Signed-off-by: Andrei Sandu <[email protected]>

    * review feedback

    Signed-off-by: Andrei Sandu <[email protected]>

    * fix approval-voting tests

    Signed-off-by: Andrei Sandu <[email protected]>

    * grunting: dispute coordinator tests

    Signed-off-by: Andrei Sandu <[email protected]>

    Signed-off-by: Andrei Sandu <[email protected]>

commit 4ddf0ff
Author: Serban Iorga <[email protected]>
Date:   Tue Oct 4 12:25:48 2022 +0300

    Companion for BEEFY: Simplify hashing for pallet-beefy-mmr (#6098)

    * beefy-mmr: Simplify hashing

    * update lockfile for {"substrate"}

    Co-authored-by: parity-processbot <>
  • Loading branch information
bredamatt committed Oct 10, 2022
1 parent 3ad5cec commit 5001fa5
Show file tree
Hide file tree
Showing 86 changed files with 4,285 additions and 2,058 deletions.
496 changes: 241 additions & 255 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ readme = "README.md"
[dependencies]
polkadot-cli = { path = "cli", features = [ "kusama-native", "westend-native", "rococo-native" ] }
color-eyre = { version = "0.6.1", default-features = false }
parity-util-mem = { version = "0.11.0", default-features = false, features = ["jemalloc-global"] }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["jemalloc-global"] }

[dev-dependencies]
assert_cmd = "2.0.4"
Expand Down Expand Up @@ -125,9 +125,9 @@ maintenance = { status = "actively-developed" }
#
# This list is ordered alphabetically.
[profile.dev.package]
blake2b_simd = { opt-level = 3 }
blake2 = { opt-level = 3 }
blake2-rfc = { opt-level = 3 }
blake2b_simd = { opt-level = 3 }
chacha20poly1305 = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 }
cranelift-wasm = { opt-level = 3 }
Expand All @@ -138,8 +138,8 @@ curve25519-dalek = { opt-level = 3 }
ed25519-dalek = { opt-level = 3 }
flate2 = { opt-level = 3 }
futures-channel = { opt-level = 3 }
hashbrown = { opt-level = 3 }
hash-db = { opt-level = 3 }
hashbrown = { opt-level = 3 }
hmac = { opt-level = 3 }
httparse = { opt-level = 3 }
integer-sqrt = { opt-level = 3 }
Expand All @@ -151,8 +151,8 @@ libz-sys = { opt-level = 3 }
mio = { opt-level = 3 }
nalgebra = { opt-level = 3 }
num-bigint = { opt-level = 3 }
parking_lot_core = { opt-level = 3 }
parking_lot = { opt-level = 3 }
parking_lot_core = { opt-level = 3 }
percent-encoding = { opt-level = 3 }
primitive-types = { opt-level = 3 }
reed-solomon-novelpoly = { opt-level = 3 }
Expand All @@ -162,6 +162,7 @@ sha2 = { opt-level = 3 }
sha3 = { opt-level = 3 }
smallvec = { opt-level = 3 }
snow = { opt-level = 3 }
substrate-bip39 = {opt-level = 3}
twox-hash = { opt-level = 3 }
uint = { opt-level = 3 }
wasmi = { opt-level = 3 }
Expand Down
6 changes: 5 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ cli = [
"polkadot-client",
"polkadot-node-core-pvf",
]
runtime-benchmarks = ["service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks"]
runtime-benchmarks = [
"service/runtime-benchmarks",
"polkadot-node-metrics/runtime-benchmarks",
"polkadot-performance-test?/runtime-benchmarks"
]
trie-memory-tracker = ["sp-trie/memory-tracker"]
full-node = ["service/full-node"]
try-runtime = ["service/try-runtime"]
Expand Down
2 changes: 1 addition & 1 deletion core-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
parity-scale-codec = { version = "3.1.5", default-features = false, features = [ "derive" ] }
parity-util-mem = { version = "0.11.0", default-features = false, optional = true }
parity-util-mem = { version = "0.12.0", default-features = false, optional = true }

[features]
default = [ "std" ]
Expand Down
6 changes: 3 additions & 3 deletions node/core/approval-voting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ futures-timer = "3.0.2"
parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] }
gum = { package = "tracing-gum", path = "../../gum" }
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
lru = "0.7"
lru = "0.8"
merlin = "2.0"
schnorrkel = "0.9.1"
kvdb = "0.11.0"
kvdb = "0.12.0"
derive_more = "0.99.17"
thiserror = "1.0.31"

Expand All @@ -40,5 +40,5 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
assert_matches = "1.4.0"
kvdb-memorydb = "0.11.0"
kvdb-memorydb = "0.12.0"
test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" }
32 changes: 32 additions & 0 deletions node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,38 @@ pub(crate) mod tests {
}
);

// Caching of sesssions needs sessoion of first unfinalied block.
assert_matches!(
handle.recv().await,
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
s_tx,
)) => {
let _ = s_tx.send(Ok(header.number));
}
);

assert_matches!(
handle.recv().await,
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
block_number,
s_tx,
)) => {
assert_eq!(block_number, header.number);
let _ = s_tx.send(Ok(Some(header.hash())));
}
);

assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
h,
RuntimeApiRequest::SessionIndexForChild(s_tx),
)) => {
assert_eq!(h, header.hash());
let _ = s_tx.send(Ok(session));
}
);

// determine_new_blocks exits early as the parent_hash is in the DB

assert_matches!(
Expand Down
7 changes: 6 additions & 1 deletion node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use std::{
collections::{
btree_map::Entry as BTMEntry, hash_map::Entry as HMEntry, BTreeMap, HashMap, HashSet,
},
num::NonZeroUsize,
sync::Arc,
time::Duration,
};
Expand Down Expand Up @@ -104,7 +105,11 @@ const APPROVAL_CHECKING_TIMEOUT: Duration = Duration::from_secs(120);
/// Value rather arbitrarily: Should not be hit in practice, it exists to more easily diagnose dead
/// lock issues for example.
const WAIT_FOR_SIGS_TIMEOUT: Duration = Duration::from_millis(500);
const APPROVAL_CACHE_SIZE: usize = 1024;
const APPROVAL_CACHE_SIZE: NonZeroUsize = match NonZeroUsize::new(1024) {
Some(cap) => cap,
None => panic!("Approval cache size must be non-zero."),
};

const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
const APPROVAL_DELAY: Tick = 2;
const LOG_TARGET: &str = "parachain::approval-voting";
Expand Down
31 changes: 31 additions & 0 deletions node/core/approval-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,37 @@ async fn import_block(
}
);

assert_matches!(
overseer_recv(overseer).await,
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
s_tx,
)) => {
let _ = s_tx.send(Ok(number));
}
);

assert_matches!(
overseer_recv(overseer).await,
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
block_number,
s_tx,
)) => {
assert_eq!(block_number, number);
let _ = s_tx.send(Ok(Some(hashes[number as usize].0)));
}
);

assert_matches!(
overseer_recv(overseer).await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
h,
RuntimeApiRequest::SessionIndexForChild(s_tx),
)) => {
assert_eq!(h, hashes[number as usize].0);
let _ = s_tx.send(Ok(number.into()));
}
);

if !fork {
assert_matches!(
overseer_recv(overseer).await,
Expand Down
4 changes: 2 additions & 2 deletions node/core/av-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
futures = "0.3.21"
futures-timer = "3.0.2"
kvdb = "0.11.0"
kvdb = "0.12.0"
thiserror = "1.0.31"
gum = { package = "tracing-gum", path = "../../gum" }
bitvec = "1.0.0"
Expand All @@ -24,7 +24,7 @@ polkadot-node-primitives = { path = "../../primitives" }
log = "0.4.17"
env_logger = "0.9.0"
assert_matches = "1.4.0"
kvdb-memorydb = "0.11.0"
kvdb-memorydb = "0.12.0"

sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
Expand Down
28 changes: 15 additions & 13 deletions node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,9 @@ fn note_block_included(
macro_rules! peek_num {
($iter:ident) => {
match $iter.peek() {
Some((k, _)) => decode_unfinalized_key(&k[..]).ok().map(|(b, _, _)| b),
None => None,
Some(Ok((k, _))) => Ok(decode_unfinalized_key(&k[..]).ok().map(|(b, _, _)| b)),
Some(Err(_)) => Err($iter.next().expect("peek returned Some(Err); qed").unwrap_err()),
None => Ok(None),
}
};
}
Expand All @@ -819,10 +820,10 @@ async fn process_block_finalized<Context>(
let mut iter = subsystem
.db
.iter_with_prefix(subsystem.config.col_meta, &start_prefix)
.take_while(|(k, _)| &k[..] < &end_prefix[..])
.take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &end_prefix[..]))
.peekable();

match peek_num!(iter) {
match peek_num!(iter)? {
None => break, // end of iterator.
Some(n) => n,
}
Expand Down Expand Up @@ -867,10 +868,10 @@ async fn process_block_finalized<Context>(
let iter = subsystem
.db
.iter_with_prefix(subsystem.config.col_meta, &start_prefix)
.take_while(|(k, _)| &k[..] < &end_prefix[..])
.take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &end_prefix[..]))
.peekable();

let batch = load_all_at_finalized_height(iter, batch_num, batch_finalized_hash);
let batch = load_all_at_finalized_height(iter, batch_num, batch_finalized_hash)?;

// Now that we've iterated over the entire batch at this finalized height,
// update the meta.
Expand All @@ -890,22 +891,22 @@ async fn process_block_finalized<Context>(
// loads all candidates at the finalized height and maps them to `true` if finalized
// and `false` if unfinalized.
fn load_all_at_finalized_height(
mut iter: std::iter::Peekable<impl Iterator<Item = (Box<[u8]>, Box<[u8]>)>>,
mut iter: std::iter::Peekable<impl Iterator<Item = io::Result<util::database::DBKeyValue>>>,
block_number: BlockNumber,
finalized_hash: Hash,
) -> impl IntoIterator<Item = (CandidateHash, bool)> {
) -> io::Result<impl IntoIterator<Item = (CandidateHash, bool)>> {
// maps candidate hashes to true if finalized, false otherwise.
let mut candidates = HashMap::new();

// Load all candidates that were included at this height.
loop {
match peek_num!(iter) {
match peek_num!(iter)? {
None => break, // end of iterator.
Some(n) if n != block_number => break, // end of batch.
_ => {},
}

let (k, _v) = iter.next().expect("`peek` used to check non-empty; qed");
let (k, _v) = iter.next().expect("`peek` used to check non-empty; qed")?;
let (_, block_hash, candidate_hash) =
decode_unfinalized_key(&k[..]).expect("`peek_num` checks validity of key; qed");

Expand All @@ -916,7 +917,7 @@ fn load_all_at_finalized_height(
}
}

candidates
Ok(candidates)
}

fn update_blocks_at_finalized_height(
Expand Down Expand Up @@ -1214,9 +1215,10 @@ fn prune_all(db: &Arc<dyn Database>, config: &Config, clock: &dyn Clock) -> Resu
let mut tx = DBTransaction::new();
let iter = db
.iter_with_prefix(config.col_meta, &range_start[..])
.take_while(|(k, _)| &k[..] < &range_end[..]);
.take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &range_end[..]));

for (k, _v) in iter {
for r in iter {
let (k, _v) = r?;
tx.delete(config.col_meta, &k[..]);

let (_, candidate_hash) = match decode_pruning_key(&k[..]) {
Expand Down
4 changes: 2 additions & 2 deletions node/core/chain-selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ polkadot-primitives = { path = "../../../primitives" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
kvdb = "0.11.0"
kvdb = "0.12.0"
thiserror = "1.0.31"
parity-scale-codec = "3.1.5"

Expand All @@ -22,4 +22,4 @@ polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
parking_lot = "0.12.0"
assert_matches = "1"
kvdb-memorydb = "0.11.0"
kvdb-memorydb = "0.12.0"
26 changes: 17 additions & 9 deletions node/core/chain-selection/src/db_backend/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,21 @@ impl Backend for DbBackend {
self.inner.iter_with_prefix(self.config.col_data, &STAGNANT_AT_PREFIX[..]);

let val = stagnant_at_iter
.filter_map(|(k, v)| {
match (decode_stagnant_at_key(&mut &k[..]), <Vec<_>>::decode(&mut &v[..]).ok()) {
(Some(at), Some(stagnant_at)) => Some((at, stagnant_at)),
_ => None,
}
.filter_map(|r| match r {
Ok((k, v)) =>
match (decode_stagnant_at_key(&mut &k[..]), <Vec<_>>::decode(&mut &v[..]).ok())
{
(Some(at), Some(stagnant_at)) => Some(Ok((at, stagnant_at))),
_ => None,
},
Err(e) => Some(Err(e)),
})
.enumerate()
.take_while(|(idx, (at, _))| *at <= up_to.into() && *idx < max_elements)
.take_while(|(idx, r)| {
r.as_ref().map_or(true, |(at, _)| *at <= up_to.into() && *idx < max_elements)
})
.map(|(_, v)| v)
.collect::<Vec<_>>();
.collect::<Result<Vec<_>, _>>()?;

Ok(val)
}
Expand All @@ -254,10 +259,13 @@ impl Backend for DbBackend {
self.inner.iter_with_prefix(self.config.col_data, &BLOCK_HEIGHT_PREFIX[..]);

let val = blocks_at_height_iter
.filter_map(|(k, _)| decode_block_height_key(&k[..]))
.filter_map(|r| match r {
Ok((k, _)) => decode_block_height_key(&k[..]).map(Ok),
Err(e) => Some(Err(e)),
})
.next();

Ok(val)
val.transpose().map_err(Error::from)
}

fn load_blocks_by_number(&self, number: BlockNumber) -> Result<Vec<Hash>, Error> {
Expand Down
6 changes: 3 additions & 3 deletions node/core/dispute-coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ edition = "2021"
futures = "0.3.21"
gum = { package = "tracing-gum", path = "../../gum" }
parity-scale-codec = "3.1.5"
kvdb = "0.11.0"
kvdb = "0.12.0"
thiserror = "1.0.31"
lru = "0.7.7"
lru = "0.8.0"
fatality = "0.0.6"

polkadot-primitives = { path = "../../../primitives" }
Expand All @@ -22,7 +22,7 @@ sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "maste


[dev-dependencies]
kvdb-memorydb = "0.11.0"
kvdb-memorydb = "0.12.0"
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
10 changes: 8 additions & 2 deletions node/core/dispute-coordinator/src/scraping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use std::collections::{BTreeMap, HashSet};
use std::{
collections::{BTreeMap, HashSet},
num::NonZeroUsize,
};

use futures::channel::oneshot;
use lru::LruCache;
Expand Down Expand Up @@ -44,7 +47,10 @@ mod tests;
/// `last_observed_blocks` LRU. This means, this value should the very least be as large as the
/// number of expected forks for keeping chain scraping efficient. Making the LRU much larger than
/// that has very limited use.
const LRU_OBSERVED_BLOCKS_CAPACITY: usize = 20;
const LRU_OBSERVED_BLOCKS_CAPACITY: NonZeroUsize = match NonZeroUsize::new(20) {
Some(cap) => cap,
None => panic!("Observed blocks cache size must be non-zero"),
};

/// Chain scraper
///
Expand Down
Loading

0 comments on commit 5001fa5

Please sign in to comment.