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

Create and submit a transaction to SDK/TM chain #47

Closed
4 tasks
ancazamfir opened this issue Apr 7, 2020 · 11 comments · Fixed by #345
Closed
4 tasks

Create and submit a transaction to SDK/TM chain #47

ancazamfir opened this issue Apr 7, 2020 · 11 comments · Fixed by #345
Assignees
Labels
I: CLI Internal: related to the relayer's CLI I: logic Internal: related to the relaying logic
Milestone

Comments

@ancazamfir
Copy link
Collaborator

Summary

Create and submit an IBC transaction to SDK/TM chain.

Problem Definition

relayer needs to submit transactions that include the IBC messages and packets.

Proposal

Evaluate https://github.com/iqlusioninc/crates/tree/develop/stdtx for submitting an IBC transaction. Could be for ClientCreate or ClientUpdate, or other.
Keystore doesn't have to be part of this if a workaround is found. We will deal with this in another issue.

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@ancazamfir ancazamfir added I: CLI Internal: related to the relayer's CLI I: logic Internal: related to the relaying logic labels Apr 7, 2020
@ancazamfir ancazamfir added this to the 0.4-4mo milestone Apr 7, 2020
@ebuchman ebuchman mentioned this issue Apr 11, 2020
6 tasks
@ancazamfir ancazamfir modified the milestones: 0.4-4mo, 0.6-6mo May 22, 2020
@ancazamfir ancazamfir modified the milestones: 0.6-6mo, 0.8-8mo Jun 29, 2020
@ebuchman
Copy link
Member

ebuchman commented Jul 7, 2020

Let's start with a ConnOpenInit - https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics#opening-handshake

Should be able to run it from the relayer CLI

@ebuchman ebuchman modified the milestones: v0.0.4, v0.0.2 Jul 7, 2020
@ebuchman
Copy link
Member

ebuchman commented Jul 7, 2020

We should open a new issue listing the set of transactions so we can start knocking them off

@ebuchman
Copy link
Member

Protobuf txs have not landed yet on the SDK so lets bump the milestone on this for now

@ebuchman ebuchman modified the milestones: v0.0.2, v.0.0.3 Jul 19, 2020
@ancazamfir ancazamfir modified the milestones: v.0.0.3, v0.0.4 Aug 28, 2020
@ebuchman
Copy link
Member

This is effectively done in #242 but bringing it into the relayer-cli is now blocking on #243 or some other resolution of dependency hell.

@ebuchman ebuchman mentioned this issue Sep 21, 2020
6 tasks
ancazamfir pushed a commit that referenced this issue Sep 30, 2020
* Initial implementation for the relayer tx command #206

* Adding initial logic to support signing #47

* Adding logic for auth tx

* Implementing initial support to conn open init and tx #206

* Changes:
- Implemented logic for tx raw connection open init
- Logic to build the message only using protobuf types
- Got some signing logic but not validated
- Still needs lots of refactoring and cleaning

* update signing code to use  k256

* Ignore .idea

* Refactoring the ConnOpenInit logic. Disabling the build and sign tx code #246

* Added logic for the conn init tx on relayer

* Finished implementing MsgConnectionOpenInit. No signing implemented #246

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
@ancazamfir ancazamfir modified the milestones: v0.0.4, v0.0.5 Sep 30, 2020
andynog added a commit that referenced this issue Oct 13, 2020
andynog added a commit that referenced this issue Oct 14, 2020
* Implemented very basic keybase to store keys (memory store)

* Logic to restore key (private/public) from mnemonic

* Added keystore to the chain

* Implemented working 'keys restore' command on the relayer
@andynog
Copy link
Contributor

andynog commented Oct 14, 2020

Got a basic keystore working. You can test against branch andy/tx-sign. Running the command below

 ./target/debug/relayer -c ./relayer-cli/tests/fixtures/two_chains.toml keys restore ibc0 test "mixture fatigue fold federal hour frequent atom seek apart diesel armed start lawn hello milk say steak peasant wonder inquiry vague mind reduce rib"

Should give the result (displays the address for now)

key restore result:  "55d4ae3492a831453fc273aff431fc76094e9b1c"

Next step is to use the private key to sign the message in the transaction.

andynog added a commit that referenced this issue Oct 20, 2020
andynog added a commit that referenced this issue Oct 20, 2020
@andynog
Copy link
Contributor

andynog commented Oct 20, 2020

I believe the tx signing is working but getting a internal error testing against stargate-4 chains (running with go relayer dev-env script)

