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

uintcv stores wrong number #1515

Closed
friedger opened this issue Jun 27, 2023 · 3 comments · Fixed by #1527
Closed

uintcv stores wrong number #1515

friedger opened this issue Jun 27, 2023 · 3 comments · Fixed by #1527
Assignees
Labels
bug Unwanted or unintended logic causing harm

Comments

@friedger
Copy link
Collaborator

What version of Stacks.js are you using?

6.5.4

Describe the bug

uintCV(10000000000000000000000000000000) => { type: 1, value: 9999999999999999635896294965248n }

How to reproduce

run the above code

Expected behavior

uintCV should encode the big number correctly

Additional context

Try to renew friedger.crashpunks on https://renewbns.com/

@friedger friedger added the bug Unwanted or unintended logic causing harm label Jun 27, 2023
@friedger
Copy link
Collaborator Author

uintCV("10000000000000000000000000000000"),
uintCV(10000000000000000000000000000000n),
uintCV(10000000000000000000000000000000)

=>

Object { type: 1, value: 10000000000000000000000000000000n }
Object { type: 1, value: 10000000000000000000000000000000n }
Object { type: 1, value: 9999999999999999635896294965248n }

@friedger
Copy link
Collaborator Author

friedger commented Jun 27, 2023

There should be an error because the number is larger than Number.MAX_SAFE_INTEGER

@janniks
Copy link
Collaborator

janniks commented Jun 27, 2023

Yep, this is just the BigInt constructor not working correctly with too large numbers. example

Will update to check bounds and throw error telling to use with string or hex construction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unwanted or unintended logic causing harm
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants