Skip to content

Commit

Permalink
Merge pull request #8 from Cerebellum-Network/feature/devnet-metadata…
Browse files Browse the repository at this point in the history
…-to-spec-54112

Runtime v54112 support
  • Loading branch information
khssnv authored Aug 9, 2024
2 parents 52f71c7 + 623b4a9 commit b63ac55
Show file tree
Hide file tree
Showing 11 changed files with 15,924 additions and 5 deletions.
3 changes: 0 additions & 3 deletions specs/devnet-0-5054152.jsonl

This file was deleted.

3 changes: 3 additions & 0 deletions specs/devnet-0-5149484.jsonl
Git LFS file not shown
17 changes: 16 additions & 1 deletion src/processors/ddcClustersProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,22 @@ export class DdcClustersProcessor extends BaseProcessor<State> {
clusterInfo.replicationTotal = cluster.props.replicationTotal
clusterInfo.status = DdcClusterStatus[cluster.status.__kind]
}
} else {
} else if (storage.ddcClusters.clusters.v54105.is(block)) {
const cluster = await storage.ddcClusters.clusters.v54105.get(
block,
clusterId,
)
if (cluster) {
clusterInfo = this.newClusterInfo(clusterId, cluster.managerId)
clusterInfo.erasureCodingRequired =
cluster.props.erasureCodingRequired
clusterInfo.erasureCodingTotal =
cluster.props.erasureCodingTotal
clusterInfo.replicationTotal = cluster.props.replicationTotal
clusterInfo.status = DdcClusterStatus[cluster.status.__kind]
}
}
else {
throwUnsupportedStorageSpec(block)
}
if (clusterInfo) {
Expand Down
12 changes: 12 additions & 0 deletions src/types/ddc-clusters/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as v48013 from '../v48013'
import * as v48017 from '../v48017'
import * as v54001 from '../v54001'
import * as v54004 from '../v54004'
import * as v54105 from '../v54105'

export const clusterCreated = {
name: 'DdcClusters.ClusterCreated',
Expand Down Expand Up @@ -132,3 +133,14 @@ export const clusterUnbonding = {
})
),
}

export const clusterEraValidated = {
name: 'DdcClusters.ClusterEraValidated',
v54105: new EventType(
'DdcClusters.ClusterEraValidated',
sts.struct({
clusterId: v54105.H160,
eraId: sts.number(),
})
),
}
16 changes: 16 additions & 0 deletions src/types/ddc-clusters/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import * as v48017 from '../v48017'
import * as v48400 from '../v48400'
import * as v53003 from '../v53003'
import * as v54001 from '../v54001'
import * as v54105 from '../v54105'

export const clusters = {
v48008: new StorageType('DdcClusters.Clusters', 'Optional', [v48008.H160], v48008.Cluster) as ClustersV48008,
v48013: new StorageType('DdcClusters.Clusters', 'Optional', [v48013.H160], v48013.Cluster) as ClustersV48013,
v48016: new StorageType('DdcClusters.Clusters', 'Optional', [v48016.H160], v48016.Cluster) as ClustersV48016,
v53003: new StorageType('DdcClusters.Clusters', 'Optional', [v53003.H160], v53003.Cluster) as ClustersV53003,
v54001: new StorageType('DdcClusters.Clusters', 'Optional', [v54001.H160], v54001.Cluster) as ClustersV54001,
v54105: new StorageType('DdcClusters.Clusters', 'Optional', [v54105.H160], v54105.Cluster) as ClustersV54105,
}

