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

(De-)serialize BigInt from/to JSON number in Quint import #2661

Merged
merged 5 commits into from
Jul 24, 2023

Conversation

thpani
Copy link
Collaborator

@thpani thpani commented Jul 24, 2023

#2654 fixed the deserialization of QuintInt.value into a Scala BigInt.
However, this is not the only TypeScript bigint needing conversion:
All Quint IDs, plus the lookup table references, are also TypeScript bigints and should be deserialized into Scala BigInts.

upickle's built-in BigInt (de)serializer reads/writes BigInts only from/to JSON strings.
Thus, there's two options for Apalache <-> Quint compatiblity:

  1. Read/write all bigints as strings from Quint.
  2. Extend upickle to support (de)serializing BigInts from/to JSON numbers, which can be arbitrarily long. This is how json-bigint already behaves on the Quint side.

A brief investigation showed that approach (1) is non-trivial; for example, it would break the JSON re-import inside Quint.

This PR implements approach (2):

  • Extend QuintDeserializer with custom BigInt{Reader,Writer} implicits to read/write JSON numbers.
  • Port the remaining Quint IDs to BigInts.
  • Revert commit 2a073ab, which wrapped all QuintInt.values in integration tests into strings as part of Deserialize QuintInt.value as BigInt #2654. Since we now read/write JSON numbers, this has become unnecessary.

Closes informalsystems/quint#1055

  • Tests added for any new code
  • Ran make fmt-fix (or had formatting run automatically on all files edited)
  • Documentation added for any new functionality
  • Entries added to ./unreleased/ for any new functionality

Copy link
Collaborator

@Kukovec Kukovec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the two json files are generated by something, so I didn't read them. The rest looks good.

@thpani
Copy link
Collaborator Author

thpani commented Jul 24, 2023

I assume the two json files are generated by something, so I didn't read them. The rest looks good.

Aaah yes, that's the revert commit. Thanks!

We override the upickle implementation, which only (de-)serializes
from/to strings.
@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2023

Codecov Report

Merging #2661 (9f08cea) into main (8ce5374) will decrease coverage by 0.05%.
The diff coverage is 50.00%.

❗ Current head 9f08cea differs from pull request most recent head ece1090. Consider uploading reports for the commit ece1090 to get more accurate results

@@            Coverage Diff             @@
##             main    #2661      +/-   ##
==========================================
- Coverage   78.55%   78.50%   -0.05%     
==========================================
  Files         455      455              
  Lines       15795    15817      +22     
  Branches     2589     2570      -19     
==========================================
+ Hits        12407    12417      +10     
- Misses       3388     3400      +12     
Impacted Files Coverage Δ
...ain/scala/at/forsyte/apalache/io/quint/Quint.scala 85.22% <ø> (ø)
...n/scala/at/forsyte/apalache/io/quint/QuintIR.scala 72.50% <50.00%> (-8.54%) ⬇️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@thpani thpani merged commit a434ef9 into main Jul 24, 2023
10 checks passed
Copy link
Contributor

@shonfeder shonfeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Glad to have the root cause sorted out :)

@thpani thpani deleted the th/qnt-parse-bigint branch July 24, 2023 11:29
@thpani thpani mentioned this pull request Jul 24, 2023
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

Successfully merging this pull request may close these issues.

quint verify converts big integers to MAX_INT somewhere
4 participants