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

feat: implement bigint support #728

Merged
merged 1 commit into from
Dec 9, 2024
Merged

feat: implement bigint support #728

merged 1 commit into from
Dec 9, 2024

Conversation

glevco
Copy link
Contributor

@glevco glevco commented Aug 1, 2024

Depends on #797

Motivation

See https://github.com/HathorNetwork/internal-issues/issues/363.

This PR adds the necessary structures to support bigint fields, however it does not yet change the OutputValueType to bigint.

Acceptance Criteria

  • Implement bigIntToBytes() and remove signedIntToBytes() support for 8 bytes.
  • Implement unpackToBigInt() and remove unpackToInt() support for 8 bytes.
  • Update bytesToOutputValue() to use unpackToBigInt().
  • Dependencies:
    • Added zod.
    • level-transcoder was added explicitly but was already an indirect dependency.
    • Removed long.
  • Create api/txApi and api/wallet Zod schemas, updating requests to use transformJsonBigIntResponse().
  • Update Output.valueToBytes() to use bigIntToBytes() instead of signedIntToBytes().
  • Create Zod schemas for some necessary interfaces.
  • Use Zod parsing in WS history txs.
  • Update LevelDB sublevels to use jsonBigIntEncoding() where necessary.
  • Implement utils/bigint.ts.
  • Change WS handler to use JSONBigInt.parse() instead of JSON.parse().
  • Change TS target to es2020 instead of es2018, adding support for bigint.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@glevco glevco self-assigned this Aug 1, 2024
@glevco glevco force-pushed the feat/bigint-functions branch 3 times, most recently from acb3f0f to badafe5 Compare August 1, 2024 16:46
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 10 lines in your changes missing coverage. Please review.

Project coverage is 80.72%. Comparing base (d10dbc8) to head (1e6331e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/api/wallet.ts 50.00% 3 Missing ⚠️
src/new/wallet.js 60.00% 2 Missing ⚠️
src/utils/bigint.ts 94.44% 2 Missing ⚠️
src/utils/storage.ts 33.33% 2 Missing ⚠️
src/utils/buffer.ts 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #728      +/-   ##
==========================================
+ Coverage   80.55%   80.72%   +0.16%     
==========================================
  Files          81       85       +4     
  Lines        6471     6547      +76     
  Branches     1396     1421      +25     
==========================================
+ Hits         5213     5285      +72     
- Misses       1245     1249       +4     
  Partials       13       13              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glevco glevco force-pushed the feat/bigint-functions branch from badafe5 to fde977c Compare August 2, 2024 16:46
@glevco glevco changed the title wip feat: implement bigint support Aug 2, 2024
@glevco glevco force-pushed the refactor/typing-improvements branch from efe15e4 to c744d46 Compare August 2, 2024 20:27
@glevco glevco force-pushed the feat/bigint-functions branch from fde977c to 6f9fa0c Compare August 2, 2024 20:29
@glevco glevco force-pushed the refactor/typing-improvements branch from c744d46 to 1b31680 Compare August 2, 2024 20:45
@glevco glevco force-pushed the feat/bigint-functions branch from 6f9fa0c to 6c44af7 Compare August 2, 2024 20:45
@glevco glevco force-pushed the refactor/typing-improvements branch from 1b31680 to 8cecc72 Compare August 2, 2024 21:40
@glevco glevco force-pushed the feat/bigint-functions branch from 6c44af7 to 8ddab19 Compare August 2, 2024 21:42
@glevco glevco marked this pull request as ready for review August 5, 2024 18:25
@glevco glevco requested a review from pedroferreira1 as a code owner August 5, 2024 18:25
@glevco glevco requested a review from r4mmer August 5, 2024 19:53
@glevco glevco force-pushed the refactor/typing-improvements branch from 8cecc72 to 59e0572 Compare August 13, 2024 21:11
Base automatically changed from refactor/typing-improvements to master August 15, 2024 16:56
@glevco glevco changed the base branch from master to ci/node-v22 November 14, 2024 15:31
@glevco glevco force-pushed the feat/bigint-functions branch 9 times, most recently from 6f6d928 to c20d3cb Compare November 14, 2024 18:23
@glevco glevco force-pushed the feat/bigint-functions branch 2 times, most recently from b23e32b to 291b937 Compare November 14, 2024 21:19
Base automatically changed from ci/node-v22 to master November 18, 2024 15:57
@glevco glevco force-pushed the feat/bigint-functions branch 2 times, most recently from 4f6195a to ed121c6 Compare November 18, 2024 17:21
@glevco glevco mentioned this pull request Nov 18, 2024
1 task
@glevco glevco force-pushed the feat/bigint-functions branch from 9ef97a7 to 1e6331e Compare December 9, 2024 21:11
@glevco glevco merged commit 0b28a4f into master Dec 9, 2024
8 checks passed
@glevco glevco deleted the feat/bigint-functions branch December 9, 2024 21:38
r4mmer added a commit that referenced this pull request Dec 13, 2024
* origin/master:
  feat: add support for max output values (#708)
  chore: remove support for Node v20 (#799)
  feat: implement bigint support (#728)
  feat: consider nano caller to the address metadata in the storage (#801)
  chore(deps): bump axios from 1.7.2 to 1.7.7 (#752)
  ci: add support for node v22 (#797)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants