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

wallet action, inter protocol data is wrapped in 2 JSON.stringify layers #7999

Open
dckc opened this issue Jul 1, 2023 · 5 comments
Open
Labels
bug Something isn't working performance Performance related issues wallet

Comments

@dckc
Copy link
Member

dckc commented Jul 1, 2023

Describe the bug

The .action field of MsgWalletSpendAction is JSON.stringify(capData) where capData includes a .body that is already JSON.stringify ed.

Senders pay by the byte, so the extra quoting costs.

To Reproduce

Steps to reproduce the behavior:

  1. generate a spend action; for example: inter bid by-price --price 7 --give 0.003IST --generate-only --from k1 >spend-action.json
  2. See lots of escaped quotes:
{"body":"#{\"method\":\"executeOffer\",\"offer\":{\"id\":\"bid-1688229012779\",\"invitationSpec\":{\"callPipe\":[[\"makeBidInvitation\",[\"$0.Alleged: BoardRemoteATOM brand\"]]],\"instancePath\":[\"auctioneer\"],\"source\":\"agoricContract\"},\"offerArgs\":{\"maxBuy\":{\"brand\":\"$0\",\"value\":\"+1000000000000\"},\"offerPrice\":{\"denominator\":{\"brand\":\"$0\",\"value\":\"+1\"},\"numerator\":{\"brand\":\"$1.Alleged: BoardRemoteIST brand\",\"value\":\"+7\"}}},\"proposal\":{\"give\":{\"Bid\":{\"brand\":\"$1\",\"value\":\"+3000\"}}}}}","slots":["board05557","board0257"]}

Expected behavior

One layer of JSON.stringify should suffice.

For example, send the .body and .slots as separate protobuf message fields.

Platform Environment

agoric-upgrade-10 mainnet

@dckc dckc added bug Something isn't working wallet performance Performance related issues labels Jul 1, 2023
@gibson042
Copy link
Member

related conversation: endojs/endo#1402 (comment)

@dckc
Copy link
Member Author

dckc commented Aug 1, 2023

a related PR was closed for lack of motivation:

this perhaps adds some motivation

@dckc dckc changed the title wallet action is wrapped in 2 JSON.stringify layers wallet action, inter protocol data is wrapped in 2 JSON.stringify layers Aug 1, 2023
@dckc
Copy link
Member Author

dckc commented Oct 4, 2023

Explorers

The contract explorer bounty is yet another context where I don't look forward to explaining the double-quoting convention.

Protobuf

Cosmos Explorers already have to deal with protobuf. Not to mention indexing / query stuff such as subquery:

In the OCapN context, I did a little playing around with protobuf encoding for passables:

Single-level JSON

I just worked up an idea that I had recently:

Comms / DeliverInbound format

Another option would be the format used in the Comms Message format used in DeliverInbound messages:

  • [${slots..};${methargs.body}](deliver:${remoteTargetSlot}::${slots..};${methargs.body})

for example: "1:0:deliver:ro+1:rp-40;#[\"getConfiguration\",[]]"

@dckc
Copy link
Member Author

dckc commented Oct 4, 2023

In endojs/endo#1804 (review) , @mhofman writes:

I would so much rather we properly split encoding from serialization for marshal, as discussed in endojs/endo#1478.

What would that look like for the offer example above?

Would it involve passing a complex object (requiring lots of allocations) through the swingset kernel rather than a body string?

@mhofman
Copy link
Member

mhofman commented Oct 4, 2023

Would it involve passing a complex object (requiring lots of allocations) through the swingset kernel rather than a body string?

Potentially, unless we have an optimization of not parsing a subset of the json, which is what @gibson042 and I mentioned we needed help from the parser for. In this PR you effectively implement that optimization for a subset of CapData json shapes. I'd prefer to take the approach of specifying the new CapDate tree format, and separating the concern of avoiding the parsing of the body tree as a future optional optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance Performance related issues wallet
Projects
None yet
Development

No branches or pull requests

3 participants