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

Json decoders truncating long numbers in JS mode #1023

Open
kushti opened this issue Aug 1, 2024 · 1 comment
Open

Json decoders truncating long numbers in JS mode #1023

kushti opened this issue Aug 1, 2024 · 1 comment

Comments

@kushti
Copy link
Member

kushti commented Aug 1, 2024

As an example,

{
  "extensionId" : "00cce45975d87414e8bdd8146bc88815be59cd9fe37a125b5021101e05675a18",
  "votes" : "000000",
  "timestamp" : 4928911477310178288,
  "size" : 223,
  "unparsedBytes" : "",
  "stateRoot" : {
      "digest" : "5c8c00b8403d3701557181c8df800001b6d5009e2201c6ff807d71808c00019780",
      "treeFlags" : "0",
      "keyLength" : "32"
  },
  "height" : 614400,
  "nBits" : 37748736,
  "version" : 2,
  "id" : "5603a937ec1988220fc44fb5022fb82d5565b961f005ebb55d85bd5a9e6f801f",
  "adProofsRoot" : "5d3f80dcff7f5e7f59007294c180808d0158d1ff6ba10000f901c7f0ef87dcff",
  "transactionsRoot" : "f17fffacb6ff7f7f1180d2ff7f1e24ffffe1ff937f807f0797b9ff6ebdae007e",
  "extensionRoot" : "1480887f80007f4b01cf7f013ff1ffff564a0000b9a54f00770e807f41ff88c0",
  "minerPk" : "03bedaee069ff4829500b3c07c4d5fe6b3ea3d3bf76c5c28c1d4dcdb1bed0ade0c",
  "powOnetimePk" : "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
  "powNonce" : "0000000000003105",
  "powDistance" : 0,
  "adProofsId" : "dec129290a763f4de41f04e87e2b661dd59758af6bdd00dd51f5d97c3a8cb9b5",
  "transactionsId" : "eba1dd82cf51147232e09c1f72b37c554c30f63274d5093bff36849a83472a42",
  "parentId" : "ac2101807f0000ca01ff0119db227f202201007f62000177a080005d440896d0"
}

when parsed in JS via

 JsonCodecs.headerDecoder.decodeJson(parse(headerJson).toOption.get).toOption.get

has timestamp 4928911477310178000, not 4928911477310178288

@satsen
Copy link

satsen commented Nov 2, 2024

numbers in javascript arent 64 bits thats why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants