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

SPIKE: signing wallet actions with keplr, ledger #5761

Closed
wants to merge 54 commits into from
Closed

Conversation

dckc
Copy link
Member

@dckc dckc commented Jul 13, 2022

refs: #4406, ##3628

Description

IOU

to run it:

cd agoric-sdk/packages/wallet/ui/demo-signing
yarn start

Security Considerations

Documentation Considerations

Testing Considerations

dckc added 13 commits July 14, 2022 00:40
 - can connect to chain and query for sequence
 - aminoTypes seem to work
 - TODO: generate protobuf codec for MsgWalletAction
 - build:proto using ts-proto seems to be working
 - TODO: tsc is griping about conflicts between jest and mocha.
         Why is it looking at jest and mocha???
built in Agoric/faucet (cosmjs-rpc branch) and copied over
avoid:

Error: Broadcasting transaction failed with code 11 (codespace: sdk). Log: out of gas in location: ReadFlat; gasWanted: 250, gasUsed: 1000: out of gas
    at SigningStargateClient.broadcastTx (stargateclient.ts:413:9)
    at async HTMLButtonElement.<anonymous> (keplr-ledger-demo.js:215:16)
@dckc
Copy link
Member Author

dckc commented Jul 15, 2022

ok... I think I got a MsgWalletAction signed and broadcast to a local chain. Next challenge:

Error: Broadcasting transaction failed with code 111222 (codespace: undefined). Log: panic message redacted to hide potentially sensitive system info: panic
    at SigningStargateClient.broadcastTx (stargateclient.ts:413:9)
    at async HTMLButtonElement.<anonymous> (keplr-ledger-demo.js:215:16)

This looks like a "something bad happened; good luck finding it" diagnostic. I don't see anything in the agd logs.

https://github.com/cosmos/cosmos-sdk/blob/bcd3c96649128276f2914a1a7373608cb3ada8d6/errors/errors.go#L19-L20

p.s. I thought maybe the problem was the missing amino codec registration, but even after fixing that (0930864), symptoms persist.

@dckc
Copy link
Member Author

dckc commented Jul 20, 2022

authz working (Any encoding)

3a39005

agd query tx BD134F52A1242B6945071F3102EF5855B15DAF030E78FA1DE055C645A3B1204D
...
  body:
    extension_options: []
    memo: ""
    messages:
    - '@type': /cosmos.authz.v1beta1.MsgGrant
      grant:
        authorization:
          '@type': /cosmos.authz.v1beta1.GenericAuthorization
          msg: /agoric.swingset.MsgWalletAction
        expiration: "2022-07-20T05:22:06Z"
      grantee: agoric12ufmm960ynt0svr8c7gwy9he909z34w73fkue8
      granter: agoric1uh4ynz9h3ea9vc80tl30s4ykmcyqwfl0d7zelw
    non_critical_extension_options: []
    timeout_height: "0"
  signatures:
  - 6D2sEJVeOOotpghW199L0mwdGcdK1qstgUO0jjvonlcT+/h1PzClo9hYb/Um3CuZRnbxQEOWA4rpGvUINAJxyg==
txhash: BD134F52A1242B6945071F3102EF5855B15DAF030E78FA1DE055C645A3B1204D

dckc added 3 commits July 19, 2022 22:08
example result:

