Runtime interface for ParachainHost (#4999)

This commit is contained in:
Jaco
2022-06-30 18:56:49 +03:00
committed by GitHub
parent 516289bcb7
commit 62be4530f9
6 changed files with 476 additions and 5 deletions
@@ -9,6 +9,7 @@ import type { Definitions } from '../../types';
import { objectSpread } from '@polkadot/util';
import hrmpTypes from './hrmp';
import { runtime } from './runtime';
import slotTypes from './slots';
// proposeParachain
@@ -77,6 +78,7 @@ const disputeTypes = {
export default {
rpc: {},
runtime,
types: objectSpread({}, cumulusTypes, disputeTypes, hrmpTypes, proposeTypes, slotTypes, {
AbridgedCandidateReceipt: {
parachainIndex: 'ParaId',
@@ -154,6 +156,13 @@ export default {
paraHead: 'Hash',
validationCodeHash: 'ValidationCodeHash'
},
CandidateEvent: {
_enum: {
CandidateBacked: '(CandidateReceipt, HeadData, CoreIndex, GroupIndex)',
CandidateIncluded: '(CandidateReceipt, HeadData, CoreIndex, GroupIndex)',
CandidateTimedOut: '(CandidateReceipt, HeadData, CoreIndex)'
}
},
CandidateHash: 'Hash',
CandidateInfo: {
who: 'AccountId',
@@ -197,6 +206,13 @@ export default {
Parachain: 'Null'
}
},
CoreState: {
_enum: {
Occupied: 'OccupiedCore',
Scheduled: 'ScheduledCore',
Free: 'Null'
}
},
DoubleVoteReport: {
identity: 'ValidatorId',
first: '(Statement, ValidatorSignature)',
@@ -206,6 +222,11 @@ export default {
},
DownwardMessage: 'Bytes',
GroupIndex: 'u32',
GroupRotationInfo: {
sessionStartBlock: 'BlockNumber',
groupRotationFrequency: 'BlockNumber',
now: 'BlockNumber'
},
GlobalValidationSchedule: {
maxCodeSize: 'u32',
maxHeadDataSize: 'u32',
@@ -273,6 +294,19 @@ export default {
horizontalMessages: 'BTreeMap<ParaId, InboundHrmpMessages>'
},
MessageQueueChain: 'RelayChainHash',
OccupiedCore: {
nextUpOnVvailable: 'Option<ScheduledCore>',
occupiedSince: 'BlockNumber',
timeOutAt: 'BlockNumber',
nextUpOnTimeOut: 'Option<ScheduledCore>',
availability: 'BitVec',
group_responsible: 'GroupIndex',
candidateHash: 'CandidateHash',
candidateDescriptor: 'CandidateDescriptor'
},
OccupiedCoreAssumption: {
_enum: ['Included,', 'TimedOut', 'Free']
},
OutboundHrmpMessage: {
recipient: 'u32',
data: 'Bytes'
@@ -329,6 +363,12 @@ export default {
relayParentStorageRoot: 'Hash',
maxPovSize: 'u32'
},
PvfCheckStatement: {
accept: 'bool',
subject: 'ValidationCodeHash',
sessionIndex: 'SessionIndex',
validatorIndex: 'ParaValidatorIndex'
},
QueuedParathread: {
claim: 'ParathreadEntry',
coreOffset: 'u32'
@@ -348,9 +388,18 @@ export default {
WithRetries: 'u32'
}
},
ScheduledCore: {
paraId: 'ParaId',
collator: 'Option<CollatorId>'
},
Scheduling: {
_enum: ['Always', 'Dynamic']
},
ScrapedOnChainVotes: {
session: 'SessionIndex',
backingValidatorsPerCandidate: 'Vec<(CandidateReceipt, Vec<(ParaValidatorIndex, ValidityAttestation)>)>',
disputes: 'MultiDisputeStatementSet'
},
SessionInfo: {
validators: 'Vec<ValidatorId>',
discoveryKeys: 'Vec<AuthorityDiscoveryId>',
@@ -0,0 +1,183 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
ParachainHost: [
{
methods: {
assumed_validation_data: {
description: 'Returns the persisted validation data for the given `ParaId` along with the corresponding validation code hash.',
params: [
{
name: 'paraId',
type: 'ParaId'
},
{
name: 'hash',
type: 'Hash'
}
],
type: 'Option<(PersistedValidationData, ValidationCodeHash)>'
},
availability_cores: {
description: 'Yields information on all availability cores as relevant to the child block.',
params: [],
type: 'Vec<CoreState>'
},
candidate_events: {
description: 'Get a vector of events concerning candidates that occurred within a block.',
params: [],
type: 'Vec<CandidateEvent>'
},
candidate_pending_availability: {
description: 'Get the receipt of a candidate pending availability.',
params: [
{
name: 'paraId',
type: 'ParaId'
}
],
type: 'Option<CommittedCandidateReceipt>'
},
check_validation_outputs: {
description: 'Checks if the given validation outputs pass the acceptance criteria.',
params: [
{
name: 'paraId',
type: 'ParaId'
},
{
name: 'outputs',
type: 'CandidateCommitments'
}
],
type: 'bool'
},
dmq_contents: {
description: 'Get all the pending inbound messages in the downward message queue for a para.',
params: [
{
name: 'paraId',
type: 'ParaId'
}
],
type: 'Vec<InboundDownwardMessage>'
},
inbound_hrmp_channels_contents: {
description: 'Get the contents of all channels addressed to the given recipient.',
params: [
{
name: 'paraId',
type: 'ParaId'
}
],
type: 'Vec<InboundHrmpMessage>'
},
on_chain_votes: {
description: 'Scrape dispute relevant from on-chain, backing votes and resolved disputes.',
params: [],
type: 'Option<ScrapedOnChainVotes>'
},
persisted_validation_data: {
description: 'Yields the persisted validation data for the given `ParaId` along with an assumption that should be used if the para currently occupies a core.',
params: [
{
name: 'paraId',
type: 'ParaId'
},
{
name: 'assumption',
type: 'OccupiedCoreAssumption'
}
],
type: 'Option<PersistedValidationData>'
},
pvfs_require_precheck: {
description: 'Returns code hashes of PVFs that require pre-checking by validators in the active set.',
params: [],
type: 'Vec<ValidationCodeHash>'
},
session_index_for_child: {
description: 'Returns the session index expected at a child of the block.',
params: [],
type: 'SessionIndex'
},
session_info: {
description: 'Get the session info for the given session, if stored.',
params: [
{
name: 'index',
type: 'SessionIndex'
}
],
type: 'Option<SessionInfo>'
},
submit_pvf_check_statement: {
description: 'Submits a PVF pre-checking statement into the transaction pool.',
params: [
{
name: 'stmt',
type: 'PvfCheckStatement'
},
{
name: 'signature',
type: 'ValidatorSignature'
}
],
type: 'Null'
},
validation_code: {
description: 'Fetch the validation code used by a para, making the given `OccupiedCoreAssumption`.',
params: [
{
name: 'paraId',
type: 'ParaId'
},
{
name: 'assumption',
type: 'OccupiedCoreAssumption'
}
],
type: 'ValidationCode'
},
validation_code_by_hash: {
description: 'Get the validation code from its hash.',
params: [
{
name: 'hash',
type: 'ValidationCodeHash'
}
],
type: 'Option<ValidationCode>'
},
validation_code_hash: {
description: 'Fetch the hash of the validation code used by a para, making the given `OccupiedCoreAssumption`.',
params: [
{
name: 'paraId',
type: 'ParaId'
},
{
name: 'assumption',
type: 'OccupiedCoreAssumption'
}
],
type: 'Option<ValidationCodeHash>'
},
validator_groups: {
description: 'Returns the validator groups and rotation info localized based on the hypothetical child of a block whose state this is invoked on',
params: [],
type: '(Vec<Vec<ParaValidatorIndex>>, GroupRotationInfo)'
},
validators: {
description: 'Get the current validators.',
params: [],
type: 'Vec<ValidatorId>'
}
},
version: 2
}
]
};
@@ -121,6 +121,17 @@ export interface CandidateDescriptor extends Struct {
readonly validationCodeHash: ValidationCodeHash;
}
/** @name CandidateEvent */
export interface CandidateEvent extends Enum {
readonly isCandidateBacked: boolean;
readonly asCandidateBacked: ITuple<[CandidateReceipt, HeadData, CoreIndex, GroupIndex]>;
readonly isCandidateIncluded: boolean;
readonly asCandidateIncluded: ITuple<[CandidateReceipt, HeadData, CoreIndex, GroupIndex]>;
readonly isCandidateTimedOut: boolean;
readonly asCandidateTimedOut: ITuple<[CandidateReceipt, HeadData, CoreIndex]>;
readonly type: 'CandidateBacked' | 'CandidateIncluded' | 'CandidateTimedOut';
}
/** @name CandidateHash */
export interface CandidateHash extends Hash {}
@@ -179,6 +190,16 @@ export interface CoreOccupied extends Enum {
readonly type: 'Parathread' | 'Parachain';
}
/** @name CoreState */
export interface CoreState extends Enum {
readonly isOccupied: boolean;
readonly asOccupied: OccupiedCore;
readonly isScheduled: boolean;
readonly asScheduled: ScheduledCore;
readonly isFree: boolean;
readonly type: 'Occupied' | 'Scheduled' | 'Free';
}
/** @name DisputeLocation */
export interface DisputeLocation extends Enum {
readonly isLocal: boolean;
@@ -253,6 +274,13 @@ export interface GlobalValidationSchedule extends Struct {
/** @name GroupIndex */
export interface GroupIndex extends u32 {}
/** @name GroupRotationInfo */
export interface GroupRotationInfo extends Struct {
readonly sessionStartBlock: BlockNumber;
readonly groupRotationFrequency: BlockNumber;
readonly now: BlockNumber;
}
/** @name HeadData */
export interface HeadData extends Bytes {}
@@ -413,6 +441,26 @@ export interface NewBidder extends Struct {
readonly sub: SubId;
}
/** @name OccupiedCore */
export interface OccupiedCore extends Struct {
readonly nextUpOnVvailable: Option<ScheduledCore>;
readonly occupiedSince: BlockNumber;
readonly timeOutAt: BlockNumber;
readonly nextUpOnTimeOut: Option<ScheduledCore>;
readonly availability: BitVec;
readonly group_responsible: GroupIndex;
readonly candidateHash: CandidateHash;
readonly candidateDescriptor: CandidateDescriptor;
}
/** @name OccupiedCoreAssumption */
export interface OccupiedCoreAssumption extends Enum {
readonly isIncluded: boolean;
readonly isTimedOut: boolean;
readonly isFree: boolean;
readonly type: 'Included' | 'TimedOut' | 'Free';
}
/** @name OutboundHrmpMessage */
export interface OutboundHrmpMessage extends Struct {
readonly recipient: u32;
@@ -520,6 +568,14 @@ export interface PersistedValidationData extends Struct {
readonly maxPovSize: u32;
}
/** @name PvfCheckStatement */
export interface PvfCheckStatement extends Struct {
readonly accept: bool;
readonly subject: ValidationCodeHash;
readonly sessionIndex: SessionIndex;
readonly validatorIndex: ParaValidatorIndex;
}
/** @name QueuedParathread */
export interface QueuedParathread extends Struct {
readonly claim: ParathreadEntry;
@@ -561,6 +617,12 @@ export interface Retriable extends Enum {
readonly type: 'Never' | 'WithRetries';
}
/** @name ScheduledCore */
export interface ScheduledCore extends Struct {
readonly paraId: ParaId;
readonly collator: Option<CollatorId>;
}
/** @name Scheduling */
export interface Scheduling extends Enum {
readonly isAlways: boolean;
@@ -568,6 +630,13 @@ export interface Scheduling extends Enum {
readonly type: 'Always' | 'Dynamic';
}
/** @name ScrapedOnChainVotes */
export interface ScrapedOnChainVotes extends Struct {
readonly session: SessionIndex;
readonly backingValidatorsPerCandidate: Vec<ITuple<[CandidateReceipt, Vec<ITuple<[ParaValidatorIndex, ValidityAttestation]>>]>>;
readonly disputes: MultiDisputeStatementSet;
}
/** @name ServiceQuality */
export interface ServiceQuality extends Enum {
readonly isOrdered: boolean;