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

Sidecar fails to handle multi block migration events #1538

Closed
ermalkaleci opened this issue Nov 6, 2024 · 5 comments · Fixed by #1541
Closed

Sidecar fails to handle multi block migration events #1538

ermalkaleci opened this issue Nov 6, 2024 · 5 comments · Fixed by #1541
Assignees

Comments

@ermalkaleci
Copy link

Description
Sidecar fails to handle events generated by pallet-migrations. Sidecar tries to find extrinsic but there're no extrinsic other than inherents during migrations

SAS_SUBSTRATE_URL=wss://rpc.shiden.astar.network npx @substrate/api-sidecar
curl http://localhost:8080/blocks/0xc26eb7b19378e953c80ef9749df2b5ae67a7bdb17b3ad9b9a0ee9c1810438a9f
"Missing extrinsic 2 in block 0xc26eb7b19378e953c80ef9749df2b5ae67a7bdb17b3ad9b9a0ee9c1810438a9f"

@Imod7 Imod7 self-assigned this Nov 7, 2024
@Imod7
Copy link
Contributor

Imod7 commented Nov 7, 2024

@ermalkaleci Thank you for the issue.

The error you are seeing is triggered here in the BlockService file which means that the check for phase.isApplyExtrinsic was found true.

In Sidecar, when an event is in the ApplyExtrinsic phase, we expect that there is an extrinsic associated to it (mentioned also in a SE answer). Then, we retrieve that extrinsic by accessing the index found in phase.asApplyExtrinsic.toNumber.

In the block you indicated, if I check the contents of phase for the event {method: 'MigrationAdvanced', section: 'multiBlockMigrations'...} that you mentioned, I get {"applyExtrinsic":2} which means you relate this event with the extrinsic in index 2. I can see the same in Subscan :

mbm

and if I click on the indicated extrinsic 7675808-2 I am redirected to a page not found as you would expect.

Before adjusting Sidecar's code, I would like to determine if the issue lies within Sidecar's code or your migration logic. To clarify this, I have the following questions:

  • Why is the phase set as ApplyExtrinsic when no extrinsic is attached to it?
  • And if setting the phase as ApplyExtrinsic is necessary, why applyExtrinsic has the value of 2 when there is no extrinsic with index 2?

@ermalkaleci
Copy link
Author

There's no issue with Shiden migration. We're using pallet-migrations from polkadot-sdk. While chain goes through migration, it applies only inherent extrinsic and then apply the migration. The extrinsic index will be incremented by 2 after inherent are applied so any event after will have extrinsic index 2 although there's no actual extrinsic triggering the migration. Migration is executed by the system itself. I don't know what will be the best solution to this but probably ignoring them or not link with an extrinsic may be a solution for now.

@ermalkaleci
Copy link
Author

@ggwpez Hey Oliver I am tagging you since you worked on this pallet :)
I don't know if I should call this a feature or a bug :)
Since inherent events will update execution phase migration events are marked as applyExtrinsic: 2

@Imod7
Copy link
Contributor

Imod7 commented Nov 9, 2024

Apologies for the late reply. I will put a fix asap on this so we can correctly output the events related to multiBlockMigrations.

@ggwpez already shared this PR paritytech/polkadot-sdk#3666 and when it gets merged I expect that these type of events will be set in phase ApplyInherent so in the future we would not have this issue anymore.

@ggwpez
Copy link
Member

ggwpez commented Nov 11, 2024

Yea sorry i think its a bug in FRAME, the phases are not quite right when a MBM is running.

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 a pull request may close this issue.

3 participants