-
Notifications
You must be signed in to change notification settings - Fork 15
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!: Convert buffer
usage to Uint8Array
#306
Conversation
buffer
usage to Uint8Array
buffer
usage to Uint8Array
@wemeetagain Hopefully this isn't too far beyond what you had in mind with regard to #303. Removing buffers provided an opportunity to fix 2 other pain points for Ultralight. If the |
@wemeetagain bump |
buffer
usage to Uint8Array
buffer
usage to Uint8Array
packages/discv5/src/util/toBuffer.ts
Outdated
} | ||
|
||
export function numberToBuffer(value: number, length: number): Buffer { | ||
export function numberToBuffer(value: number, length: number): Uint8Array { |
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.
Is this function still used? maybe delete it or refactor the usage of Buffer here
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.
Good catch. Not sure how I missed that but will do.
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.
Generally LGTM, thanks for further simplifying the codebase.
Just had one small comment
@wemeetagain should be ready for final review now. |
Fixes #303
Problems:
enr
packages referencesglobalThis.Buffer
in the base64 conversion utilities and this causes segmentation faults in theUltralight
hive testsBuffer
was only used for bytes (instead ofUint8Array
) because of the requirements ofbcrypto
which only acceptedBuffer
as input.bigint-buffer
package causes CI failures in Ultralight with arbitrarynapi-ok === false
errors that are indecipherableSolution:
Buffer
types and utilities and replace with equivalent Uint8ArraystoHex
/fromHex
usage tohexToBytes
/bytesToHex
fromethereum-cryptography
utf8
conversion toethereum-cryptography
utf8ToBytes
/bytesToUtf8
utilitiesglobalThis.buffer
scure/base
(author same as@noble/hashes
)bigint-buffer
and replace with internalbigIntToBytes
/bytesToBigInt
conversion utilities