graphprotocol / graphprotocol/graph-node
Bug: BigInt.toString produces incorrect decimal string for large uint256 numbers
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Calling BigInt.toString in graph-ts execution context produces an incorrect results for large numbers
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Given this hex: 0x344435891c9a299443ad1ff6f97829fcf3aff343795f7eb86730d1d0f968cb54, various popular js libraries successfully convert the hex to the following decimal string: 23640783215816018536649662874651199072550547213372823297679392888119521495892
In the graph-ts execution context, BigInt.toString should return the same decimal string.
However BigInt.fromByteArray(ByteArray.fromHexString(hex)).toString() returns the following:
38353673751782187045679142956196807757628143702081891553022150933500130575412, which is incorrect.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the graph-ts execution path for BigInt.toString and reproduce the issue using BigInt.fromByteArray(ByteArray.fromHexString(hex)) with the hexadecimal value in the report. Compare the returned decimal string with the expected value and verify that large uint256 values convert correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100