From 5aa288d8a4cd88fd2d982d4011a663a7c7cce732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 24 Oct 2024 10:16:15 +0200 Subject: [PATCH 01/56] feat: Tonic gRPC --- Cargo.toml | 8 +- cli/Cargo.toml | 6 +- node-wasm/Cargo.toml | 8 +- node/Cargo.toml | 10 +- proto/Cargo.toml | 21 +- proto/build.rs | 127 +++- proto/src/lib.rs | 4 + proto/src/serializers/option_any.rs | 10 +- .../da/data_availability_header.pb.go | 390 ++++++++++ proto/vendor/cosmos/auth/v1beta1/auth.proto | 47 ++ .../vendor/cosmos/auth/v1beta1/genesis.proto | 17 + proto/vendor/cosmos/auth/v1beta1/query.proto | 193 +++++ .../go-header/p2p/pb/header_request.pb.go | 706 ++++++++++++++++++ rpc/Cargo.toml | 9 +- rpc/src/lib.rs | 2 + rpc/src/tonic/mod.rs | 113 +++ rpc/tests/utils/client.rs | 4 +- rpc/tests/utils/mod.rs | 2 + rpc/tests/utils/tonic_client.rs | 45 ++ tools/update-proto-vendor.sh | 33 +- types/Cargo.toml | 8 +- 21 files changed, 1688 insertions(+), 75 deletions(-) create mode 100644 proto/vendor/celestia/da/data_availability_header.pb.go create mode 100644 proto/vendor/cosmos/auth/v1beta1/auth.proto create mode 100644 proto/vendor/cosmos/auth/v1beta1/genesis.proto create mode 100644 proto/vendor/cosmos/auth/v1beta1/query.proto create mode 100644 proto/vendor/go-header/p2p/pb/header_request.pb.go create mode 100644 rpc/src/tonic/mod.rs create mode 100644 rpc/tests/utils/tonic_client.rs diff --git a/Cargo.toml b/Cargo.toml index d76b71a0..800ab564 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,11 +9,15 @@ lumina-node-wasm = { version = "0.5.1", path = "node-wasm" } celestia-proto = { version = "0.4.1", path = "proto" } celestia-rpc = { version = "0.6.0", path = "rpc", default-features = false } celestia-types = { version = "0.6.1", path = "types", default-features = false } -libp2p = "0.54.0" -nmt-rs = "0.2.1" celestia-tendermint = { version = "0.32.2", default-features = false } celestia-tendermint-proto = "0.32.2" +libp2p = "0.54.0" +nmt-rs = "0.2.1" +prost = "0.13.3" +prost-build = "0.13.3" +prost-types = "0.13.3" + [patch.crates-io] # Uncomment to apply local changes #beetswap = { path = "../beetswap" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 7150c03d..139bd387 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -25,9 +25,9 @@ path = "src/main.rs" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] celestia-rpc = { workspace = true, features = ["p2p"] } -celestia-types = { workspace = true } -libp2p = { workspace = true } -lumina-node = { workspace = true } +celestia-types.workspace = true +libp2p.workspace = true +lumina-node.workspace = true anyhow = "1.0.86" axum = "0.7.5" diff --git a/node-wasm/Cargo.toml b/node-wasm/Cargo.toml index 325d20f5..323fc5f6 100644 --- a/node-wasm/Cargo.toml +++ b/node-wasm/Cargo.toml @@ -23,11 +23,11 @@ categories = [ crate-type = ["cdylib", "rlib"] [target.'cfg(target_arch = "wasm32")'.dependencies] -blockstore = { workspace = true } -celestia-tendermint = { workspace = true } -celestia-types = { workspace = true } +blockstore.workspace = true +celestia-tendermint.workspace = true +celestia-types.workspace = true libp2p = { workspace = true, features = ["serde"] } -lumina-node = { workspace = true } +lumina-node.workspace = true anyhow = "1.0.86" console_error_panic_hook = "0.1.7" diff --git a/node/Cargo.toml b/node/Cargo.toml index 9f2f1d3c..6deab38e 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -19,10 +19,10 @@ categories = [ ] [dependencies] -celestia-proto = { workspace = true } -celestia-tendermint = { workspace = true } -celestia-tendermint-proto = { workspace = true } -celestia-types = { workspace = true } +celestia-proto.workspace = true +celestia-tendermint.workspace = true +celestia-tendermint-proto.workspace = true +celestia-types.workspace = true libp2p = { workspace = true, features = [ "autonat", "ping", @@ -32,13 +32,13 @@ libp2p = { workspace = true, features = [ "request-response", "kad", ] } +prost.workspace = true async-trait = "0.1.80" beetswap = "0.4.0" cid = { version = "0.11.1", features = ["serde-codec"] } dashmap = "5.5.3" futures = "0.3.30" -prost = "0.12.6" rand = "0.8.5" serde = { version = "1.0.203", features = ["derive"] } smallvec = { version = "1.13.2", features = [ diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 9ab5ce32..90bd021e 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -14,17 +14,28 @@ keywords = ["blockchain", "celestia", "lumina"] categories = ["encoding", "cryptography::cryptocurrencies"] [dependencies] -celestia-tendermint-proto = { workspace = true } -prost = "0.12.6" -prost-types = "0.12.6" +celestia-tendermint-proto.workspace = true +prost.workspace = true +prost-types.workspace = true serde = { version = "1.0.203", features = ["derive"] } +tonic = "0.12.3" +pbjson = "0.7.0" +pbjson-types = "0.7.0" [build-dependencies] -prost-build = "0.12.6" -protox = "0.6.1" +prost-build.workspace = true +prost-types.workspace = true +protox = "0.7.1" +tempfile = "3.13.0" +tonic-build = "0.12.3" +pbjson-build = "0.7.0" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.42" [dev-dependencies] serde_json = "1.0.117" + +[features] +default = ["tonic"] +tonic = [] diff --git a/proto/build.rs b/proto/build.rs index 9dc979f4..48e7e94b 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -1,5 +1,7 @@ //! A build script generating rust types from protobuf definitions. +use prost_types::FileDescriptorSet; + const SERIALIZED: &str = r#"#[derive(::serde::Deserialize, ::serde::Serialize)]"#; const SERIALIZED_DEFAULT: &str = r#"#[derive(::serde::Deserialize, ::serde::Serialize)] #[serde(default)]"#; @@ -44,7 +46,7 @@ static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ (".shwap.Sample", SERIALIZED_DEFAULT), (".shwap.Share", SERIALIZED_DEFAULT), (".shwap.Share", TRANSPARENT), -]; + ]; #[rustfmt::skip] static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ @@ -63,26 +65,52 @@ static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ (".shwap.Share", BASE64STRING), ]; +#[rustfmt::skip] +static EXTERN_PATHS: &[(&str, &str)] = &[ + (".tendermint", "::celestia_tendermint_proto::v0_34"), + (".google.protobuf.Timestamp", "::celestia_tendermint_proto::google::protobuf::Timestamp"), + (".google.protobuf.Duration", "::celestia_tendermint_proto::google::protobuf::Duration"), +]; + +const PROTO_FILES: &[&str] = &[ + "vendor/celestia/blob/v1/params.proto", + "vendor/celestia/blob/v1/query.proto", + "vendor/celestia/blob/v1/tx.proto", + "vendor/celestia/da/data_availability_header.proto", + "vendor/cosmos/auth/v1beta1/auth.proto", + "vendor/cosmos/auth/v1beta1/query.proto", + "vendor/cosmos/base/abci/v1beta1/abci.proto", + "vendor/cosmos/base/node/v1beta1/query.proto", + "vendor/cosmos/base/tendermint/v1beta1/query.proto", + "vendor/cosmos/base/v1beta1/coin.proto", + "vendor/cosmos/crypto/multisig/v1beta1/multisig.proto", + "vendor/cosmos/crypto/secp256k1/keys.proto", + "vendor/cosmos/staking/v1beta1/query.proto", + "vendor/cosmos/tx/v1beta1/service.proto", + "vendor/cosmos/tx/v1beta1/tx.proto", + "vendor/go-header/p2p/pb/header_request.proto", + "vendor/header/pb/extended_header.proto", + "vendor/share/eds/byzantine/pb/share.proto", + "vendor/share/shwap/p2p/bitswap/pb/bitswap.proto", + "vendor/share/shwap/pb/shwap.proto", + "vendor/tendermint/types/types.proto", +]; + +#[cfg(feature = "tonic")] +const INCLUDES: &[&str] = &["vendor", "vendor/nmt"]; + fn main() { - let fds = protox::compile( - [ - "vendor/celestia/da/data_availability_header.proto", - "vendor/celestia/blob/v1/tx.proto", - "vendor/header/pb/extended_header.proto", - "vendor/share/eds/byzantine/pb/share.proto", - "vendor/share/shwap/pb/shwap.proto", - "vendor/share/shwap/p2p/bitswap/pb/bitswap.proto", - "vendor/cosmos/base/v1beta1/coin.proto", - "vendor/cosmos/base/abci/v1beta1/abci.proto", - "vendor/cosmos/crypto/multisig/v1beta1/multisig.proto", - "vendor/cosmos/staking/v1beta1/query.proto", - "vendor/cosmos/tx/v1beta1/tx.proto", - "vendor/go-header/p2p/pb/header_request.proto", - ], - ["vendor", "vendor/nmt"], - ) - .expect("protox failed to build"); + let fds = protox_compile(); + prost_build(fds); + #[cfg(feature = "tonic")] + tonic_build(protox_compile()) +} + +fn protox_compile() -> FileDescriptorSet { + protox::compile(PROTO_FILES, INCLUDES).expect("protox failed to build") +} +fn prost_build(fds: FileDescriptorSet) { let mut config = prost_build::Config::new(); for (type_path, attr) in CUSTOM_TYPE_ATTRIBUTES { @@ -93,19 +121,62 @@ fn main() { config.field_attribute(field_path, attr); } + for (proto_path, rust_path) in EXTERN_PATHS { + config.extern_path(proto_path.to_string(), rust_path.to_string()); + } + config .include_file("mod.rs") - .extern_path(".tendermint", "::celestia_tendermint_proto::v0_34") - .extern_path( - ".google.protobuf.Timestamp", - "::celestia_tendermint_proto::google::protobuf::Timestamp", - ) - .extern_path( - ".google.protobuf.Duration", - "::celestia_tendermint_proto::google::protobuf::Duration", - ) // Comments in Google's protobuf are causing issues with cargo-test .disable_comments([".google"]) .compile_fds(fds) .expect("prost failed"); } + +#[cfg(feature = "tonic")] +fn tonic_build(fds: FileDescriptorSet) { + let buf_img = tempfile::NamedTempFile::new() + .expect("should be able to create a temp file to hold the buf image file descriptor set"); + + let mut prost_config = prost_build::Config::new(); + prost_config.enable_type_names(); + + let mut tonic_config = tonic_build::configure() + .build_client(true) + .build_server(false) + .use_arc_self(true) + // override prost-types with pbjson-types + .compile_well_known_types(true) + .extern_path(".google.protobuf", "::pbjson_types") + .file_descriptor_set_path(buf_img.path()) + .skip_protoc_run(); + + for (type_path, attr) in CUSTOM_TYPE_ATTRIBUTES { + tonic_config = tonic_config.type_attribute(type_path, attr); + } + for (proto_path, rust_path) in EXTERN_PATHS { + tonic_config = tonic_config.extern_path(proto_path, rust_path); + } + for (field_path, attr) in CUSTOM_FIELD_ATTRIBUTES { + tonic_config = tonic_config.field_attribute(field_path, attr); + } + + tonic_config + .compile_fds_with_config(prost_config, fds) + .expect("should be able to compile protobuf using tonic"); + + let descriptor_set = std::fs::read(buf_img.path()) + .expect("the buf image/descriptor set must exist and be readable at this point"); + + pbjson_build::Builder::new() + .register_descriptors(&descriptor_set) + .unwrap() + .build(&[ + ".celestia_proto", + ".celestia", + ".cosmos", + ".tendermint", + ".google", + ]) + .unwrap(); +} diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 2a5047c6..ae5945d1 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -4,4 +4,8 @@ pub mod serializers; +#[cfg(not(feature = "tonic"))] include!(concat!(env!("OUT_DIR"), "/mod.rs")); + +#[cfg(feature = "tonic")] +::tonic::include_proto!("mod"); diff --git a/proto/src/serializers/option_any.rs b/proto/src/serializers/option_any.rs index 266cde4e..8172e632 100644 --- a/proto/src/serializers/option_any.rs +++ b/proto/src/serializers/option_any.rs @@ -1,6 +1,10 @@ //! [`serde`] serializer for the optional [`Any`]. +#[cfg(feature = "tonic")] +use pbjson_types::Any; +#[cfg(not(feature = "tonic"))] use prost_types::Any; + use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Deserialize `Option`. @@ -17,7 +21,7 @@ where let any = Option::::deserialize(deserializer)?.map(|def| Any { type_url: def.type_url, - value: def.value, + value: def.value.into(), }); Ok(any) @@ -65,7 +69,7 @@ mod tests { let msg = TxResponse { tx: Some(Any { type_url: "abc".to_string(), - value: vec![1, 2, 3], + value: vec![1, 2, 3].into(), }), }; let json = serde_json::to_string(&msg).unwrap(); @@ -85,7 +89,7 @@ mod tests { serde_json::from_str(r#"{"tx":{"type_url":"abc","value":"AQID"}}"#).unwrap(); let tx = msg.tx.unwrap(); assert_eq!(tx.type_url, "abc"); - assert_eq!(tx.value, &[1, 2, 3]) + assert_eq!(tx.value.as_ref(), &[1, 2, 3]) } #[test] diff --git a/proto/vendor/celestia/da/data_availability_header.pb.go b/proto/vendor/celestia/da/data_availability_header.pb.go new file mode 100644 index 00000000..e60760c6 --- /dev/null +++ b/proto/vendor/celestia/da/data_availability_header.pb.go @@ -0,0 +1,390 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: celestia/da/data_availability_header.proto + +package da + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// DataAvailabilityHeader contains the row and column roots of the erasure +// coded version of the data in Block.Data. +// Therefor the original Block.Data is arranged in a +// k × k matrix, which is then "extended" to a +// 2k × 2k matrix applying multiple times Reed-Solomon encoding. +// For details see Section 5.2: https://arxiv.org/abs/1809.09044 +// or the Celestia specification: +// https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/data_structures.md#availabledataheader +// Note that currently we list row and column roots in separate fields +// (different from the spec). +type DataAvailabilityHeader struct { + // RowRoot_j = root((M_{j,1} || M_{j,2} || ... || M_{j,2k} )) + RowRoots [][]byte `protobuf:"bytes,1,rep,name=row_roots,json=rowRoots,proto3" json:"row_roots,omitempty"` + // ColumnRoot_j = root((M_{1,j} || M_{2,j} || ... || M_{2k,j} )) + ColumnRoots [][]byte `protobuf:"bytes,2,rep,name=column_roots,json=columnRoots,proto3" json:"column_roots,omitempty"` +} + +func (m *DataAvailabilityHeader) Reset() { *m = DataAvailabilityHeader{} } +func (m *DataAvailabilityHeader) String() string { return proto.CompactTextString(m) } +func (*DataAvailabilityHeader) ProtoMessage() {} +func (*DataAvailabilityHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_93b487fd8444a5fd, []int{0} +} +func (m *DataAvailabilityHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DataAvailabilityHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DataAvailabilityHeader.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DataAvailabilityHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_DataAvailabilityHeader.Merge(m, src) +} +func (m *DataAvailabilityHeader) XXX_Size() int { + return m.Size() +} +func (m *DataAvailabilityHeader) XXX_DiscardUnknown() { + xxx_messageInfo_DataAvailabilityHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_DataAvailabilityHeader proto.InternalMessageInfo + +func (m *DataAvailabilityHeader) GetRowRoots() [][]byte { + if m != nil { + return m.RowRoots + } + return nil +} + +func (m *DataAvailabilityHeader) GetColumnRoots() [][]byte { + if m != nil { + return m.ColumnRoots + } + return nil +} + +func init() { + proto.RegisterType((*DataAvailabilityHeader)(nil), "celestia.da.DataAvailabilityHeader") +} + +func init() { + proto.RegisterFile("celestia/da/data_availability_header.proto", fileDescriptor_93b487fd8444a5fd) +} + +var fileDescriptor_93b487fd8444a5fd = []byte{ + // 196 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4a, 0x4e, 0xcd, 0x49, + 0x2d, 0x2e, 0xc9, 0x4c, 0xd4, 0x4f, 0x01, 0xa1, 0x92, 0xc4, 0xf8, 0xc4, 0xb2, 0xc4, 0xcc, 0x9c, + 0xc4, 0xa4, 0xcc, 0x9c, 0xcc, 0x92, 0xca, 0xf8, 0x8c, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0xbd, 0x82, + 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x6e, 0x98, 0x5a, 0xbd, 0x94, 0x44, 0xa5, 0x08, 0x2e, 0x31, 0x97, + 0xc4, 0x92, 0x44, 0x47, 0x24, 0xd5, 0x1e, 0x60, 0xc5, 0x42, 0xd2, 0x5c, 0x9c, 0x45, 0xf9, 0xe5, + 0xf1, 0x45, 0xf9, 0xf9, 0x25, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0x3c, 0x41, 0x1c, 0x45, 0xf9, + 0xe5, 0x41, 0x20, 0xbe, 0x90, 0x22, 0x17, 0x4f, 0x72, 0x7e, 0x4e, 0x69, 0x6e, 0x1e, 0x54, 0x9e, + 0x09, 0x2c, 0xcf, 0x0d, 0x11, 0x03, 0x2b, 0x71, 0xf2, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, + 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, + 0x63, 0x39, 0x86, 0x28, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, + 0x98, 0x5b, 0xf2, 0x8b, 0xd2, 0xe1, 0x6c, 0xdd, 0xc4, 0x82, 0x02, 0x7d, 0xb0, 0x5b, 0xf5, 0x91, + 0xbc, 0x95, 0xc4, 0x06, 0x16, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xa3, 0x97, 0x36, + 0xec, 0x00, 0x00, 0x00, +} + +func (m *DataAvailabilityHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DataAvailabilityHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DataAvailabilityHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ColumnRoots) > 0 { + for iNdEx := len(m.ColumnRoots) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ColumnRoots[iNdEx]) + copy(dAtA[i:], m.ColumnRoots[iNdEx]) + i = encodeVarintDataAvailabilityHeader(dAtA, i, uint64(len(m.ColumnRoots[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.RowRoots) > 0 { + for iNdEx := len(m.RowRoots) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.RowRoots[iNdEx]) + copy(dAtA[i:], m.RowRoots[iNdEx]) + i = encodeVarintDataAvailabilityHeader(dAtA, i, uint64(len(m.RowRoots[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintDataAvailabilityHeader(dAtA []byte, offset int, v uint64) int { + offset -= sovDataAvailabilityHeader(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DataAvailabilityHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RowRoots) > 0 { + for _, b := range m.RowRoots { + l = len(b) + n += 1 + l + sovDataAvailabilityHeader(uint64(l)) + } + } + if len(m.ColumnRoots) > 0 { + for _, b := range m.ColumnRoots { + l = len(b) + n += 1 + l + sovDataAvailabilityHeader(uint64(l)) + } + } + return n +} + +func sovDataAvailabilityHeader(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDataAvailabilityHeader(x uint64) (n int) { + return sovDataAvailabilityHeader(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DataAvailabilityHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataAvailabilityHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DataAvailabilityHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DataAvailabilityHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RowRoots", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataAvailabilityHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataAvailabilityHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataAvailabilityHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RowRoots = append(m.RowRoots, make([]byte, postIndex-iNdEx)) + copy(m.RowRoots[len(m.RowRoots)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ColumnRoots", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataAvailabilityHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataAvailabilityHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataAvailabilityHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ColumnRoots = append(m.ColumnRoots, make([]byte, postIndex-iNdEx)) + copy(m.ColumnRoots[len(m.ColumnRoots)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataAvailabilityHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataAvailabilityHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDataAvailabilityHeader(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataAvailabilityHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataAvailabilityHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataAvailabilityHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDataAvailabilityHeader + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDataAvailabilityHeader + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDataAvailabilityHeader + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDataAvailabilityHeader = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDataAvailabilityHeader = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDataAvailabilityHeader = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/vendor/cosmos/auth/v1beta1/auth.proto b/proto/vendor/cosmos/auth/v1beta1/auth.proto new file mode 100644 index 00000000..963c6f15 --- /dev/null +++ b/proto/vendor/cosmos/auth/v1beta1/auth.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package cosmos.auth.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; + +// BaseAccount defines a base account type. It contains all the necessary fields +// for basic account functionality. Any custom account type should extend this +// type for additional functionality (e.g. vesting). +message BaseAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = false; + + option (cosmos_proto.implements_interface) = "AccountI"; + + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty"]; + uint64 account_number = 3; + uint64 sequence = 4; +} + +// ModuleAccount defines an account for modules that holds coins on a pool. +message ModuleAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + option (cosmos_proto.implements_interface) = "ModuleAccountI"; + + BaseAccount base_account = 1 [(gogoproto.embed) = true]; + string name = 2; + repeated string permissions = 3; +} + +// Params defines the parameters for the auth module. +message Params { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + uint64 max_memo_characters = 1; + uint64 tx_sig_limit = 2; + uint64 tx_size_cost_per_byte = 3; + uint64 sig_verify_cost_ed25519 = 4 [(gogoproto.customname) = "SigVerifyCostED25519"]; + uint64 sig_verify_cost_secp256k1 = 5 [(gogoproto.customname) = "SigVerifyCostSecp256k1"]; +} diff --git a/proto/vendor/cosmos/auth/v1beta1/genesis.proto b/proto/vendor/cosmos/auth/v1beta1/genesis.proto new file mode 100644 index 00000000..c88b94ee --- /dev/null +++ b/proto/vendor/cosmos/auth/v1beta1/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package cosmos.auth.v1beta1; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/auth/v1beta1/auth.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; + +// GenesisState defines the auth module's genesis state. +message GenesisState { + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false]; + + // accounts are the accounts present at genesis. + repeated google.protobuf.Any accounts = 2; +} diff --git a/proto/vendor/cosmos/auth/v1beta1/query.proto b/proto/vendor/cosmos/auth/v1beta1/query.proto new file mode 100644 index 00000000..1775f128 --- /dev/null +++ b/proto/vendor/cosmos/auth/v1beta1/query.proto @@ -0,0 +1,193 @@ +syntax = "proto3"; +package cosmos.auth.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "cosmos/auth/v1beta1/auth.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; + +// Query defines the gRPC querier service. +service Query { + // Accounts returns all the existing accounts + // + // Since: cosmos-sdk 0.43 + rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/accounts"; + } + + // Account returns account details based on address. + rpc Account(QueryAccountRequest) returns (QueryAccountResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/accounts/{address}"; + } + + // AccountAddressByID returns account address based on account number. + // + // Since: cosmos-sdk 0.46.2 + rpc AccountAddressByID(QueryAccountAddressByIDRequest) returns (QueryAccountAddressByIDResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/address_by_id/{id}"; + } + + // Params queries all parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/params"; + } + + // ModuleAccounts returns all the existing module accounts. + // + // Since: cosmos-sdk 0.46 + rpc ModuleAccounts(QueryModuleAccountsRequest) returns (QueryModuleAccountsResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/module_accounts"; + } + + // ModuleAccountByName returns the module account info by module name + rpc ModuleAccountByName(QueryModuleAccountByNameRequest) returns (QueryModuleAccountByNameResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/module_accounts/{name}"; + } + + // Bech32Prefix queries bech32Prefix + // + // Since: cosmos-sdk 0.46 + rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/bech32"; + } + + // AddressBytesToString converts Account Address bytes to string + // + // Since: cosmos-sdk 0.46 + rpc AddressBytesToString(AddressBytesToStringRequest) returns (AddressBytesToStringResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/bech32/{address_bytes}"; + } + + // AddressStringToBytes converts Address string to bytes + // + // Since: cosmos-sdk 0.46 + rpc AddressStringToBytes(AddressStringToBytesRequest) returns (AddressStringToBytesResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/bech32/{address_string}"; + } +} + +// QueryAccountsRequest is the request type for the Query/Accounts RPC method. +// +// Since: cosmos-sdk 0.43 +message QueryAccountsRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAccountsResponse is the response type for the Query/Accounts RPC method. +// +// Since: cosmos-sdk 0.43 +message QueryAccountsResponse { + // accounts are the existing accounts + repeated google.protobuf.Any accounts = 1 [(cosmos_proto.accepts_interface) = "AccountI"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryAccountRequest is the request type for the Query/Account RPC method. +message QueryAccountRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address defines the address to query for. + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// QueryAccountResponse is the response type for the Query/Account RPC method. +message QueryAccountResponse { + // account defines the account of the corresponding address. + google.protobuf.Any account = 1 [(cosmos_proto.accepts_interface) = "AccountI"]; +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 +message QueryModuleAccountsRequest {} + +// QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 +message QueryModuleAccountsResponse { + repeated google.protobuf.Any accounts = 1 [(cosmos_proto.accepts_interface) = "ModuleAccountI"]; +} + +// QueryModuleAccountByNameRequest is the request type for the Query/ModuleAccountByName RPC method. +message QueryModuleAccountByNameRequest { + string name = 1; +} + +// QueryModuleAccountByNameResponse is the response type for the Query/ModuleAccountByName RPC method. +message QueryModuleAccountByNameResponse { + google.protobuf.Any account = 1 [(cosmos_proto.accepts_interface) = "ModuleAccountI"]; +} + +// Bech32PrefixRequest is the request type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 +message Bech32PrefixRequest {} + +// Bech32PrefixResponse is the response type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 +message Bech32PrefixResponse { + string bech32_prefix = 1; +} + +// AddressBytesToStringRequest is the request type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 +message AddressBytesToStringRequest { + bytes address_bytes = 1; +} + +// AddressBytesToStringResponse is the response type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 +message AddressBytesToStringResponse { + string address_string = 1; +} + +// AddressStringToBytesRequest is the request type for AccountBytes rpc method. +// +// Since: cosmos-sdk 0.46 +message AddressStringToBytesRequest { + string address_string = 1; +} + +// AddressStringToBytesResponse is the response type for AddressBytes rpc method. +// +// Since: cosmos-sdk 0.46 +message AddressStringToBytesResponse { + bytes address_bytes = 1; +} + +// QueryAccountAddressByIDRequest is the request type for AccountAddressByID rpc method +// +// Since: cosmos-sdk 0.46.2 +message QueryAccountAddressByIDRequest { + // id is the account number of the address to be queried. This field + // should have been an uint64 (like all account numbers), and will be + // updated to uint64 in a future version of the auth query. + int64 id = 1; +} + +// QueryAccountAddressByIDResponse is the response type for AccountAddressByID rpc method +// +// Since: cosmos-sdk 0.46.2 +message QueryAccountAddressByIDResponse { + string account_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} diff --git a/proto/vendor/go-header/p2p/pb/header_request.pb.go b/proto/vendor/go-header/p2p/pb/header_request.pb.go new file mode 100644 index 00000000..e0b7e4f0 --- /dev/null +++ b/proto/vendor/go-header/p2p/pb/header_request.pb.go @@ -0,0 +1,706 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: libs/header/p2p/pb/header_request.proto + +package p2p_pb + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type StatusCode int32 + +const ( + StatusCode_INVALID StatusCode = 0 + StatusCode_OK StatusCode = 1 + StatusCode_NOT_FOUND StatusCode = 2 +) + +var StatusCode_name = map[int32]string{ + 0: "INVALID", + 1: "OK", + 2: "NOT_FOUND", +} + +var StatusCode_value = map[string]int32{ + "INVALID": 0, + "OK": 1, + "NOT_FOUND": 2, +} + +func (x StatusCode) String() string { + return proto.EnumName(StatusCode_name, int32(x)) +} + +func (StatusCode) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_43554822dc0b0806, []int{0} +} + +type HeaderRequest struct { + // Types that are valid to be assigned to Data: + // *HeaderRequest_Origin + // *HeaderRequest_Hash + Data isHeaderRequest_Data `protobuf_oneof:"data"` + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *HeaderRequest) Reset() { *m = HeaderRequest{} } +func (m *HeaderRequest) String() string { return proto.CompactTextString(m) } +func (*HeaderRequest) ProtoMessage() {} +func (*HeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_43554822dc0b0806, []int{0} +} +func (m *HeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HeaderRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeaderRequest.Merge(m, src) +} +func (m *HeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *HeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HeaderRequest proto.InternalMessageInfo + +type isHeaderRequest_Data interface { + isHeaderRequest_Data() + MarshalTo([]byte) (int, error) + Size() int +} + +type HeaderRequest_Origin struct { + Origin uint64 `protobuf:"varint,1,opt,name=origin,proto3,oneof" json:"origin,omitempty"` +} +type HeaderRequest_Hash struct { + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3,oneof" json:"hash,omitempty"` +} + +func (*HeaderRequest_Origin) isHeaderRequest_Data() {} +func (*HeaderRequest_Hash) isHeaderRequest_Data() {} + +func (m *HeaderRequest) GetData() isHeaderRequest_Data { + if m != nil { + return m.Data + } + return nil +} + +func (m *HeaderRequest) GetOrigin() uint64 { + if x, ok := m.GetData().(*HeaderRequest_Origin); ok { + return x.Origin + } + return 0 +} + +func (m *HeaderRequest) GetHash() []byte { + if x, ok := m.GetData().(*HeaderRequest_Hash); ok { + return x.Hash + } + return nil +} + +func (m *HeaderRequest) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*HeaderRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*HeaderRequest_Origin)(nil), + (*HeaderRequest_Hash)(nil), + } +} + +type HeaderResponse struct { + Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` + StatusCode StatusCode `protobuf:"varint,2,opt,name=statusCode,proto3,enum=p2p.pb.StatusCode" json:"statusCode,omitempty"` +} + +func (m *HeaderResponse) Reset() { *m = HeaderResponse{} } +func (m *HeaderResponse) String() string { return proto.CompactTextString(m) } +func (*HeaderResponse) ProtoMessage() {} +func (*HeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43554822dc0b0806, []int{1} +} +func (m *HeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HeaderResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeaderResponse.Merge(m, src) +} +func (m *HeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *HeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HeaderResponse proto.InternalMessageInfo + +func (m *HeaderResponse) GetBody() []byte { + if m != nil { + return m.Body + } + return nil +} + +func (m *HeaderResponse) GetStatusCode() StatusCode { + if m != nil { + return m.StatusCode + } + return StatusCode_INVALID +} + +func init() { + proto.RegisterEnum("p2p.pb.StatusCode", StatusCode_name, StatusCode_value) + proto.RegisterType((*HeaderRequest)(nil), "p2p.pb.HeaderRequest") + proto.RegisterType((*HeaderResponse)(nil), "p2p.pb.HeaderResponse") +} + +func init() { + proto.RegisterFile("libs/header/p2p/pb/header_request.proto", fileDescriptor_43554822dc0b0806) +} + +var fileDescriptor_43554822dc0b0806 = []byte{ + // 271 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcd, 0x4a, 0xf3, 0x40, + 0x14, 0x86, 0x67, 0xfa, 0x85, 0xf9, 0xf0, 0xd8, 0x96, 0x32, 0x88, 0x64, 0x35, 0x94, 0x6e, 0x2c, + 0x2e, 0x12, 0x89, 0x57, 0x60, 0x2d, 0x92, 0xa2, 0x24, 0x30, 0xfe, 0xe0, 0x2e, 0x4c, 0xc8, 0x60, + 0x02, 0x9a, 0x19, 0x33, 0x93, 0x85, 0x77, 0xe1, 0x65, 0xb9, 0xec, 0xd2, 0xa5, 0x24, 0x37, 0x22, + 0x4e, 0xe3, 0xcf, 0xee, 0x3c, 0x3c, 0x2f, 0xe7, 0x3d, 0x1c, 0x38, 0x7a, 0xac, 0x72, 0x13, 0x96, + 0x52, 0x14, 0xb2, 0x09, 0x75, 0xa4, 0x43, 0x9d, 0x0f, 0x94, 0x35, 0xf2, 0xb9, 0x95, 0xc6, 0x06, + 0xba, 0x51, 0x56, 0x51, 0xa2, 0x23, 0x1d, 0xe8, 0x7c, 0x91, 0xc1, 0x24, 0x76, 0x9e, 0xef, 0x34, + 0xf5, 0x81, 0xa8, 0xa6, 0x7a, 0xa8, 0x6a, 0x1f, 0xcf, 0xf1, 0xd2, 0x8b, 0x11, 0x1f, 0x98, 0x1e, + 0x80, 0x57, 0x0a, 0x53, 0xfa, 0xa3, 0x39, 0x5e, 0x8e, 0x63, 0xc4, 0x1d, 0xd1, 0x43, 0x20, 0xe2, + 0x49, 0xb5, 0xb5, 0xf5, 0xff, 0x7d, 0xe5, 0xf9, 0x40, 0x2b, 0x02, 0x5e, 0x21, 0xac, 0x58, 0xdc, + 0xc3, 0xf4, 0xbb, 0xc0, 0x68, 0x55, 0x1b, 0x49, 0x29, 0x78, 0xb9, 0x2a, 0x5e, 0xdc, 0xfe, 0x31, + 0x77, 0x33, 0x8d, 0x00, 0x8c, 0x15, 0xb6, 0x35, 0xe7, 0xaa, 0x90, 0xae, 0x61, 0x1a, 0xd1, 0x60, + 0x77, 0x63, 0x70, 0xfd, 0x63, 0xf8, 0x9f, 0xd4, 0xf1, 0x09, 0xc0, 0xaf, 0xa1, 0xfb, 0xf0, 0x7f, + 0x93, 0xdc, 0x9d, 0x5d, 0x6d, 0xd6, 0x33, 0x44, 0x09, 0x8c, 0xd2, 0xcb, 0x19, 0xa6, 0x13, 0xd8, + 0x4b, 0xd2, 0x9b, 0xec, 0x22, 0xbd, 0x4d, 0xd6, 0xb3, 0xd1, 0xca, 0x7f, 0xeb, 0x18, 0xde, 0x76, + 0x0c, 0x7f, 0x74, 0x0c, 0xbf, 0xf6, 0x0c, 0x6d, 0x7b, 0x86, 0xde, 0x7b, 0x86, 0x72, 0xe2, 0xbe, + 0x72, 0xfa, 0x19, 0x00, 0x00, 0xff, 0xff, 0x04, 0xdd, 0x70, 0x54, 0x40, 0x01, 0x00, 0x00, +} + +func (m *HeaderRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != 0 { + i = encodeVarintHeaderRequest(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if m.Data != nil { + { + size := m.Data.Size() + i -= size + if _, err := m.Data.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *HeaderRequest_Origin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeaderRequest_Origin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintHeaderRequest(dAtA, i, uint64(m.Origin)) + i-- + dAtA[i] = 0x8 + return len(dAtA) - i, nil +} +func (m *HeaderRequest_Hash) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeaderRequest_Hash) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Hash != nil { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintHeaderRequest(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *HeaderResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StatusCode != 0 { + i = encodeVarintHeaderRequest(dAtA, i, uint64(m.StatusCode)) + i-- + dAtA[i] = 0x10 + } + if len(m.Body) > 0 { + i -= len(m.Body) + copy(dAtA[i:], m.Body) + i = encodeVarintHeaderRequest(dAtA, i, uint64(len(m.Body))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintHeaderRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovHeaderRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *HeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Data != nil { + n += m.Data.Size() + } + if m.Amount != 0 { + n += 1 + sovHeaderRequest(uint64(m.Amount)) + } + return n +} + +func (m *HeaderRequest_Origin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovHeaderRequest(uint64(m.Origin)) + return n +} +func (m *HeaderRequest_Hash) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Hash != nil { + l = len(m.Hash) + n += 1 + l + sovHeaderRequest(uint64(l)) + } + return n +} +func (m *HeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Body) + if l > 0 { + n += 1 + l + sovHeaderRequest(uint64(l)) + } + if m.StatusCode != 0 { + n += 1 + sovHeaderRequest(uint64(m.StatusCode)) + } + return n +} + +func sovHeaderRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozHeaderRequest(x uint64) (n int) { + return sovHeaderRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *HeaderRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Data = &HeaderRequest_Origin{v} + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthHeaderRequest + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthHeaderRequest + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.Data = &HeaderRequest_Hash{v} + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipHeaderRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthHeaderRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HeaderResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthHeaderRequest + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthHeaderRequest + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Body = append(m.Body[:0], dAtA[iNdEx:postIndex]...) + if m.Body == nil { + m.Body = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusCode", wireType) + } + m.StatusCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StatusCode |= StatusCode(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipHeaderRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthHeaderRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipHeaderRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeaderRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthHeaderRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupHeaderRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthHeaderRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthHeaderRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowHeaderRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupHeaderRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 00809276..921fcd6e 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -19,11 +19,14 @@ categories = [ ] [dependencies] +celestia-tendermint-proto.workspace = true +celestia-types.workspace = true +celestia-proto = { optional = true, workspace = true } async-trait = "0.1.80" -celestia-types = { workspace = true } jsonrpsee = { version = "0.24.2", features = ["client-core", "macros"] } serde = { version = "1.0.203", features = ["derive"] } thiserror = "1.0.61" +tonic = { version = "0.12.3", optional = true } tracing = "0.1.40" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -38,11 +41,12 @@ libp2p = { workspace = true, features = [ "noise", "yamux", ] } +nmt-rs.workspace = true anyhow = "1.0.86" dotenvy = "0.15.7" futures = "0.3.30" -nmt-rs = { workspace = true } rand = "0.8.5" +tonic = "0.12.3" tokio = { version = "1.38.0", features = ["rt", "macros"] } tracing = "0.1.40" @@ -52,6 +56,7 @@ wasm-bindgen-test = "0.3.42" [features] default = ["p2p"] +tonic_grpc = ["celestia-proto/tonic", "dep:tonic"] p2p = ["celestia-types/p2p"] wasm-bindgen = ["celestia-types/wasm-bindgen", "jsonrpsee/wasm-client"] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index bf02329a..fd211988 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -9,6 +9,8 @@ mod header; mod p2p; pub mod share; mod state; +#[cfg(feature = "tonic_grpc")] +pub mod tonic; pub use crate::blob::BlobClient; #[cfg(any( diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs new file mode 100644 index 00000000..50cd3465 --- /dev/null +++ b/rpc/src/tonic/mod.rs @@ -0,0 +1,113 @@ +use celestia_proto::cosmos::base::node::v1beta1::{ + service_client::ServiceClient as ConfigServiceClient, ConfigRequest, +}; +use tonic::service::Interceptor; +use tonic::transport::Channel; +use tonic::Status; + +/* +use celestia_proto::celestia::blob::v1::query_client::QueryClient; +use celestia_tendermint_proto::v0_34::types::{ + Blob as PbBlob, + BlobTx, +}; + +use celestia_proto::{ + celestia::blob::v1::{ + query_client::QueryClient as BlobQueryClient, + MsgPayForBlobs, + QueryParamsRequest as QueryBlobParamsRequest, + Params as BlobParams, + }, + cosmos::{ + auth::v1beta1::{ + query_client::QueryClient as AuthQueryClient, + BaseAccount, + Params as AuthParams, + QueryAccountRequest, + QueryAccountResponse, + QueryParamsRequest as QueryAuthParamsRequest, + }, + base::{ + node::v1beta1::{ + service_client::ServiceClient as MinGasPriceClient, + ConfigRequest as MinGasPriceRequest, + ConfigResponse as MinGasPriceResponse, + }, + tendermint::v1beta1::{ + service_client::ServiceClient as TendermintServiceClient, + GetNodeInfoRequest, + }, + v1beta1::Coin, + }, + crypto::secp256k1, + tx::v1beta1::{ + mode_info::{ + Single, + Sum, + }, + service_client::ServiceClient as TxClient, + AuthInfo, + BroadcastMode, + BroadcastTxRequest, + BroadcastTxResponse, + Fee, + GetTxRequest, + GetTxResponse, + ModeInfo, + SignDoc, + SignerInfo, + Tx, + TxBody, + }, + }, +}; +*/ + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + TonicError(#[from] Status), + + #[error("Failed to parse response")] + FailedToParseResponse, +} + +pub struct GrpcClient +where + I: Interceptor, +{ + grpc_channel: Channel, + auth_interceptor: I, +} + +impl GrpcClient +where + I: Interceptor + Clone, +{ + pub fn new(grpc_channel: Channel, auth_interceptor: I) -> Self { + Self { + grpc_channel, + auth_interceptor, + } + } + pub async fn get_min_gas_price(&self) -> Result { + const UNITS_SUFFIX: &str = "utia"; + + let mut min_gas_price_client = ConfigServiceClient::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = min_gas_price_client.config(ConfigRequest {}).await; + + let min_gas_price_with_suffix = response?.into_inner().minimum_gas_price; + let min_gas_price_str = min_gas_price_with_suffix + .strip_suffix(UNITS_SUFFIX) + .ok_or(Error::FailedToParseResponse)?; + let min_gas_price = min_gas_price_str + .parse::() + .map_err(|_| Error::FailedToParseResponse)?; + + Ok(min_gas_price) + } +} diff --git a/rpc/tests/utils/client.rs b/rpc/tests/utils/client.rs index 55beb7de..80101034 100644 --- a/rpc/tests/utils/client.rs +++ b/rpc/tests/utils/client.rs @@ -25,7 +25,7 @@ pub enum AuthLevel { Admin, } -fn token_from_env(auth_level: AuthLevel) -> Result> { +pub fn token_from_env(auth_level: AuthLevel) -> Result> { match auth_level { AuthLevel::Public => Ok(None), AuthLevel::Read => Ok(Some(env::var("CELESTIA_NODE_AUTH_TOKEN_READ")?)), @@ -34,7 +34,7 @@ fn token_from_env(auth_level: AuthLevel) -> Result> { } } -fn env_or(var_name: &str, or_value: &str) -> String { +pub fn env_or(var_name: &str, or_value: &str) -> String { env::var(var_name).unwrap_or_else(|_| or_value.to_owned()) } diff --git a/rpc/tests/utils/mod.rs b/rpc/tests/utils/mod.rs index 8755e6ed..3c3b1c8e 100644 --- a/rpc/tests/utils/mod.rs +++ b/rpc/tests/utils/mod.rs @@ -6,6 +6,8 @@ use rand::{Rng, RngCore}; pub mod client; #[cfg(feature = "p2p")] pub mod tiny_node; +#[cfg(feature = "tonic_grpc")] +pub mod tonic_client; fn ns_to_u128(ns: Namespace) -> u128 { let mut bytes = [0u8; 16]; diff --git a/rpc/tests/utils/tonic_client.rs b/rpc/tests/utils/tonic_client.rs new file mode 100644 index 00000000..09f05ac9 --- /dev/null +++ b/rpc/tests/utils/tonic_client.rs @@ -0,0 +1,45 @@ +use crate::utils::client::{env_or, token_from_env}; +use crate::AuthLevel; + +use anyhow::Result; +use tonic::metadata::{Ascii, MetadataValue}; +use tonic::service::Interceptor; +use tonic::transport::Channel; +use tonic::{Request, Status}; + +use celestia_rpc::tonic::GrpcClient; + +const CELESTIA_GRPC_URL: &str = "http://localhost:9090"; + +#[derive(Clone)] +pub struct TestAuthInterceptor { + token: Option>, +} + +impl Interceptor for TestAuthInterceptor { + fn call(&mut self, mut request: Request<()>) -> Result, Status> { + if let Some(token) = &self.token { + request + .metadata_mut() + .insert("authorization", token.clone()); + } + Ok(request) + } +} + +impl TestAuthInterceptor { + pub fn new(bearer_token: Option) -> Result { + let token = bearer_token.map(|token| token.parse()).transpose()?; + Ok(Self { token }) + } +} + +pub async fn new_test_client(auth_level: AuthLevel) -> Result> { + let _ = dotenvy::dotenv(); + let url = env_or("CELESTIA_GRPC_URL", CELESTIA_GRPC_URL); + let grpc_channel = Channel::from_shared(url)?.connect().await?; + + let token = token_from_env(auth_level)?; + let auth_interceptor = TestAuthInterceptor::new(token)?; + Ok(GrpcClient::new(grpc_channel, auth_interceptor)) +} diff --git a/tools/update-proto-vendor.sh b/tools/update-proto-vendor.sh index 3a374e66..2626c054 100755 --- a/tools/update-proto-vendor.sh +++ b/tools/update-proto-vendor.sh @@ -25,7 +25,6 @@ mkdir -p ../target/proto-vendor-src extract_urls ../target/proto-vendor-src \ https://github.com/celestiaorg/celestia-app/archive/refs/tags/v1.12.0.tar.gz \ https://github.com/celestiaorg/celestia-core/archive/refs/heads/v0.34.x-celestia.tar.gz \ - https://github.com/celestiaorg/celestia-node/archive/refs/heads/shwap.tar.gz \ https://github.com/celestiaorg/cosmos-sdk/archive/refs/heads/release/v0.46.x-celestia.tar.gz \ https://github.com/celestiaorg/nmt/archive/refs/heads/main.tar.gz \ https://github.com/cosmos/cosmos-proto/archive/refs/tags/v1.0.0-alpha7.tar.gz \ @@ -44,7 +43,7 @@ cp -r ../target/proto-vendor-src/go-header-main/p2p/pb vendor/go-header/p2p rm -rf vendor/cosmos mkdir -p vendor/cosmos -cp -r ../target/proto-vendor-src/cosmos-sdk-release-v0.46.x-celestia/proto/cosmos/{base,staking,crypto,tx} vendor/cosmos +cp -r ../target/proto-vendor-src/cosmos-sdk-release-v0.46.x-celestia/proto/cosmos/{auth,base,staking,crypto,tx} vendor/cosmos rm -rf vendor/cosmos_proto cp -r ../target/proto-vendor-src/cosmos-proto-1.0.0-alpha7/proto/cosmos_proto vendor @@ -57,21 +56,21 @@ rm -rf vendor/google mkdir -p vendor/google/api cp ../target/proto-vendor-src/googleapis-master/google/api/{annotations.proto,http.proto} vendor/google/api -rm -rf vendor/header -mkdir -p vendor/header -cp -r ../target/proto-vendor-src/celestia-node-shwap/header/pb vendor/header - -rm -rf vendor/share -mkdir -p vendor/share -shwap_dir=../target/proto-vendor-src/celestia-node-shwap/share -find "$shwap_dir" -name pb -type d -print0 | while read -r -d '' pb_dir; do - # remove prefix - out_dir="${pb_dir#"$shwap_dir"}" - # remove /pb suffix - out_dir="vendor/share/${out_dir%/*}" - mkdir -p "$out_dir" - cp -r "$pb_dir" "$out_dir" -done +#rm -rf vendor/header +#mkdir -p vendor/header +#cp -r ../target/proto-vendor-src/celestia-node-shwap/header/pb vendor/header +# +#rm -rf vendor/share +#mkdir -p vendor/share +#shwap_dir=../target/proto-vendor-src/celestia-node-shwap/share +#find "$shwap_dir" -name pb -type d -print0 | while read -r -d '' pb_dir; do +# # remove prefix +# out_dir="${pb_dir#"$shwap_dir"}" +# # remove /pb suffix +# out_dir="vendor/share/${out_dir%/*}" +# mkdir -p "$out_dir" +# cp -r "$pb_dir" "$out_dir" +#done rm -rf vendor/tendermint cp -r ../target/proto-vendor-src/celestia-core-0.34.x-celestia/proto/tendermint vendor diff --git a/types/Cargo.toml b/types/Cargo.toml index 2a148cbd..8fdec0f9 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -14,11 +14,11 @@ keywords = ["blockchain", "celestia", "lumina"] categories = ["encoding", "cryptography::cryptocurrencies"] [dependencies] -blockstore = { workspace = true } -celestia-proto = { workspace = true } +blockstore.workspace = true +celestia-proto.workspace = true celestia-tendermint = { workspace = true, features = ["std", "rust-crypto"] } -celestia-tendermint-proto = { workspace = true } -nmt-rs = { workspace = true } +celestia-tendermint-proto.workspace = true +nmt-rs.workspace = true base64 = "0.22.1" bech32 = "0.11.0" From 79823d234a8b8e3687126a6d9a7c80f95791b491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 25 Oct 2024 08:38:25 +0200 Subject: [PATCH 02/56] wip --- Cargo.lock | 1510 ++++++++++++++++++++++++++-------------------------- 1 file changed, 756 insertions(+), 754 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af4e05c5..0f239511 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,21 +1,21 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aead" @@ -52,18 +52,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -81,9 +69,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-rlp" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" +checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ "arrayvec", "bytes", @@ -91,9 +79,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -106,33 +94,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -140,9 +128,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-ff" @@ -178,7 +166,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -270,21 +258,21 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "asn1-rs" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -298,13 +286,13 @@ dependencies = [ [[package]] name = "asn1-rs-derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", "synstructure", ] @@ -316,14 +304,14 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "async-io" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" +checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" dependencies = [ "async-lock", "cfg-if", @@ -335,7 +323,7 @@ dependencies = [ "rustix", "slab", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -349,15 +337,37 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -398,29 +408,29 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" dependencies = [ "async-trait", "axum-core", "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", - "hyper 1.3.1", + "hyper 1.5.0", "hyper-util", "itoa", "matchit", @@ -435,7 +445,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -443,20 +453,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -478,17 +488,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -497,6 +507,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" @@ -557,9 +573,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -606,9 +622,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.1" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -642,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7679095248a6dc7555fae81154ed1baef264383c16621ef881a219576c72a9be" dependencies = [ "cid", - "dashmap 6.0.1", + "dashmap 6.1.0", "js-sys", "multihash", "redb", @@ -669,10 +685,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" dependencies = [ "once_cell", - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", "syn_derive", ] @@ -705,30 +721,39 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] [[package]] name = "cc" -version = "1.0.99" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +dependencies = [ + "shlex", +] [[package]] name = "celestia-proto" version = "0.4.1" dependencies = [ "celestia-tendermint-proto", - "prost", + "pbjson", + "pbjson-build", + "pbjson-types", + "prost 0.13.3", "prost-build", - "prost-types", + "prost-types 0.13.3", "protox", "serde", "serde_json", + "tempfile", + "tonic", + "tonic-build", "wasm-bindgen-test", ] @@ -738,6 +763,8 @@ version = "0.6.0" dependencies = [ "anyhow", "async-trait", + "celestia-proto", + "celestia-tendermint-proto", "celestia-types", "dotenvy", "futures", @@ -750,6 +777,7 @@ dependencies = [ "serde", "thiserror", "tokio", + "tonic", "tracing", "wasm-bindgen-test", ] @@ -770,8 +798,8 @@ dependencies = [ "instant", "num-traits", "once_cell", - "prost", - "prost-types", + "prost 0.12.6", + "prost-types 0.12.6", "serde", "serde_bytes", "serde_json", @@ -794,8 +822,8 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost", - "prost-types", + "prost 0.12.6", + "prost-types 0.12.6", "serde", "serde_bytes", "subtle-encoding", @@ -806,7 +834,7 @@ dependencies = [ name = "celestia-types" version = "0.6.1" dependencies = [ - "base64", + "base64 0.22.1", "bech32", "blockstore", "bytes", @@ -877,6 +905,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "num-traits", +] + [[package]] name = "cid" version = "0.11.1" @@ -904,9 +941,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -914,9 +951,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -926,27 +963,27 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "combine" @@ -985,18 +1022,18 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const_format" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" dependencies = [ "proc-macro2", "quote", @@ -1005,9 +1042,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core-foundation" @@ -1021,9 +1058,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core2" @@ -1036,9 +1073,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1095,7 +1132,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "subtle", "zeroize", ] @@ -1108,7 +1145,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1131,7 +1168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -1139,13 +1176,13 @@ dependencies = [ [[package]] name = "dashmap" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", "crossbeam-utils", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -1273,13 +1310,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1342,14 +1379,14 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enum-as-inner" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1361,7 +1398,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1413,9 +1450,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fastrlp" @@ -1468,6 +1505,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1500,9 +1543,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1525,9 +1568,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1535,15 +1578,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1553,9 +1596,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" @@ -1569,13 +1612,13 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1591,15 +1634,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-ticker" @@ -1624,9 +1667,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1675,9 +1718,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -1755,7 +1798,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -1764,9 +1807,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -1774,28 +1817,35 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", "tracing", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] [[package]] -name = "heck" -version = "0.4.1" +name = "hashbrown" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] name = "heck" @@ -1809,6 +1859,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -1931,9 +1987,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http 1.1.0", @@ -1948,15 +2004,15 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.9.3" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -1966,9 +2022,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -1990,16 +2046,16 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "httparse", "httpdate", "itoa", @@ -2011,13 +2067,13 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.3.1", + "hyper 1.5.0", "hyper-util", "log", "rustls", @@ -2027,149 +2083,43 @@ dependencies = [ "tower-service", ] +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.5.0", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", - "hyper 1.3.1", + "http-body 1.0.1", + "hyper 1.5.0", "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" - -[[package]] -name = "icu_properties" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "idb" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2764bba4203538c2ef2d733d5bad8fdb4622b1ebc5560831279db7b3be1332e8" +checksum = "3afe8830d5802f769dc0be20a87f9f116798c896650cb6266eb5c19a3c109eed" dependencies = [ "js-sys", "num-traits", @@ -2191,14 +2141,12 @@ dependencies = [ [[package]] name = "idna" -version = "1.0.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", - "smallvec", - "utf8_iter", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -2241,7 +2189,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.31", "log", "rand", "tokio", @@ -2277,12 +2225,22 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.6" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -2326,15 +2284,15 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -2347,9 +2305,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -2382,18 +2340,18 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1d83ae9ed70d8e3440db663e343a82f93913104744cd543bbcdd1dbc0e35d3" +checksum = "c5c71d8c1a731cc4227c2f698d377e7848ca12c8a48866fc5e6951c43a4db843" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", @@ -2406,11 +2364,11 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be764c8b96cdcd2974655560a1c6542a366440d47c88114894cc20c24317815" +checksum = "548125b159ba1314104f5bb5f38519e03a41862786aa3925cf349aae9cdd546e" dependencies = [ - "base64", + "base64 0.22.1", "futures-channel", "futures-util", "gloo-net", @@ -2431,20 +2389,20 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b772fb8aa2b511eeed75f7e19d8e5fa57be7e8202249470bf26210727399c7" +checksum = "f2882f6f8acb9fdaec7cefc4fd607119a9bd709831df7d7672a1d3b644628280" dependencies = [ "async-trait", "bytes", "futures-timer", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "jsonrpsee-types", "pin-project", - "rustc-hash 2.0.0", + "rustc-hash", "serde", "serde_json", "thiserror", @@ -2456,14 +2414,14 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5f8f6ddb09312a9592ec9e21a3ccd6f61e51730d9d56321351eff971b0fe55" +checksum = "b3638bc4617f96675973253b3a45006933bde93c2fd8a6170b33c777cc389e5b" dependencies = [ "async-trait", - "base64", - "http-body 1.0.0", - "hyper 1.3.1", + "base64 0.22.1", + "http-body 1.0.1", + "hyper 1.5.0", "hyper-rustls", "hyper-util", "jsonrpsee-core", @@ -2474,29 +2432,29 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower", + "tower 0.4.13", "tracing", "url", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "295d9b81496d1bef5bd34066d83c984388b6acb97620f468817bf46f67a1e9ab" +checksum = "c06c01ae0007548e73412c08e2285ffe5d723195bf268bce67b1b77c3bb2a14d" dependencies = [ - "heck 0.5.0", - "proc-macro-crate 3.1.0", + "heck", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "jsonrpsee-types" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98deeee954567f75632fa40666ac93a66d4f9f4ed4ca15bd6b7ed0720b53e761" +checksum = "a178c60086f24cc35bb82f57c651d0d25d99c4742b4d335de04e97fa1f08a8a1" dependencies = [ "http 1.1.0", "serde", @@ -2506,9 +2464,9 @@ dependencies = [ [[package]] name = "jsonrpsee-wasm-client" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8a01468705cf6d326b8ba9c035e71abf5cc5e10948ba46e8af151386878398" +checksum = "1a01cd500915d24ab28ca17527e23901ef1be6d659a2322451e1045532516c25" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -2517,9 +2475,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.24.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385cf0a6103a9f64987cdf0f7c9d0b08e1d7183dd952820beffb3676e7df7787" +checksum = "0fe322e0896d0955a3ebdd5bf813571c53fea29edd713bc315b76620b327e86d" dependencies = [ "http 1.1.0", "jsonrpsee-client-transport", @@ -2539,9 +2497,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "leopard-codec" @@ -2556,9 +2514,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libm" @@ -2568,9 +2526,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" -version = "0.54.0" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b06a2ceb55591d19a194956ce541329007b4e4ee87c5fdd59d64dc439286a36" +checksum = "bbbe80f9c7e00526cd6b838075b9c171919404a4732cb2fa8ece0a093223bfc4" dependencies = [ "bytes", "either", @@ -2736,7 +2694,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4e830fdf24ac8c444c12415903174d506e1e077fbe3875c404a78c5935a8543" dependencies = [ "asynchronous-codec", - "base64", + "base64 0.22.1", "byteorder", "bytes", "either", @@ -2805,9 +2763,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.46.0" +version = "0.46.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3fd4d149f0539e608d178b7cd1cfb0c1c6a8dc367eda2bc1cc81a28a1552161" +checksum = "ced237d0bd84bbebb7c2cad4c073160dacb4fe40534963c32ed6d4c6bb7702a3" dependencies = [ "arrayvec", "asynchronous-codec", @@ -2856,9 +2814,9 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a70afa7692c81ee03e89c40d1e8638d634f18baef6aeeea30fd245edfae4d3fd" +checksum = "77ebafa94a717c8442d8db8d3ae5d1c6a15e30f2d347e0cd31d057ca72e42566" dependencies = [ "futures", "libp2p-core 0.42.0", @@ -2993,10 +2951,10 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206e0aa0ebe004d778d79fb0966aa0de996c19894e2c0605ba2f8524dd4443d8" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -3150,7 +3108,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -3166,12 +3124,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "lock_api" version = "0.4.12" @@ -3184,9 +3136,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "logos" @@ -3208,8 +3160,8 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "regex-syntax 0.8.4", - "syn 2.0.66", + "regex-syntax 0.8.5", + "syn 2.0.79", ] [[package]] @@ -3223,11 +3175,11 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.3" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -3288,7 +3240,7 @@ dependencies = [ "libp2p-websocket-websys 0.3.3", "lumina-node", "pin-project", - "prost", + "prost 0.13.3", "rand", "redb", "rexie", @@ -3391,7 +3343,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -3402,9 +3354,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" dependencies = [ "mime", "unicase", @@ -3428,29 +3380,30 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi 0.3.9", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "multiaddr" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b852bc02a2da5feed68cd14fa50d0774b92790a5bdbfa932a813926c8472070" +checksum = "fe6351f60b488e04c1d21bc69e56b89cb3f5e8f5d22557d6e8031bdfd79b6961" dependencies = [ "arrayref", "byteorder", @@ -3461,7 +3414,7 @@ dependencies = [ "percent-encoding", "serde", "static_assertions", - "unsigned-varint 0.7.2", + "unsigned-varint 0.8.0", "url", ] @@ -3489,9 +3442,9 @@ dependencies = [ [[package]] name = "multihash-codetable" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c11bbdf904c8be009e82ff968c4dab84388cbafc45dfaff61936eca4bf40f1b5" +checksum = "c35f0fb09f635b18e95053fc2a9a4843272d3acf898792a14471dcf6f83df0cc" dependencies = [ "blake2b_simd", "blake2s_simd", @@ -3527,7 +3480,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", "synstructure", ] @@ -3630,9 +3583,9 @@ dependencies = [ [[package]] name = "nmt-rs" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479d559d6a0da9cd6972630efff47d85bbe483e4298723e7f3b43df149f5e484" +checksum = "e408e823bdc9b4bb525a61b44e846239833a8f9bd86c03a43e4ca314a5497582" dependencies = [ "borsh", "bytes", @@ -3668,9 +3621,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -3718,33 +3671,33 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] [[package]] name = "object" -version = "0.36.0" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "oid-registry" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" dependencies = [ "asn1-rs", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -3790,7 +3743,7 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 1.0.109", @@ -3798,9 +3751,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" @@ -3822,7 +3775,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -3831,13 +3784,50 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pbjson" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e6349fa080353f4a597daffd05cb81572a9c031a6d4fff7e504947496fcc68" +dependencies = [ + "base64 0.21.7", + "serde", +] + +[[package]] +name = "pbjson-build" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eea3058763d6e656105d1403cb04e0a41b7bbac6362d413e7c33be0c32279c9" +dependencies = [ + "heck", + "itertools 0.13.0", + "prost 0.13.3", + "prost-types 0.13.3", +] + +[[package]] +name = "pbjson-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e54e5e7bfb1652f95bc361d76f3c780d8e526b134b85417e774166ee941f0887" +dependencies = [ + "bytes", + "chrono", + "pbjson", + "pbjson-build", + "prost 0.13.3", + "prost-build", + "serde", +] + [[package]] name = "pem" version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64", + "base64 0.22.1", "serde", ] @@ -3849,9 +3839,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.10" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -3865,27 +3855,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.6.0", ] [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -3912,17 +3902,17 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.1" +version = "3.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6a007746f34ed64099e88783b0ae369eaa3da6392868ba262e2af9b8fbaea1" +checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi", + "hermit-abi 0.4.0", "pin-project-lite", "rustix", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3956,18 +3946,21 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -3992,11 +3985,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit 0.22.22", ] [[package]] @@ -4025,18 +4018,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] [[package]] name = "prometheus-client" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ca959da22a332509f2a73ae9e5f23f9dcfc31fd3a54d71f159495bd5909baa" +checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" dependencies = [ "dtoa", "itoa", @@ -4052,22 +4045,22 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "unarray", ] @@ -4078,27 +4071,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.6", +] + +[[package]] +name = "prost" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +dependencies = [ + "bytes", + "prost-derive 0.13.3", ] [[package]] name = "prost-build" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck 0.5.0", - "itertools 0.12.1", + "heck", + "itertools 0.13.0", "log", "multimap", "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.13.3", + "prost-types 0.13.3", "regex", - "syn 2.0.66", + "syn 2.0.79", "tempfile", ] @@ -4109,23 +4112,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.10.5", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", +] + +[[package]] +name = "prost-derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +dependencies = [ + "anyhow", + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.79", ] [[package]] name = "prost-reflect" -version = "0.13.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5eec97d5d34bdd17ad2db2219aabf46b054c6c41bd5529767c9ce55be5898f" +checksum = "4b7535b02f0e5efe3e1dbfcb428be152226ed0c66cad9541f2274c8ba8d4cd40" dependencies = [ "logos", "miette", "once_cell", - "prost", - "prost-types", + "prost 0.13.3", + "prost-types 0.13.3", ] [[package]] @@ -4134,33 +4150,42 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost", + "prost 0.12.6", +] + +[[package]] +name = "prost-types" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +dependencies = [ + "prost 0.13.3", ] [[package]] name = "protox" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac532509cee918d40f38c3e12f8ef9230f215f017d54de7dd975015538a42ce7" +checksum = "873f359bdecdfe6e353752f97cb9ee69368df55b16363ed2216da85e03232a58" dependencies = [ "bytes", "miette", - "prost", + "prost 0.13.3", "prost-reflect", - "prost-types", + "prost-types 0.13.3", "protox-parse", "thiserror", ] [[package]] name = "protox-parse" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6c33f43516fe397e2f930779d720ca12cd057f7da4cd6326a0ef78d69dee96" +checksum = "a3a462d115462c080ae000c29a47f0b3985737e5d3a995fcdbcaa5c782068dde" dependencies = [ "logos", "miette", - "prost-types", + "prost-types 0.13.3", "thiserror", ] @@ -4194,17 +4219,18 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "futures-io", "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash 1.1.0", + "rustc-hash", "rustls", + "socket2", "thiserror", "tokio", "tracing", @@ -4219,7 +4245,7 @@ dependencies = [ "bytes", "rand", "ring 0.17.8", - "rustc-hash 2.0.0", + "rustc-hash", "rustls", "slab", "thiserror", @@ -4229,22 +4255,22 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.2" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -4308,27 +4334,27 @@ dependencies = [ [[package]] name = "redb" -version = "2.1.1" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6dd20d3cdeb9c7d2366a0b16b93b35b75aec15309fbeb7ce477138c9f68c8c0" +checksum = "074373f3e7e5d27d8741d19512232adb47be8622d3daef3a45bcae72050c3d2a" dependencies = [ "libc", ] [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -4337,14 +4363,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -4358,13 +4384,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -4375,9 +4401,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" @@ -4464,7 +4490,7 @@ dependencies = [ "futures", "futures-timer", "rstest_macros", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -4475,13 +4501,13 @@ checksum = "4165dfae59a39dd41d8dec720d3cbfbc71f69744efb480a3920f5d4e0cc6798d" dependencies = [ "cfg-if", "glob", - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "regex", "relative-path", - "rustc_version 0.4.0", - "syn 2.0.66", + "rustc_version 0.4.1", + "syn 2.0.79", "unicode-ident", ] @@ -4532,9 +4558,9 @@ checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rust-embed" -version = "8.4.0" +version = "8.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19549741604902eb99a7ed0ee177a0663ee1eda51a29f71401f166e47e77806a" +checksum = "fa66af4a4fdd5e7ebc276f115e895611a34739a9c1c01028383d612d550953c0" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -4543,23 +4569,23 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.4.0" +version = "8.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb9f96e283ec64401f30d3df8ee2aaeb2561f34c824381efa24a35f79bf40ee4" +checksum = "6125dbc8867951125eec87294137f4e9c2c96566e61bf72c45095a7c77761478" dependencies = [ "proc-macro2", "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.66", + "syn 2.0.79", "walkdir", ] [[package]] name = "rust-embed-utils" -version = "8.4.0" +version = "8.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c74a686185620830701348de757fd36bef4aa9680fd23c49fc539ddcc1af32" +checksum = "2e5347777e9aacb56039b0e1f28785929a8a3b709e87482e7442c72e7c12529d" dependencies = [ "sha2 0.10.8", "walkdir", @@ -4571,12 +4597,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hash" version = "2.0.0" @@ -4600,9 +4620,9 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver 1.0.23", ] @@ -4618,11 +4638,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -4631,24 +4651,24 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "log", "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] [[package]] name = "rustls-native-certs" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -4659,25 +4679,24 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-platform-verifier" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5f0d26fa1ce3c790f9590868f0109289a044acb954525f933e2aa3b871c157d" +checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" dependencies = [ "core-foundation", "core-foundation-sys", @@ -4687,18 +4706,18 @@ dependencies = [ "rustls", "rustls-native-certs", "rustls-platform-verifier-android", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.8", "security-framework", "security-framework-sys", - "webpki-roots 0.26.2", + "webpki-roots 0.26.6", "winapi", ] [[package]] name = "rustls-platform-verifier-android" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" @@ -4712,9 +4731,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -4723,9 +4742,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rw-stream-sink" @@ -4755,11 +4774,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4776,11 +4795,11 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -4790,9 +4809,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -4839,9 +4858,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -4859,31 +4878,32 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -4906,7 +4926,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -4984,6 +5004,12 @@ dependencies = [ "dirs", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "2.2.0" @@ -5023,7 +5049,7 @@ dependencies = [ "curve25519-dalek", "rand_core", "ring 0.17.8", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "sha2 0.10.8", "subtle", ] @@ -5044,7 +5070,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "futures", "httparse", @@ -5075,12 +5101,6 @@ dependencies = [ "der", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -5108,9 +5128,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subtle-encoding" @@ -5140,9 +5160,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -5158,7 +5178,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -5181,7 +5201,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -5213,34 +5233,35 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -5285,21 +5306,11 @@ dependencies = [ "time-core", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -5312,30 +5323,29 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -5351,9 +5361,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -5362,9 +5372,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -5376,9 +5386,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" @@ -5386,20 +5396,64 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap", + "indexmap 2.6.0", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap", + "indexmap 2.6.0", "toml_datetime", - "winnow", + "winnow 0.6.20", +] + +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.22.1", + "bytes", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.0", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost 0.13.3", + "socket2", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types 0.13.3", + "quote", + "syn 2.0.79", ] [[package]] @@ -5410,8 +5464,28 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", + "indexmap 1.9.3", "pin-project", "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", "tokio", "tower-layer", "tower-service", @@ -5420,15 +5494,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -5462,7 +5536,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -5532,9 +5606,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uint" @@ -5565,21 +5639,21 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -5592,9 +5666,9 @@ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" @@ -5632,27 +5706,15 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", - "idna 1.0.0", + "idna 0.5.0", "percent-encoding", ] -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -5667,9 +5729,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "void" @@ -5704,9 +5766,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -5715,24 +5777,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -5742,9 +5804,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5752,28 +5814,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-bindgen-test" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +checksum = "d381749acb0943d357dcbd8f0b100640679883fcdeeef04def49daf8d33a5426" dependencies = [ "console_error_panic_hook", "js-sys", @@ -5786,20 +5848,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -5823,9 +5885,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.2" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] @@ -5854,11 +5916,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5901,7 +5963,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -5921,18 +5992,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -5943,9 +6014,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -5955,9 +6026,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -5967,15 +6038,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -5985,9 +6056,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -5997,9 +6068,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -6009,9 +6080,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -6021,9 +6092,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -6034,6 +6105,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -6044,18 +6124,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "wyz" version = "0.5.1" @@ -6096,9 +6164,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.20" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" +checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" [[package]] name = "xmltree" @@ -6149,69 +6217,25 @@ dependencies = [ "time", ] -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", - "synstructure", + "syn 2.0.79", ] [[package]] @@ -6231,27 +6255,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "zerovec" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", + "syn 2.0.79", ] From f1954d476b1beef80d00f67c0a7c2f0d10c9cb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 29 Oct 2024 09:21:56 +0100 Subject: [PATCH 03/56] wip3 --- rpc/Cargo.toml | 3 + rpc/src/tonic/mod.rs | 167 +++++++++++++++++++++++++++----- rpc/src/tonic/tendermint.rs | 19 ++++ rpc/src/tonic/types.rs | 142 +++++++++++++++++++++++++++ rpc/tests/tonic.rs | 37 +++++++ rpc/tests/utils/tonic_client.rs | 4 +- 6 files changed, 349 insertions(+), 23 deletions(-) create mode 100644 rpc/src/tonic/tendermint.rs create mode 100644 rpc/src/tonic/types.rs create mode 100644 rpc/tests/tonic.rs diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 56e101c3..6e5d708a 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -22,7 +22,10 @@ categories = [ celestia-tendermint-proto.workspace = true celestia-types.workspace = true celestia-proto = { optional = true, workspace = true } +celestia-tendermint.workspace = true +prost.workspace = true async-trait = "0.1.80" +futures = "0.3.31" jsonrpsee = { version = "0.24.2", features = ["client-core", "macros"] } serde = { version = "1.0.203", features = ["derive"] } thiserror = "1.0.61" diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs index 50cd3465..a307b7eb 100644 --- a/rpc/src/tonic/mod.rs +++ b/rpc/src/tonic/mod.rs @@ -1,10 +1,22 @@ -use celestia_proto::cosmos::base::node::v1beta1::{ - service_client::ServiceClient as ConfigServiceClient, ConfigRequest, -}; +use std::convert::Infallible; + +//use celestia_proto::cosmos::base::node::v1beta1::{ service_client::ServiceClient as ConfigServiceClient, ConfigRequest, ConfigResponse, }; + +use celestia_proto::celestia::blob::v1 as blob; +use celestia_proto::cosmos::auth::v1beta1 as auth; +use celestia_proto::cosmos::base::node::v1beta1 as config; +use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; + + use tonic::service::Interceptor; use tonic::transport::Channel; use tonic::Status; +pub mod types; + +use types::IntoGrpcParam; +use types::{AuthParams, BaseAccount, BlobParams, Block, GasPrice}; + /* use celestia_proto::celestia::blob::v1::query_client::QueryClient; use celestia_tendermint_proto::v0_34::types::{ @@ -69,8 +81,18 @@ pub enum Error { #[error(transparent)] TonicError(#[from] Status), + #[error(transparent)] + TendermintError(#[from] celestia_tendermint::Error), + #[error("Failed to parse response")] FailedToParseResponse, + + #[error("Unexpected response type")] + UnexpectedResponseType(String), + + /// Unreachable. Added to appease try_into conversion for GrpcClient method macro + #[error(transparent)] + Infallible(#[from] Infallible), } pub struct GrpcClient @@ -81,6 +103,116 @@ where auth_interceptor: I, } +/* +macro_rules! make_method { + ($name:ident, $service_client:ident, $method:ident, $param:ty, $ret:ty) => { + pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { + let mut service_client = + $service_client::service_client::ServiceClient::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = service_client.$method(param).await; + + Ok(response?.into_inner().try_into()?) + } + }; + ($name:ident, $service_client:ident, $method:ident, $ret:ty) => { + pub async fn $name(&mut self) -> Result<$ret, Error> { + let mut service_client = + $service_client::service_client::ServiceClient::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = service_client + .$method(::tonic::Request::new(Default::default())) + .await; + + Ok(response?.into_inner().try_into()?) + } + }; +} + +macro_rules! make_query { + ($name:ident, $service_client:ident, $method:ident, $param:ty, $ret:ty) => { + pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { + let mut client = $service_client::query_client::QueryClient::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = client.$method(param).await; + + Ok(response?.into_inner().try_into()?) + } + }; + ($name:ident, $service_client:ident, $method:ident, $ret:ty) => { + pub async fn $name(&mut self) -> Result<$ret, Error> { + let mut client = $service_client::query_client::QueryClient::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = client + .$method(::tonic::Request::new(Default::default())) + .await; + + Ok(response?.into_inner().try_into()?) + } + }; +} +*/ + +// macro takes a path to an appropriate generated gRPC method and a desired function signature. +// If parameters need to be converted, they should implement [`types::IntoGrpcParam`] into +// appropriate type and return type is converted using TryFrom +// +// One limitation is that it expects gRPC method to be provided in exactly 4 `::` delimited +// segments, requiring importing the proto module with `as`. This might be possible to overcome +// by rewriting the macro as tt-muncher, but it'd increase its complexity significantly +macro_rules! make_method { + ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $param:ty ) -> $ret:ty) => { + pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { + let mut client = $path::$client_module::$client_struct::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = client + .$method(param.into_parameter()) + .await; + + Ok(response?.into_inner().try_into()?) + } + }; + ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident () -> $ret:ty) => { + pub async fn $name(&mut self) -> Result<$ret, Error> { + let mut client = $path::$client_module::$client_struct::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let response = client + .$method(::tonic::Request::new(Default::default())) + .await; + + Ok(response?.into_inner().try_into()?) + } + }; +} + +/* +macro_rules! mm { + ($prefix:ident $(:: $tail:path)+; $name:ident ( $param:ty ) -> $ret:ty ) => { + mm!($prefix :: ; $($tail),* | $name($param) -> $ret); + }; + + ($($module:ident ::)+ ; $head:ident, $($tail:ident),+ | $name:ident ($param:ty) -> $ret:ty ) => { + + }; + + //(@resolved $module:path, $client_module:ident, $client_struct:ident, $method:ident; ) +} + +mm!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(i64) -> Block); +*/ + impl GrpcClient where I: Interceptor + Clone, @@ -91,23 +223,14 @@ where auth_interceptor, } } - pub async fn get_min_gas_price(&self) -> Result { - const UNITS_SUFFIX: &str = "utia"; - - let mut min_gas_price_client = ConfigServiceClient::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = min_gas_price_client.config(ConfigRequest {}).await; - - let min_gas_price_with_suffix = response?.into_inner().minimum_gas_price; - let min_gas_price_str = min_gas_price_with_suffix - .strip_suffix(UNITS_SUFFIX) - .ok_or(Error::FailedToParseResponse)?; - let min_gas_price = min_gas_price_str - .parse::() - .map_err(|_| Error::FailedToParseResponse)?; - - Ok(min_gas_price) - } + + make_method!(config::service_client::ServiceClient::config; get_min_gas_price() -> GasPrice); + + make_method!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Block); + make_method!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(i64) -> Block); + + make_method!(blob::query_client::QueryClient::params; get_blob_params() -> BlobParams); + + make_method!(auth::query_client::QueryClient::params; get_auth_params() -> AuthParams); + make_method!(auth::query_client::QueryClient::account; get_account(String) -> BaseAccount); } diff --git a/rpc/src/tonic/tendermint.rs b/rpc/src/tonic/tendermint.rs new file mode 100644 index 00000000..8f14a7d7 --- /dev/null +++ b/rpc/src/tonic/tendermint.rs @@ -0,0 +1,19 @@ +use crate::Error; +use crate::tonic::GrpcClient; + +use celestia_proto::cosmos::base::tendermint::v1beta1::{ + service_client::ServiceClient as TendermintServiceClient, + GetNodeInfoRequest, +}; + + +impl GrpcClient { + async fn get_node_info(&self) -> Result<(), Error> { + let service_client = TendermintServiceClient::with_interceptor(self.grpc_channel, self.auth_interceptor); + let request = GetNodeInfoRequest {}; + + let node_info = service_client.get_node_info(request).await?; + + node_info + } +} diff --git a/rpc/src/tonic/types.rs b/rpc/src/tonic/types.rs new file mode 100644 index 00000000..44ca23ec --- /dev/null +++ b/rpc/src/tonic/types.rs @@ -0,0 +1,142 @@ +use prost::{Message, Name}; + +use celestia_proto::celestia::blob::v1::QueryParamsResponse as QueryBlobParamsResponse; +use celestia_proto::cosmos::auth::v1beta1::QueryParamsResponse as QueryAuthParamsResponse; +use celestia_proto::cosmos::auth::v1beta1::{BaseAccount as RawBaseAccount, QueryAccountResponse, QueryAccountRequest}; +use celestia_proto::cosmos::base::node::v1beta1::ConfigResponse; +use celestia_proto::cosmos::base::tendermint::v1beta1::{ + GetBlockByHeightResponse, GetLatestBlockResponse, + GetBlockByHeightRequest +}; + +use celestia_tendermint::block::Block as TendermintBlock; + +use crate::tonic::Error; + +pub struct GasPrice(pub f64); +pub struct Block(pub TendermintBlock); +#[derive(Debug)] +pub struct BlobParams { + pub gas_per_blob_byte: u32, + pub gov_max_square_size: u64, +} +#[derive(Debug)] +pub struct AuthParams { + pub max_memo_characters: u64, + pub tx_sig_limit: u64, + pub tx_size_cost_per_byte: u64, + pub sig_verify_cost_ed25519: u64, + pub sig_verify_cost_secp256k1: u64, +} +#[derive(Debug)] +pub struct BaseAccount { + pub address: String, + //pub pub_key + account_number: u64, + sequence: u64, +} + +pub(crate) trait IntoGrpcParam { + fn into_parameter(self) -> T; +} + +impl IntoGrpcParam for i64 { + fn into_parameter(self) -> GetBlockByHeightRequest { + GetBlockByHeightRequest { + height: self + } + } +} + +impl IntoGrpcParam for String { + fn into_parameter(self) -> QueryAccountRequest { + QueryAccountRequest { + address: self + } + } +} + +impl TryFrom for GasPrice { + type Error = Error; + + fn try_from(item: ConfigResponse) -> Result { + println!("II: {item:#?}"); + const UNITS_SUFFIX: &str = "utia"; + + let min_gas_price_with_suffix = item.minimum_gas_price; + let min_gas_price_str = min_gas_price_with_suffix + .strip_suffix(UNITS_SUFFIX) + .ok_or(Error::FailedToParseResponse)?; + let min_gas_price = min_gas_price_str + .parse::() + .map_err(|_| Error::FailedToParseResponse)?; + + Ok(GasPrice(min_gas_price)) + } +} + +impl TryFrom for Block { + type Error = Error; + + fn try_from(item: GetBlockByHeightResponse) -> Result { + Ok(Block( + item.block.ok_or(Error::FailedToParseResponse)?.try_into()?, + )) + } +} + +impl TryFrom for Block { + type Error = Error; + + fn try_from(item: GetLatestBlockResponse) -> Result { + Ok(Block( + item.block.ok_or(Error::FailedToParseResponse)?.try_into()?, + )) + } +} + +impl TryFrom for BlobParams { + type Error = Error; + + fn try_from(item: QueryBlobParamsResponse) -> Result { + let params = item.params.ok_or(Error::FailedToParseResponse)?; + Ok(BlobParams { + gas_per_blob_byte: params.gas_per_blob_byte, + gov_max_square_size: params.gov_max_square_size, + }) + } +} + +impl TryFrom for AuthParams { + type Error = Error; + + fn try_from(item: QueryAuthParamsResponse) -> Result { + let params = item.params.ok_or(Error::FailedToParseResponse)?; + Ok(AuthParams { + max_memo_characters: params.max_memo_characters, + tx_sig_limit: params.tx_sig_limit, + tx_size_cost_per_byte: params.tx_size_cost_per_byte, + sig_verify_cost_ed25519: params.sig_verify_cost_ed25519, + sig_verify_cost_secp256k1: params.sig_verify_cost_secp256k1, + }) + } +} + +impl TryFrom for BaseAccount { + type Error = Error; + + fn try_from(item: QueryAccountResponse) -> Result { + let account = item.account.ok_or(Error::FailedToParseResponse)?; + if account.type_url != RawBaseAccount::type_url() { + return Err(Error::UnexpectedResponseType(account.type_url)); + } + let base_account = + RawBaseAccount::decode(&*account.value).map_err(|_| Error::FailedToParseResponse)?; + + Ok(Self { + address: base_account.address, + account_number: base_account.account_number, + sequence: base_account.sequence, + }) + } +} diff --git a/rpc/tests/tonic.rs b/rpc/tests/tonic.rs new file mode 100644 index 00000000..c56d4c90 --- /dev/null +++ b/rpc/tests/tonic.rs @@ -0,0 +1,37 @@ +pub mod utils; + +use crate::utils::client::AuthLevel; +use crate::utils::tonic_client::new_test_client; +use celestia_proto::cosmos::auth::v1beta1 as auth; +use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; + +#[tokio::test] +async fn get_min_gas_price() { + let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + let gas_price = client.get_min_gas_price().await.unwrap(); + assert!(gas_price.0 > 0.0); +} + +#[tokio::test] +async fn get_block() { + let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + + let latest_block = client.get_latest_block().await.unwrap(); + let height = latest_block.0.header.height.value() as i64; + + let block = client .get_block_by_height(height) .await .unwrap(); + assert_eq!(block.0.header, latest_block.0.header); + //println!("B: {:?}", block.0.header.height); +} + +#[tokio::test] +async fn get_account() { + let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + + let acct = client + .get_account("celestia1p3ucd3ptpw902fluyjzhq3ffgq4ntddaf0pdta".to_string()) + .await + .unwrap(); + + println!("{acct:?}"); +} diff --git a/rpc/tests/utils/tonic_client.rs b/rpc/tests/utils/tonic_client.rs index 09f05ac9..2f483845 100644 --- a/rpc/tests/utils/tonic_client.rs +++ b/rpc/tests/utils/tonic_client.rs @@ -9,7 +9,9 @@ use tonic::{Request, Status}; use celestia_rpc::tonic::GrpcClient; -const CELESTIA_GRPC_URL: &str = "http://localhost:9090"; +//const CELESTIA_GRPC_URL: &str = "http://localhost:9090"; +//const CELESTIA_GRPC_URL: &str = "https://public-celestia-consensus.numia.xyz:9090"; +const CELESTIA_GRPC_URL: &str = "https://rpc.celestia.pops.one:9090"; #[derive(Clone)] pub struct TestAuthInterceptor { From 3fc2f834e131c657175bae5f2724ed53fceb568f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 29 Oct 2024 19:51:52 +0100 Subject: [PATCH 04/56] types cleanup --- Cargo.lock | 303 ++++++++++++++++++++++++++++++++--------- Cargo.toml | 4 +- proto/build.rs | 1 + rpc/Cargo.toml | 5 +- rpc/src/tonic/mod.rs | 26 ++-- rpc/src/tonic/types.rs | 148 ++++++++++++++++---- rpc/tests/tonic.rs | 7 +- types/Cargo.toml | 1 + types/src/auth.rs | 18 +++ types/src/blob.rs | 6 + types/src/lib.rs | 1 + 11 files changed, 408 insertions(+), 112 deletions(-) create mode 100644 types/src/auth.rs diff --git a/Cargo.lock b/Cargo.lock index edc1ebd2..a9689361 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -143,7 +143,7 @@ dependencies = [ "ark-serialize 0.3.0", "ark-std 0.3.0", "derivative", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.3.3", @@ -163,7 +163,7 @@ dependencies = [ "derivative", "digest 0.10.7", "itertools 0.10.5", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.4.1", @@ -196,7 +196,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "quote", "syn 1.0.109", @@ -208,7 +208,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "proc-macro2", "quote", @@ -233,7 +233,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-std 0.4.0", "digest 0.10.7", - "num-bigint 0.4.5", + "num-bigint 0.4.6", ] [[package]] @@ -507,6 +507,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.21.7" @@ -565,6 +571,22 @@ dependencies = [ "web-time", ] +[[package]] +name = "bip32" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa13fae8b6255872fd86f7faf4b41168661d7d78609f7bfe6771b85c6739a15b" +dependencies = [ + "bs58", + "hmac", + "k256", + "rand_core", + "ripemd", + "sha2 0.10.8", + "subtle", + "zeroize", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -698,6 +720,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ + "sha2 0.10.8", "tinyvec", ] @@ -745,9 +768,9 @@ dependencies = [ "pbjson", "pbjson-build", "pbjson-types", - "prost 0.13.3", + "prost", "prost-build", - "prost-types 0.13.3", + "prost-types", "protox", "serde", "serde_json", @@ -764,8 +787,10 @@ dependencies = [ "anyhow", "async-trait", "celestia-proto", + "celestia-tendermint", "celestia-tendermint-proto", "celestia-types", + "cosmrs", "dotenvy", "futures", "getrandom", @@ -773,6 +798,7 @@ dependencies = [ "jsonrpsee", "libp2p", "nmt-rs", + "prost", "rand", "serde", "thiserror", @@ -785,8 +811,6 @@ dependencies = [ [[package]] name = "celestia-tendermint" version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce8c92a01145f79a0f3ac7c44a43a9b5ee58e8a4c716b56d98833a3848db1afd" dependencies = [ "bytes", "celestia-tendermint-proto", @@ -796,10 +820,12 @@ dependencies = [ "flex-error", "futures", "instant", + "k256", "num-traits", "once_cell", - "prost 0.12.6", - "prost-types 0.12.6", + "prost", + "prost-types", + "ripemd", "serde", "serde_bytes", "serde_json", @@ -815,15 +841,13 @@ dependencies = [ [[package]] name = "celestia-tendermint-proto" version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a95746c5221a74d7b913a415fdbb9e7c90e1b4d818dbbff59bddc034cfce2ec" dependencies = [ "bytes", "flex-error", "num-derive", "num-traits", - "prost 0.12.6", - "prost-types 0.12.6", + "prost", + "prost-types", "serde", "serde_bytes", "subtle-encoding", @@ -843,6 +867,7 @@ dependencies = [ "celestia-tendermint-proto", "cid", "const_format", + "cosmrs", "ed25519-consensus", "enum_dispatch", "getrandom", @@ -1072,6 +1097,36 @@ dependencies = [ "memchr", ] +[[package]] +name = "cosmos-sdk-proto" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c1a5856db92cd90dddc955bce308703d3519fb33ae3d0b8f3658e9cfd05c3f" +dependencies = [ + "prost", + "tendermint-proto", +] + +[[package]] +name = "cosmrs" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "210fbe6f98594963b46cc980f126a9ede5db9a3848ca65b71303bebdb01afcd9" +dependencies = [ + "bip32", + "cosmos-sdk-proto", + "ecdsa", + "eyre", + "k256", + "rand_core", + "serde", + "serde_json", + "signature", + "subtle-encoding", + "tendermint", + "thiserror", +] + [[package]] name = "cpufeatures" version = "0.2.14" @@ -1102,6 +1157,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1234,7 +1301,7 @@ dependencies = [ "asn1-rs", "displaydoc", "nom", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "rusticata-macros", ] @@ -1275,6 +1342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -1332,6 +1400,20 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + [[package]] name = "ed25519" version = "2.2.3" @@ -1378,6 +1460,25 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "enum-as-inner" version = "0.6.1" @@ -1466,6 +1567,16 @@ dependencies = [ "bytes", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -1692,6 +1803,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -1787,6 +1899,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + [[package]] name = "h2" version = "0.3.26" @@ -2487,6 +2610,18 @@ dependencies = [ "url", ] +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.8", +] + [[package]] name = "keccak" version = "0.1.5" @@ -3242,7 +3377,7 @@ dependencies = [ "libp2p-websocket-websys 0.3.3", "lumina-node", "pin-project", - "prost 0.13.3", + "prost", "rand", "redb", "rexie", @@ -3873,8 +4008,8 @@ checksum = "6eea3058763d6e656105d1403cb04e0a41b7bbac6362d413e7c33be0c32279c9" dependencies = [ "heck", "itertools 0.13.0", - "prost 0.13.3", - "prost-types 0.13.3", + "prost", + "prost-types", ] [[package]] @@ -3887,7 +4022,7 @@ dependencies = [ "chrono", "pbjson", "pbjson-build", - "prost 0.13.3", + "prost", "prost-build", "serde", ] @@ -4135,16 +4270,6 @@ dependencies = [ "unarray", ] -[[package]] -name = "prost" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" -dependencies = [ - "bytes", - "prost-derive 0.12.6", -] - [[package]] name = "prost" version = "0.13.3" @@ -4152,7 +4277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", - "prost-derive 0.13.3", + "prost-derive", ] [[package]] @@ -4169,26 +4294,13 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost 0.13.3", - "prost-types 0.13.3", + "prost", + "prost-types", "regex", "syn 2.0.79", "tempfile", ] -[[package]] -name = "prost-derive" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "syn 2.0.79", -] - [[package]] name = "prost-derive" version = "0.13.3" @@ -4211,17 +4323,8 @@ dependencies = [ "logos", "miette", "once_cell", - "prost 0.13.3", - "prost-types 0.13.3", -] - -[[package]] -name = "prost-types" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" -dependencies = [ - "prost 0.12.6", + "prost", + "prost-types", ] [[package]] @@ -4230,7 +4333,7 @@ version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ - "prost 0.13.3", + "prost", ] [[package]] @@ -4241,9 +4344,9 @@ checksum = "873f359bdecdfe6e353752f97cb9ee69368df55b16363ed2216da85e03232a58" dependencies = [ "bytes", "miette", - "prost 0.13.3", + "prost", "prost-reflect", - "prost-types 0.13.3", + "prost-types", "protox-parse", "thiserror", ] @@ -4256,7 +4359,7 @@ checksum = "a3a462d115462c080ae000c29a47f0b3985737e5d3a995fcdbcaa5c782068dde" dependencies = [ "logos", "miette", - "prost-types 0.13.3", + "prost-types", "thiserror", ] @@ -4503,6 +4606,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ring" version = "0.16.20" @@ -4608,7 +4721,7 @@ dependencies = [ "ark-ff 0.4.2", "bytes", "fastrlp", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "parity-scale-codec", "primitive-types", @@ -4864,6 +4977,20 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -4874,7 +5001,7 @@ dependencies = [ "core-foundation", "core-foundation-sys", "libc", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "security-framework-sys", ] @@ -5087,6 +5214,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ + "digest 0.10.7", "rand_core", ] @@ -5315,6 +5443,51 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "tendermint" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d513ce7f9e41c67ab2dd3d554ef65f36fbcc61745af1e1f93eafdeefa1ce37" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "k256", + "num-traits", + "once_cell", + "prost", + "ripemd", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto", + "time", + "zeroize", +] + +[[package]] +name = "tendermint-proto" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c81ba1b023ec00763c3bc4f4376c67c0047f185cccf95c416c7a2f16272c4cbb" +dependencies = [ + "bytes", + "flex-error", + "prost", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + [[package]] name = "thiserror" version = "1.0.64" @@ -5503,7 +5676,7 @@ dependencies = [ "hyper-util", "percent-encoding", "pin-project", - "prost 0.13.3", + "prost", "socket2", "tokio", "tokio-stream", @@ -5522,7 +5695,7 @@ dependencies = [ "prettyplease", "proc-macro2", "prost-build", - "prost-types 0.13.3", + "prost-types", "quote", "syn 2.0.79", ] diff --git a/Cargo.toml b/Cargo.toml index a66f58aa..75b5346a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ prost-types = "0.13.3" # Uncomment to apply local changes #beetswap = { path = "../beetswap" } #blockstore = { path = "../blockstore" } -#celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } -#celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } +celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } +celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } #nmt-rs = { path = "../nmt-rs" } #libp2p = { path = "../../rust-libp2p/libp2p" } #libp2p-core = { path = "../../rust-libp2p/core" } diff --git a/proto/build.rs b/proto/build.rs index 48e7e94b..0074f498 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -93,6 +93,7 @@ const PROTO_FILES: &[&str] = &[ "vendor/share/eds/byzantine/pb/share.proto", "vendor/share/shwap/p2p/bitswap/pb/bitswap.proto", "vendor/share/shwap/pb/shwap.proto", + //"vendor/tendermint/crypto/keys.proto", "vendor/tendermint/types/types.proto", ]; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 6e5d708a..10c06f9e 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -24,7 +24,9 @@ celestia-types.workspace = true celestia-proto = { optional = true, workspace = true } celestia-tendermint.workspace = true prost.workspace = true + async-trait = "0.1.80" +cosmrs = "0.21.0" futures = "0.3.31" jsonrpsee = { version = "0.24.2", features = ["client-core", "macros"] } serde = { version = "1.0.203", features = ["derive"] } @@ -57,10 +59,11 @@ getrandom = { version = "0.2.15", features = ["js"] } wasm-bindgen-test = "0.3.42" [features] -default = ["p2p"] +default = ["p2p", "secp256k1"] tonic_grpc = ["celestia-proto/tonic", "dep:tonic"] p2p = ["celestia-types/p2p"] wasm-bindgen = ["celestia-types/wasm-bindgen", "jsonrpsee/wasm-client"] +secp256k1 = ["celestia-tendermint/secp256k1"] [package.metadata.docs.rs] features = ["p2p"] diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs index a307b7eb..6dd5b5f8 100644 --- a/rpc/src/tonic/mod.rs +++ b/rpc/src/tonic/mod.rs @@ -1,12 +1,14 @@ use std::convert::Infallible; -//use celestia_proto::cosmos::base::node::v1beta1::{ service_client::ServiceClient as ConfigServiceClient, ConfigRequest, ConfigResponse, }; +use celestia_types::auth::{AuthParams, BaseAccount}; +use celestia_types::blob::BlobParams; use celestia_proto::celestia::blob::v1 as blob; use celestia_proto::cosmos::auth::v1beta1 as auth; use celestia_proto::cosmos::base::node::v1beta1 as config; use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; +use cosmrs::ErrorReport; use tonic::service::Interceptor; use tonic::transport::Channel; @@ -14,8 +16,8 @@ use tonic::Status; pub mod types; -use types::IntoGrpcParam; -use types::{AuthParams, BaseAccount, BlobParams, Block, GasPrice}; +use types::Block; +use types::{FromGrpcResponse, IntoGrpcParam}; /* use celestia_proto::celestia::blob::v1::query_client::QueryClient; @@ -84,6 +86,12 @@ pub enum Error { #[error(transparent)] TendermintError(#[from] celestia_tendermint::Error), + #[error(transparent)] + CosmrsError(#[from] ErrorReport), + + #[error(transparent)] + TendermintProtoError(#[from] celestia_tendermint_proto::Error), + #[error("Failed to parse response")] FailedToParseResponse, @@ -175,11 +183,9 @@ macro_rules! make_method { self.grpc_channel.clone(), self.auth_interceptor.clone(), ); - let response = client - .$method(param.into_parameter()) - .await; + let response = client.$method(param.into_parameter()).await; - Ok(response?.into_inner().try_into()?) + Ok(response?.into_inner().try_from_response()?) } }; ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident () -> $ret:ty) => { @@ -192,7 +198,7 @@ macro_rules! make_method { .$method(::tonic::Request::new(Default::default())) .await; - Ok(response?.into_inner().try_into()?) + Ok(response?.into_inner().try_from_response()?) } }; } @@ -224,10 +230,12 @@ where } } - make_method!(config::service_client::ServiceClient::config; get_min_gas_price() -> GasPrice); + make_method!(config::service_client::ServiceClient::config; get_min_gas_price() -> f64); make_method!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Block); make_method!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(i64) -> Block); + // TODO get_node_info + // make_method!(tendermint::service_client::ServiceClient::get_node_info; get_node_info() -> NodeInfo); make_method!(blob::query_client::QueryClient::params; get_blob_params() -> BlobParams); diff --git a/rpc/src/tonic/types.rs b/rpc/src/tonic/types.rs index 44ca23ec..85c3fdd5 100644 --- a/rpc/src/tonic/types.rs +++ b/rpc/src/tonic/types.rs @@ -1,66 +1,151 @@ use prost::{Message, Name}; +use celestia_types::auth::{AuthParams, BaseAccount}; +use celestia_types::blob::BlobParams; + use celestia_proto::celestia::blob::v1::QueryParamsResponse as QueryBlobParamsResponse; use celestia_proto::cosmos::auth::v1beta1::QueryParamsResponse as QueryAuthParamsResponse; -use celestia_proto::cosmos::auth::v1beta1::{BaseAccount as RawBaseAccount, QueryAccountResponse, QueryAccountRequest}; +use celestia_proto::cosmos::auth::v1beta1::{ + BaseAccount as RawBaseAccount, QueryAccountRequest, QueryAccountResponse, +}; use celestia_proto::cosmos::base::node::v1beta1::ConfigResponse; use celestia_proto::cosmos::base::tendermint::v1beta1::{ - GetBlockByHeightResponse, GetLatestBlockResponse, - GetBlockByHeightRequest + GetBlockByHeightRequest, GetBlockByHeightResponse, GetLatestBlockResponse, }; use celestia_tendermint::block::Block as TendermintBlock; +use cosmrs::crypto::PublicKey; +use cosmrs::Any; + use crate::tonic::Error; -pub struct GasPrice(pub f64); pub struct Block(pub TendermintBlock); -#[derive(Debug)] -pub struct BlobParams { - pub gas_per_blob_byte: u32, - pub gov_max_square_size: u64, -} -#[derive(Debug)] -pub struct AuthParams { - pub max_memo_characters: u64, - pub tx_sig_limit: u64, - pub tx_size_cost_per_byte: u64, - pub sig_verify_cost_ed25519: u64, - pub sig_verify_cost_secp256k1: u64, -} -#[derive(Debug)] -pub struct BaseAccount { - pub address: String, - //pub pub_key - account_number: u64, - sequence: u64, + +pub(crate) trait FromGrpcResponse { + fn try_from_response(self) -> Result; } pub(crate) trait IntoGrpcParam { fn into_parameter(self) -> T; } +impl FromGrpcResponse for QueryBlobParamsResponse { + fn try_from_response(self) -> Result { + let params = self.params.ok_or(Error::FailedToParseResponse)?; + Ok(BlobParams { + gas_per_blob_byte: params.gas_per_blob_byte, + gov_max_square_size: params.gov_max_square_size, + }) + } +} + +impl FromGrpcResponse for GetBlockByHeightResponse { + fn try_from_response(self) -> Result { + Ok(Block( + self.block.ok_or(Error::FailedToParseResponse)?.try_into()?, + )) + } +} + +impl FromGrpcResponse for GetLatestBlockResponse { + fn try_from_response(self) -> Result { + Ok(Block( + self.block.ok_or(Error::FailedToParseResponse)?.try_into()?, + )) + } +} + +impl FromGrpcResponse for QueryAuthParamsResponse { + fn try_from_response(self) -> Result { + let params = self.params.ok_or(Error::FailedToParseResponse)?; + Ok(AuthParams { + max_memo_characters: params.max_memo_characters, + tx_sig_limit: params.tx_sig_limit, + tx_size_cost_per_byte: params.tx_size_cost_per_byte, + sig_verify_cost_ed25519: params.sig_verify_cost_ed25519, + sig_verify_cost_secp256k1: params.sig_verify_cost_secp256k1, + }) + } +} + +impl FromGrpcResponse for QueryAccountResponse { + fn try_from_response(self) -> Result { + let account = self.account.ok_or(Error::FailedToParseResponse)?; + if account.type_url != RawBaseAccount::type_url() { + return Err(Error::UnexpectedResponseType(account.type_url)); + } + println!("ACTT: {:#?}", account.value); + let base_account = + RawBaseAccount::decode(&*account.value).map_err(|_| Error::FailedToParseResponse)?; + + let any_pub_key = base_account.pub_key.ok_or(Error::FailedToParseResponse)?; + // cosmrs has different Any type than pbjson_types Any + let pub_key = PublicKey::try_from(Any { + type_url: any_pub_key.type_url, + value: any_pub_key.value.to_vec(), + })?; + + /* + println!("key: {:#?}", raw_pub_key); + let any_pub_key = Any::decode(raw_pub_key.value).unwrap(); + + //if raw_pub_key.type_url != RawPublicKey::type_url() { return Err(Error::UnexpectedResponseType(raw_pub_key.type_url)); } + panic!("xxx"); + //let a : () = raw_pub_key.value; + let raw_pub_key = RawPublicKey::decode( &*raw_pub_key.value).unwrap(); + let pub_key = match raw_pub_key.sum.ok_or(Error::FailedToParseResponse)? { + Sum::Ed25519(bytes) => { + PublicKey::from_raw_ed25519(&bytes).ok_or(Error::FailedToParseResponse)? + } + #[cfg(feature = "secp256k1")] + Sum::Secp256k1(bytes) => { + PublicKey::from_raw_secp256k1(&bytes).ok_or(Error::FailedToParseResponse)? + } + }; + */ + Ok(BaseAccount { + address: base_account.address, + pub_key, + account_number: base_account.account_number, + sequence: base_account.sequence, + }) + } +} + +impl FromGrpcResponse for ConfigResponse { + fn try_from_response(self) -> Result { + const UNITS_SUFFIX: &str = "utia"; + + let min_gas_price_with_suffix = self.minimum_gas_price; + let min_gas_price_str = min_gas_price_with_suffix + .strip_suffix(UNITS_SUFFIX) + .ok_or(Error::FailedToParseResponse)?; + let min_gas_price = min_gas_price_str + .parse::() + .map_err(|_| Error::FailedToParseResponse)?; + + Ok(min_gas_price) + } +} + impl IntoGrpcParam for i64 { fn into_parameter(self) -> GetBlockByHeightRequest { - GetBlockByHeightRequest { - height: self - } + GetBlockByHeightRequest { height: self } } } impl IntoGrpcParam for String { fn into_parameter(self) -> QueryAccountRequest { - QueryAccountRequest { - address: self - } + QueryAccountRequest { address: self } } } +/* impl TryFrom for GasPrice { type Error = Error; fn try_from(item: ConfigResponse) -> Result { - println!("II: {item:#?}"); const UNITS_SUFFIX: &str = "utia"; let min_gas_price_with_suffix = item.minimum_gas_price; @@ -94,7 +179,9 @@ impl TryFrom for Block { )) } } +*/ +/* impl TryFrom for BlobParams { type Error = Error; @@ -140,3 +227,4 @@ impl TryFrom for BaseAccount { }) } } +*/ diff --git a/rpc/tests/tonic.rs b/rpc/tests/tonic.rs index c56d4c90..16cfe834 100644 --- a/rpc/tests/tonic.rs +++ b/rpc/tests/tonic.rs @@ -2,14 +2,12 @@ pub mod utils; use crate::utils::client::AuthLevel; use crate::utils::tonic_client::new_test_client; -use celestia_proto::cosmos::auth::v1beta1 as auth; -use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; #[tokio::test] async fn get_min_gas_price() { let mut client = new_test_client(AuthLevel::Write).await.unwrap(); let gas_price = client.get_min_gas_price().await.unwrap(); - assert!(gas_price.0 > 0.0); + assert!(gas_price > 0.0); } #[tokio::test] @@ -19,9 +17,8 @@ async fn get_block() { let latest_block = client.get_latest_block().await.unwrap(); let height = latest_block.0.header.height.value() as i64; - let block = client .get_block_by_height(height) .await .unwrap(); + let block = client.get_block_by_height(height).await.unwrap(); assert_eq!(block.0.header, latest_block.0.header); - //println!("B: {:?}", block.0.header.height); } #[tokio::test] diff --git a/types/Cargo.toml b/types/Cargo.toml index de934a2b..af3b28a7 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -25,6 +25,7 @@ bech32 = "0.11.0" bytes = "1.6.0" cid = { version = "0.11.1", default-features = false, features = ["std"] } const_format = "0.2.32" +cosmrs = "0.21.0" ed25519-consensus = { version = "2.1.0", optional = true } enum_dispatch = "0.3.13" leopard-codec = "0.1.0" diff --git a/types/src/auth.rs b/types/src/auth.rs new file mode 100644 index 00000000..dae8b4cf --- /dev/null +++ b/types/src/auth.rs @@ -0,0 +1,18 @@ +use cosmrs::crypto::PublicKey; + +#[derive(Debug)] +pub struct AuthParams { + pub max_memo_characters: u64, + pub tx_sig_limit: u64, + pub tx_size_cost_per_byte: u64, + pub sig_verify_cost_ed25519: u64, + pub sig_verify_cost_secp256k1: u64, +} + +#[derive(Debug)] +pub struct BaseAccount { + pub address: String, + pub pub_key: PublicKey, + pub account_number: u64, + pub sequence: u64, +} diff --git a/types/src/blob.rs b/types/src/blob.rs index 478ed8b6..da003c90 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -37,6 +37,12 @@ pub struct Blob { pub index: Option, } +#[derive(Debug)] +pub struct BlobParams { + pub gas_per_blob_byte: u32, + pub gov_max_square_size: u64, +} + impl Blob { /// Create a new blob with the given data within the [`Namespace`]. /// diff --git a/types/src/lib.rs b/types/src/lib.rs index 25676617..f10dc3ab 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] +pub mod auth; pub mod blob; mod block; mod byzantine; From 3198132caf0ccde12ad4639407314ac386cf0e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 30 Oct 2024 10:10:56 +0100 Subject: [PATCH 05/56] missing rpc methods --- Cargo.lock | 2 + proto/Cargo.toml | 1 + proto/build.rs | 2 + rpc/src/tonic/mod.rs | 51 ++++++++++---- rpc/src/tonic/types.rs | 137 ++++++++++---------------------------- rpc/src/tonic/types/tx.rs | 108 ++++++++++++++++++++++++++++++ 6 files changed, 187 insertions(+), 114 deletions(-) create mode 100644 rpc/src/tonic/types/tx.rs diff --git a/Cargo.lock b/Cargo.lock index a9689361..9e882f60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -765,6 +765,7 @@ name = "celestia-proto" version = "0.4.1" dependencies = [ "celestia-tendermint-proto", + "cosmos-sdk-proto", "pbjson", "pbjson-build", "pbjson-types", @@ -1105,6 +1106,7 @@ checksum = "a4c1a5856db92cd90dddc955bce308703d3519fb33ae3d0b8f3658e9cfd05c3f" dependencies = [ "prost", "tendermint-proto", + "tonic", ] [[package]] diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 90bd021e..b95eaaca 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -17,6 +17,7 @@ categories = ["encoding", "cryptography::cryptocurrencies"] celestia-tendermint-proto.workspace = true prost.workspace = true prost-types.workspace = true +cosmos-sdk-proto = "0.26.0" serde = { version = "1.0.203", features = ["derive"] } tonic = "0.12.3" pbjson = "0.7.0" diff --git a/proto/build.rs b/proto/build.rs index 0074f498..6673379c 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -70,6 +70,8 @@ static EXTERN_PATHS: &[(&str, &str)] = &[ (".tendermint", "::celestia_tendermint_proto::v0_34"), (".google.protobuf.Timestamp", "::celestia_tendermint_proto::google::protobuf::Timestamp"), (".google.protobuf.Duration", "::celestia_tendermint_proto::google::protobuf::Duration"), + (".cosmos.tx.v1beta1.TxBody", "cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody"), + (".cosmos.tx.v1beta1.AuthInfo", "cosmos_sdk_proto::cosmos::tx::v1beta1::AuthInfo"), ]; const PROTO_FILES: &[&str] = &[ diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs index 6dd5b5f8..8b54a0d4 100644 --- a/rpc/src/tonic/mod.rs +++ b/rpc/src/tonic/mod.rs @@ -7,6 +7,7 @@ use celestia_proto::celestia::blob::v1 as blob; use celestia_proto::cosmos::auth::v1beta1 as auth; use celestia_proto::cosmos::base::node::v1beta1 as config; use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; +use celestia_proto::cosmos::tx::v1beta1 as tx; use cosmrs::ErrorReport; @@ -16,9 +17,12 @@ use tonic::Status; pub mod types; +use types::tx::{TxResponse, GetTxResponse}; use types::Block; use types::{FromGrpcResponse, IntoGrpcParam}; +use celestia_tendermint_proto::v0_34::types::BlobTx; + /* use celestia_proto::celestia::blob::v1::query_client::QueryClient; use celestia_tendermint_proto::v0_34::types::{ @@ -169,13 +173,8 @@ macro_rules! make_query { } */ -// macro takes a path to an appropriate generated gRPC method and a desired function signature. -// If parameters need to be converted, they should implement [`types::IntoGrpcParam`] into -// appropriate type and return type is converted using TryFrom -// -// One limitation is that it expects gRPC method to be provided in exactly 4 `::` delimited -// segments, requiring importing the proto module with `as`. This might be possible to overcome -// by rewriting the macro as tt-muncher, but it'd increase its complexity significantly + +/* macro_rules! make_method { ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $param:ty ) -> $ret:ty) => { pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { @@ -202,6 +201,29 @@ macro_rules! make_method { } }; } +*/ + +// macro takes a path to an appropriate generated gRPC method and a desired function signature. +// If parameters need to be converted, they should implement [`types::IntoGrpcParam`] into +// appropriate type and return type is converted using TryFrom +// +// One limitation is that it expects gRPC method to be provided in exactly 4 `::` delimited +// segments, requiring importing the proto module with `as`. This might be possible to overcome +// by rewriting the macro as tt-muncher, but it'd increase its complexity significantly +macro_rules! make_method2 { + ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $( $param:ident : $param_type:ty ),* ) -> $ret:ty) => { + pub async fn $name(&mut self, $($param: $param_type),*) -> Result<$ret, Error> { + let mut client = $path::$client_module::$client_struct::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let request = ::tonic::Request::new(( $($param),* ).into_parameter()); + let response = client.$method(request).await; + + Ok(response?.into_inner().try_from_response()?) + } + }; +} /* macro_rules! mm { @@ -230,15 +252,18 @@ where } } - make_method!(config::service_client::ServiceClient::config; get_min_gas_price() -> f64); + make_method2!(config::service_client::ServiceClient::config; get_min_gas_price() -> f64); - make_method!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Block); - make_method!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(i64) -> Block); + make_method2!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Block); + make_method2!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(height:i64) -> Block); // TODO get_node_info // make_method!(tendermint::service_client::ServiceClient::get_node_info; get_node_info() -> NodeInfo); - make_method!(blob::query_client::QueryClient::params; get_blob_params() -> BlobParams); + make_method2!(blob::query_client::QueryClient::params; get_blob_params() -> BlobParams); + + make_method2!(auth::query_client::QueryClient::params; get_auth_params() -> AuthParams); + make_method2!(auth::query_client::QueryClient::account; get_account(account: String) -> BaseAccount); - make_method!(auth::query_client::QueryClient::params; get_auth_params() -> AuthParams); - make_method!(auth::query_client::QueryClient::account; get_account(String) -> BaseAccount); + make_method2!(tx::service_client::ServiceClient::broadcast_tx; broadcast_tx(blob_tx: BlobTx, mode: tx::BroadcastMode) -> TxResponse); + make_method2!(tx::service_client::ServiceClient::get_tx; get_tx(hash: String) -> GetTxResponse); } diff --git a/rpc/src/tonic/types.rs b/rpc/src/tonic/types.rs index 85c3fdd5..5a3161c7 100644 --- a/rpc/src/tonic/types.rs +++ b/rpc/src/tonic/types.rs @@ -3,23 +3,33 @@ use prost::{Message, Name}; use celestia_types::auth::{AuthParams, BaseAccount}; use celestia_types::blob::BlobParams; -use celestia_proto::celestia::blob::v1::QueryParamsResponse as QueryBlobParamsResponse; -use celestia_proto::cosmos::auth::v1beta1::QueryParamsResponse as QueryAuthParamsResponse; +use celestia_proto::celestia::blob::v1::{ + QueryParamsRequest as QueryBlobParamsRequest, QueryParamsResponse as QueryBlobParamsResponse, +}; use celestia_proto::cosmos::auth::v1beta1::{ BaseAccount as RawBaseAccount, QueryAccountRequest, QueryAccountResponse, }; -use celestia_proto::cosmos::base::node::v1beta1::ConfigResponse; +use celestia_proto::cosmos::auth::v1beta1::{ + QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, +}; +use celestia_proto::cosmos::base::node::v1beta1::{ConfigRequest, ConfigResponse}; use celestia_proto::cosmos::base::tendermint::v1beta1::{ - GetBlockByHeightRequest, GetBlockByHeightResponse, GetLatestBlockResponse, + GetBlockByHeightRequest, GetBlockByHeightResponse, GetLatestBlockRequest, + GetLatestBlockResponse, }; +use celestia_proto::cosmos::tx::v1beta1::{BroadcastMode, BroadcastTxRequest, GetTxRequest}; use celestia_tendermint::block::Block as TendermintBlock; +use celestia_tendermint_proto::v0_34::types::BlobTx; + use cosmrs::crypto::PublicKey; use cosmrs::Any; use crate::tonic::Error; +pub mod tx; + pub struct Block(pub TendermintBlock); pub(crate) trait FromGrpcResponse { @@ -86,24 +96,6 @@ impl FromGrpcResponse for QueryAccountResponse { value: any_pub_key.value.to_vec(), })?; - /* - println!("key: {:#?}", raw_pub_key); - let any_pub_key = Any::decode(raw_pub_key.value).unwrap(); - - //if raw_pub_key.type_url != RawPublicKey::type_url() { return Err(Error::UnexpectedResponseType(raw_pub_key.type_url)); } - panic!("xxx"); - //let a : () = raw_pub_key.value; - let raw_pub_key = RawPublicKey::decode( &*raw_pub_key.value).unwrap(); - let pub_key = match raw_pub_key.sum.ok_or(Error::FailedToParseResponse)? { - Sum::Ed25519(bytes) => { - PublicKey::from_raw_ed25519(&bytes).ok_or(Error::FailedToParseResponse)? - } - #[cfg(feature = "secp256k1")] - Sum::Secp256k1(bytes) => { - PublicKey::from_raw_secp256k1(&bytes).ok_or(Error::FailedToParseResponse)? - } - }; - */ Ok(BaseAccount { address: base_account.address, pub_key, @@ -141,90 +133,33 @@ impl IntoGrpcParam for String { } } -/* -impl TryFrom for GasPrice { - type Error = Error; - - fn try_from(item: ConfigResponse) -> Result { - const UNITS_SUFFIX: &str = "utia"; - - let min_gas_price_with_suffix = item.minimum_gas_price; - let min_gas_price_str = min_gas_price_with_suffix - .strip_suffix(UNITS_SUFFIX) - .ok_or(Error::FailedToParseResponse)?; - let min_gas_price = min_gas_price_str - .parse::() - .map_err(|_| Error::FailedToParseResponse)?; - - Ok(GasPrice(min_gas_price)) - } -} - -impl TryFrom for Block { - type Error = Error; - - fn try_from(item: GetBlockByHeightResponse) -> Result { - Ok(Block( - item.block.ok_or(Error::FailedToParseResponse)?.try_into()?, - )) - } -} - -impl TryFrom for Block { - type Error = Error; - - fn try_from(item: GetLatestBlockResponse) -> Result { - Ok(Block( - item.block.ok_or(Error::FailedToParseResponse)?.try_into()?, - )) - } -} -*/ - -/* -impl TryFrom for BlobParams { - type Error = Error; - - fn try_from(item: QueryBlobParamsResponse) -> Result { - let params = item.params.ok_or(Error::FailedToParseResponse)?; - Ok(BlobParams { - gas_per_blob_byte: params.gas_per_blob_byte, - gov_max_square_size: params.gov_max_square_size, - }) +impl IntoGrpcParam for (BlobTx, BroadcastMode) { + fn into_parameter(self) -> BroadcastTxRequest { + let (blob_tx, mode) = self; + BroadcastTxRequest { + tx_bytes: blob_tx.encode_to_vec(), + mode: mode.into(), + } } } -impl TryFrom for AuthParams { - type Error = Error; - - fn try_from(item: QueryAuthParamsResponse) -> Result { - let params = item.params.ok_or(Error::FailedToParseResponse)?; - Ok(AuthParams { - max_memo_characters: params.max_memo_characters, - tx_sig_limit: params.tx_sig_limit, - tx_size_cost_per_byte: params.tx_size_cost_per_byte, - sig_verify_cost_ed25519: params.sig_verify_cost_ed25519, - sig_verify_cost_secp256k1: params.sig_verify_cost_secp256k1, - }) +impl IntoGrpcParam for String { + fn into_parameter(self) -> GetTxRequest { + GetTxRequest { hash: self } } } -impl TryFrom for BaseAccount { - type Error = Error; - - fn try_from(item: QueryAccountResponse) -> Result { - let account = item.account.ok_or(Error::FailedToParseResponse)?; - if account.type_url != RawBaseAccount::type_url() { - return Err(Error::UnexpectedResponseType(account.type_url)); +macro_rules! make_empty_params { + ($request_type:ident) => { + impl IntoGrpcParam<$request_type> for () { + fn into_parameter(self) -> $request_type { + $request_type {} + } } - let base_account = - RawBaseAccount::decode(&*account.value).map_err(|_| Error::FailedToParseResponse)?; - - Ok(Self { - address: base_account.address, - account_number: base_account.account_number, - sequence: base_account.sequence, - }) - } + }; } -*/ + +make_empty_params!(GetLatestBlockRequest); +make_empty_params!(ConfigRequest); +make_empty_params!(QueryAuthParamsRequest); +make_empty_params!(QueryBlobParamsRequest); diff --git a/rpc/src/tonic/types/tx.rs b/rpc/src/tonic/types/tx.rs new file mode 100644 index 00000000..a1123676 --- /dev/null +++ b/rpc/src/tonic/types/tx.rs @@ -0,0 +1,108 @@ +use cosmrs::Tx; + +use celestia_proto::cosmos::tx::v1beta1::{BroadcastTxResponse, GetTxResponse as RawGetTxResponse}; +use celestia_proto::cosmos::base::abci::v1beta1::{TxResponse as RawTxResponse}; + +use crate::tonic::types::FromGrpcResponse; +use crate::tonic::Error; + +pub struct TxResponse { + /// The block height + pub height: i64, + + /// The transaction hash. + pub txhash: String, + + /// Namespace for the Code + pub codespace: String, + + /// Response code. + pub code: u32, + + /// Result bytes, if any. + pub data: String, + + /// The output of the application's logger (raw string). May be + /// non-deterministic. + pub raw_log: String, + + // The output of the application's logger (typed). May be non-deterministic. + //#[serde(with = "crate::serializers::null_default")] + //pub logs: ::prost::alloc::vec::Vec, + /// Additional information. May be non-deterministic. + pub info: String, + + /// Amount of gas requested for transaction. + pub gas_wanted: i64, + + /// Amount of gas consumed by transaction. + pub gas_used: i64, + + // The request transaction bytes. + //#[serde(with = "crate::serializers::option_any")] + //pub tx: ::core::option::Option<::pbjson_types::Any>, + /// Time of the previous block. For heights > 1, it's the weighted median of + /// the timestamps of the valid votes in the block.LastCommit. For height == 1, + /// it's genesis time. + pub timestamp: String, + // Events defines all the events emitted by processing a transaction. Note, + // these events include those emitted by processing all the messages and those + // emitted from the ante. Whereas Logs contains the events, with + // additional metadata, emitted only by processing the messages. + // + // Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + //#[serde(with = "crate::serializers::null_default")] + //pub events: ::prost::alloc::vec::Vec< ::celestia_tendermint_proto::v0_34::abci::Event, >, +} + +pub struct GetTxResponse { + pub tx: Tx, + + pub tx_response: TxResponse, +} + +impl TryFrom for TxResponse { + type Error = Error; + + fn try_from(response: RawTxResponse) -> Result { + // TODO: add missing fields with conversion + Ok(TxResponse { + height: response.height, + txhash: response.txhash, + codespace: response.codespace, + code: response.code, + data: response.data, + raw_log: response.raw_log, + //logs: response.logs + info: response.info, + gas_wanted: response.gas_wanted, + gas_used: response.gas_used, + //tx: response.tx + timestamp: response.timestamp, + //events: response.events + }) + } +} + +impl FromGrpcResponse for BroadcastTxResponse { + fn try_from_response(self) -> Result { + self.tx_response.ok_or(Error::FailedToParseResponse)?.try_into() + } +} + +impl FromGrpcResponse for RawGetTxResponse { + fn try_from_response(self) -> Result { + let tx_response = self.tx_response.ok_or(Error::FailedToParseResponse)?.try_into()?; + let tx = self.tx.ok_or(Error::FailedToParseResponse)?; + let cosmos_tx = Tx { + body: tx.body.ok_or(Error::FailedToParseResponse)?.try_into()?, + auth_info: tx.auth_info.ok_or(Error::FailedToParseResponse)?.try_into()?, + signatures: tx.signatures, + }; + + Ok(GetTxResponse { + tx: cosmos_tx, + tx_response, + }) + } +} From 07c67b46364f9bf7702316e96fae7779a6c0a3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 30 Oct 2024 10:16:50 +0100 Subject: [PATCH 06/56] smh fmt --- rpc/src/tonic/mod.rs | 3 +-- rpc/src/tonic/types/tx.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs index 8b54a0d4..51ada230 100644 --- a/rpc/src/tonic/mod.rs +++ b/rpc/src/tonic/mod.rs @@ -17,7 +17,7 @@ use tonic::Status; pub mod types; -use types::tx::{TxResponse, GetTxResponse}; +use types::tx::{GetTxResponse, TxResponse}; use types::Block; use types::{FromGrpcResponse, IntoGrpcParam}; @@ -173,7 +173,6 @@ macro_rules! make_query { } */ - /* macro_rules! make_method { ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $param:ty ) -> $ret:ty) => { diff --git a/rpc/src/tonic/types/tx.rs b/rpc/src/tonic/types/tx.rs index a1123676..07b90cac 100644 --- a/rpc/src/tonic/types/tx.rs +++ b/rpc/src/tonic/types/tx.rs @@ -1,7 +1,7 @@ use cosmrs::Tx; +use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; use celestia_proto::cosmos::tx::v1beta1::{BroadcastTxResponse, GetTxResponse as RawGetTxResponse}; -use celestia_proto::cosmos::base::abci::v1beta1::{TxResponse as RawTxResponse}; use crate::tonic::types::FromGrpcResponse; use crate::tonic::Error; @@ -86,17 +86,25 @@ impl TryFrom for TxResponse { impl FromGrpcResponse for BroadcastTxResponse { fn try_from_response(self) -> Result { - self.tx_response.ok_or(Error::FailedToParseResponse)?.try_into() + self.tx_response + .ok_or(Error::FailedToParseResponse)? + .try_into() } } impl FromGrpcResponse for RawGetTxResponse { fn try_from_response(self) -> Result { - let tx_response = self.tx_response.ok_or(Error::FailedToParseResponse)?.try_into()?; + let tx_response = self + .tx_response + .ok_or(Error::FailedToParseResponse)? + .try_into()?; let tx = self.tx.ok_or(Error::FailedToParseResponse)?; let cosmos_tx = Tx { body: tx.body.ok_or(Error::FailedToParseResponse)?.try_into()?, - auth_info: tx.auth_info.ok_or(Error::FailedToParseResponse)?.try_into()?, + auth_info: tx + .auth_info + .ok_or(Error::FailedToParseResponse)? + .try_into()?, signatures: tx.signatures, }; From 4a98ffd3d9db126c53579d473a312304c5fc4629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 30 Oct 2024 13:24:09 +0100 Subject: [PATCH 07/56] patch --- Cargo.lock | 2 ++ Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e882f60..4570eb51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -812,6 +812,7 @@ dependencies = [ [[package]] name = "celestia-tendermint" version = "0.32.2" +source = "git+https://github.com/eigerco/celestia-tendermint-rs/?branch=chore%2Fprost-0.13.3#7c77122234fcc8473b99345ba4fe943d89438fbd" dependencies = [ "bytes", "celestia-tendermint-proto", @@ -842,6 +843,7 @@ dependencies = [ [[package]] name = "celestia-tendermint-proto" version = "0.32.2" +source = "git+https://github.com/eigerco/celestia-tendermint-rs/?branch=chore%2Fprost-0.13.3#7c77122234fcc8473b99345ba4fe943d89438fbd" dependencies = [ "bytes", "flex-error", diff --git a/Cargo.toml b/Cargo.toml index 75b5346a..6329d591 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ prost-types = "0.13.3" # Uncomment to apply local changes #beetswap = { path = "../beetswap" } #blockstore = { path = "../blockstore" } -celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } -celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } +celestia-tendermint = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } +celestia-tendermint-proto = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } #nmt-rs = { path = "../nmt-rs" } #libp2p = { path = "../../rust-libp2p/libp2p" } #libp2p-core = { path = "../../rust-libp2p/core" } From d967c5cfd336afbcd3de944329763a7f7b77681d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 30 Oct 2024 13:56:20 +0100 Subject: [PATCH 08/56] fix wasm deps --- Cargo.lock | 1 - proto/Cargo.toml | 13 ++++++++----- proto/build.rs | 1 - rpc/Cargo.toml | 5 ++--- rpc/src/lib.rs | 2 +- rpc/tests/utils/mod.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4570eb51..834680ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,6 @@ checksum = "a4c1a5856db92cd90dddc955bce308703d3519fb33ae3d0b8f3658e9cfd05c3f" dependencies = [ "prost", "tendermint-proto", - "tonic", ] [[package]] diff --git a/proto/Cargo.toml b/proto/Cargo.toml index b95eaaca..a8282a31 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -17,18 +17,22 @@ categories = ["encoding", "cryptography::cryptocurrencies"] celestia-tendermint-proto.workspace = true prost.workspace = true prost-types.workspace = true -cosmos-sdk-proto = "0.26.0" +cosmos-sdk-proto = { version = "0.26.0", default-features = false } serde = { version = "1.0.203", features = ["derive"] } -tonic = "0.12.3" pbjson = "0.7.0" pbjson-types = "0.7.0" +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +tonic = { version = "0.12.3", optional = true } + +[target.'cfg(not(target_arch = "wasm32"))'.build-dependencies] +tonic-build = { version = "0.12.3", optional = true } + [build-dependencies] prost-build.workspace = true prost-types.workspace = true protox = "0.7.1" tempfile = "3.13.0" -tonic-build = "0.12.3" pbjson-build = "0.7.0" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] @@ -38,5 +42,4 @@ wasm-bindgen-test = "0.3.42" serde_json = "1.0.117" [features] -default = ["tonic"] -tonic = [] +tonic = ["dep:tonic", "dep:tonic-build"] diff --git a/proto/build.rs b/proto/build.rs index 6673379c..df3897f1 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -99,7 +99,6 @@ const PROTO_FILES: &[&str] = &[ "vendor/tendermint/types/types.proto", ]; -#[cfg(feature = "tonic")] const INCLUDES: &[&str] = &["vendor", "vendor/nmt"]; fn main() { diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 10c06f9e..47a43f40 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -31,12 +31,12 @@ futures = "0.3.31" jsonrpsee = { version = "0.24.2", features = ["client-core", "macros"] } serde = { version = "1.0.203", features = ["derive"] } thiserror = "1.0.61" -tonic = { version = "0.12.3", optional = true } tracing = "0.1.40" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] http = "1.1.0" jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } +tonic = { version = "0.12.3", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] libp2p = { workspace = true, features = [ @@ -50,7 +50,6 @@ nmt-rs.workspace = true anyhow = "1.0.86" dotenvy = "0.15.7" rand = "0.8.5" -tonic = "0.12.3" tokio = { version = "1.38.0", features = ["rt", "macros"] } tracing = "0.1.40" @@ -60,7 +59,7 @@ wasm-bindgen-test = "0.3.42" [features] default = ["p2p", "secp256k1"] -tonic_grpc = ["celestia-proto/tonic", "dep:tonic"] +tonic = ["celestia-proto/tonic", "dep:tonic"] p2p = ["celestia-types/p2p"] wasm-bindgen = ["celestia-types/wasm-bindgen", "jsonrpsee/wasm-client"] secp256k1 = ["celestia-tendermint/secp256k1"] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index fd211988..620f32a6 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -9,7 +9,7 @@ mod header; mod p2p; pub mod share; mod state; -#[cfg(feature = "tonic_grpc")] +#[cfg(all(feature = "tonic", not(target_arch = "wasm32")))] pub mod tonic; pub use crate::blob::BlobClient; diff --git a/rpc/tests/utils/mod.rs b/rpc/tests/utils/mod.rs index 3c3b1c8e..a4f0fb8c 100644 --- a/rpc/tests/utils/mod.rs +++ b/rpc/tests/utils/mod.rs @@ -6,7 +6,7 @@ use rand::{Rng, RngCore}; pub mod client; #[cfg(feature = "p2p")] pub mod tiny_node; -#[cfg(feature = "tonic_grpc")] +#[cfg(feature = "tonic")] pub mod tonic_client; fn ns_to_u128(ns: Namespace) -> u128 { From ca03d4d3fc0174f41c8cfc88e951aee379275e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 30 Oct 2024 14:40:12 +0100 Subject: [PATCH 09/56] fix wasm --- proto/Cargo.toml | 5 ++++- proto/build.rs | 3 +++ proto/src/serializers.rs | 1 + proto/src/serializers/option_any.rs | 5 +---- rpc/tests/tonic.rs | 2 ++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/proto/Cargo.toml b/proto/Cargo.toml index a8282a31..8851940b 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -21,9 +21,12 @@ cosmos-sdk-proto = { version = "0.26.0", default-features = false } serde = { version = "1.0.203", features = ["derive"] } pbjson = "0.7.0" pbjson-types = "0.7.0" +tonic = { version = "0.12.3", optional = true, default-features = false, features = [ + "codegen", "prost" +]} [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tonic = { version = "0.12.3", optional = true } +tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "transport" ] } [target.'cfg(not(target_arch = "wasm32"))'.build-dependencies] tonic-build = { version = "0.12.3", optional = true } diff --git a/proto/build.rs b/proto/build.rs index df3897f1..73927f9c 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -11,6 +11,7 @@ const BASE64STRING: &str = const QUOTED: &str = r#"#[serde(with = "celestia_tendermint_proto::serializers::from_str")]"#; const VEC_BASE64STRING: &str = r#"#[serde(with = "celestia_tendermint_proto::serializers::bytes::vec_base64string")]"#; +#[cfg(not(feature = "tonic"))] const OPTION_ANY: &str = r#"#[serde(with = "crate::serializers::option_any")]"#; const OPTION_TIMESTAMP: &str = r#"#[serde(with = "crate::serializers::option_timestamp")]"#; const NULL_DEFAULT: &str = r#"#[serde(with = "crate::serializers::null_default")]"#; @@ -52,6 +53,7 @@ static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ (".celestia.da.DataAvailabilityHeader.row_roots", VEC_BASE64STRING), (".celestia.da.DataAvailabilityHeader.column_roots", VEC_BASE64STRING), + #[cfg(not(feature = "tonic"))] (".cosmos.base.abci.v1beta1.TxResponse.tx", OPTION_ANY), (".cosmos.base.abci.v1beta1.TxResponse.logs", NULL_DEFAULT), (".cosmos.base.abci.v1beta1.TxResponse.events", NULL_DEFAULT), @@ -146,6 +148,7 @@ fn tonic_build(fds: FileDescriptorSet) { let mut tonic_config = tonic_build::configure() .build_client(true) .build_server(false) + .client_mod_attribute(".", "#[cfg(not(target_arch=\"wasm32\"))]") .use_arc_self(true) // override prost-types with pbjson-types .compile_well_known_types(true) diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index d8119ab1..3c436ffd 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -1,5 +1,6 @@ //! Custom serializers to be used with [`serde`]. pub mod null_default; +#[cfg(not(feature = "tonic"))] pub mod option_any; pub mod option_timestamp; diff --git a/proto/src/serializers/option_any.rs b/proto/src/serializers/option_any.rs index 8172e632..7e3fed72 100644 --- a/proto/src/serializers/option_any.rs +++ b/proto/src/serializers/option_any.rs @@ -1,8 +1,5 @@ //! [`serde`] serializer for the optional [`Any`]. -#[cfg(feature = "tonic")] -use pbjson_types::Any; -#[cfg(not(feature = "tonic"))] use prost_types::Any; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -89,7 +86,7 @@ mod tests { serde_json::from_str(r#"{"tx":{"type_url":"abc","value":"AQID"}}"#).unwrap(); let tx = msg.tx.unwrap(); assert_eq!(tx.type_url, "abc"); - assert_eq!(tx.value.as_ref(), &[1, 2, 3]) + assert_eq!(tx.value.as_ref(), [1, 2, 3]) } #[test] diff --git a/rpc/tests/tonic.rs b/rpc/tests/tonic.rs index 16cfe834..76c8d33e 100644 --- a/rpc/tests/tonic.rs +++ b/rpc/tests/tonic.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "tonic")] + pub mod utils; use crate::utils::client::AuthLevel; From 2ae6bf134f5591f13068c030b3140f0f207161b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 30 Oct 2024 15:03:33 +0100 Subject: [PATCH 10/56] fix docs --- types/src/auth.rs | 15 +++++++++++++++ types/src/blob.rs | 3 +++ 2 files changed, 18 insertions(+) diff --git a/types/src/auth.rs b/types/src/auth.rs index dae8b4cf..88bbfe6b 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -1,18 +1,33 @@ +//! TODO: + use cosmrs::crypto::PublicKey; +/// Params defines the parameters for the auth module. #[derive(Debug)] pub struct AuthParams { + /// Maximum number of memo characters pub max_memo_characters: u64, + /// Maximum nubmer of signatures pub tx_sig_limit: u64, + /// Cost per transaction byte pub tx_size_cost_per_byte: u64, + /// Cost to verify ed25519 signature pub sig_verify_cost_ed25519: u64, + /// Cost to verify secp255k1 signature pub sig_verify_cost_secp256k1: u64, } +/// BaseAccount defines a base account type. It contains all the necessary fields +/// for basic account functionality. Any custom account type should extend this +/// type for additional functionality (e.g. vesting). #[derive(Debug)] pub struct BaseAccount { + /// hex encoded hash address of the account pub address: String, + /// Public key associated with the account pub pub_key: PublicKey, + /// TODO: pub account_number: u64, + /// TODO: pub sequence: u64, } diff --git a/types/src/blob.rs b/types/src/blob.rs index da003c90..c7b622ed 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -37,9 +37,12 @@ pub struct Blob { pub index: Option, } +/// Params defines the parameters for the blob module. #[derive(Debug)] pub struct BlobParams { + /// Gas cost per blob byte pub gas_per_blob_byte: u32, + /// Max square size pub gov_max_square_size: u64, } From ee3ebcdcb8e5670076f45cb0c283075ea15e33f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 31 Oct 2024 08:25:44 +0100 Subject: [PATCH 11/56] new wasm-pack? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f74e593..bcb99a3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - name: Install wasm-pack uses: taiki-e/cache-cargo-install-action@v1 with: - tool: wasm-pack@0.12.1 + tool: wasm-pack@0.13.1 - name: Install chromedriver # we don't specify chrome version to match whatever's installed uses: nanasess/setup-chromedriver@v2 From 6b60e86c83fa5f2c0f3dd620051af18b08c73548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Mon, 4 Nov 2024 10:00:58 +0100 Subject: [PATCH 12/56] fiddling --- .github/workflows/ci.yml | 4 +-- Cargo.lock | 1 + ci/docker-compose.yml | 2 ++ ci/run-validator.sh | 1 + rpc/Cargo.toml | 1 + rpc/src/tonic/mod.rs | 2 ++ rpc/src/tonic/types.rs | 61 +++++++++++++++++++++------------ rpc/tests/tonic.rs | 4 +++ rpc/tests/utils/tonic_client.rs | 5 ++- 9 files changed, 54 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcb99a3d..2b83274b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,10 +72,10 @@ jobs: run: cargo build --all --target=wasm32-unknown-unknown --all-features - name: Test proto crate - run: wasm-pack test --node proto + run: wasm-pack test --headless --chrome proto - name: Test types crate - run: wasm-pack test --node types --features=wasm-bindgen + run: wasm-pack test --headless --chrome types --features=wasm-bindgen - name: Test node crate run: wasm-pack test --headless --chrome node diff --git a/Cargo.lock b/Cargo.lock index 834680ed..70cdae91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -799,6 +799,7 @@ dependencies = [ "jsonrpsee", "libp2p", "nmt-rs", + "pbjson-types", "prost", "rand", "serde", diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml index 69f93e6f..b24c41f9 100644 --- a/ci/docker-compose.yml +++ b/ci/docker-compose.yml @@ -8,6 +8,8 @@ services: environment: # provide amount of bridge nodes to provision (default: 1) - BRIDGE_COUNT=2 + ports: + - 19090:9090 volumes: - credentials:/credentials - genesis:/genesis diff --git a/ci/run-validator.sh b/ci/run-validator.sh index 573f1d10..47b6d71b 100755 --- a/ci/run-validator.sh +++ b/ci/run-validator.sh @@ -117,6 +117,7 @@ setup_private_validator() { celestia-appd keys add "$NODE_NAME" --keyring-backend="test" validator_addr="$(celestia-appd keys show "$NODE_NAME" -a --keyring-backend="test")" # Create a validator's genesis account for the genesis.json with an initial bag of coins + echo "VALIDATOR ADDR: $validator_addr" celestia-appd add-genesis-account "$validator_addr" "$VALIDATOR_COINS" # Generate a genesis transaction that creates a validator with a self-delegation celestia-appd gentx "$NODE_NAME" 5000000000utia \ diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 47a43f40..c3b82c38 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -36,6 +36,7 @@ tracing = "0.1.40" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] http = "1.1.0" jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } +pbjson-types = "0.7.0" tonic = { version = "0.12.3", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs index 51ada230..a9efd41e 100644 --- a/rpc/src/tonic/mod.rs +++ b/rpc/src/tonic/mod.rs @@ -262,6 +262,8 @@ where make_method2!(auth::query_client::QueryClient::params; get_auth_params() -> AuthParams); make_method2!(auth::query_client::QueryClient::account; get_account(account: String) -> BaseAccount); + // TODO: pagination? + make_method2!(auth::query_client::QueryClient::accounts; get_accounts() -> Vec); make_method2!(tx::service_client::ServiceClient::broadcast_tx; broadcast_tx(blob_tx: BlobTx, mode: tx::BroadcastMode) -> TxResponse); make_method2!(tx::service_client::ServiceClient::get_tx; get_tx(hash: String) -> GetTxResponse); diff --git a/rpc/src/tonic/types.rs b/rpc/src/tonic/types.rs index 5a3161c7..ec4ecd7a 100644 --- a/rpc/src/tonic/types.rs +++ b/rpc/src/tonic/types.rs @@ -7,7 +7,8 @@ use celestia_proto::celestia::blob::v1::{ QueryParamsRequest as QueryBlobParamsRequest, QueryParamsResponse as QueryBlobParamsResponse, }; use celestia_proto::cosmos::auth::v1beta1::{ - BaseAccount as RawBaseAccount, QueryAccountRequest, QueryAccountResponse, + BaseAccount as RawBaseAccount, QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest, + QueryAccountsResponse, }; use celestia_proto::cosmos::auth::v1beta1::{ QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, @@ -78,30 +79,40 @@ impl FromGrpcResponse for QueryAuthParamsResponse { }) } } +fn account_from_any(any: pbjson_types::Any) -> Result { + if any.type_url != RawBaseAccount::type_url() { + return Err(Error::UnexpectedResponseType(any.type_url)); + } + let base_account = + RawBaseAccount::decode(&*any.value).map_err(|_| Error::FailedToParseResponse)?; + + let any_pub_key = base_account.pub_key.ok_or(Error::FailedToParseResponse)?; + // cosmrs has different Any type than pbjson_types Any + let pub_key = PublicKey::try_from(Any { + type_url: any_pub_key.type_url, + value: any_pub_key.value.to_vec(), + })?; + + Ok(BaseAccount { + address: base_account.address, + pub_key, + account_number: base_account.account_number, + sequence: base_account.sequence, + }) +} impl FromGrpcResponse for QueryAccountResponse { fn try_from_response(self) -> Result { - let account = self.account.ok_or(Error::FailedToParseResponse)?; - if account.type_url != RawBaseAccount::type_url() { - return Err(Error::UnexpectedResponseType(account.type_url)); - } - println!("ACTT: {:#?}", account.value); - let base_account = - RawBaseAccount::decode(&*account.value).map_err(|_| Error::FailedToParseResponse)?; - - let any_pub_key = base_account.pub_key.ok_or(Error::FailedToParseResponse)?; - // cosmrs has different Any type than pbjson_types Any - let pub_key = PublicKey::try_from(Any { - type_url: any_pub_key.type_url, - value: any_pub_key.value.to_vec(), - })?; - - Ok(BaseAccount { - address: base_account.address, - pub_key, - account_number: base_account.account_number, - sequence: base_account.sequence, - }) + account_from_any(self.account.ok_or(Error::FailedToParseResponse)?) + } +} + +impl FromGrpcResponse> for QueryAccountsResponse { + fn try_from_response(self) -> Result, Error> { + self.accounts + .into_iter() + .map(|acct| account_from_any(acct)) + .collect() } } @@ -149,6 +160,12 @@ impl IntoGrpcParam for String { } } +impl IntoGrpcParam for () { + fn into_parameter(self) -> QueryAccountsRequest { + QueryAccountsRequest { pagination: None } + } +} + macro_rules! make_empty_params { ($request_type:ident) => { impl IntoGrpcParam<$request_type> for () { diff --git a/rpc/tests/tonic.rs b/rpc/tests/tonic.rs index 76c8d33e..290558e3 100644 --- a/rpc/tests/tonic.rs +++ b/rpc/tests/tonic.rs @@ -27,6 +27,10 @@ async fn get_block() { async fn get_account() { let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + let accounts = client.get_accounts().await.unwrap(); + + println!("first account : {:?}", accounts.first()); + let acct = client .get_account("celestia1p3ucd3ptpw902fluyjzhq3ffgq4ntddaf0pdta".to_string()) .await diff --git a/rpc/tests/utils/tonic_client.rs b/rpc/tests/utils/tonic_client.rs index 2f483845..7a3e51d9 100644 --- a/rpc/tests/utils/tonic_client.rs +++ b/rpc/tests/utils/tonic_client.rs @@ -9,9 +9,8 @@ use tonic::{Request, Status}; use celestia_rpc::tonic::GrpcClient; -//const CELESTIA_GRPC_URL: &str = "http://localhost:9090"; -//const CELESTIA_GRPC_URL: &str = "https://public-celestia-consensus.numia.xyz:9090"; -const CELESTIA_GRPC_URL: &str = "https://rpc.celestia.pops.one:9090"; +const CELESTIA_GRPC_URL: &str = "http://localhost:19090"; +//const CELESTIA_GRPC_URL: &str = "https://rpc.celestia.pops.one:9090"; #[derive(Clone)] pub struct TestAuthInterceptor { From a299aefd9c28a011304f6846e1184b4fd6bc22ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 5 Nov 2024 10:03:21 +0100 Subject: [PATCH 13/56] tonic crate --- Cargo.lock | 19 +- Cargo.toml | 2 +- rpc/Cargo.toml | 2 - rpc/src/lib.rs | 2 - rpc/src/tonic/mod.rs | 270 ------------------ rpc/tests/utils/mod.rs | 2 - tonic/Cargo.toml | 42 +++ tonic/src/client.rs | 75 +++++ tonic/src/error.rs | 29 ++ tonic/src/lib.rs | 8 + {rpc/src/tonic => tonic/src}/tendermint.rs | 0 {rpc/src/tonic => tonic/src}/types.rs | 2 +- tonic/src/types/pagination.rs | 30 ++ {rpc/src/tonic => tonic/src}/types/tx.rs | 4 +- {rpc => tonic}/tests/tonic.rs | 11 +- .../tonic_client.rs => tonic/tests/utils.rs | 14 +- 16 files changed, 218 insertions(+), 294 deletions(-) delete mode 100644 rpc/src/tonic/mod.rs create mode 100644 tonic/Cargo.toml create mode 100644 tonic/src/client.rs create mode 100644 tonic/src/error.rs create mode 100644 tonic/src/lib.rs rename {rpc/src/tonic => tonic/src}/tendermint.rs (100%) rename {rpc/src/tonic => tonic/src}/types.rs (99%) create mode 100644 tonic/src/types/pagination.rs rename {rpc/src/tonic => tonic/src}/types/tx.rs (98%) rename {rpc => tonic}/tests/tonic.rs (70%) rename rpc/tests/utils/tonic_client.rs => tonic/tests/utils.rs (78%) diff --git a/Cargo.lock b/Cargo.lock index 70cdae91..51e8cc80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -805,7 +805,6 @@ dependencies = [ "serde", "thiserror", "tokio", - "tonic", "tracing", "wasm-bindgen-test", ] @@ -858,6 +857,24 @@ dependencies = [ "time", ] +[[package]] +name = "celestia-tonic" +version = "0.1.0" +dependencies = [ + "anyhow", + "celestia-proto", + "celestia-tendermint", + "celestia-tendermint-proto", + "celestia-types", + "cosmrs", + "dotenvy", + "pbjson-types", + "prost", + "thiserror", + "tokio", + "tonic", +] + [[package]] name = "celestia-types" version = "0.6.1" diff --git a/Cargo.toml b/Cargo.toml index 6329d591..35870b9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["cli", "node", "node-wasm", "proto", "rpc", "types"] +members = ["cli", "node", "node-wasm", "proto", "rpc", "tonic", "types"] [workspace.dependencies] blockstore = "0.7.0" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index c3b82c38..c96e048a 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -37,7 +37,6 @@ tracing = "0.1.40" http = "1.1.0" jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } pbjson-types = "0.7.0" -tonic = { version = "0.12.3", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] libp2p = { workspace = true, features = [ @@ -60,7 +59,6 @@ wasm-bindgen-test = "0.3.42" [features] default = ["p2p", "secp256k1"] -tonic = ["celestia-proto/tonic", "dep:tonic"] p2p = ["celestia-types/p2p"] wasm-bindgen = ["celestia-types/wasm-bindgen", "jsonrpsee/wasm-client"] secp256k1 = ["celestia-tendermint/secp256k1"] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 620f32a6..bf02329a 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -9,8 +9,6 @@ mod header; mod p2p; pub mod share; mod state; -#[cfg(all(feature = "tonic", not(target_arch = "wasm32")))] -pub mod tonic; pub use crate::blob::BlobClient; #[cfg(any( diff --git a/rpc/src/tonic/mod.rs b/rpc/src/tonic/mod.rs deleted file mode 100644 index a9efd41e..00000000 --- a/rpc/src/tonic/mod.rs +++ /dev/null @@ -1,270 +0,0 @@ -use std::convert::Infallible; - -use celestia_types::auth::{AuthParams, BaseAccount}; -use celestia_types::blob::BlobParams; - -use celestia_proto::celestia::blob::v1 as blob; -use celestia_proto::cosmos::auth::v1beta1 as auth; -use celestia_proto::cosmos::base::node::v1beta1 as config; -use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; -use celestia_proto::cosmos::tx::v1beta1 as tx; - -use cosmrs::ErrorReport; - -use tonic::service::Interceptor; -use tonic::transport::Channel; -use tonic::Status; - -pub mod types; - -use types::tx::{GetTxResponse, TxResponse}; -use types::Block; -use types::{FromGrpcResponse, IntoGrpcParam}; - -use celestia_tendermint_proto::v0_34::types::BlobTx; - -/* -use celestia_proto::celestia::blob::v1::query_client::QueryClient; -use celestia_tendermint_proto::v0_34::types::{ - Blob as PbBlob, - BlobTx, -}; - -use celestia_proto::{ - celestia::blob::v1::{ - query_client::QueryClient as BlobQueryClient, - MsgPayForBlobs, - QueryParamsRequest as QueryBlobParamsRequest, - Params as BlobParams, - }, - cosmos::{ - auth::v1beta1::{ - query_client::QueryClient as AuthQueryClient, - BaseAccount, - Params as AuthParams, - QueryAccountRequest, - QueryAccountResponse, - QueryParamsRequest as QueryAuthParamsRequest, - }, - base::{ - node::v1beta1::{ - service_client::ServiceClient as MinGasPriceClient, - ConfigRequest as MinGasPriceRequest, - ConfigResponse as MinGasPriceResponse, - }, - tendermint::v1beta1::{ - service_client::ServiceClient as TendermintServiceClient, - GetNodeInfoRequest, - }, - v1beta1::Coin, - }, - crypto::secp256k1, - tx::v1beta1::{ - mode_info::{ - Single, - Sum, - }, - service_client::ServiceClient as TxClient, - AuthInfo, - BroadcastMode, - BroadcastTxRequest, - BroadcastTxResponse, - Fee, - GetTxRequest, - GetTxResponse, - ModeInfo, - SignDoc, - SignerInfo, - Tx, - TxBody, - }, - }, -}; -*/ - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error(transparent)] - TonicError(#[from] Status), - - #[error(transparent)] - TendermintError(#[from] celestia_tendermint::Error), - - #[error(transparent)] - CosmrsError(#[from] ErrorReport), - - #[error(transparent)] - TendermintProtoError(#[from] celestia_tendermint_proto::Error), - - #[error("Failed to parse response")] - FailedToParseResponse, - - #[error("Unexpected response type")] - UnexpectedResponseType(String), - - /// Unreachable. Added to appease try_into conversion for GrpcClient method macro - #[error(transparent)] - Infallible(#[from] Infallible), -} - -pub struct GrpcClient -where - I: Interceptor, -{ - grpc_channel: Channel, - auth_interceptor: I, -} - -/* -macro_rules! make_method { - ($name:ident, $service_client:ident, $method:ident, $param:ty, $ret:ty) => { - pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { - let mut service_client = - $service_client::service_client::ServiceClient::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = service_client.$method(param).await; - - Ok(response?.into_inner().try_into()?) - } - }; - ($name:ident, $service_client:ident, $method:ident, $ret:ty) => { - pub async fn $name(&mut self) -> Result<$ret, Error> { - let mut service_client = - $service_client::service_client::ServiceClient::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = service_client - .$method(::tonic::Request::new(Default::default())) - .await; - - Ok(response?.into_inner().try_into()?) - } - }; -} - -macro_rules! make_query { - ($name:ident, $service_client:ident, $method:ident, $param:ty, $ret:ty) => { - pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { - let mut client = $service_client::query_client::QueryClient::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = client.$method(param).await; - - Ok(response?.into_inner().try_into()?) - } - }; - ($name:ident, $service_client:ident, $method:ident, $ret:ty) => { - pub async fn $name(&mut self) -> Result<$ret, Error> { - let mut client = $service_client::query_client::QueryClient::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = client - .$method(::tonic::Request::new(Default::default())) - .await; - - Ok(response?.into_inner().try_into()?) - } - }; -} -*/ - -/* -macro_rules! make_method { - ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $param:ty ) -> $ret:ty) => { - pub async fn $name(&mut self, param: $param) -> Result<$ret, Error> { - let mut client = $path::$client_module::$client_struct::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = client.$method(param.into_parameter()).await; - - Ok(response?.into_inner().try_from_response()?) - } - }; - ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident () -> $ret:ty) => { - pub async fn $name(&mut self) -> Result<$ret, Error> { - let mut client = $path::$client_module::$client_struct::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let response = client - .$method(::tonic::Request::new(Default::default())) - .await; - - Ok(response?.into_inner().try_from_response()?) - } - }; -} -*/ - -// macro takes a path to an appropriate generated gRPC method and a desired function signature. -// If parameters need to be converted, they should implement [`types::IntoGrpcParam`] into -// appropriate type and return type is converted using TryFrom -// -// One limitation is that it expects gRPC method to be provided in exactly 4 `::` delimited -// segments, requiring importing the proto module with `as`. This might be possible to overcome -// by rewriting the macro as tt-muncher, but it'd increase its complexity significantly -macro_rules! make_method2 { - ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $( $param:ident : $param_type:ty ),* ) -> $ret:ty) => { - pub async fn $name(&mut self, $($param: $param_type),*) -> Result<$ret, Error> { - let mut client = $path::$client_module::$client_struct::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let request = ::tonic::Request::new(( $($param),* ).into_parameter()); - let response = client.$method(request).await; - - Ok(response?.into_inner().try_from_response()?) - } - }; -} - -/* -macro_rules! mm { - ($prefix:ident $(:: $tail:path)+; $name:ident ( $param:ty ) -> $ret:ty ) => { - mm!($prefix :: ; $($tail),* | $name($param) -> $ret); - }; - - ($($module:ident ::)+ ; $head:ident, $($tail:ident),+ | $name:ident ($param:ty) -> $ret:ty ) => { - - }; - - //(@resolved $module:path, $client_module:ident, $client_struct:ident, $method:ident; ) -} - -mm!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(i64) -> Block); -*/ - -impl GrpcClient -where - I: Interceptor + Clone, -{ - pub fn new(grpc_channel: Channel, auth_interceptor: I) -> Self { - Self { - grpc_channel, - auth_interceptor, - } - } - - make_method2!(config::service_client::ServiceClient::config; get_min_gas_price() -> f64); - - make_method2!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Block); - make_method2!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(height:i64) -> Block); - // TODO get_node_info - // make_method!(tendermint::service_client::ServiceClient::get_node_info; get_node_info() -> NodeInfo); - - make_method2!(blob::query_client::QueryClient::params; get_blob_params() -> BlobParams); - - make_method2!(auth::query_client::QueryClient::params; get_auth_params() -> AuthParams); - make_method2!(auth::query_client::QueryClient::account; get_account(account: String) -> BaseAccount); - // TODO: pagination? - make_method2!(auth::query_client::QueryClient::accounts; get_accounts() -> Vec); - - make_method2!(tx::service_client::ServiceClient::broadcast_tx; broadcast_tx(blob_tx: BlobTx, mode: tx::BroadcastMode) -> TxResponse); - make_method2!(tx::service_client::ServiceClient::get_tx; get_tx(hash: String) -> GetTxResponse); -} diff --git a/rpc/tests/utils/mod.rs b/rpc/tests/utils/mod.rs index a4f0fb8c..8755e6ed 100644 --- a/rpc/tests/utils/mod.rs +++ b/rpc/tests/utils/mod.rs @@ -6,8 +6,6 @@ use rand::{Rng, RngCore}; pub mod client; #[cfg(feature = "p2p")] pub mod tiny_node; -#[cfg(feature = "tonic")] -pub mod tonic_client; fn ns_to_u128(ns: Namespace) -> u128 { let mut bytes = [0u8; 16]; diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml new file mode 100644 index 00000000..a6421efa --- /dev/null +++ b/tonic/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "celestia-tonic" +version = "0.1.0" +edition = "2021" +license = "Apache-2.0" +description = "A collection of traits for interacting with Celestia validator nodes gRPC" +authors = ["Eiger "] +homepage = "https://www.eiger.co" +repository = "https://github.com/eigerco/lumina" +readme = "README.md" +# crates.io is limited to 5 keywords and 5 categories +keywords = ["blockchain", "celestia", "lumina"] +# Must be one of +categories = [ + "api-bindings", + "asynchronous", + "encoding", + "cryptography::cryptocurrencies", +] + +[dependencies] +celestia-tendermint-proto.workspace = true +celestia-types.workspace = true +celestia-proto = { workspace = true, features = [ "tonic" ] } +celestia-tendermint.workspace = true +prost.workspace = true + +cosmrs = "0.21.0" +thiserror = "1.0.61" +tonic = { version = "0.12.3", default-features = false, features = [ + "codegen", "prost" +]} + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +anyhow = "1.0.86" +dotenvy = "0.15.7" +pbjson-types = "0.7.0" +tokio = { version = "1.38.0", features = ["rt", "macros"] } + +[features] +default = ["transport"] +transport = ["tonic/transport"] diff --git a/tonic/src/client.rs b/tonic/src/client.rs new file mode 100644 index 00000000..60806e99 --- /dev/null +++ b/tonic/src/client.rs @@ -0,0 +1,75 @@ +use tonic::service::Interceptor; +use tonic::transport::Channel; + +use celestia_proto::celestia::blob::v1 as blob; +use celestia_proto::cosmos::auth::v1beta1 as auth; +use celestia_proto::cosmos::base::node::v1beta1 as config; +use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; +use celestia_proto::cosmos::tx::v1beta1 as tx; +use celestia_tendermint_proto::v0_34::types::BlobTx; +use celestia_types::auth::{AuthParams, BaseAccount}; +use celestia_types::blob::BlobParams; + +use crate::types::tx::{GetTxResponse, TxResponse}; +use crate::types::Block; +use crate::types::{FromGrpcResponse, IntoGrpcParam}; +use crate::Error; + +pub struct GrpcClient +where + I: Interceptor, +{ + grpc_channel: Channel, + auth_interceptor: I, +} + +// macro takes a path to an appropriate generated gRPC method and a desired function signature. +// If parameters need to be converted, they should implement [`types::IntoGrpcParam`] into +// appropriate type and return type is converted using TryFrom +// +// One limitation is that it expects gRPC method to be provided in exactly 4 `::` delimited +// segments, requiring importing the proto module with `as`. This might be possible to overcome +// by rewriting the macro as tt-muncher, but it'd increase its complexity significantly +macro_rules! make_method2 { + ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $( $param:ident : $param_type:ty ),* ) -> $ret:ty) => { + pub async fn $name(&mut self, $($param: $param_type),*) -> $ret { + let mut client = $path::$client_module::$client_struct::with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let request = ::tonic::Request::new(( $($param),* ).into_parameter()); + let response = client.$method(request).await; + + Ok(response?.into_inner().try_from_response()?) + } + }; +} + +impl GrpcClient +where + I: Interceptor + Clone, +{ + pub fn new(grpc_channel: Channel, auth_interceptor: I) -> Self { + Self { + grpc_channel, + auth_interceptor, + } + } + + make_method2!(config::service_client::ServiceClient::config; get_min_gas_price() -> Result); + + make_method2!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Result); + make_method2!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(height:i64) -> Result); + // TODO get_node_info + // make_method!(tendermint::service_client::ServiceClient::get_node_info; get_node_info() -> NodeInfo); + + make_method2!(blob::query_client::QueryClient::params; get_blob_params() -> Result); + + make_method2!(auth::query_client::QueryClient::params; get_auth_params() -> Result); + make_method2!(auth::query_client::QueryClient::account; get_account(account: String) -> Result); + // TODO: pagination? + make_method2!(auth::query_client::QueryClient::accounts; get_accounts() -> Result, Error>); + + make_method2!(tx::service_client::ServiceClient::broadcast_tx; broadcast_tx(blob_tx: BlobTx, mode: tx::BroadcastMode) -> Result); + make_method2!(tx::service_client::ServiceClient::get_tx; get_tx(hash: String) -> Result); +} diff --git a/tonic/src/error.rs b/tonic/src/error.rs new file mode 100644 index 00000000..b1cef7fe --- /dev/null +++ b/tonic/src/error.rs @@ -0,0 +1,29 @@ +use std::convert::Infallible; + +use cosmrs::ErrorReport; +use tonic::Status; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + TonicError(#[from] Status), + + #[error(transparent)] + TendermintError(#[from] celestia_tendermint::Error), + + #[error(transparent)] + CosmrsError(#[from] ErrorReport), + + #[error(transparent)] + TendermintProtoError(#[from] celestia_tendermint_proto::Error), + + #[error("Failed to parse response")] + FailedToParseResponse, + + #[error("Unexpected response type")] + UnexpectedResponseType(String), + + /// Unreachable. Added to appease try_into conversion for GrpcClient method macro + #[error(transparent)] + Infallible(#[from] Infallible), +} diff --git a/tonic/src/lib.rs b/tonic/src/lib.rs new file mode 100644 index 00000000..7c464619 --- /dev/null +++ b/tonic/src/lib.rs @@ -0,0 +1,8 @@ +#[cfg(feature = "transport")] +mod client; +mod error; +pub mod types; + +#[cfg(feature = "transport")] +pub use client::GrpcClient; +pub use error::Error; diff --git a/rpc/src/tonic/tendermint.rs b/tonic/src/tendermint.rs similarity index 100% rename from rpc/src/tonic/tendermint.rs rename to tonic/src/tendermint.rs diff --git a/rpc/src/tonic/types.rs b/tonic/src/types.rs similarity index 99% rename from rpc/src/tonic/types.rs rename to tonic/src/types.rs index ec4ecd7a..a2b27183 100644 --- a/rpc/src/tonic/types.rs +++ b/tonic/src/types.rs @@ -27,7 +27,7 @@ use celestia_tendermint_proto::v0_34::types::BlobTx; use cosmrs::crypto::PublicKey; use cosmrs::Any; -use crate::tonic::Error; +use crate::Error; pub mod tx; diff --git a/tonic/src/types/pagination.rs b/tonic/src/types/pagination.rs new file mode 100644 index 00000000..1666e99a --- /dev/null +++ b/tonic/src/types/pagination.rs @@ -0,0 +1,30 @@ +use celestia_proto::cosmos::base::query::v1beta1::pagination::PageRequest as RawPageRequest; +use celestia_proto::cosmos::base::query::v1beta1::pagination::PageResponse as RawPageResponse; + +use crate::tonic::types::FromGrpcResponse; +use crate::tonic::Error; + +pub enum KeyOrOffset { + Key(Vec), + Offset(u64), +} + +pub struct PageRequest { + query_start: KeyOrOffset, + limit: Option, + count_total: bool, + reverse: bool, +} + +impl From for RawPageRequest { + fn from(item: PageRequest) -> RawPageRequest { + RawPageRequest { + + } + } +} + +pub struct PageResponse { + pub next_key: Option>, + pub total: Option, +} diff --git a/rpc/src/tonic/types/tx.rs b/tonic/src/types/tx.rs similarity index 98% rename from rpc/src/tonic/types/tx.rs rename to tonic/src/types/tx.rs index 07b90cac..995158ca 100644 --- a/rpc/src/tonic/types/tx.rs +++ b/tonic/src/types/tx.rs @@ -3,8 +3,8 @@ use cosmrs::Tx; use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; use celestia_proto::cosmos::tx::v1beta1::{BroadcastTxResponse, GetTxResponse as RawGetTxResponse}; -use crate::tonic::types::FromGrpcResponse; -use crate::tonic::Error; +use crate::types::FromGrpcResponse; +use crate::Error; pub struct TxResponse { /// The block height diff --git a/rpc/tests/tonic.rs b/tonic/tests/tonic.rs similarity index 70% rename from rpc/tests/tonic.rs rename to tonic/tests/tonic.rs index 290558e3..501c7c28 100644 --- a/rpc/tests/tonic.rs +++ b/tonic/tests/tonic.rs @@ -1,20 +1,17 @@ -#![cfg(feature = "tonic")] - pub mod utils; -use crate::utils::client::AuthLevel; -use crate::utils::tonic_client::new_test_client; +use crate::utils::new_test_client; #[tokio::test] async fn get_min_gas_price() { - let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + let mut client = new_test_client().await.unwrap(); let gas_price = client.get_min_gas_price().await.unwrap(); assert!(gas_price > 0.0); } #[tokio::test] async fn get_block() { - let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + let mut client = new_test_client().await.unwrap(); let latest_block = client.get_latest_block().await.unwrap(); let height = latest_block.0.header.height.value() as i64; @@ -25,7 +22,7 @@ async fn get_block() { #[tokio::test] async fn get_account() { - let mut client = new_test_client(AuthLevel::Write).await.unwrap(); + let mut client = new_test_client().await.unwrap(); let accounts = client.get_accounts().await.unwrap(); diff --git a/rpc/tests/utils/tonic_client.rs b/tonic/tests/utils.rs similarity index 78% rename from rpc/tests/utils/tonic_client.rs rename to tonic/tests/utils.rs index 7a3e51d9..ee497809 100644 --- a/rpc/tests/utils/tonic_client.rs +++ b/tonic/tests/utils.rs @@ -1,5 +1,4 @@ -use crate::utils::client::{env_or, token_from_env}; -use crate::AuthLevel; +use std::env; use anyhow::Result; use tonic::metadata::{Ascii, MetadataValue}; @@ -7,7 +6,7 @@ use tonic::service::Interceptor; use tonic::transport::Channel; use tonic::{Request, Status}; -use celestia_rpc::tonic::GrpcClient; +use celestia_tonic::GrpcClient; const CELESTIA_GRPC_URL: &str = "http://localhost:19090"; //const CELESTIA_GRPC_URL: &str = "https://rpc.celestia.pops.one:9090"; @@ -35,12 +34,15 @@ impl TestAuthInterceptor { } } -pub async fn new_test_client(auth_level: AuthLevel) -> Result> { +pub fn env_or(var_name: &str, or_value: &str) -> String { + env::var(var_name).unwrap_or_else(|_| or_value.to_owned()) +} + +pub async fn new_test_client() -> Result> { let _ = dotenvy::dotenv(); let url = env_or("CELESTIA_GRPC_URL", CELESTIA_GRPC_URL); let grpc_channel = Channel::from_shared(url)?.connect().await?; - let token = token_from_env(auth_level)?; - let auth_interceptor = TestAuthInterceptor::new(token)?; + let auth_interceptor = TestAuthInterceptor::new(None)?; Ok(GrpcClient::new(grpc_channel, auth_interceptor)) } From ae8f6077219e632420222a49d6e943bd470bec28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 6 Nov 2024 17:12:24 +0100 Subject: [PATCH 14/56] proc macro --- Cargo.lock | 92 ++++++++++++--------- tonic/Cargo.toml | 1 + tonic/README.md | 5 ++ tonic/grpc_method_macro/Cargo.toml | 12 +++ tonic/grpc_method_macro/src/lib.rs | 128 +++++++++++++++++++++++++++++ tonic/src/client.rs | 86 ++++++++++--------- tonic/src/error.rs | 14 ++++ tonic/src/lib.rs | 7 +- tonic/src/types.rs | 19 ++--- tonic/src/types/tx.rs | 4 + 10 files changed, 276 insertions(+), 92 deletions(-) create mode 100644 tonic/README.md create mode 100644 tonic/grpc_method_macro/Cargo.toml create mode 100644 tonic/grpc_method_macro/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 51e8cc80..46406d98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,7 +292,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "synstructure", ] @@ -304,7 +304,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -356,7 +356,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -367,7 +367,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -408,7 +408,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -710,7 +710,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "syn_derive", ] @@ -868,6 +868,7 @@ dependencies = [ "celestia-types", "cosmrs", "dotenvy", + "grpc_method", "pbjson-types", "prost", "thiserror", @@ -1017,7 +1018,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1234,7 +1235,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1406,7 +1407,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1509,7 +1510,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1521,7 +1522,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1751,7 +1752,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1931,6 +1932,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "grpc_method" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "h2" version = "0.3.26" @@ -2592,7 +2602,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3111,7 +3121,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3318,7 +3328,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.8.5", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3501,7 +3511,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3638,7 +3648,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "synstructure", ] @@ -4102,7 +4112,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -4187,7 +4197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -4245,9 +4255,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -4272,7 +4282,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -4318,7 +4328,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.79", + "syn 2.0.87", "tempfile", ] @@ -4332,7 +4342,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -4712,7 +4722,7 @@ dependencies = [ "regex", "relative-path", "rustc_version 0.4.1", - "syn 2.0.79", + "syn 2.0.87", "unicode-ident", ] @@ -4782,7 +4792,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.79", + "syn 2.0.87", "walkdir", ] @@ -5112,7 +5122,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5145,7 +5155,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5380,9 +5390,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -5398,7 +5408,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5421,7 +5431,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5526,7 +5536,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5610,7 +5620,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5718,7 +5728,7 @@ dependencies = [ "prost-build", "prost-types", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -5801,7 +5811,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -6051,7 +6061,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -6085,7 +6095,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6119,7 +6129,7 @@ checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -6500,7 +6510,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -6520,5 +6530,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index a6421efa..93be9835 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -24,6 +24,7 @@ celestia-types.workspace = true celestia-proto = { workspace = true, features = [ "tonic" ] } celestia-tendermint.workspace = true prost.workspace = true +grpc_method.path = "./grpc_method_macro" cosmrs = "0.21.0" thiserror = "1.0.61" diff --git a/tonic/README.md b/tonic/README.md new file mode 100644 index 00000000..83ca75ff --- /dev/null +++ b/tonic/README.md @@ -0,0 +1,5 @@ +# Celestia gRPC + +A collection of types for interacting with Celestia validator nodes over gRPC + +This crate builds on top of [`tonic`](https://docs.rs/tonic). diff --git a/tonic/grpc_method_macro/Cargo.toml b/tonic/grpc_method_macro/Cargo.toml new file mode 100644 index 00000000..a0fab9c2 --- /dev/null +++ b/tonic/grpc_method_macro/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "grpc_method" +version = "0.1.0" +edition = "2021" + +[dependencies] +quote = "1.0.37" +syn = "2.0.87" +proc-macro2 = "1.0.89" + +[lib] +proc-macro = true diff --git a/tonic/grpc_method_macro/src/lib.rs b/tonic/grpc_method_macro/src/lib.rs new file mode 100644 index 00000000..a434b4ea --- /dev/null +++ b/tonic/grpc_method_macro/src/lib.rs @@ -0,0 +1,128 @@ +//! Helper crate for grpc_method macro for creating gRPC methods +//! +//! # Example +//! ``` +//! use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient; +//! # use tonic::service::Interceptor; +//! # use tonic::transport::Channel; +//! # +//! # pub struct GrpcClient +//! # where +//! # I: Interceptor, +//! # { +//! # grpc_channel: Channel, +//! # auth_interceptor: I, +//! # } +//! +//! impl GrpcClient +//! where +//! I: Interceptor + Clone, +//! { +//! /// Get auth params +//! #[grpc_method(AuthQueryClient::params)] +//! async fn get_auth_params(&mut self) -> Result; +//! } +//! ```` + +extern crate proc_macro; + +use proc_macro::TokenStream; +use proc_macro2::{Group, TokenStream as TokenStream2}; +use quote::{quote, TokenStreamExt}; +use syn::parse::{Parse, ParseStream}; +use syn::punctuated::Punctuated; +use syn::{parse_macro_input, Attribute, FnArg, Ident, Signature, Token}; + +#[derive(Debug)] +struct GrpcMethod { + doc_hash: Token![#], + doc_group: Group, + attrs: Vec, + signature: Signature, + _terminating_semi: Token![;], +} + +impl Parse for GrpcMethod { + fn parse(input: ParseStream) -> syn::Result { + Ok(GrpcMethod { + doc_hash: input.parse()?, + doc_group: input.parse()?, + attrs: input.call(Attribute::parse_inner)?, + signature: input.parse()?, + _terminating_semi: input.parse()?, + }) + } +} + +impl GrpcMethod { + fn instantiate_method(&self, tonic_method: GrpcMethodAttribute) -> TokenStream2 { + let mut tokens = TokenStream2::new(); + + tokens.append_all(&self.attrs); + + let grpc_client_struct = tonic_method.client; + let grpc_method_name = tonic_method.method; + + let doc_hash = self.doc_hash; + let doc_group = &self.doc_group; + + let signature = self.signature.clone(); + let params: Vec<_> = self + .signature + .inputs + .iter() + .filter_map(|arg| { + let FnArg::Typed(arg) = arg else { + return None; + }; + Some(&arg.pat) + }) + .collect(); + + let method = quote! { + #doc_hash #doc_group + pub #signature { + let mut client = #grpc_client_struct :: with_interceptor( + self.grpc_channel.clone(), + self.auth_interceptor.clone(), + ); + let request = ::tonic::Request::new(( #( #params ),* ).into_parameter()); + let response = client. #grpc_method_name (request).await; + response?.into_inner().try_from_response() + } + }; + + tokens.extend(method); + + tokens + } +} + +#[derive(Debug)] +struct GrpcMethodAttribute { + method: Ident, + client: Punctuated, +} + +impl Parse for GrpcMethodAttribute { + fn parse(input: ParseStream) -> syn::Result { + let mut parsed = Punctuated::::parse_separated_nonempty(input)?; + + let method = parsed.pop().expect("expected client method").into_value(); + parsed.pop_punct(); + let client = parsed; + + Ok(GrpcMethodAttribute { method, client }) + } +} + +/// Annotate a function signature passing ServiceClient method to be called +#[proc_macro_attribute] +pub fn grpc_method(attr: TokenStream, item: TokenStream) -> TokenStream { + let attributes = parse_macro_input!(attr as GrpcMethodAttribute); + let method_sig = parse_macro_input!(item as GrpcMethod); + + let method = method_sig.instantiate_method(attributes); + + method.into() +} diff --git a/tonic/src/client.rs b/tonic/src/client.rs index 60806e99..ec614a5c 100644 --- a/tonic/src/client.rs +++ b/tonic/src/client.rs @@ -1,20 +1,26 @@ use tonic::service::Interceptor; use tonic::transport::Channel; -use celestia_proto::celestia::blob::v1 as blob; -use celestia_proto::cosmos::auth::v1beta1 as auth; -use celestia_proto::cosmos::base::node::v1beta1 as config; -use celestia_proto::cosmos::base::tendermint::v1beta1 as tendermint; -use celestia_proto::cosmos::tx::v1beta1 as tx; +use celestia_proto::celestia::blob::v1::query_client::QueryClient as BlobQueryClient; +use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient as AuthQueryClient; +use celestia_proto::cosmos::base::node::v1beta1::service_client::ServiceClient as ConfigServiceClient; +use celestia_proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient as TendermintServiceClient; +use celestia_proto::cosmos::tx::v1beta1::service_client::ServiceClient as TxServiceClient; + use celestia_tendermint_proto::v0_34::types::BlobTx; use celestia_types::auth::{AuthParams, BaseAccount}; use celestia_types::blob::BlobParams; +use grpc_method::grpc_method; + use crate::types::tx::{GetTxResponse, TxResponse}; use crate::types::Block; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; +pub use celestia_proto::cosmos::tx::v1beta1::BroadcastMode; + +/// Struct wrapping all the tonic types and doing type conversion behind the scenes. pub struct GrpcClient where I: Interceptor, @@ -23,32 +29,11 @@ where auth_interceptor: I, } -// macro takes a path to an appropriate generated gRPC method and a desired function signature. -// If parameters need to be converted, they should implement [`types::IntoGrpcParam`] into -// appropriate type and return type is converted using TryFrom -// -// One limitation is that it expects gRPC method to be provided in exactly 4 `::` delimited -// segments, requiring importing the proto module with `as`. This might be possible to overcome -// by rewriting the macro as tt-muncher, but it'd increase its complexity significantly -macro_rules! make_method2 { - ($path:ident :: $client_module:ident :: $client_struct:ident :: $method:ident; $name:ident ( $( $param:ident : $param_type:ty ),* ) -> $ret:ty) => { - pub async fn $name(&mut self, $($param: $param_type),*) -> $ret { - let mut client = $path::$client_module::$client_struct::with_interceptor( - self.grpc_channel.clone(), - self.auth_interceptor.clone(), - ); - let request = ::tonic::Request::new(( $($param),* ).into_parameter()); - let response = client.$method(request).await; - - Ok(response?.into_inner().try_from_response()?) - } - }; -} - impl GrpcClient where I: Interceptor + Clone, { + /// Create a new client out of channel and optional auth pub fn new(grpc_channel: Channel, auth_interceptor: I) -> Self { Self { grpc_channel, @@ -56,20 +41,47 @@ where } } - make_method2!(config::service_client::ServiceClient::config; get_min_gas_price() -> Result); + /// Get Minimum Gas price + #[grpc_method(ConfigServiceClient::config)] + async fn get_min_gas_price(&mut self) -> Result; + + /// Get latest block + #[grpc_method(TendermintServiceClient::get_latest_block)] + async fn get_latest_block(&mut self) -> Result; + + /// Get block by height + #[grpc_method(TendermintServiceClient::get_block_by_height)] + async fn get_block_by_height(&mut self, height: i64) -> Result; - make_method2!(tendermint::service_client::ServiceClient::get_latest_block; get_latest_block() -> Result); - make_method2!(tendermint::service_client::ServiceClient::get_block_by_height; get_block_by_height(height:i64) -> Result); // TODO get_node_info - // make_method!(tendermint::service_client::ServiceClient::get_node_info; get_node_info() -> NodeInfo); + // make_method!(TendermintServiceClient::get_node_info; get_node_info() -> NodeInfo); + + /// Get blob params + #[grpc_method(BlobQueryClient::params)] + async fn get_blob_params(&mut self) -> Result; - make_method2!(blob::query_client::QueryClient::params; get_blob_params() -> Result); + /// Get auth params + #[grpc_method(AuthQueryClient::params)] + async fn get_auth_params(&mut self) -> Result; + + /// Get account + #[grpc_method(AuthQueryClient::account)] + async fn get_account(&mut self, account: String) -> Result; - make_method2!(auth::query_client::QueryClient::params; get_auth_params() -> Result); - make_method2!(auth::query_client::QueryClient::account; get_account(account: String) -> Result); // TODO: pagination? - make_method2!(auth::query_client::QueryClient::accounts; get_accounts() -> Result, Error>); + /// Get accounts + #[grpc_method(AuthQueryClient::accounts)] + async fn get_accounts(&mut self) -> Result, Error>; + + /// Broadcast Tx + #[grpc_method(TxServiceClient::broadcast_tx)] + async fn broadcast_tx( + &mut self, + blob_tx: BlobTx, + mode: BroadcastMode, + ) -> Result; - make_method2!(tx::service_client::ServiceClient::broadcast_tx; broadcast_tx(blob_tx: BlobTx, mode: tx::BroadcastMode) -> Result); - make_method2!(tx::service_client::ServiceClient::get_tx; get_tx(hash: String) -> Result); + /// Get Tx + #[grpc_method(TxServiceClient::get_tx)] + async fn get_tx(&mut self, hash: String) -> Result; } diff --git a/tonic/src/error.rs b/tonic/src/error.rs index b1cef7fe..7a771fbb 100644 --- a/tonic/src/error.rs +++ b/tonic/src/error.rs @@ -3,23 +3,37 @@ use std::convert::Infallible; use cosmrs::ErrorReport; use tonic::Status; +/// Alias for a `Result` with the error type [`celestia_tonic::Error`]. +/// +/// [`celestia_tonic::Error`]: crate::Error +pub type Result = std::result::Result; + +/// Representation of all the errors that can occur when interacting with [`celestia_tonic`]. +/// +/// [`celestia_tonic`]: crate #[derive(Debug, thiserror::Error)] pub enum Error { + /// Tonic error #[error(transparent)] TonicError(#[from] Status), + /// Tendermint Error #[error(transparent)] TendermintError(#[from] celestia_tendermint::Error), + /// Cosmrs Error #[error(transparent)] CosmrsError(#[from] ErrorReport), + /// Tendermint Proto Error #[error(transparent)] TendermintProtoError(#[from] celestia_tendermint_proto::Error), + /// Failed to parse gRPC response #[error("Failed to parse response")] FailedToParseResponse, + /// Unexpected reponse type #[error("Unexpected response type")] UnexpectedResponseType(String), diff --git a/tonic/src/lib.rs b/tonic/src/lib.rs index 7c464619..80c7df3b 100644 --- a/tonic/src/lib.rs +++ b/tonic/src/lib.rs @@ -1,8 +1,11 @@ +#![doc = include_str!("../README.md")] + #[cfg(feature = "transport")] mod client; mod error; +/// Custom types and wrappers needed by gRPC pub mod types; #[cfg(feature = "transport")] -pub use client::GrpcClient; -pub use error::Error; +pub use crate::client::GrpcClient; +pub use crate::error::{Error, Result}; diff --git a/tonic/src/types.rs b/tonic/src/types.rs index a2b27183..1e6c9d7c 100644 --- a/tonic/src/types.rs +++ b/tonic/src/types.rs @@ -1,8 +1,7 @@ +use cosmrs::crypto::PublicKey; +use cosmrs::Any; use prost::{Message, Name}; -use celestia_types::auth::{AuthParams, BaseAccount}; -use celestia_types::blob::BlobParams; - use celestia_proto::celestia::blob::v1::{ QueryParamsRequest as QueryBlobParamsRequest, QueryParamsResponse as QueryBlobParamsResponse, }; @@ -19,18 +18,17 @@ use celestia_proto::cosmos::base::tendermint::v1beta1::{ GetLatestBlockResponse, }; use celestia_proto::cosmos::tx::v1beta1::{BroadcastMode, BroadcastTxRequest, GetTxRequest}; - use celestia_tendermint::block::Block as TendermintBlock; - use celestia_tendermint_proto::v0_34::types::BlobTx; - -use cosmrs::crypto::PublicKey; -use cosmrs::Any; +use celestia_types::auth::{AuthParams, BaseAccount}; +use celestia_types::blob::BlobParams; use crate::Error; +/// types related to transaction querying and submission pub mod tx; +/// block pub struct Block(pub TendermintBlock); pub(crate) trait FromGrpcResponse { @@ -109,10 +107,7 @@ impl FromGrpcResponse for QueryAccountResponse { impl FromGrpcResponse> for QueryAccountsResponse { fn try_from_response(self) -> Result, Error> { - self.accounts - .into_iter() - .map(|acct| account_from_any(acct)) - .collect() + self.accounts.into_iter().map(account_from_any).collect() } } diff --git a/tonic/src/types/tx.rs b/tonic/src/types/tx.rs index 995158ca..f107e008 100644 --- a/tonic/src/types/tx.rs +++ b/tonic/src/types/tx.rs @@ -6,6 +6,7 @@ use celestia_proto::cosmos::tx::v1beta1::{BroadcastTxResponse, GetTxResponse as use crate::types::FromGrpcResponse; use crate::Error; +/// Response to a tx query pub struct TxResponse { /// The block height pub height: i64, @@ -55,9 +56,12 @@ pub struct TxResponse { //pub events: ::prost::alloc::vec::Vec< ::celestia_tendermint_proto::v0_34::abci::Event, >, } +/// Response to GetTx pub struct GetTxResponse { + /// Response Transaction pub tx: Tx, + /// TxResponse to a Query pub tx_response: TxResponse, } From 5712fbf5d9c5438906b91834c266861699020f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 7 Nov 2024 09:57:23 +0100 Subject: [PATCH 15/56] cleanup, updates --- Cargo.lock | 43 +- Cargo.toml | 2 +- {tonic => grpc}/Cargo.toml | 2 +- {tonic => grpc}/README.md | 0 {tonic => grpc}/grpc_method_macro/Cargo.toml | 0 {tonic => grpc}/grpc_method_macro/src/lib.rs | 0 {tonic => grpc}/src/client.rs | 10 +- {tonic => grpc}/src/error.rs | 10 +- {tonic => grpc}/src/lib.rs | 0 {tonic => grpc}/src/types.rs | 106 +-- grpc/src/types/auth.rs | 77 ++ {tonic => grpc}/src/types/pagination.rs | 0 {tonic => grpc}/src/types/tx.rs | 0 {tonic => grpc}/tests/tonic.rs | 21 +- {tonic => grpc}/tests/utils.rs | 2 +- proto/Cargo.toml | 10 +- proto/build.rs | 9 +- proto/vendor/celestia/blob/v1/query.proto | 1 - proto/vendor/celestia/blob/v1/tx.proto | 5 +- proto/vendor/celestia/core/v1/blob/blob.proto | 24 + .../v1}/da/data_availability_header.proto | 6 +- .../vendor/celestia/core/v1/proof/proof.proto | 54 ++ proto/vendor/celestia/core/v1/tx/tx.proto | 40 + .../da/data_availability_header.pb.go | 390 ---------- proto/vendor/celestia/minfee/v1/genesis.proto | 16 + proto/vendor/celestia/minfee/v1/query.proto | 28 + proto/vendor/celestia/qgb/v1/genesis.proto | 6 +- proto/vendor/celestia/qgb/v1/query.proto | 5 +- proto/vendor/celestia/qgb/v1/tx.proto | 4 +- proto/vendor/celestia/qgb/v1/types.proto | 4 +- proto/vendor/celestia/signal/v1/query.proto | 42 ++ proto/vendor/celestia/signal/v1/tx.proto | 35 + proto/vendor/celestia/signal/v1/upgrade.proto | 15 + .../go-header/p2p/pb/header_request.pb.go | 706 ------------------ proto/vendor/header/pb/extended_header.proto | 4 +- proto/vendor/nmt/pb/proof.proto | 10 +- proto/vendor/tendermint/abci/types.proto | 15 +- proto/vendor/tendermint/state/types.proto | 3 + proto/vendor/tendermint/store/types.proto | 8 +- rpc/Cargo.toml | 5 +- rpc/tests/utils/client.rs | 4 +- tonic/src/tendermint.rs | 19 - tools/update-proto-vendor.sh | 35 +- types/Cargo.toml | 1 - types/src/auth.rs | 97 ++- types/src/data_availability_header.rs | 2 +- types/src/error.rs | 4 + 47 files changed, 556 insertions(+), 1324 deletions(-) rename {tonic => grpc}/Cargo.toml (98%) rename {tonic => grpc}/README.md (100%) rename {tonic => grpc}/grpc_method_macro/Cargo.toml (100%) rename {tonic => grpc}/grpc_method_macro/src/lib.rs (100%) rename {tonic => grpc}/src/client.rs (91%) rename {tonic => grpc}/src/error.rs (87%) rename {tonic => grpc}/src/lib.rs (100%) rename {tonic => grpc}/src/types.rs (50%) create mode 100644 grpc/src/types/auth.rs rename {tonic => grpc}/src/types/pagination.rs (100%) rename {tonic => grpc}/src/types/tx.rs (100%) rename {tonic => grpc}/tests/tonic.rs (52%) rename {tonic => grpc}/tests/utils.rs (97%) create mode 100644 proto/vendor/celestia/core/v1/blob/blob.proto rename proto/vendor/celestia/{ => core/v1}/da/data_availability_header.proto (89%) create mode 100644 proto/vendor/celestia/core/v1/proof/proof.proto create mode 100644 proto/vendor/celestia/core/v1/tx/tx.proto delete mode 100644 proto/vendor/celestia/da/data_availability_header.pb.go create mode 100644 proto/vendor/celestia/minfee/v1/genesis.proto create mode 100644 proto/vendor/celestia/minfee/v1/query.proto create mode 100644 proto/vendor/celestia/signal/v1/query.proto create mode 100644 proto/vendor/celestia/signal/v1/tx.proto create mode 100644 proto/vendor/celestia/signal/v1/upgrade.proto delete mode 100644 proto/vendor/go-header/p2p/pb/header_request.pb.go delete mode 100644 tonic/src/tendermint.rs diff --git a/Cargo.lock b/Cargo.lock index 46406d98..9b85e355 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -760,6 +760,25 @@ dependencies = [ "shlex", ] +[[package]] +name = "celestia-grpc" +version = "0.1.0" +dependencies = [ + "anyhow", + "celestia-proto", + "celestia-tendermint", + "celestia-tendermint-proto", + "celestia-types", + "cosmrs", + "dotenvy", + "grpc_method", + "pbjson-types", + "prost", + "thiserror", + "tokio", + "tonic", +] + [[package]] name = "celestia-proto" version = "0.4.1" @@ -791,7 +810,6 @@ dependencies = [ "celestia-tendermint", "celestia-tendermint-proto", "celestia-types", - "cosmrs", "dotenvy", "futures", "getrandom", @@ -799,7 +817,6 @@ dependencies = [ "jsonrpsee", "libp2p", "nmt-rs", - "pbjson-types", "prost", "rand", "serde", @@ -822,12 +839,10 @@ dependencies = [ "flex-error", "futures", "instant", - "k256", "num-traits", "once_cell", "prost", "prost-types", - "ripemd", "serde", "serde_bytes", "serde_json", @@ -857,25 +872,6 @@ dependencies = [ "time", ] -[[package]] -name = "celestia-tonic" -version = "0.1.0" -dependencies = [ - "anyhow", - "celestia-proto", - "celestia-tendermint", - "celestia-tendermint-proto", - "celestia-types", - "cosmrs", - "dotenvy", - "grpc_method", - "pbjson-types", - "prost", - "thiserror", - "tokio", - "tonic", -] - [[package]] name = "celestia-types" version = "0.6.1" @@ -889,7 +885,6 @@ dependencies = [ "celestia-tendermint-proto", "cid", "const_format", - "cosmrs", "ed25519-consensus", "enum_dispatch", "getrandom", diff --git a/Cargo.toml b/Cargo.toml index 35870b9c..008c51c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["cli", "node", "node-wasm", "proto", "rpc", "tonic", "types"] +members = ["cli", "node", "node-wasm", "proto", "rpc", "grpc", "types"] [workspace.dependencies] blockstore = "0.7.0" diff --git a/tonic/Cargo.toml b/grpc/Cargo.toml similarity index 98% rename from tonic/Cargo.toml rename to grpc/Cargo.toml index 93be9835..d411cde2 100644 --- a/tonic/Cargo.toml +++ b/grpc/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "celestia-tonic" +name = "celestia-grpc" version = "0.1.0" edition = "2021" license = "Apache-2.0" diff --git a/tonic/README.md b/grpc/README.md similarity index 100% rename from tonic/README.md rename to grpc/README.md diff --git a/tonic/grpc_method_macro/Cargo.toml b/grpc/grpc_method_macro/Cargo.toml similarity index 100% rename from tonic/grpc_method_macro/Cargo.toml rename to grpc/grpc_method_macro/Cargo.toml diff --git a/tonic/grpc_method_macro/src/lib.rs b/grpc/grpc_method_macro/src/lib.rs similarity index 100% rename from tonic/grpc_method_macro/src/lib.rs rename to grpc/grpc_method_macro/src/lib.rs diff --git a/tonic/src/client.rs b/grpc/src/client.rs similarity index 91% rename from tonic/src/client.rs rename to grpc/src/client.rs index ec614a5c..b49497b9 100644 --- a/tonic/src/client.rs +++ b/grpc/src/client.rs @@ -6,15 +6,15 @@ use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient as AuthQuer use celestia_proto::cosmos::base::node::v1beta1::service_client::ServiceClient as ConfigServiceClient; use celestia_proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient as TendermintServiceClient; use celestia_proto::cosmos::tx::v1beta1::service_client::ServiceClient as TxServiceClient; - +use celestia_tendermint::block::Block; use celestia_tendermint_proto::v0_34::types::BlobTx; -use celestia_types::auth::{AuthParams, BaseAccount}; +use celestia_types::auth::AuthParams; use celestia_types::blob::BlobParams; use grpc_method::grpc_method; +use crate::types::auth::Account; use crate::types::tx::{GetTxResponse, TxResponse}; -use crate::types::Block; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; @@ -66,12 +66,12 @@ where /// Get account #[grpc_method(AuthQueryClient::account)] - async fn get_account(&mut self, account: String) -> Result; + async fn get_account(&mut self, account: String) -> Result; // TODO: pagination? /// Get accounts #[grpc_method(AuthQueryClient::accounts)] - async fn get_accounts(&mut self) -> Result, Error>; + async fn get_accounts(&mut self) -> Result, Error>; /// Broadcast Tx #[grpc_method(TxServiceClient::broadcast_tx)] diff --git a/tonic/src/error.rs b/grpc/src/error.rs similarity index 87% rename from tonic/src/error.rs rename to grpc/src/error.rs index 7a771fbb..c096f04f 100644 --- a/tonic/src/error.rs +++ b/grpc/src/error.rs @@ -1,5 +1,3 @@ -use std::convert::Infallible; - use cosmrs::ErrorReport; use tonic::Status; @@ -25,6 +23,10 @@ pub enum Error { #[error(transparent)] CosmrsError(#[from] ErrorReport), + /// Celestia types error + #[error(transparent)] + CelestiaTypesError(#[from] celestia_types::Error), + /// Tendermint Proto Error #[error(transparent)] TendermintProtoError(#[from] celestia_tendermint_proto::Error), @@ -36,8 +38,4 @@ pub enum Error { /// Unexpected reponse type #[error("Unexpected response type")] UnexpectedResponseType(String), - - /// Unreachable. Added to appease try_into conversion for GrpcClient method macro - #[error(transparent)] - Infallible(#[from] Infallible), } diff --git a/tonic/src/lib.rs b/grpc/src/lib.rs similarity index 100% rename from tonic/src/lib.rs rename to grpc/src/lib.rs diff --git a/tonic/src/types.rs b/grpc/src/types.rs similarity index 50% rename from tonic/src/types.rs rename to grpc/src/types.rs index 1e6c9d7c..9a2fff8e 100644 --- a/tonic/src/types.rs +++ b/grpc/src/types.rs @@ -1,35 +1,36 @@ -use cosmrs::crypto::PublicKey; -use cosmrs::Any; -use prost::{Message, Name}; +use prost::Message; use celestia_proto::celestia::blob::v1::{ QueryParamsRequest as QueryBlobParamsRequest, QueryParamsResponse as QueryBlobParamsResponse, }; -use celestia_proto::cosmos::auth::v1beta1::{ - BaseAccount as RawBaseAccount, QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest, - QueryAccountsResponse, -}; -use celestia_proto::cosmos::auth::v1beta1::{ - QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, -}; use celestia_proto::cosmos::base::node::v1beta1::{ConfigRequest, ConfigResponse}; use celestia_proto::cosmos::base::tendermint::v1beta1::{ GetBlockByHeightRequest, GetBlockByHeightResponse, GetLatestBlockRequest, GetLatestBlockResponse, }; use celestia_proto::cosmos::tx::v1beta1::{BroadcastMode, BroadcastTxRequest, GetTxRequest}; -use celestia_tendermint::block::Block as TendermintBlock; +use celestia_tendermint::block::Block; use celestia_tendermint_proto::v0_34::types::BlobTx; -use celestia_types::auth::{AuthParams, BaseAccount}; use celestia_types::blob::BlobParams; use crate::Error; +/// types related to authorisation +pub mod auth; /// types related to transaction querying and submission pub mod tx; -/// block -pub struct Block(pub TendermintBlock); +macro_rules! make_empty_params { + ($request_type:ident) => { + impl IntoGrpcParam<$request_type> for () { + fn into_parameter(self) -> $request_type { + $request_type {} + } + } + }; +} + +pub(crate) use make_empty_params; pub(crate) trait FromGrpcResponse { fn try_from_response(self) -> Result; @@ -51,63 +52,13 @@ impl FromGrpcResponse for QueryBlobParamsResponse { impl FromGrpcResponse for GetBlockByHeightResponse { fn try_from_response(self) -> Result { - Ok(Block( - self.block.ok_or(Error::FailedToParseResponse)?.try_into()?, - )) + Ok(self.block.ok_or(Error::FailedToParseResponse)?.try_into()?) } } impl FromGrpcResponse for GetLatestBlockResponse { fn try_from_response(self) -> Result { - Ok(Block( - self.block.ok_or(Error::FailedToParseResponse)?.try_into()?, - )) - } -} - -impl FromGrpcResponse for QueryAuthParamsResponse { - fn try_from_response(self) -> Result { - let params = self.params.ok_or(Error::FailedToParseResponse)?; - Ok(AuthParams { - max_memo_characters: params.max_memo_characters, - tx_sig_limit: params.tx_sig_limit, - tx_size_cost_per_byte: params.tx_size_cost_per_byte, - sig_verify_cost_ed25519: params.sig_verify_cost_ed25519, - sig_verify_cost_secp256k1: params.sig_verify_cost_secp256k1, - }) - } -} -fn account_from_any(any: pbjson_types::Any) -> Result { - if any.type_url != RawBaseAccount::type_url() { - return Err(Error::UnexpectedResponseType(any.type_url)); - } - let base_account = - RawBaseAccount::decode(&*any.value).map_err(|_| Error::FailedToParseResponse)?; - - let any_pub_key = base_account.pub_key.ok_or(Error::FailedToParseResponse)?; - // cosmrs has different Any type than pbjson_types Any - let pub_key = PublicKey::try_from(Any { - type_url: any_pub_key.type_url, - value: any_pub_key.value.to_vec(), - })?; - - Ok(BaseAccount { - address: base_account.address, - pub_key, - account_number: base_account.account_number, - sequence: base_account.sequence, - }) -} - -impl FromGrpcResponse for QueryAccountResponse { - fn try_from_response(self) -> Result { - account_from_any(self.account.ok_or(Error::FailedToParseResponse)?) - } -} - -impl FromGrpcResponse> for QueryAccountsResponse { - fn try_from_response(self) -> Result, Error> { - self.accounts.into_iter().map(account_from_any).collect() + Ok(self.block.ok_or(Error::FailedToParseResponse)?.try_into()?) } } @@ -133,12 +84,6 @@ impl IntoGrpcParam for i64 { } } -impl IntoGrpcParam for String { - fn into_parameter(self) -> QueryAccountRequest { - QueryAccountRequest { address: self } - } -} - impl IntoGrpcParam for (BlobTx, BroadcastMode) { fn into_parameter(self) -> BroadcastTxRequest { let (blob_tx, mode) = self; @@ -155,23 +100,6 @@ impl IntoGrpcParam for String { } } -impl IntoGrpcParam for () { - fn into_parameter(self) -> QueryAccountsRequest { - QueryAccountsRequest { pagination: None } - } -} - -macro_rules! make_empty_params { - ($request_type:ident) => { - impl IntoGrpcParam<$request_type> for () { - fn into_parameter(self) -> $request_type { - $request_type {} - } - } - }; -} - make_empty_params!(GetLatestBlockRequest); make_empty_params!(ConfigRequest); -make_empty_params!(QueryAuthParamsRequest); make_empty_params!(QueryBlobParamsRequest); diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs new file mode 100644 index 00000000..971e805f --- /dev/null +++ b/grpc/src/types/auth.rs @@ -0,0 +1,77 @@ +use prost::{Message, Name}; + +use celestia_proto::cosmos::auth::v1beta1::{ + BaseAccount as RawBaseAccount, ModuleAccount as RawModuleAccount, QueryAccountRequest, + QueryAccountResponse, QueryAccountsRequest, QueryAccountsResponse, + QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, +}; +use celestia_types::auth::{AuthParams, BaseAccount, ModuleAccount}; + +use crate::types::make_empty_params; +use crate::types::{FromGrpcResponse, IntoGrpcParam}; +use crate::Error; + +/// Enum representing different types of account +#[derive(Debug, PartialEq)] +#[non_exhaustive] +pub enum Account { + /// Base account type + Base(BaseAccount), + /// Account for modules that holds coins on a pool + Module(ModuleAccount), +} + +impl FromGrpcResponse for QueryAuthParamsResponse { + fn try_from_response(self) -> Result { + let params = self.params.ok_or(Error::FailedToParseResponse)?; + Ok(AuthParams { + max_memo_characters: params.max_memo_characters, + tx_sig_limit: params.tx_sig_limit, + tx_size_cost_per_byte: params.tx_size_cost_per_byte, + sig_verify_cost_ed25519: params.sig_verify_cost_ed25519, + sig_verify_cost_secp256k1: params.sig_verify_cost_secp256k1, + }) + } +} + +impl FromGrpcResponse for QueryAccountResponse { + fn try_from_response(self) -> Result { + account_from_any(self.account.ok_or(Error::FailedToParseResponse)?) + } +} + +impl FromGrpcResponse> for QueryAccountsResponse { + fn try_from_response(self) -> Result, Error> { + self.accounts.into_iter().map(account_from_any).collect() + } +} + +make_empty_params!(QueryAuthParamsRequest); + +impl IntoGrpcParam for String { + fn into_parameter(self) -> QueryAccountRequest { + QueryAccountRequest { address: self } + } +} + +impl IntoGrpcParam for () { + fn into_parameter(self) -> QueryAccountsRequest { + QueryAccountsRequest { pagination: None } + } +} + +fn account_from_any(any: pbjson_types::Any) -> Result { + let account = if any.type_url == RawBaseAccount::type_url() { + let base_account = + RawBaseAccount::decode(&*any.value).map_err(|_| Error::FailedToParseResponse)?; + Account::Base(base_account.try_into()?) + } else if any.type_url == RawModuleAccount::type_url() { + let module_account = + RawModuleAccount::decode(&*any.value).map_err(|_| Error::FailedToParseResponse)?; + Account::Module(module_account.try_into()?) + } else { + return Err(Error::UnexpectedResponseType(any.type_url)); + }; + + Ok(account) +} diff --git a/tonic/src/types/pagination.rs b/grpc/src/types/pagination.rs similarity index 100% rename from tonic/src/types/pagination.rs rename to grpc/src/types/pagination.rs diff --git a/tonic/src/types/tx.rs b/grpc/src/types/tx.rs similarity index 100% rename from tonic/src/types/tx.rs rename to grpc/src/types/tx.rs diff --git a/tonic/tests/tonic.rs b/grpc/tests/tonic.rs similarity index 52% rename from tonic/tests/tonic.rs rename to grpc/tests/tonic.rs index 501c7c28..b98fd7a5 100644 --- a/tonic/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -1,3 +1,5 @@ +use celestia_grpc::types::auth::Account; + pub mod utils; use crate::utils::new_test_client; @@ -14,10 +16,10 @@ async fn get_block() { let mut client = new_test_client().await.unwrap(); let latest_block = client.get_latest_block().await.unwrap(); - let height = latest_block.0.header.height.value() as i64; + let height = latest_block.header.height.value() as i64; let block = client.get_block_by_height(height).await.unwrap(); - assert_eq!(block.0.header, latest_block.0.header); + assert_eq!(block.header, latest_block.header); } #[tokio::test] @@ -26,12 +28,15 @@ async fn get_account() { let accounts = client.get_accounts().await.unwrap(); - println!("first account : {:?}", accounts.first()); + let first_account = accounts.first().expect("account to exist"); + + let address = match first_account { + Account::Base(acct) => acct.address.to_string(), + Account::Module(acct) => acct.base_account.as_ref().unwrap().address.to_string(), + _ => unimplemented!("unknown account type"), + }; - let acct = client - .get_account("celestia1p3ucd3ptpw902fluyjzhq3ffgq4ntddaf0pdta".to_string()) - .await - .unwrap(); + let account = client.get_account(address).await.unwrap(); - println!("{acct:?}"); + assert_eq!(&account, first_account); } diff --git a/tonic/tests/utils.rs b/grpc/tests/utils.rs similarity index 97% rename from tonic/tests/utils.rs rename to grpc/tests/utils.rs index ee497809..b9889442 100644 --- a/tonic/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -6,7 +6,7 @@ use tonic::service::Interceptor; use tonic::transport::Channel; use tonic::{Request, Status}; -use celestia_tonic::GrpcClient; +use celestia_grpc::GrpcClient; const CELESTIA_GRPC_URL: &str = "http://localhost:19090"; //const CELESTIA_GRPC_URL: &str = "https://rpc.celestia.pops.one:9090"; diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 8851940b..4db3b614 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -19,8 +19,8 @@ prost.workspace = true prost-types.workspace = true cosmos-sdk-proto = { version = "0.26.0", default-features = false } serde = { version = "1.0.203", features = ["derive"] } -pbjson = "0.7.0" -pbjson-types = "0.7.0" +pbjson = { version = "0.7.0", optional = true } +pbjson-types = { version = "0.7.0", optional = true } tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "codegen", "prost" ]} @@ -35,8 +35,8 @@ tonic-build = { version = "0.12.3", optional = true } prost-build.workspace = true prost-types.workspace = true protox = "0.7.1" -tempfile = "3.13.0" -pbjson-build = "0.7.0" +tempfile = { version = "3.13.0", optional = true } +pbjson-build = { version = "0.7.0", optional = true } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.42" @@ -45,4 +45,4 @@ wasm-bindgen-test = "0.3.42" serde_json = "1.0.117" [features] -tonic = ["dep:tonic", "dep:tonic-build"] +tonic = ["dep:tonic", "dep:tonic-build", "dep:pbjson", "dep:pbjson-types", "dep:pbjson-build", "dep:tempfile"] diff --git a/proto/build.rs b/proto/build.rs index 73927f9c..508b7b89 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -18,7 +18,7 @@ const NULL_DEFAULT: &str = r#"#[serde(with = "crate::serializers::null_default") #[rustfmt::skip] static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ - (".celestia.da.DataAvailabilityHeader", SERIALIZED_DEFAULT), + (".celestia.core.v1.da.DataAvailabilityHeader", SERIALIZED_DEFAULT), (".celestia.blob.v1.MsgPayForBlobs", SERIALIZED_DEFAULT), (".cosmos.base.abci.v1beta1.ABCIMessageLog", SERIALIZED_DEFAULT), (".cosmos.base.abci.v1beta1.Attribute", SERIALIZED_DEFAULT), @@ -47,12 +47,12 @@ static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ (".shwap.Sample", SERIALIZED_DEFAULT), (".shwap.Share", SERIALIZED_DEFAULT), (".shwap.Share", TRANSPARENT), - ]; +]; #[rustfmt::skip] static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ (".celestia.da.DataAvailabilityHeader.row_roots", VEC_BASE64STRING), - (".celestia.da.DataAvailabilityHeader.column_roots", VEC_BASE64STRING), + (".celestia.core.v1.da.DataAvailabilityHeader.column_roots", VEC_BASE64STRING), #[cfg(not(feature = "tonic"))] (".cosmos.base.abci.v1beta1.TxResponse.tx", OPTION_ANY), (".cosmos.base.abci.v1beta1.TxResponse.logs", NULL_DEFAULT), @@ -80,7 +80,7 @@ const PROTO_FILES: &[&str] = &[ "vendor/celestia/blob/v1/params.proto", "vendor/celestia/blob/v1/query.proto", "vendor/celestia/blob/v1/tx.proto", - "vendor/celestia/da/data_availability_header.proto", + "vendor/celestia/core/v1/da/data_availability_header.proto", "vendor/cosmos/auth/v1beta1/auth.proto", "vendor/cosmos/auth/v1beta1/query.proto", "vendor/cosmos/base/abci/v1beta1/abci.proto", @@ -97,7 +97,6 @@ const PROTO_FILES: &[&str] = &[ "vendor/share/eds/byzantine/pb/share.proto", "vendor/share/shwap/p2p/bitswap/pb/bitswap.proto", "vendor/share/shwap/pb/shwap.proto", - //"vendor/tendermint/crypto/keys.proto", "vendor/tendermint/types/types.proto", ]; diff --git a/proto/vendor/celestia/blob/v1/query.proto b/proto/vendor/celestia/blob/v1/query.proto index 8c6c49e9..47d484b3 100644 --- a/proto/vendor/celestia/blob/v1/query.proto +++ b/proto/vendor/celestia/blob/v1/query.proto @@ -3,7 +3,6 @@ package celestia.blob.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; import "celestia/blob/v1/params.proto"; option go_package = "github.com/celestiaorg/celestia-app/x/blob/types"; diff --git a/proto/vendor/celestia/blob/v1/tx.proto b/proto/vendor/celestia/blob/v1/tx.proto index 287dc73e..552424c3 100644 --- a/proto/vendor/celestia/blob/v1/tx.proto +++ b/proto/vendor/celestia/blob/v1/tx.proto @@ -9,17 +9,20 @@ option go_package = "github.com/celestiaorg/celestia-app/x/blob/types"; service Msg { // PayForBlobs allows the user to pay for the inclusion of one or more blobs rpc PayForBlobs(MsgPayForBlobs) returns (MsgPayForBlobsResponse) { - option (google.api.http).get = "/blob/v1/payforblobs"; + option (google.api.http) = { post: "/blob/v1/payforblobs", body: "*" }; } } // MsgPayForBlobs pays for the inclusion of a blob in the block. message MsgPayForBlobs { + // signer is the bech32 encoded signer address. See + // https://en.bitcoin.it/wiki/Bech32. string signer = 1; // namespaces is a list of namespaces that the blobs are associated with. A // namespace is a byte slice of length 29 where the first byte is the // namespaceVersion and the subsequent 28 bytes are the namespaceId. repeated bytes namespaces = 2; + // blob_sizes is a list of blob sizes (one per blob). Each size is in bytes. repeated uint32 blob_sizes = 3; // share_commitments is a list of share commitments (one per blob). repeated bytes share_commitments = 4; diff --git a/proto/vendor/celestia/core/v1/blob/blob.proto b/proto/vendor/celestia/core/v1/blob/blob.proto new file mode 100644 index 00000000..45ece976 --- /dev/null +++ b/proto/vendor/celestia/core/v1/blob/blob.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package celestia.core.v1.blob; + +option go_package = "github.com/celestiaorg/go-square/blob"; + +// Blob (named after binary large object) is a chunk of data submitted by a user +// to be published to the Celestia blockchain. The data of a Blob is published +// to a namespace and is encoded into shares based on the format specified by +// share_version. +message Blob { + bytes namespace_id = 1; + bytes data = 2; + uint32 share_version = 3; + uint32 namespace_version = 4; +} + +// BlobTx wraps an encoded sdk.Tx with a second field to contain blobs of data. +// The raw bytes of the blobs are not signed over, instead we verify each blob +// using the relevant MsgPayForBlobs that is signed over in the encoded sdk.Tx. +message BlobTx { + bytes tx = 1; + repeated Blob blobs = 2; + string type_id = 3; +} \ No newline at end of file diff --git a/proto/vendor/celestia/da/data_availability_header.proto b/proto/vendor/celestia/core/v1/da/data_availability_header.proto similarity index 89% rename from proto/vendor/celestia/da/data_availability_header.proto rename to proto/vendor/celestia/core/v1/da/data_availability_header.proto index 87f93469..19a4b7d3 100644 --- a/proto/vendor/celestia/da/data_availability_header.proto +++ b/proto/vendor/celestia/core/v1/da/data_availability_header.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package celestia.da; +package celestia.core.v1.da; -option go_package = "github.com/celestiaorg/celestia-app/proto/celestia/da"; +option go_package = "github.com/celestiaorg/celestia-app/proto/celestia/core/v1/da"; // DataAvailabilityHeader contains the row and column roots of the erasure // coded version of the data in Block.Data. -// Therefor the original Block.Data is arranged in a +// Therefore the original Block.Data is arranged in a // k × k matrix, which is then "extended" to a // 2k × 2k matrix applying multiple times Reed-Solomon encoding. // For details see Section 5.2: https://arxiv.org/abs/1809.09044 diff --git a/proto/vendor/celestia/core/v1/proof/proof.proto b/proto/vendor/celestia/core/v1/proof/proof.proto new file mode 100644 index 00000000..816cf871 --- /dev/null +++ b/proto/vendor/celestia/core/v1/proof/proof.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; +package celestia.core.v1.proof; + +option go_package = "github.com/celestiaorg/celestia-app/pkg/proof"; + +// ShareProof is an NMT proof that a set of shares exist in a set of rows and a +// Merkle proof that those rows exist in a Merkle tree with a given data root. +message ShareProof { + repeated bytes data = 1; + repeated NMTProof share_proofs = 2; + bytes namespace_id = 3; + RowProof row_proof = 4; + uint32 namespace_version = 5; +} + +// RowProof is a Merkle proof that a set of rows exist in a Merkle tree with a +// given data root. +message RowProof { + repeated bytes row_roots = 1; + repeated Proof proofs = 2; + bytes root = 3; + uint32 start_row = 4; + uint32 end_row = 5; +} + +// NMTProof is a proof of a namespace.ID in an NMT. +// In case this proof proves the absence of a namespace.ID +// in a tree it also contains the leaf hashes of the range +// where that namespace would be. +message NMTProof { + // Start index of this proof. + int32 start = 1; + // End index of this proof. + int32 end = 2; + // Nodes that together with the corresponding leaf values can be used to + // recompute the root and verify this proof. Nodes should consist of the max + // and min namespaces along with the actual hash, resulting in each being 48 + // bytes each + repeated bytes nodes = 3; + // leafHash are nil if the namespace is present in the NMT. In case the + // namespace to be proved is in the min/max range of the tree but absent, this + // will contain the leaf hash necessary to verify the proof of absence. Leaf + // hashes should consist of the namespace along with the actual hash, + // resulting 40 bytes total. + bytes leaf_hash = 4; +} + +// Proof is taken from the merkle package +message Proof { + int64 total = 1; + int64 index = 2; + bytes leaf_hash = 3; + repeated bytes aunts = 4; +} \ No newline at end of file diff --git a/proto/vendor/celestia/core/v1/tx/tx.proto b/proto/vendor/celestia/core/v1/tx/tx.proto new file mode 100644 index 00000000..0da698ad --- /dev/null +++ b/proto/vendor/celestia/core/v1/tx/tx.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package celestia.core.v1.tx; + +import "google/api/annotations.proto"; + +option go_package = "github.com/celestiaorg/celestia-app/app/grpc/tx"; + +// Service defines a gRPC service for interacting with transactions. +service Tx { + // TxStatus returns the status of a transaction. There are four possible states: + // - Committed + // - Pending + // - Evicted + // - Unknown + rpc TxStatus(TxStatusRequest) returns (TxStatusResponse) { + option (google.api.http) = { + get: "/celestia/core/v1/tx/{tx_id}" + }; + } +} + +// TxStatusRequest is the request type for the TxStatus gRPC method. +message TxStatusRequest { + // this is the hex encoded transaction hash (should be 64 bytes long) + string tx_id = 1; +} + +// TxStatusResponse is the response type for the TxStatus gRPC method. +message TxStatusResponse { + int64 height = 1; + uint32 index = 2; + // execution_code is returned when the transaction has been committed + // and returns whether it was successful or errored. A non zero + // execution code indicated an error. + uint32 execution_code = 3; + // error log for failed transactions. + string error = 4; + // status is the status of the transaction. + string status = 5; +} \ No newline at end of file diff --git a/proto/vendor/celestia/da/data_availability_header.pb.go b/proto/vendor/celestia/da/data_availability_header.pb.go deleted file mode 100644 index e60760c6..00000000 --- a/proto/vendor/celestia/da/data_availability_header.pb.go +++ /dev/null @@ -1,390 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: celestia/da/data_availability_header.proto - -package da - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// DataAvailabilityHeader contains the row and column roots of the erasure -// coded version of the data in Block.Data. -// Therefor the original Block.Data is arranged in a -// k × k matrix, which is then "extended" to a -// 2k × 2k matrix applying multiple times Reed-Solomon encoding. -// For details see Section 5.2: https://arxiv.org/abs/1809.09044 -// or the Celestia specification: -// https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/data_structures.md#availabledataheader -// Note that currently we list row and column roots in separate fields -// (different from the spec). -type DataAvailabilityHeader struct { - // RowRoot_j = root((M_{j,1} || M_{j,2} || ... || M_{j,2k} )) - RowRoots [][]byte `protobuf:"bytes,1,rep,name=row_roots,json=rowRoots,proto3" json:"row_roots,omitempty"` - // ColumnRoot_j = root((M_{1,j} || M_{2,j} || ... || M_{2k,j} )) - ColumnRoots [][]byte `protobuf:"bytes,2,rep,name=column_roots,json=columnRoots,proto3" json:"column_roots,omitempty"` -} - -func (m *DataAvailabilityHeader) Reset() { *m = DataAvailabilityHeader{} } -func (m *DataAvailabilityHeader) String() string { return proto.CompactTextString(m) } -func (*DataAvailabilityHeader) ProtoMessage() {} -func (*DataAvailabilityHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_93b487fd8444a5fd, []int{0} -} -func (m *DataAvailabilityHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DataAvailabilityHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DataAvailabilityHeader.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DataAvailabilityHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_DataAvailabilityHeader.Merge(m, src) -} -func (m *DataAvailabilityHeader) XXX_Size() int { - return m.Size() -} -func (m *DataAvailabilityHeader) XXX_DiscardUnknown() { - xxx_messageInfo_DataAvailabilityHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_DataAvailabilityHeader proto.InternalMessageInfo - -func (m *DataAvailabilityHeader) GetRowRoots() [][]byte { - if m != nil { - return m.RowRoots - } - return nil -} - -func (m *DataAvailabilityHeader) GetColumnRoots() [][]byte { - if m != nil { - return m.ColumnRoots - } - return nil -} - -func init() { - proto.RegisterType((*DataAvailabilityHeader)(nil), "celestia.da.DataAvailabilityHeader") -} - -func init() { - proto.RegisterFile("celestia/da/data_availability_header.proto", fileDescriptor_93b487fd8444a5fd) -} - -var fileDescriptor_93b487fd8444a5fd = []byte{ - // 196 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4a, 0x4e, 0xcd, 0x49, - 0x2d, 0x2e, 0xc9, 0x4c, 0xd4, 0x4f, 0x01, 0xa1, 0x92, 0xc4, 0xf8, 0xc4, 0xb2, 0xc4, 0xcc, 0x9c, - 0xc4, 0xa4, 0xcc, 0x9c, 0xcc, 0x92, 0xca, 0xf8, 0x8c, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0xbd, 0x82, - 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x6e, 0x98, 0x5a, 0xbd, 0x94, 0x44, 0xa5, 0x08, 0x2e, 0x31, 0x97, - 0xc4, 0x92, 0x44, 0x47, 0x24, 0xd5, 0x1e, 0x60, 0xc5, 0x42, 0xd2, 0x5c, 0x9c, 0x45, 0xf9, 0xe5, - 0xf1, 0x45, 0xf9, 0xf9, 0x25, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0x3c, 0x41, 0x1c, 0x45, 0xf9, - 0xe5, 0x41, 0x20, 0xbe, 0x90, 0x22, 0x17, 0x4f, 0x72, 0x7e, 0x4e, 0x69, 0x6e, 0x1e, 0x54, 0x9e, - 0x09, 0x2c, 0xcf, 0x0d, 0x11, 0x03, 0x2b, 0x71, 0xf2, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, - 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, - 0x63, 0x39, 0x86, 0x28, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, - 0x98, 0x5b, 0xf2, 0x8b, 0xd2, 0xe1, 0x6c, 0xdd, 0xc4, 0x82, 0x02, 0x7d, 0xb0, 0x5b, 0xf5, 0x91, - 0xbc, 0x95, 0xc4, 0x06, 0x16, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xa3, 0x97, 0x36, - 0xec, 0x00, 0x00, 0x00, -} - -func (m *DataAvailabilityHeader) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DataAvailabilityHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DataAvailabilityHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ColumnRoots) > 0 { - for iNdEx := len(m.ColumnRoots) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ColumnRoots[iNdEx]) - copy(dAtA[i:], m.ColumnRoots[iNdEx]) - i = encodeVarintDataAvailabilityHeader(dAtA, i, uint64(len(m.ColumnRoots[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.RowRoots) > 0 { - for iNdEx := len(m.RowRoots) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.RowRoots[iNdEx]) - copy(dAtA[i:], m.RowRoots[iNdEx]) - i = encodeVarintDataAvailabilityHeader(dAtA, i, uint64(len(m.RowRoots[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintDataAvailabilityHeader(dAtA []byte, offset int, v uint64) int { - offset -= sovDataAvailabilityHeader(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *DataAvailabilityHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.RowRoots) > 0 { - for _, b := range m.RowRoots { - l = len(b) - n += 1 + l + sovDataAvailabilityHeader(uint64(l)) - } - } - if len(m.ColumnRoots) > 0 { - for _, b := range m.ColumnRoots { - l = len(b) - n += 1 + l + sovDataAvailabilityHeader(uint64(l)) - } - } - return n -} - -func sovDataAvailabilityHeader(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozDataAvailabilityHeader(x uint64) (n int) { - return sovDataAvailabilityHeader(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *DataAvailabilityHeader) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDataAvailabilityHeader - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DataAvailabilityHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DataAvailabilityHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RowRoots", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDataAvailabilityHeader - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthDataAvailabilityHeader - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthDataAvailabilityHeader - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RowRoots = append(m.RowRoots, make([]byte, postIndex-iNdEx)) - copy(m.RowRoots[len(m.RowRoots)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ColumnRoots", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDataAvailabilityHeader - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthDataAvailabilityHeader - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthDataAvailabilityHeader - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ColumnRoots = append(m.ColumnRoots, make([]byte, postIndex-iNdEx)) - copy(m.ColumnRoots[len(m.ColumnRoots)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipDataAvailabilityHeader(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthDataAvailabilityHeader - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipDataAvailabilityHeader(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowDataAvailabilityHeader - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowDataAvailabilityHeader - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowDataAvailabilityHeader - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthDataAvailabilityHeader - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupDataAvailabilityHeader - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthDataAvailabilityHeader - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthDataAvailabilityHeader = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowDataAvailabilityHeader = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupDataAvailabilityHeader = fmt.Errorf("proto: unexpected end of group") -) diff --git a/proto/vendor/celestia/minfee/v1/genesis.proto b/proto/vendor/celestia/minfee/v1/genesis.proto new file mode 100644 index 00000000..203d70f3 --- /dev/null +++ b/proto/vendor/celestia/minfee/v1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package celestia.minfee.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/celestiaorg/celestia-app/x/minfee"; + +// GenesisState defines the minfee module's genesis state. +message GenesisState { + string network_min_gas_price = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/vendor/celestia/minfee/v1/query.proto b/proto/vendor/celestia/minfee/v1/query.proto new file mode 100644 index 00000000..83f830e5 --- /dev/null +++ b/proto/vendor/celestia/minfee/v1/query.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package celestia.minfee.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/celestiaorg/celestia-app/x/minfee"; + +// Query defines the gRPC querier service. +service Query { + // NetworkMinGasPrice queries the network wide minimum gas price. + rpc NetworkMinGasPrice(QueryNetworkMinGasPrice) returns (QueryNetworkMinGasPriceResponse) { + option (google.api.http).get = "/celestia/minfee/v1/min_gas_price"; + } +} + +// QueryNetworkMinGasPrice is the request type for the Query/NetworkMinGasPrice RPC method. +message QueryNetworkMinGasPrice {} + +// QueryNetworkMinGasPriceResponse is the response type for Query/NetworkMinGasPrice RPC method. +message QueryNetworkMinGasPriceResponse { + string network_min_gas_price = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/vendor/celestia/qgb/v1/genesis.proto b/proto/vendor/celestia/qgb/v1/genesis.proto index 623c5e71..f574d88e 100644 --- a/proto/vendor/celestia/qgb/v1/genesis.proto +++ b/proto/vendor/celestia/qgb/v1/genesis.proto @@ -4,15 +4,15 @@ package celestia.qgb.v1; import "gogoproto/gogo.proto"; import "celestia/qgb/v1/types.proto"; -option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types"; +option go_package = "github.com/celestiaorg/celestia-app/x/blobstream/types"; -// Params represent the Quantum Gravity Bridge genesis and store parameters. +// Params represent Blobstream genesis and store parameters. message Params { option (gogoproto.stringer) = false; uint64 data_commitment_window = 1; } -// GenesisState struct, containing all persistent data required by the QGB +// GenesisState struct, containing all persistent data required by Blobstream // module message GenesisState { Params params = 1; } diff --git a/proto/vendor/celestia/qgb/v1/query.proto b/proto/vendor/celestia/qgb/v1/query.proto index f28547b1..83cc4451 100644 --- a/proto/vendor/celestia/qgb/v1/query.proto +++ b/proto/vendor/celestia/qgb/v1/query.proto @@ -4,16 +4,15 @@ package celestia.qgb.v1; import "celestia/qgb/v1/genesis.proto"; import "celestia/qgb/v1/types.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "google/protobuf/any.proto"; -option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types"; +option go_package = "github.com/celestiaorg/celestia-app/x/blobstream/types"; // Query defines the gRPC querier service. service Query { - // Params queries the current parameters for the qgb module + // Params queries the current parameters for the blobstream module rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/qgb/v1/params"; } diff --git a/proto/vendor/celestia/qgb/v1/tx.proto b/proto/vendor/celestia/qgb/v1/tx.proto index 62c808ba..b9c4fe1e 100644 --- a/proto/vendor/celestia/qgb/v1/tx.proto +++ b/proto/vendor/celestia/qgb/v1/tx.proto @@ -5,9 +5,9 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types"; +option go_package = "github.com/celestiaorg/celestia-app/x/blobstream/types"; -// Msg is the message server for receiving qgb transactions +// Msg is the message server for receiving Blobstream transactions service Msg { // RegisterEVMAddress records an evm address for the validator which is used // by the relayer to aggregate signatures. A validator can only register a diff --git a/proto/vendor/celestia/qgb/v1/types.proto b/proto/vendor/celestia/qgb/v1/types.proto index 386c278e..266788e2 100644 --- a/proto/vendor/celestia/qgb/v1/types.proto +++ b/proto/vendor/celestia/qgb/v1/types.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types"; +option go_package = "github.com/celestiaorg/celestia-app/x/blobstream/types"; // BridgeValidator represents a validator's ETH address and its power message BridgeValidator { @@ -15,7 +15,7 @@ message BridgeValidator { string evm_address = 2; } -// Valset is the EVM Bridge Multsig Set, each qgb validator also +// Valset is the EVM Bridge Multsig Set, each Blobstream validator also // maintains an ETH key to sign messages, these are used to check signatures on // ETH because of the significant gas savings message Valset { diff --git a/proto/vendor/celestia/signal/v1/query.proto b/proto/vendor/celestia/signal/v1/query.proto new file mode 100644 index 00000000..1d1b04f5 --- /dev/null +++ b/proto/vendor/celestia/signal/v1/query.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package celestia.signal.v1; + +import "google/api/annotations.proto"; +import "celestia/signal/v1/upgrade.proto"; + +option go_package = "github.com/celestiaorg/celestia-app/x/signal/types"; + +// Query defines the signal Query service. +service Query { + // VersionTally enables a client to query for the tally of voting power that + // has signalled for a particular version. + rpc VersionTally(QueryVersionTallyRequest) + returns (QueryVersionTallyResponse) { + option (google.api.http).get = "/signal/v1/tally/{version}"; + } + + // GetUpgrade enables a client to query for upgrade information if an upgrade is pending. + // The response will be empty if no upgrade is pending. + rpc GetUpgrade(QueryGetUpgradeRequest) + returns (QueryGetUpgradeResponse) { + option (google.api.http).get = "/signal/v1/upgrade"; + } +} + +// QueryVersionTallyRequest is the request type for the VersionTally query. +message QueryVersionTallyRequest { uint64 version = 1; } + +// QueryVersionTallyResponse is the response type for the VersionTally query. +message QueryVersionTallyResponse { + uint64 voting_power = 1; + uint64 threshold_power = 2; + uint64 total_voting_power = 3; +} + +// QueryGetUpgradeRequest is the request type for the GetUpgrade query. +message QueryGetUpgradeRequest {} + +// QueryGetUpgradeResponse is the response type for the GetUpgrade query. +message QueryGetUpgradeResponse { + Upgrade upgrade = 1; +} diff --git a/proto/vendor/celestia/signal/v1/tx.proto b/proto/vendor/celestia/signal/v1/tx.proto new file mode 100644 index 00000000..42634cea --- /dev/null +++ b/proto/vendor/celestia/signal/v1/tx.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package celestia.signal.v1; + +import "google/api/annotations.proto"; + +option go_package = "github.com/celestiaorg/celestia-app/x/signal/types"; + +// Msg defines the signal Msg service. +service Msg { + // SignalVersion allows a validator to signal for a version. + rpc SignalVersion(MsgSignalVersion) returns (MsgSignalVersionResponse) { + option (google.api.http).post = "/signal/v1/signal"; + } + + // TryUpgrade tallies all the votes for all the versions to determine if a + // quorum has been reached for a version. + rpc TryUpgrade(MsgTryUpgrade) returns (MsgTryUpgradeResponse) { + option (google.api.http).post = "/signal/v1/upgrade"; + } +} + +// MsgSignalVersion signals for an upgrade. +message MsgSignalVersion { + string validator_address = 1; + uint64 version = 2; +} + +// MsgSignalVersionResponse is the response type for the SignalVersion method. +message MsgSignalVersionResponse {} + +// MsgTryUpgrade tries to upgrade the chain. +message MsgTryUpgrade { string signer = 1; } + +// MsgTryUpgradeResponse is the response type for the TryUpgrade method. +message MsgTryUpgradeResponse {} diff --git a/proto/vendor/celestia/signal/v1/upgrade.proto b/proto/vendor/celestia/signal/v1/upgrade.proto new file mode 100644 index 00000000..6d5ac4e0 --- /dev/null +++ b/proto/vendor/celestia/signal/v1/upgrade.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package celestia.signal.v1; + +option go_package = "github.com/celestiaorg/celestia-app/x/signal/types"; + +// Upgrade is a type that represents a network upgrade. +message Upgrade { + // AppVersion is the app version that has received a quorum of validators to + // signal for it. + uint64 app_version = 1; + + // UpgradeHeight is the height at which the network should upgrade to the + // AppVersion. + int64 upgrade_height = 2; +} diff --git a/proto/vendor/go-header/p2p/pb/header_request.pb.go b/proto/vendor/go-header/p2p/pb/header_request.pb.go deleted file mode 100644 index e0b7e4f0..00000000 --- a/proto/vendor/go-header/p2p/pb/header_request.pb.go +++ /dev/null @@ -1,706 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: libs/header/p2p/pb/header_request.proto - -package p2p_pb - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StatusCode int32 - -const ( - StatusCode_INVALID StatusCode = 0 - StatusCode_OK StatusCode = 1 - StatusCode_NOT_FOUND StatusCode = 2 -) - -var StatusCode_name = map[int32]string{ - 0: "INVALID", - 1: "OK", - 2: "NOT_FOUND", -} - -var StatusCode_value = map[string]int32{ - "INVALID": 0, - "OK": 1, - "NOT_FOUND": 2, -} - -func (x StatusCode) String() string { - return proto.EnumName(StatusCode_name, int32(x)) -} - -func (StatusCode) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_43554822dc0b0806, []int{0} -} - -type HeaderRequest struct { - // Types that are valid to be assigned to Data: - // *HeaderRequest_Origin - // *HeaderRequest_Hash - Data isHeaderRequest_Data `protobuf_oneof:"data"` - Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *HeaderRequest) Reset() { *m = HeaderRequest{} } -func (m *HeaderRequest) String() string { return proto.CompactTextString(m) } -func (*HeaderRequest) ProtoMessage() {} -func (*HeaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_43554822dc0b0806, []int{0} -} -func (m *HeaderRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HeaderRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *HeaderRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HeaderRequest.Merge(m, src) -} -func (m *HeaderRequest) XXX_Size() int { - return m.Size() -} -func (m *HeaderRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HeaderRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HeaderRequest proto.InternalMessageInfo - -type isHeaderRequest_Data interface { - isHeaderRequest_Data() - MarshalTo([]byte) (int, error) - Size() int -} - -type HeaderRequest_Origin struct { - Origin uint64 `protobuf:"varint,1,opt,name=origin,proto3,oneof" json:"origin,omitempty"` -} -type HeaderRequest_Hash struct { - Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3,oneof" json:"hash,omitempty"` -} - -func (*HeaderRequest_Origin) isHeaderRequest_Data() {} -func (*HeaderRequest_Hash) isHeaderRequest_Data() {} - -func (m *HeaderRequest) GetData() isHeaderRequest_Data { - if m != nil { - return m.Data - } - return nil -} - -func (m *HeaderRequest) GetOrigin() uint64 { - if x, ok := m.GetData().(*HeaderRequest_Origin); ok { - return x.Origin - } - return 0 -} - -func (m *HeaderRequest) GetHash() []byte { - if x, ok := m.GetData().(*HeaderRequest_Hash); ok { - return x.Hash - } - return nil -} - -func (m *HeaderRequest) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*HeaderRequest) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*HeaderRequest_Origin)(nil), - (*HeaderRequest_Hash)(nil), - } -} - -type HeaderResponse struct { - Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` - StatusCode StatusCode `protobuf:"varint,2,opt,name=statusCode,proto3,enum=p2p.pb.StatusCode" json:"statusCode,omitempty"` -} - -func (m *HeaderResponse) Reset() { *m = HeaderResponse{} } -func (m *HeaderResponse) String() string { return proto.CompactTextString(m) } -func (*HeaderResponse) ProtoMessage() {} -func (*HeaderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43554822dc0b0806, []int{1} -} -func (m *HeaderResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HeaderResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *HeaderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HeaderResponse.Merge(m, src) -} -func (m *HeaderResponse) XXX_Size() int { - return m.Size() -} -func (m *HeaderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HeaderResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_HeaderResponse proto.InternalMessageInfo - -func (m *HeaderResponse) GetBody() []byte { - if m != nil { - return m.Body - } - return nil -} - -func (m *HeaderResponse) GetStatusCode() StatusCode { - if m != nil { - return m.StatusCode - } - return StatusCode_INVALID -} - -func init() { - proto.RegisterEnum("p2p.pb.StatusCode", StatusCode_name, StatusCode_value) - proto.RegisterType((*HeaderRequest)(nil), "p2p.pb.HeaderRequest") - proto.RegisterType((*HeaderResponse)(nil), "p2p.pb.HeaderResponse") -} - -func init() { - proto.RegisterFile("libs/header/p2p/pb/header_request.proto", fileDescriptor_43554822dc0b0806) -} - -var fileDescriptor_43554822dc0b0806 = []byte{ - // 271 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcd, 0x4a, 0xf3, 0x40, - 0x14, 0x86, 0x67, 0xfa, 0x85, 0xf9, 0xf0, 0xd8, 0x96, 0x32, 0x88, 0x64, 0x35, 0x94, 0x6e, 0x2c, - 0x2e, 0x12, 0x89, 0x57, 0x60, 0x2d, 0x92, 0xa2, 0x24, 0x30, 0xfe, 0xe0, 0x2e, 0x4c, 0xc8, 0x60, - 0x02, 0x9a, 0x19, 0x33, 0x93, 0x85, 0x77, 0xe1, 0x65, 0xb9, 0xec, 0xd2, 0xa5, 0x24, 0x37, 0x22, - 0x4e, 0xe3, 0xcf, 0xee, 0x3c, 0x3c, 0x2f, 0xe7, 0x3d, 0x1c, 0x38, 0x7a, 0xac, 0x72, 0x13, 0x96, - 0x52, 0x14, 0xb2, 0x09, 0x75, 0xa4, 0x43, 0x9d, 0x0f, 0x94, 0x35, 0xf2, 0xb9, 0x95, 0xc6, 0x06, - 0xba, 0x51, 0x56, 0x51, 0xa2, 0x23, 0x1d, 0xe8, 0x7c, 0x91, 0xc1, 0x24, 0x76, 0x9e, 0xef, 0x34, - 0xf5, 0x81, 0xa8, 0xa6, 0x7a, 0xa8, 0x6a, 0x1f, 0xcf, 0xf1, 0xd2, 0x8b, 0x11, 0x1f, 0x98, 0x1e, - 0x80, 0x57, 0x0a, 0x53, 0xfa, 0xa3, 0x39, 0x5e, 0x8e, 0x63, 0xc4, 0x1d, 0xd1, 0x43, 0x20, 0xe2, - 0x49, 0xb5, 0xb5, 0xf5, 0xff, 0x7d, 0xe5, 0xf9, 0x40, 0x2b, 0x02, 0x5e, 0x21, 0xac, 0x58, 0xdc, - 0xc3, 0xf4, 0xbb, 0xc0, 0x68, 0x55, 0x1b, 0x49, 0x29, 0x78, 0xb9, 0x2a, 0x5e, 0xdc, 0xfe, 0x31, - 0x77, 0x33, 0x8d, 0x00, 0x8c, 0x15, 0xb6, 0x35, 0xe7, 0xaa, 0x90, 0xae, 0x61, 0x1a, 0xd1, 0x60, - 0x77, 0x63, 0x70, 0xfd, 0x63, 0xf8, 0x9f, 0xd4, 0xf1, 0x09, 0xc0, 0xaf, 0xa1, 0xfb, 0xf0, 0x7f, - 0x93, 0xdc, 0x9d, 0x5d, 0x6d, 0xd6, 0x33, 0x44, 0x09, 0x8c, 0xd2, 0xcb, 0x19, 0xa6, 0x13, 0xd8, - 0x4b, 0xd2, 0x9b, 0xec, 0x22, 0xbd, 0x4d, 0xd6, 0xb3, 0xd1, 0xca, 0x7f, 0xeb, 0x18, 0xde, 0x76, - 0x0c, 0x7f, 0x74, 0x0c, 0xbf, 0xf6, 0x0c, 0x6d, 0x7b, 0x86, 0xde, 0x7b, 0x86, 0x72, 0xe2, 0xbe, - 0x72, 0xfa, 0x19, 0x00, 0x00, 0xff, 0xff, 0x04, 0xdd, 0x70, 0x54, 0x40, 0x01, 0x00, 0x00, -} - -func (m *HeaderRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HeaderRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Amount != 0 { - i = encodeVarintHeaderRequest(dAtA, i, uint64(m.Amount)) - i-- - dAtA[i] = 0x18 - } - if m.Data != nil { - { - size := m.Data.Size() - i -= size - if _, err := m.Data.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *HeaderRequest_Origin) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HeaderRequest_Origin) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i = encodeVarintHeaderRequest(dAtA, i, uint64(m.Origin)) - i-- - dAtA[i] = 0x8 - return len(dAtA) - i, nil -} -func (m *HeaderRequest_Hash) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HeaderRequest_Hash) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Hash != nil { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintHeaderRequest(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *HeaderResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HeaderResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.StatusCode != 0 { - i = encodeVarintHeaderRequest(dAtA, i, uint64(m.StatusCode)) - i-- - dAtA[i] = 0x10 - } - if len(m.Body) > 0 { - i -= len(m.Body) - copy(dAtA[i:], m.Body) - i = encodeVarintHeaderRequest(dAtA, i, uint64(len(m.Body))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintHeaderRequest(dAtA []byte, offset int, v uint64) int { - offset -= sovHeaderRequest(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *HeaderRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Data != nil { - n += m.Data.Size() - } - if m.Amount != 0 { - n += 1 + sovHeaderRequest(uint64(m.Amount)) - } - return n -} - -func (m *HeaderRequest_Origin) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 1 + sovHeaderRequest(uint64(m.Origin)) - return n -} -func (m *HeaderRequest_Hash) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Hash != nil { - l = len(m.Hash) - n += 1 + l + sovHeaderRequest(uint64(l)) - } - return n -} -func (m *HeaderResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Body) - if l > 0 { - n += 1 + l + sovHeaderRequest(uint64(l)) - } - if m.StatusCode != 0 { - n += 1 + sovHeaderRequest(uint64(m.StatusCode)) - } - return n -} - -func sovHeaderRequest(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozHeaderRequest(x uint64) (n int) { - return sovHeaderRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *HeaderRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HeaderRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType) - } - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Data = &HeaderRequest_Origin{v} - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHeaderRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHeaderRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Data = &HeaderRequest_Hash{v} - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipHeaderRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthHeaderRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HeaderResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HeaderResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHeaderRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHeaderRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Body = append(m.Body[:0], dAtA[iNdEx:postIndex]...) - if m.Body == nil { - m.Body = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StatusCode", wireType) - } - m.StatusCode = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StatusCode |= StatusCode(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipHeaderRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthHeaderRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipHeaderRequest(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHeaderRequest - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthHeaderRequest - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupHeaderRequest - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthHeaderRequest - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthHeaderRequest = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowHeaderRequest = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupHeaderRequest = fmt.Errorf("proto: unexpected end of group") -) diff --git a/proto/vendor/header/pb/extended_header.proto b/proto/vendor/header/pb/extended_header.proto index aafb5753..e93b64d8 100644 --- a/proto/vendor/header/pb/extended_header.proto +++ b/proto/vendor/header/pb/extended_header.proto @@ -4,13 +4,13 @@ package header.pb; import "tendermint/types/types.proto"; import "tendermint/types/validator.proto"; -import "celestia/da/data_availability_header.proto"; +import "celestia/core/v1/da/data_availability_header.proto"; message ExtendedHeader { tendermint.types.Header header = 1; tendermint.types.Commit commit = 2; tendermint.types.ValidatorSet validator_set = 3; - celestia.da.DataAvailabilityHeader dah = 4; + celestia.core.v1.da.DataAvailabilityHeader dah = 4; } // Generated with: diff --git a/proto/vendor/nmt/pb/proof.proto b/proto/vendor/nmt/pb/proof.proto index 431685a6..9b48d392 100644 --- a/proto/vendor/nmt/pb/proof.proto +++ b/proto/vendor/nmt/pb/proof.proto @@ -1,4 +1,4 @@ -syntax="proto3"; +syntax = "proto3"; package proof.pb; @@ -6,10 +6,10 @@ option go_package = "github.com/celestiaorg/nmt/pb"; message Proof { // Start index of the leaves that match the queried namespace.ID. - int64 start = 1; + int64 start = 1; // End index (non-inclusive) of the leaves that match the queried // namespace.ID. - int64 end = 2; + int64 end = 2; // Nodes hold the tree nodes necessary for the Merkle range proof. repeated bytes nodes = 3; // leaf_hash contains the namespace.ID if NMT does not have it and @@ -18,5 +18,5 @@ message Proof { bytes leaf_hash = 4; // The is_max_namespace_ignored flag influences the calculation of the // namespace ID range for intermediate nodes in the tree. - bool is_max_namespace_ignored=5; -} \ No newline at end of file + bool is_max_namespace_ignored = 5; +} diff --git a/proto/vendor/tendermint/abci/types.proto b/proto/vendor/tendermint/abci/types.proto index deb43974..2adc2ba7 100644 --- a/proto/vendor/tendermint/abci/types.proto +++ b/proto/vendor/tendermint/abci/types.proto @@ -11,6 +11,7 @@ import "tendermint/crypto/keys.proto"; import "tendermint/types/params.proto"; import "google/protobuf/timestamp.proto"; import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; // This file is copied from http://github.com/tendermint/abci // NOTE: When using custom types, mind the warnings. @@ -47,6 +48,11 @@ message RequestEcho { message RequestFlush {} +message TimeoutsInfo { + google.protobuf.Duration timeout_propose = 1 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + google.protobuf.Duration timeout_commit = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; +} + message RequestInfo { string version = 1; uint64 block_version = 2; @@ -108,8 +114,9 @@ message RequestListSnapshots {} // offers a snapshot to the application message RequestOfferSnapshot { - Snapshot snapshot = 1; // snapshot offered by peers - bytes app_hash = 2; // light client-verified app hash for snapshot height + Snapshot snapshot = 1; // snapshot offered by peers + bytes app_hash = 2; // light client-verified app hash for snapshot height + uint64 app_version = 3; // The application version at which the snapshot was taken } // loads a snapshot chunk @@ -193,6 +200,8 @@ message ResponseInfo { int64 last_block_height = 4; bytes last_block_app_hash = 5; + + TimeoutsInfo timeouts = 6 [(gogoproto.nullable) = false]; } // nondeterministic @@ -207,6 +216,7 @@ message ResponseInitChain { ConsensusParams consensus_params = 1; repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; bytes app_hash = 3; + TimeoutsInfo timeouts = 4 [(gogoproto.nullable) = false]; } message ResponseQuery { @@ -264,6 +274,7 @@ message ResponseEndBlock { ConsensusParams consensus_param_updates = 2; repeated Event events = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; + TimeoutsInfo timeouts = 4 [(gogoproto.nullable) = false]; } message ResponseCommit { diff --git a/proto/vendor/tendermint/state/types.proto b/proto/vendor/tendermint/state/types.proto index f3fdc0ef..9796a8fc 100644 --- a/proto/vendor/tendermint/state/types.proto +++ b/proto/vendor/tendermint/state/types.proto @@ -77,4 +77,7 @@ message State { // the latest AppHash we've received from calling abci.Commit() bytes app_hash = 13; + + // timeouts to be used for the next block height + tendermint.abci.TimeoutsInfo timeouts = 15 [(gogoproto.nullable) = false]; } diff --git a/proto/vendor/tendermint/store/types.proto b/proto/vendor/tendermint/store/types.proto index e1d994b4..64a32d1f 100644 --- a/proto/vendor/tendermint/store/types.proto +++ b/proto/vendor/tendermint/store/types.proto @@ -11,11 +11,11 @@ message BlockStoreState { // TxInfo describes the location of a tx inside a committed block // as well as the result of executing the transaction and the error log output. message TxInfo { - int64 height = 1; - uint32 index = 2; + int64 height = 1; + uint32 index = 2; // The response code of executing the tx. 0 means // successfully executed, all others are error codes. - uint32 code = 3; + uint32 code = 3; // The error log output generated if the transaction execution fails. - string error = 4; + string error = 4; } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index c96e048a..fb4880bd 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -26,7 +26,6 @@ celestia-tendermint.workspace = true prost.workspace = true async-trait = "0.1.80" -cosmrs = "0.21.0" futures = "0.3.31" jsonrpsee = { version = "0.24.2", features = ["client-core", "macros"] } serde = { version = "1.0.203", features = ["derive"] } @@ -36,7 +35,6 @@ tracing = "0.1.40" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] http = "1.1.0" jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] } -pbjson-types = "0.7.0" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] libp2p = { workspace = true, features = [ @@ -58,10 +56,9 @@ getrandom = { version = "0.2.15", features = ["js"] } wasm-bindgen-test = "0.3.42" [features] -default = ["p2p", "secp256k1"] +default = ["p2p"] p2p = ["celestia-types/p2p"] wasm-bindgen = ["celestia-types/wasm-bindgen", "jsonrpsee/wasm-client"] -secp256k1 = ["celestia-tendermint/secp256k1"] [package.metadata.docs.rs] features = ["p2p"] diff --git a/rpc/tests/utils/client.rs b/rpc/tests/utils/client.rs index 80101034..55beb7de 100644 --- a/rpc/tests/utils/client.rs +++ b/rpc/tests/utils/client.rs @@ -25,7 +25,7 @@ pub enum AuthLevel { Admin, } -pub fn token_from_env(auth_level: AuthLevel) -> Result> { +fn token_from_env(auth_level: AuthLevel) -> Result> { match auth_level { AuthLevel::Public => Ok(None), AuthLevel::Read => Ok(Some(env::var("CELESTIA_NODE_AUTH_TOKEN_READ")?)), @@ -34,7 +34,7 @@ pub fn token_from_env(auth_level: AuthLevel) -> Result> { } } -pub fn env_or(var_name: &str, or_value: &str) -> String { +fn env_or(var_name: &str, or_value: &str) -> String { env::var(var_name).unwrap_or_else(|_| or_value.to_owned()) } diff --git a/tonic/src/tendermint.rs b/tonic/src/tendermint.rs deleted file mode 100644 index 8f14a7d7..00000000 --- a/tonic/src/tendermint.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::Error; -use crate::tonic::GrpcClient; - -use celestia_proto::cosmos::base::tendermint::v1beta1::{ - service_client::ServiceClient as TendermintServiceClient, - GetNodeInfoRequest, -}; - - -impl GrpcClient { - async fn get_node_info(&self) -> Result<(), Error> { - let service_client = TendermintServiceClient::with_interceptor(self.grpc_channel, self.auth_interceptor); - let request = GetNodeInfoRequest {}; - - let node_info = service_client.get_node_info(request).await?; - - node_info - } -} diff --git a/tools/update-proto-vendor.sh b/tools/update-proto-vendor.sh index 2626c054..075a90f1 100755 --- a/tools/update-proto-vendor.sh +++ b/tools/update-proto-vendor.sh @@ -23,8 +23,9 @@ rm -rf ../target/proto-vendor-src mkdir -p ../target/proto-vendor-src extract_urls ../target/proto-vendor-src \ - https://github.com/celestiaorg/celestia-app/archive/refs/tags/v1.12.0.tar.gz \ + https://github.com/celestiaorg/celestia-app/archive/refs/tags/v2.3.1.tar.gz \ https://github.com/celestiaorg/celestia-core/archive/refs/heads/v0.34.x-celestia.tar.gz \ + https://github.com/celestiaorg/celestia-node/archive/refs/heads/main.tar.gz \ https://github.com/celestiaorg/cosmos-sdk/archive/refs/heads/release/v0.46.x-celestia.tar.gz \ https://github.com/celestiaorg/nmt/archive/refs/heads/main.tar.gz \ https://github.com/cosmos/cosmos-proto/archive/refs/tags/v1.0.0-alpha7.tar.gz \ @@ -35,7 +36,7 @@ extract_urls ../target/proto-vendor-src \ mkdir -p vendor rm -rf vendor/celestia -cp -r ../target/proto-vendor-src/celestia-app-1.12.0/proto/celestia vendor +cp -r ../target/proto-vendor-src/celestia-app-2.3.1/proto/celestia vendor rm -rf vendor/go-header mkdir -p vendor/go-header/p2p @@ -56,21 +57,21 @@ rm -rf vendor/google mkdir -p vendor/google/api cp ../target/proto-vendor-src/googleapis-master/google/api/{annotations.proto,http.proto} vendor/google/api -#rm -rf vendor/header -#mkdir -p vendor/header -#cp -r ../target/proto-vendor-src/celestia-node-shwap/header/pb vendor/header -# -#rm -rf vendor/share -#mkdir -p vendor/share -#shwap_dir=../target/proto-vendor-src/celestia-node-shwap/share -#find "$shwap_dir" -name pb -type d -print0 | while read -r -d '' pb_dir; do -# # remove prefix -# out_dir="${pb_dir#"$shwap_dir"}" -# # remove /pb suffix -# out_dir="vendor/share/${out_dir%/*}" -# mkdir -p "$out_dir" -# cp -r "$pb_dir" "$out_dir" -#done +rm -rf vendor/header +mkdir -p vendor/header +cp -r ../target/proto-vendor-src/celestia-node-main/header/pb vendor/header + +rm -rf vendor/share +mkdir -p vendor/share +main_dir=../target/proto-vendor-src/celestia-node-main/share +find "$main_dir" -name pb -type d -print0 | while read -r -d '' pb_dir; do + # remove prefix + out_dir="${pb_dir#"$main_dir"}" + # remove /pb suffix + out_dir="vendor/share/${out_dir%/*}" + mkdir -p "$out_dir" + cp -r "$pb_dir" "$out_dir" +done rm -rf vendor/tendermint cp -r ../target/proto-vendor-src/celestia-core-0.34.x-celestia/proto/tendermint vendor diff --git a/types/Cargo.toml b/types/Cargo.toml index af3b28a7..de934a2b 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -25,7 +25,6 @@ bech32 = "0.11.0" bytes = "1.6.0" cid = { version = "0.11.1", default-features = false, features = ["std"] } const_format = "0.2.32" -cosmrs = "0.21.0" ed25519-consensus = { version = "2.1.0", optional = true } enum_dispatch = "0.3.13" leopard-codec = "0.1.0" diff --git a/types/src/auth.rs b/types/src/auth.rs index 88bbfe6b..71845cec 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -1,6 +1,11 @@ -//! TODO: +//! types related to accounts -use cosmrs::crypto::PublicKey; +use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; +use celestia_proto::cosmos::auth::v1beta1::ModuleAccount as RawModuleAccount; +use celestia_tendermint::public_key::PublicKey; +use celestia_tendermint_proto::Protobuf; + +use crate::Error; /// Params defines the parameters for the auth module. #[derive(Debug)] @@ -17,17 +22,87 @@ pub struct AuthParams { pub sig_verify_cost_secp256k1: u64, } -/// BaseAccount defines a base account type. It contains all the necessary fields -/// for basic account functionality. Any custom account type should extend this -/// type for additional functionality (e.g. vesting). -#[derive(Debug)] +/// [`BaseAccount`] defines a base account type. +/// +/// It contains all the necessary fields for basic account functionality. +/// +/// Any custom account type should extend this type for additional functionality +/// (e.g. vesting). +#[derive(Debug, Clone, PartialEq)] pub struct BaseAccount { - /// hex encoded hash address of the account + /// Bech32 [`AccountId`] of this account. pub address: String, - /// Public key associated with the account - pub pub_key: PublicKey, - /// TODO: + /// Optional [`PublicKey`] associated with this account. + pub pub_key: Option, + /// `account_number` is the account number of the account in state pub account_number: u64, - /// TODO: + /// Sequence of the account, which describes the number of committed transactions signed by a + /// given address. pub sequence: u64, } + +/// ModuleAccount defines an account for modules that holds coins on a pool. +#[derive(Debug, Clone, PartialEq)] +pub struct ModuleAccount { + /// [`BaseAccount`] specification of this module account. + pub base_account: Option, + /// Name of the module. + pub name: String, + /// Permissions associated with this module account. + pub permissions: Vec, +} + +impl From for RawBaseAccount { + fn from(account: BaseAccount) -> Self { + RawBaseAccount { + address: account.address, + pub_key: None, //todo!(), + account_number: account.account_number, + sequence: account.sequence, + } + } +} + +impl TryFrom for BaseAccount { + type Error = Error; + + fn try_from(account: RawBaseAccount) -> Result { + Ok(BaseAccount { + address: account.address, + pub_key: None, + account_number: account.account_number, + sequence: account.sequence, + }) + } +} + +impl From for RawModuleAccount { + fn from(account: ModuleAccount) -> Self { + let base_account = account.base_account.map(BaseAccount::into); + RawModuleAccount { + base_account, + name: account.name, + permissions: account.permissions, + } + } +} + +impl TryFrom for ModuleAccount { + type Error = Error; + + fn try_from(account: RawModuleAccount) -> Result { + let base_account = account + .base_account + .map(RawBaseAccount::try_into) + .transpose()?; + Ok(ModuleAccount { + base_account, + name: account.name, + permissions: account.permissions, + }) + } +} + +impl Protobuf for BaseAccount {} + +impl Protobuf for ModuleAccount {} diff --git a/types/src/data_availability_header.rs b/types/src/data_availability_header.rs index 53373a59..8095c889 100644 --- a/types/src/data_availability_header.rs +++ b/types/src/data_availability_header.rs @@ -1,6 +1,6 @@ use std::ops::RangeInclusive; -use celestia_proto::celestia::da::DataAvailabilityHeader as RawDataAvailabilityHeader; +use celestia_proto::celestia::core::v1::da::DataAvailabilityHeader as RawDataAvailabilityHeader; use celestia_tendermint::merkle::simple_hash_from_byte_vectors; use celestia_tendermint_proto::v0_34::types::RowProof as RawRowProof; use celestia_tendermint_proto::Protobuf; diff --git a/types/src/error.rs b/types/src/error.rs index b85513d4..9d877f0d 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -164,6 +164,10 @@ pub enum Error { #[error("Invalid balance amount: {0}")] InvalidBalanceAmount(String), + /// Invalid Public Key + #[error("Invalid Public Key")] + InvalidPublicKeyType(String), + /// Unsupported fraud proof type. #[error("Unsupported fraud proof type: {0}")] UnsupportedFraudProofType(String), From df97053f6881ab36c20a36b29d452a38157ca647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 08:26:32 +0100 Subject: [PATCH 16/56] fix wasm --- Cargo.toml | 1 + grpc/Cargo.toml | 7 ++----- grpc/src/lib.rs | 3 +-- proto/Cargo.toml | 13 +++++++------ types/src/auth.rs | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 008c51c1..5f638809 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ blockstore = "0.7.0" lumina-node = { version = "0.5.1", path = "node" } lumina-node-wasm = { version = "0.5.2", path = "node-wasm" } celestia-proto = { version = "0.4.1", path = "proto" } +celestia-grpc = { version = "0.1.0", path = "grpc" } celestia-rpc = { version = "0.6.0", path = "rpc", default-features = false } celestia-types = { version = "0.6.1", path = "types", default-features = false } celestia-tendermint = { version = "0.32.2", default-features = false } diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index d411cde2..4ea777b2 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -31,13 +31,10 @@ thiserror = "1.0.61" tonic = { version = "0.12.3", default-features = false, features = [ "codegen", "prost" ]} +pbjson-types = "0.7.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] anyhow = "1.0.86" dotenvy = "0.15.7" -pbjson-types = "0.7.0" tokio = { version = "1.38.0", features = ["rt", "macros"] } - -[features] -default = ["transport"] -transport = ["tonic/transport"] +tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "transport" ] } diff --git a/grpc/src/lib.rs b/grpc/src/lib.rs index 80c7df3b..2fe75817 100644 --- a/grpc/src/lib.rs +++ b/grpc/src/lib.rs @@ -1,11 +1,10 @@ #![doc = include_str!("../README.md")] +#![cfg(not(target_arch = "wasm32"))] -#[cfg(feature = "transport")] mod client; mod error; /// Custom types and wrappers needed by gRPC pub mod types; -#[cfg(feature = "transport")] pub use crate::client::GrpcClient; pub use crate::error::{Error, Result}; diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 4db3b614..7d87522a 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -25,18 +25,19 @@ tonic = { version = "0.12.3", optional = true, default-features = false, feature "codegen", "prost" ]} -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "transport" ] } - -[target.'cfg(not(target_arch = "wasm32"))'.build-dependencies] -tonic-build = { version = "0.12.3", optional = true } - [build-dependencies] prost-build.workspace = true prost-types.workspace = true protox = "0.7.1" tempfile = { version = "3.13.0", optional = true } pbjson-build = { version = "0.7.0", optional = true } +tonic-build = { version = "0.12.3", default-features = false, optional = true, features = [ "prost" ]} + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "transport" ] } +tonic-build = { version = "0.12.3", optional = true, default-features = false, features = ["transport"] } + +#[target.'cfg(not(target_arch = "wasm32"))'.build-dependencies] [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.42" diff --git a/types/src/auth.rs b/types/src/auth.rs index 71845cec..b5b1f059 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -30,9 +30,9 @@ pub struct AuthParams { /// (e.g. vesting). #[derive(Debug, Clone, PartialEq)] pub struct BaseAccount { - /// Bech32 [`AccountId`] of this account. + /// Bech32 `AccountId` of this account. pub address: String, - /// Optional [`PublicKey`] associated with this account. + /// Optional `PublicKey` associated with this account. pub pub_key: Option, /// `account_number` is the account number of the account in state pub account_number: u64, From 9de6b1184bf046cd67d5c41fc1d4ec469412a010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 08:52:13 +0100 Subject: [PATCH 17/56] fix wasm --- grpc/tests/tonic.rs | 2 ++ grpc/tests/utils.rs | 2 ++ proto/src/lib.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index b98fd7a5..36be6721 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -1,3 +1,5 @@ +#![cfg(not(target_arch = "wasm32"))] + use celestia_grpc::types::auth::Account; pub mod utils; diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index b9889442..68729b63 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -1,3 +1,5 @@ +#![cfg(not(target_arch = "wasm32"))] + use std::env; use anyhow::Result; diff --git a/proto/src/lib.rs b/proto/src/lib.rs index ae5945d1..5c930b55 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -1,5 +1,6 @@ #![allow(clippy::all)] #![allow(missing_docs)] +#![allow(rustdoc::invalid_rust_codeblocks)] #![doc = include_str!("../README.md")] pub mod serializers; From d6ac94a8c381819d4188a0008a7c308dd2703718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 09:59:51 +0100 Subject: [PATCH 18/56] missed serialisation --- proto/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/build.rs b/proto/build.rs index 508b7b89..f609a2e4 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -51,7 +51,7 @@ static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ #[rustfmt::skip] static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ - (".celestia.da.DataAvailabilityHeader.row_roots", VEC_BASE64STRING), + (".celestia.core.v1.da.DataAvailabilityHeader.row_roots", VEC_BASE64STRING), (".celestia.core.v1.da.DataAvailabilityHeader.column_roots", VEC_BASE64STRING), #[cfg(not(feature = "tonic"))] (".cosmos.base.abci.v1beta1.TxResponse.tx", OPTION_ANY), From 97218051327d7faaf4ccea190795456b649b3667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 10:13:56 +0100 Subject: [PATCH 19/56] doctests --- proto/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 5c930b55..0bbd3ce0 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -1,6 +1,7 @@ #![allow(clippy::all)] #![allow(missing_docs)] #![allow(rustdoc::invalid_rust_codeblocks)] +#![cfg(not(doctest))] #![doc = include_str!("../README.md")] pub mod serializers; From 007ecccdf4effb5e11aef8b4b8d9a7d2f237ea2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 10:40:18 +0100 Subject: [PATCH 20/56] lasts tests --- grpc/grpc_method_macro/src/lib.rs | 4 ++-- proto/Cargo.toml | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/grpc/grpc_method_macro/src/lib.rs b/grpc/grpc_method_macro/src/lib.rs index a434b4ea..f2656f2e 100644 --- a/grpc/grpc_method_macro/src/lib.rs +++ b/grpc/grpc_method_macro/src/lib.rs @@ -1,7 +1,7 @@ //! Helper crate for grpc_method macro for creating gRPC methods //! //! # Example -//! ``` +//! ```rust,ignore //! use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient; //! # use tonic::service::Interceptor; //! # use tonic::transport::Channel; @@ -22,7 +22,7 @@ //! #[grpc_method(AuthQueryClient::params)] //! async fn get_auth_params(&mut self) -> Result; //! } -//! ```` +//! ``` extern crate proc_macro; diff --git a/proto/Cargo.toml b/proto/Cargo.toml index cec03b22..21d0d4f4 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -37,8 +37,6 @@ tonic-build = { version = "0.12.3", default-features = false, optional = true, f tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "transport" ] } tonic-build = { version = "0.12.3", optional = true, default-features = false, features = ["transport"] } -#[target.'cfg(not(target_arch = "wasm32"))'.build-dependencies] - [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.42" From 150b007ecd30520e3b00e16d648efb20ffaed3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 15:59:08 +0100 Subject: [PATCH 21/56] fix any pubkey --- Cargo.lock | 3 +++ grpc/Cargo.toml | 2 +- proto/build.rs | 1 + types/Cargo.toml | 4 +++- types/src/auth.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++-- types/src/error.rs | 4 ++++ 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c2ec22c..2ed9e739 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -839,10 +839,12 @@ dependencies = [ "flex-error", "futures", "instant", + "k256", "num-traits", "once_cell", "prost", "prost-types", + "ripemd", "serde", "serde_bytes", "serde_json", @@ -894,6 +896,7 @@ dependencies = [ "multiaddr", "multihash", "nmt-rs", + "pbjson-types", "prost", "rand", "ruint", diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index 4ea777b2..67dca2cb 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -20,7 +20,7 @@ categories = [ [dependencies] celestia-tendermint-proto.workspace = true -celestia-types.workspace = true +celestia-types = { workspace = true, features = [ "tonic" ] } celestia-proto = { workspace = true, features = [ "tonic" ] } celestia-tendermint.workspace = true prost.workspace = true diff --git a/proto/build.rs b/proto/build.rs index f609a2e4..5bed272d 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -87,6 +87,7 @@ const PROTO_FILES: &[&str] = &[ "vendor/cosmos/base/node/v1beta1/query.proto", "vendor/cosmos/base/tendermint/v1beta1/query.proto", "vendor/cosmos/base/v1beta1/coin.proto", + "vendor/cosmos/crypto/ed25519/keys.proto", "vendor/cosmos/crypto/multisig/v1beta1/multisig.proto", "vendor/cosmos/crypto/secp256k1/keys.proto", "vendor/cosmos/staking/v1beta1/query.proto", diff --git a/types/Cargo.toml b/types/Cargo.toml index c4eb03b1..64ec07c5 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -16,7 +16,7 @@ categories = ["encoding", "cryptography::cryptocurrencies"] [dependencies] blockstore.workspace = true celestia-proto.workspace = true -celestia-tendermint = { workspace = true, features = ["std", "rust-crypto"] } +celestia-tendermint = { workspace = true, features = ["std", "rust-crypto", "secp256k1"] } celestia-tendermint-proto.workspace = true nmt-rs.workspace = true @@ -31,6 +31,7 @@ leopard-codec = "0.1.0" libp2p-identity = { version = "0.2.9", optional = true } multiaddr = { version = "0.18.1", optional = true } multihash = "0.19.1" +pbjson-types = { version = "0.7.0", optional = true } prost = { workspace = true } rand = { version = "0.8.5", optional = true } ruint = { version = "1.12.3", features = ["serde"] } @@ -60,6 +61,7 @@ default = ["p2p"] p2p = ["dep:libp2p-identity", "dep:multiaddr", "dep:serde_repr"] test-utils = ["dep:ed25519-consensus", "dep:rand"] wasm-bindgen = ["celestia-tendermint/wasm-bindgen"] +tonic = ["dep:pbjson-types"] [package.metadata.docs.rs] features = ["p2p", "test-utils"] diff --git a/types/src/auth.rs b/types/src/auth.rs index b5b1f059..092ca2b0 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -2,11 +2,20 @@ use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; use celestia_proto::cosmos::auth::v1beta1::ModuleAccount as RawModuleAccount; +use celestia_proto::cosmos::crypto::ed25519::PubKey as Ed25519PubKey; +use celestia_proto::cosmos::crypto::secp256k1::PubKey as Secp256k1PubKey; use celestia_tendermint::public_key::PublicKey; use celestia_tendermint_proto::Protobuf; +#[cfg(feature = "tonic")] +use pbjson_types::Any; +use prost::Message; + use crate::Error; +const COSMOS_ED25519_PUBKEY: &str = "/cosmos.crypto.ed25519.PubKey"; +const COSMOS_SECP256K1_PUBKEY: &str = "/cosmos.crypto.secp256k1.PubKey"; + /// Params defines the parameters for the auth module. #[derive(Debug)] pub struct AuthParams { @@ -56,7 +65,7 @@ impl From for RawBaseAccount { fn from(account: BaseAccount) -> Self { RawBaseAccount { address: account.address, - pub_key: None, //todo!(), + pub_key: account.pub_key.map(any_from_public_key), account_number: account.account_number, sequence: account.sequence, } @@ -67,9 +76,10 @@ impl TryFrom for BaseAccount { type Error = Error; fn try_from(account: RawBaseAccount) -> Result { + let pub_key = account.pub_key.map(public_key_from_any).transpose()?; Ok(BaseAccount { address: account.address, - pub_key: None, + pub_key, account_number: account.account_number, sequence: account.sequence, }) @@ -103,6 +113,41 @@ impl TryFrom for ModuleAccount { } } +fn public_key_from_any(any: Any) -> Result { + match any.type_url.as_ref() { + COSMOS_ED25519_PUBKEY => { + PublicKey::from_raw_ed25519(&Ed25519PubKey::decode(&*any.value)?.key) + } + COSMOS_SECP256K1_PUBKEY => { + PublicKey::from_raw_secp256k1(&Secp256k1PubKey::decode(&*any.value)?.key) + } + other => return Err(Error::InvalidPublicKeyType(other.to_string())), + } + .ok_or(Error::InvalidPublicKey) +} + +fn any_from_public_key(key: PublicKey) -> Any { + match key { + key @ PublicKey::Ed25519(_) => Any { + type_url: COSMOS_ED25519_PUBKEY.to_string(), + value: Ed25519PubKey { + key: key.to_bytes(), + } + .encode_to_vec() + .into(), + }, + key @ PublicKey::Secp256k1(_) => Any { + type_url: COSMOS_SECP256K1_PUBKEY.to_string(), + value: Secp256k1PubKey { + key: key.to_bytes(), + } + .encode_to_vec() + .into(), + }, + _ => unimplemented!("unexpected key type"), + } +} + impl Protobuf for BaseAccount {} impl Protobuf for ModuleAccount {} diff --git a/types/src/error.rs b/types/src/error.rs index 66f9011e..e819087e 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -117,6 +117,10 @@ pub enum Error { #[error("Invalid proof type: {0}")] InvalidShwapProofType(i32), + /// Could not deserialise Public Key + #[error("Could not deserialize public key")] + InvalidPublicKey, + /// Range proof verification error. #[error("Range proof verification failed: {0:?}")] RangeProofError(nmt_rs::simple_merkle::error::RangeProofError), From 2011a373188c809d423df48128a27bc7d4309a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 8 Nov 2024 16:27:25 +0100 Subject: [PATCH 22/56] refix wasm --- Cargo.lock | 1 + types/Cargo.toml | 3 ++- types/src/auth.rs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2ed9e739..43ba8bc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -898,6 +898,7 @@ dependencies = [ "nmt-rs", "pbjson-types", "prost", + "prost-types", "rand", "ruint", "serde", diff --git a/types/Cargo.toml b/types/Cargo.toml index 64ec07c5..1bfc62d1 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -19,6 +19,7 @@ celestia-proto.workspace = true celestia-tendermint = { workspace = true, features = ["std", "rust-crypto", "secp256k1"] } celestia-tendermint-proto.workspace = true nmt-rs.workspace = true +prost.workspace = true base64 = "0.22.1" bech32 = "0.11.0" @@ -32,7 +33,6 @@ libp2p-identity = { version = "0.2.9", optional = true } multiaddr = { version = "0.18.1", optional = true } multihash = "0.19.1" pbjson-types = { version = "0.7.0", optional = true } -prost = { workspace = true } rand = { version = "0.8.5", optional = true } ruint = { version = "1.12.3", features = ["serde"] } serde = { version = "1.0.203", features = ["derive"] } @@ -54,6 +54,7 @@ indoc = "2.0.5" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] getrandom = { version = "0.2.15", features = ["js"] } +prost-types.workspace = true wasm-bindgen-test = "0.3.42" [features] diff --git a/types/src/auth.rs b/types/src/auth.rs index 092ca2b0..3de4a978 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -10,6 +10,8 @@ use celestia_tendermint_proto::Protobuf; #[cfg(feature = "tonic")] use pbjson_types::Any; use prost::Message; +#[cfg(not(feature = "tonic"))] +use prost_types::Any; use crate::Error; From 6f9f898a73c57560d33e4d56eebb908e421614be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 12 Nov 2024 07:46:19 +0100 Subject: [PATCH 23/56] deps --- types/Cargo.toml | 2 +- types/src/auth.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/Cargo.toml b/types/Cargo.toml index 1bfc62d1..603ea6b9 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -20,6 +20,7 @@ celestia-tendermint = { workspace = true, features = ["std", "rust-crypto", "sec celestia-tendermint-proto.workspace = true nmt-rs.workspace = true prost.workspace = true +prost-types.workspace = true base64 = "0.22.1" bech32 = "0.11.0" @@ -54,7 +55,6 @@ indoc = "2.0.5" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] getrandom = { version = "0.2.15", features = ["js"] } -prost-types.workspace = true wasm-bindgen-test = "0.3.42" [features] diff --git a/types/src/auth.rs b/types/src/auth.rs index 3de4a978..331af420 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -9,9 +9,9 @@ use celestia_tendermint_proto::Protobuf; #[cfg(feature = "tonic")] use pbjson_types::Any; -use prost::Message; #[cfg(not(feature = "tonic"))] use prost_types::Any; +use prost::Message; use crate::Error; From 8a7086a3cef65495750a5832cc1d1b810deaefcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 12 Nov 2024 08:37:34 +0100 Subject: [PATCH 24/56] fmt --- types/src/auth.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/src/auth.rs b/types/src/auth.rs index 331af420..65d86d20 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -11,7 +11,10 @@ use celestia_tendermint_proto::Protobuf; use pbjson_types::Any; #[cfg(not(feature = "tonic"))] use prost_types::Any; +// workaround for otherwise unused prost-types if tonic feature flag is enabled tripping up CI use prost::Message; +#[allow(unused_imports)] +use prost_types::Any as _; use crate::Error; From fc9d6ee20175820c62174135a421d3ad2d863c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 14 Nov 2024 09:22:00 +0100 Subject: [PATCH 25/56] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yiannis Marangos Signed-off-by: Mikołaj Florkiewicz --- grpc/Cargo.toml | 2 +- grpc/grpc_method_macro/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index 67dca2cb..640c56fb 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -24,7 +24,7 @@ celestia-types = { workspace = true, features = [ "tonic" ] } celestia-proto = { workspace = true, features = [ "tonic" ] } celestia-tendermint.workspace = true prost.workspace = true -grpc_method.path = "./grpc_method_macro" +grpc_method = { version = "0.1.0", path = "grpc_method_macro" } cosmrs = "0.21.0" thiserror = "1.0.61" diff --git a/grpc/grpc_method_macro/Cargo.toml b/grpc/grpc_method_macro/Cargo.toml index a0fab9c2..31318038 100644 --- a/grpc/grpc_method_macro/Cargo.toml +++ b/grpc/grpc_method_macro/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "grpc_method" +name = "celestia-grpc-macros" version = "0.1.0" edition = "2021" From 1bc3379b25fc0c154320675b8d3db4a0d786e876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 14 Nov 2024 09:23:22 +0100 Subject: [PATCH 26/56] pr review --- Cargo.lock | 10 ++++++---- Cargo.toml | 4 ++-- .../Cargo.toml | 0 .../src/lib.rs | 0 grpc/src/lib.rs | 1 - grpc/src/types.rs | 2 ++ tools/update-proto-vendor.sh | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) rename grpc/{grpc_method_macro => celestia-grpc-macros}/Cargo.toml (100%) rename grpc/{grpc_method_macro => celestia-grpc-macros}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 43ba8bc6..9ccb223a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -828,8 +828,9 @@ dependencies = [ [[package]] name = "celestia-tendermint" -version = "0.32.2" -source = "git+https://github.com/eigerco/celestia-tendermint-rs/?branch=chore%2Fprost-0.13.3#7c77122234fcc8473b99345ba4fe943d89438fbd" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da8dd966aaa817ce6e320bc4037a29094354f5d2cee19758498de2f98642c64" dependencies = [ "bytes", "celestia-tendermint-proto", @@ -859,8 +860,9 @@ dependencies = [ [[package]] name = "celestia-tendermint-proto" -version = "0.32.2" -source = "git+https://github.com/eigerco/celestia-tendermint-rs/?branch=chore%2Fprost-0.13.3#7c77122234fcc8473b99345ba4fe943d89438fbd" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bbd5c2345d29ea85566ad8a1114cc0dfb20dacf8f9e0722d64886d0e1e064f7" dependencies = [ "bytes", "flex-error", diff --git a/Cargo.toml b/Cargo.toml index 3ddc477b..d36892ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ prost-types = "0.13.3" # Uncomment to apply local changes #beetswap = { path = "../beetswap" } #blockstore = { path = "../blockstore" } -celestia-tendermint = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } -celestia-tendermint-proto = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } +#celestia-tendermint = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } +#celestia-tendermint-proto = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } #nmt-rs = { path = "../nmt-rs" } #libp2p = { path = "../../rust-libp2p/libp2p" } #libp2p-core = { path = "../../rust-libp2p/core" } diff --git a/grpc/grpc_method_macro/Cargo.toml b/grpc/celestia-grpc-macros/Cargo.toml similarity index 100% rename from grpc/grpc_method_macro/Cargo.toml rename to grpc/celestia-grpc-macros/Cargo.toml diff --git a/grpc/grpc_method_macro/src/lib.rs b/grpc/celestia-grpc-macros/src/lib.rs similarity index 100% rename from grpc/grpc_method_macro/src/lib.rs rename to grpc/celestia-grpc-macros/src/lib.rs diff --git a/grpc/src/lib.rs b/grpc/src/lib.rs index 2fe75817..9e68cbfa 100644 --- a/grpc/src/lib.rs +++ b/grpc/src/lib.rs @@ -3,7 +3,6 @@ mod client; mod error; -/// Custom types and wrappers needed by gRPC pub mod types; pub use crate::client::GrpcClient; diff --git a/grpc/src/types.rs b/grpc/src/types.rs index 9a2fff8e..6ba06aaa 100644 --- a/grpc/src/types.rs +++ b/grpc/src/types.rs @@ -1,3 +1,5 @@ +//! Custom types and wrappers needed by gRPC + use prost::Message; use celestia_proto::celestia::blob::v1::{ diff --git a/tools/update-proto-vendor.sh b/tools/update-proto-vendor.sh index 5018234b..5b850524 100755 --- a/tools/update-proto-vendor.sh +++ b/tools/update-proto-vendor.sh @@ -66,7 +66,7 @@ mkdir -p vendor/share shwap_dir=../target/proto-vendor-src/celestia-node-main/share find "$shwap_dir" -name pb -type d -print0 | while read -r -d '' pb_dir; do # remove prefix - out_dir="${pb_dir#"$main_dir"}" + out_dir="${pb_dir#"$shwap_dir"}" # remove /pb suffix out_dir="vendor/share/${out_dir%/*}" mkdir -p "$out_dir" From e00bd0bb06d46c28bd2e32571131f8620884200c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 14 Nov 2024 09:32:50 +0100 Subject: [PATCH 27/56] fix --- Cargo.lock | 20 +++++++++---------- grpc/Cargo.toml | 2 +- .../Cargo.toml | 0 .../src/lib.rs | 0 grpc/src/client.rs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename grpc/{celestia-grpc-macros => grpc-macros}/Cargo.toml (100%) rename grpc/{celestia-grpc-macros => grpc-macros}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 9ccb223a..c2f9751f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -765,13 +765,13 @@ name = "celestia-grpc" version = "0.1.0" dependencies = [ "anyhow", + "celestia-grpc-macros", "celestia-proto", "celestia-tendermint", "celestia-tendermint-proto", "celestia-types", "cosmrs", "dotenvy", - "grpc_method", "pbjson-types", "prost", "thiserror", @@ -779,6 +779,15 @@ dependencies = [ "tonic", ] +[[package]] +name = "celestia-grpc-macros" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "celestia-proto" version = "0.5.0" @@ -1933,15 +1942,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "grpc_method" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "h2" version = "0.3.26" diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index 640c56fb..15812aa9 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -24,7 +24,7 @@ celestia-types = { workspace = true, features = [ "tonic" ] } celestia-proto = { workspace = true, features = [ "tonic" ] } celestia-tendermint.workspace = true prost.workspace = true -grpc_method = { version = "0.1.0", path = "grpc_method_macro" } +celestia-grpc-macros = { version = "0.1.0", path = "grpc-macros" } cosmrs = "0.21.0" thiserror = "1.0.61" diff --git a/grpc/celestia-grpc-macros/Cargo.toml b/grpc/grpc-macros/Cargo.toml similarity index 100% rename from grpc/celestia-grpc-macros/Cargo.toml rename to grpc/grpc-macros/Cargo.toml diff --git a/grpc/celestia-grpc-macros/src/lib.rs b/grpc/grpc-macros/src/lib.rs similarity index 100% rename from grpc/celestia-grpc-macros/src/lib.rs rename to grpc/grpc-macros/src/lib.rs diff --git a/grpc/src/client.rs b/grpc/src/client.rs index b49497b9..ce356cde 100644 --- a/grpc/src/client.rs +++ b/grpc/src/client.rs @@ -11,7 +11,7 @@ use celestia_tendermint_proto::v0_34::types::BlobTx; use celestia_types::auth::AuthParams; use celestia_types::blob::BlobParams; -use grpc_method::grpc_method; +use celestia_grpc_macros::grpc_method; use crate::types::auth::Account; use crate::types::tx::{GetTxResponse, TxResponse}; From da920c264bdb3a6a2ea70488cef87edf83a07706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 15 Nov 2024 09:05:19 +0100 Subject: [PATCH 28/56] types cleanup --- grpc/src/types/tx.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index f107e008..747ffdae 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -1,7 +1,9 @@ use cosmrs::Tx; +use celestia_proto::cosmos::base::abci::v1beta1::AbciMessageLog; use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; use celestia_proto::cosmos::tx::v1beta1::{BroadcastTxResponse, GetTxResponse as RawGetTxResponse}; +use celestia_tendermint_proto::v0_34::abci::Event; use crate::types::FromGrpcResponse; use crate::Error; @@ -27,9 +29,9 @@ pub struct TxResponse { /// non-deterministic. pub raw_log: String, - // The output of the application's logger (typed). May be non-deterministic. - //#[serde(with = "crate::serializers::null_default")] - //pub logs: ::prost::alloc::vec::Vec, + /// The output of the application's logger (typed). May be non-deterministic. + pub logs: Vec, + /// Additional information. May be non-deterministic. pub info: String, @@ -39,21 +41,19 @@ pub struct TxResponse { /// Amount of gas consumed by transaction. pub gas_used: i64, - // The request transaction bytes. - //#[serde(with = "crate::serializers::option_any")] - //pub tx: ::core::option::Option<::pbjson_types::Any>, + /// The request transaction bytes. + pub tx: ::core::option::Option<::pbjson_types::Any>, + /// Time of the previous block. For heights > 1, it's the weighted median of /// the timestamps of the valid votes in the block.LastCommit. For height == 1, /// it's genesis time. pub timestamp: String, - // Events defines all the events emitted by processing a transaction. Note, - // these events include those emitted by processing all the messages and those - // emitted from the ante. Whereas Logs contains the events, with - // additional metadata, emitted only by processing the messages. - // - // Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 - //#[serde(with = "crate::serializers::null_default")] - //pub events: ::prost::alloc::vec::Vec< ::celestia_tendermint_proto::v0_34::abci::Event, >, + + /// Events defines all the events emitted by processing a transaction. Note, + /// these events include those emitted by processing all the messages and those + /// emitted from the ante. Whereas Logs contains the events, with + /// additional metadata, emitted only by processing the messages. + pub events: Vec, } /// Response to GetTx @@ -77,13 +77,13 @@ impl TryFrom for TxResponse { code: response.code, data: response.data, raw_log: response.raw_log, - //logs: response.logs + logs: response.logs, info: response.info, gas_wanted: response.gas_wanted, gas_used: response.gas_used, - //tx: response.tx + tx: response.tx, timestamp: response.timestamp, - //events: response.events + events: response.events, }) } } From e5adde78e6b9a5d0a5ee8ce24bc7c8990ccd20bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 15 Nov 2024 09:52:57 +0100 Subject: [PATCH 29/56] revert toml --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d36892ce..44a6ede7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ prost-types = "0.13.3" # Uncomment to apply local changes #beetswap = { path = "../beetswap" } #blockstore = { path = "../blockstore" } -#celestia-tendermint = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } -#celestia-tendermint-proto = { git = "https://github.com/eigerco/celestia-tendermint-rs/", branch = "chore/prost-0.13.3" } +#celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } +#celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } #nmt-rs = { path = "../nmt-rs" } #libp2p = { path = "../../rust-libp2p/libp2p" } #libp2p-core = { path = "../../rust-libp2p/core" } From 4df09f7ea8ab7fd543dc62905ba2be9fb0ef72e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 19 Nov 2024 19:05:35 +0100 Subject: [PATCH 30/56] blob submission --- Cargo.lock | 145 ++++++++++++++++++++++---------------- Cargo.toml | 8 +-- ci/run-validator.sh | 4 ++ grpc/Cargo.toml | 6 +- grpc/src/client.rs | 10 ++- grpc/src/error.rs | 4 ++ grpc/src/types.rs | 20 ------ grpc/src/types/auth.rs | 12 +++- grpc/src/types/tx.rs | 148 ++++++++++++++++++++++++++++++++++++--- grpc/tests/tonic.rs | 81 +++++++++++++++++++++- grpc/tests/utils.rs | 16 ++++- proto/Cargo.toml | 5 +- proto/build.rs | 8 ++- proto/src/cosmrs/mod.rs | 149 ++++++++++++++++++++++++++++++++++++++++ proto/src/lib.rs | 2 + types/src/auth.rs | 19 +++-- types/src/blob.rs | 99 +++++++++++++++++++++++++- types/src/error.rs | 8 +++ 18 files changed, 632 insertions(+), 112 deletions(-) create mode 100644 proto/src/cosmrs/mod.rs diff --git a/Cargo.lock b/Cargo.lock index c2f9751f..b5f9ec85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror", + "thiserror 1.0.64", "time", ] @@ -563,7 +563,7 @@ dependencies = [ "multihash-codetable", "quick-protobuf", "smallvec", - "thiserror", + "thiserror 1.0.64", "time", "tracing", "unsigned-varint 0.8.0", @@ -685,7 +685,7 @@ dependencies = [ "multihash", "redb", "rexie", - "thiserror", + "thiserror 1.0.64", "tokio", "wasm-bindgen", ] @@ -770,11 +770,15 @@ dependencies = [ "celestia-tendermint", "celestia-tendermint-proto", "celestia-types", + "cosmos-sdk-proto", "cosmrs", "dotenvy", + "hex", + "k256", "pbjson-types", "prost", - "thiserror", + "serde", + "thiserror 1.0.64", "tokio", "tonic", ] @@ -794,6 +798,7 @@ version = "0.5.0" dependencies = [ "celestia-tendermint-proto", "cosmos-sdk-proto", + "cosmrs", "pbjson", "pbjson-build", "pbjson-types", @@ -804,6 +809,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "thiserror 2.0.3", "tonic", "tonic-build", "wasm-bindgen-test", @@ -829,7 +835,7 @@ dependencies = [ "prost", "rand", "serde", - "thiserror", + "thiserror 1.0.64", "tokio", "tracing", "wasm-bindgen-test", @@ -837,9 +843,7 @@ dependencies = [ [[package]] name = "celestia-tendermint" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da8dd966aaa817ce6e320bc4037a29094354f5d2cee19758498de2f98642c64" +version = "0.33.0" dependencies = [ "bytes", "celestia-tendermint-proto", @@ -869,9 +873,7 @@ dependencies = [ [[package]] name = "celestia-tendermint-proto" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bbd5c2345d29ea85566ad8a1114cc0dfb20dacf8f9e0722d64886d0e1e064f7" +version = "0.33.0" dependencies = [ "bytes", "flex-error", @@ -916,7 +918,7 @@ dependencies = [ "serde_json", "serde_repr", "sha2 0.10.8", - "thiserror", + "thiserror 1.0.64", "time", "wasm-bindgen-test", ] @@ -1137,6 +1139,7 @@ checksum = "a4c1a5856db92cd90dddc955bce308703d3519fb33ae3d0b8f3658e9cfd05c3f" dependencies = [ "prost", "tendermint-proto", + "tonic", ] [[package]] @@ -1156,7 +1159,7 @@ dependencies = [ "signature", "subtle-encoding", "tendermint", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -1467,7 +1470,7 @@ dependencies = [ "rand_core", "serde", "sha2 0.9.9", - "thiserror", + "thiserror 1.0.64", "zeroize", ] @@ -1888,7 +1891,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -2051,7 +2054,7 @@ dependencies = [ "once_cell", "rand", "socket2", - "thiserror", + "thiserror 1.0.64", "tinyvec", "tokio", "tracing", @@ -2074,7 +2077,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror", + "thiserror 1.0.64", "tokio", "tracing", ] @@ -2279,7 +2282,7 @@ checksum = "3afe8830d5802f769dc0be20a87f9f116798c896650cb6266eb5c19a3c109eed" dependencies = [ "js-sys", "num-traits", - "thiserror", + "thiserror 1.0.64", "tokio", "wasm-bindgen", "web-sys", @@ -2484,7 +2487,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.64", "walkdir", ] @@ -2535,7 +2538,7 @@ dependencies = [ "rustls-pki-types", "rustls-platform-verifier", "soketto", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-rustls", "tokio-util", @@ -2561,7 +2564,7 @@ dependencies = [ "rustc-hash", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-stream", "tracing", @@ -2586,7 +2589,7 @@ dependencies = [ "rustls-platform-verifier", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tokio", "tower 0.4.13", "tracing", @@ -2615,7 +2618,7 @@ dependencies = [ "http 1.1.0", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -2651,7 +2654,9 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "once_cell", "sha2 0.10.8", + "signature", ] [[package]] @@ -2677,7 +2682,7 @@ checksum = "ee58dbc414bd23885d7da915e0457618b36d1fc950a6169ef2cb29829d1b1a1d" dependencies = [ "bytes", "lazy_static", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -2728,7 +2733,7 @@ dependencies = [ "multiaddr", "pin-project", "rw-stream-sink", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -2764,7 +2769,7 @@ dependencies = [ "quick-protobuf-codec", "rand", "rand_core", - "thiserror", + "thiserror 1.0.64", "tracing", "void", "web-time", @@ -2803,7 +2808,7 @@ dependencies = [ "rand", "rw-stream-sink", "smallvec", - "thiserror", + "thiserror 1.0.64", "tracing", "unsigned-varint 0.8.0", "void", @@ -2832,7 +2837,7 @@ dependencies = [ "rw-stream-sink", "serde", "smallvec", - "thiserror", + "thiserror 1.0.64", "tracing", "unsigned-varint 0.8.0", "void", @@ -2905,7 +2910,7 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "smallvec", - "thiserror", + "thiserror 1.0.64", "tracing", "void", ] @@ -2924,7 +2929,7 @@ dependencies = [ "rand", "serde", "sha2 0.10.8", - "thiserror", + "thiserror 1.0.64", "tracing", "zeroize", ] @@ -2952,7 +2957,7 @@ dependencies = [ "serde", "sha2 0.10.8", "smallvec", - "thiserror", + "thiserror 1.0.64", "tracing", "uint", "void", @@ -3019,7 +3024,7 @@ dependencies = [ "sha2 0.10.8", "snow", "static_assertions", - "thiserror", + "thiserror 1.0.64", "tracing", "x25519-dalek", "zeroize", @@ -3062,7 +3067,7 @@ dependencies = [ "ring 0.17.8", "rustls", "socket2", - "thiserror", + "thiserror 1.0.64", "tokio", "tracing", ] @@ -3156,7 +3161,7 @@ dependencies = [ "ring 0.17.8", "rustls", "rustls-webpki 0.101.7", - "thiserror", + "thiserror 1.0.64", "x509-parser", "yasna", ] @@ -3192,7 +3197,7 @@ dependencies = [ "pin-project-lite", "rw-stream-sink", "soketto", - "thiserror", + "thiserror 1.0.64", "tracing", "url", "webpki-roots 0.25.4", @@ -3210,7 +3215,7 @@ dependencies = [ "libp2p-core 0.41.3", "parking_lot", "send_wrapper 0.6.0", - "thiserror", + "thiserror 1.0.64", "tracing", "wasm-bindgen", "web-sys", @@ -3228,7 +3233,7 @@ dependencies = [ "libp2p-core 0.42.0", "parking_lot", "send_wrapper 0.6.0", - "thiserror", + "thiserror 1.0.64", "tracing", "wasm-bindgen", "web-sys", @@ -3248,7 +3253,7 @@ dependencies = [ "multiaddr", "multihash", "send_wrapper 0.6.0", - "thiserror", + "thiserror 1.0.64", "tracing", "wasm-bindgen", "wasm-bindgen-futures", @@ -3264,7 +3269,7 @@ dependencies = [ "either", "futures", "libp2p-core 0.42.0", - "thiserror", + "thiserror 1.0.64", "tracing", "yamux 0.12.1", "yamux 0.13.3", @@ -3422,7 +3427,7 @@ dependencies = [ "serde_json", "smallvec", "tempfile", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-util", "tracing", @@ -3453,7 +3458,7 @@ dependencies = [ "serde-wasm-bindgen", "serde_json", "serde_repr", - "thiserror", + "thiserror 1.0.64", "time", "tokio", "tracing", @@ -3500,7 +3505,7 @@ checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ "cfg-if", "miette-derive", - "thiserror", + "thiserror 1.0.64", "unicode-width", ] @@ -3708,7 +3713,7 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -3722,7 +3727,7 @@ dependencies = [ "log", "netlink-packet-core", "netlink-sys", - "thiserror", + "thiserror 1.0.64", "tokio", ] @@ -4082,7 +4087,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.64", "ucd-trie", ] @@ -4380,7 +4385,7 @@ dependencies = [ "prost-reflect", "prost-types", "protox-parse", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -4392,7 +4397,7 @@ dependencies = [ "logos", "miette", "prost-types", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -4419,7 +4424,7 @@ dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", - "thiserror", + "thiserror 1.0.64", "unsigned-varint 0.8.0", ] @@ -4437,7 +4442,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2", - "thiserror", + "thiserror 1.0.64", "tokio", "tracing", ] @@ -4454,7 +4459,7 @@ dependencies = [ "rustc-hash", "rustls", "slab", - "thiserror", + "thiserror 1.0.64", "tinyvec", "tracing", ] @@ -4564,7 +4569,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -4634,7 +4639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "887466cfa8a12c08ee4b174998135cea8ff0fd84858627cd793e56535a045bc9" dependencies = [ "idb", - "thiserror", + "thiserror 1.0.64", "wasm-bindgen", ] @@ -4738,7 +4743,7 @@ dependencies = [ "netlink-packet-route", "netlink-proto", "nix", - "thiserror", + "thiserror 1.0.64", "tokio", ] @@ -5088,9 +5093,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -5117,9 +5122,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -5526,7 +5531,16 @@ version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.64", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -5540,6 +5554,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -5799,7 +5824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" dependencies = [ "crossbeam-channel", - "thiserror", + "thiserror 1.0.64", "time", "tracing-subscriber", ] @@ -6434,7 +6459,7 @@ dependencies = [ "nom", "oid-registry", "rusticata-macros", - "thiserror", + "thiserror 1.0.64", "time", ] diff --git a/Cargo.toml b/Cargo.toml index 44a6ede7..0f231f23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ celestia-proto = { version = "0.5.0", path = "proto" } celestia-grpc = { version = "0.1.0", path = "grpc" } celestia-rpc = { version = "0.7.1", path = "rpc", default-features = false } celestia-types = { version = "0.8.0", path = "types", default-features = false } -celestia-tendermint = { version = "0.32.2", default-features = false } -celestia-tendermint-proto = "0.32.2" +celestia-tendermint = { version = "0.33.0", default-features = false } +celestia-tendermint-proto = "0.33.0" libp2p = "0.54.0" nmt-rs = "0.2.1" @@ -23,8 +23,8 @@ prost-types = "0.13.3" # Uncomment to apply local changes #beetswap = { path = "../beetswap" } #blockstore = { path = "../blockstore" } -#celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } -#celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } +celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } +celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } #nmt-rs = { path = "../nmt-rs" } #libp2p = { path = "../../rust-libp2p/libp2p" } #libp2p-core = { path = "../../rust-libp2p/core" } diff --git a/ci/run-validator.sh b/ci/run-validator.sh index 47b6d71b..7d6db003 100755 --- a/ci/run-validator.sh +++ b/ci/run-validator.sh @@ -105,6 +105,10 @@ provision_bridge_nodes() { echo "Provisioning finished." } +provision_grpc_account() { + #celestia-appd keys import +} + # Set up the validator for a private alone network. # Based on # https://github.com/celestiaorg/celestia-app/blob/main/scripts/single-node.sh diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index 15812aa9..5ab9ffb1 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -21,12 +21,16 @@ categories = [ [dependencies] celestia-tendermint-proto.workspace = true celestia-types = { workspace = true, features = [ "tonic" ] } -celestia-proto = { workspace = true, features = [ "tonic" ] } +celestia-proto = { workspace = true, features = [ "tonic", "cosmrs" ] } celestia-tendermint.workspace = true prost.workspace = true celestia-grpc-macros = { version = "0.1.0", path = "grpc-macros" } +cosmos-sdk-proto = "0.26.0" +hex = "0.4.3" +serde = "1.0.215" cosmrs = "0.21.0" +k256 = "0.13.4" thiserror = "1.0.61" tonic = { version = "0.12.3", default-features = false, features = [ "codegen", "prost" diff --git a/grpc/src/client.rs b/grpc/src/client.rs index ce356cde..de4efdc6 100644 --- a/grpc/src/client.rs +++ b/grpc/src/client.rs @@ -6,10 +6,10 @@ use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient as AuthQuer use celestia_proto::cosmos::base::node::v1beta1::service_client::ServiceClient as ConfigServiceClient; use celestia_proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient as TendermintServiceClient; use celestia_proto::cosmos::tx::v1beta1::service_client::ServiceClient as TxServiceClient; +use celestia_proto::cosmos::tx::v1beta1::Tx as RawTx; use celestia_tendermint::block::Block; -use celestia_tendermint_proto::v0_34::types::BlobTx; use celestia_types::auth::AuthParams; -use celestia_types::blob::BlobParams; +use celestia_types::blob::{Blob, BlobParams}; use celestia_grpc_macros::grpc_method; @@ -53,9 +53,6 @@ where #[grpc_method(TendermintServiceClient::get_block_by_height)] async fn get_block_by_height(&mut self, height: i64) -> Result; - // TODO get_node_info - // make_method!(TendermintServiceClient::get_node_info; get_node_info() -> NodeInfo); - /// Get blob params #[grpc_method(BlobQueryClient::params)] async fn get_blob_params(&mut self) -> Result; @@ -77,7 +74,8 @@ where #[grpc_method(TxServiceClient::broadcast_tx)] async fn broadcast_tx( &mut self, - blob_tx: BlobTx, + tx: RawTx, + blobs: Vec, mode: BroadcastMode, ) -> Result; diff --git a/grpc/src/error.rs b/grpc/src/error.rs index c096f04f..64c99e68 100644 --- a/grpc/src/error.rs +++ b/grpc/src/error.rs @@ -27,6 +27,10 @@ pub enum Error { #[error(transparent)] CelestiaTypesError(#[from] celestia_types::Error), + /// Error coming from a celestia-proto cosmrs compatibility layer + //#[error(transparent)] + //CelestiaProtoCosmrsError(#[from] celestia_proto::cosmrs::Error), + /// Tendermint Proto Error #[error(transparent)] TendermintProtoError(#[from] celestia_tendermint_proto::Error), diff --git a/grpc/src/types.rs b/grpc/src/types.rs index 6ba06aaa..ead99ebf 100644 --- a/grpc/src/types.rs +++ b/grpc/src/types.rs @@ -1,7 +1,5 @@ //! Custom types and wrappers needed by gRPC -use prost::Message; - use celestia_proto::celestia::blob::v1::{ QueryParamsRequest as QueryBlobParamsRequest, QueryParamsResponse as QueryBlobParamsResponse, }; @@ -10,9 +8,7 @@ use celestia_proto::cosmos::base::tendermint::v1beta1::{ GetBlockByHeightRequest, GetBlockByHeightResponse, GetLatestBlockRequest, GetLatestBlockResponse, }; -use celestia_proto::cosmos::tx::v1beta1::{BroadcastMode, BroadcastTxRequest, GetTxRequest}; use celestia_tendermint::block::Block; -use celestia_tendermint_proto::v0_34::types::BlobTx; use celestia_types::blob::BlobParams; use crate::Error; @@ -86,22 +82,6 @@ impl IntoGrpcParam for i64 { } } -impl IntoGrpcParam for (BlobTx, BroadcastMode) { - fn into_parameter(self) -> BroadcastTxRequest { - let (blob_tx, mode) = self; - BroadcastTxRequest { - tx_bytes: blob_tx.encode_to_vec(), - mode: mode.into(), - } - } -} - -impl IntoGrpcParam for String { - fn into_parameter(self) -> GetTxRequest { - GetTxRequest { hash: self } - } -} - make_empty_params!(GetLatestBlockRequest); make_empty_params!(ConfigRequest); make_empty_params!(QueryBlobParamsRequest); diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index 971e805f..7783db99 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -5,6 +5,7 @@ use celestia_proto::cosmos::auth::v1beta1::{ QueryAccountResponse, QueryAccountsRequest, QueryAccountsResponse, QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, }; +use celestia_tendermint_proto::google::protobuf::Any; use celestia_types::auth::{AuthParams, BaseAccount, ModuleAccount}; use crate::types::make_empty_params; @@ -21,6 +22,15 @@ pub enum Account { Module(ModuleAccount), } +impl Account { + pub fn base_account_ref(&self) -> Option<&BaseAccount> { + match self { + Account::Base(acct) => Some(&acct), + Account::Module(acct) => acct.base_account.as_ref(), + } + } +} + impl FromGrpcResponse for QueryAuthParamsResponse { fn try_from_response(self) -> Result { let params = self.params.ok_or(Error::FailedToParseResponse)?; @@ -60,7 +70,7 @@ impl IntoGrpcParam for () { } } -fn account_from_any(any: pbjson_types::Any) -> Result { +fn account_from_any(any: Any) -> Result { let account = if any.type_url == RawBaseAccount::type_url() { let base_account = RawBaseAccount::decode(&*any.value).map_err(|_| Error::FailedToParseResponse)?; diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 747ffdae..bd67e395 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -1,14 +1,35 @@ +use std::convert::Infallible; + +use celestia_tendermint_proto::google::protobuf::Any; use cosmrs::Tx; +use k256::ecdsa::{signature::Signer, Signature}; +use prost::{Message, Name}; +use serde::{Deserialize, Serialize}; + +use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; use celestia_proto::cosmos::base::abci::v1beta1::AbciMessageLog; use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; -use celestia_proto::cosmos::tx::v1beta1::{BroadcastTxResponse, GetTxResponse as RawGetTxResponse}; +use celestia_proto::cosmos::base::v1beta1::Coin; +use celestia_proto::cosmos::crypto::secp256k1; +use celestia_proto::cosmos::tx::v1beta1::mode_info::{Single, Sum}; +use celestia_proto::cosmos::tx::v1beta1::SignDoc; +use celestia_proto::cosmos::tx::v1beta1::{ + AuthInfo, BroadcastTxResponse, Fee, GetTxRequest as RawGetTxRequest, + GetTxResponse as RawGetTxResponse, ModeInfo, SignerInfo, Tx as RawTx, TxBody, +}; +use celestia_proto::cosmos::tx::v1beta1::{BroadcastMode, BroadcastTxRequest, GetTxRequest}; use celestia_tendermint_proto::v0_34::abci::Event; +use celestia_tendermint_proto::v0_34::types::{Blob as RawBlob, BlobTx as RawBlobTx}; +use celestia_tendermint_proto::Protobuf; +use celestia_types::auth::{AccountKeypair, BaseAccount}; +use celestia_types::blob::{Blob, MsgPayForBlobs}; -use crate::types::FromGrpcResponse; +use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; /// Response to a tx query +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct TxResponse { /// The block height pub height: i64, @@ -42,7 +63,7 @@ pub struct TxResponse { pub gas_used: i64, /// The request transaction bytes. - pub tx: ::core::option::Option<::pbjson_types::Any>, + pub tx: Option, /// Time of the previous block. For heights > 1, it's the weighted median of /// the timestamps of the valid votes in the block.LastCommit. For height == 1, @@ -57,6 +78,7 @@ pub struct TxResponse { } /// Response to GetTx +#[derive(Debug)] pub struct GetTxResponse { /// Response Transaction pub tx: Tx, @@ -69,7 +91,6 @@ impl TryFrom for TxResponse { type Error = Error; fn try_from(response: RawTxResponse) -> Result { - // TODO: add missing fields with conversion Ok(TxResponse { height: response.height, txhash: response.txhash, @@ -102,13 +123,17 @@ impl FromGrpcResponse for RawGetTxResponse { .tx_response .ok_or(Error::FailedToParseResponse)? .try_into()?; + let tx = self.tx.ok_or(Error::FailedToParseResponse)?; + + let cosmrs_tx_body: cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody = + tx.body.ok_or(Error::FailedToParseResponse)?.into(); + let cosmrs_auth_info: cosmos_sdk_proto::cosmos::tx::v1beta1::AuthInfo = + tx.auth_info.ok_or(Error::FailedToParseResponse)?.into(); + let cosmos_tx = Tx { - body: tx.body.ok_or(Error::FailedToParseResponse)?.try_into()?, - auth_info: tx - .auth_info - .ok_or(Error::FailedToParseResponse)? - .try_into()?, + body: cosmrs_tx_body.try_into()?, + auth_info: cosmrs_auth_info.try_into()?, signatures: tx.signatures, }; @@ -118,3 +143,108 @@ impl FromGrpcResponse for RawGetTxResponse { }) } } + +impl IntoGrpcParam for (RawTx, Vec, BroadcastMode) { + fn into_parameter(self) -> BroadcastTxRequest { + let (tx, blobs, mode) = self; + assert!(blobs.len() > 0); + let blob_tx = new_blob_tx(&tx, blobs); + BroadcastTxRequest { + tx_bytes: blob_tx.encode_to_vec(), + mode: mode.into(), + } + } +} + +impl IntoGrpcParam for String { + fn into_parameter(self) -> RawGetTxRequest { + RawGetTxRequest { hash: self } + } +} + +pub fn prep_signed_tx( + msg_pay_for_blobs: &MsgPayForBlobs, + base_account: &BaseAccount, + gas_limit: u64, + fee: u64, + chain_id: String, + account_keys: AccountKeypair, +) -> RawTx { + // From https://github.com/celestiaorg/celestia-app/blob/v2.3.1/pkg/appconsts/global_consts.go#L77 + const FEE_DENOM: &str = "utia"; + // From https://github.com/celestiaorg/cosmos-sdk/blob/v1.25.0-sdk-v0.46.16/proto/cosmos/tx/signing/v1beta1/signing.proto#L24 + const SIGNING_MODE_INFO: Option = Some(ModeInfo { + sum: Some(Sum::Single(Single { mode: 1 })), + }); + + let fee = Fee { + amount: vec![Coin { + denom: FEE_DENOM.to_string(), + amount: fee.to_string(), + }], + gas_limit, + ..Fee::default() + }; + + let public_key = secp256k1::PubKey { + key: account_keys + .verifying_key + .to_encoded_point(true) + .as_bytes() + .to_vec(), + }; + + let public_key_as_any = Any { + type_url: secp256k1::PubKey::type_url(), + value: public_key.encode_to_vec().into(), + }; + + let auth_info = AuthInfo { + signer_infos: vec![SignerInfo { + public_key: Some(public_key_as_any.into()), + mode_info: SIGNING_MODE_INFO, + sequence: base_account.sequence, + }], + fee: Some(fee), + tip: None, + }; + + let msg_pay_for_blobs_value: Result<_, Infallible> = msg_pay_for_blobs.encode_vec(); + let msg_pay_for_blobs_as_any = Any { + type_url: RawMsgPayForBlobs::type_url(), + value: msg_pay_for_blobs_value.expect("Result to be Infallible"), + }; + + let tx_body = TxBody { + messages: vec![msg_pay_for_blobs_as_any], + ..TxBody::default() + }; + + let bytes_to_sign = SignDoc { + body_bytes: tx_body.encode_to_vec(), + auth_info_bytes: auth_info.encode_to_vec(), + chain_id, + account_number: base_account.account_number, + } + .encode_to_vec(); + + let signature: Signature = account_keys.signing_key.sign(&bytes_to_sign); + + RawTx { + auth_info: Some(auth_info), + body: Some(tx_body), + signatures: vec![signature.to_bytes().to_vec()], + } +} + +pub fn new_blob_tx(signed_tx: &RawTx, blobs: Vec) -> RawBlobTx { + // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 + const BLOB_TX_TYPE_ID: &str = "BLOB"; + + let blobs = blobs.into_iter().map(|blob| RawBlob::from(blob)).collect(); + RawBlobTx { + tx: signed_tx.encode_to_vec(), + blobs, + type_id: BLOB_TX_TYPE_ID.to_string(), + } +} diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index 36be6721..e951b42d 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -1,10 +1,15 @@ #![cfg(not(target_arch = "wasm32"))] +use std::u64; + use celestia_grpc::types::auth::Account; +use celestia_grpc::types::tx::prep_signed_tx; +use celestia_proto::cosmos::tx::v1beta1::BroadcastMode; +use celestia_types::{blob::MsgPayForBlobs, nmt::Namespace, AppVersion, Blob}; pub mod utils; -use crate::utils::new_test_client; +use crate::utils::{load_account_key, new_test_client}; #[tokio::test] async fn get_min_gas_price() { @@ -13,6 +18,25 @@ async fn get_min_gas_price() { assert!(gas_price > 0.0); } +#[tokio::test] +async fn get_blob_params() { + let mut client = new_test_client().await.unwrap(); + let params = client.get_blob_params().await.unwrap(); + assert!(params.gas_per_blob_byte > 0); + assert!(params.gov_max_square_size > 0); +} + +#[tokio::test] +async fn get_auth_params() { + let mut client = new_test_client().await.unwrap(); + let params = client.get_auth_params().await.unwrap(); + assert!(params.max_memo_characters > 0); + assert!(params.tx_sig_limit > 0); + assert!(params.tx_size_cost_per_byte > 0); + assert!(params.sig_verify_cost_ed25519 > 0); + assert!(params.sig_verify_cost_secp256k1 > 0); +} + #[tokio::test] async fn get_block() { let mut client = new_test_client().await.unwrap(); @@ -42,3 +66,58 @@ async fn get_account() { assert_eq!(&account, first_account); } + +#[tokio::test] +async fn submit_blob() { + let mut client = new_test_client().await.unwrap(); + let address = "celestia1rkfxnqt8wwu2vqgpa2ph84xa2ty0nseex4xqlc".to_string(); + let private_key = + hex::decode("374b1d38f76c57fb6a1bb7bb840795239640441a37f506dc8de0d82b1ea9f690").unwrap(); + let namespace = Namespace::new_v0(&[1, 2, 3]).unwrap(); + let blob = Blob::new(namespace, "Hello, World!".into(), AppVersion::V1).unwrap(); + let blobs = vec![blob]; + + let chain_id = "private".to_string(); + let keypair = load_account_key(&private_key); + + let account = client.get_account(address.clone()).await.unwrap(); + + let msg_pay_for_blobs = MsgPayForBlobs::new(&blobs, address).unwrap(); + + // gas and fees are overestimated for simplicity + let tx = prep_signed_tx( + &msg_pay_for_blobs, + account.base_account_ref().unwrap(), + 100000, + 5000, + chain_id, + keypair, + ); + + use prost::Message; + + let txbody = tx.body.clone().unwrap(); + + let response = client + .broadcast_tx(tx, blobs, BroadcastMode::Sync) + .await + .unwrap(); + + + // TODO: sth more CI-like + // wait for the tx to become available + for i in 1..10 { + println!("LOP"); + let res = client.get_tx(response.txhash.clone()).await; + println!("{res:#?}"); + if res.is_ok() { + break; + } + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + } + + let submitted_tx = client + .get_tx(response.txhash) + .await + .expect("get to be successful"); +} diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index 68729b63..0d6d9263 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -1,8 +1,11 @@ #![cfg(not(target_arch = "wasm32"))] -use std::env; +use std::path::Path; +use std::{env, fs}; use anyhow::Result; +use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; +use celestia_types::auth::AccountKeypair; use tonic::metadata::{Ascii, MetadataValue}; use tonic::service::Interceptor; use tonic::transport::Channel; @@ -48,3 +51,14 @@ pub async fn new_test_client() -> Result> { let auth_interceptor = TestAuthInterceptor::new(None)?; Ok(GrpcClient::new(grpc_channel, auth_interceptor)) } + +pub fn load_account_key(key_bytes: &[u8]) -> AccountKeypair { + //let hex_encoded = fs::read_to_string(path).unwrap(); + //let bytes = hex::decode(hex_encoded.trim()).unwrap(); + let signing_key = SigningKey::from_slice(key_bytes).unwrap(); + + AccountKeypair { + verifying_key: *signing_key.verifying_key(), + signing_key, + } +} diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 21d0d4f4..52ee9894 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -18,9 +18,11 @@ celestia-tendermint-proto.workspace = true prost.workspace = true prost-types.workspace = true cosmos-sdk-proto = { version = "0.26.0", default-features = false } +cosmrs = { version = "0.21.0", optional = true } serde = { version = "1.0.203", features = ["derive"] } pbjson = { version = "0.7.0", optional = true } pbjson-types = { version = "0.7.0", optional = true } +thiserror = { version = "2.0.3", optional = true } tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "codegen", "prost" ]} @@ -44,4 +46,5 @@ wasm-bindgen-test = "0.3.42" serde_json = "1.0.117" [features] -tonic = ["dep:tonic", "dep:tonic-build", "dep:pbjson", "dep:pbjson-types", "dep:pbjson-build", "dep:tempfile"] +tonic = [ "dep:tonic", "dep:tonic-build", "dep:pbjson", "dep:pbjson-types", "dep:pbjson-build", "dep:tempfile" ] +cosmrs = [ "dep:cosmrs", "dep:thiserror" ] diff --git a/proto/build.rs b/proto/build.rs index 5bed272d..1d0fd7d9 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -72,8 +72,10 @@ static EXTERN_PATHS: &[(&str, &str)] = &[ (".tendermint", "::celestia_tendermint_proto::v0_34"), (".google.protobuf.Timestamp", "::celestia_tendermint_proto::google::protobuf::Timestamp"), (".google.protobuf.Duration", "::celestia_tendermint_proto::google::protobuf::Duration"), - (".cosmos.tx.v1beta1.TxBody", "cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody"), - (".cosmos.tx.v1beta1.AuthInfo", "cosmos_sdk_proto::cosmos::tx::v1beta1::AuthInfo"), + (".google.protobuf.Any", "::celestia_tendermint_proto::google::protobuf::Any"), + //(".cosmos.tx.v1beta1.TxBody", "cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody"), + //(".cosmos.tx.v1beta1.AuthInfo", "cosmos_sdk_proto::cosmos::tx::v1beta1::AuthInfo"), + //(".cosmos.tx.v1beta1.SignerInfo", "cosmos_sdk_proto::cosmos::tx::v1beta1::SignerInfo"), ]; const PROTO_FILES: &[&str] = &[ @@ -152,7 +154,7 @@ fn tonic_build(fds: FileDescriptorSet) { .use_arc_self(true) // override prost-types with pbjson-types .compile_well_known_types(true) - .extern_path(".google.protobuf", "::pbjson_types") + //.extern_path(".google.protobuf", "::pbjson_types") .file_descriptor_set_path(buf_img.path()) .skip_protoc_run(); diff --git a/proto/src/cosmrs/mod.rs b/proto/src/cosmrs/mod.rs new file mode 100644 index 00000000..f399a412 --- /dev/null +++ b/proto/src/cosmrs/mod.rs @@ -0,0 +1,149 @@ +use crate::cosmos::base::v1beta1::Coin; +use crate::cosmos::crypto::multisig::v1beta1::CompactBitArray; +use crate::cosmos::tx::v1beta1::mode_info::Multi; +use crate::cosmos::tx::v1beta1::mode_info::Single; +use crate::cosmos::tx::v1beta1::mode_info::Sum; +use crate::cosmos::tx::v1beta1::{AuthInfo, Fee, ModeInfo, SignerInfo, Tip, TxBody}; +use celestia_tendermint_proto::google::protobuf::Any; + +use cosmos_sdk_proto::cosmos::base::v1beta1::Coin as CosmrsCoin; +use cosmos_sdk_proto::cosmos::crypto::multisig::v1beta1::CompactBitArray as CosmrsCompactBitArray; +use cosmos_sdk_proto::cosmos::tx::v1beta1::mode_info::Multi as CosmrsMulti; +use cosmos_sdk_proto::cosmos::tx::v1beta1::mode_info::Single as CosmrsSingle; +use cosmos_sdk_proto::cosmos::tx::v1beta1::mode_info::Sum as CosmrsModeInfoSum; +use cosmos_sdk_proto::cosmos::tx::v1beta1::AuthInfo as CosmrsAuthInfo; +use cosmos_sdk_proto::cosmos::tx::v1beta1::Fee as CosmrsFee; +use cosmos_sdk_proto::cosmos::tx::v1beta1::ModeInfo as CosmrsModeInfo; +use cosmos_sdk_proto::cosmos::tx::v1beta1::SignerInfo as CosmrsSignerInfo; +use cosmos_sdk_proto::cosmos::tx::v1beta1::Tip as CosmrsTip; +use cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody as CosmrsTxBody; + +pub trait ProtobufAnyConvertable { + type Target; + + fn convert(self) -> Self::Target; +} + +impl ProtobufAnyConvertable for Any { + type Target = cosmrs::Any; + + fn convert(self) -> Self::Target { + cosmrs::Any { + type_url: self.type_url, + value: self.value.to_vec(), + } + } +} + +impl From for CosmrsTxBody { + fn from(value: TxBody) -> Self { + let messages = value.messages.into_iter().map(|e| e.convert()).collect(); + let extension_options = value + .extension_options + .into_iter() + .map(|e| e.convert()) + .collect(); + let non_critical_extension_options = value + .non_critical_extension_options + .into_iter() + .map(|e| e.convert()) + .collect(); + CosmrsTxBody { + messages, + memo: value.memo, + timeout_height: value.timeout_height, + extension_options, + non_critical_extension_options, + } + } +} + +impl From for CosmrsAuthInfo { + fn from(value: AuthInfo) -> Self { + let signer_infos = value.signer_infos.into_iter().map(Into::into).collect(); + + // tip field is deprecated, but we want to convert it anyway + #[allow(deprecated)] + CosmrsAuthInfo { + signer_infos, + fee: value.fee.map(Into::into), + tip: value.tip.map(Into::into), + } + } +} + +impl From for CosmrsSignerInfo { + fn from(value: SignerInfo) -> Self { + CosmrsSignerInfo { + public_key: value.public_key.map(ProtobufAnyConvertable::convert), + mode_info: value.mode_info.map(Into::into), + sequence: value.sequence, + } + } +} + +impl From for CosmrsFee { + fn from(value: Fee) -> Self { + let amount = value.amount.into_iter().map(Into::into).collect(); + CosmrsFee { + amount, + gas_limit: value.gas_limit, + payer: value.payer, + granter: value.granter, + } + } +} + +impl From for CosmrsTip { + fn from(value: Tip) -> Self { + let amount = value.amount.into_iter().map(Into::into).collect(); + CosmrsTip { + amount, + tipper: value.tipper, + } + } +} + +impl From for CosmrsCoin { + fn from(value: Coin) -> Self { + CosmrsCoin { + denom: value.denom, + amount: value.amount, + } + } +} + +impl From for CosmrsModeInfo { + fn from(value: ModeInfo) -> Self { + let sum = value.sum.map(|sum| match sum { + Sum::Single(s) => CosmrsModeInfoSum::Single(s.into()), + Sum::Multi(s) => CosmrsModeInfoSum::Multi(s.into()), + }); + CosmrsModeInfo { sum } + } +} + +impl From for CosmrsSingle { + fn from(value: Single) -> Self { + CosmrsSingle { mode: value.mode } + } +} + +impl From for CosmrsMulti { + fn from(value: Multi) -> Self { + let mode_infos = value.mode_infos.into_iter().map(Into::into).collect(); + CosmrsMulti { + bitarray: value.bitarray.map(Into::into), + mode_infos, + } + } +} + +impl From for CosmrsCompactBitArray { + fn from(value: CompactBitArray) -> Self { + CosmrsCompactBitArray { + extra_bits_stored: value.extra_bits_stored, + elems: value.elems, + } + } +} diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 0bbd3ce0..c7e5be9e 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -4,6 +4,8 @@ #![cfg(not(doctest))] #![doc = include_str!("../README.md")] +#[cfg(feature = "cosmrs")] +pub mod cosmrs; pub mod serializers; #[cfg(not(feature = "tonic"))] diff --git a/types/src/auth.rs b/types/src/auth.rs index 65d86d20..84209b5e 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -1,16 +1,19 @@ //! types related to accounts +//use ed25519_consensus::{SigningKey, VerificationKey}; + use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; use celestia_proto::cosmos::auth::v1beta1::ModuleAccount as RawModuleAccount; use celestia_proto::cosmos::crypto::ed25519::PubKey as Ed25519PubKey; use celestia_proto::cosmos::crypto::secp256k1::PubKey as Secp256k1PubKey; use celestia_tendermint::public_key::PublicKey; use celestia_tendermint_proto::Protobuf; +//use celestia_tendermint::private_key::Secp256k1 as SigningKey; +//use celestia_tendermint::public_key::Secp256k1 as VerificationKey; +use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; +use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; -#[cfg(feature = "tonic")] -use pbjson_types::Any; -#[cfg(not(feature = "tonic"))] -use prost_types::Any; +use celestia_tendermint_proto::google::protobuf::Any; // workaround for otherwise unused prost-types if tonic feature flag is enabled tripping up CI use prost::Message; #[allow(unused_imports)] @@ -66,6 +69,14 @@ pub struct ModuleAccount { pub permissions: Vec, } +#[derive(Debug, Clone)] +pub struct AccountKeypair { + /// public key + pub verifying_key: VerifyingKey, + /// private key + pub signing_key: SigningKey, +} + impl From for RawBaseAccount { fn from(account: BaseAccount) -> Self { RawBaseAccount { diff --git a/types/src/blob.rs b/types/src/blob.rs index 0d33664f..1b83280d 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -10,8 +10,10 @@ use crate::consts::appconsts; use crate::consts::appconsts::{subtree_root_threshold, AppVersion}; use crate::nmt::Namespace; use crate::{bail_validation, Error, Result, Share}; +use celestia_tendermint_proto::Protobuf; pub use self::commitment::Commitment; +pub use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; pub use celestia_tendermint_proto::v0_34::types::Blob as RawBlob; /// Arbitrary data that can be stored in the network within certain [`Namespace`]. @@ -38,7 +40,7 @@ pub struct Blob { } /// Params defines the parameters for the blob module. -#[derive(Debug)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct BlobParams { /// Gas cost per blob byte pub gas_per_blob_byte: u32, @@ -46,6 +48,23 @@ pub struct BlobParams { pub gov_max_square_size: u64, } +/// MsgPayForBlobs pays for the inclusion of a blob in the block. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct MsgPayForBlobs { + pub signer: String, + /// namespaces is a list of namespaces that the blobs are associated with. + pub namespaces: Vec, + /// sizes of the associated blobs + pub blob_sizes: Vec, + /// share_commitments is a list of share commitments (one per blob). + pub share_commitments: Vec, + /// share_versions are the versions of the share format that the blobs + /// associated with this message should use when included in a block. The + /// share_versions specified must match the share_versions used to generate the + /// share_commitment in this message. + pub share_versions: Vec, +} + impl Blob { /// Create a new blob with the given data within the [`Namespace`]. /// @@ -325,6 +344,84 @@ fn shares_needed_for_blob(blob_len: usize) -> usize { 1 + without_first_share.div_ceil(appconsts::CONTINUATION_SPARSE_SHARE_CONTENT_SIZE) } +impl MsgPayForBlobs { + pub fn new(blobs: &[Blob], signer_address: String) -> Result { + let blob_count = blobs.len(); + let mut blob_sizes = Vec::with_capacity(blob_count); + let mut namespaces = Vec::with_capacity(blob_count); + let mut share_commitments = Vec::with_capacity(blob_count); + let mut share_versions = Vec::with_capacity(blob_count); + for blob in blobs { + blob_sizes.push(u32::try_from(blob.data.len()).map_err(|_| Error::BlobTooLarge)?); + namespaces.push(blob.namespace); + share_commitments.push(blob.commitment); + share_versions.push(u32::from(blob.share_version)); + } + + Ok(Self { + signer: signer_address, + namespaces, + blob_sizes, + share_commitments, + share_versions, + }) + } +} + +impl From for RawMsgPayForBlobs { + fn from(msg: MsgPayForBlobs) -> Self { + let namespaces = msg + .namespaces + .into_iter() + .map(|n| n.as_bytes().to_vec()) + .collect(); + let share_commitments = msg + .share_commitments + .into_iter() + .map(|c| c.0.to_vec()) + .collect(); + + RawMsgPayForBlobs { + signer: msg.signer, + namespaces, + blob_sizes: msg.blob_sizes, + share_commitments, + share_versions: msg.share_versions, + } + } +} + +impl TryFrom for MsgPayForBlobs { + type Error = Error; + + fn try_from(msg: RawMsgPayForBlobs) -> Result { + let namespaces = msg + .namespaces + .into_iter() + .map(|n| Namespace::from_raw(&n)) + .collect::>()?; + let share_commitments = msg + .share_commitments + .into_iter() + .map(|c| { + Ok(Commitment( + c.try_into().map_err(|_| Error::InvalidComittmentLength)?, + )) + }) + .collect::>()?; + + Ok(MsgPayForBlobs { + signer: msg.signer, + namespaces, + blob_sizes: msg.blob_sizes, + share_commitments, + share_versions: msg.share_versions, + }) + } +} + +impl Protobuf for MsgPayForBlobs {} + mod index_serde { use serde::ser::Error; use serde::{Deserialize, Deserializer, Serializer}; diff --git a/types/src/error.rs b/types/src/error.rs index e819087e..a3b97129 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -211,6 +211,14 @@ pub enum Error { /// Metadata mismatch between shares in blob. #[error("Metadata mismatch between shares in blob: {0}")] BlobSharesMetadataMismatch(String), + + /// Blob too large, length must fit u32 + #[error("Blob too large")] + BlobTooLarge, + + /// Invalid comittment length + #[error("Invalid committment length")] + InvalidComittmentLength, } impl From for Error { From 4a735a951eccf20a15681b375b3c506b26ef7fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 08:34:54 +0100 Subject: [PATCH 31/56] consolidate types --- grpc/src/types/auth.rs | 9 +++++---- grpc/src/types/tx.rs | 25 +++++++++++-------------- grpc/tests/tonic.rs | 21 ++------------------- grpc/tests/utils.rs | 5 +---- types/src/auth.rs | 24 ++++++++---------------- types/src/blob.rs | 1 + 6 files changed, 28 insertions(+), 57 deletions(-) diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index 7783db99..c7cfc604 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -1,12 +1,13 @@ use prost::{Message, Name}; use celestia_proto::cosmos::auth::v1beta1::{ - BaseAccount as RawBaseAccount, ModuleAccount as RawModuleAccount, QueryAccountRequest, - QueryAccountResponse, QueryAccountsRequest, QueryAccountsResponse, + QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest, QueryAccountsResponse, QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, }; use celestia_tendermint_proto::google::protobuf::Any; -use celestia_types::auth::{AuthParams, BaseAccount, ModuleAccount}; +use celestia_types::auth::{ + AuthParams, BaseAccount, ModuleAccount, RawBaseAccount, RawModuleAccount, +}; use crate::types::make_empty_params; use crate::types::{FromGrpcResponse, IntoGrpcParam}; @@ -25,7 +26,7 @@ pub enum Account { impl Account { pub fn base_account_ref(&self) -> Option<&BaseAccount> { match self { - Account::Base(acct) => Some(&acct), + Account::Base(acct) => Some(acct), Account::Module(acct) => acct.base_account.as_ref(), } } diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index bd67e395..f278e40f 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -1,29 +1,26 @@ use std::convert::Infallible; -use celestia_tendermint_proto::google::protobuf::Any; use cosmrs::Tx; use k256::ecdsa::{signature::Signer, Signature}; use prost::{Message, Name}; use serde::{Deserialize, Serialize}; -use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; - -use celestia_proto::cosmos::base::abci::v1beta1::AbciMessageLog; -use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; +use celestia_proto::cosmos::base::abci::v1beta1::{AbciMessageLog, TxResponse as RawTxResponse}; use celestia_proto::cosmos::base::v1beta1::Coin; use celestia_proto::cosmos::crypto::secp256k1; use celestia_proto::cosmos::tx::v1beta1::mode_info::{Single, Sum}; -use celestia_proto::cosmos::tx::v1beta1::SignDoc; use celestia_proto::cosmos::tx::v1beta1::{ - AuthInfo, BroadcastTxResponse, Fee, GetTxRequest as RawGetTxRequest, - GetTxResponse as RawGetTxResponse, ModeInfo, SignerInfo, Tx as RawTx, TxBody, + AuthInfo, BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, Fee, + GetTxRequest as RawGetTxRequest, GetTxResponse as RawGetTxResponse, ModeInfo, SignDoc, + SignerInfo, Tx as RawTx, TxBody, }; -use celestia_proto::cosmos::tx::v1beta1::{BroadcastMode, BroadcastTxRequest, GetTxRequest}; +use celestia_tendermint_proto::google::protobuf::Any; use celestia_tendermint_proto::v0_34::abci::Event; -use celestia_tendermint_proto::v0_34::types::{Blob as RawBlob, BlobTx as RawBlobTx}; use celestia_tendermint_proto::Protobuf; use celestia_types::auth::{AccountKeypair, BaseAccount}; -use celestia_types::blob::{Blob, MsgPayForBlobs}; +use celestia_types::blob::{Blob, MsgPayForBlobs, RawBlob, RawBlobTx, RawMsgPayForBlobs}; +//use celestia_tendermint_proto::v0_34::types::{BlobTx as RawBlobTx}; +//use celestia_types::state::RawTxResponse; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; @@ -196,12 +193,12 @@ pub fn prep_signed_tx( let public_key_as_any = Any { type_url: secp256k1::PubKey::type_url(), - value: public_key.encode_to_vec().into(), + value: public_key.encode_to_vec(), }; let auth_info = AuthInfo { signer_infos: vec![SignerInfo { - public_key: Some(public_key_as_any.into()), + public_key: Some(public_key_as_any), mode_info: SIGNING_MODE_INFO, sequence: base_account.sequence, }], @@ -241,7 +238,7 @@ pub fn new_blob_tx(signed_tx: &RawTx, blobs: Vec) -> RawBlobTx { // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 const BLOB_TX_TYPE_ID: &str = "BLOB"; - let blobs = blobs.into_iter().map(|blob| RawBlob::from(blob)).collect(); + let blobs = blobs.into_iter().map(RawBlob::from).collect(); RawBlobTx { tx: signed_tx.encode_to_vec(), blobs, diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index e951b42d..58dbb991 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -1,7 +1,5 @@ #![cfg(not(target_arch = "wasm32"))] -use std::u64; - use celestia_grpc::types::auth::Account; use celestia_grpc::types::tx::prep_signed_tx; use celestia_proto::cosmos::tx::v1beta1::BroadcastMode; @@ -94,29 +92,14 @@ async fn submit_blob() { keypair, ); - use prost::Message; - - let txbody = tx.body.clone().unwrap(); - let response = client .broadcast_tx(tx, blobs, BroadcastMode::Sync) .await .unwrap(); + tokio::time::sleep(std::time::Duration::from_secs(3)).await; - // TODO: sth more CI-like - // wait for the tx to become available - for i in 1..10 { - println!("LOP"); - let res = client.get_tx(response.txhash.clone()).await; - println!("{res:#?}"); - if res.is_ok() { - break; - } - tokio::time::sleep(std::time::Duration::from_secs(1)).await; - } - - let submitted_tx = client + let _submitted_tx = client .get_tx(response.txhash) .await .expect("get to be successful"); diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index 0d6d9263..39bc795b 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -1,7 +1,6 @@ #![cfg(not(target_arch = "wasm32"))] -use std::path::Path; -use std::{env, fs}; +use std::env; use anyhow::Result; use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; @@ -53,8 +52,6 @@ pub async fn new_test_client() -> Result> { } pub fn load_account_key(key_bytes: &[u8]) -> AccountKeypair { - //let hex_encoded = fs::read_to_string(path).unwrap(); - //let bytes = hex::decode(hex_encoded.trim()).unwrap(); let signing_key = SigningKey::from_slice(key_bytes).unwrap(); AccountKeypair { diff --git a/types/src/auth.rs b/types/src/auth.rs index 84209b5e..e7e7a0ca 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -1,26 +1,20 @@ //! types related to accounts -//use ed25519_consensus::{SigningKey, VerificationKey}; +use prost::Message; -use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; -use celestia_proto::cosmos::auth::v1beta1::ModuleAccount as RawModuleAccount; use celestia_proto::cosmos::crypto::ed25519::PubKey as Ed25519PubKey; use celestia_proto::cosmos::crypto::secp256k1::PubKey as Secp256k1PubKey; -use celestia_tendermint::public_key::PublicKey; -use celestia_tendermint_proto::Protobuf; -//use celestia_tendermint::private_key::Secp256k1 as SigningKey; -//use celestia_tendermint::public_key::Secp256k1 as VerificationKey; use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; +use celestia_tendermint::public_key::PublicKey; use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; - use celestia_tendermint_proto::google::protobuf::Any; -// workaround for otherwise unused prost-types if tonic feature flag is enabled tripping up CI -use prost::Message; -#[allow(unused_imports)] -use prost_types::Any as _; +use celestia_tendermint_proto::Protobuf; use crate::Error; +pub use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; +pub use celestia_proto::cosmos::auth::v1beta1::ModuleAccount as RawModuleAccount; + const COSMOS_ED25519_PUBKEY: &str = "/cosmos.crypto.ed25519.PubKey"; const COSMOS_SECP256K1_PUBKEY: &str = "/cosmos.crypto.secp256k1.PubKey"; @@ -149,16 +143,14 @@ fn any_from_public_key(key: PublicKey) -> Any { value: Ed25519PubKey { key: key.to_bytes(), } - .encode_to_vec() - .into(), + .encode_to_vec(), }, key @ PublicKey::Secp256k1(_) => Any { type_url: COSMOS_SECP256K1_PUBKEY.to_string(), value: Secp256k1PubKey { key: key.to_bytes(), } - .encode_to_vec() - .into(), + .encode_to_vec(), }, _ => unimplemented!("unexpected key type"), } diff --git a/types/src/blob.rs b/types/src/blob.rs index 1b83280d..3a76b033 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -15,6 +15,7 @@ use celestia_tendermint_proto::Protobuf; pub use self::commitment::Commitment; pub use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; pub use celestia_tendermint_proto::v0_34::types::Blob as RawBlob; +pub use celestia_tendermint_proto::v0_34::types::BlobTx as RawBlobTx; /// Arbitrary data that can be stored in the network within certain [`Namespace`]. // NOTE: We don't use the `serde(try_from)` pattern for this type From ad5e97443d9107213918e0cd4351bd3c37062eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 10:17:33 +0100 Subject: [PATCH 32/56] Any->Any --- Cargo.lock | 4 ++++ Cargo.toml | 4 ++-- grpc/src/types/auth.rs | 2 +- grpc/src/types/tx.rs | 8 +++----- proto/build.rs | 5 +---- proto/src/cosmrs/mod.rs | 15 ++++++++------- types/src/auth.rs | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5f9ec85..741d1be6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -844,6 +844,8 @@ dependencies = [ [[package]] name = "celestia-tendermint" version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4529cd69c16e0f75b40f87ed281b602d01e99e1ad0a7a5b147ec93e8711001" dependencies = [ "bytes", "celestia-tendermint-proto", @@ -874,6 +876,8 @@ dependencies = [ [[package]] name = "celestia-tendermint-proto" version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "263e3443a0e60c0f5a407a62f2486217a20cd28617cdaa3ec6546d288728b91d" dependencies = [ "bytes", "flex-error", diff --git a/Cargo.toml b/Cargo.toml index 0f231f23..e5c1a4ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ prost-types = "0.13.3" # Uncomment to apply local changes #beetswap = { path = "../beetswap" } #blockstore = { path = "../blockstore" } -celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } -celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } +#celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } +#celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } #nmt-rs = { path = "../nmt-rs" } #libp2p = { path = "../../rust-libp2p/libp2p" } #libp2p-core = { path = "../../rust-libp2p/core" } diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index c7cfc604..7da3f0b1 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -1,10 +1,10 @@ use prost::{Message, Name}; +use pbjson_types::Any; use celestia_proto::cosmos::auth::v1beta1::{ QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest, QueryAccountsResponse, QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, }; -use celestia_tendermint_proto::google::protobuf::Any; use celestia_types::auth::{ AuthParams, BaseAccount, ModuleAccount, RawBaseAccount, RawModuleAccount, }; diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index f278e40f..899da608 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -4,6 +4,7 @@ use cosmrs::Tx; use k256::ecdsa::{signature::Signer, Signature}; use prost::{Message, Name}; use serde::{Deserialize, Serialize}; +use pbjson_types::Any; use celestia_proto::cosmos::base::abci::v1beta1::{AbciMessageLog, TxResponse as RawTxResponse}; use celestia_proto::cosmos::base::v1beta1::Coin; @@ -14,13 +15,10 @@ use celestia_proto::cosmos::tx::v1beta1::{ GetTxRequest as RawGetTxRequest, GetTxResponse as RawGetTxResponse, ModeInfo, SignDoc, SignerInfo, Tx as RawTx, TxBody, }; -use celestia_tendermint_proto::google::protobuf::Any; use celestia_tendermint_proto::v0_34::abci::Event; use celestia_tendermint_proto::Protobuf; use celestia_types::auth::{AccountKeypair, BaseAccount}; use celestia_types::blob::{Blob, MsgPayForBlobs, RawBlob, RawBlobTx, RawMsgPayForBlobs}; -//use celestia_tendermint_proto::v0_34::types::{BlobTx as RawBlobTx}; -//use celestia_types::state::RawTxResponse; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; @@ -193,7 +191,7 @@ pub fn prep_signed_tx( let public_key_as_any = Any { type_url: secp256k1::PubKey::type_url(), - value: public_key.encode_to_vec(), + value: public_key.encode_to_vec().into(), }; let auth_info = AuthInfo { @@ -209,7 +207,7 @@ pub fn prep_signed_tx( let msg_pay_for_blobs_value: Result<_, Infallible> = msg_pay_for_blobs.encode_vec(); let msg_pay_for_blobs_as_any = Any { type_url: RawMsgPayForBlobs::type_url(), - value: msg_pay_for_blobs_value.expect("Result to be Infallible"), + value: msg_pay_for_blobs_value.expect("Result to be Infallible").into(), }; let tx_body = TxBody { diff --git a/proto/build.rs b/proto/build.rs index 1d0fd7d9..dbff5bd1 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -72,10 +72,7 @@ static EXTERN_PATHS: &[(&str, &str)] = &[ (".tendermint", "::celestia_tendermint_proto::v0_34"), (".google.protobuf.Timestamp", "::celestia_tendermint_proto::google::protobuf::Timestamp"), (".google.protobuf.Duration", "::celestia_tendermint_proto::google::protobuf::Duration"), - (".google.protobuf.Any", "::celestia_tendermint_proto::google::protobuf::Any"), - //(".cosmos.tx.v1beta1.TxBody", "cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody"), - //(".cosmos.tx.v1beta1.AuthInfo", "cosmos_sdk_proto::cosmos::tx::v1beta1::AuthInfo"), - //(".cosmos.tx.v1beta1.SignerInfo", "cosmos_sdk_proto::cosmos::tx::v1beta1::SignerInfo"), + (".google.protobuf.Any", "::pbjson_types::Any"), ]; const PROTO_FILES: &[&str] = &[ diff --git a/proto/src/cosmrs/mod.rs b/proto/src/cosmrs/mod.rs index f399a412..57eb727a 100644 --- a/proto/src/cosmrs/mod.rs +++ b/proto/src/cosmrs/mod.rs @@ -1,10 +1,4 @@ -use crate::cosmos::base::v1beta1::Coin; -use crate::cosmos::crypto::multisig::v1beta1::CompactBitArray; -use crate::cosmos::tx::v1beta1::mode_info::Multi; -use crate::cosmos::tx::v1beta1::mode_info::Single; -use crate::cosmos::tx::v1beta1::mode_info::Sum; -use crate::cosmos::tx::v1beta1::{AuthInfo, Fee, ModeInfo, SignerInfo, Tip, TxBody}; -use celestia_tendermint_proto::google::protobuf::Any; +use pbjson_types::Any; use cosmos_sdk_proto::cosmos::base::v1beta1::Coin as CosmrsCoin; use cosmos_sdk_proto::cosmos::crypto::multisig::v1beta1::CompactBitArray as CosmrsCompactBitArray; @@ -18,6 +12,13 @@ use cosmos_sdk_proto::cosmos::tx::v1beta1::SignerInfo as CosmrsSignerInfo; use cosmos_sdk_proto::cosmos::tx::v1beta1::Tip as CosmrsTip; use cosmos_sdk_proto::cosmos::tx::v1beta1::TxBody as CosmrsTxBody; +use crate::cosmos::base::v1beta1::Coin; +use crate::cosmos::crypto::multisig::v1beta1::CompactBitArray; +use crate::cosmos::tx::v1beta1::mode_info::Multi; +use crate::cosmos::tx::v1beta1::mode_info::Single; +use crate::cosmos::tx::v1beta1::mode_info::Sum; +use crate::cosmos::tx::v1beta1::{AuthInfo, Fee, ModeInfo, SignerInfo, Tip, TxBody}; + pub trait ProtobufAnyConvertable { type Target; diff --git a/types/src/auth.rs b/types/src/auth.rs index e7e7a0ca..dff5e816 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -1,13 +1,13 @@ //! types related to accounts use prost::Message; +use pbjson_types::Any; use celestia_proto::cosmos::crypto::ed25519::PubKey as Ed25519PubKey; use celestia_proto::cosmos::crypto::secp256k1::PubKey as Secp256k1PubKey; use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; use celestia_tendermint::public_key::PublicKey; use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; -use celestia_tendermint_proto::google::protobuf::Any; use celestia_tendermint_proto::Protobuf; use crate::Error; @@ -143,14 +143,14 @@ fn any_from_public_key(key: PublicKey) -> Any { value: Ed25519PubKey { key: key.to_bytes(), } - .encode_to_vec(), + .encode_to_vec().into(), }, key @ PublicKey::Secp256k1(_) => Any { type_url: COSMOS_SECP256K1_PUBKEY.to_string(), value: Secp256k1PubKey { key: key.to_bytes(), } - .encode_to_vec(), + .encode_to_vec().into(), }, _ => unimplemented!("unexpected key type"), } From 1ba8a0a89db7f4d732e6e1ed175f27d282eeca0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 15:31:07 +0100 Subject: [PATCH 33/56] Add missing file --- types/src/tx.rs | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 types/src/tx.rs diff --git a/types/src/tx.rs b/types/src/tx.rs new file mode 100644 index 00000000..fc710b83 --- /dev/null +++ b/types/src/tx.rs @@ -0,0 +1,123 @@ +use celestia_tendermint_proto::Protobuf; +use pbjson_types::Any; + +use celestia_proto::cosmos::tx::v1beta1::{ + AuthInfo as RawAuthInfo, Fee, SignerInfo, TxBody as RawTxBody, +}; +use celestia_tendermint::block::Height; + +use crate::Error; + +type Signature = Vec; + +/// [`Tx`] is the standard type used for broadcasting transactions. +#[derive(Debug, Clone)] +pub struct Tx { + /// Processable content of the transaction + pub body: TxBody, + + /// Authorization related content of the transaction, specifically signers, signer modes + /// and [`Fee`]. + pub auth_info: AuthInfo, + + /// List of signatures that matches the length and order of [`AuthInfo`]’s `signer_info`s to + /// allow connecting signature meta information like public key and signing mode by position. + /// + /// Signatures are provided as raw bytes so as to support current and future signature types. + /// [`AuthInfo`] should be introspected to determine the signature algorithm used. + pub signatures: Vec, +} + +/// [`TxBody`] of a transaction that all signers sign over. +#[derive(Debug, Clone)] +pub struct TxBody { + /// `messages` is a list of messages to be executed. The required signers of + /// those messages define the number and order of elements in `AuthInfo`'s + /// signer_infos and Tx's signatures. Each required signer address is added to + /// the list only the first time it occurs. + /// + /// By convention, the first required signer (usually from the first message) + /// is referred to as the primary signer and pays the fee for the whole + /// transaction. + pub messages: Vec, + /// `memo` is any arbitrary memo to be added to the transaction. + pub memo: String, + /// `timeout` is the block height after which this transaction will not + /// be processed by the chain + pub timeout_height: Height, + /// `extension_options` are arbitrary options that can be added by chains + /// when the default options are not sufficient. If any of these are present + /// and can't be handled, the transaction will be rejected + pub extension_options: Vec, + /// `extension_options` are arbitrary options that can be added by chains + /// when the default options are not sufficient. If any of these are present + /// and can't be handled, they will be ignored + pub non_critical_extension_options: Vec, +} + +/// [`AuthInfo`] describes the fee and signer modes that are used to sign a transaction. +#[derive(Debug, Clone)] +pub struct AuthInfo { + /// Defines the signing modes for the required signers. + /// + /// The number and order of elements must match the required signers from transaction + /// [`Body`][`super::Body`]’s messages. The first element is the primary signer and the one + /// which pays the [`Fee`]. + pub signer_infos: Vec, + /// [`Fee`] and gas limit for the transaction. + /// + /// The first signer is the primary signer and the one which pays the fee. + /// The fee can be calculated based on the cost of evaluating the body and doing signature + /// verification of the signers. This can be estimated via simulation. + pub fee: Fee, +} + +impl TryFrom for TxBody { + type Error = Error; + + fn try_from(value: RawTxBody) -> Result { + Ok(TxBody { + messages: value.messages, + memo: value.memo, + timeout_height: value.timeout_height.try_into()?, + extension_options: value.extension_options, + non_critical_extension_options: value.non_critical_extension_options, + }) + } +} + +impl From for RawTxBody { + fn from(value: TxBody) -> Self { + RawTxBody { + messages: value.messages, + memo: value.memo, + timeout_height: value.timeout_height.into(), + extension_options: value.extension_options, + non_critical_extension_options: value.non_critical_extension_options, + } + } +} + +impl TryFrom for AuthInfo { + type Error = Error; + + fn try_from(value: RawAuthInfo) -> Result { + Ok(AuthInfo { + signer_infos: value.signer_infos, + fee: value.fee.ok_or(Error::MissingFee)?, + }) + } +} + +impl From for RawAuthInfo { + fn from(value: AuthInfo) -> Self { + #[allow(deprecated)] // tip is deprecated + RawAuthInfo { + signer_infos: value.signer_infos, + fee: Some(value.fee), + tip: None, + } + } +} + +impl Protobuf for TxBody {} From 8db565fb4e30d5c66c26e52337acd4825f16f96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 15:50:33 +0100 Subject: [PATCH 34/56] CI --- Cargo.lock | 94 ----------------------------------------------- grpc/Cargo.toml | 2 +- proto/Cargo.toml | 3 -- types/src/auth.rs | 3 +- types/src/blob.rs | 2 + types/src/tx.rs | 4 +- 6 files changed, 8 insertions(+), 100 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa31b569..f3321548 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,22 +583,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "bip32" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa13fae8b6255872fd86f7faf4b41168661d7d78609f7bfe6771b85c6739a15b" -dependencies = [ - "bs58", - "hmac", - "k256", - "rand_core", - "ripemd", - "sha2 0.10.8", - "subtle", - "zeroize", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -732,7 +716,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "sha2 0.10.8", "tinyvec", ] @@ -804,8 +787,6 @@ name = "celestia-proto" version = "0.5.0" dependencies = [ "celestia-tendermint-proto", - "cosmos-sdk-proto", - "cosmrs", "pbjson", "pbjson-build", "pbjson-types", @@ -1142,36 +1123,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "cosmos-sdk-proto" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462e1f6a8e005acc8835d32d60cbd7973ed65ea2a8d8473830e675f050956427" -dependencies = [ - "prost", - "tendermint-proto", -] - -[[package]] -name = "cosmrs" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "210fbe6f98594963b46cc980f126a9ede5db9a3848ca65b71303bebdb01afcd9" -dependencies = [ - "bip32", - "cosmos-sdk-proto", - "ecdsa", - "eyre", - "k256", - "rand_core", - "serde", - "serde_json", - "signature", - "subtle-encoding", - "tendermint", - "thiserror 1.0.61", -] - [[package]] name = "cpufeatures" version = "0.2.12" @@ -5615,51 +5566,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "tendermint" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d513ce7f9e41c67ab2dd3d554ef65f36fbcc61745af1e1f93eafdeefa1ce37" -dependencies = [ - "bytes", - "digest 0.10.7", - "ed25519", - "ed25519-consensus", - "flex-error", - "futures", - "k256", - "num-traits", - "once_cell", - "prost", - "ripemd", - "serde", - "serde_bytes", - "serde_json", - "serde_repr", - "sha2 0.10.8", - "signature", - "subtle", - "subtle-encoding", - "tendermint-proto", - "time", - "zeroize", -] - -[[package]] -name = "tendermint-proto" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c81ba1b023ec00763c3bc4f4376c67c0047f185cccf95c416c7a2f16272c4cbb" -dependencies = [ - "bytes", - "flex-error", - "prost", - "serde", - "serde_bytes", - "subtle-encoding", - "time", -] - [[package]] name = "thiserror" version = "1.0.61" diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index 3f59a243..18546d99 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -21,7 +21,7 @@ categories = [ [dependencies] celestia-tendermint-proto.workspace = true celestia-types = { workspace = true, features = [ "tonic" ] } -celestia-proto = { workspace = true, features = [ "tonic", "cosmrs" ] } +celestia-proto = { workspace = true, features = [ "tonic" ] } celestia-tendermint.workspace = true prost.workspace = true celestia-grpc-macros = { version = "0.1.0", path = "grpc-macros" } diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 52ee9894..297f9c9a 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -17,8 +17,6 @@ categories = ["encoding", "cryptography::cryptocurrencies"] celestia-tendermint-proto.workspace = true prost.workspace = true prost-types.workspace = true -cosmos-sdk-proto = { version = "0.26.0", default-features = false } -cosmrs = { version = "0.21.0", optional = true } serde = { version = "1.0.203", features = ["derive"] } pbjson = { version = "0.7.0", optional = true } pbjson-types = { version = "0.7.0", optional = true } @@ -47,4 +45,3 @@ serde_json = "1.0.117" [features] tonic = [ "dep:tonic", "dep:tonic-build", "dep:pbjson", "dep:pbjson-types", "dep:pbjson-build", "dep:tempfile" ] -cosmrs = [ "dep:cosmrs", "dep:thiserror" ] diff --git a/types/src/auth.rs b/types/src/auth.rs index 9ddfa0e5..dd56f47b 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -52,7 +52,7 @@ pub struct BaseAccount { pub sequence: u64, } -/// ModuleAccount defines an account for modules that holds coins on a pool. +/// [`ModuleAccount`] defines an account for modules that holds coins on a pool. #[derive(Debug, Clone, PartialEq)] pub struct ModuleAccount { /// [`BaseAccount`] specification of this module account. @@ -63,6 +63,7 @@ pub struct ModuleAccount { pub permissions: Vec, } +/// [`AccountKeypair`] is a pair of keys associated with an account #[derive(Debug, Clone)] pub struct AccountKeypair { /// public key diff --git a/types/src/blob.rs b/types/src/blob.rs index 84b4e638..e7088fa5 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -52,6 +52,7 @@ pub struct BlobParams { /// MsgPayForBlobs pays for the inclusion of a blob in the block. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct MsgPayForBlobs { + /// signer is the bech32 encoded signer address pub signer: String, /// namespaces is a list of namespaces that the blobs are associated with. pub namespaces: Vec, @@ -346,6 +347,7 @@ fn shares_needed_for_blob(blob_len: usize) -> usize { } impl MsgPayForBlobs { + /// Create a pay for blobs message for the provided Blobs and signer pub fn new(blobs: &[Blob], signer_address: String) -> Result { let blob_count = blobs.len(); if blob_count == 0 { diff --git a/types/src/tx.rs b/types/src/tx.rs index fc710b83..1f51fa2e 100644 --- a/types/src/tx.rs +++ b/types/src/tx.rs @@ -1,3 +1,5 @@ +//! Types associated with submitting and querying transaction + use celestia_tendermint_proto::Protobuf; use pbjson_types::Any; @@ -61,7 +63,7 @@ pub struct AuthInfo { /// Defines the signing modes for the required signers. /// /// The number and order of elements must match the required signers from transaction - /// [`Body`][`super::Body`]’s messages. The first element is the primary signer and the one + /// [`TxBody`]’s messages. The first element is the primary signer and the one /// which pays the [`Fee`]. pub signer_infos: Vec, /// [`Fee`] and gas limit for the transaction. From 2c5589acb62b57d9d4d6d9d7d3124bb28820d5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 15:59:29 +0100 Subject: [PATCH 35/56] CI2 --- Cargo.lock | 119 +++++++++++++++++------------------------ grpc/src/types/auth.rs | 1 + grpc/src/types/tx.rs | 2 + proto/Cargo.toml | 1 - types/Cargo.toml | 1 + 5 files changed, 53 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3321548..fb93fe5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,7 +292,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror 1.0.61", + "thiserror", "time", ] @@ -575,7 +575,7 @@ dependencies = [ "multihash-codetable", "quick-protobuf", "smallvec", - "thiserror 1.0.61", + "thiserror", "time", "tracing", "unsigned-varint 0.8.0", @@ -681,7 +681,7 @@ dependencies = [ "multihash", "redb", "rexie", - "thiserror 1.0.61", + "thiserror", "tokio", "wasm-bindgen", ] @@ -768,7 +768,7 @@ dependencies = [ "pbjson-types", "prost", "serde", - "thiserror 1.0.61", + "thiserror", "tokio", "tonic", ] @@ -797,7 +797,6 @@ dependencies = [ "serde", "serde_json", "tempfile", - "thiserror 2.0.3", "tonic", "tonic-build", "wasm-bindgen-test", @@ -823,7 +822,7 @@ dependencies = [ "prost", "rand", "serde", - "thiserror 1.0.61", + "thiserror", "tokio", "tracing", "wasm-bindgen-test", @@ -910,7 +909,7 @@ dependencies = [ "serde_json", "serde_repr", "sha2 0.10.8", - "thiserror 1.0.61", + "thiserror", "time", "wasm-bindgen-test", ] @@ -1431,7 +1430,7 @@ dependencies = [ "rand_core", "serde", "sha2 0.9.9", - "thiserror 1.0.61", + "thiserror", "zeroize", ] @@ -1846,7 +1845,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror 1.0.61", + "thiserror", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -2002,7 +2001,7 @@ dependencies = [ "once_cell", "rand", "socket2", - "thiserror 1.0.61", + "thiserror", "tinyvec", "tokio", "tracing", @@ -2025,7 +2024,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror 1.0.61", + "thiserror", "tokio", "tracing", ] @@ -2348,7 +2347,7 @@ checksum = "2764bba4203538c2ef2d733d5bad8fdb4622b1ebc5560831279db7b3be1332e8" dependencies = [ "js-sys", "num-traits", - "thiserror 1.0.61", + "thiserror", "tokio", "wasm-bindgen", "web-sys", @@ -2564,7 +2563,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror 1.0.61", + "thiserror", "walkdir", ] @@ -2615,7 +2614,7 @@ dependencies = [ "rustls-pki-types", "rustls-platform-verifier", "soketto", - "thiserror 1.0.61", + "thiserror", "tokio", "tokio-rustls", "tokio-util", @@ -2641,7 +2640,7 @@ dependencies = [ "rustc-hash 2.0.0", "serde", "serde_json", - "thiserror 1.0.61", + "thiserror", "tokio", "tokio-stream", "tracing", @@ -2666,7 +2665,7 @@ dependencies = [ "rustls-platform-verifier", "serde", "serde_json", - "thiserror 1.0.61", + "thiserror", "tokio", "tower", "tracing", @@ -2695,7 +2694,7 @@ dependencies = [ "http 1.1.0", "serde", "serde_json", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -2759,7 +2758,7 @@ checksum = "ee58dbc414bd23885d7da915e0457618b36d1fc950a6169ef2cb29829d1b1a1d" dependencies = [ "bytes", "lazy_static", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -2810,7 +2809,7 @@ dependencies = [ "multiaddr", "pin-project", "rw-stream-sink", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -2846,7 +2845,7 @@ dependencies = [ "quick-protobuf-codec", "rand", "rand_core", - "thiserror 1.0.61", + "thiserror", "tracing", "void", "web-time", @@ -2885,7 +2884,7 @@ dependencies = [ "rand", "rw-stream-sink", "smallvec", - "thiserror 1.0.61", + "thiserror", "tracing", "unsigned-varint 0.8.0", "void", @@ -2914,7 +2913,7 @@ dependencies = [ "rw-stream-sink", "serde", "smallvec", - "thiserror 1.0.61", + "thiserror", "tracing", "unsigned-varint 0.8.0", "void", @@ -2987,7 +2986,7 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "smallvec", - "thiserror 1.0.61", + "thiserror", "tracing", "void", ] @@ -3006,7 +3005,7 @@ dependencies = [ "rand", "serde", "sha2 0.10.8", - "thiserror 1.0.61", + "thiserror", "tracing", "zeroize", ] @@ -3034,7 +3033,7 @@ dependencies = [ "serde", "sha2 0.10.8", "smallvec", - "thiserror 1.0.61", + "thiserror", "tracing", "uint", "void", @@ -3101,7 +3100,7 @@ dependencies = [ "sha2 0.10.8", "snow", "static_assertions", - "thiserror 1.0.61", + "thiserror", "tracing", "x25519-dalek", "zeroize", @@ -3144,7 +3143,7 @@ dependencies = [ "ring 0.17.8", "rustls", "socket2", - "thiserror 1.0.61", + "thiserror", "tokio", "tracing", ] @@ -3238,7 +3237,7 @@ dependencies = [ "ring 0.17.8", "rustls", "rustls-webpki 0.101.7", - "thiserror 1.0.61", + "thiserror", "x509-parser", "yasna", ] @@ -3274,7 +3273,7 @@ dependencies = [ "pin-project-lite", "rw-stream-sink", "soketto", - "thiserror 1.0.61", + "thiserror", "tracing", "url", "webpki-roots 0.25.4", @@ -3292,7 +3291,7 @@ dependencies = [ "libp2p-core 0.41.3", "parking_lot", "send_wrapper 0.6.0", - "thiserror 1.0.61", + "thiserror", "tracing", "wasm-bindgen", "web-sys", @@ -3310,7 +3309,7 @@ dependencies = [ "libp2p-core 0.42.0", "parking_lot", "send_wrapper 0.6.0", - "thiserror 1.0.61", + "thiserror", "tracing", "wasm-bindgen", "web-sys", @@ -3330,7 +3329,7 @@ dependencies = [ "multiaddr", "multihash", "send_wrapper 0.6.0", - "thiserror 1.0.61", + "thiserror", "tracing", "wasm-bindgen", "wasm-bindgen-futures", @@ -3346,7 +3345,7 @@ dependencies = [ "either", "futures", "libp2p-core 0.42.0", - "thiserror 1.0.61", + "thiserror", "tracing", "yamux 0.12.1", "yamux 0.13.3", @@ -3510,7 +3509,7 @@ dependencies = [ "serde_json", "smallvec", "tempfile", - "thiserror 1.0.61", + "thiserror", "tokio", "tokio-util", "tracing", @@ -3543,7 +3542,7 @@ dependencies = [ "serde-wasm-bindgen", "serde_json", "serde_repr", - "thiserror 1.0.61", + "thiserror", "time", "tokio", "tracing", @@ -3590,7 +3589,7 @@ checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ "cfg-if", "miette-derive", - "thiserror 1.0.61", + "thiserror", "unicode-width", ] @@ -3797,7 +3796,7 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -3811,7 +3810,7 @@ dependencies = [ "log", "netlink-packet-core", "netlink-sys", - "thiserror 1.0.61", + "thiserror", "tokio", ] @@ -4171,7 +4170,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", - "thiserror 1.0.61", + "thiserror", "ucd-trie", ] @@ -4466,7 +4465,7 @@ dependencies = [ "prost-reflect", "prost-types", "protox-parse", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -4478,7 +4477,7 @@ dependencies = [ "logos", "miette", "prost-types", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -4505,7 +4504,7 @@ dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", - "thiserror 1.0.61", + "thiserror", "unsigned-varint 0.8.0", ] @@ -4522,7 +4521,7 @@ dependencies = [ "quinn-udp", "rustc-hash 1.1.0", "rustls", - "thiserror 1.0.61", + "thiserror", "tokio", "tracing", ] @@ -4539,7 +4538,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls", "slab", - "thiserror 1.0.61", + "thiserror", "tinyvec", "tracing", ] @@ -4649,7 +4648,7 @@ checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", - "thiserror 1.0.61", + "thiserror", ] [[package]] @@ -4719,7 +4718,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "887466cfa8a12c08ee4b174998135cea8ff0fd84858627cd793e56535a045bc9" dependencies = [ "idb", - "thiserror 1.0.61", + "thiserror", "wasm-bindgen", ] @@ -4823,7 +4822,7 @@ dependencies = [ "netlink-packet-route", "netlink-proto", "nix", - "thiserror 1.0.61", + "thiserror", "tokio", ] @@ -5572,16 +5571,7 @@ version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ - "thiserror-impl 1.0.61", -] - -[[package]] -name = "thiserror" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" -dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl", ] [[package]] @@ -5595,17 +5585,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "thiserror-impl" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "thread_local" version = "1.1.8" @@ -5860,7 +5839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" dependencies = [ "crossbeam-channel", - "thiserror 1.0.61", + "thiserror", "time", "tracing-subscriber", ] @@ -6501,7 +6480,7 @@ dependencies = [ "nom", "oid-registry", "rusticata-macros", - "thiserror 1.0.61", + "thiserror", "time", ] diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index 24ae21f6..813b4c95 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -24,6 +24,7 @@ pub enum Account { } impl Account { + /// Return [`BaseAccount`] reference, if it exists, from either Base or Module account pub fn base_account_ref(&self) -> Option<&BaseAccount> { match self { Account::Base(acct) => Some(acct), diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index c0d8760c..899b53d0 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -156,6 +156,8 @@ impl IntoGrpcParam for String { } } +/// Prepare and sign transaction [`RawTx`] so that it can be sent alongside the blobs for +/// submission pub fn prep_signed_tx( msg_pay_for_blobs: &MsgPayForBlobs, base_account: &BaseAccount, diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 297f9c9a..22a9e744 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -20,7 +20,6 @@ prost-types.workspace = true serde = { version = "1.0.203", features = ["derive"] } pbjson = { version = "0.7.0", optional = true } pbjson-types = { version = "0.7.0", optional = true } -thiserror = { version = "2.0.3", optional = true } tonic = { version = "0.12.3", optional = true, default-features = false, features = [ "codegen", "prost" ]} diff --git a/types/Cargo.toml b/types/Cargo.toml index 603ea6b9..ade0bda9 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -70,3 +70,4 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-udeps.ignore] development = ["indoc"] +normal = ["prost-types"] # unused if tonic flag is enabled From a71eed31a9af81fe39669a73e8d502000920f748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 16:03:53 +0100 Subject: [PATCH 36/56] unpublic --- grpc/src/types/tx.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 899b53d0..5ee829eb 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -235,7 +235,8 @@ pub fn prep_signed_tx( } } -pub fn new_blob_tx(signed_tx: &RawTx, blobs: Vec) -> RawBlobTx { + +fn new_blob_tx(signed_tx: &RawTx, blobs: Vec) -> RawBlobTx { // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 const BLOB_TX_TYPE_ID: &str = "BLOB"; From 299ce05523b94d01e37268e171cb1636c722e58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Wed, 20 Nov 2024 21:59:01 +0100 Subject: [PATCH 37/56] fix CI keygen --- Cargo.lock | 13 ++----------- ci/run-validator.sh | 7 +++---- grpc/src/types/tx.rs | 25 +++++++++++-------------- grpc/tests/tonic.rs | 19 +++++++++---------- grpc/tests/utils.rs | 29 +++++++++++++++++++++-------- 5 files changed, 46 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb93fe5b..45846ce7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2529,15 +2529,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -4405,7 +4396,7 @@ checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", "heck 0.5.0", - "itertools 0.12.1", + "itertools 0.13.0", "log", "multimap", "once_cell", @@ -4425,7 +4416,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.87", diff --git a/ci/run-validator.sh b/ci/run-validator.sh index 7d6db003..e553894b 100755 --- a/ci/run-validator.sh +++ b/ci/run-validator.sh @@ -59,6 +59,7 @@ provision_bridge_nodes() { for node_idx in $(seq 0 "$last_node_idx"); do local bridge_name="bridge-$node_idx" local key_file="$CREDENTIALS_DIR/$bridge_name.key" + local plaintext_key_file="$CREDENTIALS_DIR/$bridge_name.plaintext-key" local addr_file="$CREDENTIALS_DIR/$bridge_name.addr" if [ ! -e "$key_file" ]; then @@ -67,6 +68,8 @@ provision_bridge_nodes() { celestia-appd keys add "$bridge_name" --keyring-backend "test" # export it echo "password" | celestia-appd keys export "$bridge_name" 2> "$key_file.lock" + # export also plaintext key for convenience in tests + echo y | celestia-appd keys export "$bridge_name" --unsafe --unarmored-hex 2> "${plaintext_key_file}" # the `.lock` file and `mv` ensures that readers read file only after finished writing mv "$key_file.lock" "$key_file" # export associated address @@ -105,10 +108,6 @@ provision_bridge_nodes() { echo "Provisioning finished." } -provision_grpc_account() { - #celestia-appd keys import -} - # Set up the validator for a private alone network. # Based on # https://github.com/celestiaorg/celestia-app/blob/main/scripts/single-node.sh diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 5ee829eb..03d30257 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -140,9 +140,19 @@ impl FromGrpcResponse for RawGetTxResponse { impl IntoGrpcParam for (RawTx, Vec, BroadcastMode) { fn into_parameter(self) -> BroadcastTxRequest { let (tx, blobs, mode) = self; + + // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 + const BLOB_TX_TYPE_ID: &str = "BLOB"; + // empty blob list causes error response, but this is already checked when creating MsgPayForBlobs debug_assert!(!blobs.is_empty()); - let blob_tx = new_blob_tx(&tx, blobs); + + let blobs = blobs.into_iter().map(RawBlob::from).collect(); + let blob_tx = RawBlobTx { + tx: tx.encode_to_vec(), + blobs, + type_id: BLOB_TX_TYPE_ID.to_string(), + }; BroadcastTxRequest { tx_bytes: blob_tx.encode_to_vec(), mode: mode.into(), @@ -234,16 +244,3 @@ pub fn prep_signed_tx( signatures: vec![signature.to_bytes().to_vec()], } } - - -fn new_blob_tx(signed_tx: &RawTx, blobs: Vec) -> RawBlobTx { - // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 - const BLOB_TX_TYPE_ID: &str = "BLOB"; - - let blobs = blobs.into_iter().map(RawBlob::from).collect(); - RawBlobTx { - tx: signed_tx.encode_to_vec(), - blobs, - type_id: BLOB_TX_TYPE_ID.to_string(), - } -} diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index 58dbb991..94581c2e 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -3,11 +3,15 @@ use celestia_grpc::types::auth::Account; use celestia_grpc::types::tx::prep_signed_tx; use celestia_proto::cosmos::tx::v1beta1::BroadcastMode; -use celestia_types::{blob::MsgPayForBlobs, nmt::Namespace, AppVersion, Blob}; +use celestia_types::blob::MsgPayForBlobs; +use celestia_types::nmt::Namespace; +use celestia_types::{AppVersion, Blob}; pub mod utils; -use crate::utils::{load_account_key, new_test_client}; +use crate::utils::{load_account, new_test_client}; + +const BRIDGE_0_DATA: &str = "../ci/credentials/bridge-0"; #[tokio::test] async fn get_min_gas_price() { @@ -68,16 +72,11 @@ async fn get_account() { #[tokio::test] async fn submit_blob() { let mut client = new_test_client().await.unwrap(); - let address = "celestia1rkfxnqt8wwu2vqgpa2ph84xa2ty0nseex4xqlc".to_string(); - let private_key = - hex::decode("374b1d38f76c57fb6a1bb7bb840795239640441a37f506dc8de0d82b1ea9f690").unwrap(); - let namespace = Namespace::new_v0(&[1, 2, 3]).unwrap(); - let blob = Blob::new(namespace, "Hello, World!".into(), AppVersion::V1).unwrap(); - let blobs = vec![blob]; + let (address, keypair) = load_account(BRIDGE_0_DATA); + let namespace = Namespace::new_v0(&[1, 2, 3]).unwrap(); + let blobs = vec![Blob::new(namespace, "Hello, World!".into(), AppVersion::V1).unwrap()]; let chain_id = "private".to_string(); - let keypair = load_account_key(&private_key); - let account = client.get_account(address.clone()).await.unwrap(); let msg_pay_for_blobs = MsgPayForBlobs::new(&blobs, address).unwrap(); diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index 39bc795b..95fa0408 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -1,19 +1,19 @@ #![cfg(not(target_arch = "wasm32"))] -use std::env; +use std::{env, fs}; use anyhow::Result; -use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; -use celestia_types::auth::AccountKeypair; use tonic::metadata::{Ascii, MetadataValue}; use tonic::service::Interceptor; use tonic::transport::Channel; use tonic::{Request, Status}; +use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; +use celestia_types::auth::AccountKeypair; + use celestia_grpc::GrpcClient; const CELESTIA_GRPC_URL: &str = "http://localhost:19090"; -//const CELESTIA_GRPC_URL: &str = "https://rpc.celestia.pops.one:9090"; #[derive(Clone)] pub struct TestAuthInterceptor { @@ -51,11 +51,24 @@ pub async fn new_test_client() -> Result> { Ok(GrpcClient::new(grpc_channel, auth_interceptor)) } -pub fn load_account_key(key_bytes: &[u8]) -> AccountKeypair { - let signing_key = SigningKey::from_slice(key_bytes).unwrap(); +pub fn load_account(path: &str) -> (String, AccountKeypair) { + let account_file = format!("{path}.addr"); + let key_file = format!("{path}.plaintext-key"); - AccountKeypair { + let account = fs::read_to_string(account_file).expect("file with account name to exists"); + let hex_encoded_key = fs::read_to_string(key_file).expect("file with plaintext key to exists"); + //let (_label, key_material) = SecretDocument::read_pem_file(key_file).expect("valid private key file"); + //let key : EcPrivateKey = key_material.try_into().expect("valid key data"); + + let signing_key = SigningKey::from_slice( + &hex::decode(hex_encoded_key.trim()).expect("valid hex representation"), + ) + .expect("valid key material"); + + let keypair = AccountKeypair { verifying_key: *signing_key.verifying_key(), signing_key, - } + }; + + (account.trim().to_string(), keypair) } From d961f49ca6aa5087fb80f9e057f956c5e1e8bc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 08:17:56 +0100 Subject: [PATCH 38/56] fix wasm --- Cargo.lock | 1 - grpc/Cargo.toml | 4 ++-- grpc/src/types/pagination.rs | 30 ----------------------------- grpc/tests/tonic.rs | 2 +- grpc/tests/utils.rs | 2 -- proto/build.rs | 1 + proto/src/serializers/option_any.rs | 3 +++ rpc/Cargo.toml | 1 - types/Cargo.toml | 2 +- types/src/auth.rs | 3 +++ types/src/tx.rs | 5 ++++- 11 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 grpc/src/types/pagination.rs diff --git a/Cargo.lock b/Cargo.lock index 45846ce7..76bce5e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -808,7 +808,6 @@ version = "0.7.1" dependencies = [ "anyhow", "async-trait", - "celestia-proto", "celestia-tendermint", "celestia-tendermint-proto", "celestia-types", diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index 18546d99..f2bcd408 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -27,13 +27,13 @@ prost.workspace = true celestia-grpc-macros = { version = "0.1.0", path = "grpc-macros" } hex = "0.4.3" -serde = "1.0.215" k256 = "0.13.4" +pbjson-types = "0.7.0" +serde = "1.0.215" thiserror = "1.0.61" tonic = { version = "0.12.3", default-features = false, features = [ "codegen", "prost" ]} -pbjson-types = "0.7.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] anyhow = "1.0.86" diff --git a/grpc/src/types/pagination.rs b/grpc/src/types/pagination.rs deleted file mode 100644 index 1666e99a..00000000 --- a/grpc/src/types/pagination.rs +++ /dev/null @@ -1,30 +0,0 @@ -use celestia_proto::cosmos::base::query::v1beta1::pagination::PageRequest as RawPageRequest; -use celestia_proto::cosmos::base::query::v1beta1::pagination::PageResponse as RawPageResponse; - -use crate::tonic::types::FromGrpcResponse; -use crate::tonic::Error; - -pub enum KeyOrOffset { - Key(Vec), - Offset(u64), -} - -pub struct PageRequest { - query_start: KeyOrOffset, - limit: Option, - count_total: bool, - reverse: bool, -} - -impl From for RawPageRequest { - fn from(item: PageRequest) -> RawPageRequest { - RawPageRequest { - - } - } -} - -pub struct PageResponse { - pub next_key: Option>, - pub total: Option, -} diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index 94581c2e..b82316ae 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -75,7 +75,7 @@ async fn submit_blob() { let (address, keypair) = load_account(BRIDGE_0_DATA); let namespace = Namespace::new_v0(&[1, 2, 3]).unwrap(); - let blobs = vec![Blob::new(namespace, "Hello, World!".into(), AppVersion::V1).unwrap()]; + let blobs = vec![Blob::new(namespace, "Hello, World!".into(), AppVersion::V3).unwrap()]; let chain_id = "private".to_string(); let account = client.get_account(address.clone()).await.unwrap(); diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index 95fa0408..78120fb2 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -57,8 +57,6 @@ pub fn load_account(path: &str) -> (String, AccountKeypair) { let account = fs::read_to_string(account_file).expect("file with account name to exists"); let hex_encoded_key = fs::read_to_string(key_file).expect("file with plaintext key to exists"); - //let (_label, key_material) = SecretDocument::read_pem_file(key_file).expect("valid private key file"); - //let key : EcPrivateKey = key_material.try_into().expect("valid key data"); let signing_key = SigningKey::from_slice( &hex::decode(hex_encoded_key.trim()).expect("valid hex representation"), diff --git a/proto/build.rs b/proto/build.rs index 9b25447e..c07f7a8a 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -72,6 +72,7 @@ static EXTERN_PATHS: &[(&str, &str)] = &[ (".tendermint", "::celestia_tendermint_proto::v0_34"), (".google.protobuf.Timestamp", "::celestia_tendermint_proto::google::protobuf::Timestamp"), (".google.protobuf.Duration", "::celestia_tendermint_proto::google::protobuf::Duration"), + #[cfg(feature = "tonic")] (".google.protobuf.Any", "::pbjson_types::Any"), ]; diff --git a/proto/src/serializers/option_any.rs b/proto/src/serializers/option_any.rs index 7e3fed72..f266dbb5 100644 --- a/proto/src/serializers/option_any.rs +++ b/proto/src/serializers/option_any.rs @@ -1,5 +1,8 @@ //! [`serde`] serializer for the optional [`Any`]. +#[cfg(feature = "tonic")] +use pbjson_types::Any; +#[cfg(not(feature = "tonic"))] use prost_types::Any; use serde::{Deserialize, Deserializer, Serialize, Serializer}; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 994d237a..4b14163a 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -21,7 +21,6 @@ categories = [ [dependencies] celestia-tendermint-proto.workspace = true celestia-types.workspace = true -celestia-proto = { optional = true, workspace = true } celestia-tendermint.workspace = true prost.workspace = true diff --git a/types/Cargo.toml b/types/Cargo.toml index ade0bda9..daf7a15b 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -62,7 +62,7 @@ default = ["p2p"] p2p = ["dep:libp2p-identity", "dep:multiaddr", "dep:serde_repr"] test-utils = ["dep:ed25519-consensus", "dep:rand"] wasm-bindgen = ["celestia-tendermint/wasm-bindgen"] -tonic = ["dep:pbjson-types"] +tonic = ["dep:pbjson-types", "celestia-proto/tonic"] [package.metadata.docs.rs] features = ["p2p", "test-utils"] diff --git a/types/src/auth.rs b/types/src/auth.rs index dd56f47b..5f160be1 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -1,6 +1,9 @@ //! types related to accounts +#[cfg(feature = "tonic")] use pbjson_types::Any; +#[cfg(not(feature = "tonic"))] +use prost_types::Any; use prost::Message; use celestia_proto::cosmos::crypto::ed25519::PubKey as Ed25519PubKey; diff --git a/types/src/tx.rs b/types/src/tx.rs index 1f51fa2e..e9be2609 100644 --- a/types/src/tx.rs +++ b/types/src/tx.rs @@ -1,8 +1,11 @@ //! Types associated with submitting and querying transaction -use celestia_tendermint_proto::Protobuf; +#[cfg(feature = "tonic")] use pbjson_types::Any; +#[cfg(not(feature = "tonic"))] +use prost_types::Any; +use celestia_tendermint_proto::Protobuf; use celestia_proto::cosmos::tx::v1beta1::{ AuthInfo as RawAuthInfo, Fee, SignerInfo, TxBody as RawTxBody, }; From 6eb1d084f3194a1cd53f6480836635945ce5ab14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 08:20:31 +0100 Subject: [PATCH 39/56] undo wasm-pack --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b59e49c..de80e38b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - name: Install wasm-pack uses: taiki-e/cache-cargo-install-action@v1 with: - tool: wasm-pack@0.13.1 + tool: wasm-pack@0.12.1 - name: Install chromedriver # we don't specify chrome version to match whatever's installed uses: nanasess/setup-chromedriver@v2 From 2bdd1c332d89687b8bb8b643f3302001fd421da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 09:48:31 +0100 Subject: [PATCH 40/56] key reorg --- grpc/src/client.rs | 3 +- grpc/src/types/auth.rs | 7 +- grpc/src/types/tx.rs | 43 +++------ grpc/tests/tonic.rs | 36 ++++---- grpc/tests/utils.rs | 30 +++++-- types/src/auth.rs | 20 ++--- types/src/blob.rs | 103 +-------------------- types/src/blob/msg_pay_for_blobs.rs | 134 ++++++++++++++++++++++++++++ types/src/tx.rs | 2 +- 9 files changed, 202 insertions(+), 176 deletions(-) create mode 100644 types/src/blob/msg_pay_for_blobs.rs diff --git a/grpc/src/client.rs b/grpc/src/client.rs index de4efdc6..bad9f800 100644 --- a/grpc/src/client.rs +++ b/grpc/src/client.rs @@ -10,6 +10,7 @@ use celestia_proto::cosmos::tx::v1beta1::Tx as RawTx; use celestia_tendermint::block::Block; use celestia_types::auth::AuthParams; use celestia_types::blob::{Blob, BlobParams}; +use celestia_types::state::Address; use celestia_grpc_macros::grpc_method; @@ -63,7 +64,7 @@ where /// Get account #[grpc_method(AuthQueryClient::account)] - async fn get_account(&mut self, account: String) -> Result; + async fn get_account(&mut self, account: &Address) -> Result; // TODO: pagination? /// Get accounts diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index 813b4c95..8099dc00 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -8,6 +8,7 @@ use celestia_proto::cosmos::auth::v1beta1::{ use celestia_types::auth::{ AuthParams, BaseAccount, ModuleAccount, RawBaseAccount, RawModuleAccount, }; +use celestia_types::state::Address; use crate::types::make_empty_params; use crate::types::{FromGrpcResponse, IntoGrpcParam}; @@ -60,9 +61,11 @@ impl FromGrpcResponse> for QueryAccountsResponse { make_empty_params!(QueryAuthParamsRequest); -impl IntoGrpcParam for String { +impl IntoGrpcParam for &Address { fn into_parameter(self) -> QueryAccountRequest { - QueryAccountRequest { address: self } + QueryAccountRequest { + address: self.to_string(), + } } } diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 03d30257..c3225bea 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -1,5 +1,3 @@ -use std::convert::Infallible; - use k256::ecdsa::{signature::Signer, Signature}; use pbjson_types::Any; use prost::{Message, Name}; @@ -12,12 +10,12 @@ use celestia_proto::cosmos::tx::v1beta1::mode_info::{Single, Sum}; use celestia_proto::cosmos::tx::v1beta1::{ AuthInfo, BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, Fee, GetTxRequest as RawGetTxRequest, GetTxResponse as RawGetTxResponse, ModeInfo, SignDoc, - SignerInfo, Tx as RawTx, TxBody, + SignerInfo, Tx as RawTx, TxBody as RawTxBody, }; +use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; use celestia_tendermint_proto::v0_34::abci::Event; -use celestia_tendermint_proto::Protobuf; -use celestia_types::auth::{AccountKeypair, BaseAccount}; -use celestia_types::blob::{Blob, MsgPayForBlobs, RawBlob, RawBlobTx, RawMsgPayForBlobs}; +use celestia_types::auth::BaseAccount; +use celestia_types::blob::{Blob, RawBlob, RawBlobTx}; use celestia_types::tx::Tx; use crate::types::{FromGrpcResponse, IntoGrpcParam}; @@ -166,15 +164,14 @@ impl IntoGrpcParam for String { } } -/// Prepare and sign transaction [`RawTx`] so that it can be sent alongside the blobs for -/// submission -pub fn prep_signed_tx( - msg_pay_for_blobs: &MsgPayForBlobs, +pub fn sign_tx( + tx_body: RawTxBody, + chain_id: String, base_account: &BaseAccount, + verifying_key: VerifyingKey, + signer: impl Signer, gas_limit: u64, fee: u64, - chain_id: String, - account_keys: AccountKeypair, ) -> RawTx { // From https://github.com/celestiaorg/celestia-app/blob/v2.3.1/pkg/appconsts/global_consts.go#L77 const FEE_DENOM: &str = "utia"; @@ -193,11 +190,7 @@ pub fn prep_signed_tx( }; let public_key = secp256k1::PubKey { - key: account_keys - .verifying_key - .to_encoded_point(true) - .as_bytes() - .to_vec(), + key: verifying_key.to_encoded_point(true).as_bytes().to_vec(), }; let public_key_as_any = Any { @@ -214,20 +207,6 @@ pub fn prep_signed_tx( fee: Some(fee), tip: None, }; - - let msg_pay_for_blobs_value: Result<_, Infallible> = msg_pay_for_blobs.encode_vec(); - let msg_pay_for_blobs_as_any = Any { - type_url: RawMsgPayForBlobs::type_url(), - value: msg_pay_for_blobs_value - .expect("Result to be Infallible") - .into(), - }; - - let tx_body = TxBody { - messages: vec![msg_pay_for_blobs_as_any], - ..TxBody::default() - }; - let bytes_to_sign = SignDoc { body_bytes: tx_body.encode_to_vec(), auth_info_bytes: auth_info.encode_to_vec(), @@ -236,7 +215,7 @@ pub fn prep_signed_tx( } .encode_to_vec(); - let signature: Signature = account_keys.signing_key.sign(&bytes_to_sign); + let signature: Signature = signer.sign(&bytes_to_sign); RawTx { auth_info: Some(auth_info), diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index b82316ae..a28611a9 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -1,7 +1,7 @@ #![cfg(not(target_arch = "wasm32"))] use celestia_grpc::types::auth::Account; -use celestia_grpc::types::tx::prep_signed_tx; +use celestia_grpc::types::tx::sign_tx; use celestia_proto::cosmos::tx::v1beta1::BroadcastMode; use celestia_types::blob::MsgPayForBlobs; use celestia_types::nmt::Namespace; @@ -11,7 +11,7 @@ pub mod utils; use crate::utils::{load_account, new_test_client}; -const BRIDGE_0_DATA: &str = "../ci/credentials/bridge-0"; +const BRIDGE_0_ACCOUNT_DATA: &str = "../ci/credentials/bridge-0"; #[tokio::test] async fn get_min_gas_price() { @@ -59,12 +59,12 @@ async fn get_account() { let first_account = accounts.first().expect("account to exist"); let address = match first_account { - Account::Base(acct) => acct.address.to_string(), - Account::Module(acct) => acct.base_account.as_ref().unwrap().address.to_string(), + Account::Base(acct) => acct.address.clone(), + Account::Module(acct) => acct.base_account.as_ref().unwrap().address.clone(), _ => unimplemented!("unknown account type"), }; - let account = client.get_account(address).await.unwrap(); + let account = client.get_account(&address).await.unwrap(); assert_eq!(&account, first_account); } @@ -73,22 +73,28 @@ async fn get_account() { async fn submit_blob() { let mut client = new_test_client().await.unwrap(); - let (address, keypair) = load_account(BRIDGE_0_DATA); + let account_credentials = load_account(BRIDGE_0_ACCOUNT_DATA); let namespace = Namespace::new_v0(&[1, 2, 3]).unwrap(); let blobs = vec![Blob::new(namespace, "Hello, World!".into(), AppVersion::V3).unwrap()]; let chain_id = "private".to_string(); - let account = client.get_account(address.clone()).await.unwrap(); + let account = client + .get_account(&account_credentials.address) + .await + .unwrap(); + // gas and fees are overestimated for simplicity + let gas_limit = 100000; + let fee = 5000; - let msg_pay_for_blobs = MsgPayForBlobs::new(&blobs, address).unwrap(); + let msg_pay_for_blobs = MsgPayForBlobs::new(&blobs, account_credentials.address).unwrap(); - // gas and fees are overestimated for simplicity - let tx = prep_signed_tx( - &msg_pay_for_blobs, - account.base_account_ref().unwrap(), - 100000, - 5000, + let tx = sign_tx( + msg_pay_for_blobs.into(), chain_id, - keypair, + account.base_account_ref().unwrap(), + account_credentials.verifying_key, + account_credentials.signing_key, + gas_limit, + fee, ); let response = client diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index 78120fb2..0dc0488f 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -8,13 +8,26 @@ use tonic::service::Interceptor; use tonic::transport::Channel; use tonic::{Request, Status}; -use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; -use celestia_types::auth::AccountKeypair; - use celestia_grpc::GrpcClient; +use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; +use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; +use celestia_types::state::Address; const CELESTIA_GRPC_URL: &str = "http://localhost:19090"; +/// [`TestAccount`] stores celestia account credentials and information, for cases where we don't +/// mind jusk keeping the plaintext secret key in memory +#[derive(Debug, Clone)] +pub struct TestAccount { + /// Bech32 `AccountId` of this account + pub address: Address, + /// public key + pub verifying_key: VerifyingKey, + /// private key + pub signing_key: SigningKey, +} + +// #[derive(Clone)] pub struct TestAuthInterceptor { token: Option>, @@ -51,8 +64,8 @@ pub async fn new_test_client() -> Result> { Ok(GrpcClient::new(grpc_channel, auth_interceptor)) } -pub fn load_account(path: &str) -> (String, AccountKeypair) { - let account_file = format!("{path}.addr"); +pub fn load_account(path: &str) -> TestAccount { + let account_file = format!("{path}.addr"); // TODO: consolidate let key_file = format!("{path}.plaintext-key"); let account = fs::read_to_string(account_file).expect("file with account name to exists"); @@ -63,10 +76,9 @@ pub fn load_account(path: &str) -> (String, AccountKeypair) { ) .expect("valid key material"); - let keypair = AccountKeypair { + TestAccount { + address: account.trim().parse().expect("valid address"), verifying_key: *signing_key.verifying_key(), signing_key, - }; - - (account.trim().to_string(), keypair) + } } diff --git a/types/src/auth.rs b/types/src/auth.rs index 5f160be1..23b68ac6 100644 --- a/types/src/auth.rs +++ b/types/src/auth.rs @@ -2,17 +2,16 @@ #[cfg(feature = "tonic")] use pbjson_types::Any; +use prost::Message; #[cfg(not(feature = "tonic"))] use prost_types::Any; -use prost::Message; use celestia_proto::cosmos::crypto::ed25519::PubKey as Ed25519PubKey; use celestia_proto::cosmos::crypto::secp256k1::PubKey as Secp256k1PubKey; -use celestia_tendermint::crypto::default::ecdsa_secp256k1::SigningKey; use celestia_tendermint::public_key::PublicKey; -use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; use celestia_tendermint_proto::Protobuf; +use crate::state::Address; use crate::Error; pub use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; @@ -45,7 +44,7 @@ pub struct AuthParams { #[derive(Debug, Clone, PartialEq)] pub struct BaseAccount { /// Bech32 `AccountId` of this account. - pub address: String, + pub address: Address, /// Optional `PublicKey` associated with this account. pub pub_key: Option, /// `account_number` is the account number of the account in state @@ -66,19 +65,10 @@ pub struct ModuleAccount { pub permissions: Vec, } -/// [`AccountKeypair`] is a pair of keys associated with an account -#[derive(Debug, Clone)] -pub struct AccountKeypair { - /// public key - pub verifying_key: VerifyingKey, - /// private key - pub signing_key: SigningKey, -} - impl From for RawBaseAccount { fn from(account: BaseAccount) -> Self { RawBaseAccount { - address: account.address, + address: account.address.to_string(), pub_key: account.pub_key.map(any_from_public_key), account_number: account.account_number, sequence: account.sequence, @@ -92,7 +82,7 @@ impl TryFrom for BaseAccount { fn try_from(account: RawBaseAccount) -> Result { let pub_key = account.pub_key.map(public_key_from_any).transpose()?; Ok(BaseAccount { - address: account.address, + address: account.address.parse()?, pub_key, account_number: account.account_number, sequence: account.sequence, diff --git a/types/src/blob.rs b/types/src/blob.rs index e7088fa5..e0a63cf2 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -5,14 +5,15 @@ use std::iter; use serde::{Deserialize, Serialize}; mod commitment; +mod msg_pay_for_blobs; use crate::consts::appconsts; use crate::consts::appconsts::{subtree_root_threshold, AppVersion}; use crate::nmt::Namespace; use crate::{bail_validation, Error, Result, Share}; -use celestia_tendermint_proto::Protobuf; pub use self::commitment::Commitment; +pub use self::msg_pay_for_blobs::MsgPayForBlobs; pub use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; pub use celestia_tendermint_proto::v0_34::types::Blob as RawBlob; pub use celestia_tendermint_proto::v0_34::types::BlobTx as RawBlobTx; @@ -49,24 +50,6 @@ pub struct BlobParams { pub gov_max_square_size: u64, } -/// MsgPayForBlobs pays for the inclusion of a blob in the block. -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct MsgPayForBlobs { - /// signer is the bech32 encoded signer address - pub signer: String, - /// namespaces is a list of namespaces that the blobs are associated with. - pub namespaces: Vec, - /// sizes of the associated blobs - pub blob_sizes: Vec, - /// share_commitments is a list of share commitments (one per blob). - pub share_commitments: Vec, - /// share_versions are the versions of the share format that the blobs - /// associated with this message should use when included in a block. The - /// share_versions specified must match the share_versions used to generate the - /// share_commitment in this message. - pub share_versions: Vec, -} - impl Blob { /// Create a new blob with the given data within the [`Namespace`]. /// @@ -346,88 +329,6 @@ fn shares_needed_for_blob(blob_len: usize) -> usize { 1 + without_first_share.div_ceil(appconsts::CONTINUATION_SPARSE_SHARE_CONTENT_SIZE) } -impl MsgPayForBlobs { - /// Create a pay for blobs message for the provided Blobs and signer - pub fn new(blobs: &[Blob], signer_address: String) -> Result { - let blob_count = blobs.len(); - if blob_count == 0 { - return Err(Error::EmptyBlobList); - } - let mut blob_sizes = Vec::with_capacity(blob_count); - let mut namespaces = Vec::with_capacity(blob_count); - let mut share_commitments = Vec::with_capacity(blob_count); - let mut share_versions = Vec::with_capacity(blob_count); - for blob in blobs { - blob_sizes.push(u32::try_from(blob.data.len()).map_err(|_| Error::BlobTooLarge)?); - namespaces.push(blob.namespace); - share_commitments.push(blob.commitment); - share_versions.push(u32::from(blob.share_version)); - } - - Ok(Self { - signer: signer_address, - namespaces, - blob_sizes, - share_commitments, - share_versions, - }) - } -} - -impl From for RawMsgPayForBlobs { - fn from(msg: MsgPayForBlobs) -> Self { - let namespaces = msg - .namespaces - .into_iter() - .map(|n| n.as_bytes().to_vec()) - .collect(); - let share_commitments = msg - .share_commitments - .into_iter() - .map(|c| c.0.to_vec()) - .collect(); - - RawMsgPayForBlobs { - signer: msg.signer, - namespaces, - blob_sizes: msg.blob_sizes, - share_commitments, - share_versions: msg.share_versions, - } - } -} - -impl TryFrom for MsgPayForBlobs { - type Error = Error; - - fn try_from(msg: RawMsgPayForBlobs) -> Result { - let namespaces = msg - .namespaces - .into_iter() - .map(|n| Namespace::from_raw(&n)) - .collect::>()?; - let share_commitments = msg - .share_commitments - .into_iter() - .map(|c| { - Ok(Commitment( - c.try_into().map_err(|_| Error::InvalidComittmentLength)?, - )) - }) - .collect::>()?; - - Ok(MsgPayForBlobs { - signer: msg.signer, - namespaces, - blob_sizes: msg.blob_sizes, - share_commitments, - share_versions: msg.share_versions, - }) - } -} - -impl Protobuf for MsgPayForBlobs {} - mod index_serde { use serde::ser::Error; use serde::{Deserialize, Deserializer, Serializer}; diff --git a/types/src/blob/msg_pay_for_blobs.rs b/types/src/blob/msg_pay_for_blobs.rs new file mode 100644 index 00000000..4c8fce1a --- /dev/null +++ b/types/src/blob/msg_pay_for_blobs.rs @@ -0,0 +1,134 @@ +use std::convert::Infallible; + +#[cfg(feature = "tonic")] +use pbjson_types::Any; +use prost::Name; +#[cfg(not(feature = "tonic"))] +use prost_types::Any; +use serde::{Deserialize, Serialize}; + +use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; +use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; +use celestia_tendermint_proto::Protobuf; + +use crate::blob::{Blob, Commitment}; +use crate::nmt::Namespace; +use crate::state::Address; +use crate::{Error, Result}; + +/// MsgPayForBlobs pays for the inclusion of a blob in the block. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct MsgPayForBlobs { + /// signer is the bech32 encoded signer address + pub signer: Address, + /// namespaces is a list of namespaces that the blobs are associated with. + pub namespaces: Vec, + /// sizes of the associated blobs + pub blob_sizes: Vec, + /// share_commitments is a list of share commitments (one per blob). + pub share_commitments: Vec, + /// share_versions are the versions of the share format that the blobs + /// associated with this message should use when included in a block. The + /// share_versions specified must match the share_versions used to generate the + /// share_commitment in this message. + pub share_versions: Vec, +} + +impl MsgPayForBlobs { + /// Create a pay for blobs message for the provided Blobs and signer + pub fn new(blobs: &[Blob], signer: Address) -> Result { + let blob_count = blobs.len(); + if blob_count == 0 { + return Err(Error::EmptyBlobList); + } + let mut blob_sizes = Vec::with_capacity(blob_count); + let mut namespaces = Vec::with_capacity(blob_count); + let mut share_commitments = Vec::with_capacity(blob_count); + let mut share_versions = Vec::with_capacity(blob_count); + for blob in blobs { + blob_sizes.push(u32::try_from(blob.data.len()).map_err(|_| Error::BlobTooLarge)?); + namespaces.push(blob.namespace); + share_commitments.push(blob.commitment); + share_versions.push(u32::from(blob.share_version)); + } + + Ok(Self { + signer, + namespaces, + blob_sizes, + share_commitments, + share_versions, + }) + } +} + +impl From for RawTxBody { + fn from(msg: MsgPayForBlobs) -> Self { + let msg_pay_for_blobs_value: Result<_, Infallible> = msg.encode_vec(); + let msg_pay_for_blobs_as_any = Any { + type_url: RawMsgPayForBlobs::type_url(), + value: msg_pay_for_blobs_value + .expect("Result to be Infallible") + .into(), + }; + + RawTxBody { + messages: vec![msg_pay_for_blobs_as_any], + ..RawTxBody::default() + } + } +} + +impl From for RawMsgPayForBlobs { + fn from(msg: MsgPayForBlobs) -> Self { + let namespaces = msg + .namespaces + .into_iter() + .map(|n| n.as_bytes().to_vec()) + .collect(); + let share_commitments = msg + .share_commitments + .into_iter() + .map(|c| c.0.to_vec()) + .collect(); + + RawMsgPayForBlobs { + signer: msg.signer.to_string(), + namespaces, + blob_sizes: msg.blob_sizes, + share_commitments, + share_versions: msg.share_versions, + } + } +} + +impl TryFrom for MsgPayForBlobs { + type Error = Error; + + fn try_from(msg: RawMsgPayForBlobs) -> Result { + let namespaces = msg + .namespaces + .into_iter() + .map(|n| Namespace::from_raw(&n)) + .collect::>()?; + let share_commitments = msg + .share_commitments + .into_iter() + .map(|c| { + Ok(Commitment( + c.try_into().map_err(|_| Error::InvalidComittmentLength)?, + )) + }) + .collect::>()?; + + Ok(MsgPayForBlobs { + signer: msg.signer.parse()?, + namespaces, + blob_sizes: msg.blob_sizes, + share_commitments, + share_versions: msg.share_versions, + }) + } +} + +impl Protobuf for MsgPayForBlobs {} diff --git a/types/src/tx.rs b/types/src/tx.rs index e9be2609..d62fb0a7 100644 --- a/types/src/tx.rs +++ b/types/src/tx.rs @@ -5,11 +5,11 @@ use pbjson_types::Any; #[cfg(not(feature = "tonic"))] use prost_types::Any; -use celestia_tendermint_proto::Protobuf; use celestia_proto::cosmos::tx::v1beta1::{ AuthInfo as RawAuthInfo, Fee, SignerInfo, TxBody as RawTxBody, }; use celestia_tendermint::block::Height; +use celestia_tendermint_proto::Protobuf; use crate::Error; From e33d0aba260ba66e871e6de2f5ad618bf7136cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 10:15:09 +0100 Subject: [PATCH 41/56] Make TxBody conversion dependent on tonic to fix wasm --- grpc/src/types/tx.rs | 1 + types/src/blob/msg_pay_for_blobs.rs | 46 ++++++++++++++++------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index c3225bea..2d3b440f 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -164,6 +164,7 @@ impl IntoGrpcParam for String { } } +/// Sign `tx_body` and the transaction metadata as the `base_account` using `signer` pub fn sign_tx( tx_body: RawTxBody, chain_id: String, diff --git a/types/src/blob/msg_pay_for_blobs.rs b/types/src/blob/msg_pay_for_blobs.rs index 4c8fce1a..ab469da3 100644 --- a/types/src/blob/msg_pay_for_blobs.rs +++ b/types/src/blob/msg_pay_for_blobs.rs @@ -1,14 +1,7 @@ -use std::convert::Infallible; -#[cfg(feature = "tonic")] -use pbjson_types::Any; -use prost::Name; -#[cfg(not(feature = "tonic"))] -use prost_types::Any; use serde::{Deserialize, Serialize}; use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; -use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; use celestia_tendermint_proto::Protobuf; use crate::blob::{Blob, Commitment}; @@ -62,19 +55,32 @@ impl MsgPayForBlobs { } } -impl From for RawTxBody { - fn from(msg: MsgPayForBlobs) -> Self { - let msg_pay_for_blobs_value: Result<_, Infallible> = msg.encode_vec(); - let msg_pay_for_blobs_as_any = Any { - type_url: RawMsgPayForBlobs::type_url(), - value: msg_pay_for_blobs_value - .expect("Result to be Infallible") - .into(), - }; - - RawTxBody { - messages: vec![msg_pay_for_blobs_as_any], - ..RawTxBody::default() +#[cfg(feature = "tonic")] +mod tx_body_conversion { + use super::{MsgPayForBlobs, RawMsgPayForBlobs}; + + use std::convert::Infallible; + + use pbjson_types::Any; + use prost::Name; + + use celestia_tendermint_proto::Protobuf; + use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; + + impl From for RawTxBody { + fn from(msg: MsgPayForBlobs) -> Self { + let msg_pay_for_blobs_value: Result<_, Infallible> = msg.encode_vec(); + let msg_pay_for_blobs_as_any = Any { + type_url: RawMsgPayForBlobs::type_url(), + value: msg_pay_for_blobs_value + .expect("Result to be Infallible") + .into(), + }; + + RawTxBody { + messages: vec![msg_pay_for_blobs_as_any], + ..RawTxBody::default() + } } } } From 963450f891da2fd82158ac67d01cef0f72f0fd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 14:34:07 +0100 Subject: [PATCH 42/56] Move tx types to types::state::tx --- Cargo.lock | 1 + grpc/src/client.rs | 4 +- grpc/src/types/tx.rs | 99 +------ rpc/tests/state.rs | 2 +- types/Cargo.toml | 1 + types/src/bit_array.rs | 54 ++++ types/src/blob/msg_pay_for_blobs.rs | 3 +- types/src/error.rs | 16 + types/src/lib.rs | 2 +- types/src/state.rs | 2 +- types/src/state/tx.rs | 434 +++++++++++++++++++++++++++- types/src/tx.rs | 128 -------- 12 files changed, 515 insertions(+), 231 deletions(-) create mode 100644 types/src/bit_array.rs delete mode 100644 types/src/tx.rs diff --git a/Cargo.lock b/Cargo.lock index 76bce5e0..0f6544e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -883,6 +883,7 @@ version = "0.8.0" dependencies = [ "base64 0.22.1", "bech32", + "bitvec", "blockstore", "bytes", "celestia-proto", diff --git a/grpc/src/client.rs b/grpc/src/client.rs index bad9f800..c9d68ff7 100644 --- a/grpc/src/client.rs +++ b/grpc/src/client.rs @@ -6,16 +6,16 @@ use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient as AuthQuer use celestia_proto::cosmos::base::node::v1beta1::service_client::ServiceClient as ConfigServiceClient; use celestia_proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient as TendermintServiceClient; use celestia_proto::cosmos::tx::v1beta1::service_client::ServiceClient as TxServiceClient; -use celestia_proto::cosmos::tx::v1beta1::Tx as RawTx; use celestia_tendermint::block::Block; use celestia_types::auth::AuthParams; use celestia_types::blob::{Blob, BlobParams}; use celestia_types::state::Address; +use celestia_types::state::{RawTx, TxResponse}; use celestia_grpc_macros::grpc_method; use crate::types::auth::Account; -use crate::types::tx::{GetTxResponse, TxResponse}; +use crate::types::tx::GetTxResponse; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 2d3b440f..75077c76 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -1,75 +1,26 @@ +use std::convert::Infallible; + use k256::ecdsa::{signature::Signer, Signature}; use pbjson_types::Any; use prost::{Message, Name}; -use serde::{Deserialize, Serialize}; -use celestia_proto::cosmos::base::abci::v1beta1::{AbciMessageLog, TxResponse as RawTxResponse}; use celestia_proto::cosmos::base::v1beta1::Coin; use celestia_proto::cosmos::crypto::secp256k1; use celestia_proto::cosmos::tx::v1beta1::mode_info::{Single, Sum}; use celestia_proto::cosmos::tx::v1beta1::{ - AuthInfo, BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, Fee, - GetTxRequest as RawGetTxRequest, GetTxResponse as RawGetTxResponse, ModeInfo, SignDoc, - SignerInfo, Tx as RawTx, TxBody as RawTxBody, + BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, Fee, GetTxRequest as RawGetTxRequest, + GetTxResponse as RawGetTxResponse, ModeInfo, SignDoc, SignerInfo, TxBody as RawTxBody, }; use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; -use celestia_tendermint_proto::v0_34::abci::Event; +use celestia_tendermint_proto::Protobuf; use celestia_types::auth::BaseAccount; use celestia_types::blob::{Blob, RawBlob, RawBlobTx}; -use celestia_types::tx::Tx; +use celestia_types::state::{RawTx, TxResponse}; +use celestia_types::tx::{AuthInfo, Tx}; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; -/// Response to a tx query -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct TxResponse { - /// The block height - pub height: i64, - - /// The transaction hash. - pub txhash: String, - - /// Namespace for the Code - pub codespace: String, - - /// Response code. - pub code: u32, - - /// Result bytes, if any. - pub data: String, - - /// The output of the application's logger (raw string). May be - /// non-deterministic. - pub raw_log: String, - - /// The output of the application's logger (typed). May be non-deterministic. - pub logs: Vec, - - /// Additional information. May be non-deterministic. - pub info: String, - - /// Amount of gas requested for transaction. - pub gas_wanted: i64, - - /// Amount of gas consumed by transaction. - pub gas_used: i64, - - /// The request transaction bytes. - pub tx: Option, - - /// Time of the previous block. For heights > 1, it's the weighted median of - /// the timestamps of the valid votes in the block.LastCommit. For height == 1, - /// it's genesis time. - pub timestamp: String, - - /// Events defines all the events emitted by processing a transaction. Note, - /// these events include those emitted by processing all the messages and those - /// emitted from the ante. Whereas Logs contains the events, with - /// additional metadata, emitted only by processing the messages. - pub events: Vec, -} - /// Response to GetTx #[derive(Debug)] pub struct GetTxResponse { @@ -80,33 +31,12 @@ pub struct GetTxResponse { pub tx_response: TxResponse, } -impl TryFrom for TxResponse { - type Error = Error; - - fn try_from(response: RawTxResponse) -> Result { - Ok(TxResponse { - height: response.height, - txhash: response.txhash, - codespace: response.codespace, - code: response.code, - data: response.data, - raw_log: response.raw_log, - logs: response.logs, - info: response.info, - gas_wanted: response.gas_wanted, - gas_used: response.gas_used, - tx: response.tx, - timestamp: response.timestamp, - events: response.events, - }) - } -} - impl FromGrpcResponse for BroadcastTxResponse { fn try_from_response(self) -> Result { - self.tx_response + Ok(self + .tx_response .ok_or(Error::FailedToParseResponse)? - .try_into() + .try_into()?) } } @@ -205,12 +135,13 @@ pub fn sign_tx( mode_info: SIGNING_MODE_INFO, sequence: base_account.sequence, }], - fee: Some(fee), - tip: None, + fee, }; + let auth_info_bytes: Result<_, Infallible> = auth_info.encode_vec(); + let bytes_to_sign = SignDoc { body_bytes: tx_body.encode_to_vec(), - auth_info_bytes: auth_info.encode_to_vec(), + auth_info_bytes: auth_info_bytes.expect("Result to be Infallible"), chain_id, account_number: base_account.account_number, } @@ -219,7 +150,7 @@ pub fn sign_tx( let signature: Signature = signer.sign(&bytes_to_sign); RawTx { - auth_info: Some(auth_info), + auth_info: Some(auth_info.into()), body: Some(tx_body), signatures: vec![signature.to_bytes().to_vec()], } diff --git a/rpc/tests/state.rs b/rpc/tests/state.rs index 9e535914..36f63aae 100644 --- a/rpc/tests/state.rs +++ b/rpc/tests/state.rs @@ -45,7 +45,7 @@ async fn submit_pay_for_blob() { .unwrap(); let received_blob = client - .blob_get(tx_response.height as u64, namespace, blob.commitment) + .blob_get(tx_response.height.into(), namespace, blob.commitment) .await .unwrap(); diff --git a/types/Cargo.toml b/types/Cargo.toml index daf7a15b..c2363c49 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -24,6 +24,7 @@ prost-types.workspace = true base64 = "0.22.1" bech32 = "0.11.0" +bitvec = "1.0.1" bytes = "1.6.0" cid = { version = "0.11.1", default-features = false, features = ["std"] } const_format = "0.2.32" diff --git a/types/src/bit_array.rs b/types/src/bit_array.rs new file mode 100644 index 00000000..4083d0d6 --- /dev/null +++ b/types/src/bit_array.rs @@ -0,0 +1,54 @@ +use bitvec::{order::Msb0, vec::BitVec}; + +use celestia_proto::cosmos::crypto::multisig::v1beta1::CompactBitArray; + +use crate::Error; + +#[derive(Debug, Clone, PartialEq)] +pub struct BitVector(pub BitVec); + +impl TryFrom for BitVector { + type Error = Error; + + fn try_from(value: CompactBitArray) -> Result { + let num_bits = (value.elems.len() - 1) * 8 + value.extra_bits_stored as usize; + let mut bit_vec = + BitVec::<_, Msb0>::try_from_vec(value.elems).map_err(|_| Error::BitarrayTooLarge)?; + + bit_vec.truncate(num_bits); + + Ok(BitVector(bit_vec)) + } +} + +impl From for CompactBitArray { + fn from(mut value: BitVector) -> Self { + let num_bits = value.0.len(); + // make sure we don't touch uninitialised memory + value.0.set_uninitialized(false); + let bytes = value.0.into_vec(); + // N mod 8 must fit u32, this is safe + let extra_bits_stored = (num_bits % 8) as u32; + CompactBitArray { + extra_bits_stored, + elems: bytes, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_empty() { + let source = CompactBitArray { + extra_bits_stored: 0, + elems: vec![], + }; + let vec = BitVector::try_from(source.clone()).unwrap(); + assert!(vec.0.is_empty()); + let result = CompactBitArray::from(vec); + assert_eq!(source, result); + } +} diff --git a/types/src/blob/msg_pay_for_blobs.rs b/types/src/blob/msg_pay_for_blobs.rs index ab469da3..2fe76801 100644 --- a/types/src/blob/msg_pay_for_blobs.rs +++ b/types/src/blob/msg_pay_for_blobs.rs @@ -1,4 +1,3 @@ - use serde::{Deserialize, Serialize}; use celestia_proto::celestia::blob::v1::MsgPayForBlobs as RawMsgPayForBlobs; @@ -64,8 +63,8 @@ mod tx_body_conversion { use pbjson_types::Any; use prost::Name; - use celestia_tendermint_proto::Protobuf; use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; + use celestia_tendermint_proto::Protobuf; impl From for RawTxBody { fn from(msg: MsgPayForBlobs) -> Self { diff --git a/types/src/error.rs b/types/src/error.rs index 4c6669c1..75b698b8 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -70,6 +70,22 @@ pub enum Error { #[error("Missing fee field")] MissingFee, + /// Missing sum field + #[error("Missing sum field")] + MissingSum, + + /// Missing mode info field + #[error("Missing mode info field")] + MissingModeInfo, + + /// Missing bitarray field + #[error("Missing bitarray field")] + MissingBitarray, + + /// Bit array too large + #[error("Bit array to large")] + BitarrayTooLarge, + /// Wrong proof type. #[error("Wrong proof type")] WrongProofType, diff --git a/types/src/lib.rs b/types/src/lib.rs index b2dbce7b..cffa0c42 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -2,6 +2,7 @@ #![doc = include_str!("../README.md")] pub mod auth; +mod bit_array; pub mod blob; mod block; mod byzantine; @@ -27,7 +28,6 @@ mod sync; #[cfg_attr(docsrs, doc(cfg(feature = "test-utils")))] pub mod test_utils; pub mod trust_level; -pub mod tx; mod tx_config; mod validate; mod validator_set; diff --git a/types/src/state.rs b/types/src/state.rs index 582be621..bc2d1b06 100644 --- a/types/src/state.rs +++ b/types/src/state.rs @@ -10,7 +10,7 @@ pub use self::balance::Balance; pub use self::query_delegation::{ QueryDelegationResponse, QueryRedelegationsResponse, QueryUnbondingDelegationResponse, }; -pub use self::tx::{RawTx, TxResponse}; +pub use self::tx::{RawTx, RawTxBody, RawTxResponse, Tx, TxBody, TxResponse}; /// A 256-bit unsigned integer. pub type Uint = ruint::aliases::U256; diff --git a/types/src/state/tx.rs b/types/src/state/tx.rs index b1f72e4a..08011d6a 100644 --- a/types/src/state/tx.rs +++ b/types/src/state/tx.rs @@ -1,17 +1,427 @@ -use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; +use celestia_tendermint_proto::Protobuf; +#[cfg(feature = "tonic")] +use pbjson_types::Any; +#[cfg(not(feature = "tonic"))] +use prost_types::Any; use serde::{Deserialize, Serialize}; -/// Raw transaction data. -/// -/// # Note -/// -/// Transaction has no types at this level +use celestia_proto::cosmos::base::abci::v1beta1::AbciMessageLog; +use celestia_tendermint_proto::v0_34::abci::Event; + +use crate::bit_array::BitVector; +use crate::Error; +use crate::Height; + +pub use celestia_proto::cosmos::base::abci::v1beta1::TxResponse as RawTxResponse; +pub use celestia_proto::cosmos::base::v1beta1::Coin as RawCoin; +pub use celestia_proto::cosmos::tx::v1beta1::mode_info::Sum as RawSum; +pub use celestia_proto::cosmos::tx::v1beta1::mode_info::{Multi, Single}; +pub use celestia_proto::cosmos::tx::v1beta1::AuthInfo as RawAuthInfo; +pub use celestia_proto::cosmos::tx::v1beta1::Fee as RawFee; +pub use celestia_proto::cosmos::tx::v1beta1::ModeInfo as RawModeInfo; +pub use celestia_proto::cosmos::tx::v1beta1::SignerInfo as RawSignerInfo; +pub use celestia_proto::cosmos::tx::v1beta1::Tx as RawTx; +pub use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; + +pub type Signature = Vec; + +/// [`Tx`] is the standard type used for broadcasting transactions. +#[derive(Debug, Clone)] +pub struct Tx { + /// Processable content of the transaction + pub body: TxBody, + + /// Authorization related content of the transaction, specifically signers, signer modes + /// and [`Fee`]. + pub auth_info: AuthInfo, + + /// List of signatures that matches the length and order of [`AuthInfo`]’s `signer_info`s to + /// allow connecting signature meta information like public key and signing mode by position. + /// + /// Signatures are provided as raw bytes so as to support current and future signature types. + /// [`AuthInfo`] should be introspected to determine the signature algorithm used. + pub signatures: Vec, +} + +/// [`TxBody`] of a transaction that all signers sign over. +#[derive(Debug, Clone)] +pub struct TxBody { + /// `messages` is a list of messages to be executed. The required signers of + /// those messages define the number and order of elements in `AuthInfo`'s + /// signer_infos and Tx's signatures. Each required signer address is added to + /// the list only the first time it occurs. + /// + /// By convention, the first required signer (usually from the first message) + /// is referred to as the primary signer and pays the fee for the whole + /// transaction. + pub messages: Vec, + /// `memo` is any arbitrary memo to be added to the transaction. + pub memo: String, + /// `timeout` is the block height after which this transaction will not + /// be processed by the chain + pub timeout_height: Height, + /// `extension_options` are arbitrary options that can be added by chains + /// when the default options are not sufficient. If any of these are present + /// and can't be handled, the transaction will be rejected + pub extension_options: Vec, + /// `extension_options` are arbitrary options that can be added by chains + /// when the default options are not sufficient. If any of these are present + /// and can't be handled, they will be ignored + pub non_critical_extension_options: Vec, +} + +/// Response to a tx query #[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct RawTx { - #[serde(with = "celestia_tendermint_proto::serializers::bytes::base64string")] - data: Vec, +pub struct TxResponse { + /// The block height + pub height: Height, + + /// The transaction hash. + pub txhash: String, + + /// Namespace for the Code + pub codespace: String, + + /// Response code. + pub code: u32, + + /// Result bytes, if any. + pub data: String, + + /// The output of the application's logger (raw string). May be + /// non-deterministic. + pub raw_log: String, + + /// The output of the application's logger (typed). May be non-deterministic. + pub logs: Vec, + + /// Additional information. May be non-deterministic. + pub info: String, + + /// Amount of gas requested for transaction. + pub gas_wanted: i64, + + /// Amount of gas consumed by transaction. + pub gas_used: i64, + + /// The request transaction bytes. + #[serde(skip)] + // caused by prost_types/pbjson_types::Any conditional compilation, should be + // removed once we align on tendermint::Any + pub tx: Option, + + /// Time of the previous block. For heights > 1, it's the weighted median of + /// the timestamps of the valid votes in the block.LastCommit. For height == 1, + /// it's genesis time. + pub timestamp: String, + + /// Events defines all the events emitted by processing a transaction. Note, + /// these events include those emitted by processing all the messages and those + /// emitted from the ante. Whereas Logs contains the events, with + /// additional metadata, emitted only by processing the messages. + pub events: Vec, +} + +/// [`AuthInfo`] describes the fee and signer modes that are used to sign a transaction. +#[derive(Debug, Clone)] +pub struct AuthInfo { + /// Defines the signing modes for the required signers. + /// + /// The number and order of elements must match the required signers from transaction + /// [`TxBody`]’s messages. The first element is the primary signer and the one + /// which pays the [`Fee`]. + pub signer_infos: Vec, + /// [`Fee`] and gas limit for the transaction. + /// + /// The first signer is the primary signer and the one which pays the fee. + /// The fee can be calculated based on the cost of evaluating the body and doing signature + /// verification of the signers. This can be estimated via simulation. + pub fee: Fee, +} + +/// SignerInfo describes the public key and signing mode of a single top-level +/// signer. +#[derive(Debug, Clone, PartialEq)] +pub struct SignerInfo { + /// public_key is the public key of the signer. It is optional for accounts + /// that already exist in state. If unset, the verifier can use the required \ + /// signer address for this position and lookup the public key. + pub public_key: Option, + /// mode_info describes the signing mode of the signer and is a nested + /// structure to support nested multisig pubkey's + pub mode_info: ModeInfo, + /// sequence is the sequence of the account, which describes the + /// number of committed transactions signed by a given address. It is used to + /// prevent replay attacks. + pub sequence: u64, +} + +/// ModeInfo describes the signing mode of a single or nested multisig signer. +#[derive(Debug, Clone, PartialEq)] +pub struct ModeInfo { + /// sum is the oneof that specifies whether this represents a single or nested + /// multisig signer + pub sum: Sum, +} + +/// sum is the oneof that specifies whether this represents a single or nested +/// multisig signer +#[derive(Debug, Clone, PartialEq)] +pub enum Sum { + /// Single is the mode info for a single signer. It is structured as a message + /// to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the + /// future + Single { + /// mode is the signing mode of the single signer + mode: i32, + }, + /// Multi is the mode info for a multisig public key + Multi { + /// bitarray specifies which keys within the multisig are signing + bitarray: BitVector, + /// mode_infos is the corresponding modes of the signers of the multisig + /// which could include nested multisig public keys + mode_infos: Vec, + }, +} + +/// Fee includes the amount of coins paid in fees and the maximum +/// gas to be used by the transaction. The ratio yields an effective "gasprice", +/// which must be above some miminum to be accepted into the mempool. +#[derive(Debug, Clone, PartialEq)] +pub struct Fee { + /// amount is the amount of coins to be paid as a fee + pub amount: Vec, + /// gas_limit is the maximum gas that can be used in transaction processing + /// before an out of gas error occurs + pub gas_limit: u64, + /// if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. + /// the payer must be a tx signer (and thus have signed this field in AuthInfo). + /// setting this field does *not* change the ordering of required signers for the transaction. + pub payer: String, + /// if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used + /// to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does + /// not support fee grants, this will fail + pub granter: String, +} + +/// Coin defines a token with a denomination and an amount. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +pub struct Coin { + /// Coin denomination + pub denom: String, + /// Coin amount + pub amount: String, // TODO: should be int? +} + +impl TryFrom for TxBody { + type Error = Error; + + fn try_from(value: RawTxBody) -> Result { + Ok(TxBody { + messages: value.messages, + memo: value.memo, + timeout_height: value.timeout_height.try_into()?, + extension_options: value.extension_options, + non_critical_extension_options: value.non_critical_extension_options, + }) + } +} + +impl From for RawTxBody { + fn from(value: TxBody) -> Self { + RawTxBody { + messages: value.messages, + memo: value.memo, + timeout_height: value.timeout_height.into(), + extension_options: value.extension_options, + non_critical_extension_options: value.non_critical_extension_options, + } + } +} + +impl TryFrom for AuthInfo { + type Error = Error; + + fn try_from(value: RawAuthInfo) -> Result { + let signer_infos = value + .signer_infos + .into_iter() + .map(TryFrom::try_from) + .collect::>()?; + Ok(AuthInfo { + signer_infos, + fee: value.fee.ok_or(Error::MissingFee)?.try_into()?, + }) + } +} + +impl From for RawAuthInfo { + fn from(value: AuthInfo) -> Self { + let signer_infos = value.signer_infos.into_iter().map(Into::into).collect(); + #[allow(deprecated)] // tip is deprecated + RawAuthInfo { + signer_infos, + fee: Some(value.fee.into()), + tip: None, + } + } +} + +impl TryFrom for TxResponse { + type Error = Error; + + fn try_from(response: RawTxResponse) -> Result { + Ok(TxResponse { + height: response.height.try_into()?, + txhash: response.txhash, + codespace: response.codespace, + code: response.code, + data: response.data, + raw_log: response.raw_log, + logs: response.logs, + info: response.info, + gas_wanted: response.gas_wanted, + gas_used: response.gas_used, + tx: response.tx, + timestamp: response.timestamp, + events: response.events, + }) + } +} + +impl TryFrom for SignerInfo { + type Error = Error; + + fn try_from(value: RawSignerInfo) -> Result { + Ok(SignerInfo { + public_key: value.public_key, + mode_info: value.mode_info.ok_or(Error::MissingModeInfo)?.try_into()?, + sequence: value.sequence, + }) + } +} + +impl From for RawSignerInfo { + fn from(value: SignerInfo) -> Self { + RawSignerInfo { + public_key: value.public_key, + mode_info: Some(value.mode_info.into()), + sequence: value.sequence, + } + } +} + +impl TryFrom for Fee { + type Error = Error; + + fn try_from(value: RawFee) -> Result { + let amount = value + .amount + .into_iter() + .map(TryInto::try_into) + .collect::>()?; + Ok(Fee { + amount, + gas_limit: value.gas_limit, + payer: value.payer, + granter: value.granter, + }) + } +} + +impl From for RawFee { + fn from(value: Fee) -> Self { + let amount = value.amount.into_iter().map(Into::into).collect(); + RawFee { + amount, + gas_limit: value.gas_limit, + payer: value.payer, + granter: value.granter, + } + } +} + +impl TryFrom for ModeInfo { + type Error = Error; + + fn try_from(value: RawModeInfo) -> Result { + Ok(ModeInfo { + sum: value.sum.ok_or(Error::MissingSum)?.try_into()?, + }) + } +} + +impl From for RawModeInfo { + fn from(value: ModeInfo) -> Self { + RawModeInfo { + sum: Some(value.sum.into()), + } + } +} + +impl TryFrom for Sum { + type Error = Error; + + fn try_from(value: RawSum) -> Result { + let sum = match value { + RawSum::Single(Single { mode }) => Sum::Single { mode }, + RawSum::Multi(Multi { + bitarray, + mode_infos, + }) => { + let bitarray = bitarray.ok_or(Error::MissingBitarray)?.try_into()?; + let mode_infos = mode_infos + .into_iter() + .map(TryInto::try_into) + .collect::>()?; + Sum::Multi { + bitarray, + mode_infos, + } + } + }; + Ok(sum) + } +} + +impl From for RawSum { + fn from(value: Sum) -> Self { + match value { + Sum::Single { mode } => RawSum::Single(Single { mode }), + Sum::Multi { + bitarray, + mode_infos, + } => { + let mode_infos = mode_infos.into_iter().map(Into::into).collect(); + RawSum::Multi(Multi { + bitarray: Some(bitarray.into()), + mode_infos, + }) + } + } + } +} + +impl From for RawCoin { + fn from(value: Coin) -> Self { + RawCoin { + denom: value.denom, + amount: value.amount, + } + } +} + +impl TryFrom for Coin { + type Error = Error; + + fn try_from(value: RawCoin) -> Result { + Ok(Coin { + denom: value.denom, + amount: value.amount, + }) + } } -/// Raw transaction response. -pub type TxResponse = RawTxResponse; +impl Protobuf for TxBody {} +impl Protobuf for AuthInfo {} diff --git a/types/src/tx.rs b/types/src/tx.rs deleted file mode 100644 index d62fb0a7..00000000 --- a/types/src/tx.rs +++ /dev/null @@ -1,128 +0,0 @@ -//! Types associated with submitting and querying transaction - -#[cfg(feature = "tonic")] -use pbjson_types::Any; -#[cfg(not(feature = "tonic"))] -use prost_types::Any; - -use celestia_proto::cosmos::tx::v1beta1::{ - AuthInfo as RawAuthInfo, Fee, SignerInfo, TxBody as RawTxBody, -}; -use celestia_tendermint::block::Height; -use celestia_tendermint_proto::Protobuf; - -use crate::Error; - -type Signature = Vec; - -/// [`Tx`] is the standard type used for broadcasting transactions. -#[derive(Debug, Clone)] -pub struct Tx { - /// Processable content of the transaction - pub body: TxBody, - - /// Authorization related content of the transaction, specifically signers, signer modes - /// and [`Fee`]. - pub auth_info: AuthInfo, - - /// List of signatures that matches the length and order of [`AuthInfo`]’s `signer_info`s to - /// allow connecting signature meta information like public key and signing mode by position. - /// - /// Signatures are provided as raw bytes so as to support current and future signature types. - /// [`AuthInfo`] should be introspected to determine the signature algorithm used. - pub signatures: Vec, -} - -/// [`TxBody`] of a transaction that all signers sign over. -#[derive(Debug, Clone)] -pub struct TxBody { - /// `messages` is a list of messages to be executed. The required signers of - /// those messages define the number and order of elements in `AuthInfo`'s - /// signer_infos and Tx's signatures. Each required signer address is added to - /// the list only the first time it occurs. - /// - /// By convention, the first required signer (usually from the first message) - /// is referred to as the primary signer and pays the fee for the whole - /// transaction. - pub messages: Vec, - /// `memo` is any arbitrary memo to be added to the transaction. - pub memo: String, - /// `timeout` is the block height after which this transaction will not - /// be processed by the chain - pub timeout_height: Height, - /// `extension_options` are arbitrary options that can be added by chains - /// when the default options are not sufficient. If any of these are present - /// and can't be handled, the transaction will be rejected - pub extension_options: Vec, - /// `extension_options` are arbitrary options that can be added by chains - /// when the default options are not sufficient. If any of these are present - /// and can't be handled, they will be ignored - pub non_critical_extension_options: Vec, -} - -/// [`AuthInfo`] describes the fee and signer modes that are used to sign a transaction. -#[derive(Debug, Clone)] -pub struct AuthInfo { - /// Defines the signing modes for the required signers. - /// - /// The number and order of elements must match the required signers from transaction - /// [`TxBody`]’s messages. The first element is the primary signer and the one - /// which pays the [`Fee`]. - pub signer_infos: Vec, - /// [`Fee`] and gas limit for the transaction. - /// - /// The first signer is the primary signer and the one which pays the fee. - /// The fee can be calculated based on the cost of evaluating the body and doing signature - /// verification of the signers. This can be estimated via simulation. - pub fee: Fee, -} - -impl TryFrom for TxBody { - type Error = Error; - - fn try_from(value: RawTxBody) -> Result { - Ok(TxBody { - messages: value.messages, - memo: value.memo, - timeout_height: value.timeout_height.try_into()?, - extension_options: value.extension_options, - non_critical_extension_options: value.non_critical_extension_options, - }) - } -} - -impl From for RawTxBody { - fn from(value: TxBody) -> Self { - RawTxBody { - messages: value.messages, - memo: value.memo, - timeout_height: value.timeout_height.into(), - extension_options: value.extension_options, - non_critical_extension_options: value.non_critical_extension_options, - } - } -} - -impl TryFrom for AuthInfo { - type Error = Error; - - fn try_from(value: RawAuthInfo) -> Result { - Ok(AuthInfo { - signer_infos: value.signer_infos, - fee: value.fee.ok_or(Error::MissingFee)?, - }) - } -} - -impl From for RawAuthInfo { - fn from(value: AuthInfo) -> Self { - #[allow(deprecated)] // tip is deprecated - RawAuthInfo { - signer_infos: value.signer_infos, - fee: Some(value.fee), - tip: None, - } - } -} - -impl Protobuf for TxBody {} From 9bb8299ffc0accbf15e56cfdc24e840f572ef113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 14:59:20 +0100 Subject: [PATCH 43/56] streamline --- grpc/src/types/tx.rs | 29 ++++++++--------------------- types/src/error.rs | 4 ++++ types/src/state.rs | 5 ++++- types/src/state/tx.rs | 27 +++++++++++++++++++++++---- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 75077c76..0e6af8e2 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -4,19 +4,18 @@ use k256::ecdsa::{signature::Signer, Signature}; use pbjson_types::Any; use prost::{Message, Name}; -use celestia_proto::cosmos::base::v1beta1::Coin; use celestia_proto::cosmos::crypto::secp256k1; -use celestia_proto::cosmos::tx::v1beta1::mode_info::{Single, Sum}; use celestia_proto::cosmos::tx::v1beta1::{ - BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, Fee, GetTxRequest as RawGetTxRequest, - GetTxResponse as RawGetTxResponse, ModeInfo, SignDoc, SignerInfo, TxBody as RawTxBody, + BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, GetTxRequest as RawGetTxRequest, + GetTxResponse as RawGetTxResponse, SignDoc, }; use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; use celestia_tendermint_proto::Protobuf; use celestia_types::auth::BaseAccount; use celestia_types::blob::{Blob, RawBlob, RawBlobTx}; -use celestia_types::state::{RawTx, TxResponse}; -use celestia_types::tx::{AuthInfo, Tx}; +use celestia_types::state::{ + AuthInfo, Fee, ModeInfo, RawTx, RawTxBody, SignerInfo, Sum, Tx, TxResponse, +}; use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; @@ -104,26 +103,14 @@ pub fn sign_tx( gas_limit: u64, fee: u64, ) -> RawTx { - // From https://github.com/celestiaorg/celestia-app/blob/v2.3.1/pkg/appconsts/global_consts.go#L77 - const FEE_DENOM: &str = "utia"; // From https://github.com/celestiaorg/cosmos-sdk/blob/v1.25.0-sdk-v0.46.16/proto/cosmos/tx/signing/v1beta1/signing.proto#L24 - const SIGNING_MODE_INFO: Option = Some(ModeInfo { - sum: Some(Sum::Single(Single { mode: 1 })), - }); - - let fee = Fee { - amount: vec![Coin { - denom: FEE_DENOM.to_string(), - amount: fee.to_string(), - }], - gas_limit, - ..Fee::default() + const SIGNING_MODE_INFO: ModeInfo = ModeInfo { + sum: Sum::Single { mode: 1 }, }; let public_key = secp256k1::PubKey { key: verifying_key.to_encoded_point(true).as_bytes().to_vec(), }; - let public_key_as_any = Any { type_url: secp256k1::PubKey::type_url(), value: public_key.encode_to_vec().into(), @@ -135,7 +122,7 @@ pub fn sign_tx( mode_info: SIGNING_MODE_INFO, sequence: base_account.sequence, }], - fee, + fee: Fee::new(fee, gas_limit), }; let auth_info_bytes: Result<_, Infallible> = auth_info.encode_vec(); diff --git a/types/src/error.rs b/types/src/error.rs index 75b698b8..68b37f3b 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -192,6 +192,10 @@ pub enum Error { #[error("Invalid balance amount: {0}")] InvalidBalanceAmount(String), + /// Invalid coin amount. + #[error("Invalid coin amount: {0}")] + InvalidCoinAmount(String), + /// Invalid Public Key #[error("Invalid Public Key")] InvalidPublicKeyType(String), diff --git a/types/src/state.rs b/types/src/state.rs index bc2d1b06..cca59984 100644 --- a/types/src/state.rs +++ b/types/src/state.rs @@ -10,7 +10,10 @@ pub use self::balance::Balance; pub use self::query_delegation::{ QueryDelegationResponse, QueryRedelegationsResponse, QueryUnbondingDelegationResponse, }; -pub use self::tx::{RawTx, RawTxBody, RawTxResponse, Tx, TxBody, TxResponse}; +pub use self::tx::{ + AuthInfo, Coin, Fee, ModeInfo, RawTx, RawTxBody, RawTxResponse, SignerInfo, Sum, Tx, TxBody, + TxResponse, BOND_DENOM, +}; /// A 256-bit unsigned integer. pub type Uint = ruint::aliases::U256; diff --git a/types/src/state/tx.rs b/types/src/state/tx.rs index 08011d6a..d407cbde 100644 --- a/types/src/state/tx.rs +++ b/types/src/state/tx.rs @@ -25,6 +25,9 @@ pub use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; pub type Signature = Vec; +// [`BOND_DENOM`] defines the native staking denomination +pub const BOND_DENOM: &str = "utia"; + /// [`Tx`] is the standard type used for broadcasting transactions. #[derive(Debug, Clone)] pub struct Tx { @@ -188,7 +191,7 @@ pub enum Sum { /// Fee includes the amount of coins paid in fees and the maximum /// gas to be used by the transaction. The ratio yields an effective "gasprice", /// which must be above some miminum to be accepted into the mempool. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Default)] pub struct Fee { /// amount is the amount of coins to be paid as a fee pub amount: Vec, @@ -211,7 +214,20 @@ pub struct Coin { /// Coin denomination pub denom: String, /// Coin amount - pub amount: String, // TODO: should be int? + pub amount: u64, +} + +impl Fee { + pub fn new(utia_fee: u64, gas_limit: u64) -> Self { + Fee { + amount: vec![Coin { + denom: BOND_DENOM.to_string(), + amount: utia_fee, + }], + gas_limit, + ..Default::default() + } + } } impl TryFrom for TxBody { @@ -407,7 +423,7 @@ impl From for RawCoin { fn from(value: Coin) -> Self { RawCoin { denom: value.denom, - amount: value.amount, + amount: value.amount.to_string(), } } } @@ -418,7 +434,10 @@ impl TryFrom for Coin { fn try_from(value: RawCoin) -> Result { Ok(Coin { denom: value.denom, - amount: value.amount, + amount: value + .amount + .parse() + .map_err(|_| Error::InvalidCoinAmount(value.amount))?, }) } } From 388dd50c7ff082c1f7e89fcd55f862a2a9421fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 15:10:20 +0100 Subject: [PATCH 44/56] reexport broadcast mode --- grpc/src/types/tx.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 0e6af8e2..68055baf 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -6,7 +6,7 @@ use prost::{Message, Name}; use celestia_proto::cosmos::crypto::secp256k1; use celestia_proto::cosmos::tx::v1beta1::{ - BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, GetTxRequest as RawGetTxRequest, + BroadcastTxRequest, BroadcastTxResponse, GetTxRequest as RawGetTxRequest, GetTxResponse as RawGetTxResponse, SignDoc, }; use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; @@ -20,6 +20,8 @@ use celestia_types::state::{ use crate::types::{FromGrpcResponse, IntoGrpcParam}; use crate::Error; +pub use celestia_proto::cosmos::tx::v1beta1::BroadcastMode; + /// Response to GetTx #[derive(Debug)] pub struct GetTxResponse { From 963a3915073a5a49c8445f06a9529bdf1fd6944f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 16:01:01 +0100 Subject: [PATCH 45/56] fix Ci, more bittests --- grpc/tests/utils.rs | 2 +- rpc/src/state.rs | 14 ++++----- rpc/tests/state.rs | 2 +- types/src/bit_array.rs | 64 +++++++++++++++++++++++++++++++++++++++++- types/src/error.rs | 4 +++ types/src/state/tx.rs | 5 +++- 6 files changed, 80 insertions(+), 11 deletions(-) diff --git a/grpc/tests/utils.rs b/grpc/tests/utils.rs index 0dc0488f..d5c467ca 100644 --- a/grpc/tests/utils.rs +++ b/grpc/tests/utils.rs @@ -65,7 +65,7 @@ pub async fn new_test_client() -> Result> { } pub fn load_account(path: &str) -> TestAccount { - let account_file = format!("{path}.addr"); // TODO: consolidate + let account_file = format!("{path}.addr"); let key_file = format!("{path}.plaintext-key"); let account = fs::read_to_string(account_file).expect("file with account name to exists"); diff --git a/rpc/src/state.rs b/rpc/src/state.rs index 2e349fb9..2ab58350 100644 --- a/rpc/src/state.rs +++ b/rpc/src/state.rs @@ -1,6 +1,6 @@ use celestia_types::state::{ AccAddress, Address, Balance, QueryDelegationResponse, QueryRedelegationsResponse, - QueryUnbondingDelegationResponse, TxResponse, Uint, ValAddress, + QueryUnbondingDelegationResponse, RawTxResponse, Uint, ValAddress, }; use celestia_types::{blob::RawBlob, TxConfig}; use jsonrpsee::proc_macros::rpc; @@ -31,7 +31,7 @@ pub trait State { dest: &ValAddress, amount: Uint, config: TxConfig, - ) -> Result; + ) -> Result; /// CancelUnbondingDelegation cancels a user's pending undelegation from a validator. #[method(name = "state.CancelUnbondingDelegation")] @@ -41,7 +41,7 @@ pub trait State { amount: Uint, height: Uint, config: TxConfig, - ) -> Result; + ) -> Result; /// Delegate sends a user's liquid tokens to a validator for delegation. #[method(name = "state.Delegate")] @@ -50,7 +50,7 @@ pub trait State { addr: &ValAddress, amount: Uint, config: TxConfig, - ) -> Result; + ) -> Result; /// IsStopped checks if the Module's context has been stopped. #[method(name = "state.IsStopped")] @@ -84,7 +84,7 @@ pub trait State { &self, blobs: &[RawBlob], config: TxConfig, - ) -> Result; + ) -> Result; /// Transfer sends the given amount of coins from default wallet of the node to the given account address. #[method(name = "state.Transfer")] @@ -93,7 +93,7 @@ pub trait State { to: &AccAddress, amount: Uint, config: TxConfig, - ) -> Result; + ) -> Result; /// Undelegate undelegates a user's delegated tokens, unbonding them from the current validator. #[method(name = "Undelegate")] @@ -102,5 +102,5 @@ pub trait State { addr: &ValAddress, amount: Uint, config: TxConfig, - ) -> Result; + ) -> Result; } diff --git a/rpc/tests/state.rs b/rpc/tests/state.rs index 36f63aae..9e535914 100644 --- a/rpc/tests/state.rs +++ b/rpc/tests/state.rs @@ -45,7 +45,7 @@ async fn submit_pay_for_blob() { .unwrap(); let received_blob = client - .blob_get(tx_response.height.into(), namespace, blob.commitment) + .blob_get(tx_response.height as u64, namespace, blob.commitment) .await .unwrap(); diff --git a/types/src/bit_array.rs b/types/src/bit_array.rs index 4083d0d6..51021be1 100644 --- a/types/src/bit_array.rs +++ b/types/src/bit_array.rs @@ -11,7 +11,17 @@ impl TryFrom for BitVector { type Error = Error; fn try_from(value: CompactBitArray) -> Result { - let num_bits = (value.elems.len() - 1) * 8 + value.extra_bits_stored as usize; + let num_bytes = value.elems.len(); + if num_bytes == 0 && value.extra_bits_stored != 0 { + return Err(Error::MalformedCompactBitArray); + } + + let last_byte_bits = match value.extra_bits_stored { + 0 => 8, + n @ 1..=7 => n, + _ => return Err(Error::MalformedCompactBitArray), + } as usize; + let num_bits = num_bytes.saturating_sub(1) * 8 + last_byte_bits; let mut bit_vec = BitVec::<_, Msb0>::try_from_vec(value.elems).map_err(|_| Error::BitarrayTooLarge)?; @@ -39,6 +49,7 @@ impl From for CompactBitArray { #[cfg(test)] mod tests { use super::*; + use bitvec::prelude::*; #[test] fn test_empty() { @@ -51,4 +62,55 @@ mod tests { let result = CompactBitArray::from(vec); assert_eq!(source, result); } + + #[test] + fn byte_aligned() { + let source = CompactBitArray { + extra_bits_stored: 0, + elems: vec![0b00000001, 0b00000010], + }; + let expected_bits = bits![0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0]; + + let vec = BitVector::try_from(source.clone()).unwrap(); + assert_eq!(vec.0.len(), 16); + assert_eq!(vec.0, expected_bits); + + let result = CompactBitArray::from(vec); + assert_eq!(source, result); + } + + // test relies on the fact that we're setting uninitialised part of bitfield to 0, + // which we do anyway for safety + #[test] + fn with_extra_bytes() { + let source = CompactBitArray { + extra_bits_stored: 1, + elems: vec![0b00000000, 0b10000000], + }; + let expected_bits = bits![0, 0, 0, 0, 0, 0, 0, 0, 1]; + + let vec = BitVector::try_from(source.clone()).unwrap(); + assert_eq!(vec.0.len(), 9); + assert_eq!(vec.0, expected_bits); + + let result = CompactBitArray::from(vec); + assert_eq!(source, result); + } + + #[test] + fn malformed() { + let source = CompactBitArray { + extra_bits_stored: 8, + elems: vec![0b00000000], + }; + let error = BitVector::try_from(source.clone()).unwrap_err(); + assert!(matches!(error, Error::MalformedCompactBitArray)); + + let source = CompactBitArray { + extra_bits_stored: 1, + elems: vec![], + }; + let error = BitVector::try_from(source.clone()).unwrap_err(); + assert!(matches!(error, Error::MalformedCompactBitArray)); + } } diff --git a/types/src/error.rs b/types/src/error.rs index 68b37f3b..c8475241 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -86,6 +86,10 @@ pub enum Error { #[error("Bit array to large")] BitarrayTooLarge, + /// Malformed CompactBitArray + #[error("CompactBitArray malformed")] + MalformedCompactBitArray, + /// Wrong proof type. #[error("Wrong proof type")] WrongProofType, diff --git a/types/src/state/tx.rs b/types/src/state/tx.rs index d407cbde..0a32b1d1 100644 --- a/types/src/state/tx.rs +++ b/types/src/state/tx.rs @@ -25,7 +25,7 @@ pub use celestia_proto::cosmos::tx::v1beta1::TxBody as RawTxBody; pub type Signature = Vec; -// [`BOND_DENOM`] defines the native staking denomination +/// [`BOND_DENOM`] defines the native staking denomination pub const BOND_DENOM: &str = "utia"; /// [`Tx`] is the standard type used for broadcasting transactions. @@ -218,6 +218,9 @@ pub struct Coin { } impl Fee { + /// Create [`Fee`] struct with provided number of utia and gas limit, + /// without setting custom [`Fee::payer`] or [`Fee::granter`] fields, + /// which means first tx signer is responsible for paying. pub fn new(utia_fee: u64, gas_limit: u64) -> Self { Fee { amount: vec![Coin { From 3c1d7c10521dd678fe98ae85e564a52d9802fdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 17:08:10 +0100 Subject: [PATCH 46/56] Update grpc/Cargo.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maciej Zwoliński Signed-off-by: Mikołaj Florkiewicz --- grpc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grpc/Cargo.toml b/grpc/Cargo.toml index f2bcd408..7038c079 100644 --- a/grpc/Cargo.toml +++ b/grpc/Cargo.toml @@ -3,7 +3,7 @@ name = "celestia-grpc" version = "0.1.0" edition = "2021" license = "Apache-2.0" -description = "A collection of traits for interacting with Celestia validator nodes gRPC" +description = "A client for interacting with Celestia validator nodes gRPC" authors = ["Eiger "] homepage = "https://www.eiger.co" repository = "https://github.com/eigerco/lumina" From 9a835ed8804171334a44223a8d1410d1b940f517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 21 Nov 2024 17:32:36 +0100 Subject: [PATCH 47/56] cleanup --- ci/run-validator.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/run-validator.sh b/ci/run-validator.sh index e553894b..21a8e703 100755 --- a/ci/run-validator.sh +++ b/ci/run-validator.sh @@ -120,7 +120,6 @@ setup_private_validator() { celestia-appd keys add "$NODE_NAME" --keyring-backend="test" validator_addr="$(celestia-appd keys show "$NODE_NAME" -a --keyring-backend="test")" # Create a validator's genesis account for the genesis.json with an initial bag of coins - echo "VALIDATOR ADDR: $validator_addr" celestia-appd add-genesis-account "$validator_addr" "$VALIDATOR_COINS" # Generate a genesis transaction that creates a validator with a self-delegation celestia-appd gentx "$NODE_NAME" 5000000000utia \ From 5224cfddc5496e824cec482a14c692d6a0d6f2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 22 Nov 2024 09:49:03 +0100 Subject: [PATCH 48/56] Yiannis review --- Cargo.toml | 2 +- grpc/src/types/auth.rs | 1 - grpc/tests/tonic.rs | 1 - proto/src/lib.rs | 4 ---- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e5c1a4ff..aef47f1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["cli", "node", "node-wasm", "proto", "rpc", "grpc", "types"] +members = ["cli", "grpc", "grpc/grpc-macros", "node", "node-wasm", "proto", "rpc", "types", ] [workspace.dependencies] blockstore = "0.7.0" diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index 8099dc00..8d543088 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -16,7 +16,6 @@ use crate::Error; /// Enum representing different types of account #[derive(Debug, PartialEq)] -#[non_exhaustive] pub enum Account { /// Base account type Base(BaseAccount), diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index a28611a9..2013934f 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -61,7 +61,6 @@ async fn get_account() { let address = match first_account { Account::Base(acct) => acct.address.clone(), Account::Module(acct) => acct.base_account.as_ref().unwrap().address.clone(), - _ => unimplemented!("unknown account type"), }; let account = client.get_account(&address).await.unwrap(); diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 0bbd3ce0..fc4fec3b 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -6,8 +6,4 @@ pub mod serializers; -#[cfg(not(feature = "tonic"))] include!(concat!(env!("OUT_DIR"), "/mod.rs")); - -#[cfg(feature = "tonic")] -::tonic::include_proto!("mod"); From 8d6e7c9165eca9f19631cf9ef019a45bbe469c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 22 Nov 2024 10:19:54 +0100 Subject: [PATCH 49/56] test --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aef47f1b..bf8cbc7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [workspace] resolver = "2" -members = ["cli", "grpc", "grpc/grpc-macros", "node", "node-wasm", "proto", "rpc", "types", ] +members = ["cli", "grpc", "node", "node-wasm", "proto", "rpc", "types", ] [workspace.dependencies] blockstore = "0.7.0" lumina-node = { version = "0.7.0", path = "node" } lumina-node-wasm = { version = "0.6.1", path = "node-wasm" } -celestia-proto = { version = "0.5.0", path = "proto" } +celestia-proto = { version = "0.5.1", path = "proto" } celestia-grpc = { version = "0.1.0", path = "grpc" } celestia-rpc = { version = "0.7.1", path = "rpc", default-features = false } celestia-types = { version = "0.8.0", path = "types", default-features = false } From 3da916ea40b184a06af35dc678d0998e8cde6a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 22 Nov 2024 10:20:51 +0100 Subject: [PATCH 50/56] test update --- Cargo.lock | 2 +- proto/CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ proto/Cargo.toml | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f6544e4..fd7838fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,7 +784,7 @@ dependencies = [ [[package]] name = "celestia-proto" -version = "0.5.0" +version = "0.5.1" dependencies = [ "celestia-tendermint-proto", "pbjson", diff --git a/proto/CHANGELOG.md b/proto/CHANGELOG.md index 00e40fc0..3bea2837 100644 --- a/proto/CHANGELOG.md +++ b/proto/CHANGELOG.md @@ -6,6 +6,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.5.1](https://github.com/fl0rek/celestia-node-rs/compare/celestia-proto-v0.5.0...celestia-proto-v0.5.1) - 2024-11-22 + +### Added + +- Tonic gRPC + +### Fixed + +- fix wasm +- fix any pubkey +- fix wasm +- fix wasm +- fix wasm +- fix wasm deps + +### Other + +- Yiannis review +- CI2 +- CI +- remove cosmrs, streamline +- Any->Any +- blob submission +- lasts tests +- doctests +- missed serialisation +- Merge remote-tracking branch 'upstream/main' into feat/grpc +- cleanup, updates +- missing rpc methods +- types cleanup + ## [0.5.0](https://github.com/eigerco/lumina/compare/celestia-proto-v0.4.1...celestia-proto-v0.5.0) - 2024-10-25 ### Added diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 22a9e744..01ff9e75 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "celestia-proto" -version = "0.5.0" +version = "0.5.1" edition = "2021" license = "Apache-2.0" description = "Rust implementation of proto structs used in celestia ecosystem" From 94371963f68035fdcb1d76852e23d01c85d5ac6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 22 Nov 2024 15:52:52 +0100 Subject: [PATCH 51/56] Maciek's review --- grpc/src/client.rs | 32 ++++++++++++++++++++++++++++---- grpc/src/error.rs | 4 ++++ grpc/src/types/auth.rs | 2 +- grpc/src/types/tx.rs | 21 ++++----------------- grpc/tests/tonic.rs | 2 +- proto/build.rs | 2 -- proto/src/serializers.rs | 1 - types/src/lib.rs | 1 - types/src/state.rs | 1 + types/src/{ => state}/auth.rs | 16 +--------------- 10 files changed, 40 insertions(+), 42 deletions(-) rename types/src/{ => state}/auth.rs (90%) diff --git a/grpc/src/client.rs b/grpc/src/client.rs index c9d68ff7..4962b582 100644 --- a/grpc/src/client.rs +++ b/grpc/src/client.rs @@ -1,3 +1,4 @@ +use prost::Message; use tonic::service::Interceptor; use tonic::transport::Channel; @@ -7,8 +8,8 @@ use celestia_proto::cosmos::base::node::v1beta1::service_client::ServiceClient a use celestia_proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient as TendermintServiceClient; use celestia_proto::cosmos::tx::v1beta1::service_client::ServiceClient as TxServiceClient; use celestia_tendermint::block::Block; -use celestia_types::auth::AuthParams; -use celestia_types::blob::{Blob, BlobParams}; +use celestia_types::blob::{Blob, BlobParams, RawBlobTx}; +use celestia_types::state::auth::AuthParams; use celestia_types::state::Address; use celestia_types::state::{RawTx, TxResponse}; @@ -71,14 +72,37 @@ where #[grpc_method(AuthQueryClient::accounts)] async fn get_accounts(&mut self) -> Result, Error>; - /// Broadcast Tx + /// Broadcast prepared and serialised transaction #[grpc_method(TxServiceClient::broadcast_tx)] async fn broadcast_tx( + &mut self, + tx_bytes: Vec, + mode: BroadcastMode, + ) -> Result; + + /// Broadcast blob transaction + pub async fn broadcast_blob_tx( &mut self, tx: RawTx, blobs: Vec, mode: BroadcastMode, - ) -> Result; + ) -> Result { + // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 + const BLOB_TX_TYPE_ID: &str = "BLOB"; + + if blobs.is_empty() { + return Err(Error::TxEmptyBlobList); + } + + let blobs = blobs.into_iter().map(Into::into).collect(); + let blob_tx = RawBlobTx { + tx: tx.encode_to_vec(), + blobs, + type_id: BLOB_TX_TYPE_ID.to_string(), + }; + + self.broadcast_tx(blob_tx.encode_to_vec(), mode).await + } /// Get Tx #[grpc_method(TxServiceClient::get_tx)] diff --git a/grpc/src/error.rs b/grpc/src/error.rs index d7fe08c8..9cdb2c7c 100644 --- a/grpc/src/error.rs +++ b/grpc/src/error.rs @@ -33,4 +33,8 @@ pub enum Error { /// Unexpected reponse type #[error("Unexpected response type")] UnexpectedResponseType(String), + + /// Empty blob submission list + #[error("Attempted to submit blob transaction with empty blob list")] + TxEmptyBlobList, } diff --git a/grpc/src/types/auth.rs b/grpc/src/types/auth.rs index 8d543088..330f13ca 100644 --- a/grpc/src/types/auth.rs +++ b/grpc/src/types/auth.rs @@ -5,7 +5,7 @@ use celestia_proto::cosmos::auth::v1beta1::{ QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest, QueryAccountsResponse, QueryParamsRequest as QueryAuthParamsRequest, QueryParamsResponse as QueryAuthParamsResponse, }; -use celestia_types::auth::{ +use celestia_types::state::auth::{ AuthParams, BaseAccount, ModuleAccount, RawBaseAccount, RawModuleAccount, }; use celestia_types::state::Address; diff --git a/grpc/src/types/tx.rs b/grpc/src/types/tx.rs index 68055baf..9297f75d 100644 --- a/grpc/src/types/tx.rs +++ b/grpc/src/types/tx.rs @@ -11,8 +11,7 @@ use celestia_proto::cosmos::tx::v1beta1::{ }; use celestia_tendermint::public_key::Secp256k1 as VerifyingKey; use celestia_tendermint_proto::Protobuf; -use celestia_types::auth::BaseAccount; -use celestia_types::blob::{Blob, RawBlob, RawBlobTx}; +use celestia_types::state::auth::BaseAccount; use celestia_types::state::{ AuthInfo, Fee, ModeInfo, RawTx, RawTxBody, SignerInfo, Sum, Tx, TxResponse, }; @@ -66,24 +65,12 @@ impl FromGrpcResponse for RawGetTxResponse { } } -impl IntoGrpcParam for (RawTx, Vec, BroadcastMode) { +impl IntoGrpcParam for (Vec, BroadcastMode) { fn into_parameter(self) -> BroadcastTxRequest { - let (tx, blobs, mode) = self; + let (tx_bytes, mode) = self; - // From https://github.com/celestiaorg/celestia-core/blob/v1.43.0-tm-v0.34.35/pkg/consts/consts.go#L19 - const BLOB_TX_TYPE_ID: &str = "BLOB"; - - // empty blob list causes error response, but this is already checked when creating MsgPayForBlobs - debug_assert!(!blobs.is_empty()); - - let blobs = blobs.into_iter().map(RawBlob::from).collect(); - let blob_tx = RawBlobTx { - tx: tx.encode_to_vec(), - blobs, - type_id: BLOB_TX_TYPE_ID.to_string(), - }; BroadcastTxRequest { - tx_bytes: blob_tx.encode_to_vec(), + tx_bytes, mode: mode.into(), } } diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index 2013934f..07d1387a 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -97,7 +97,7 @@ async fn submit_blob() { ); let response = client - .broadcast_tx(tx, blobs, BroadcastMode::Sync) + .broadcast_blob_tx(tx, blobs, BroadcastMode::Sync) .await .unwrap(); diff --git a/proto/build.rs b/proto/build.rs index c07f7a8a..d8fa4617 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -11,7 +11,6 @@ const BASE64STRING: &str = const QUOTED: &str = r#"#[serde(with = "celestia_tendermint_proto::serializers::from_str")]"#; const VEC_BASE64STRING: &str = r#"#[serde(with = "celestia_tendermint_proto::serializers::bytes::vec_base64string")]"#; -#[cfg(not(feature = "tonic"))] const OPTION_ANY: &str = r#"#[serde(with = "crate::serializers::option_any")]"#; const OPTION_TIMESTAMP: &str = r#"#[serde(with = "crate::serializers::option_timestamp")]"#; const NULL_DEFAULT: &str = r#"#[serde(with = "crate::serializers::null_default")]"#; @@ -53,7 +52,6 @@ static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ (".celestia.core.v1.da.DataAvailabilityHeader.row_roots", VEC_BASE64STRING), (".celestia.core.v1.da.DataAvailabilityHeader.column_roots", VEC_BASE64STRING), - #[cfg(not(feature = "tonic"))] (".cosmos.base.abci.v1beta1.TxResponse.tx", OPTION_ANY), (".cosmos.base.abci.v1beta1.TxResponse.logs", NULL_DEFAULT), (".cosmos.base.abci.v1beta1.TxResponse.events", NULL_DEFAULT), diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index 3c436ffd..d8119ab1 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -1,6 +1,5 @@ //! Custom serializers to be used with [`serde`]. pub mod null_default; -#[cfg(not(feature = "tonic"))] pub mod option_any; pub mod option_timestamp; diff --git a/types/src/lib.rs b/types/src/lib.rs index cffa0c42..d20541d1 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -1,7 +1,6 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] -pub mod auth; mod bit_array; pub mod blob; mod block; diff --git a/types/src/state.rs b/types/src/state.rs index cca59984..e584d1f5 100644 --- a/types/src/state.rs +++ b/types/src/state.rs @@ -1,6 +1,7 @@ //! Types and interfaces for accessing Celestia's state-relevant information. mod address; +pub mod auth; mod balance; mod query_delegation; mod tx; diff --git a/types/src/auth.rs b/types/src/state/auth.rs similarity index 90% rename from types/src/auth.rs rename to types/src/state/auth.rs index 23b68ac6..18b9ec6b 100644 --- a/types/src/auth.rs +++ b/types/src/state/auth.rs @@ -16,25 +16,11 @@ use crate::Error; pub use celestia_proto::cosmos::auth::v1beta1::BaseAccount as RawBaseAccount; pub use celestia_proto::cosmos::auth::v1beta1::ModuleAccount as RawModuleAccount; +pub use celestia_proto::cosmos::auth::v1beta1::Params as AuthParams; const COSMOS_ED25519_PUBKEY: &str = "/cosmos.crypto.ed25519.PubKey"; const COSMOS_SECP256K1_PUBKEY: &str = "/cosmos.crypto.secp256k1.PubKey"; -/// Params defines the parameters for the auth module. -#[derive(Debug)] -pub struct AuthParams { - /// Maximum number of memo characters - pub max_memo_characters: u64, - /// Maximum nubmer of signatures - pub tx_sig_limit: u64, - /// Cost per transaction byte - pub tx_size_cost_per_byte: u64, - /// Cost to verify ed25519 signature - pub sig_verify_cost_ed25519: u64, - /// Cost to verify secp255k1 signature - pub sig_verify_cost_secp256k1: u64, -} - /// [`BaseAccount`] defines a base account type. /// /// It contains all the necessary fields for basic account functionality. From 0bab6946ef1204affc18d57045a9b88d1e836531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Fri, 22 Nov 2024 18:53:55 +0100 Subject: [PATCH 52/56] move bitvector --- types/src/lib.rs | 1 - types/src/state.rs | 1 + types/src/{ => state}/bit_array.rs | 0 types/src/state/tx.rs | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename types/src/{ => state}/bit_array.rs (100%) diff --git a/types/src/lib.rs b/types/src/lib.rs index d20541d1..b7c87fb7 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -1,7 +1,6 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] -mod bit_array; pub mod blob; mod block; mod byzantine; diff --git a/types/src/state.rs b/types/src/state.rs index e584d1f5..562e679b 100644 --- a/types/src/state.rs +++ b/types/src/state.rs @@ -3,6 +3,7 @@ mod address; pub mod auth; mod balance; +mod bit_array; mod query_delegation; mod tx; diff --git a/types/src/bit_array.rs b/types/src/state/bit_array.rs similarity index 100% rename from types/src/bit_array.rs rename to types/src/state/bit_array.rs diff --git a/types/src/state/tx.rs b/types/src/state/tx.rs index 0a32b1d1..a4491538 100644 --- a/types/src/state/tx.rs +++ b/types/src/state/tx.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use celestia_proto::cosmos::base::abci::v1beta1::AbciMessageLog; use celestia_tendermint_proto::v0_34::abci::Event; -use crate::bit_array::BitVector; +use crate::state::bit_array::BitVector; use crate::Error; use crate::Height; From d4722bf1968fe557946972cd45a521904f274e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Mon, 25 Nov 2024 11:48:00 +0100 Subject: [PATCH 53/56] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yiannis Marangos Signed-off-by: Mikołaj Florkiewicz --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index bf8cbc7a..f2b2a016 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["cli", "grpc", "node", "node-wasm", "proto", "rpc", "types", ] +members = ["cli", "grpc", "node", "node-wasm", "proto", "rpc", "types"] [workspace.dependencies] blockstore = "0.7.0" From 4a72049debb206fb37119af52f93dfe623f3ca2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Mon, 25 Nov 2024 11:53:22 +0100 Subject: [PATCH 54/56] remove files commited by mistake --- proto/CHANGELOG.md | 31 ------------------------------- proto/Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/proto/CHANGELOG.md b/proto/CHANGELOG.md index 3bea2837..00e40fc0 100644 --- a/proto/CHANGELOG.md +++ b/proto/CHANGELOG.md @@ -6,37 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.5.1](https://github.com/fl0rek/celestia-node-rs/compare/celestia-proto-v0.5.0...celestia-proto-v0.5.1) - 2024-11-22 - -### Added - -- Tonic gRPC - -### Fixed - -- fix wasm -- fix any pubkey -- fix wasm -- fix wasm -- fix wasm -- fix wasm deps - -### Other - -- Yiannis review -- CI2 -- CI -- remove cosmrs, streamline -- Any->Any -- blob submission -- lasts tests -- doctests -- missed serialisation -- Merge remote-tracking branch 'upstream/main' into feat/grpc -- cleanup, updates -- missing rpc methods -- types cleanup - ## [0.5.0](https://github.com/eigerco/lumina/compare/celestia-proto-v0.4.1...celestia-proto-v0.5.0) - 2024-10-25 ### Added diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 01ff9e75..22a9e744 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "celestia-proto" -version = "0.5.1" +version = "0.5.0" edition = "2021" license = "Apache-2.0" description = "Rust implementation of proto structs used in celestia ecosystem" From 0c1a44e5ab9c7c5e6648f738e2f5852ed752332b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Mon, 25 Nov 2024 12:06:02 +0100 Subject: [PATCH 55/56] Update Cargo.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maciej Zwoliński Signed-off-by: Mikołaj Florkiewicz --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f2b2a016..f69353a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = ["cli", "grpc", "node", "node-wasm", "proto", "rpc", "types"] blockstore = "0.7.0" lumina-node = { version = "0.7.0", path = "node" } lumina-node-wasm = { version = "0.6.1", path = "node-wasm" } -celestia-proto = { version = "0.5.1", path = "proto" } +celestia-proto = { version = "0.5.0", path = "proto" } celestia-grpc = { version = "0.1.0", path = "grpc" } celestia-rpc = { version = "0.7.1", path = "rpc", default-features = false } celestia-types = { version = "0.8.0", path = "types", default-features = false } From 6bd6feb6927746ac96ac9744ff4c6a3bd72550be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Mon, 25 Nov 2024 13:54:09 +0100 Subject: [PATCH 56/56] update --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fd7838fe..0f6544e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,7 +784,7 @@ dependencies = [ [[package]] name = "celestia-proto" -version = "0.5.1" +version = "0.5.0" dependencies = [ "celestia-tendermint-proto", "pbjson",