Skip to content

Commit

Permalink
Native tendermint and minor fixes (#1712)
Browse files Browse the repository at this point in the history
Closes #1709 
Closes #1243
  • Loading branch information
aeryz authored Apr 9, 2024
2 parents 6f837b9 + 398238c commit 8a4ec00
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 80 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ bun.lockb
.nfs*
cache
.svelte-kit
build
.eslintcache
.prettiercache
.code-workspace
Expand Down
1 change: 1 addition & 0 deletions cosmwasm/ucs01-relay-api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub struct Ics20Packet {
pub amount: Uint256,
pub sender: String,
pub receiver: String,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub memo: String,
}

Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/ucs01-relay/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl<'a> TransferProtocol for Ics20Protocol<'a> {
}

fn ack_success() -> Self::Ack {
Ics20Ack::Result(b"1".into())
Ics20Ack::Result(vec![1].into())
}

fn ack_failure(error: String) -> Self::Ack {
Expand Down
108 changes: 46 additions & 62 deletions lib/chain-utils/src/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,78 +247,62 @@ impl Chain for Cosmos {

async fn read_ack(
&self,
block_hash: H256,
tx_hash: H256,
destination_channel_id: unionlabs::id::ChannelId,
destination_port_id: unionlabs::id::PortId,
sequence: NonZeroU64,
) -> Vec<u8> {
let block_height = self
.tm_client
.block_by_hash(block_hash.0.to_vec().try_into().unwrap())
.await
.unwrap()
.block
.unwrap()
.header
.height;

tracing::info!(
"Querying ack for {}/{}/{} at {}",
"Querying ack for {}/{}/{} from tx {tx_hash}",
destination_port_id,
destination_channel_id,
sequence,
block_height
);

let wa =
self.tm_client
.tx_search(
tendermint_rpc::query::Query::eq("tx.height", u64::from(block_height)),
false,
1,
255,
tendermint_rpc::Order::Ascending,
)
.await
.unwrap()
.txs
.into_iter()
.find_map(|tx| {
tx.tx_result.events.into_iter().find_map(|event| {
let maybe_ack = WriteAcknowledgement::try_from(
unionlabs::tendermint::abci::event::Event {
ty: event.kind,
attributes: event.attributes.into_iter().map(|attr| {
unionlabs::tendermint::abci::event_attribute::EventAttribute {
key: attr.key,
value: attr.value,
index: attr.index,
}
}).collect()
},
);
match maybe_ack {
Ok(ok)
if ok.packet_sequence == sequence
&& ok.packet_dst_port == destination_port_id
&& ok.packet_dst_channel == destination_channel_id =>
{
Some(ok)
}
Ok(ok) => {
tracing::debug!("Found ack not matching our packet {:?}", ok);
None
}
Err(TryFromTendermintEventError::IncorrectType { .. }) => None,
Err(err) => {
panic!("{err:#?}")
}
}
})
})
.unwrap();

wa.packet_ack_hex
self.tm_client
// TODO: Use tx_search here
.tx(tx_hash.0.to_vec().try_into().unwrap(), false)
.await
.unwrap()
.tx_result
.events
.into_iter()
.find_map(|event| {
let maybe_ack =
WriteAcknowledgement::try_from(unionlabs::tendermint::abci::event::Event {
ty: event.kind,
attributes: event
.attributes
.into_iter()
.map(|attr| {
unionlabs::tendermint::abci::event_attribute::EventAttribute {
key: attr.key,
value: attr.value,
index: attr.index,
}
})
.collect(),
});
match maybe_ack {
Ok(ok)
if ok.packet_sequence == sequence
&& ok.packet_dst_port == destination_port_id
&& ok.packet_dst_channel == destination_channel_id =>
{
Some(ok)
}
Ok(ok) => {
tracing::debug!("Found ack not matching our packet {:?}", ok);
None
}
Err(TryFromTendermintEventError::IncorrectType { .. }) => None,
Err(err) => {
panic!("{err:#?}")
}
}
})
.unwrap()
.packet_ack_hex
}
}

Expand Down
20 changes: 20 additions & 0 deletions networks/devnet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
jailed_validator_threshold = "10";
};
slashing.params = { signed_blocks_window = "10"; };
tokenfactory.params = {
denom_creation_fee = [
{
denom = "muno";
amount = "10000000";
}
];
};
};
};
lightClients = [
Expand Down Expand Up @@ -66,6 +74,18 @@
];
portIncrease = 200;
sdkVersion = 47;
genesisOverwrites = {
app_state = {
tokenfactory.params = {
denom_creation_fee = [
{
denom = "uosmo";
amount = "10000000";
}
];
};
};
};
};

