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

fix Telescope encoding Decimal #10080

Merged
merged 6 commits into from
Sep 16, 2024
Merged

fix Telescope encoding Decimal #10080

merged 6 commits into from
Sep 16, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented Sep 12, 2024

closes: #10072

Description

We can't use cosmjs/math because it uses bn.js which is huge. They've decided not to remove it from cosmjs/math so we patched Telescope to use its own Decimal module. However the subset chosen started breaking with the use of Query modules.

Updating the patch was a giant pain so instead this sources from a fork, https://github.com/agoric-labs/telescope/tree/agoric-safe/

When updating that fork, the assets have to be build and pushed because they're not published to NPM.

Also, the code built should be compatible with what's currently published to NPM because the other packages will be sourced from there. Note that this fork is currently behind upstream (agoric-labs/telescope@agoric-safe...cosmology-tech:telescope:main ) because this commit requires an unpublished @cosmology/utils (symption is toPosixPath undefined).

Security Considerations

sources from a repo using gitpkg.vercel.app which could modify the contents in transit. The yarn.lock doesn't have an integrity check for Git sources. However this code is only used for codegen so any malice or even error would be detected in the new output.

Scaling Considerations

n/a

Documentation Considerations

The fork updating process is not obvious. I hope the PR description suffices.

Testing Considerations

The new build QueryDelegatorDelegationsResponse test fails under master, showing that it solves the problem.

Upgrade Considerations

n/a

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

🥷

@@ -74,3 +75,21 @@ test('build Query Packet', t => {
'eyJkYXRhIjoiQ2pvS0ZBb0xZMjl6Ylc5ek1YUmxjM1FTQlhWaGRHOXRFaUl2WTI5emJXOXpMbUpoYm1zdWRqRmlaWFJoTVM1UmRXVnllUzlDWVd4aGJtTmwiLCJtZW1vIjoiIn0=',
);
});

test('build QueryDelegatorDelegationsResponse', t => {
Copy link
Member

Choose a reason for hiding this comment

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

I think I ran into trouble parsing before. Do you know whether we already have a test for that? It seems pretty cheap to add one here.

@@ -136,7 +144,7 @@
"devDependencies": {
"@agoric/cosmos": "^0.34.1",
"@ava/typescript": "^4.1.0",
"@cosmology/telescope": "^1.7.1",
"@cosmology/telescope": "https://gitpkg.vercel.app/agoric-labs/telescope/packages/telescope?8d2c2f6ba637a5578eead09a7368dc41c262a9d0",
Copy link
Member

Choose a reason for hiding this comment

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

Confirm my understanding here, please? The reason for gitpkg rather than a link to github.com is that the package we want is not at the top level?

Copy link
Member

Choose a reason for hiding this comment

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

Ah... I see internal discussion Aug 20 to confirm that others in the shop know about gitpkg.

Copy link

cloudflare-workers-and-pages bot commented Sep 12, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: c1c5a6f
Status: ✅  Deploy successful!
Preview URL: https://036f7b54.agoric-sdk.pages.dev
Branch Preview URL: https://10072-bigint-decimal.agoric-sdk.pages.dev

View logs

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Sep 12, 2024
*/
export const TimestampProtoShape = { seconds: M.nat(), nanos: M.number() };
export const TimestampProtoShape = { seconds: M.string(), nanos: M.number() };
Copy link
Member

Choose a reason for hiding this comment

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

Good catch. I would like us to add an E2E test for the LocalOrchAcct staking flows (Undelegate for this particular change) , perhaps in the course of #10048 and/or #9838

Copy link
Member Author

@turadg turadg Sep 13, 2024

Choose a reason for hiding this comment

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

fwiw I didn't catch this analytically. it was caught by your improvement to JsonSafe in telescope that we finally have in agoric-sdk.

That required this change:

      return /** @type {JsonSafe<MsgUndelegateResponse>} */ ({
        // 5 seconds from unix epoch
-        completionTime: { seconds: 5n, nanos: 0 },
+        completionTime: { seconds: '5', nanos: 0 },

Which then required the guard change.

@mergify mergify bot merged commit 67a57a4 into master Sep 16, 2024
82 checks passed
@mergify mergify bot deleted the 10072-bigint-Decimal branch September 16, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cosmic-proto toProtoMsg relying on Decimal fail
3 participants