export interface ClustersV48008 {
Expand Down Expand Up @@ -86,6 +88,20 @@ export interface ClustersV54001 {
getPairsPaged(pageSize: number, block: Block, key: v54001.H160): AsyncIterable<[k: v54001.H160, v: (v54001.Cluster | undefined)][]>
}

export interface ClustersV54105 {
is(block: RuntimeCtx): boolean
get(block: Block, key: v54105.H160): Promise<(v54105.Cluster | undefined)>
getMany(block: Block, keys: v54105.H160[]): Promise<(v54105.Cluster | undefined)[]>
getKeys(block: Block): Promise<v54105.H160[]>
getKeys(block: Block, key: v54105.H160): Promise<v54105.H160[]>
getKeysPaged(pageSize: number, block: Block): AsyncIterable<v54105.H160[]>
getKeysPaged(pageSize: number, block: Block, key: v54105.H160): AsyncIterable<v54105.H160[]>
getPairs(block: Block): Promise<[k: v54105.H160, v: (v54105.Cluster | undefined)][]>
getPairs(block: Block, key: v54105.H160): Promise<[k: v54105.H160, v: (v54105.Cluster | undefined)][]>
getPairsPaged(pageSize: number, block: Block): AsyncIterable<[k: v54105.H160, v: (v54105.Cluster | undefined)][]>
getPairsPaged(pageSize: number, block: Block, key: v54105.H160): AsyncIterable<[k: v54105.H160, v: (v54105.Cluster | undefined)][]>
}

export const clustersNodes = {
v48008: new StorageType('DdcClusters.ClustersNodes', 'Default', [v48008.H160, v48008.NodePubKey], sts.boolean()) as ClustersNodesV48008,
v48013: new StorageType('DdcClusters.ClustersNodes', 'Optional', [v48013.H160, v48013.NodePubKey], sts.boolean()) as ClustersNodesV48013,
Expand Down
3 changes: 3 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * as v48017 from './v48017'
export * as v48013 from './v48013'
export * as v54001 from './v54001'
export * as v54004 from './v54004'
export * as v54105 from './v54105'
export * as v48800 from './v48800'
export * as v54100 from './v54100'
export * as v50000 from './v50000'
Expand Down Expand Up @@ -43,6 +44,8 @@ export * as v48700 from './v48700'
export * as v51301 from './v51301'
export * as v53001 from './v53001'
export * as v54002 from './v54002'
export * as v54106 from './v54106'
export * as v54112 from './v54112'
export * as v53003 from './v53003'
export * as events from './events'
export * as constants from './constants'
Expand Down
78 changes: 78 additions & 0 deletions src/types/system/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import * as v54001 from '../v54001'
import * as v54002 from '../v54002'
import * as v54004 from '../v54004'
import * as v54100 from '../v54100'
import * as v54105 from '../v54105'
import * as v54106 from '../v54106'
import * as v54112 from '../v54112'

export const account = {
/**
Expand Down Expand Up @@ -733,6 +736,36 @@ export const events = {
* just in case someone still reads them from within the runtime.
*/
v54100: new StorageType('System.Events', 'Default', [], sts.array(() => v54100.EventRecord)) as EventsV54100,
/**
* Events deposited for the current block.
*
* NOTE: The item is unbound and should therefore never be read on chain.
* It could otherwise inflate the PoV size of a block.
*
* Events have a large in-memory size. Box the events to not go out-of-memory
* just in case someone still reads them from within the runtime.
*/
v54105: new StorageType('System.Events', 'Default', [], sts.array(() => v54105.EventRecord)) as EventsV54105,
/**
* Events deposited for the current block.
*
* NOTE: The item is unbound and should therefore never be read on chain.
* It could otherwise inflate the PoV size of a block.
*
* Events have a large in-memory size. Box the events to not go out-of-memory
* just in case someone still reads them from within the runtime.
*/
v54106: new StorageType('System.Events', 'Default', [], sts.array(() => v54106.EventRecord)) as EventsV54106,
/**
* Events deposited for the current block.
*
* NOTE: The item is unbound and should therefore never be read on chain.
* It could otherwise inflate the PoV size of a block.
*
* Events have a large in-memory size. Box the events to not go out-of-memory
* just in case someone still reads them from within the runtime.
*/
v54112: new StorageType('System.Events', 'Default', [], sts.array(() => v54112.EventRecord)) as EventsV54112,
}

/**
Expand Down Expand Up @@ -1353,6 +1386,51 @@ export interface EventsV54100 {
get(block: Block): Promise<(v54100.EventRecord[] | undefined)>
}

/**
* Events deposited for the current block.
*
* NOTE: The item is unbound and should therefore never be read on chain.
* It could otherwise inflate the PoV size of a block.
*
* Events have a large in-memory size. Box the events to not go out-of-memory
* just in case someone still reads them from within the runtime.
*/
export interface EventsV54105 {
is(block: RuntimeCtx): boolean
getDefault(block: Block): v54105.EventRecord[]
get(block: Block): Promise<(v54105.EventRecord[] | undefined)>
}

/**
* Events deposited for the current block.
*
* NOTE: The item is unbound and should therefore never be read on chain.
* It could otherwise inflate the PoV size of a block.
*
* Events have a large in-memory size. Box the events to not go out-of-memory
* just in case someone still reads them from within the runtime.
*/
export interface EventsV54106 {
is(block: RuntimeCtx): boolean
getDefault(block: Block): v54106.EventRecord[]
get(block: Block): Promise<(v54106.EventRecord[] | undefined)>
}

/**
* Events deposited for the current block.
*
* NOTE: The item is unbound and should therefore never be read on chain.
* It could otherwise inflate the PoV size of a block.
*
* Events have a large in-memory size. Box the events to not go out-of-memory
* just in case someone still reads them from within the runtime.
*/
export interface EventsV54112 {
is(block: RuntimeCtx): boolean
getDefault(block: Block): v54112.EventRecord[]
get(block: Block): Promise<(v54112.EventRecord[] | undefined)>
}

export const eventCount = {
/**
* The number of events in the `Events<T>` list.
Expand Down
Loading

0 comments on commit b63ac55

Please sign in to comment.