Skip to content

Commit

Permalink
feat: Generate Cosmos address for Injective (#4618)
Browse files Browse the repository at this point in the history
### Description

Injective uses different logic compared to Neutron and Osmosis to
generate account addresses from public key. It is implemented in this PR
so that sender address is correctly generated from signer info of
transaction.

Depending on the type of public key communicated in the transaction, we
shall generate either Bitcoin-like or Ethereum-like address for
Injective.

We can also specify the type of account id for the signer. Bitcoin-like
will be chosen by default, so, we don't need to change the configuration
of Relayer.

### Drive-by changes

Made some errors to be warnings. We'll add metrics to measure how
frequent the issues are and decide how to fix them:
1. transaction contains multiple contract execution messages
2. transaction contains fees in unsupported denominations

Made Scraper to refrain from recording transaction which it cannot parse
properly.

### Backward compatibility

Yes

### Testing

Added unit tests
Manual testing with Injective blockchain

---------

Co-authored-by: Danil Nemirovsky <[email protected]>
  • Loading branch information
2 people authored and ltyu committed Oct 8, 2024
1 parent be4cb44 commit 1cc1671
Show file tree
Hide file tree
Showing 22 changed files with 416 additions and 97 deletions.
81 changes: 46 additions & 35 deletions rust/main/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions rust/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"hyperlane-test",
"utils/abigen",
"utils/backtrace-oneline",
"utils/crypto",
"utils/hex",
"utils/run-locally",
]
Expand Down Expand Up @@ -69,10 +70,10 @@ futures-util = "0.3"
generic-array = { version = "0.14", features = ["serde", "more_lengths"] }
# Required for WASM support https://docs.rs/getrandom/latest/getrandom/#webassembly-support
bech32 = "0.9.1"
elliptic-curve = "0.12.3"
elliptic-curve = "0.13.8"
getrandom = { version = "0.2", features = ["js"] }
hex = "0.4.3"
http = "*"
http = "0.2.12"
hyper = "0.14"
hyper-tls = "0.5.0"
hyperlane-cosmwasm-interface = "=0.0.6-rc6"
Expand All @@ -81,7 +82,7 @@ injective-std = "=0.1.5"
itertools = "*"
jobserver = "=0.1.26"
jsonrpc-core = "18.0"
k256 = { version = "0.13.1", features = ["std", "ecdsa"] }
k256 = { version = "0.13.4", features = ["arithmetic", "std", "ecdsa"] }
log = "0.4"
macro_rules_attribute = "0.2"
maplit = "1.0"
Expand Down
1 change: 1 addition & 0 deletions rust/main/chains/hyperlane-cosmos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ base64 = { workspace = true }
bech32 = { workspace = true }
cosmrs = { workspace = true, features = ["cosmwasm", "tokio", "grpc", "rpc"] }
cosmwasm-std = { workspace = true }
crypto = { path = "../../utils/crypto" }
derive-new = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
Expand Down
11 changes: 10 additions & 1 deletion rust/main/chains/hyperlane-cosmos/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::fmt::Debug;

use cosmrs::proto::prost;

use crypto::PublicKeyError;
use hyperlane_core::ChainCommunicationError;
use std::fmt::Debug;

/// Errors from the crates specific to the hyperlane-cosmos
/// implementation.
Expand Down Expand Up @@ -60,3 +63,9 @@ impl From<HyperlaneCosmosError> for ChainCommunicationError {
ChainCommunicationError::from_other(value)
}
}

impl From<PublicKeyError> for HyperlaneCosmosError {
fn from(value: PublicKeyError) -> Self {
HyperlaneCosmosError::PublicKeyError(value.to_string())
}
}
Loading

0 comments on commit 1cc1671

Please sign in to comment.