feat!: Convert buffer usage to Uint8Array#306
Conversation
buffer usage to Uint8Arraybuffer 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 Uint8Arraybuffer 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.
Is this function still used? maybe delete it or refactor the usage of Buffer here
There was a problem hiding this comment.
Good catch. Not sure how I missed that but will do.
wemeetagain
left a comment
There was a problem hiding this comment.
Generally LGTM, thanks for further simplifying the codebase.
Just had one small comment
|
@wemeetagain should be ready for final review now. |
Manually applied changes from [this PR](ChainSafe/discv5#306) to remove vulnerable dep on `bigint-buffer` to [this branch](ChainSafe/discv5@master...AztecProtocol:discv5:chore/upgrade-yarn-v2) Co-authored-by: Santiago Palladino <santiago@aztec-labs.com> Co-authored-by: mralj <nikola.mratinic@gmail.com>
Manually applied changes from [this PR](ChainSafe/discv5#306) to remove vulnerable dep on `bigint-buffer` to [this branch](ChainSafe/discv5@master...AztecProtocol:discv5:chore/upgrade-yarn-v2)
…17541) Manually applied changes from [this PR](ChainSafe/discv5#306) to remove vulnerable dep on `bigint-buffer` to [this branch](ChainSafe/discv5@master...AztecProtocol:discv5:chore/upgrade-yarn-v2)
…17541) Manually applied changes from [this PR](ChainSafe/discv5#306) to remove vulnerable dep on `bigint-buffer` to [this branch](ChainSafe/discv5@master...AztecProtocol:discv5:chore/upgrade-yarn-v2)
Manually applied changes from [this PR](ChainSafe/discv5#306) to remove vulnerable dep on `bigint-buffer` to [this branch](ChainSafe/discv5@master...AztecProtocol:discv5:chore/upgrade-yarn-v2)
…17541) Manually applied changes from [this PR](ChainSafe/discv5#306) to remove vulnerable dep on `bigint-buffer` to [this branch](ChainSafe/discv5@master...AztecProtocol:discv5:chore/upgrade-yarn-v2)
Removed dependency on bigint-buffer by patching discv5. Repo [link](https://github.com/NethermindEth/discv5/tree/mralj/chore/backport-306-v2) Applied changes are from [this PR](ChainSafe/discv5#306) This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Removed dependency on bigint-buffer by patching discv5. Repo [link](ChainSafe/discv5@master...NethermindEth:discv5:mralj/chore/backport-306-v3) The applied changes are inspired by [this PR](ChainSafe/discv5#306), but the changeset is much smaller -- I have only removed the dependency on `bigint-buffer` and made it work, because previous attempts made code flaky. This has been done to remove vulnerable transitive dependency ([link](https://github.com/AztecProtocol/aztec-packages/security/dependabot/395))
Fixes #303
Problems:
enrpackages referencesglobalThis.Bufferin the base64 conversion utilities and this causes segmentation faults in theUltralighthive testsBufferwas only used for bytes (instead ofUint8Array) because of the requirements ofbcryptowhich only acceptedBufferas input.bigint-bufferpackage causes CI failures in Ultralight with arbitrarynapi-ok === falseerrors that are indecipherableSolution:
Buffertypes and utilities and replace with equivalent Uint8ArraystoHex/fromHexusage tohexToBytes/bytesToHexfromethereum-cryptographyutf8conversion toethereum-cryptographyutf8ToBytes/bytesToUtf8utilitiesglobalThis.bufferscure/base(author same as@noble/hashes)bigint-bufferand replace with internalbigIntToBytes/bytesToBigIntconversion utilities