mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 13:48:00 +00:00
polkadot: pin one block per session (#1220)
* polkadot: propagate UnpinHandle to ActiveLeafUpdate Also extract the leaf creation for tests into a common function. * dispute-coordinator: try pinned blocks for slashin * apparently 1.72 is smarter than 1.70 * address nits * rename fresh_leaf to new_leaf
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use self::test_helpers::mock::new_leaf;
|
||||
use super::*;
|
||||
use ::test_helpers::{
|
||||
dummy_candidate_receipt_bad_sig, dummy_collator, dummy_collator_signature,
|
||||
@@ -24,12 +25,11 @@ use futures::{future, Future};
|
||||
use polkadot_node_primitives::{BlockData, InvalidCandidate, SignedFullStatement, Statement};
|
||||
use polkadot_node_subsystem::{
|
||||
errors::RuntimeApiError,
|
||||
jaeger,
|
||||
messages::{
|
||||
AllMessages, CollatorProtocolMessage, RuntimeApiMessage, RuntimeApiRequest,
|
||||
ValidationFailed,
|
||||
},
|
||||
ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, TimeoutExt,
|
||||
ActiveLeavesUpdate, FromOrchestra, OverseerSignal, TimeoutExt,
|
||||
};
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
use polkadot_primitives::{
|
||||
@@ -234,12 +234,7 @@ async fn test_startup(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
|
||||
// Start work on some new parent.
|
||||
virtual_overseer
|
||||
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(
|
||||
ActivatedLeaf {
|
||||
hash: test_state.relay_parent,
|
||||
number: 1,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
},
|
||||
new_leaf(test_state.relay_parent, 1),
|
||||
))))
|
||||
.await;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use polkadot_node_subsystem::{
|
||||
messages::{ChainApiMessage, FragmentTreeMembership},
|
||||
TimeoutExt,
|
||||
ActivatedLeaf, TimeoutExt,
|
||||
};
|
||||
use polkadot_primitives::{vstaging as vstaging_primitives, BlockNumber, Header, OccupiedCore};
|
||||
|
||||
@@ -346,12 +346,7 @@ fn seconding_sanity_check_allowed() {
|
||||
// `a` is grandparent of `b`.
|
||||
let leaf_a_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_a_parent = get_parent_hash(leaf_a_hash);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_a_hash,
|
||||
number: LEAF_A_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -359,12 +354,7 @@ fn seconding_sanity_check_allowed() {
|
||||
const LEAF_B_ANCESTRY_LEN: BlockNumber = 4;
|
||||
|
||||
let leaf_b_hash = Hash::from_low_u64_be(128);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_b_hash,
|
||||
number: LEAF_B_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_b_hash, LEAF_B_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_B_BLOCK_NUMBER - LEAF_B_ANCESTRY_LEN)];
|
||||
let test_leaf_b = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -503,24 +493,14 @@ fn seconding_sanity_check_disallowed() {
|
||||
// `a` is grandparent of `b`.
|
||||
let leaf_a_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_a_parent = get_parent_hash(leaf_a_hash);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_a_hash,
|
||||
number: LEAF_A_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
const LEAF_B_BLOCK_NUMBER: BlockNumber = LEAF_A_BLOCK_NUMBER + 2;
|
||||
const LEAF_B_ANCESTRY_LEN: BlockNumber = 4;
|
||||
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_b_hash,
|
||||
number: LEAF_B_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_b_hash, LEAF_B_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_B_BLOCK_NUMBER - LEAF_B_ANCESTRY_LEN)];
|
||||
let test_leaf_b = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -722,12 +702,7 @@ fn prospective_parachains_reject_candidate() {
|
||||
|
||||
let leaf_a_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_a_parent = get_parent_hash(leaf_a_hash);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_a_hash,
|
||||
number: LEAF_A_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -905,12 +880,7 @@ fn second_multiple_candidates_per_relay_parent() {
|
||||
let leaf_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_parent = get_parent_hash(leaf_hash);
|
||||
let leaf_grandparent = get_parent_hash(leaf_parent);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_hash,
|
||||
number: LEAF_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -1046,12 +1016,7 @@ fn backing_works() {
|
||||
|
||||
let leaf_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_parent = get_parent_hash(leaf_hash);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_hash,
|
||||
number: LEAF_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -1212,12 +1177,7 @@ fn concurrent_dependent_candidates() {
|
||||
let leaf_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_parent = get_parent_hash(leaf_hash);
|
||||
let leaf_grandparent = get_parent_hash(leaf_parent);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_hash,
|
||||
number: LEAF_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
@@ -1458,12 +1418,7 @@ fn seconding_sanity_check_occupy_same_depth() {
|
||||
let leaf_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_parent = get_parent_hash(leaf_hash);
|
||||
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_hash,
|
||||
number: LEAF_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
|
||||
|
||||
let min_block_number = LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN;
|
||||
let min_relay_parents = vec![(para_id_a, min_block_number), (para_id_b, min_block_number)];
|
||||
@@ -1617,12 +1572,7 @@ fn occupied_core_assignment() {
|
||||
|
||||
let leaf_a_hash = Hash::from_low_u64_be(130);
|
||||
let leaf_a_parent = get_parent_hash(leaf_a_hash);
|
||||
let activated = ActivatedLeaf {
|
||||
hash: leaf_a_hash,
|
||||
number: LEAF_A_BLOCK_NUMBER,
|
||||
status: LeafStatus::Fresh,
|
||||
span: Arc::new(jaeger::Span::Disabled),
|
||||
};
|
||||
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
|
||||
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
|
||||
let test_leaf_a = TestLeaf { activated, min_relay_parents };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user