Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch node side to v2 candidate receipts #5679

Draft
wants to merge 11 commits into
base: sandreim/runtime_v2_descriptor_support
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cumulus/client/consensus/aura/src/collators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_primitives::{
AsyncBackingParams, CoreIndex, CoreState, Hash as RelayHash, Id as ParaId,
vstaging::CoreState, AsyncBackingParams, CoreIndex, Hash as RelayHash, Id as ParaId,
OccupiedCoreAssumption, ValidationCodeHash,
};
use sc_consensus_aura::{standalone as aura_internal, AuraApi};
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use async_trait::async_trait;
use codec::Encode;
use cumulus_client_pov_recovery::RecoveryKind;
use cumulus_primitives_core::{
relay_chain::{BlockId, BlockNumber, CoreState},
relay_chain::{vstaging::CoreState, BlockId, BlockNumber},
CumulusDigestItem, InboundDownwardMessage, InboundHrmpMessage,
};
use cumulus_relay_chain_interface::{
Expand Down
12 changes: 6 additions & 6 deletions cumulus/client/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use polkadot_node_primitives::{CollationSecondedSignal, Statement};
use polkadot_node_subsystem::messages::RuntimeApiRequest;
use polkadot_parachain_primitives::primitives::HeadData;
use polkadot_primitives::{
CandidateReceipt, CompactStatement, Hash as PHash, Id as ParaId, OccupiedCoreAssumption,
SigningContext, UncheckedSigned,
vstaging::CandidateReceiptV2 as CandidateReceipt, CompactStatement, Hash as PHash,
Id as ParaId, OccupiedCoreAssumption, SigningContext, UncheckedSigned,
};

use codec::{Decode, DecodeAll, Encode};
Expand Down Expand Up @@ -79,7 +79,7 @@ impl Decode for BlockAnnounceData {
let relay_parent = match PHash::decode(input) {
Ok(p) => p,
// For being backwards compatible, we support missing relay-chain parent.
Err(_) => receipt.descriptor.relay_parent,
Err(_) => receipt.descriptor.relay_parent(),
};

Ok(Self { receipt, statement, relay_parent })
Expand Down Expand Up @@ -108,7 +108,7 @@ impl BlockAnnounceData {
return Err(Validation::Failure { disconnect: true })
}

if HeadData(encoded_header).hash() != self.receipt.descriptor.para_head {
if HeadData(encoded_header).hash() != self.receipt.descriptor.para_head() {
tracing::debug!(
target: LOG_TARGET,
"Receipt para head hash doesn't match the hash of the header in the block announcement",
Expand Down Expand Up @@ -302,7 +302,7 @@ where
}
.map_err(|e| Box::new(BlockAnnounceError(format!("{:?}", e))) as Box<_>)?;

Ok(candidate_receipts.into_iter().map(|cr| cr.descriptor.para_head))
Ok(candidate_receipts.into_iter().map(|cr| cr.descriptor.para_head()))
}

/// Handle a block announcement with empty data (no statement) attached to it.
Expand Down Expand Up @@ -399,7 +399,7 @@ where
return Ok(e)
}

let relay_parent = block_announce_data.receipt.descriptor.relay_parent;
let relay_parent = block_announce_data.receipt.descriptor.relay_parent();

relay_chain_interface
.wait_for_block(relay_parent)
Expand Down
22 changes: 12 additions & 10 deletions cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ use futures::{executor::block_on, poll, task::Poll, FutureExt, Stream, StreamExt
use parking_lot::Mutex;
use polkadot_node_primitives::{SignedFullStatement, Statement};
use polkadot_primitives::{
vstaging::{CommittedCandidateReceiptV2, CoreState},
BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorPair,
CommittedCandidateReceipt, CoreState, Hash as PHash, HeadData, InboundDownwardMessage,
InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, SessionIndex,
SigningContext, ValidationCodeHash, ValidatorId,
CommittedCandidateReceipt, Hash as PHash, HeadData, InboundDownwardMessage, InboundHrmpMessage,
OccupiedCoreAssumption, PersistedValidationData, SessionIndex, SigningContext,
ValidationCodeHash, ValidatorId,
};
use polkadot_test_client::{
Client as PClient, ClientBlockImportExt, DefaultTestClientBuilderExt, FullBackend as PBackend,
Expand Down Expand Up @@ -162,15 +163,15 @@ impl RelayChainInterface for DummyRelayChainInterface {
&self,
_: PHash,
_: ParaId,
) -> RelayChainResult<Option<CommittedCandidateReceipt>> {
) -> RelayChainResult<Option<CommittedCandidateReceiptV2>> {
if self.data.lock().runtime_version >=
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
panic!("Should have used candidates_pending_availability instead");
}

if self.data.lock().has_pending_availability {
Ok(Some(dummy_candidate()))
Ok(Some(dummy_candidate().into()))
} else {
Ok(None)
}
Expand All @@ -180,15 +181,15 @@ impl RelayChainInterface for DummyRelayChainInterface {
&self,
_: PHash,
_: ParaId,
) -> RelayChainResult<Vec<CommittedCandidateReceipt>> {
) -> RelayChainResult<Vec<CommittedCandidateReceiptV2>> {
if self.data.lock().runtime_version <
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
panic!("Should have used candidate_pending_availability instead");
}

if self.data.lock().has_pending_availability {
Ok(vec![dummy_candidate()])
Ok(vec![dummy_candidate().into()])
} else {
Ok(vec![])
}
Expand Down Expand Up @@ -392,7 +393,7 @@ async fn make_gossip_message_and_header(
validation_code_hash: ValidationCodeHash::from(PHash::random()),
},
};
let statement = Statement::Seconded(candidate_receipt);
let statement = Statement::Seconded(candidate_receipt.into());
let signed = SignedFullStatement::sign(
&keystore,
statement,
Expand Down Expand Up @@ -505,7 +506,7 @@ fn legacy_block_announce_data_handling() {

let block_data =
BlockAnnounceData::decode(&mut &data[..]).expect("Decoding works from legacy works");
assert_eq!(receipt.descriptor.relay_parent, block_data.relay_parent);
assert_eq!(receipt.descriptor.relay_parent(), block_data.relay_parent);

let data = block_data.encode();
LegacyBlockAnnounceData::decode(&mut &data[..]).expect("Decoding works");
Expand Down Expand Up @@ -580,7 +581,8 @@ async fn check_statement_seconded() {
erasure_root: PHash::random(),
signature: sp_core::sr25519::Signature::default().into(),
validation_code_hash: ValidationCodeHash::from(PHash::random()),
},
}
.into(),
},
statement: signed_statement.convert_payload().into(),
relay_parent,
Expand Down
6 changes: 5 additions & 1 deletion cumulus/client/pov-recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ use polkadot_node_primitives::{PoV, POV_BOMB_LIMIT};
use polkadot_node_subsystem::messages::{AvailabilityRecoveryMessage, RuntimeApiRequest};
use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::{
CandidateReceipt, CommittedCandidateReceipt, Id as ParaId, SessionIndex,
vstaging::{
CandidateReceiptV2 as CandidateReceipt,
CommittedCandidateReceiptV2 as CommittedCandidateReceipt,
},
Id as ParaId, SessionIndex,
};

use cumulus_primitives_core::ParachainBlockData;
Expand Down
6 changes: 4 additions & 2 deletions cumulus/client/pov-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use super::*;
use assert_matches::assert_matches;
use codec::{Decode, Encode};
use cumulus_primitives_core::relay_chain::{
BlockId, CandidateCommitments, CandidateDescriptor, CoreState,
vstaging::{CandidateDescriptorV2, CoreState},
BlockId, CandidateCommitments, CandidateDescriptor,
};
use cumulus_relay_chain_interface::{
InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PHash, PHeader,
Expand Down Expand Up @@ -516,7 +517,8 @@ fn make_candidate_chain(candidate_number_range: Range<u32>) -> Vec<CommittedCand
signature: collator.sign(&[0u8; 132]).into(),
para_head: PHash::zero(),
validation_code_hash: PHash::zero().into(),
},
}
.into(),
commitments: CandidateCommitments {
head_data: head_data.encode().into(),
upward_messages: vec![].try_into().expect("empty vec fits within bounds"),
Expand Down
7 changes: 4 additions & 3 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ use std::{collections::btree_map::BTreeMap, pin::Pin, sync::Arc, time::Duration}
use async_trait::async_trait;
use cumulus_primitives_core::{
relay_chain::{
runtime_api::ParachainHost, Block as PBlock, BlockId, BlockNumber,
CommittedCandidateReceipt, CoreState, Hash as PHash, Header as PHeader, InboundHrmpMessage,
OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
runtime_api::ParachainHost,
vstaging::{CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState},
Block as PBlock, BlockId, BlockNumber, Hash as PHash, Header as PHeader,
InboundHrmpMessage, OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
};
Expand Down
5 changes: 3 additions & 2 deletions cumulus/client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ use sp_api::ApiError;
use cumulus_primitives_core::relay_chain::BlockId;
pub use cumulus_primitives_core::{
relay_chain::{
BlockNumber, CommittedCandidateReceipt, CoreState, Hash as PHash, Header as PHeader,
InboundHrmpMessage, OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
vstaging::{CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState},
BlockNumber, Hash as PHash, Header as PHeader, InboundHrmpMessage, OccupiedCoreAssumption,
SessionIndex, ValidationCodeHash, ValidatorId,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use futures::{Stream, StreamExt};
use polkadot_core_primitives::{Block, BlockNumber, Hash, Header};
use polkadot_overseer::{ChainApiBackend, RuntimeApiSubsystemClient};
use polkadot_primitives::{
async_backing::{AsyncBackingParams, BackingState},
slashing, ApprovalVotingParams, CoreIndex, NodeFeatures,
async_backing::AsyncBackingParams, slashing, vstaging::async_backing::BackingState,
ApprovalVotingParams, CoreIndex, NodeFeatures,
};
use sc_authority_discovery::{AuthorityDiscovery, Error as AuthorityDiscoveryError};
use sc_client_api::AuxStore;
Expand Down Expand Up @@ -143,7 +143,7 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
&self,
at: Hash,
) -> Result<
Vec<polkadot_primitives::CoreState<Hash, polkadot_core_primitives::BlockNumber>>,
Vec<polkadot_primitives::vstaging::CoreState<Hash, polkadot_core_primitives::BlockNumber>>,
sp_api::ApiError,
> {
Ok(self.rpc_client.parachain_host_availability_cores(at).await?)
Expand Down Expand Up @@ -226,7 +226,10 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
) -> Result<Option<polkadot_primitives::CommittedCandidateReceipt<Hash>>, sp_api::ApiError> {
) -> Result<
Option<polkadot_primitives::vstaging::CommittedCandidateReceiptV2<Hash>>,
sp_api::ApiError,
> {
Ok(self
.rpc_client
.parachain_host_candidate_pending_availability(at, para_id)
Expand All @@ -236,7 +239,7 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
async fn candidate_events(
&self,
at: Hash,
) -> Result<Vec<polkadot_primitives::CandidateEvent<Hash>>, sp_api::ApiError> {
) -> Result<Vec<polkadot_primitives::vstaging::CandidateEvent<Hash>>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_candidate_events(at).await?)
}

Expand Down Expand Up @@ -284,7 +287,8 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
async fn on_chain_votes(
&self,
at: Hash,
) -> Result<Option<polkadot_primitives::ScrapedOnChainVotes<Hash>>, sp_api::ApiError> {
) -> Result<Option<polkadot_primitives::vstaging::ScrapedOnChainVotes<Hash>>, sp_api::ApiError>
{
Ok(self.rpc_client.parachain_host_on_chain_votes(at).await?)
}

Expand Down Expand Up @@ -456,7 +460,10 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
) -> Result<Vec<polkadot_primitives::CommittedCandidateReceipt<Hash>>, sp_api::ApiError> {
) -> Result<
Vec<polkadot_primitives::vstaging::CommittedCandidateReceiptV2<Hash>>,
sp_api::ApiError,
> {
Ok(self
.rpc_client
.parachain_host_candidates_pending_availability(at, para_id)
Expand Down
5 changes: 3 additions & 2 deletions cumulus/client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use async_trait::async_trait;
use core::time::Duration;
use cumulus_primitives_core::{
relay_chain::{
CommittedCandidateReceipt, Hash as RelayHash, Header as RelayHeader, InboundHrmpMessage,
OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
vstaging::CommittedCandidateReceiptV2 as CommittedCandidateReceipt, Hash as RelayHash,
Header as RelayHeader, InboundHrmpMessage, OccupiedCoreAssumption, SessionIndex,
ValidationCodeHash, ValidatorId,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
};
Expand Down
19 changes: 12 additions & 7 deletions cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ use codec::{Decode, Encode};

use cumulus_primitives_core::{
relay_chain::{
async_backing::{AsyncBackingParams, BackingState},
slashing, ApprovalVotingParams, BlockNumber, CandidateCommitments, CandidateEvent,
CandidateHash, CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState,
ExecutorParams, GroupRotationInfo, Hash as RelayHash, Header as RelayHeader,
InboundHrmpMessage, NodeFeatures, OccupiedCoreAssumption, PvfCheckStatement,
ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash,
ValidatorId, ValidatorIndex, ValidatorSignature,
async_backing::AsyncBackingParams,
slashing,
vstaging::{
async_backing::BackingState, CandidateEvent,
CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState,
ScrapedOnChainVotes,
},
ApprovalVotingParams, BlockNumber, CandidateCommitments, CandidateHash, CoreIndex,
DisputeState, ExecutorParams, GroupRotationInfo, Hash as RelayHash, Header as RelayHeader,
InboundHrmpMessage, NodeFeatures, OccupiedCoreAssumption, PvfCheckStatement, SessionIndex,
SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
ValidatorSignature,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
};
Expand Down
2 changes: 2 additions & 0 deletions polkadot/node/collation-generation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ polkadot-primitives-test-helpers = { workspace = true }
assert_matches = { workspace = true }
rstest = { workspace = true }
sp-keyring = { workspace = true, default-features = true }
polkadot-primitives = { workspace = true, features = ["test"] }

10 changes: 6 additions & 4 deletions polkadot/node/collation-generation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ use polkadot_node_subsystem_util::{
request_validators, runtime::fetch_claim_queue,
};
use polkadot_primitives::{
collator_signature_payload, CandidateCommitments, CandidateDescriptor, CandidateReceipt,
CollatorPair, CoreIndex, CoreState, Hash, Id as ParaId, OccupiedCoreAssumption,
PersistedValidationData, ScheduledCore, ValidationCodeHash,
collator_signature_payload,
vstaging::{CandidateReceiptV2 as CandidateReceipt, CoreState},
CandidateCommitments, CandidateDescriptor, CollatorPair, CoreIndex, Hash, Id as ParaId,
OccupiedCoreAssumption, PersistedValidationData, ScheduledCore, ValidationCodeHash,
};
use sp_core::crypto::Pair;
use std::sync::Arc;
Expand Down Expand Up @@ -607,7 +608,8 @@ async fn construct_and_distribute_receipt(
erasure_root,
para_head: commitments.head_data.hash(),
validation_code_hash,
},
}
.into(),
};

gum::debug!(
Expand Down
Loading
Loading