mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 05:07:55 +00:00
Finish migration to v2 primitives (#5037)
* remove v0 primitives from polkadot-primitives * first pass: remove v0 * fix fallout in erasure-coding * remove v1 primitives, consolidate to v2 * the great import update * update runtime_api_impl_v1 to v2 as well * guide: add `Version` request for runtime API * add version query to runtime API * reintroduce OldV1SessionInfo in a limited way
This commit is contained in:
committed by
GitHub
parent
3394cbb142
commit
49f7e5cce4
@@ -20,15 +20,12 @@ use memory_lru::{MemoryLruCache, ResidentSize};
|
||||
use parity_util_mem::{MallocSizeOf, MallocSizeOfExt};
|
||||
use sp_consensus_babe::Epoch;
|
||||
|
||||
use polkadot_primitives::{
|
||||
v1::{
|
||||
AuthorityDiscoveryId, BlockNumber, CandidateCommitments, CandidateEvent,
|
||||
CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash, Id as ParaId,
|
||||
InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption,
|
||||
PersistedValidationData, ScrapedOnChainVotes, SessionIndex, ValidationCode,
|
||||
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
},
|
||||
v2::{PvfCheckStatement, SessionInfo},
|
||||
use polkadot_primitives::v2::{
|
||||
AuthorityDiscoveryId, BlockNumber, CandidateCommitments, CandidateEvent,
|
||||
CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash, Id as ParaId,
|
||||
InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData,
|
||||
PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode,
|
||||
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
};
|
||||
|
||||
const AUTHORITIES_CACHE_SIZE: usize = 128 * 1024;
|
||||
@@ -49,6 +46,7 @@ const CURRENT_BABE_EPOCH_CACHE_SIZE: usize = 64 * 1024;
|
||||
const ON_CHAIN_VOTES_CACHE_SIZE: usize = 3 * 1024;
|
||||
const PVFS_REQUIRE_PRECHECK_SIZE: usize = 1024;
|
||||
const VALIDATION_CODE_HASH_CACHE_SIZE: usize = 64 * 1024;
|
||||
const VERSION_CACHE_SIZE: usize = 4 * 1024;
|
||||
|
||||
struct ResidentSizeOf<T>(T);
|
||||
|
||||
@@ -116,6 +114,7 @@ pub(crate) struct RequestResultCache {
|
||||
(Hash, ParaId, OccupiedCoreAssumption),
|
||||
ResidentSizeOf<Option<ValidationCodeHash>>,
|
||||
>,
|
||||
version: MemoryLruCache<Hash, ResidentSizeOf<u32>>,
|
||||
}
|
||||
|
||||
impl Default for RequestResultCache {
|
||||
@@ -142,6 +141,7 @@ impl Default for RequestResultCache {
|
||||
on_chain_votes: MemoryLruCache::new(ON_CHAIN_VOTES_CACHE_SIZE),
|
||||
pvfs_require_precheck: MemoryLruCache::new(PVFS_REQUIRE_PRECHECK_SIZE),
|
||||
validation_code_hash: MemoryLruCache::new(VALIDATION_CODE_HASH_CACHE_SIZE),
|
||||
version: MemoryLruCache::new(VERSION_CACHE_SIZE),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,6 +399,14 @@ impl RequestResultCache {
|
||||
) {
|
||||
self.validation_code_hash.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
pub(crate) fn version(&mut self, relay_parent: &Hash) -> Option<&u32> {
|
||||
self.version.get(&relay_parent).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_version(&mut self, key: Hash, value: u32) {
|
||||
self.version.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum RequestResult {
|
||||
@@ -433,4 +441,5 @@ pub(crate) enum RequestResult {
|
||||
// This is a request with side-effects and no result, hence ().
|
||||
SubmitPvfCheckStatement(Hash, PvfCheckStatement, ValidatorSignature, ()),
|
||||
ValidationCodeHash(Hash, ParaId, OccupiedCoreAssumption, Option<ValidationCodeHash>),
|
||||
Version(Hash, u32),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user