Skip to content

Commit fec2790

Browse files
authored
Fix issue #11272 (#11290)
Also: - more relay_parent -> scheduling_parent fixes. - Some candidate validation cleanup (a bit less spaghetti) - Make sure we don't use the relay parent to fetch state anywhere - state might not be available now - Make sure usages of scheduling parent in disputes for fetching state are sound - Via fixing 11272: Simpler backing pipeline - no threading of node features everywhere
1 parent 8c6f760 commit fec2790

File tree

74 files changed

+4145
-2070
lines changed

Some content is hidden

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

74 files changed

+4145
-2070
lines changed

cumulus/client/relay-chain-minimal-node/src/blockchain_rpc_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
487487
Ok(self.rpc_client.parachain_host_max_relay_parent_session_age(at).await?)
488488
}
489489

490-
async fn allowed_relay_parent_info(
490+
async fn ancestor_relay_parent_info(
491491
&self,
492492
at: Hash,
493493
session_index: polkadot_primitives::SessionIndex,
@@ -498,7 +498,7 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
498498
> {
499499
Ok(self
500500
.rpc_client
501-
.parachain_host_allowed_relay_parent_info(at, session_index, relay_parent)
501+
.parachain_host_ancestor_relay_parent_info(at, session_index, relay_parent)
502502
.await?)
503503
}
504504
}

cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,14 +799,14 @@ impl RelayChainRpcClient {
799799
.await
800800
}
801801

802-
pub async fn parachain_host_allowed_relay_parent_info(
802+
pub async fn parachain_host_ancestor_relay_parent_info(
803803
&self,
804804
at: RelayHash,
805805
session_index: SessionIndex,
806806
relay_parent: RelayHash,
807807
) -> Result<Option<RelayParentInfo<RelayHash, BlockNumber>>, RelayChainError> {
808808
self.call_remote_runtime_function(
809-
"ParachainHost_allowed_relay_parent_info",
809+
"ParachainHost_ancestor_relay_parent_info",
810810
at,
811811
Some((session_index, relay_parent)),
812812
)

polkadot/node/collation-generation/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ async fn construct_and_distribute_receipt(
665665

666666
let ccr = CommittedCandidateReceiptV2 { descriptor, commitments: commitments.clone() };
667667

668-
ccr.parse_ump_signals(&transposed_claim_queue, scheduling_parent.is_some())
668+
ccr.parse_ump_signals(&transposed_claim_queue)
669669
.map_err(Error::CandidateReceiptCheck)?;
670670

671671
ccr.to_plain()

polkadot/node/collation-generation/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ fn approved_peer_signal() {
556556
assert_eq!(descriptor.persisted_validation_data_hash(), expected_pvd.hash());
557557
assert_eq!(descriptor.para_head(), dummy_head_data().hash());
558558
assert_eq!(descriptor.validation_code_hash(), validation_code_hash);
559-
assert_eq!(descriptor.version(true), CandidateDescriptorVersion::V3);
559+
assert_eq!(descriptor.version(), CandidateDescriptorVersion::V3);
560560
}
561561
);
562562

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

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -847,46 +847,22 @@ impl CurrentlyCheckingSet {
847847
}
848848
}
849849

850-
async fn get_extended_session_info<'a, Sender>(
851-
runtime_info: &'a mut RuntimeInfo,
852-
sender: &mut Sender,
853-
relay_parent: Hash,
854-
) -> Option<&'a ExtendedSessionInfo>
855-
where
856-
Sender: SubsystemSender<RuntimeApiMessage>,
857-
{
858-
match runtime_info.get_session_info(sender, relay_parent).await {
859-
Ok(extended_info) => Some(&extended_info),
860-
Err(_) => {
861-
gum::debug!(
862-
target: LOG_TARGET,
863-
?relay_parent,
864-
"Can't obtain SessionInfo or ExecutorParams"
865-
);
866-
None
867-
},
868-
}
869-
}
870-
871850
async fn get_extended_session_info_by_index<'a, Sender>(
872851
runtime_info: &'a mut RuntimeInfo,
873852
sender: &mut Sender,
874-
relay_parent: Hash,
853+
block_hash: Hash,
875854
session_index: SessionIndex,
876855
) -> Option<&'a ExtendedSessionInfo>
877856
where
878857
Sender: SubsystemSender<RuntimeApiMessage>,
879858
{
880-
match runtime_info
881-
.get_session_info_by_index(sender, relay_parent, session_index)
882-
.await
883-
{
859+
match runtime_info.get_session_info_by_index(sender, block_hash, session_index).await {
884860
Ok(extended_info) => Some(&extended_info),
885861
Err(_) => {
886862
gum::debug!(
887863
target: LOG_TARGET,
888864
session = session_index,
889-
?relay_parent,
865+
?block_hash,
890866
"Can't obtain SessionInfo or ExecutorParams"
891867
);
892868
None
@@ -897,13 +873,13 @@ where
897873
async fn get_session_info_by_index<'a, Sender>(
898874
runtime_info: &'a mut RuntimeInfo,
899875
sender: &mut Sender,
900-
relay_parent: Hash,
876+
block_hash: Hash,
901877
session_index: SessionIndex,
902878
) -> Option<&'a SessionInfo>
903879
where
904880
Sender: SubsystemSender<RuntimeApiMessage>,
905881
{
906-
get_extended_session_info_by_index(runtime_info, sender, relay_parent, session_index)
882+
get_extended_session_info_by_index(runtime_info, sender, block_hash, session_index)
907883
.await
908884
.map(|extended_info| &extended_info.session_info)
909885
}
@@ -1923,14 +1899,24 @@ async fn distribution_messages_for_activation<Sender: SubsystemSender<RuntimeApi
19231899

19241900
if !block_entry.candidate_is_pending_signature(*candidate_hash)
19251901
{
1902+
// Executor params are session-buffered, so we use
1903+
// block_hash (the including relay block) for the runtime
1904+
// API query — its state is guaranteed available. The
1905+
// session index comes from the candidate descriptor
1906+
// (relay_parent's session), falling back to the including
1907+
// block's session for V1 descriptors where relay_parent
1908+
// == scheduling_parent.
1909+
let session = candidate_entry
1910+
.candidate_receipt()
1911+
.descriptor()
1912+
.session_index()
1913+
.unwrap_or(block_entry.session());
19261914
let ExtendedSessionInfo { ref executor_params, .. } =
1927-
match get_extended_session_info(
1915+
match get_extended_session_info_by_index(
19281916
session_info_provider,
19291917
sender,
1930-
candidate_entry
1931-
.candidate_receipt()
1932-
.descriptor()
1933-
.relay_parent(),
1918+
block_hash,
1919+
session,
19341920
)
19351921
.await
19361922
{
@@ -3388,16 +3374,23 @@ async fn process_wakeup<Sender: SubsystemSender<RuntimeApiMessage>>(
33883374
};
33893375

33903376
if let Some((cert, val_index, tranche)) = maybe_cert {
3391-
let ExtendedSessionInfo { ref executor_params, .. } = match get_extended_session_info(
3392-
session_info_provider,
3393-
sender,
3394-
candidate_entry.candidate_receipt().descriptor().relay_parent(),
3395-
)
3396-
.await
3397-
{
3398-
Some(i) => i,
3399-
None => return Ok(actions),
3400-
};
3377+
// Executor params are session-buffered, so we use relay_block (the including relay
3378+
// block) for the runtime API query — its state is guaranteed available. The session
3379+
// index comes from the candidate descriptor (relay_parent's session), falling back
3380+
// to the including block's session for V1 descriptors.
3381+
let session = candidate_receipt.descriptor.session_index().unwrap_or(block_entry.session());
3382+
let ExtendedSessionInfo { ref executor_params, .. } =
3383+
match get_extended_session_info_by_index(
3384+
session_info_provider,
3385+
sender,
3386+
relay_block,
3387+
session,
3388+
)
3389+
.await
3390+
{
3391+
Some(i) => i,
3392+
None => return Ok(actions),
3393+
};
34013394
let indirect_cert =
34023395
IndirectAssignmentCertV2 { block_hash: relay_block, validator: val_index, cert };
34033396

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

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2963,13 +2963,6 @@ fn subsystem_validate_approvals_cache() {
29632963
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot)));
29642964
clock.inner.lock().wakeup_all(slot_to_tick(slot));
29652965

2966-
assert_matches!(
2967-
overseer_recv(&mut virtual_overseer).await,
2968-
AllMessages::RuntimeApi(RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(rx), )) => {
2969-
rx.send(Ok(1u32.into())).unwrap();
2970-
}
2971-
);
2972-
29732966
futures_timer::Delay::new(Duration::from_millis(200)).await;
29742967

29752968
clock.inner.lock().wakeup_all(slot_to_tick(slot + 2));
@@ -4090,13 +4083,6 @@ fn test_approval_is_sent_on_max_approval_coalesce_count() {
40904083
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot)));
40914084
clock.inner.lock().wakeup_all(slot_to_tick(slot));
40924085

4093-
assert_matches!(
4094-
overseer_recv(&mut virtual_overseer).await,
4095-
AllMessages::RuntimeApi(RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(rx), )) => {
4096-
rx.send(Ok(1u32.into())).unwrap();
4097-
}
4098-
);
4099-
41004086
futures_timer::Delay::new(Duration::from_millis(200)).await;
41014087

41024088
clock.inner.lock().wakeup_all(slot_to_tick(slot + 2));
@@ -4398,13 +4384,6 @@ fn test_approval_is_sent_on_max_approval_coalesce_wait() {
43984384
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot)));
43994385
clock.inner.lock().wakeup_all(slot_to_tick(slot));
44004386