devnet-simd = mkCosmosDevnet {
Expand Down
4 changes: 2 additions & 2 deletions uniond/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ require (
)

replace (
github.com/cometbft/cometbft => github.com/unionlabs/cometbls v0.0.0-20240310221349-e2d54edc212b
github.com/cometbft/cometbft => github.com/unionlabs/cometbls v0.0.0-20240408193122-ee48ab4d6789
// Fork of gnark crypto until https://github.com/ConsenSys/gnark-crypto/pull/314 is merged
github.com/consensys/gnark-crypto => github.com/unionlabs/gnark-crypto v0.0.0-20231016072529-15c0507b6578
github.com/cosmos/cosmos-sdk => github.com/unionlabs/cosmos-sdk v0.0.0-20240329210622-7d067955f702
github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/unionlabs/ibc-go/modules/light-clients/08-wasm v0.0.0-20231219091832-0947f2e3d1aa
github.com/cosmos/ibc-go/v8 => github.com/unionlabs/ibc-go/v8 v8.0.0-20231219091832-0947f2e3d1aa
github.com/cosmos/ibc-go/v8 => github.com/unionlabs/ibc-go/v8 v8.0.0-20240408193244-9289688332be
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
8 changes: 4 additions & 4 deletions uniond/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1084,16 +1084,16 @@ github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/unionlabs/cometbls v0.0.0-20240310221349-e2d54edc212b h1:KLUmkf0vAzt+ZfwfuH03bf7+73rNB+iLV8ux/6S5rmg=
github.com/unionlabs/cometbls v0.0.0-20240310221349-e2d54edc212b/go.mod h1:ZN5TH4WzX9x+hgcipytd0WghjGcCBy6M8YVgnHOCd/0=
github.com/unionlabs/cometbls v0.0.0-20240408193122-ee48ab4d6789 h1:Zx4NRmHUx0duDQgztivR/6jTz2xen43PoAeIkyCyEvQ=
github.com/unionlabs/cometbls v0.0.0-20240408193122-ee48ab4d6789/go.mod h1:ZN5TH4WzX9x+hgcipytd0WghjGcCBy6M8YVgnHOCd/0=
github.com/unionlabs/cosmos-sdk v0.0.0-20240329210622-7d067955f702 h1:0+Aw+2Hdo+Z4+eVnA6KqGZ4wstL+089LuP63n6XX8Ps=
github.com/unionlabs/cosmos-sdk v0.0.0-20240329210622-7d067955f702/go.mod h1:2B7Z2vkgssySAIsIMPPUqvDmG3AR1zjVcz/Ci8EqLeo=
github.com/unionlabs/gnark-crypto v0.0.0-20231016072529-15c0507b6578 h1:Owzup0XvshGNHgS1s0xUI/mZM+fPvTT7dLg7P0cT2vQ=
github.com/unionlabs/gnark-crypto v0.0.0-20231016072529-15c0507b6578/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
github.com/unionlabs/ibc-go/modules/light-clients/08-wasm v0.0.0-20231219091832-0947f2e3d1aa h1:pzXp42whoLAzvNkdJHPnWPzWAN2iDtqAFoN/BksxmAE=
github.com/unionlabs/ibc-go/modules/light-clients/08-wasm v0.0.0-20231219091832-0947f2e3d1aa/go.mod h1:u2FXNcSxzzn5IwjWBA51HKMwiYMRK6/G35VmSJULhP0=
github.com/unionlabs/ibc-go/v8 v8.0.0-20231219091832-0947f2e3d1aa h1:H/ctmTgXZJc2RFXV+33cprLSfwsN4g2GxmRlXu3I5A4=
github.com/unionlabs/ibc-go/v8 v8.0.0-20231219091832-0947f2e3d1aa/go.mod h1:iTbn3GQH6ArtHhcA5HPytL8U0tU6btp12D3F+3C+RXA=
github.com/unionlabs/ibc-go/v8 v8.0.0-20240408193244-9289688332be h1:Qv/IzpldRtfnamoT6pGvyL7eDMobFTXUaHpG1mUYX/A=
github.com/unionlabs/ibc-go/v8 v8.0.0-20240408193244-9289688332be/go.mod h1:w4D6whozap76QhIYt8FlVy6WqNedZXqotyapFrUK5Sc=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
Expand Down
10 changes: 8 additions & 2 deletions uniond/vendor/github.com/cometbft/cometbft/light/verifier.go

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

44 changes: 44 additions & 0 deletions uniond/vendor/github.com/cometbft/cometbft/types/block.go

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

37 changes: 37 additions & 0 deletions uniond/vendor/github.com/cometbft/cometbft/types/light.go

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

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

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

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

8 changes: 4 additions & 4 deletions uniond/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ github.com/cockroachdb/redact/internal/rfmt/fmtsort
# github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06
## explicit; go 1.19
github.com/cockroachdb/tokenbucket
# github.com/cometbft/cometbft v0.38.5 => github.com/unionlabs/cometbls v0.0.0-20240310221349-e2d54edc212b
# github.com/cometbft/cometbft v0.38.5 => github.com/unionlabs/cometbls v0.0.0-20240408193122-ee48ab4d6789
## explicit; go 1.21
github.com/cometbft/cometbft/abci/client
github.com/cometbft/cometbft/abci/example/kvstore
Expand Down Expand Up @@ -787,7 +787,7 @@ github.com/cosmos/ibc-go/modules/light-clients/08-wasm/client/cli
github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm
github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper
github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types
# github.com/cosmos/ibc-go/v8 v8.0.0 => github.com/unionlabs/ibc-go/v8 v8.0.0-20231219091832-0947f2e3d1aa
# github.com/cosmos/ibc-go/v8 v8.0.0 => github.com/unionlabs/ibc-go/v8 v8.0.0-20240408193244-9289688332be
## explicit; go 1.21
github.com/cosmos/ibc-go/v8/internal/logging
github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts
Expand Down Expand Up @@ -1798,9 +1798,9 @@ rsc.io/tmplfunc/internal/parse
## explicit; go 1.12
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
# github.com/cometbft/cometbft => github.com/unionlabs/cometbls v0.0.0-20240310221349-e2d54edc212b
# github.com/cometbft/cometbft => github.com/unionlabs/cometbls v0.0.0-20240408193122-ee48ab4d6789
# github.com/consensys/gnark-crypto => github.com/unionlabs/gnark-crypto v0.0.0-20231016072529-15c0507b6578
# github.com/cosmos/cosmos-sdk => github.com/unionlabs/cosmos-sdk v0.0.0-20240329210622-7d067955f702
# github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/unionlabs/ibc-go/modules/light-clients/08-wasm v0.0.0-20231219091832-0947f2e3d1aa
# github.com/cosmos/ibc-go/v8 => github.com/unionlabs/ibc-go/v8 v8.0.0-20231219091832-0947f2e3d1aa
# github.com/cosmos/ibc-go/v8 => github.com/unionlabs/ibc-go/v8 v8.0.0-20240408193244-9289688332be
# github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
Loading

0 comments on commit 8a4ec00

Please sign in to comment.