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

Commit 2590cd2

Browse files
committed
MERGE
* master: Pass through `runtime-benchmark` feature (#6110) Properly migrate weights to v2 (#6091) Buffered connection management for collator-protocol (#6022) Add unknown words (#6105) Batch vote import in dispute-distribution (#5894) Bump lru from 0.7.8 to 0.8.0 (#6060) Keep sessions in window for the full unfinalized chain (#6054)
2 parents ac54856 + df4a1c3 commit 2590cd2

File tree

53 files changed

+3327
-687
lines changed

Some content is hidden

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

53 files changed

+3327
-687
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ maintenance = { status = "actively-developed" }
125125
#
126126
# This list is ordered alphabetically.
127127
[profile.dev.package]
128-
blake2b_simd = { opt-level = 3 }
129128
blake2 = { opt-level = 3 }
130129
blake2-rfc = { opt-level = 3 }
130+
blake2b_simd = { opt-level = 3 }
131131
chacha20poly1305 = { opt-level = 3 }
132132
cranelift-codegen = { opt-level = 3 }
133133
cranelift-wasm = { opt-level = 3 }
@@ -138,8 +138,8 @@ curve25519-dalek = { opt-level = 3 }
138138
ed25519-dalek = { opt-level = 3 }
139139
flate2 = { opt-level = 3 }
140140
futures-channel = { opt-level = 3 }
141-
hashbrown = { opt-level = 3 }
142141
hash-db = { opt-level = 3 }
142+
hashbrown = { opt-level = 3 }
143143
hmac = { opt-level = 3 }
144144
httparse = { opt-level = 3 }
145145
integer-sqrt = { opt-level = 3 }
@@ -151,8 +151,8 @@ libz-sys = { opt-level = 3 }
151151
mio = { opt-level = 3 }
152152
nalgebra = { opt-level = 3 }
153153
num-bigint = { opt-level = 3 }
154-
parking_lot_core = { opt-level = 3 }
155154
parking_lot = { opt-level = 3 }
155+
parking_lot_core = { opt-level = 3 }
156156
percent-encoding = { opt-level = 3 }
157157
primitive-types = { opt-level = 3 }
158158
reed-solomon-novelpoly = { opt-level = 3 }
@@ -162,6 +162,7 @@ sha2 = { opt-level = 3 }
162162
sha3 = { opt-level = 3 }
163163
smallvec = { opt-level = 3 }
164164
snow = { opt-level = 3 }
165+
substrate-bip39 = {opt-level = 3}
165166
twox-hash = { opt-level = 3 }
166167
uint = { opt-level = 3 }
167168
wasmi = { opt-level = 3 }

cli/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ cli = [
5656
"polkadot-client",
5757
"polkadot-node-core-pvf",
5858
]
59-
runtime-benchmarks = ["service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks"]
59+
runtime-benchmarks = [
60+
"service/runtime-benchmarks",
61+
"polkadot-node-metrics/runtime-benchmarks",
62+
"polkadot-performance-test?/runtime-benchmarks"
63+
]
6064
trie-memory-tracker = ["sp-trie/memory-tracker"]
6165
full-node = ["service/full-node"]
6266
try-runtime = ["service/try-runtime"]

node/core/approval-voting/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ futures-timer = "3.0.2"
1010
parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] }
1111
gum = { package = "tracing-gum", path = "../../gum" }
1212
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
13-
lru = "0.7"
13+
lru = "0.8"
1414
merlin = "2.0"
1515
schnorrkel = "0.9.1"
1616
kvdb = "0.11.0"

node/core/approval-voting/src/import.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,38 @@ pub(crate) mod tests {
12961296
}
12971297
);
12981298

1299+
// Caching of sesssions needs sessoion of first unfinalied block.
1300+
assert_matches!(
1301+
handle.recv().await,
1302+
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
1303+
s_tx,
1304+
)) => {
1305+
let _ = s_tx.send(Ok(header.number));
1306+
}
1307+
);
1308+
1309+
assert_matches!(
1310+
handle.recv().await,
1311+
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
1312+
block_number,
1313+
s_tx,
1314+
)) => {
1315+
assert_eq!(block_number, header.number);
1316+
let _ = s_tx.send(Ok(Some(header.hash())));
1317+
}
1318+
);
1319+
1320+
assert_matches!(
1321+
handle.recv().await,
1322+
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
1323+
h,
1324+
RuntimeApiRequest::SessionIndexForChild(s_tx),
1325+
)) => {
1326+
assert_eq!(h, header.hash());
1327+
let _ = s_tx.send(Ok(session));
1328+
}
1329+
);
1330+
12991331
// determine_new_blocks exits early as the parent_hash is in the DB
13001332

