-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: add getAddressLookupTable method to Connection #27127
feat: add getAddressLookupTable method to Connection #27127
Conversation
Codecov Report
@@ Coverage Diff @@
## master #27127 +/- ##
===========================================
- Coverage 81.9% 76.9% -5.0%
===========================================
Files 631 48 -583
Lines 174252 2506 -171746
Branches 0 355 +355
===========================================
- Hits 142728 1928 -140800
+ Misses 31524 448 -31076
- Partials 0 130 +130 |
80b3df5
to
a460255
Compare
} | ||
|
||
isActive(): boolean { | ||
const U64_MAX = 2n ** 64n - 1n; |
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.
Fun fact: this change made web3.js
incompatible with React Native because:
- JavaScript Core (JSC) doesn't support the exponentiation operator (
**
) so there's a transform that converts2n ** 64n
toMath.pow(2n, 64n)
and then you're in trouble becauseMath.pow()
doesn't work withbigint
(runtime fatal) - Hermes supports the exponentiation operator but doesn't support
bigint
yet.
No change necessary – I'm working on it.
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.
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.
Ouch, thanks for the heads up. Seems worthwhile to use a literal here then, or do you think it's not worth the trouble?
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.
There are now three places in web3.js
that use BigInt
- This, with exponentiation
- @noble/ed25519, with exponentiation
- @noble/secp256k1, with exponentiation
If we inline the computation and convince the noble libs to do the same (eg. just literally change this to BigInt('18446744073709551616')
and comment it) then:
- Less CPU overhead (nice)
- JSC: still fucked because JSC doesn't support
BigInt
- JSC with
BigInt
polyfill: still fucked because polyfills don't permit arithmetic (require('big-integer')(1) + require('big-integer')(1)
is actually nonsense, because it's basicallyObject + Object
) - Pre 0.70 Hermes: still fucked because of no
BigInt
support - >=0.70 Hermes: Works, but so does the original exponentiated code.
I'm going to post about this on September 1st, but my recommendation going forward for anyone who wants to use Solana libraries in React Native going forward will be to upgrade to React Native 0.70 and switch to Hermes. Big integers are critical for most crypto use cases, Hermes is now the default in React Native from 0.70 onward, and the way out of this mess is forward.
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.
Ok, really appreciate the breakdown on this. I'll leave as-is then
Problem
No way to fetch and decode address lookup tables with web3
Summary of Changes
getAddressLookupTable
method toConnection
Fixes #