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

fix: only query finalized blocks in javascript client #46

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

tlovell-sxt
Copy link
Contributor

Rationale for this change

A difference between the behavior of the rust and javascript clients has been observed which leads to StaleTableData errors in the javascript. When no particular block was requested, the javascript client was simply using the jsonrpc getStorage method without supplying a block. In this case, the jsonrpc uses the latest block, which is not necessarily finalized. On the other hand, the rust was implicitly requesting the latest finalized block via subxt. This change makes it so the javascript is only requesting finalized blocks too, which is important since only events in finalized blocks are inserted to the database.

What changes are included in this PR?

  • getFinalizedHead method added to javascript client
  • if blockHash is null, the finalized head is requested

Are these changes tested?

No.

Copy link

github-actions bot commented Nov 25, 2024

0.4.1

Bug Fixes

  • only query finalized blocks in javascript client (8222b5c

@tlovell-sxt tlovell-sxt force-pushed the fix/js-client-latest-finalized branch from d360eaa to d351afe Compare November 25, 2024 23:34
Dustin-Ray
Dustin-Ray previously approved these changes Nov 25, 2024
Copy link
Contributor

@Dustin-Ray Dustin-Ray left a comment

Choose a reason for hiding this comment

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

LGTM - Thank you

A difference between the behavior of the rust and javascript clients has
been observed which leads to StaleTableData errors in the javascript.
When no particular block was requested, the javascript client was simply
using the jsonrpc getStorage method without supplying a block. In this
case, the jsonrpc uses the latest block, which is not necessarily
finalized. On the other hand, the rust was implicitly requesting the
latest finalized block via subxt. This change makes it so the javascript
is only requesting finalized blocks too, which is important since only
events in finalized blocks are inserted to the database.
@JayWhite2357 JayWhite2357 merged commit 9464746 into main Nov 26, 2024
8 checks passed
@JayWhite2357 JayWhite2357 deleted the fix/js-client-latest-finalized branch November 26, 2024 01:31
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.

3 participants