./target/debug/relayer -c ./relayer-cli/tests/fixtures/two_chains.toml tx raw conn-init ibc0 ibc1 ibczeroclient ibconeclient ibczeroconn ibconeconn
     Message ConnectionOpenInitOptions { src_client_id: ClientId("ibczeroclient"), dest_client_id: ClientId("ibconeclient"), src_connection_id: ConnectionId("ibczeroconn"), dest_connection_id: ConnectionId("ibconeconn"), src_chain_config: ChainConfig { id: chain::Id(ibc0), rpc_addr: Tcp { peer_id: None, host: "localhost", port: 26657 }, account_prefix: "cosmos", key_name: "testkey", store_prefix: "ibc", client_ids: ["cla1", "cla2"], gas: 200000, trusting_period: 1209600s }, dest_chain_config: ChainConfig { id: chain::Id(ibc1), rpc_addr: Tcp { peer_id: None, host: "localhost", port: 26557 }, account_prefix: "cosmos", key_name: "testkey", store_prefix: "ibc", client_ids: ["clb1"], gas: 200000, trusting_period: 1209600s } }
TxRAW "0a9f010a9c010a2d2f6962632e636f72652e636f6e6e656374696f6e2e76312e4d7367436f6e6e656374696f6e4f70656e496e6974126b0a0d6962637a65726f636c69656e74120b6962637a65726f636f6e6e1a1c0a0c6962636f6e65636c69656e74120a6962636f6e65636f6e6e1a002205312e302e302a283235454635364341373935313335453430393336384536444238313130463232413442453035433212500a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103af916c8d01cfdb919cc875539c759b4adb210f324d716c7ab4e4d74d408cc9ac12040a0208011a400bb6dd5cca614c3217eb75203e1b5559ee0f88d4f01314ec90223f2e50c4e1bd62fe531a1fb9311c989e227330274602c27f142f43ac70a2627f4387962c6e6a"
Tx Error Response: Response { code: Err(1), data: Data([]), log: Log("internal"), hash: transaction::Hash(D2969C20DA35EBA7B1883F1679BD3AE272B07DCCF3559B02FF41511DDD325AB4) }
conn init failed, error:  tx error: Message transaction failure: failed to initialize open connection: RPC error: RPC error: internal

if I send the tx via broadcast_tx_sync directly also get the error

