-
Notifications
You must be signed in to change notification settings - Fork 222
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
smart-wallet PSM trade performs 17 account-state storage updates #6038
Comments
Oh, the |
@dckc mentioned that there's half a dozen Notifiers for various parts of the account, and then one sort of meta-Notifier that follows all of them, and it's the meta-Notifier that writes out state updates to chainStorage. If it turns out that the time we're spending doing these updates is significant, we might want to consider a scheme where there are zero smaller notifiers, and the smart wallet is responsible for knowing when its operation is complete, and then prodding the one meta-Notifier to write out a single update with all the changes in it. |
Of the 84 cranks that were
We spent a total of 730ms doing
|
Describe the bug
@dckc and I were examining a slogfile containing a single smart-wallet AMM trade. In the current tree (commit afabe7f) this needed 171 deliveries, consisting of 84
dispatch.deliver
s and 87dispatch.notify
(promise resolutions). Once we increased the per-block computron limit (by about 10x), this took a total of 1.575 seconds to complete.Many of those deliveries are to update the chain storage data. The chain storage nodes are owned by v1-bootstrap, so we can grep the slogfile for
toBridge
to find where various vats are asking v1-bootstrap to perform a syscall to send a message through the bridge to the cosmos side. I counted onetoBridge
call to update storage:published.psm.IST.AUSD.metrics
, three tobank
(1:set ibc/usdc1234 = 4000440
, 2:set ibc/usdc1234 = 0
, 3:set uist = 4000039
), and 17 to update storage:published.wallet.agoricNNN
(the address performing the trade).The bodies of the
toBridge
calls (and thesetValue
calls which prompted them) grew somewhat over the course of those 17 (the 142/893/139/137 are the non-account ones described above, while the account ones grew from 8872 to 15655):The KernelDeliveryObject (as recorded in the slogfile) for the last value written into the account storage key was:
Which turns into a bridge-device invocation of:
storage
append
published.wallet.agoric1hfcw2ryh8duca65gadgttvn4sdgxvafs96n6d8
The
value
, once decoded, yields:["unknown:1","board0425","board0074","board04312","board00613","board02314","board05311","board05815","board06120","unknown:6","unknown:10","unknown:18","unknown:19","unknown:20","unknown:22","unknown:4","unknown:3","unknown:24","unknown:15","unknown:8","unknown:25"]
The
body
, once decoded, yields:wallet state body
```json { "contacts": [ [ "Self", { "actions": { "@qclass": "slot", "iface": "Alleged: contact", "index": 0 }, "address": "agoric1hfcw2ryh8duca65gadgttvn4sdgxvafs96n6d8", "depositBoardId": "board04719", "meta": { "id": 1 } } ] ], "dapps": [], "issuers": [ [ "AUSD", { "assetKind": "nat", "brand": { "@qclass": "slot", "iface": "Alleged: AUSD brand", "index": 1 }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "issuer": { "@qclass": "slot", "iface": "Alleged: AUSD issuer", "index": 2 }, "issuerBoardId": "board0074", "meta": { "id": 4 } } ], [ "BLD", { "assetKind": "nat", "brand": { "@qclass": "slot", "iface": "Alleged: BLD brand", "index": 3 }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "issuer": { "@qclass": "slot", "iface": "Alleged: BLD issuer", "index": 4 }, "issuerBoardId": "board00613", "meta": { "id": 5 } } ], [ "IST", { "assetKind": "nat", "brand": { "@qclass": "slot", "iface": "Alleged: IST brand", "index": 5 }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "issuer": { "@qclass": "slot", "iface": "Alleged: IST issuer", "index": 6 }, "issuerBoardId": "board05311", "meta": { "id": 6 } } ], [ "zoe invite", { "assetKind": "set", "brand": { "@qclass": "slot", "iface": "Alleged: Zoe Invitation brand", "index": 7 }, "displayInfo": { "assetKind": "set" }, "issuer": { "@qclass": "slot", "iface": "Alleged: Zoe Invitation issuer", "index": 8 }, "issuerBoardId": "board06120", "meta": { "id": 2 } } ] ], "offers": [ { "actions": { "@qclass": "undefined" }, "id": "unknown#1661288219007", "installation": { "@qclass": "undefined" }, "installationPetname": "unnamed-2", "instance": { "@qclass": "undefined" }, "instanceHandleBoardId": "board00917", "instancePetname": "unnamed-1", "invitationDetails": { "description": "swap", "handle": { "kind": "unnamed", "petname": "unnamed-3" }, "installation": { "kind": "unnamed", "petname": "unnamed-2" }, "instance": { "kind": "unnamed", "petname": "unnamed-1" } }, "invitationMaker": { "method": "makeSwapInvitation" }, "meta": { "creationStamp": 1661288219007, "id": "1661288219007" }, "proposalForDisplay": { "exit": { "onDemand": null }, "give": { "In": { "amount": { "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "value": 4000440 }, "purse": { "@qclass": "slot", "iface": "Alleged: Virtual Purse", "index": 9 }, "pursePetname": "AUSD" } }, "want": { "Out": { "amount": { "brand": { "kind": "brand", "petname": "IST" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "value": 4000000 }, "purse": { "@qclass": "slot", "iface": "Alleged: Virtual Purse", "index": 10 }, "pursePetname": "Agoric stable local currency" } } }, "proposalTemplate": { "give": { "In": { "pursePetname": "AUSD", "value": 4000440 } }, "want": { "Out": { "pursePetname": "Agoric stable local currency", "value": 4000000 } } }, "rawId": "1661288219007", "requestContext": { "dappOrigin": "unknown", "origin": "unknown" }, "status": "accept" } ], "payments": [ { "actions": { "@qclass": "slot", "iface": "Alleged: payment actions", "index": 11 }, "assetKind": "nat", "brand": { "@qclass": "slot", "index": 1 }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 10 }, "payment": { "kind": "unnamed", "petname": "unnamed-5" } }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 10 }, "payment": { "kind": "unnamed", "petname": "unnamed-5" }, "status": "pending" }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 10 }, "payment": { "kind": "unnamed", "petname": "unnamed-5" }, "status": "pending" }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 10 }, "payment": { "kind": "unnamed", "petname": "unnamed-5" }, "status": { "@qclass": "undefined" } }, "issuer": { "@qclass": "slot", "index": 2 }, "issuerBoardId": "board0074", "meta": { "id": 10 }, "payment": { "@qclass": "slot", "iface": "Alleged: AUSD payment", "index": 12 }, "status": { "@qclass": "undefined" } }, { "actions": { "@qclass": "slot", "iface": "Alleged: payment actions", "index": 13 }, "assetKind": "nat", "brand": { "@qclass": "slot", "index": 1 }, "depositedAmount": { "brand": { "@qclass": "slot", "index": 1 }, "value": { "@qclass": "bigint", "digits": "0" } }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "depositedAmount": { "brand": { "kind": "brand", "petname": "AUSD" }, "value": { "@qclass": "bigint", "digits": "0" } }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "AUSD" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 11 }, "payment": { "kind": "unnamed", "petname": "unnamed-6" } }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 11 }, "payment": { "kind": "unnamed", "petname": "unnamed-6" }, "status": "pending" }, "issuer": { "kind": "unnamed", "petname": "unnamed-4" }, "issuerBoardId": "board0074", "meta": { "id": 11 }, "payment": { "@qclass": "undefined" }, "status": "deposited" }, "issuer": { "@qclass": "slot", "index": 2 }, "issuerBoardId": "board0074", "meta": { "id": 11 }, "payment": { "@qclass": "undefined" }, "status": "deposited" }, { "actions": { "@qclass": "slot", "iface": "Alleged: payment actions", "index": 14 }, "assetKind": "nat", "brand": { "@qclass": "slot", "index": 5 }, "depositedAmount": { "brand": { "@qclass": "slot", "index": 5 }, "value": { "@qclass": "bigint", "digits": "4000039" } }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "IST" }, "depositedAmount": { "brand": { "kind": "brand", "petname": "IST" }, "value": { "@qclass": "bigint", "digits": "4000039" } }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "IST" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "displayPayment": { "assetKind": "nat", "brand": { "kind": "brand", "petname": "IST" }, "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "issuer": { "kind": "unnamed", "petname": "unnamed-7" }, "issuerBoardId": "board05311", "meta": { "id": 12 }, "payment": { "kind": "unnamed", "petname": "unnamed-8" } }, "issuer": { "kind": "unnamed", "petname": "unnamed-7" }, "issuerBoardId": "board05311", "meta": { "id": 12 }, "payment": { "kind": "unnamed", "petname": "unnamed-8" }, "status": "pending" }, "issuer": { "kind": "unnamed", "petname": "unnamed-7" }, "issuerBoardId": "board05311", "meta": { "id": 12 }, "payment": { "@qclass": "undefined" }, "status": "deposited" }, "issuer": { "@qclass": "slot", "index": 6 }, "issuerBoardId": "board05311", "meta": { "id": 12 }, "payment": { "@qclass": "undefined" }, "status": "deposited" } ], "purses": [ { "actions": { "@qclass": "slot", "iface": "Alleged: purse.actions", "index": 15 }, "brand": { "@qclass": "slot", "index": 7 }, "brandBoardId": "board05815", "brandPetname": "zoe invite", "currentAmount": { "brand": { "kind": "brand", "petname": "zoe invite" }, "value": [] }, "currentAmountSlots": { "body": "{\"brand\":{\"@qclass\":\"slot\",\"iface\":\"Alleged: Zoe Invitation brand\",\"index\":0},\"value\":[]}", "slots": [ { "kind": "brand", "petname": "zoe invite" } ] }, "depositBoardId": "board04719", "displayInfo": { "assetKind": "set" }, "meta": { "id": 3 }, "purse": { "@qclass": "slot", "iface": "Alleged: Zoe Invitation Purse purse", "index": 16 }, "pursePetname": "Default Zoe invite purse", "value": [] }, { "actions": { "@qclass": "slot", "iface": "Alleged: purse.actions", "index": 17 }, "brand": { "@qclass": "slot", "index": 1 }, "brandBoardId": "board0425", "brandPetname": "AUSD", "currentAmount": { "brand": { "kind": "brand", "petname": "AUSD" }, "value": { "@qclass": "bigint", "digits": "1117999560" } }, "currentAmountSlots": { "body": "{\"brand\":{\"@qclass\":\"slot\",\"iface\":\"Alleged: AUSD brand\",\"index\":0},\"value\":{\"@qclass\":\"bigint\",\"digits\":\"1117999560\"}}", "slots": [ { "kind": "brand", "petname": "AUSD" } ] }, "depositBoardId": "board04719", "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "meta": { "id": 7 }, "purse": { "@qclass": "slot", "index": 9 }, "pursePetname": "AUSD", "value": { "@qclass": "bigint", "digits": "1117999560" } }, { "actions": { "@qclass": "slot", "iface": "Alleged: purse.actions", "index": 18 }, "brand": { "@qclass": "slot", "index": 3 }, "brandBoardId": "board04312", "brandPetname": "BLD", "currentAmount": { "brand": { "kind": "brand", "petname": "BLD" }, "value": { "@qclass": "bigint", "digits": "13000000" } }, "currentAmountSlots": { "body": "{\"brand\":{\"@qclass\":\"slot\",\"iface\":\"Alleged: BLD brand\",\"index\":0},\"value\":{\"@qclass\":\"bigint\",\"digits\":\"13000000\"}}", "slots": [ { "kind": "brand", "petname": "BLD" } ] }, "depositBoardId": "board04719", "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "meta": { "id": 8 }, "purse": { "@qclass": "slot", "iface": "Alleged: Virtual Purse", "index": 19 }, "pursePetname": "Agoric staking token", "value": { "@qclass": "bigint", "digits": "13000000" } }, { "actions": { "@qclass": "slot", "iface": "Alleged: purse.actions", "index": 20 }, "brand": { "@qclass": "slot", "index": 5 }, "brandBoardId": "board02314", "brandPetname": "IST", "currentAmount": { "brand": { "kind": "brand", "petname": "IST" }, "value": { "@qclass": "bigint", "digits": "12349000039" } }, "currentAmountSlots": { "body": "{\"brand\":{\"@qclass\":\"slot\",\"iface\":\"Alleged: IST brand\",\"index\":0},\"value\":{\"@qclass\":\"bigint\",\"digits\":\"12349000039\"}}", "slots": [ { "kind": "brand", "petname": "IST" } ] }, "depositBoardId": "board04719", "displayInfo": { "assetKind": "nat", "decimalPlaces": 6 }, "meta": { "id": 9 }, "purse": { "@qclass": "slot", "index": 10 }, "pursePetname": "Agoric stable local currency", "value": { "@qclass": "bigint", "digits": "12349000039" } } ] } ```(incidentally,
cat block30.slog |jq -c 'select(.type=="deliver" and .kd[0]=="message")' |grep toBridge |jq -c '.kd'|tail -1 |jq '.[2].methargs.body | fromjson | .[1][1].value|fromjson|.body |fromjson'
is the command to get that last bit)I'm still doing the calculation to see just how much time it took to perform those updates.
We're thinking that:
unknown:NN
values in the update, it makes me think that somevalToSlot
table isn't surviving properly, so brands or purses or something are not being recognized the second time around, so something new is being allocated for it, and that's effectively leaking somethingmarshal
which would remove one later of JSONing, and would remove some of the double-quotes (by expressing compound objects with specially-prefixed strings rather than@qclass
-bearing objects). That would help, although I don't know by how much.The text was updated successfully, but these errors were encountered: