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

fix: Fix certificate issue for Cosmos chains #5114

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
708 changes: 430 additions & 278 deletions rust/main/Cargo.lock

Large diffs are not rendered by default.

27 changes: 11 additions & 16 deletions rust/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ color-eyre = "0.6"
config = "0.13.3"
console-subscriber = "0.2.0"
convert_case = "0.6"
cosmrs = { version = "0.14", default-features = false, features = [
cosmrs = { version = "0.18.0", default-features = false, features = [
"cosmwasm",
"rpc",
"tokio",
Expand All @@ -73,12 +73,12 @@ bech32 = "0.9.1"
elliptic-curve = "0.13.8"
getrandom = { version = "0.2", features = ["js"] }
hex = "0.4.3"
http = "0.2.12"
http = "1.2.0"
hyper = "0.14"
hyper-tls = "0.5.0"
hyperlane-cosmwasm-interface = "=0.0.6-rc6"
injective-protobuf = "0.2.2"
injective-std = "=0.1.5"
injective-std = "1.13.2-hyperlane-2025-01-09-11-28"
itertools = "*"
jobserver = "=0.1.26"
jsonrpc-core = "18.0"
Expand Down Expand Up @@ -134,16 +134,16 @@ static_assertions = "1.1"
strum = "0.26.2"
strum_macros = "0.26.2"
tempfile = "3.3"
tendermint = "0.32.2"
tendermint-rpc = { version = "0.32.0", features = ["http-client", "tokio"] }
tendermint = "0.38.1"
tendermint-rpc = { version = "0.38.1", features = ["http-client", "tokio"] }
thiserror = "1.0"
time = "0.3"
tiny-keccak = "2.0.2"
tokio = { version = "1.4", features = ["parking_lot", "tracing"] }
tokio = { version = "1.42.0", features = ["parking_lot", "tracing"] }
tokio-metrics = { version = "0.3.1", default-features = false }
tokio-test = "0.4"
toml_edit = "0.19.14"
tonic = "0.9.2"
tonic = "0.12.3"
tracing = { version = "0.1" }
tracing-error = "0.2"
tracing-futures = "0.2"
Expand Down Expand Up @@ -300,12 +300,7 @@ version = "=0.1.0"
git = "https://github.com/hyperlane-xyz/solana-program-library.git"
branch = "hyperlane"

[patch.crates-io.tendermint]
branch = "trevor/0.32.2-fork"
git = "https://github.com/hyperlane-xyz/tendermint-rs.git"
version = "=0.32.2"

[patch.crates-io.tendermint-rpc]
branch = "trevor/0.32.2-fork"
git = "https://github.com/hyperlane-xyz/tendermint-rs.git"
version = "=0.32.2"
[patch.crates-io.injective-std]
version = "1.13.2-hyperlane-2025-01-09-11-28"
git = "https://github.com/hyperlane-xyz/cw-injective.git"
tag = "1.13.2-hyperlane-2025-01-09-11-28"
2 changes: 1 addition & 1 deletion rust/main/chains/hyperlane-cosmos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tonic = { workspace = true, features = [
"transport",
"tls",
"tls-roots",
"tls-roots-common",
"tls-native-roots",
] }
tracing = { workspace = true }
tracing-futures = { workspace = true }
Expand Down
143 changes: 76 additions & 67 deletions rust/main/chains/hyperlane-cosmos/src/interchain_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,76 +122,85 @@ impl CosmosInterchainGasPaymasterIndexer {
let mut gas_payment = IncompleteInterchainGasPayment::default();

for attr in attrs {
let key = attr.key.as_str();
let value = attr.value.as_str();

match key {
CONTRACT_ADDRESS_ATTRIBUTE_KEY => {
contract_address = Some(value.to_string());
}
v if *CONTRACT_ADDRESS_ATTRIBUTE_KEY_BASE64 == v => {
contract_address = Some(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?);
match attr {
EventAttribute::V037(a) => {
let key = a.key.as_str();
let value = a.value.as_str();

match key {
CONTRACT_ADDRESS_ATTRIBUTE_KEY => {
contract_address = Some(value.to_string());
}
v if *CONTRACT_ADDRESS_ATTRIBUTE_KEY_BASE64 == v => {
contract_address = Some(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?);
}

MESSAGE_ID_ATTRIBUTE_KEY => {
gas_payment.message_id =
Some(H256::from_slice(hex::decode(value)?.as_slice()));
}
v if *MESSAGE_ID_ATTRIBUTE_KEY_BASE64 == v => {
gas_payment.message_id = Some(H256::from_slice(
hex::decode(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?)?
.as_slice(),
));
}

PAYMENT_ATTRIBUTE_KEY => {
gas_payment.payment = Some(U256::from_dec_str(value)?);
}
v if *PAYMENT_ATTRIBUTE_KEY_BASE64 == v => {
let dec_str = String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?;
// U256's from_str assumes a radix of 16, so we explicitly use from_dec_str.
gas_payment.payment = Some(U256::from_dec_str(dec_str.as_str())?);
}

GAS_AMOUNT_ATTRIBUTE_KEY => {
gas_payment.gas_amount = Some(U256::from_dec_str(value)?);
}
v if *GAS_AMOUNT_ATTRIBUTE_KEY_BASE64 == v => {
let dec_str = String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?;
// U256's from_str assumes a radix of 16, so we explicitly use from_dec_str.
gas_payment.gas_amount = Some(U256::from_dec_str(dec_str.as_str())?);
}

DESTINATION_ATTRIBUTE_KEY => {
gas_payment.destination = Some(value.parse::<u32>()?);
}
v if *DESTINATION_ATTRIBUTE_KEY_BASE64 == v => {
gas_payment.destination = Some(
String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?
.parse()?,
);
}

_ => {}
}
}

MESSAGE_ID_ATTRIBUTE_KEY => {
gas_payment.message_id = Some(H256::from_slice(hex::decode(value)?.as_slice()));
EventAttribute::V034(a) => {
unimplemented!();
}
v if *MESSAGE_ID_ATTRIBUTE_KEY_BASE64 == v => {
gas_payment.message_id = Some(H256::from_slice(
hex::decode(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?)?
.as_slice(),
));
}

PAYMENT_ATTRIBUTE_KEY => {
gas_payment.payment = Some(U256::from_dec_str(value)?);
}
v if *PAYMENT_ATTRIBUTE_KEY_BASE64 == v => {
let dec_str = String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?;
// U256's from_str assumes a radix of 16, so we explicitly use from_dec_str.
gas_payment.payment = Some(U256::from_dec_str(dec_str.as_str())?);
}

GAS_AMOUNT_ATTRIBUTE_KEY => {
gas_payment.gas_amount = Some(U256::from_dec_str(value)?);
}
v if *GAS_AMOUNT_ATTRIBUTE_KEY_BASE64 == v => {
let dec_str = String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?;
// U256's from_str assumes a radix of 16, so we explicitly use from_dec_str.
gas_payment.gas_amount = Some(U256::from_dec_str(dec_str.as_str())?);
}

DESTINATION_ATTRIBUTE_KEY => {
gas_payment.destination = Some(value.parse::<u32>()?);
}
v if *DESTINATION_ATTRIBUTE_KEY_BASE64 == v => {
gas_payment.destination = Some(
String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?
.parse()?,
);
}

_ => {}
}
}

Expand Down
58 changes: 33 additions & 25 deletions rust/main/chains/hyperlane-cosmos/src/mailbox/delivery_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,42 @@ impl CosmosMailboxDeliveryIndexer {
let mut message_id: Option<Delivery> = None;

for attr in attrs {
let key = attr.key.as_str();
let value = attr.value.as_str();

match key {
CONTRACT_ADDRESS_ATTRIBUTE_KEY => {
contract_address = Some(value.to_string());
}
v if *CONTRACT_ADDRESS_ATTRIBUTE_KEY_BASE64 == v => {
contract_address = Some(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?);
match attr {
EventAttribute::V037(a) => {
let key = a.key.as_str();
let value = a.value.as_str();

match key {
CONTRACT_ADDRESS_ATTRIBUTE_KEY => {
contract_address = Some(value.to_string());
}
v if *CONTRACT_ADDRESS_ATTRIBUTE_KEY_BASE64 == v => {
contract_address = Some(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?);
}

MESSAGE_ID_ATTRIBUTE_KEY => {
message_id = Some(value.parse::<H256>()?);
}
v if *MESSAGE_ID_ATTRIBUTE_KEY_BASE64 == v => {
let hex = String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?;
message_id = Some(hex.parse::<H256>()?);
}

_ => {}
}
}

MESSAGE_ID_ATTRIBUTE_KEY => {
message_id = Some(value.parse::<H256>()?);
EventAttribute::V034(a) => {
unimplemented!();
}
v if *MESSAGE_ID_ATTRIBUTE_KEY_BASE64 == v => {
let hex = String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?;
message_id = Some(hex.parse::<H256>()?);
}

_ => {}
}
}

Expand Down
68 changes: 38 additions & 30 deletions rust/main/chains/hyperlane-cosmos/src/mailbox/dispatch_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,47 @@ impl CosmosMailboxDispatchIndexer {
let mut message: Option<HyperlaneMessage> = None;

for attr in attrs {
let key = attr.key.as_str();
let value = attr.value.as_str();

match key {
CONTRACT_ADDRESS_ATTRIBUTE_KEY => {
contract_address = Some(value.to_string());
}
v if *CONTRACT_ADDRESS_ATTRIBUTE_KEY_BASE64 == v => {
contract_address = Some(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?);
match attr {
EventAttribute::V037(a) => {
let key = a.key.as_str();
let value = a.value.as_str();

match key {
CONTRACT_ADDRESS_ATTRIBUTE_KEY => {
contract_address = Some(value.to_string());
}
v if *CONTRACT_ADDRESS_ATTRIBUTE_KEY_BASE64 == v => {
contract_address = Some(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?);
}

MESSAGE_ATTRIBUTE_KEY => {
// Intentionally using read_from to get a Result::Err if there's
// an issue with the message.
let mut reader = Cursor::new(hex::decode(value)?);
message = Some(HyperlaneMessage::read_from(&mut reader)?);
}
v if *MESSAGE_ATTRIBUTE_KEY_BASE64 == v => {
// Intentionally using read_from to get a Result::Err if there's
// an issue with the message.
let mut reader = Cursor::new(hex::decode(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?)?);
message = Some(HyperlaneMessage::read_from(&mut reader)?);
}

_ => {}
}
}

MESSAGE_ATTRIBUTE_KEY => {
// Intentionally using read_from to get a Result::Err if there's
// an issue with the message.
let mut reader = Cursor::new(hex::decode(value)?);
message = Some(HyperlaneMessage::read_from(&mut reader)?);
EventAttribute::V034(a) => {
unimplemented!();
}
v if *MESSAGE_ATTRIBUTE_KEY_BASE64 == v => {
// Intentionally using read_from to get a Result::Err if there's
// an issue with the message.
let mut reader = Cursor::new(hex::decode(String::from_utf8(
BASE64
.decode(value)
.map_err(Into::<HyperlaneCosmosError>::into)?,
)?)?);
message = Some(HyperlaneMessage::read_from(&mut reader)?);
}

_ => {}
}
}

Expand Down
Loading
Loading