ergoplatform / sigmastate-interpreter

ErgoScript compiler and ErgoTree Interpreter implementation for Ergo blockchain
MIT License
63 stars 41 forks source link

Json decoders truncating long numbers in JS mode #1023

Open kushti opened 3 months ago

kushti commented 3 months ago

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 commented 2 weeks ago

numbers in javascript arent 64 bits thats why