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

Feature/lit 2407 js sdk add timestamp on each handshake to alert for when we #349

Conversation

joshLong145
Copy link

@joshLong145 joshLong145 commented Feb 9, 2024

Description

Adds an expiration check for latestBlockhash as after 30 seconds the hash is expired on the nodes and we should no longer generate new auth materials using the stale hash. getLatestBlockhash will now reconnect to nodes to fetch the latest hash. we need to connect to all nodes to assure the latestBlockhash returned is the same from all network participants.
Unfortunately this does break backwards compatibility as we now need to make getLatestBlockhash and async implementation as it calls async implementation internally. Since we must wait for the hash to refresh the method signature has now been made async

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

New e2e test has been made to force the blockhash to expire and cause the system to refresh its sate.

  • e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@joshLong145 joshLong145 changed the base branch from master to staging/3.1.3 February 9, 2024 00:22
…eature/lit-2407-js-sdk-add-timestamp-on-each-handshake-to-alert-for-when-we
});
}

if (Date.now() - this.lastblockHashRetrieved! >= 30_000) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we make 30_000 as constant

@joshLong145
Copy link
Author

closing for a new implementation using a setInterval for syncing block hashes implicitly. This will allow us to keep the current api surface.

@joshLong145 joshLong145 closed this Feb 9, 2024
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.

2 participants