Skip to content

JS Dash SDK cannot send documents transitions (number type overflow) #2436

Open
@pshenmic

Description

@pshenmic

Issue

While working on Web Dash DApp, we were able to create an initial implementation, however, during further debugging we came across previously unknown issue that is making unable to create any more documents batch transactions.

It looks like that first 24 (or sometimes even less) documents transactions executes correctly, but then all transactions suddenly starts fails with error:

Error submitting document: Error: Identity Y6WwZ3LYETZjsekjWjoZWnSBu9o5P5MD4Z3HmVGJiYt is trying to set an invalid identity nonce. The current identity nonce is 36028797018963994, we are setting 25, error is nonce already present in past

The issue is that identityNonce and identityContractNonce is not just a number that being incremented, but rather a u64 value. However, js is not able to always correctly handle it:

Image

Which leads to incorrect nonce being included in the further documents batch transactions, making it not possible to interact with that data contract with your identity anymore.

Javascript does have BigInt feature to properly store it without any loss, however it is not widely supported still yet, and protobufjs library did not implement it, and incorrectly casts it to number. There is one other option like protocolbuffers/protobuf#3666 (comment) to represent it as string, but unfortunately it didn't work in our setup. From what I've read the recommendation is to read as string.

Possible Solution

Patch client code, fork gRPC library or change all u64 to string in the schema

Steps to Reproduce (for bugs)

  1. Create documents from one identity to specific data contract until you hit the nonce issue

Context

Your Environment

  • Version used:
  • Environment name and version (e.g. Chrome 39, node.js 5.4):
  • Operating System and version (desktop, server, or mobile):
  • Link to your project:

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingjs-sdkJS Dash SDK related

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions