-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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>
- Loading branch information
1 parent
052b574
commit 2b5029b
Showing
24 changed files
with
748 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,88 @@ | ||
# relayer-cli | ||
# Relayer (Rust) | ||
|
||
`relayer-cli` is an application. | ||
This is the repository for the IBC Relayer built in Rust. | ||
|
||
For updates please check the [releases on the ibc-rs repository](https://github.com/informalsystems/ibc-rs/releases) | ||
|
||
## Getting Started | ||
|
||
This application is authored using [Abscissa], a Rust application framework. | ||
In order to run the Relayer please ensure you have [Rust installed on your machine](https://www.rust-lang.org/tools/install) | ||
|
||
### Submitting an IBC transaction | ||
|
||
The `tx raw conn-init` command works now. Signing the message is working and the gaia chain (stargate-4) accepts the transaction. | ||
|
||
The command accepts two parameters that allows you to send a transaction: | ||
|
||
* **signer-key** (-k) -> specify a key file (name and location) that will be used by the signer. This key seed file has a mnemonic (seed phrase) that can be used to retrieve the private key (BIP-39) used to sign the transaction. | ||
* **account_sequence** (-s) -> this is the account sequence value, basically every time a tx is committed by the account this number increases. | ||
|
||
#### Steps to testing the transaction: | ||
|
||
* Start two chains using the `dev-env` script from the [ovrclk/relayer](https://github.com/ovrclk/relayer) (make sure to checkout stargate-4 version) | ||
* 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"} | ||
} | ||
|
||
|
||
* In order to find the account sequence run the command below: | ||
|
||
For the address value after `gaiad query account` use the `address` from the step above. | ||
|
||
`$ gaiad query account cosmos1tqzwwr5hrnq2ceg5fg52m720m50xpfy08at7l9 --home ./data/ibc1 --chain-id ibc1 --node tcp://localhost:26557` | ||
|
||
This will return a JSON with a 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" | ||
|
||
|
||
* Run the transaction command. This will try to initialize an `ibczeroconn2` connection on chain `ibc1` | ||
|
||
`$ 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: []` | ||
|
||
* Check if the connection was created on `ibc-1` using the Golang relayer | ||
|
||
`$ rly query connections ibc1 | jq .` | ||
|
||
If you see an entry in the JSON file that points to the `ibczeroconn2` connection with state `STATE_INIT` it confirms that the transaction worked: | ||
|
||
|
||
{ | ||
"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" | ||
} | ||
} | ||
}, | ||
|
||
|
||
|
||
For more information, see: | ||
|
||
[Documentation] | ||
|
||
[Abscissa]: https://github.com/iqlusioninc/abscissa | ||
[Documentation]: https://docs.rs/abscissa_core/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//! `keys` subcommand | ||
use abscissa_core::{Command, Help, Options, Runnable}; | ||
|
||
mod restore; | ||
|
||
/// `keys` subcommand | ||
#[derive(Command, Debug, Options, Runnable)] | ||
pub enum KeysCmd { | ||
/// The `help` subcommand | ||
#[options(help = "get usage information")] | ||
Help(Help<Self>), | ||
|
||
/// The `keys restore` subcommand | ||
#[options(help = "keys restore")] | ||
Restore(restore::KeyRestoreCmd), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use crate::application::app_config; | ||
use abscissa_core::{Command, Options, Runnable}; | ||
use relayer::config::Config; | ||
|
||
use crate::error::{Error, Kind}; | ||
use crate::prelude::*; | ||
use relayer::keys::restore::{restore_key, KeysRestoreOptions}; | ||
|
||
#[derive(Clone, Command, Debug, Options)] | ||
pub struct KeyRestoreCmd { | ||
#[options(free, help = "identifier of the chain")] | ||
chain_id: Option<String>, | ||
|
||
#[options(free, help = "the key name")] | ||
name: Option<String>, | ||
|
||
#[options(free, help = "mnemonic to add key")] | ||
mnemonic: Option<String>, | ||
} | ||
|
||
impl KeyRestoreCmd { | ||
fn validate_options(&self, config: &Config) -> Result<KeysRestoreOptions, String> { | ||
let chain_id = self | ||
.chain_id | ||
.clone() | ||
.ok_or_else(|| "missing chain identifier".to_string())?; | ||
|
||
let chain_config = config | ||
.chains | ||
.iter() | ||
.find(|c| c.id == chain_id.parse().unwrap()) | ||
.ok_or_else(|| { | ||
"Invalid chain identifier. Cannot retrieve the chain configuration".to_string() | ||
})?; | ||
|
||
let key_name = self | ||
.name | ||
.clone() | ||
.ok_or_else(|| "missing key name".to_string())?; | ||
|
||
let mnemonic_words = self | ||
.mnemonic | ||
.clone() | ||
.ok_or_else(|| "missing mnemonic".to_string())?; | ||
|
||
Ok(KeysRestoreOptions { | ||
name: key_name, | ||
mnemonic: mnemonic_words, | ||
chain_config: chain_config.clone(), | ||
}) | ||
} | ||
} | ||
|
||
impl Runnable for KeyRestoreCmd { | ||
fn run(&self) { | ||
let config = app_config(); | ||
|
||
let opts = match self.validate_options(&config) { | ||
Err(err) => { | ||
status_err!("invalid options: {}", err); | ||
return; | ||
} | ||
Ok(result) => result, | ||
}; | ||
|
||
let res: Result<Vec<u8>, Error> = | ||
restore_key(opts).map_err(|e| Kind::Keys.context(e).into()); | ||
|
||
match res { | ||
Ok(r) => status_info!("key restore result: ", "{:?}", hex::encode(r)), | ||
Err(e) => status_info!("key restore failed: ", "{}", e), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.