Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

##### Rust #####
rustVer=1.70-slim
rustVer=1.88-slim
rustImageName=rust:$(rustVer)
rustImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(rustImageName)

Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ exclude = ["codegen", "no-std-check"]
license = "Apache-2.0"
name = "ics23"
repository = "https://github.com/cosmos/ics23/tree/master/rust"
rust-version = "1.60"
version = "0.12.0"
rust-version = "1.88"
version = "0.12.1"

[workspace]
members = ["codegen", "no-std-check"]
Expand All @@ -19,7 +19,8 @@ blake2 = {version = "0.10.6", optional = true, default-features = false}
blake3 = {version = "1.5.0", optional = true, default-features = false}
bytes = {version = "1.0.1", default-features = false}
hex = {version = "0.4.3", default-features = false, features = ["alloc"]}
prost = {version = "0.13", default-features = false, features = ["prost-derive"]}
prost = {version = "0.14.1", default-features = false, features = ["derive"]}
prost-derive = "0.14.1"
ripemd = {version = "0.1.1", optional = true, default-features = false}
sha2 = {version = "0.10.2", optional = true, default-features = false}
sha3 = {version = "0.10.2", optional = true, default-features = false}
Expand Down
6 changes: 3 additions & 3 deletions rust/codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "codegen"
version = "0.1.0"
version = "0.1.1"
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bytes = "1.0.1"
prost = "0.13"
prost-build = "0.13"
prost = "0.14.1"
prost-build = "0.14.1"
informalsystems-pbjson-build = "0.7.0"
70 changes: 27 additions & 43 deletions rust/src/cosmos.ics23.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
/// With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field
/// in the ProofSpec is valuable to prevent this mutability. And why all trees should
/// length-prefix the data before hashing it.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExistenceProof {
#[prost(bytes = "vec", tag = "1")]
Expand All @@ -35,7 +34,6 @@ pub struct ExistenceProof {
/// NonExistenceProof takes a proof of two neighbors, one left of the desired key,
/// one right of the desired key. If both proofs are valid AND they are neighbors,
/// then there is no valid proof for the given key.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NonExistenceProof {
/// TODO: remove this as unnecessary??? we prove a range
Expand All @@ -48,15 +46,13 @@ pub struct NonExistenceProof {
}
///
/// CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommitmentProof {
#[prost(oneof = "commitment_proof::Proof", tags = "1, 2, 3, 4")]
pub proof: ::core::option::Option<commitment_proof::Proof>,
}
/// Nested message and enum types in `CommitmentProof`.
pub mod commitment_proof {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Proof {
#[prost(message, tag = "1")]
Expand Down Expand Up @@ -84,8 +80,7 @@ pub mod commitment_proof {
///
/// Then combine the bytes, and hash it
/// output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue)
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct LeafOp {
#[prost(enumeration = "HashOp", tag = "1")]
pub hash: i32,
Expand Down Expand Up @@ -116,8 +111,7 @@ pub struct LeafOp {
/// Any special data, like prepending child with the length, or prepending the entire operation with
/// some value to differentiate from leaf nodes, should be included in prefix and suffix.
/// If either of prefix or suffix is empty, we just treat it as an empty string
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct InnerOp {
#[prost(enumeration = "HashOp", tag = "1")]
pub hash: i32,
Expand All @@ -137,8 +131,7 @@ pub struct InnerOp {
/// generate a given hash (by interpretting the preimage differently).
/// We need this for proper security, requires client knows a priori what
/// tree format server uses. But not in code, rather a configuration object.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ProofSpec {
/// any field in the ExistenceProof must be the same as in this spec.
/// except Prefix, which is just the first bytes of prefix (spec can be longer)
Expand Down Expand Up @@ -168,8 +161,7 @@ pub struct ProofSpec {
/// isLeftMost(spec: InnerSpec, op: InnerOp)
/// isRightMost(spec: InnerSpec, op: InnerOp)
/// isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp)
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct InnerSpec {
/// Child order is the ordering of the children node, must count from 0
/// iavl tree is \[0, 1\] (left then right)
Expand All @@ -192,22 +184,19 @@ pub struct InnerSpec {
}
///
/// BatchProof is a group of multiple proof types than can be compressed
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchProof {
#[prost(message, repeated, tag = "1")]
pub entries: ::prost::alloc::vec::Vec<BatchEntry>,
}
/// Use BatchEntry not CommitmentProof, to avoid recursion
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchEntry {
#[prost(oneof = "batch_entry::Proof", tags = "1, 2")]
pub proof: ::core::option::Option<batch_entry::Proof>,
}
/// Nested message and enum types in `BatchEntry`.
pub mod batch_entry {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Proof {
#[prost(message, tag = "1")]
Expand All @@ -216,7 +205,6 @@ pub mod batch_entry {
Nonexist(super::NonExistenceProof),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompressedBatchProof {
#[prost(message, repeated, tag = "1")]
Expand All @@ -225,25 +213,22 @@ pub struct CompressedBatchProof {
pub lookup_inners: ::prost::alloc::vec::Vec<InnerOp>,
}
/// Use BatchEntry not CommitmentProof, to avoid recursion
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CompressedBatchEntry {
#[prost(oneof = "compressed_batch_entry::Proof", tags = "1, 2")]
pub proof: ::core::option::Option<compressed_batch_entry::Proof>,
}
/// Nested message and enum types in `CompressedBatchEntry`.
pub mod compressed_batch_entry {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Proof {
#[prost(message, tag = "1")]
Exist(super::CompressedExistenceProof),
#[prost(message, tag = "2")]
Nonexist(super::CompressedNonExistenceProof),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CompressedExistenceProof {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
Expand All @@ -255,8 +240,7 @@ pub struct CompressedExistenceProof {
#[prost(int32, repeated, tag = "4")]
pub path: ::prost::alloc::vec::Vec<i32>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CompressedNonExistenceProof {
/// TODO: remove this as unnecessary??? we prove a range
#[prost(bytes = "vec", tag = "1")]
Expand Down Expand Up @@ -289,16 +273,16 @@ impl HashOp {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
HashOp::NoHash => "NO_HASH",
HashOp::Sha256 => "SHA256",
HashOp::Sha512 => "SHA512",
HashOp::Keccak256 => "KECCAK256",
HashOp::Ripemd160 => "RIPEMD160",
HashOp::Bitcoin => "BITCOIN",
HashOp::Sha512256 => "SHA512_256",
HashOp::Blake2b512 => "BLAKE2B_512",
HashOp::Blake2s256 => "BLAKE2S_256",
HashOp::Blake3 => "BLAKE3",
Self::NoHash => "NO_HASH",
Self::Sha256 => "SHA256",
Self::Sha512 => "SHA512",
Self::Keccak256 => "KECCAK256",
Self::Ripemd160 => "RIPEMD160",
Self::Bitcoin => "BITCOIN",
Self::Sha512256 => "SHA512_256",
Self::Blake2b512 => "BLAKE2B_512",
Self::Blake2s256 => "BLAKE2S_256",
Self::Blake3 => "BLAKE3",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand Down Expand Up @@ -352,15 +336,15 @@ impl LengthOp {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
LengthOp::NoPrefix => "NO_PREFIX",
LengthOp::VarProto => "VAR_PROTO",
LengthOp::VarRlp => "VAR_RLP",
LengthOp::Fixed32Big => "FIXED32_BIG",
LengthOp::Fixed32Little => "FIXED32_LITTLE",
LengthOp::Fixed64Big => "FIXED64_BIG",
LengthOp::Fixed64Little => "FIXED64_LITTLE",
LengthOp::Require32Bytes => "REQUIRE_32_BYTES",
LengthOp::Require64Bytes => "REQUIRE_64_BYTES",
Self::NoPrefix => "NO_PREFIX",
Self::VarProto => "VAR_PROTO",
Self::VarRlp => "VAR_RLP",
Self::Fixed32Big => "FIXED32_BIG",
Self::Fixed32Little => "FIXED32_LITTLE",
Self::Fixed64Big => "FIXED64_BIG",
Self::Fixed64Little => "FIXED64_LITTLE",
Self::Require32Bytes => "REQUIRE_32_BYTES",
Self::Require64Bytes => "REQUIRE_64_BYTES",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand Down