13011333
assert_matches!(

node/core/approval-voting/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ use std::{
7070
collections::{
7171
btree_map::Entry as BTMEntry, hash_map::Entry as HMEntry, BTreeMap, HashMap, HashSet,
7272
},
73+
num::NonZeroUsize,
7374
sync::Arc,
7475
time::Duration,
7576
};
@@ -104,7 +105,11 @@ const APPROVAL_CHECKING_TIMEOUT: Duration = Duration::from_secs(120);
104105
/// Value rather arbitrarily: Should not be hit in practice, it exists to more easily diagnose dead
105106
/// lock issues for example.
106107
const WAIT_FOR_SIGS_TIMEOUT: Duration = Duration::from_millis(500);
107-
const APPROVAL_CACHE_SIZE: usize = 1024;
108+
const APPROVAL_CACHE_SIZE: NonZeroUsize = match NonZeroUsize::new(1024) {
109+
Some(cap) => cap,
110+
None => panic!("Approval cache size must be non-zero."),
111+
};
112+
108113
const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
109114
const APPROVAL_DELAY: Tick = 2;
110115
const LOG_TARGET: &str = "parachain::approval-voting";

node/core/approval-voting/src/tests.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,37 @@ async fn import_block(
807807
}
808808
);
809809

810+
assert_matches!(
811+
overseer_recv(overseer).await,
812+
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
813+
s_tx,
814+
)) => {
815+
let _ = s_tx.send(Ok(number));
816+
}
817+
);
818+
819+
assert_matches!(
820+
overseer_recv(overseer).await,
821+
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
822+
block_number,
823+
s_tx,
824+
)) => {
825+
assert_eq!(block_number, number);
826+
let _ = s_tx.send(Ok(Some(hashes[number as usize].0)));
827+
}
828+
);
829+
830+
assert_matches!(
831+
overseer_recv(overseer).await,
832+
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
833+
h,
834+
RuntimeApiRequest::SessionIndexForChild(s_tx),
835+
)) => {
836+
assert_eq!(h, hashes[number as usize].0);
837+
let _ = s_tx.send(Ok(number.into()));
838+
}
839+
);
840+
810841
if !fork {
811842
assert_matches!(
812843
overseer_recv(overseer).await,

node/core/dispute-coordinator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gum = { package = "tracing-gum", path = "../../gum" }
1010
parity-scale-codec = "3.1.5"
1111
kvdb = "0.11.0"
1212
thiserror = "1.0.31"
13-
lru = "0.7.7"
13+
lru = "0.8.0"
1414
fatality = "0.0.6"
1515

1616
polkadot-primitives = { path = "../../../primitives" }

node/core/dispute-coordinator/src/scraping/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use std::collections::{BTreeMap, HashSet};
17+
use std::{
18+
collections::{BTreeMap, HashSet},
19+
num::NonZeroUsize,
20+
};
1821

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

4955
/// Chain scraper
5056
///

node/core/dispute-coordinator/src/tests.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,15 @@ impl TestState {
239239
)))
240240
.await;
241241

242-
self.handle_sync_queries(virtual_overseer, block_hash, session).await;
242+
self.handle_sync_queries(virtual_overseer, block_hash, block_number, session)
243+
.await;
243244
}
244245

245246
async fn handle_sync_queries(
246247
&mut self,
247248
virtual_overseer: &mut VirtualOverseer,
248249
block_hash: Hash,
250+
block_number: BlockNumber,
249251
session: SessionIndex,
250252
) {
251253
// Order of messages is not fixed (different on initializing):
@@ -278,11 +280,45 @@ impl TestState {
278280
finished_steps.got_session_information = true;
279281
assert_eq!(h, block_hash);
280282
let _ = tx.send(Ok(session));
283+
284+
// Queries for fetching earliest unfinalized block session. See `RollingSessionWindow`.
285+
assert_matches!(
286+
overseer_recv(virtual_overseer).await,
287+
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
288+
s_tx,
289+
)) => {
290+
let _ = s_tx.send(Ok(block_number));
291+
}
292+
);
293+
294+
assert_matches!(
295+
overseer_recv(virtual_overseer).await,
296+
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
297+
number,
298+
s_tx,
299+
)) => {
300+
assert_eq!(block_number, number);
301+
let _ = s_tx.send(Ok(Some(block_hash)));
302+
}
303+
);
304+
305+
assert_matches!(
306+
overseer_recv(virtual_overseer).await,
307+
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
308+
h,
309+
RuntimeApiRequest::SessionIndexForChild(s_tx),
310+
)) => {
311+
assert_eq!(h, block_hash);
312+
let _ = s_tx.send(Ok(session));
313+
}
314+
);
315+
281316
// No queries, if subsystem knows about this session already.
282317
if self.known_session == Some(session) {
283318
continue
284319
}
285320
self.known_session = Some(session);
321+
286322
loop {
287323
// answer session info queries until the current session is reached.
288324
assert_matches!(
@@ -361,7 +397,8 @@ impl TestState {
361397
)))
362398
.await;
363399

364-
self.handle_sync_queries(virtual_overseer, *leaf, session).await;
400+
self.handle_sync_queries(virtual_overseer, *leaf, n as BlockNumber, session)
401+
.await;
365402
}
366403
}
367404

0 commit comments

Comments
 (0)