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

Ethermint support #1295

Merged
merged 8 commits into from
Sep 10, 2021
Merged

Ethermint support #1295

merged 8 commits into from
Sep 10, 2021

Conversation

tomtau
Copy link
Contributor

@tomtau tomtau commented Aug 17, 2021

Closes: #1267 #1071

Description

  • collected changes from hermes is not compatible with ethermint #1267 (comment)
  • EthAccount definition was directly pasted into the proto library
    (as different chains use the same proto definition, but under a different package path)
  • added a new configuration option that allows specifying the address derivation
    as well as the proto type of public keys
    (e.g. "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
    or "/ethermint.crypto.v1alpha1.ethsecp256k1.PubKey")

For contributor use:

  • Added a changelog entry, using unclog.
  • If applicable: Unit tests written, added test to CI.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments.
  • Re-reviewed Files changed in the Github PR explorer.

@tomtau
Copy link
Contributor Author

tomtau commented Aug 17, 2021

@devashishdxt @xlab @leejw51crypto see if this works -- I'll try rebasing the change onto the 0.43 branch and test it later.

@adizere @hu55a1n1 FYI the protobuf definitions:
https://github.com/tharsis/ethermint/blob/main/proto/ethermint/types/v1alpha1/account.proto
https://github.com/InjectiveLabs/injective-oracle-scaffold/blob/master/proto/injective/types/v1beta1/account.proto

@adizere
Copy link
Member

adizere commented Aug 17, 2021

Wow, many thanks Tomas!

@devashishdxt @xlab @leejw51crypto see if this works -- I'll try rebasing the change onto the 0.43 branch and test it later.

The 0.43 branch (PR #948) will be merged within a couple of days. It's pretty much ready we're just adding support for legacy SDK chains (0.42).

@adizere adizere linked an issue Aug 17, 2021 that may be closed by this pull request
@tomtau
Copy link
Contributor Author

tomtau commented Aug 17, 2021

tested it locally with two chains (one pure Cosmos SDK-based, and one with the Ethermint module) using this 0.43-based branch: https://github.com/tomtau/ibc-rs/commits/test/ethermint-0.43

and it seems to work:

...
Aug 17 16:22:45.774  INFO done deveth-1 => OpenConfirmChannel(
    OpenConfirm(
        Attributes {
            height: Height {
                revision: 1,
                height: 569,
            },
            port_id: PortId(
                "transfer",
            ),
            channel_id: Some(
                ChannelId(
                    "channel-0",
                ),
            ),
            connection_id: ConnectionId(
                "connection-1",
            ),
            counterparty_port_id: PortId(
                "transfer",
            ),
            counterparty_channel_id: Some(
                ChannelId(
                    "channel-1",
                ),
            ),
        },
    ),
)

Success: Channel {
    ordering: Unordered,
    a_side: ChannelSide {
        chain: ProdChainHandle {
            chain_id: ChainId {
                id: "devnet-1",
                version: 1,
            },
            runtime_sender: Sender { .. },
        },
        client_id: ClientId(
            "07-tendermint-4",
        ),
        connection_id: ConnectionId(
            "connection-2",
        ),
        port_id: PortId(
            "transfer",
        ),
        channel_id: Some(
            ChannelId(
                "channel-1",
            ),
        ),
    },
    b_side: ChannelSide {
        chain: ProdChainHandle {
            chain_id: ChainId {
                id: "deveth-1",
                version: 1,
            },
            runtime_sender: Sender { .. },
        },
        client_id: ClientId(
            "07-tendermint-1",
        ),
        connection_id: ConnectionId(
            "connection-1",
        ),
        port_id: PortId(
            "transfer",
        ),
        channel_id: Some(
            ChannelId(
                "channel-0",
            ),
        ),
    },
    connection_delay: 0ns,
    version: Some(
        "ics20-1",
    ),
}

@romac romac changed the title added Ethermint support (fixes #1267 #1071) Ethermint support Aug 17, 2021
@RiccardoM
Copy link

@adizere Are there plans to release this for v0.42 chains in the near future? Will this also solve #1155?

@tomtau
Copy link
Contributor Author

tomtau commented Aug 19, 2021

@RiccardoM AFAIK #1155 is for validator signature verification, so it's orthogonal to the Ethermint support (which requires account and transaction signing changes)

@xlab xlab mentioned this pull request Aug 20, 2021
11 tasks
)

- collected changes from informalsystems#1267 (comment)
- EthAccount definition was directly pasted into the proto library
(as different chains the same proto definition, but under a different package path)
- added a new configuration option that allows specifying the address derivation
as well as the proto type of public keys
(e.g. "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
or "/ethermint.crypto.v1alpha1.ethsecp256k1.PubKey")
relayer/src/keyring.rs Outdated Show resolved Hide resolved
relayer/src/keyring.rs Outdated Show resolved Hide resolved
@hu55a1n1
Copy link
Member

Hi @tomtau! Thank you for your patience. I've been trying to run some tests against this PR with @romac's help. I patched our scripts to be able to run two Ethermint (0.5.0) chains. Here are some of my findings and suggestions.

  • Signature verification fails for keys added with --algo="secp256k1". I think this is caused due to a bug in the Keyring::sign_msg() function and I have suggested a fix.
$ cargo run -- -c /home/hussaini/.hermes/config.toml tx raw create-client ethermint_901-1 ethermint_902-2
   Compiling ibc-relayer v0.6.2 (/home/hussaini/Documents/ibc-rs/relayer)
   Compiling ibc-relayer-rest v0.1.0 (/home/hussaini/Documents/ibc-rs/relayer-rest)
   Compiling ibc-relayer-cli v0.6.2 (/home/hussaini/Documents/ibc-rs/relayer-cli)
    Finished dev [unoptimized + debuginfo] target(s) in 25.50s
     Running `target/debug/hermes -c /home/hussaini/.hermes/config.toml tx raw create-client ethermint_901-1 ethermint_902-2`
Success: ChainError(
    "deliver_tx on chain ethermint_901-1 for Tx hash E95AE4451496F4E360193D384FFCC75CFCF1763B5F2C443ED550BCAFED5E7794 reports error: code=Err(4), log=Log(\"signature verification failed; please verify account number (0) and chain-id (ethermint_901-1): unauthorized\")",
)

Here's the config I am using -

[global]
strategy = 'packets'
log_level = 'error'

[[chains]]
id = 'ethermint_901-1'
rpc_addr = 'http://127.0.0.1:26657'
grpc_addr = 'http://127.0.0.1:9090'
websocket_addr = 'ws://localhost:26657/websocket'
rpc_timeout = '10s'
account_prefix = 'eth'
key_name = 'testkey'
store_prefix = 'ibc'
max_gas = 200000
gas_price = { price = 0.001, denom = 'stake' }
max_msg_num = 4
max_tx_size = 1048576
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/cosmos.crypto.secp256k1.PubKey' } }

[[chains]]
id = 'ethermint_902-2'
rpc_addr = 'http://127.0.0.1:26557'
grpc_addr = 'http://127.0.0.1:9091'
websocket_addr = 'ws://localhost:26557/websocket'
rpc_timeout = '10s'
account_prefix = 'eth'
key_name = 'testkey'
store_prefix = 'ibc'
gas_price = { price = 0.001, denom = 'stake' }
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/cosmos.crypto.secp256k1.PubKey' } }
  • Client creation is working as expected with the default --algo. 🎉
$ cargo run -- -c /home/hussaini/.hermes/config.toml tx raw create-client ethermint_901-1 ethermint_902-2
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/hermes -c /home/hussaini/.hermes/config.toml tx raw create-client ethermint_901-1 ethermint_902-2`
Success: CreateClient(
    CreateClient(
        Attributes {
            height: Height {
                revision: 1,
                height: 64,
            },
            client_id: ClientId(
                "07-tendermint-0",
            ),
            client_type: Tendermint,
            consensus_height: Height {
                revision: 2,
                height: 50,
            },
        },
    ),
)

And the corresponding Config.toml ->

[global]
strategy = 'packets'
log_level = 'error'

[[chains]]
id = 'ethermint_901-1'
rpc_addr = 'http://127.0.0.1:26657'
grpc_addr = 'http://127.0.0.1:9090'
websocket_addr = 'ws://localhost:26657/websocket'
rpc_timeout = '10s'
account_prefix = 'eth'
key_name = 'testkey'
store_prefix = 'ibc'
max_gas = 200000
gas_price = { price = 0.001, denom = 'stake' }
max_msg_num = 4
max_tx_size = 1048576
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

[[chains]]
id = 'ethermint_902-2'
rpc_addr = 'http://127.0.0.1:26557'
grpc_addr = 'http://127.0.0.1:9091'
websocket_addr = 'ws://localhost:26557/websocket'
rpc_timeout = '10s'
account_prefix = 'eth'
key_name = 'testkey'
store_prefix = 'ibc'
gas_price = { price = 0.001, denom = 'stake' }
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

I think it would be nice to have a config paramter -> address_type.coin_type, that can be used to assert whether or not the hd_path for keys add | restore matches or not. But this is just an optional improvement suggestion.
In the meantime, I will continue to run our E2E test suite against this PR (I see that @xlab has already made modifications there which will be useful) and hopefully also a cross chain setup just for the sake of completeness.

@tomtau tomtau requested a review from hu55a1n1 August 27, 2021 03:33
@tomtau
Copy link
Contributor Author

tomtau commented Aug 27, 2021

Thanks @hu55a1n1 ! yeah, I haven't tested ethermint signing with a different signing algo, but I've added a check based on the public key similar to your suggestion.

As for the coin type check, that may be a good idea regardless of Ethermint -- e.g. some Cosmos SDK-only chains have custom coin types... we can perhaps open an issue for it? I'm not sure if an extra optional config + check is the simplest UX (as one may still omit that config option / leave it as default) -- maybe a simpler way would be just to always print the HD path that was used in those key operations + a reminder note for the user to verify it

@hu55a1n1
Copy link
Member

hu55a1n1 commented Aug 31, 2021

Hi @tomtau, I noticed that you added the check to fix the --algo=secp256k1 problem to the get_address() function but not to the sign_msg() function. I believe we would need the same check there as well because I am still seeing the same error on tx raw create-client (i.e. signature verification failed; please verify account number (0) and chain-id (ethermint_901-1): unauthorized) as described in my previous comment.
I have been able to run our E2E test suite against these changes with the following configurations ->

  • ethermintd <> ethermintd
  • ethermintd (--algo=secp256k1) <> ethermintd (--algo=secp256k1)
  • ethermintd (--algo=secp256k1) <> ethermintd
  • ethermintd <> gaiad
  • ethermintd (--algo=secp256k1) <> gaiad

All tests are passing with the previously suggested fix. 🎉

@tomtau
Copy link
Contributor Author

tomtau commented Aug 31, 2021

@hu55a1n1 1668937 -- the check is on sign_msg now as well

Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏🎉

Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to try and document the Ethermint version(s) which Hermes is now becoming compatible with, as of this PR.

config.toml Outdated Show resolved Hide resolved
)]
pub enum AddressType {
Cosmos,
Ethermint { pk_type: String },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if it's a good idea to restrict the possible values that pk_type can take, either by making this an enum, or checking the String against a predefined list of accepted values.

Beside '/injective.crypto.v1beta1.ethsecp256k1.PubKey' and "/ethermint.crypto.v1alpha1.ethsecp256k1.PubKey" are there numerous other values that pk_type can take?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are potentially many more : /ethermint.crypto.v1beta1.ethsecp256k1.PubKey, /ethermint.crypto.v1.ethsecp256k1.PubKey, /cosmos.crypto.ethsecp256k1.PubKey...

Right now, in order to be useful (given Ethermint has been copied over and modified), it makes sense to keep it a bit flexible -- otherwise, every chain would need to open a PR to modify the enum.

Later, once the ethsecp256k1 support lands in Cosmos SDK, it'll make sense to deprecate this with that Cosmos SDK release and recommend chains to migrate to /cosmos.crypto.ethsecp256k1.PubKey (or whatever the canonical proto ends up being)... and after that, remove this extra config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a plan, thanks for the detailed rationale! I agree with you.

relayer/src/keyring/pub_key.rs Show resolved Hide resolved
@tomtau
Copy link
Contributor Author

tomtau commented Sep 7, 2021

@adizere I've added extra comments: e07d221

As I mentioned: #1295 (comment) -- I'm not sure how many Ethermint proto types are out there in the wild, so it may make sense to keep this flexible until networks migrate to the future canonical Cosmos SDK ones

@tomtau tomtau requested a review from adizere September 7, 2021 09:27
Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you Tomas!

I have two more concerns:

  1. We have no Ethermint chain in our CI pipeline. It will be difficult to assert that future PRs will not break compatibility with EthAccounts. Adding to CI is complex, but at the very least, we should have a documentation (or pointer to a document) describing how to instantiate ethermintd w/ and w/out --algo=secp256k1, so that we know some basic steps for future (manual) testing of Hermes against ethermint-based chains.

Is this the best place to get started with starting/working with ethermint?

As a side note, a better fix would be to add support in gm for running ethermintd, but that's also a bit more complex and need not block this PR.

  1. Is there anyone from crypto team that should give their input before we merge this?

proto/src/lib.rs Show resolved Hide resolved
@adizere adizere mentioned this pull request Sep 7, 2021
10 tasks
@tomtau tomtau requested a review from adizere September 8, 2021 03:34
@tomtau
Copy link
Contributor Author

tomtau commented Sep 8, 2021

@adizere

  1. I added a few links for the manual testing steps: 06aee03 -- the Injective's fork actually does have E2E tests: InjectiveLabs@47187c7 but it looks like it's no longer testing the Gaia integration, and I assume one will want to have both in the CI pipelines here... which, as you say, may be complex, so it's perhaps better to do in a separate PR. As for the link you posted, those docs on ethermint.zone refer to the pre-Stargate versions -- the more up-to-date docs for post-Stargate versions are on ethermint.dev.
  2. Perhaps @yihuang or @thomas-nguy -- we've been running a fork of Hermes based on this PR for some time, but it may good for them to have a final look and comment before it's merged.

@leejw51crypto
Copy link
Contributor

lgtm

@hu55a1n1
Copy link
Member

hu55a1n1 commented Sep 8, 2021

Here's the patch that I used for running our E2E tests to test the changes in this PR against other ethermint/gaia chains. Note that Ethermint expects the chain id to be in a certain format as described here. The patched dev-env script can be used to bootstrap chains with different binaries ->

./scripts/dev-env ~/.hermes/config.toml gaiad ibc-0 ethermintd ethermint_902-2 
diff --git a/relayer/tests/config/fixtures/relayer_conf_example.toml b/relayer/tests/config/fixtures/relayer_conf_example.toml
index 44d001bc..35edd920 100644
--- a/relayer/tests/config/fixtures/relayer_conf_example.toml
+++ b/relayer/tests/config/fixtures/relayer_conf_example.toml
@@ -3,34 +3,35 @@ strategy = 'packets'
 log_level = 'error'
 
 [[chains]]
-id = 'chain_A'
+id = 'ethermint_901-1'
 rpc_addr = 'http://127.0.0.1:26657'
 grpc_addr = 'http://127.0.0.1:9090'
 websocket_addr = 'ws://localhost:26657/websocket'
 rpc_timeout = '10s'
-account_prefix = 'cosmos'
+account_prefix = 'eth'
 key_name = 'testkey'
 store_prefix = 'ibc'
-max_gas = 200000
+max_gas = 3000000
 gas_price = { price = 0.001, denom = 'stake' }
 max_msg_num = 4
 max_tx_size = 1048576
 clock_drift = '5s'
 trusting_period = '14days'
 trust_threshold = { numerator = '1', denominator = '3' }
-address_type = { derivation = 'cosmos' }
+address_type = { derivation = 'ethermint', proto_type = { pk_type = '/cosmos.crypto.secp256k1.PubKey' } }
 
 [[chains]]
-id = 'chain_B'
+id = 'ethermint_902-2'
 rpc_addr = 'http://127.0.0.1:26557'
-grpc_addr = 'http://127.0.0.1:9090'
+grpc_addr = 'http://127.0.0.1:9091'
 websocket_addr = 'ws://localhost:26557/websocket'
 rpc_timeout = '10s'
-account_prefix = 'cosmos'
+account_prefix = 'eth'
 key_name = 'testkey'
 store_prefix = 'ibc'
+max_gas = 3000000
 gas_price = { price = 0.001, denom = 'stake' }
 clock_drift = '5s'
 trusting_period = '14days'
 trust_threshold = { numerator = '1', denominator = '3' }
-address_type = { derivation = 'ethermint', proto_type = { pk_type = '/injective.crypto.v1beta1.ethsecp256k1.PubKey' } }
+address_type = { derivation = 'ethermint', proto_type = { pk_type = '/cosmos.crypto.secp256k1.PubKey' } }
diff --git a/scripts/dev-env b/scripts/dev-env
index eeb3dd87..9cfa8c66 100755
--- a/scripts/dev-env
+++ b/scripts/dev-env
@@ -23,19 +23,27 @@ if [ -z "$3" ]; then
   missing "CHAIN_1_ID"
 fi
 
+if [ -z "$4" ]; then
+  missing "CHAIN_0_ID"
+fi
+
+if [ -z "$5" ]; then
+  missing "CHAIN_1_ID"
+fi
 
-if [ "$#" -gt 4 ]; then
+if [ "$#" -gt 5 ]; then
   echo "Incorrect number of parameters."
   usage
 fi
 
 CONFIG_FILE="$1"
-CHAIN_0_ID="$2"
-CHAIN_1_ID="$3"
-CHAIN_2_ID="$4"
+CHAIN_0="$2"
+CHAIN_0_ID="$3"
+CHAIN_1="$4"
+CHAIN_1_ID="$5"
 
 SETUP_CHAINS="$(dirname "$0")/setup-chains"
 INIT_CLIENTS="$(dirname "$0")/init-hermes"
 
-"$SETUP_CHAINS" "$CHAIN_0_ID" "$CHAIN_1_ID" "$CHAIN_2_ID"
-"$INIT_CLIENTS" "$CONFIG_FILE" "$CHAIN_0_ID" "$CHAIN_1_ID" "$CHAIN_2_ID"
+"$SETUP_CHAINS" "$CHAIN_0" "$CHAIN_0_ID" "$CHAIN_1" "$CHAIN_1_ID"
+"$INIT_CLIENTS" "$CONFIG_FILE" "$CHAIN_0_ID" "$CHAIN_1_ID"
diff --git a/scripts/init-hermes b/scripts/init-hermes
index 22d2a81d..0b697725 100755
--- a/scripts/init-hermes
+++ b/scripts/init-hermes
@@ -25,8 +25,7 @@ if [ -z "$3" ]; then
   missing "CHAIN_1_ID"
 fi
 
-
-if [ "$#" -gt 4 ]; then
+if [ "$#" -gt 3 ]; then
   echo "Incorrect number of parameters."
   usage
 fi
@@ -34,7 +33,6 @@ fi
 CONFIG_FILE="$1"
 CHAIN_0_ID="$2"
 CHAIN_1_ID="$3"
-CHAIN_2_ID="$4"
 
 if ! [ -f "$CONFIG_FILE" ]; then
   echo "[CONFIG_FILE] ($1) does not exist or is not a file."
@@ -51,26 +49,16 @@ if ! grep -q -s "$CHAIN_1_ID" "$CONFIG_FILE"; then
   usage
 fi
 
-if [ -n "$CHAIN_2_ID" ] && ! grep -q -s "$CHAIN_2_ID" "$CONFIG_FILE"; then
-  echo "error: configuration for chain [$CHAIN_2_ID] does not exist in file $CONFIG_FILE."
-  usage
-fi
-
-GAIA_DATA="$(pwd)/data"
+DATA="$(pwd)/data"
 
 echo "Building the Rust relayer..."
 cargo build -q --locked
 
 # add the key seeds to the keyring of each chain
 echo "Importing keys..."
-cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_0_ID" -f "$GAIA_DATA/$CHAIN_0_ID/user_seed.json"
-cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_0_ID" -f "$GAIA_DATA/$CHAIN_0_ID/user2_seed.json" -n user2
-cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_1_ID" -f "$GAIA_DATA/$CHAIN_1_ID/user_seed.json"
-cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_1_ID" -f "$GAIA_DATA/$CHAIN_1_ID/user2_seed.json" -n user2
-
-if [ -n "$CHAIN_2_ID" ]; then
-  cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_2_ID" -f "$GAIA_DATA/$CHAIN_2_ID/user_seed.json"
-  cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_2_ID" -f "$GAIA_DATA/$CHAIN_2_ID/user2_seed.json" -n user2
-fi
+cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_0_ID" -f "$DATA/$CHAIN_0_ID/user_seed.json" -p "m/44'/60'/0'/0/0"
+cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_0_ID" -f "$DATA/$CHAIN_0_ID/user2_seed.json" -p "m/44'/60'/0'/0/0" -n user2
+cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_1_ID" -f "$DATA/$CHAIN_1_ID/user_seed.json" -p "m/44'/60'/0'/0/0"
+cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_1_ID" -f "$DATA/$CHAIN_1_ID/user2_seed.json" -p "m/44'/60'/0'/0/0" -n user2
 
 echo "Done!"
diff --git a/scripts/one-chain b/scripts/one-chain
index 0fd34068..4ce2478c 100755
--- a/scripts/one-chain
+++ b/scripts/one-chain
@@ -13,7 +13,7 @@ missing() {
 }
 
 if [ -z "$1" ]; then
-  missing "[BINARY] (gaiad|akash)"
+  missing "[BINARY] (gaiad|ethermint)"
 fi
 
 if [ -z "$2" ]; then
@@ -58,7 +58,12 @@ PROF_PORT=$6
 GRPC_PORT=$7
 SAMOLEANS=$8
 
-echo "Creating $BINARY instance: home=$CHAIN_DIR | chain-id=$CHAIN_ID | p2p=:$P2P_PORT | rpc=:$RPC_PORT | profiling=:$PROF_PORT | grpc=:$GRPC_PORT | samoleans=:$SAMOLEANS"
+GRPC_WEB_PORT=$((GRPC_PORT + 100))
+JRPC_PORT=$((GRPC_PORT + 10))
+
+echo -e "Creating $BINARY instance:
+  \t home=$CHAIN_DIR | chain-id=$CHAIN_ID | p2p=:$P2P_PORT | rpc=:$RPC_PORT | profiling=:$PROF_PORT |
+  \t grpc=:$GRPC_PORT | grpc-web=:$GRPC_WEB_PORT | samoleans=:$SAMOLEANS"
 
 # Add dir for chain, exit if error
 if ! mkdir -p $CHAIN_DIR/$CHAIN_ID 2>/dev/null; then
@@ -77,11 +82,11 @@ HERMES_COINS="${STAKE},${SAMOLEANS}samoleans"
 
 $BINARY --home $CHAIN_DIR/$CHAIN_ID --chain-id $CHAIN_ID init $CHAIN_ID &> /dev/null
 sleep 1
-$BINARY --home $CHAIN_DIR/$CHAIN_ID keys add validator --keyring-backend="test" --output json > $CHAIN_DIR/$CHAIN_ID/validator_seed.json 2> /dev/null
+$BINARY --home $CHAIN_DIR/$CHAIN_ID keys add validator --keyring-backend="test" --algo="secp256k1" --output json > $CHAIN_DIR/$CHAIN_ID/validator_seed.json 2> /dev/null
 sleep 1
-$BINARY --home $CHAIN_DIR/$CHAIN_ID keys add user --keyring-backend="test" --output json > $CHAIN_DIR/$CHAIN_ID/user_seed.json 2> /dev/null
+$BINARY --home $CHAIN_DIR/$CHAIN_ID keys add user --keyring-backend="test" --algo="secp256k1" --output json > $CHAIN_DIR/$CHAIN_ID/user_seed.json 2> /dev/null
 sleep 1
-$BINARY --home $CHAIN_DIR/$CHAIN_ID keys add user2 --keyring-backend="test" --output json > $CHAIN_DIR/$CHAIN_ID/user2_seed.json 2> /dev/null
+$BINARY --home $CHAIN_DIR/$CHAIN_ID keys add user2 --keyring-backend="test" --algo="secp256k1" --output json > $CHAIN_DIR/$CHAIN_ID/user2_seed.json 2> /dev/null
 sleep 1
 
 # Add samoleans to user
@@ -139,9 +144,10 @@ else
   # sed -i '' 's/info/debug/g' $CHAIN_DIR/$CHAIN_ID/config/config.toml
 fi
 
-# Start gaia
-echo "Start gaia on grpc port: $GRPC_PORT..."
-$BINARY --home $CHAIN_DIR/$CHAIN_ID start --pruning=nothing --grpc.address="0.0.0.0:$GRPC_PORT" --log_level error > $CHAIN_DIR/$CHAIN_ID.log 2>&1 &
+# Start chain
+echo "Start $BINARY on grpc port: $GRPC_PORT & grpc-web port: $GRPC_WEB_PORT..."
+$BINARY --home $CHAIN_DIR/$CHAIN_ID start --grpc-web.address "0.0.0.0:$GRPC_WEB_PORT" --pruning=nothing --grpc.address="0.0.0.0:$GRPC_PORT" --json-rpc.address="0.0.0.0:$JRPC_PORT" --log_level error > $CHAIN_DIR/$CHAIN_ID.log 2>&1 &
+#$BINARY --home $CHAIN_DIR/$CHAIN_ID start --pruning=nothing --grpc.address="0.0.0.0:$GRPC_PORT" --log_level error > $CHAIN_DIR/$CHAIN_ID.log 2>&1 &
 
 # Show validator's and user's balance
 sleep 3
diff --git a/scripts/setup-chains b/scripts/setup-chains
index a95e84db..ecd8f573 100755
--- a/scripts/setup-chains
+++ b/scripts/setup-chains
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-# Copied from https://github.com/cosmos/relayer and modified to initialize Gaia chains.
+# Copied from https://github.com/cosmos/relayer and modified to initialize multiple chains.
 
 usage() {
   echo "Usage: $0 CHAIN_0_ID CHAIN_1_ID [CHAIN_2_ID]"
@@ -14,27 +14,36 @@ missing() {
 }
 
 if [ -z "$1" ]; then
-  missing "CHAIN_0_ID"
+  missing "CHAIN_0"
 fi
 
 if [ -z "$2" ]; then
+  missing "CHAIN_0_ID"
+fi
+
+if [ -z "$3" ]; then
+  missing "CHAIN_1"
+fi
+
+if [ -z "$4" ]; then
   missing "CHAIN_1_ID"
 fi
 
 
-if [ "$#" -gt 3 ]; then
+if [ "$#" -gt 4 ]; then
   echo "Incorrect number of parameters."
   usage
 fi
 
-CHAIN_0_ID="$1"
-CHAIN_1_ID="$2"
-CHAIN_2_ID="$3"
+CHAIN_0="$1"
+CHAIN_0_ID="$2"
+CHAIN_1="$3"
+CHAIN_1_ID="$4"
 
-GAIA_DATA="$(pwd)/data"
+DATA_DIR="$(pwd)/data"
 
 # Ensure user understands what will be deleted
-if [[ -d $GAIA_DATA ]] && [[ ! "$3" == "skip" ]]; then
+if [[ -d $DATA_DIR ]] && [[ ! "$3" == "skip" ]]; then
   echo "WARNING: $0 will DELETE the '$(pwd)/data' folder."
   read -p "> Do you wish to continue? (y/n): " -n 1 -r
   echo
@@ -43,50 +52,44 @@ if [[ -d $GAIA_DATA ]] && [[ ! "$3" == "skip" ]]; then
   fi
 fi
 
-# Ensure gaiad is installed
-if ! [ -x "$(which gaiad)" ]; then
-  echo "Error: gaiad is not installed. Try running 'make build-gaia'" >&2
+# Ensure chains are installed
+if ! [ -x "$(which $CHAIN_0)" ]; then
+  echo "Error: $CHAIN_0 is not installed." >&2
+  exit 1
+fi
+if ! [ -x "$(which $CHAIN_1)" ]; then
+  echo "Error: $CHAIN_1 is not installed." >&2
   exit 1
 fi
 
 # Display software version
-echo "GAIA VERSION INFO: $(gaiad version --log_level info)"
+echo "$CHAIN_0 VERSION INFO: $($CHAIN_0 version --log_level info)"
+echo "$CHAIN_1 VERSION INFO: $($CHAIN_1 version --log_level info)"
 
 # Delete data from old runs
-echo "Deleting $GAIA_DATA folder..."
-rm -rf "$GAIA_DATA"
+echo "Deleting $DATA_DIR folder..."
+rm -rf "$DATA_DIR"
 
-# Stop existing gaiad processes
-killall gaiad &> /dev/null || true
-killall akash &> /dev/null || true
+# Stop existing chain processes
+killall $CHAIN_0 &> /dev/null || true
+killall $CHAIN_1 &> /dev/null || true
 
-echo "Generating gaia configurations..."
-mkdir -p "$GAIA_DATA" && cd "$GAIA_DATA" && cd ../
+echo "Generating chains' configurations..."
+mkdir -p "$DATA_DIR" && cd "$DATA_DIR" && cd ../
 
 ONE_CHAIN="$(dirname "$0")/one-chain"
 
 CHAIN_0_RPC_PORT=26657
 CHAIN_1_RPC_PORT=26557
-CHAIN_2_RPC_PORT=26457
 
 CHAIN_0_GRPC_PORT=9090
 CHAIN_1_GRPC_PORT=9091
-CHAIN_2_GRPC_PORT=9092
 
 CHAIN_0_SAMOLEANS=100000000000
 CHAIN_1_SAMOLEANS=100000000000
-CHAIN_2_SAMOLEANS=100000000000
-
-"$ONE_CHAIN" gaiad "$CHAIN_0_ID" ./data $CHAIN_0_RPC_PORT 26656 6060 $CHAIN_0_GRPC_PORT $CHAIN_0_SAMOLEANS
-"$ONE_CHAIN" gaiad "$CHAIN_1_ID" ./data $CHAIN_1_RPC_PORT 26556 6061 $CHAIN_1_GRPC_PORT $CHAIN_1_SAMOLEANS
 
-if [ -n "$CHAIN_2_ID" ]; then
-  "$ONE_CHAIN" gaiad "$CHAIN_2_ID" ./data $CHAIN_2_RPC_PORT 26456 6062 $CHAIN_2_GRPC_PORT $CHAIN_2_SAMOLEANS
-fi
-
-[ -f "$GAIA_DATA/$CHAIN_0_ID.log" ] && echo "$CHAIN_0_ID initialized. Watch file $GAIA_DATA/$CHAIN_0_ID.log to see its execution."
-[ -f "$GAIA_DATA/$CHAIN_1_ID.log" ] && echo "$CHAIN_1_ID initialized. Watch file $GAIA_DATA/$CHAIN_1_ID.log to see its execution."
+"$ONE_CHAIN" $CHAIN_0 "$CHAIN_0_ID" ./data $CHAIN_0_RPC_PORT 26656 6060 $CHAIN_0_GRPC_PORT $CHAIN_0_SAMOLEANS
+"$ONE_CHAIN" $CHAIN_1 "$CHAIN_1_ID" ./data $CHAIN_1_RPC_PORT 26556 6061 $CHAIN_1_GRPC_PORT $CHAIN_1_SAMOLEANS
 
-if [ -n "$CHAIN_2_ID" ]; then
-  [ -f "$GAIA_DATA/$CHAIN_2_ID.log" ] && echo "$CHAIN_2_ID initialized. Watch file $GAIA_DATA/$CHAIN_2_ID.log to see its execution."
-fi
+[ -f "$DATA_DIR/$CHAIN_0_ID.log" ] && echo "$CHAIN_0_ID initialized. Watch file $DATA_DIR/$CHAIN_0_ID.log to see its execution."
+[ -f "$DATA_DIR/$CHAIN_1_ID.log" ] && echo "$CHAIN_1_ID initialized. Watch file $DATA_DIR/$CHAIN_1_ID.log to see its execution."

proto/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@yihuang yihuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

For visibility, there's also similar PR to gravity bridge's orchestrator(PeggyJV/gravity-bridge#150), ideally, these cosmos-related rust projects should share a common infrastructure in the future.

@adizere adizere merged commit 8544658 into informalsystems:master Sep 10, 2021
@adizere adizere mentioned this pull request Jan 18, 2022
5 tasks
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* added Ethermint support (fixes informalsystems#1267 informalsystems#1071)

- collected changes from informalsystems#1267 (comment)
- EthAccount definition was directly pasted into the proto library
(as different chains the same proto definition, but under a different package path)
- added a new configuration option that allows specifying the address derivation
as well as the proto type of public keys
(e.g. "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
or "/ethermint.crypto.v1alpha1.ethsecp256k1.PubKey")

* added a comment for eth address and change query_account return type back to BaseAccount

* check the public key type in ethermint address generation

* added a check on `sign_msg`

* added comments + reordered example config

* added links with information for testing Ethermint

* adjusted a comment for `EthAccount`

Co-authored-by: Romain Ruetschi <romain@informal.systems>
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.

hermes is not compatible with ethermint Adding key generation algorithm for "eth_secp256k1"
8 participants