Skip to content
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

Support archive_unstable_body #864

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

Tbaut
Copy link
Contributor

@Tbaut Tbaut commented Dec 10, 2024

closes #860
This adds support for archive_unstable_body which answers an array of extrinsics.

Please let me know what's the best way to test this without hardcoding the extrinsics

@@ -42,6 +42,13 @@ describe('chain rpc', () => {
await check(api.rpc.chain.getBlock(hash0)).toMatchSnapshot()
await check(api.rpc.chain.getBlock(hash1000)).toMatchSnapshot()

expect(await api.rpc('archive_unstable_body', hash1000)).toEqual(
expect.arrayContaining([
'0x280401000be3da72cc7d01',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's most probably not ok to hardcode these. How can I access the lower parts of a snapshot?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine. Block 100 isn't going to change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to not use match snapshot of the whole body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thing is that archive_unstable_body only responds with the extrinsics array. However toMatchSnapshot is for the body, the header etc. So if I could have selected juste the extrinsics from this snaptshot, it would have been ideal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you misunderstood how snapshot works. it is for any shapes of data. run yarn vitest -u file/name.ts to generate/update snapshots
https://vitest.dev/guide/snapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I have indeed no idea, and was definitely looking for help. I'll check it out in the morning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the guidance, it's now using a snapshot

*
* @return Block extrinsics
*/
export const archive_unstable_body: Handler<[HexString], HexString[]> = async (context, [hash]) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like me to create a new archive folder, and put this function there?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will make finding things a bit easier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, I also moved the archive alias.

@Tbaut Tbaut requested review from xlc and ermalkaleci December 11, 2024 08:54
@xlc xlc merged commit 738d23a into AcalaNetwork:master Dec 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support archive_unstable_body
3 participants