-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat: coretime implementation #1558
base: master
Are you sure you want to change the base?
Conversation
744895d
to
6de3395
Compare
4efc743
to
f6e8a77
Compare
9ef9d68
to
e8a0808
Compare
142039d
to
4dcdf17
Compare
} | ||
|
||
private checkCoretimeModule = (): void => { | ||
if (this.api.query.onDemandAssignmentProvider && this.api.query.coretimeAssignmentProvider) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I understand this correct - either broker
needs to exist or onDemandAssignmentProvider
and coretimeAssignmentProvider
?
Would there ever be a case where they all need to exists at once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding broker is a coretime chain pallet only while onDemandAssignemntProvider and coretimeAssignmentProvider are relay chain only pallets
CoretimeGenericController.sanitizedSend(res, await this.service.getCoretimeCores(hash)); | ||
}; | ||
|
||
private checkCoretimeModule = (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same sentiment as the comment in CoretimeChain
return coreSchedules as unknown as Record<string, unknown>[]; | ||
}; | ||
|
||
private getAndDecodeCoreDescriptors = async (api: ApiDecoration<'promise'>): Promise<TCoreDescriptor[]> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private getAndDecodeCoreDescriptors = async (api: ApiDecoration<'promise'>): Promise<TCoreDescriptor[]> => { | |
private getAndDecodeCoreDescriptors = async (api: ApiDecoration<'promise'>): Promise<TCoreDescriptor[]> => { | |
const coreDescriptors = await api.query.coretimeAssignmentProvider.coreDescriptors.entries(); | |
return coreDescriptors.map((descriptor) => extractCoreDescriptorInfo(descriptor[0], descriptor[1])); | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api.query.coretimeAssignmentProvider.coreDescriptors.entries() return a type: [StorageKey, Codec][]
for which i need to typecast to convert the codec into the actual type. I'm not sure if something could be off on my set up, it seems like I don't get the corresponding type correctly and thrown an error
return descriptors.map((descriptor) => extractCoreDescriptorInfo(descriptor[0], descriptor[1])); | ||
}; | ||
|
||
private getAndDecodeParachainsLifecycle = async (api: ApiDecoration<'promise'>): Promise<TParaLifecycle[]> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private getAndDecodeParachainsLifecycle = async (api: ApiDecoration<'promise'>): Promise<TParaLifecycle[]> => { | |
private getAndDecodeParachainsLifecycle = async (api: ApiDecoration<'promise'>): Promise<TParaLifecycle[]> => { | |
const parachains = await api.query.paras.paraLifecycles.entries(); | |
return parachains.map((para) => | |
extractParachainLifecycleInfo( | |
para[0], | |
para[1], | |
), | |
); | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api.query.paras.paraLifecycles.entries() return a type: [StorageKey, Codec][]
for which i need to typecast to convert the codec into the actual type. I'm not sure if something could be off on my set up, it seems like I don't get the corresponding type correctly and thrown an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall amazing PR! I have a few nits:
-
The typecasting can be removed. AFAIU the types are correctly passed down from PJS so you should be good.
-
For any imported types we can use
import type
.
Other than that the PR looks really great!
I removed most of typecasting (nice catch, not sure I was having issues before), I had to leave typecasting for coreDescriptors and paraLifecycles though, we can doublecheck if there is something wrong on my end though
thanks for checking it out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
New Feature: Implements the coretime endpoints for relay chain and for coretime chain.
It includes basic endpoints for single information record recovery, and more advanced endpoints with precomputed calculations and information.