4401-
assert_matches!(
4402-
overseer_recv(&mut virtual_overseer).await,
4403-
AllMessages::RuntimeApi(RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(rx), )) => {
4404-
rx.send(Ok(1u32.into())).unwrap();
4405-
}
4406-
);
4407-
44084387
futures_timer::Delay::new(Duration::from_millis(200)).await;
44094388

44104389
clock.inner.lock().wakeup_all(slot_to_tick(slot + 2));
@@ -4519,13 +4498,6 @@ async fn setup_overseer_with_two_blocks_each_with_one_assignment_triggered(
45194498
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot)));
45204499
clock.inner.lock().wakeup_all(slot_to_tick(slot));
45214500

4522-
assert_matches!(
4523-
overseer_recv(virtual_overseer).await,
4524-
AllMessages::RuntimeApi(RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(rx), )) => {
4525-
rx.send(Ok(1u32.into())).unwrap();
4526-
}
4527-
);
4528-
45294501
futures_timer::Delay::new(Duration::from_millis(200)).await;
45304502

45314503
clock.inner.lock().wakeup_all(slot_to_tick(slot + 2));
@@ -4629,13 +4601,6 @@ async fn setup_overseer_with_blocks_with_two_assignments_triggered(
46294601
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot)));
46304602
clock.inner.lock().wakeup_all(slot_to_tick(slot));
46314603

4632-
assert_matches!(
4633-
overseer_recv(virtual_overseer).await,
4634-
AllMessages::RuntimeApi(RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(rx), )) => {
4635-
rx.send(Ok(1u32.into())).unwrap();
4636-
}
4637-
);
4638-
46394604
futures_timer::Delay::new(Duration::from_millis(200)).await;
46404605

46414606
clock.inner.lock().wakeup_all(slot_to_tick(slot + 2));
@@ -5621,12 +5586,6 @@ fn subsystem_launches_missed_assignments_on_restart() {
56215586
}
56225587
);
56235588

5624-
assert_matches!(
5625-
overseer_recv(&mut virtual_overseer).await,
5626-
AllMessages::RuntimeApi(RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(rx), )) => {
5627-
rx.send(Ok(1u32.into())).unwrap();
5628-
}
5629-
);
56305589
assert_matches!(
56315590
overseer_recv(&mut virtual_overseer).await,
56325591
AllMessages::ApprovalDistribution(ApprovalDistributionMessage::DistributeAssignment(

0 commit comments

Comments
 (0)