Skip to content

Commit 3d11c7f

Browse files
sandreimactions-user
authored andcommitted
Switch node side to v2 candidate receipts (paritytech#5679)
on top of paritytech#5423 This PR implements the plumbing work required for paritytech#5047 . I also added additional helper methods gated by feature "test" in primitives. TODO: - [x] PRDoc --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Co-authored-by: GitHub Action <action@github.com>
1 parent ce09c20 commit 3d11c7f

122 files changed

Lines changed: 1136 additions & 721 deletions

File tree

Some content is hidden

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

cumulus/client/consensus/common/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use async_trait::async_trait;
2020
use codec::Encode;
2121
use cumulus_client_pov_recovery::RecoveryKind;
2222
use cumulus_primitives_core::{
23-
relay_chain::{BlockId, BlockNumber, CoreState},
23+
relay_chain::{vstaging::CoreState, BlockId, BlockNumber},
2424
CumulusDigestItem, InboundDownwardMessage, InboundHrmpMessage,
2525
};
2626
use cumulus_relay_chain_interface::{

cumulus/client/network/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use polkadot_node_primitives::{CollationSecondedSignal, Statement};
3232
use polkadot_node_subsystem::messages::RuntimeApiRequest;
3333
use polkadot_parachain_primitives::primitives::HeadData;
3434
use polkadot_primitives::{
35-
CandidateReceipt, CompactStatement, Hash as PHash, Id as ParaId, OccupiedCoreAssumption,
36-
SigningContext, UncheckedSigned,
35+
vstaging::CandidateReceiptV2 as CandidateReceipt, CompactStatement, Hash as PHash,
36+
Id as ParaId, OccupiedCoreAssumption, SigningContext, UncheckedSigned,
3737
};
3838

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

8585
Ok(Self { receipt, statement, relay_parent })
@@ -108,7 +108,7 @@ impl BlockAnnounceData {
108108
return Err(Validation::Failure { disconnect: true })
109109
}
110110

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

305-
Ok(candidate_receipts.into_iter().map(|cr| cr.descriptor.para_head))
305+
Ok(candidate_receipts.into_iter().map(|cr| cr.descriptor.para_head()))
306306
}
307307

308308
/// Handle a block announcement with empty data (no statement) attached to it.
@@ -399,7 +399,7 @@ where
399399
return Ok(e)
400400
}
401401

402-
let relay_parent = block_announce_data.receipt.descriptor.relay_parent;
402+
let relay_parent = block_announce_data.receipt.descriptor.relay_parent();
403403

404404
relay_chain_interface
405405
.wait_for_block(relay_parent)