curl localhost:26657/broadcast_tx_sync?tx=0x0a9f010a9c010a2d2f6962632e636f72652e636f6e6e656374696f6e2e76312e4d7367436f6e6e656374696f6e4f70656e496e6974126b0a0d6962637a65726f636c69656e74120b6962637a65726f636f6e6e1a1c0a0c6962636f6e65636c69656e74120a6962636f6e65636f6e6e1a002205312e302e302a283235454635364341373935313335453430393336384536444238313130463232413442453035433212500a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103af916c8d01cfdb919cc875539c759b4adb210f324d716c7ab4e4d74d408cc9ac12040a0208011a400bb6dd5cca614c3217eb75203e1b5559ee0f88d4f01314ec90223f2e50c4e1bd62fe531a1fb9311c989e227330274602c27f142f43ac70a2627f4387962c6e6a
{
  "jsonrpc": "2.0",
  "id": -1,
  "result": {
    "code": 1,
    "data": "",
    "log": "internal",
    "codespace": "undefined",
    "hash": "D2969C20DA35EBA7B1883F1679BD3AE272B07DCCF3559B02FF41511DDD325AB4"
  }

The error doesn't show up in the chains log so not sure where it's happening. Haven't been able to debug it directly on gaia or cosmos-sdk yet.

@andynog
Copy link
Contributor

andynog commented Oct 23, 2020

The tx raw conn-init command works now. Signing the message is working and the gaia chain (stargate-4) accepts the transaction.

For now, I've added two parameters to the command

  • signer-key (-k) -> you specify a key file (name and location) that will be used as the signer. This key seed file has a mnemonic (seed phrase) that can be used to retrieve the private key (BIP-39)
  • account_sequence (-s) -> this is the account sequence value, basically every time a tx is committed by the account this number increases

Testing the transaction:

  1. Start two chains using the dev-env script from the ovrclk/relayer (checkout stargate-4)
  2. After you run the script, the Go relayer will create a data folder for the chains. Open the key seed file ./data/ibc1/key_seed.json for chain ibc-1 and look for the account value
{"name":"user","type":"local","address":"cosmos1tqzwwr5hrnq2ceg5fg52m720m50xpfy08at7l9","pubkey":"cosmospub1addwnpepq08wntxejcla5hd93stgudw02htdpa9vu5a2ds8xkvmgrkrrpwlj6sdhkz6","mnemonic":"[MNEMONIC WORDS"}
  1. In order to find the account sequence run:

gaiad query account cosmospub1addwnpepq08wntxejcla5hd93stgudw02htdpa9vu5a2ds8xkvmgrkrrpwlj6sdhkz6 --home ./data/ibc1 --chain-id ibc1 --node tcp://localhost:26557

this will return the sequence number at the end. Make a note of that, you will need this number as an argument to the transaction command.

'@type': /cosmos.auth.v1beta1.BaseAccount
account_number: "0"
address: cosmos1tqzwwr5hrnq2ceg5fg52m720m50xpfy08at7l9
pub_key:
  '@type': /cosmos.crypto.secp256k1.PubKey
  key: A87prNmWP9pdpYwWjjXPVdbQ9KzlOqbA5rM2gdhjC78t
sequence: "12"
  1. Run the transaction command. We will try to initialize an ibczeroconn2 connection

cargo run --bin relayer -- -c ./relayer-cli/tests/fixtures/two_chains.toml tx raw conn-init ibc0 ibc1 ibczeroclient ibconeclient ibczeroconn2 ibconeconn -s 12 -k key_seed.json

if you get an empty response it means the tx worked

conn init, result: []

  1. Check if the connection was created on ibc-1 using the Golang relayer

rly query connections ibc1 | jq .

you should see an entry in the JSON file that points to the ibczeroconn2 connection with state STATE_INIT

{
      "id": "ibczeroconn21",
      "client_id": "ibczeroclient",
      "versions": [
        "\n\u00011\u0012\rORDER_ORDERED\u0012\u000fORDER_UNORDERED"
      ],
      "state": "STATE_INIT",
      "counterparty": {
        "client_id": "ibconeclient",
        "connection_id": "ibconeconn",
        "prefix": {
          "key_prefix": "aWJj"
        }
      }
    },

@andynog andynog self-assigned this Oct 24, 2020
@ancazamfir
Copy link
Collaborator Author

ancazamfir commented Oct 27, 2020

Looks good. A few observations:

In order to find the account sequence run:
gaiad query account cosmospub1addwnpepq08wntxejcla5hd93stgudw02htdpa9vu5a2ds8xkvmgrkrrpwlj6sdhkz6 --home ./data/ibc1 --chain-id ibc1 --node tcp://localhost:26557

here we need to pass the address, cosmos1tqzwwr5hrnq2ceg5fg52m720m50xpfy08at7l9 in the example.

If we try to create the same connection twice we should get an error. You should call broadcast_tx_commit() in broadcast_tx(), this will return the Code (success or failure) and some Log and Data to show in case of failure.

Currently creating the connection second time returns:
conn init, result: []

Here are the current logs (removed some):

D[2020-10-27|13:31:55.968] Invalid tx                                   module=state code=2 log="\ngit.luolix.top/cosmos/cosmos-...(*localClient).DeliverTxAsync
failed to execute message; message index: 0: connection handshake open init failed: ibczeroconn4: connection already exists"

@ancazamfir
Copy link
Collaborator Author

With broadcast_tx_commit() it returns something like:

conn init, result:  TxResult { code: Err(2), data: None, log: Log("\ngit.luolix.top/cosmos/cosmos-sdk/x/ibc/core/03-connection/keeper.Keeper.ConnOpenInit\n\tgit.luolix.top/cosmos/cosmos-sdk@v0.40.0-rc0/x/ibc/core/03-connection/keeper/handshake.go:27\ngit.luolix.top/cosmos/cosmos-sdk/x/ibc/core/03-connection.HandleMsgConnectionOpenInit\n\tgit.luolix.top/cosmos/cosmos-sdk@v0.40.0-rc0/x/ibc/core/03-connection/handler.go:13\ngit.luolix.top/cosmos/cosmos-sdk/x/ibc/core.NewHandler.func1\n\tgit.luolix.top/cosmos/cosmos-sdk@v0.40.0-rc0/x/ibc/core/handler.go:36\ngit.luolix.top/cosmos/cosmos-sdk/baseapp.(*BaseApp).runMsgs\n\tgit.luolix.top/cosmos/cosmos-sdk@v0.40.0-rc0/baseapp/baseapp.go:692\ngit.luolix.top/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgit.luolix.top/cosmos/cosmos-sdk@v0.40.0-rc0/baseapp/baseapp.go:653\ngit.luolix.top/cosmos/cosmos-sdk/baseapp.(*BaseApp).DeliverTx\n\tgit.luolix.top/cosmos/cosmos-sdk@v0.40.0-rc0/baseapp/abci.go:271\ngit.luolix.top/tendermint/tendermint/abci/client.(*localClient).DeliverTxAsync\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/abci/client/local_client.go:87\ngit.luolix.top/tendermint/tendermint/proxy.(*appConnConsensus).DeliverTxAsync\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/proxy/app_conn.go:85\ngit.luolix.top/tendermint/tendermint/state.execBlockOnProxyApp\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/state/execution.go:313\ngit.luolix.top/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/state/execution.go:138\ngit.luolix.top/tendermint/tendermint/consensus.(*State).finalizeCommit\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:1569\ngit.luolix.top/tendermint/tendermint/consensus.(*State).tryFinalizeCommit\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:1487\ngit.luolix.top/tendermint/tendermint/consensus.(*State).enterCommit.func1\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:1420\ngit.luolix.top/tendermint/tendermint/consensus.(*State).enterCommit\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:1459\ngit.luolix.top/tendermint/tendermint/consensus.(*State).addVote\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:2044\ngit.luolix.top/tendermint/tendermint/consensus.(*State).tryAddVote\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:1846\ngit.luolix.top/tendermint/tendermint/consensus.(*State).handleMsg\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:803\ngit.luolix.top/tendermint/tendermint/consensus.(*State).receiveRoutine\n\tgit.luolix.top/tendermint/tendermint@v0.34.0-rc4.0.20201005135527-d7d0ffea13c6/consensus/state.go:752\nfailed to execute message; message index: 0: connection handshake open init failed: ibczeroconn4: connection already exists") }

we will need to get a shorter explanation for that Err(2)

@andynog andynog changed the title Investigate: create and submit transaction to SDK/TM chain Create and submit a transaction to SDK/TM chain Oct 27, 2020
@andynog
Copy link
Contributor

andynog commented Oct 27, 2020

Thanks @ancazamfir I will look into those error cases for an existing connection.

@andynog andynog mentioned this issue Oct 27, 2020
5 tasks
ancazamfir added a commit that referenced this issue Oct 30, 2020
* Initial implementation for tx sign

* Adding logic to build the tx as part of the chain. Added broadcast tx to chain. #47

* Added keys restore command boileplate for abscissa. Restore key functionality not implemented yet #47

* Implemented changes to support tx signing (#47):

* Implemented very basic keybase to store keys (memory store)

* Logic to restore key (private/public) from mnemonic

* Added keystore to the chain

* Implemented working 'keys restore' command on the relayer

* Refactoring keybase structure (#47)

* Initial logic to send message (#47)

* Got the logic to sign but MsgConnectionOpenInit test against stargate-4 not working (#47)

* MsgConnectionOpenInit tx working logic! (#47)

* Added option to tx raw conn-init to specify and read key file content (#47)

* Logic to parse the key_seed.json file passed as tx raw parameter working (#47)

* Added support to specify key file and account sequence for the tax raw conn-init command (#47)

* Adding instructions on how to submit a transaction (#345)

* Fixing format issues (#345)

* Fixing tests (#345)

* Update relayer/src/tx/client.rs

I had this in place so I could test. OK to change it back

Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>

* Update relayer/src/tx/connection.rs

OK, didn't know where to get it from, thanks.

Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>

Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this issue Sep 13, 2022
* Initial implementation for the relayer tx command informalsystems#206

* Adding initial logic to support signing informalsystems#47

* Adding logic for auth tx

* Implementing initial support to conn open init and tx informalsystems#206

* Changes:
- Implemented logic for tx raw connection open init
- Logic to build the message only using protobuf types
- Got some signing logic but not validated
- Still needs lots of refactoring and cleaning

* update signing code to use  k256

* Ignore .idea

* Refactoring the ConnOpenInit logic. Disabling the build and sign tx code informalsystems#246

* Added logic for the conn init tx on relayer

* Finished implementing MsgConnectionOpenInit. No signing implemented informalsystems#246

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this issue Sep 13, 2022
* Initial implementation for tx sign

* Adding logic to build the tx as part of the chain. Added broadcast tx to chain. informalsystems#47

* Added keys restore command boileplate for abscissa. Restore key functionality not implemented yet informalsystems#47

* Implemented changes to support tx signing (informalsystems#47):

* Implemented very basic keybase to store keys (memory store)

* Logic to restore key (private/public) from mnemonic

* Added keystore to the chain

* Implemented working 'keys restore' command on the relayer

* Refactoring keybase structure (informalsystems#47)

* Initial logic to send message (informalsystems#47)

* Got the logic to sign but MsgConnectionOpenInit test against stargate-4 not working (informalsystems#47)

* MsgConnectionOpenInit tx working logic! (informalsystems#47)

* Added option to tx raw conn-init to specify and read key file content (informalsystems#47)

* Logic to parse the key_seed.json file passed as tx raw parameter working (informalsystems#47)

* Added support to specify key file and account sequence for the tax raw conn-init command (informalsystems#47)

* Adding instructions on how to submit a transaction (informalsystems#345)

* Fixing format issues (informalsystems#345)

* Fixing tests (informalsystems#345)

* Update relayer/src/tx/client.rs

I had this in place so I could test. OK to change it back

Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>

* Update relayer/src/tx/connection.rs

OK, didn't know where to get it from, thanks.

Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>

Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: CLI Internal: related to the relayer's CLI I: logic Internal: related to the relaying logic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants