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

Adding a key to Hermes creates the wrong address #3985

Closed
5 tasks
tot-truong opened this issue May 7, 2024 · 12 comments
Closed
5 tasks

Adding a key to Hermes creates the wrong address #3985

tot-truong opened this issue May 7, 2024 · 12 comments

Comments

@tot-truong
Copy link

Summary of Bug

When adding a key to Hermes it creates the wrong address for the injective-1 mainnet (compared using injectived).

Version

hermes 1.8.2

Steps to Reproduce

Using injectived => inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7

$ injectived version
Version v1.12.1 (e1ab66c)
Compiled at 20240429-0857 using Go go1.21.3 (amd64)

injectived keys add aa-test --recover
> Enter your bip39 mnemonic
that upper concert rice water duck body deny mom bulb crop warfare ugly focus worry expand ribbon gift exist knee pave zoo simple hazard
{"name":"aa-test","type":"local","address":"inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7","pubkey":"{\"@type\":\"/injective.crypto.v1beta1.ethsecp256k1.PubKey\",\"key\":\"ApIXFaJWETKktnjBeDB4xW1+FRL//s92jPhn50BrpwpR\"}"}

hd-path "m/44'/60'/0'/0/0" => inj1etzf7nsxsqs8xhtnw0qu0kzateqj9qcgwm3l66 => EXPECTED inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7

$ hermes version
2024-05-07T15:53:33.042568Z  INFO ThreadId(01) running Hermes v1.8.2
hermes 1.8.2
$ echo "that upper concert rice water duck body deny mom bulb crop warfare ugly focus worry expand ribbon gift exist knee pave zoo simple hazard" > mnemonic.txt;hermes --config main.toml keys add --chain injective-1 --key-name test --hd-path "m/44'/60'/0'/0/0" --mnemonic-file mnemonic.txt
2024-05-07T15:47:43.920337Z  INFO ThreadId(01) running Hermes v1.8.2
SUCCESS Restored key 'test' (inj1etzf7nsxsqs8xhtnw0qu0kzateqj9qcgwm3l66) on chain injective-1

No hd path set => inj1yvvuw3nm4fphmxjeuwhjek6wqmvepnze94kjxv

$ echo "that upper concert rice water duck body deny mom bulb crop warfare ugly focus worry expand ribbon gift exist knee pave zoo simple hazard" > mnemonic.txt;hermes --config main.toml keys add --chain injective-1 --key-name test --mnemonic-file mnemonic.txt --overwrite
2024-05-07T15:49:34.166285Z  INFO ThreadId(01) running Hermes v1.8.2
2024-05-07T15:49:34.167439Z  WARN ThreadId(01) key test will be overwritten
SUCCESS Restored key 'test' (inj1yvvuw3nm4fphmxjeuwhjek6wqmvepnze94kjxv) on chain injective-1

Hermes config main.toml

[global]
log_level = "info"

[mode.clients]
enabled = true
refresh = true
misbehaviour = true

[mode.connections]
enabled = false

[mode.channels]
enabled = false

[mode.packets]
enabled = true
clear_interval = 100
clear_on_start = true
tx_confirmation = false
auto_register_counterparty_payee = false

[mode.packets.ics20_max_memo_size]
enabled = true
size = 32768

[mode.packets.ics20_max_receiver_size]
enabled = true
size = 2048

[rest]
enabled = false
host = "127.0.0.1"
port = 3000

[telemetry]
enabled = false
host = "127.0.0.1"
port = 3001

[telemetry.buckets.latency_submitted]
start = 500
end = 20000
buckets = 10

[telemetry.buckets.latency_confirmed]
start = 1000
end = 30000
buckets = 10

[[chains]]
type = "CosmosSdk"
id = "injective-1"
rpc_addr = "https://rpc-injective.whispernode.com/"
grpc_addr = "https://injective-grpc.publicnode.com/"
rpc_timeout = "10s"
# trusted_node = false
account_prefix = "inj"
key_name = 'injective_relayer'
key_store_type = "Test"
store_prefix = "ibc"
default_gas = 100000
max_gas = 400000
gas_multiplier = 1.1
max_msg_num = 1 # 30 / relay only 1 packet, otherwise max gas is exceeded
max_tx_size = 180000
# max_grpc_decoding_size = 33554432
# query_packets_chunk_size = 50
clock_drift = "5s"
max_block_time = "30s"
client_refresh_rate = "1/3"
ccv_consumer_chain = false
memo_prefix = 'test'
sequential_batch_tx = false

[chains.event_source]
mode = "push"
url = "wss://rpc-injective.whispernode.com/websocket"
batch_delay = "500ms"

[chains.trust_threshold]
numerator = 2
denominator = 3

[chains.gas_price]
price = 700000000.0
denom = "inj"

[chains.packet_filter]
policy = "allow"
list = [
]
[chains.packet_filter.min_fees]

# [chains.dynamic_gas_price]
# enabled = false
# multiplier = 1.1
# max = 0.6

[chains.address_type]
derivation = "cosmos"

[chains.excluded_sequences]

# [tracing_server]
# enabled = false
# port = 5555

Acceptance Criteria


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@taitruong
Copy link

taitruong commented May 8, 2024

Can confirm, having the same issue. Hermes creates completely different Injective address - as compared to injectived or rly.

@adizere
Copy link
Member

adizere commented May 8, 2024

Thanks for reporting this!

You mean the problem appears when you skip specifying --hd-path "m/44'/60'/0'/0/0" as parameter to keys add command ?

@tot-truong
Copy link
Author

tot-truong commented May 8, 2024 via email

@taitruong
Copy link

Any updates here? Bug can be reproduce and Injective addresses arent properly created - even with hd path m/44'/60'/0'/0/0 (results to different address compared to using injectived cli).

@romac
Copy link
Member

romac commented May 22, 2024

According to the Injective documentation:

By default, the keyring generates a eth_secp256k1 keypair. The keyring also supports ed25519 keys, which may be created by passing the --algo ed25519 flag. A keyring can of course hold both types of keys simultaneously.

If I configure address_type accordingly:

[[chain]]
id = 'injective-1'
# ...
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

I then get the expected address:

$ hermes --config injective.toml keys add --chain injective-1 --key-name test --hd-path "m/44'/60'/0'/0/0" --mnemonic-file mnemonic.txt --overwrite
2024-05-22T09:36:52.022765Z  INFO ThreadId(01) running Hermes v1.8.2+25f547595
2024-05-22T09:36:52.023353Z  WARN ThreadId(01) key test will be overwritten
SUCCESS Restored key 'test' (inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7) on chain injective-1

@romac romac closed this as completed May 22, 2024
@romac
Copy link
Member

romac commented May 22, 2024

@tot-truong What do you think we could document better on the Hermes side to prevent such issues? The address_type config is mentioned in the config.toml, but perhaps we should have a dedicated section in the guide?

@taitruong
Copy link

According to the Injective documentation:

By default, the keyring generates a eth_secp256k1 keypair. The keyring also supports ed25519 keys, which may be created by passing the --algo ed25519 flag. A keyring can of course hold both types of keys simultaneously.

If I configure address_type accordingly:

[[chain]]
id = 'injective-1'
# ...
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

I then get the expected address:

$ hermes --config injective.toml keys add --chain injective-1 --key-name test --hd-path "m/44'/60'/0'/0/0" --mnemonic-file mnemonic.txt --overwrite
2024-05-22T09:36:52.022765Z  INFO ThreadId(01) running Hermes v1.8.2+25f547595
2024-05-22T09:36:52.023353Z  WARN ThreadId(01) key test will be overwritten
SUCCESS Restored key 'test' (inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7) on chain injective-1

@romac we have tested with address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } } and it generates wrong injective address.

Have u tried restoring key using injectived? In our case injectived produces a different address.

@romac
Copy link
Member

romac commented May 23, 2024

Is the address I got not the very same address output by injectived? inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7

I will try with injectived as soon as I get a chance, in the meantime can you please share full logs and Hermes config with the address_type I shared above?

@tot-truong
Copy link
Author

Is the address I got not the very same address output by injectived? inj1mzy2fz8wzq069r8z20m2fcvsdye3pr7qrwfvx7

I will try with injectived as soon as I get a chance, in the meantime can you please share full logs and Hermes config with the address_type I shared above?

Even when adding the address type to the hermes config

[[chain]]
id = 'injective-1'
# ...
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

I still get the wrong address

$ echo "that upper concert rice water duck body deny mom bulb crop warfare ugly focus worry expand ribbon gift exist knee pave zoo simple hazard" > mnemonic.txt;hermes --config main.toml keys add --overwrite --chain injective-1 --key-name test --hd-path "m/44'/60'/0'/0/0" --mnemonic-file mnemonic.txt
2024-06-03T01:52:39.199791Z  INFO ThreadId(01) running Hermes v1.8.2
2024-06-03T01:52:39.200152Z  WARN ThreadId(01) key test will be overwritten
SUCCESS Restored key 'test' (inj1etzf7nsxsqs8xhtnw0qu0kzateqj9qcgwm3l66) on chain injective-1

@tot-truong
Copy link
Author

I wonder if the reason is that your on a different version than me on Hermes?

Hermes v1.8.2 vs v1.8.2+25f547595

Here is the full main.toml

[global]
log_level = "info"

[mode.clients]
enabled = true
refresh = true
misbehaviour = true

[mode.connections]
enabled = false

[mode.channels]
enabled = false

[mode.packets]
enabled = true
clear_interval = 100
clear_on_start = true
tx_confirmation = false
auto_register_counterparty_payee = false

[mode.packets.ics20_max_memo_size]
enabled = true
size = 32768

[mode.packets.ics20_max_receiver_size]
enabled = true
size = 2048

[rest]
enabled = false
host = "127.0.0.1"
port = 3000

[telemetry]
enabled = false
host = "127.0.0.1"
port = 3001

[telemetry.buckets.latency_submitted]
start = 500
end = 20000
buckets = 10

[telemetry.buckets.latency_confirmed]
start = 1000
end = 30000
buckets = 10

[[chains]]
type = "CosmosSdk"
id = "injective-1"
rpc_addr = "https://rpc-injective.whispernode.com/"
grpc_addr = "https://injective-grpc.publicnode.com/"
rpc_timeout = "10s"
# trusted_node = false
account_prefix = "inj"
key_name = 'injective_relayer'
key_store_type = "Test"
store_prefix = "ibc"
default_gas = 100000
max_gas = 400000
gas_multiplier = 1.1
max_msg_num = 1 # 30 / relay only 1 packet, otherwise max gas is exceeded
max_tx_size = 180000
# max_grpc_decoding_size = 33554432
# query_packets_chunk_size = 50
clock_drift = "5s"
max_block_time = "30s"
client_refresh_rate = "1/3"
ccv_consumer_chain = false
memo_prefix = 'test'
sequential_batch_tx = false
address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

[chains.event_source]
mode = "push"
url = "wss://rpc-injective.whispernode.com/websocket"
batch_delay = "500ms"

[chains.trust_threshold]
numerator = 2
denominator = 3

[chains.gas_price]
price = 700000000.0
denom = "inj"

[chains.packet_filter]
policy = "allow"
list = [
]
[chains.packet_filter.min_fees]

# [chains.dynamic_gas_price]
# enabled = false
# multiplier = 1.1
# max = 0.6

[chains.address_type]
derivation = "cosmos"

[chains.excluded_sequences]

# [tracing_server]
# enabled = false
# port = 5555

mnemonic.txt

@romac
Copy link
Member

romac commented Jun 3, 2024

You are specifying address_type twice and therefore overriding the correct definition by the wrong one.

Try removing the second one

[chains.address_type]
derivation = "cosmos"

and only keep

address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } }

@tot-truong
Copy link
Author

echo "that upper concert rice water duck body deny mom bulb crop warfare ugly focus worry expand ribbon gift exist knee pave zoo simple hazard" > mnemonic.txt;hermes --config main.toml keys add --overwrite --chain injective-1 --key-name test --hd-path "m/44'/60'/0'/0/0" --mnemonic-file mnemonic.txt

Thanks 100x, that worked! The proper address is now created!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

No branches or pull requests

4 participants