cumulus/client/network/src/tests.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ use futures::{executor::block_on, poll, task::Poll, FutureExt, Stream, StreamExt
2626
use parking_lot::Mutex;
2727
use polkadot_node_primitives::{SignedFullStatement, Statement};
2828
use polkadot_primitives::{
29+
vstaging::{CommittedCandidateReceiptV2, CoreState},
2930
BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorPair,
30-
CommittedCandidateReceipt, CoreState, Hash as PHash, HeadData, InboundDownwardMessage,
31-
InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, SessionIndex,
32-
SigningContext, ValidationCodeHash, ValidatorId,
31+
CommittedCandidateReceipt, Hash as PHash, HeadData, InboundDownwardMessage, InboundHrmpMessage,
32+
OccupiedCoreAssumption, PersistedValidationData, SessionIndex, SigningContext,
33+
ValidationCodeHash, ValidatorId,
3334
};
3435
use polkadot_test_client::{
3536
Client as PClient, ClientBlockImportExt, DefaultTestClientBuilderExt, FullBackend as PBackend,
@@ -166,15 +167,15 @@ impl RelayChainInterface for DummyRelayChainInterface {
166167
&self,
167168
_: PHash,
168169
_: ParaId,
169-
) -> RelayChainResult<Option<CommittedCandidateReceipt>> {
170+
) -> RelayChainResult<Option<CommittedCandidateReceiptV2>> {
170171
if self.data.lock().runtime_version >=
171172
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
172173
{
173174
panic!("Should have used candidates_pending_availability instead");
174175
}
175176

176177
if self.data.lock().has_pending_availability {
177-
Ok(Some(dummy_candidate()))
178+
Ok(Some(dummy_candidate().into()))
178179
} else {
179180
Ok(None)
180181
}
@@ -184,15 +185,15 @@ impl RelayChainInterface for DummyRelayChainInterface {
184185
&self,
185186
_: PHash,
186187
_: ParaId,
187-
) -> RelayChainResult<Vec<CommittedCandidateReceipt>> {
188+
) -> RelayChainResult<Vec<CommittedCandidateReceiptV2>> {
188189
if self.data.lock().runtime_version <
189190
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
190191
{
191192
panic!("Should have used candidate_pending_availability instead");
192193
}
193194

194195
if self.data.lock().has_pending_availability {
195-
Ok(vec![dummy_candidate()])
196+
Ok(vec![dummy_candidate().into()])
196197
} else {
197198
Ok(vec![])
198199
}
@@ -412,7 +413,7 @@ async fn make_gossip_message_and_header(
412413
validation_code_hash: ValidationCodeHash::from(PHash::random()),
413414
},
414415
};
415-
let statement = Statement::Seconded(candidate_receipt);
416+
let statement = Statement::Seconded(candidate_receipt.into());
416417
let signed = SignedFullStatement::sign(
417418
&keystore,
418419
statement,
@@ -525,7 +526,7 @@ fn legacy_block_announce_data_handling() {
525526

526527
let block_data =
527528
BlockAnnounceData::decode(&mut &data[..]).expect("Decoding works from legacy works");
528-
assert_eq!(receipt.descriptor.relay_parent, block_data.relay_parent);
529+
assert_eq!(receipt.descriptor.relay_parent(), block_data.relay_parent);
529530

530531
let data = block_data.encode();
531532
LegacyBlockAnnounceData::decode(&mut &data[..]).expect("Decoding works");
@@ -600,7 +601,8 @@ async fn check_statement_seconded() {
600601
erasure_root: PHash::random(),
601602
signature: sp_core::sr25519::Signature::default().into(),
602603
validation_code_hash: ValidationCodeHash::from(PHash::random()),
603-
},
604+
}
605+
.into(),
604606
},
605607
statement: signed_statement.convert_payload().into(),
606608
relay_parent,

cumulus/client/pov-recovery/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ use polkadot_node_primitives::{PoV, POV_BOMB_LIMIT};
5656
use polkadot_node_subsystem::messages::{AvailabilityRecoveryMessage, RuntimeApiRequest};
5757
use polkadot_overseer::Handle as OverseerHandle;
5858
use polkadot_primitives::{
59-
CandidateReceipt, CommittedCandidateReceipt, Id as ParaId, SessionIndex,
59+
vstaging::{
60+
CandidateReceiptV2 as CandidateReceipt,
61+
CommittedCandidateReceiptV2 as CommittedCandidateReceipt,
62+
},
63+
Id as ParaId, SessionIndex,
6064
};
6165

6266
use cumulus_primitives_core::ParachainBlockData;

cumulus/client/pov-recovery/src/tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use super::*;
1818
use assert_matches::assert_matches;
1919
use codec::{Decode, Encode};
2020
use cumulus_primitives_core::relay_chain::{
21-
BlockId, CandidateCommitments, CandidateDescriptor, CoreIndex, CoreState,
21+
vstaging::CoreState, BlockId, CandidateCommitments, CandidateDescriptor, CoreIndex,
2222
};
2323
use cumulus_relay_chain_interface::{
2424
InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PHash, PHeader,
@@ -532,7 +532,8 @@ fn make_candidate_chain(candidate_number_range: Range<u32>) -> Vec<CommittedCand
532532
signature: collator.sign(&[0u8; 132]).into(),
533533
para_head: PHash::zero(),
534534
validation_code_hash: PHash::zero().into(),
535-
},
535+
}
536+
.into(),
536537
commitments: CandidateCommitments {
537538
head_data: head_data.encode().into(),
538539
upward_messages: vec![].try_into().expect("empty vec fits within bounds"),

cumulus/client/relay-chain-inprocess-interface/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ use std::{
2424
use async_trait::async_trait;
2525
use cumulus_primitives_core::{
2626
relay_chain::{
27-
runtime_api::ParachainHost, Block as PBlock, BlockId, BlockNumber,
28-
CommittedCandidateReceipt, CoreIndex, CoreState, Hash as PHash, Header as PHeader,
27+
runtime_api::ParachainHost,
28+
vstaging::{CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState},
29+
Block as PBlock, BlockId, BlockNumber, CoreIndex, Hash as PHash, Header as PHeader,
2930
InboundHrmpMessage, OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
3031
},
3132
InboundDownwardMessage, ParaId, PersistedValidationData,

cumulus/client/relay-chain-interface/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ use sp_api::ApiError;
3333
use cumulus_primitives_core::relay_chain::{BlockId, Hash as RelayHash};
3434
pub use cumulus_primitives_core::{
3535
relay_chain::{
36-
BlockNumber, CommittedCandidateReceipt, CoreIndex, CoreState, Hash as PHash,
37-
Header as PHeader, InboundHrmpMessage, OccupiedCoreAssumption, SessionIndex,
38-
ValidationCodeHash, ValidatorId,
36+
vstaging::{CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState},
37+
BlockNumber, CoreIndex, Hash as PHash, Header as PHeader, InboundHrmpMessage,
38+
OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
3939
},
4040
InboundDownwardMessage, ParaId, PersistedValidationData,
4141
};

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use futures::{Stream, StreamExt};
2626
use polkadot_core_primitives::{Block, BlockNumber, Hash, Header};
2727
use polkadot_overseer::{ChainApiBackend, RuntimeApiSubsystemClient};
2828
use polkadot_primitives::{
29-
async_backing::{AsyncBackingParams, BackingState},
30-
slashing, ApprovalVotingParams, CoreIndex, NodeFeatures,
29+
async_backing::AsyncBackingParams, slashing, vstaging::async_backing::BackingState,
30+
ApprovalVotingParams, CoreIndex, NodeFeatures,
3131
};
3232
use sc_authority_discovery::{AuthorityDiscovery, Error as AuthorityDiscoveryError};
3333
use sc_client_api::AuxStore;
@@ -143,7 +143,10 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
143143
async fn availability_cores(
144144
&self,
145145
at: Hash,
146-
) -> Result<Vec<polkadot_primitives::CoreState<Hash, BlockNumber>>, sp_api::ApiError> {
146+
) -> Result<
147+
Vec<polkadot_primitives::vstaging::CoreState<Hash, polkadot_core_primitives::BlockNumber>>,
148+
sp_api::ApiError,
149+
> {
147150
Ok(self.rpc_client.parachain_host_availability_cores(at).await?)
148151
}
149152

@@ -212,8 +215,11 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
212215
async fn candidate_pending_availability(
213216
&self,
214217
at: Hash,
215-
para_id: ParaId,
216-
) -> Result<Option<polkadot_primitives::CommittedCandidateReceipt<Hash>>, sp_api::ApiError> {
218+
para_id: cumulus_primitives_core::ParaId,
219+
) -> Result<
220+
Option<polkadot_primitives::vstaging::CommittedCandidateReceiptV2<Hash>>,
221+
sp_api::ApiError,
222+
> {
217223
Ok(self
218224
.rpc_client
219225
.parachain_host_candidate_pending_availability(at, para_id)
@@ -223,7 +229,7 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
223229
async fn candidate_events(
224230
&self,
225231
at: Hash,
226-
) -> Result<Vec<polkadot_primitives::CandidateEvent<Hash>>, sp_api::ApiError> {
232+
) -> Result<Vec<polkadot_primitives::vstaging::CandidateEvent<Hash>>, sp_api::ApiError> {
227233
Ok(self.rpc_client.parachain_host_candidate_events(at).await?)
228234
}
229235

@@ -266,7 +272,8 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
266272
async fn on_chain_votes(
267273
&self,
268274
at: Hash,
269-
) -> Result<Option<polkadot_primitives::ScrapedOnChainVotes<Hash>>, sp_api::ApiError> {
275+
) -> Result<Option<polkadot_primitives::vstaging::ScrapedOnChainVotes<Hash>>, sp_api::ApiError>
276+
{
270277
Ok(self.rpc_client.parachain_host_on_chain_votes(at).await?)
271278
}
272279

@@ -437,8 +444,11 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
437444
async fn candidates_pending_availability(
438445
&self,
439446
at: Hash,
440-
para_id: ParaId,
441-
) -> Result<Vec<polkadot_primitives::CommittedCandidateReceipt<Hash>>, sp_api::ApiError> {
447+
para_id: cumulus_primitives_core::ParaId,
448+
) -> Result<
449+
Vec<polkadot_primitives::vstaging::CommittedCandidateReceiptV2<Hash>>,
450+
sp_api::ApiError,
451+
> {
442452
Ok(self
443453
.rpc_client
444454
.parachain_host_candidates_pending_availability(at, para_id)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ use async_trait::async_trait;
1818
use core::time::Duration;
1919
use cumulus_primitives_core::{
2020
relay_chain::{
21-
CommittedCandidateReceipt, Hash as RelayHash, Header as RelayHeader, InboundHrmpMessage,
22-
OccupiedCoreAssumption, SessionIndex, ValidationCodeHash, ValidatorId,
21+
vstaging::CommittedCandidateReceiptV2 as CommittedCandidateReceipt, Hash as RelayHash,
22+
Header as RelayHeader, InboundHrmpMessage, OccupiedCoreAssumption, SessionIndex,
23+
ValidationCodeHash, ValidatorId,
2324
},
2425
InboundDownwardMessage, ParaId, PersistedValidationData,
2526
};

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ use codec::{Decode, Encode};
3232

3333
use cumulus_primitives_core::{
3434
relay_chain::{
35-
async_backing::{AsyncBackingParams, BackingState},
36-
slashing, ApprovalVotingParams, BlockNumber, CandidateCommitments, CandidateEvent,
37-
CandidateHash, CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState,
38-
ExecutorParams, GroupRotationInfo, Hash as RelayHash, Header as RelayHeader,
39-
InboundHrmpMessage, NodeFeatures, OccupiedCoreAssumption, PvfCheckStatement,
40-
ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash,
41-
ValidatorId, ValidatorIndex, ValidatorSignature,
35+
async_backing::AsyncBackingParams,
36+
slashing,
37+
vstaging::{
38+
async_backing::BackingState, CandidateEvent,
39+
CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState,
40+
ScrapedOnChainVotes,
41+
},
42+
ApprovalVotingParams, BlockNumber, CandidateCommitments, CandidateHash, CoreIndex,
43+
DisputeState, ExecutorParams, GroupRotationInfo, Hash as RelayHash, Header as RelayHeader,
44+
InboundHrmpMessage, NodeFeatures, OccupiedCoreAssumption, PvfCheckStatement, SessionIndex,
45+
SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
46+
ValidatorSignature,
4247
},
4348
InboundDownwardMessage, ParaId, PersistedValidationData,
4449
};

0 commit comments

Comments
 (0)