agoric-sdk/packages/cosmic-swingset$ ~/go/bin/agd query tx E0EDE9B200AB0B9FF33DA288BC9E455C228854D76D5AD12C80EA5138C6706D06
...
timestamp: "2022-07-20T03:07:21Z"
tx:
  '@type': /cosmos.tx.v1beta1.Tx
  auth_info:
    fee:
      amount:
      - amount: "0"
        denom: uist
      gas_limit: "100000"
      granter: ""
      payer: ""
    signer_infos:
    - mode_info:
        single:
          mode: SIGN_MODE_DIRECT
      public_key:
        '@type': /cosmos.crypto.secp256k1.PubKey
        key: AggWzZHxF8d7Quy/N9UUGWwU05pIEJKNFGFPpfx01Ika
      sequence: "4"
  body:
    extension_options: []
    memo: ""
    messages:
    - '@type': /cosmos.authz.v1beta1.MsgGrant
      grant:
        authorization:
          '@type': /cosmos.authz.v1beta1.GenericAuthorization
          msg: /agoric.swingset.MsgWalletAction
        expiration: "2022-07-20T07:07:22Z"
      grantee: agoric12ufmm960ynt0svr8c7gwy9he909z34w73fkue8
      granter: agoric1uh4ynz9h3ea9vc80tl30s4ykmcyqwfl0d7zelw
    - '@type': /cosmos.feegrant.v1beta1.MsgGrantAllowance
      allowance:
        '@type': /cosmos.feegrant.v1beta1.BasicAllowance
        expiration: "2022-07-20T07:07:22Z"
        spend_limit:
        - amount: "250000"
          denom: uist
      grantee: agoric12ufmm960ynt0svr8c7gwy9he909z34w73fkue8
      granter: agoric1uh4ynz9h3ea9vc80tl30s4ykmcyqwfl0d7zelw
    non_critical_extension_options: []
    timeout_height: "0"
  signatures:
  - JTO/ouDtWgTB8fO8ngHceQk+AxIup8tWClaKEFCOqiE1N5gC2TEVN2CiKch2tmE6/Pj2NXJH9DoGFEpz5WBB7A==
txhash: E0EDE9B200AB0B9FF33DA288BC9E455C228854D76D5AD12C80EA5138C6706D06
struggling to get it to work.

currently gives:

"failed to execute message; message index: 0: authorization not found: unauthorized"

despite:

$ agd query authz grants agoric1uh4ynz9h3ea9vc80tl30s4ykmcyqwfl0d7zelw agoric1prh40kcgtx4uxd870aye5swmqzdrfu4ggp5pfm
grants:
- authorization:
    '@type': /cosmos.authz.v1beta1.GenericAuthorization
    msg: /agoric.swingset.MsgWalletAction
  expiration: "2022-07-20T08:42:41Z"
@dckc
Copy link
Member Author

dckc commented Jul 20, 2022

@michaelfig noted he got tx authz exec working a while back. I found it: 20cdfa8 in chain-cosmos-sdk.js. It shells out to the golang code, though, so it doesn't quite show how to address the problem I'm seeing in cosmjs.

@dckc
Copy link
Member Author

dckc commented Jul 21, 2022

re authz... perhaps cosmos/cosmjs#1155 provides a clue: maybe payload messages need the encode/fromPartial treatment

dckc added 11 commits July 21, 2022 21:07
grant fails thusly:

aminotypes.ts:38 Uncaught (in promise) Error: The message type '/cosmos.authz.v1beta1.MsgGrant' cannot be signed using the Amino JSON sign mode because this is not supported by chain.
    at AminoTypes.toAmino (aminotypes.ts:38:13)
    at signingstargateclient.ts:351:56
    at Array.map (<anonymous>)
    at SigningStargateClient.signAmino (signingstargateclient.ts:351:27)
    at async SigningStargateClient.signAndBroadcast (signingstargateclient.ts:295:19)
    at async Object.authorizeLocalKey (keyManagement.js:350:18)

and submit offer thusly:

Uncaught (in promise) Error: Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (14), sequence (0) and chain-id (agoric): unauthorized
    at SigningStargateClient.broadcastTx (stargateclient.ts:413:9)
    at async Object.submitSpendAction (keyManagement.js:381:18)
@dckc
Copy link
Member Author

dckc commented Sep 6, 2022

still useful as a record of the journey, but this spike has been largely subsumed by other work

@dckc dckc closed this Sep 6, 2022
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.

1 participant