Skip to content
Draft

wip #5300

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
130 changes: 130 additions & 0 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ members = [
# "voyager/modules/state/movement",
"voyager/modules/state/sui",

"voyager/modules/proof/attested",
"voyager/modules/proof/cosmos-sdk",
"voyager/modules/proof/cosmos-sdk-union",
"voyager/modules/proof/ethermint",
Expand All @@ -164,6 +165,7 @@ members = [
"voyager/modules/client/state-lens/ics23-smt",
"voyager/modules/client/sui",
"voyager/modules/client/trusted-mpt",
"voyager/modules/client/attested",

"voyager/modules/client-bootstrap/base",
"voyager/modules/client-bootstrap/bob",
Expand All @@ -179,6 +181,7 @@ members = [
"voyager/modules/client-bootstrap/state-lens/ics23-smt",
"voyager/modules/client-bootstrap/state-lens/ics23-ics23",
"voyager/modules/client-bootstrap/sui",
"voyager/modules/client-bootstrap/attested",

"voyager/modules/finality/base",
"voyager/modules/finality/bob",
Expand All @@ -191,6 +194,7 @@ members = [
"voyager/modules/finality/tendermint",
"voyager/modules/finality/trusted-evm",
"voyager/modules/finality/sui",
"voyager/modules/finality/attested-evm",

"voyager/plugins/client-update/base",
"voyager/plugins/client-update/bob",
Expand All @@ -205,6 +209,7 @@ members = [
"voyager/plugins/client-update/state-lens",
"voyager/plugins/client-update/sui",
"voyager/plugins/client-update/trusted-mpt",
"voyager/plugins/client-update/attested",

"voyager/plugins/periodic-client-update",

Expand All @@ -227,6 +232,8 @@ members = [
"voyager/plugins/sui-ibc-app",
"voyager/plugins/sui-packet-timeout",

"voyager/plugins/attestor/evm",

"drip",

# "lib/aptos-verifier",
Expand Down Expand Up @@ -329,6 +336,7 @@ arbitrum-client = { path = "lib/arbitrum-client", defa
arbitrum-light-client-types = { path = "lib/arbitrum-light-client-types", default-features = false }
arbitrum-types = { path = "lib/arbitrum-types", default-features = false }
arbitrum-verifier = { path = "lib/arbitrum-verifier", default-features = false }
attested-light-client = { path = "cosmwasm/ibc-union/lightclient/attested", default-features = false }
attested-light-client-types = { path = "lib/attested-light-client-types", default-features = false }
base-client = { path = "lib/base-client", default-features = false }
base-light-client-types = { path = "lib/base-light-client-types", default-features = false }
Expand Down
8 changes: 7 additions & 1 deletion cosmwasm/cosmwasm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ _: {
};
# lightclients = pkgs.lib.lists.remove "cometbls" (builtins.attrNames all-lightclients);
lightclients = [
"trusted-mpt"
# "trusted-mpt"
# "sui"
"attested"
];
}
{
Expand Down Expand Up @@ -491,6 +492,11 @@ _: {
dir = "parlia";
client-type = "parlia";
}
{
name = "attested";
dir = "attested";
client-type = "attested";
}
];

# client type => package name
Expand Down
4 changes: 3 additions & 1 deletion cosmwasm/ibc-union/lightclient/attested/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ crate-type = ["cdylib", "rlib"]
attested-light-client-types = { workspace = true, features = ["serde", "ethabi", "bincode"] }
bincode = { workspace = true, features = ["derive"] }
cosmwasm-std = { workspace = true, features = ["abort"] }
depolama = { workspace = true }
depolama = { workspace = true, features = ["iterator"] }
embed-commit = { workspace = true }
frissitheto = { workspace = true }
ibc-union-light-client = { workspace = true }
ibc-union-msg = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde-utils = { workspace = true }
thiserror = { workspace = true }
unionlabs = { workspace = true, features = ["ethabi"] }

Expand All @@ -33,6 +34,7 @@ ed25519-dalek = { workspace = true, features = ["default"] }
hex = { workspace = true }
hex-literal = { workspace = true }
serde_json = { workspace = true }
unionlabs = { workspace = true, features = ["test-utils"] }

[features]
library = []
25 changes: 22 additions & 3 deletions cosmwasm/ibc-union/lightclient/attested/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ impl IbcClient for AttestedLightClient {
StorageProof {}: Self::StorageProof,
value: Vec<u8>,
) -> Result<(), IbcClientError<Self>> {
let ClientState::V1(client_state) = ctx.read_self_client_state()?;

verify_attestation(
ctx.deps,
client_state.chain_id,
height,
key.into(),
AttestationValue::Existence(value.into()),
Expand All @@ -54,8 +57,16 @@ impl IbcClient for AttestedLightClient {
key: Vec<u8>,
StorageProof {}: Self::StorageProof,
) -> Result<(), IbcClientError<Self>> {
verify_attestation(ctx.deps, height, key.into(), AttestationValue::NonExistence)
.map_err(Into::into)
let ClientState::V1(client_state) = ctx.read_self_client_state()?;

verify_attestation(
ctx.deps,
client_state.chain_id,
height,
key.into(),
AttestationValue::NonExistence,
)
.map_err(Into::into)
}

fn verify_header(
Expand Down Expand Up @@ -115,11 +126,14 @@ pub fn verify_header(

let Header { height, timestamp } = header;

let attested_timestamp = deps.storage.read::<HeightTimestamps>(&height)?;
let attested_timestamp = deps
.storage
.read::<HeightTimestamps>(&(client_state.chain_id.clone(), height))?;

ensure!(
attested_timestamp == timestamp,
Error::InvalidTimestamp {
chain_id: client_state.chain_id,
height,
attested_timestamp,
timestamp
Expand All @@ -138,6 +152,7 @@ pub fn verify_header(

pub fn verify_attestation(
deps: Deps,
chain_id: String,
height: u64,
key: Bytes,
value: AttestationValue,
Expand All @@ -147,10 +162,12 @@ pub fn verify_attestation(
let attested = deps
.storage
.maybe_read::<Attestations>(&AttestationKey {
chain_id: chain_id.clone(),
height,
key: key.clone(),
})?
.ok_or_else(|| Error::AttestationNotFound {
chain_id: chain_id.clone(),
height,
key: key.clone(),
})?;
Expand All @@ -161,6 +178,7 @@ pub fn verify_attestation(
ensure!(
value == attested,
Error::InvalidAttestedValue {
chain_id,
height,
key,
attested: Existence(attested),
Expand All @@ -177,6 +195,7 @@ pub fn verify_attestation(
// invalid
(attested @ Existence(_), value @ NonExistence)
| (attested @ NonExistence, value @ Existence(_)) => Err(Error::InvalidAttestedValue {
chain_id,
height,
key,
attested,
Expand Down
Loading
Loading