Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps)!: update prost, tokio, tonic and other dependencies #95

Merged
merged 13 commits into from
Oct 7, 2024
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[workspace]
resolver = "2"
members = ["abci", "proto-compiler", "proto"]

[workspace.package]

rust-version = "1.80"
version = "1.1.0"
5 changes: 2 additions & 3 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This is an example Dockerfile, demonstrating build process of rs-tenderdash-abci

# rust:alpine3.17, published Mar 24, 2023 at 2:55 am
FROM rust:alpine3.17
FROM rust:1.80-alpine3.20

RUN apk add --no-cache \
git \
Expand All @@ -13,7 +12,7 @@ RUN apk add --no-cache \
unzip \
bash

SHELL ["/bin/bash", "-c"]
SHELL ["/bin/bash", "-exc"]

# one of: aarch_64, x86_64
# ARG PROTOC_ARCH=x86_64
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile-debian
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# This is an example Dockerfile, demonstrating build process of rs-tenderdash-abci

# We use Debian base image, as Alpine has some segmentation fault issue
FROM rust:bullseye
FROM rust:1.80.0-bookworm

SHELL ["/bin/bash", "-exc"]

RUN --mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
--mount=type=cache,sharing=locked,target=/var/cache/apt \
Expand All @@ -28,8 +30,6 @@ WORKDIR /usr/src/abci-app
# revspec or SHA of commit/branch/tag to use
ARG REVISION="refs/heads/master"

SHELL ["/bin/bash", "-c"]

# Add tenderdash-abci as a dependency and build the package
#
# Some notes here:
Expand Down
17 changes: 6 additions & 11 deletions abci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
version = "1.2.0+1.3.0"

name = "tenderdash-abci"
edition = "2021"
license = "Apache-2.0"
Expand All @@ -12,6 +12,9 @@ documentation = "https://dashpay.github.io/rs-tenderdash-abci/tenderdash_abci/"
description = """tenderdash-abci provides a simple framework with which to build\
low-level applications on top of Tenderdash."""

rust-version.workspace = true
version.workspace = true

[features]
default = [
"server",
Expand Down Expand Up @@ -46,7 +49,6 @@ required-features = ["server"]
uuid = { version = "1.8.0", features = ["v4", "fast-rng"], optional = true }
tenderdash-proto = { path = "../proto", default-features = false }
bytes = { version = "1.6.0" }
prost = { version = "0.12.4" }
tracing = { version = "0.1.40", default-features = false }
tracing-subscriber = { version = "0.3.18", optional = true, default-features = false, features = [
"ansi",
Expand Down Expand Up @@ -75,16 +77,9 @@ futures = { version = "0.3.30", optional = true }
anyhow = { version = "1.0.82" }
bincode = { version = "2.0.0-rc.3" }
blake2 = { version = "0.10.6" }
bollard = { version = "0.16.1" }
bollard = { version = "0.17" }
futures = { version = "0.3.30" }
tokio = { version = "1.37.0", features = [
"macros",
"signal",
"time",
"io-std",
] }
tokio = { version = "1.39", features = ["macros", "signal", "time", "io-std"] }
hex = { version = "0.4.3" }
lazy_static = { version = "1.4.0" }
# For tests of gRPC server
tonic = { version = "0.11.0" }
pollster = { version = "0.3.0" }
2 changes: 1 addition & 1 deletion abci/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ mod server;
use std::io;

pub use application::{check_version, Application, RequestDispatcher};
use prost::{DecodeError, EncodeError};
#[allow(deprecated)]
#[cfg(feature = "server")]
pub use server::{start_server, CancellationToken, Server, ServerBuilder, ServerRuntime};
pub use tenderdash_proto as proto;
use tenderdash_proto::prost::{DecodeError, EncodeError};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Inconsistent Imports Detected

The import of DecodeError and EncodeError in proto/src/error.rs still uses prost::{DecodeError, EncodeError}. To maintain consistency across the codebase, please update this import to tenderdash_proto::prost::{DecodeError, EncodeError}.

🔗 Analysis chain

LGTM! Verify impact on codebase.

The import change from prost to tenderdash_proto::prost for DecodeError and EncodeError looks good and aligns with the PR objectives. This modification likely reflects updates in the dependency structure or aims to maintain consistency across the project.

To ensure this change doesn't introduce any unintended consequences, please run the following script to verify that all usages of DecodeError and EncodeError in the codebase are consistent with this new import:

This script will help identify any inconsistencies in the usage or import of these error types across the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of DecodeError and EncodeError from tenderdash_proto::prost

# Test: Search for DecodeError and EncodeError usages
echo "Searching for DecodeError and EncodeError usages:"
rg --type rust -e "DecodeError" -e "EncodeError"

# Test: Verify imports of DecodeError and EncodeError
echo "Verifying imports of DecodeError and EncodeError:"
rg --type rust -e "use .*prost::.*DecodeError" -e "use .*prost::.*EncodeError"

Length of output: 825


#[cfg(feature = "crypto")]
pub mod signatures;
Expand Down
12 changes: 7 additions & 5 deletions abci/src/server/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use std::{fmt::Debug, sync::Arc};

use bytes::{Buf, BufMut, BytesMut};
use futures::{SinkExt, StreamExt};
use prost::Message;
use proto::abci::{Request, Response};
use tenderdash_proto::prost::{
encoding::{decode_varint, encode_varint},
Message,
};
use tokio::{
io::{AsyncRead, AsyncWrite},
sync::{
Expand Down Expand Up @@ -162,7 +165,7 @@ impl Decoder for Coder {
let src_len = src.len();

let mut tmp = src.clone().freeze();
let encoded_len = match prost::encoding::decode_varint(&mut tmp) {
let encoded_len = match decode_varint(&mut tmp) {
Ok(len) => len,
// We've potentially only received a partial length delimiter
Err(_) if src_len <= MAX_VARINT_LENGTH => return Ok(None),
Expand Down Expand Up @@ -198,16 +201,15 @@ impl Encoder<proto::abci::Response> for Coder {
message.encode(&mut buf)?;

let buf = buf.freeze();
prost::encoding::encode_varint(buf.len() as u64, dst);
encode_varint(buf.len() as u64, dst);
dst.put(buf);
Ok(())
}
}

#[cfg(test)]
mod test {
use prost::Message;
use tenderdash_proto::abci;
use tenderdash_proto::{abci, prost::Message};
use tokio::{io::AsyncWriteExt, sync::mpsc};
use tokio_util::sync::CancellationToken;

Expand Down
3 changes: 1 addition & 2 deletions abci/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use std::{
};

use bytes::BufMut;
use prost::Message;
use tenderdash_proto::types::CanonicalVote;
use tenderdash_proto::{prost::Message, types::CanonicalVote};

use crate::{
proto::types::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the Syntax of the #[deprecated] Attribute

The syntax for the #[deprecated] attribute should include named parameters such as since and note. The correct usage is:

#[deprecated(note = "replaced by calculate_sign_hash() to unify naming between core, platform and tenderdash")]

This ensures that the compiler properly recognizes the deprecation and provides informative warnings.

Expand Down
15 changes: 9 additions & 6 deletions abci/tests/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tenderdash_abci::{
};
mod common;
use tenderdash_abci::proto;
use tonic::{async_trait, Response, Status};
use tenderdash_proto::tonic::{async_trait, Response, Status};

#[cfg(feature = "docker-tests")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn grpc_server_test(test_name: &str, bind_address: &str) {
use core::panic;

use proto::abci::abci_application_server::AbciApplicationServer;
use tonic::transport::Server;
use tenderdash_proto::tonic::transport::Server;

tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::new("debug"))
Expand Down Expand Up @@ -125,17 +125,20 @@ pub struct TestApp {
impl AbciApplication for TestApp {
async fn echo(
&self,
request: tonic::Request<RequestEcho>,
) -> Result<tonic::Response<proto::abci::ResponseEcho>, Status> {
request: tenderdash_proto::tonic::Request<RequestEcho>,
) -> Result<tenderdash_proto::tonic::Response<proto::abci::ResponseEcho>, Status> {
tracing::info!(?request, "Echo called");
Ok(Response::new(proto::abci::ResponseEcho {
message: request.into_inner().message,
}))
}
async fn info(
&self,
_request: tonic::Request<RequestInfo>,
) -> std::result::Result<tonic::Response<ResponseInfo>, tonic::Status> {
_request: tenderdash_proto::tonic::Request<RequestInfo>,
) -> std::result::Result<
tenderdash_proto::tonic::Response<ResponseInfo>,
tenderdash_proto::tonic::Status,
> {
tracing::info!("Info called, test successful");
let resp = ResponseInfo {
..Default::default()
Expand Down
17 changes: 10 additions & 7 deletions proto-compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
[package]
version = "1.2.0+1.3.0"

name = "tenderdash-proto-compiler"
authors = ["Informal Systems <[email protected]>", "Dash Core Group"]
edition = "2021"
description = "Internal tool to download and build tenderdash protobuf definitions; used by proto/build.rs"
publish = false

rust-version.workspace = true
version.workspace = true

[lib]

[dependencies]
walkdir = { version = "2.5.0" }
prost-build = { version = "0.12.4" }
tempfile = { version = "3.10.1" }
regex = { "version" = "1.10.4" }
prost-build = { version = "0.13" }
tempfile = { version = "3.12" }
regex = { "version" = "1.10" }
# Use of native-tls-vendored should build vendored openssl, which is required for Alpine build
ureq = { "version" = "2.9.6" }
zip = { version = "2.1.3", default-features = false, features = ["deflate"] }
ureq = { "version" = "2.10" }
zip = { version = "2.2", default-features = false, features = ["deflate"] }
fs_extra = { version = "1.3.0" }
tonic-build = { version = "0.11.0", optional = true }
tonic-build = { version = "0.12", optional = true }


[features]
Expand Down
21 changes: 12 additions & 9 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
version = "1.2.0+1.3.0"

name = "tenderdash-proto"
edition = "2021"
license = "Apache-2.0"
Expand All @@ -19,6 +19,9 @@ description = """
tenderdash-proto is a the Rust implementation of the Tenderdash proto structs.
"""

rust-version.workspace = true
version.workspace = true

[package.metadata.docs.rs]
all-features = true

Expand All @@ -44,30 +47,30 @@ grpc = [
]

[dependencies]
prost = { version = "0.12.4", default-features = false, features = [
prost = { version = "0.13", default-features = false, features = [
"prost-derive",
] }
tonic = { version = "0.11.0", optional = true }
bytes = { version = "1.6.0", default-features = false, features = ["serde"] }
serde = { version = "1.0.197", default-features = false, features = ["derive"] }
tonic = { version = "0.12", optional = true }
bytes = { version = "1.7", default-features = false, features = ["serde"] }
serde = { version = "1.0.208", default-features = false, features = ["derive"] }
subtle-encoding = { version = "0.5.1", default-features = false, features = [
"hex",
"base64",
"alloc",
] }
num-traits = { version = "0.2.18", default-features = false }
num-traits = { version = "0.2.19", default-features = false }
num-derive = { version = "0.4.2", default-features = false }
time = { version = "0.3.36", default-features = false, features = [
"macros",
"parsing",
] }
flex-error = { version = "0.4.4", default-features = false }
chrono = { version = "0.4.37", default-features = false }
derive_more = { version = "0.99.17" }
chrono = { version = "0.4.38", default-features = false }
derive_more = { version = "1.0", features = ["from", "from_str"] }


[dev-dependencies]
serde_json = { version = "1.0.115", default-features = false, features = [
serde_json = { version = "1.0.125", default-features = false, features = [
"alloc",
] }

Expand Down
1 change: 1 addition & 0 deletions proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::fmt::Display;

use bytes::{Buf, BufMut};
pub use error::Error;
pub use prost;
use prost::{encoding::encoded_len_varint, Message};
#[rustfmt::skip]
pub mod tenderdash_nostd;
Expand Down
4 changes: 2 additions & 2 deletions proto/src/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::fmt;
/// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
/// restricting to that range, we ensure that we can convert to and from [RFC
/// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
#[derive(Clone, PartialEq, ::prost::Message, ::serde::Deserialize, ::serde::Serialize)]
#[derive(Clone, Copy, PartialEq, ::prost::Message, ::serde::Deserialize, ::serde::Serialize)]
#[serde(
from = "crate::serializers::timestamp::Rfc3339",
into = "crate::serializers::timestamp::Rfc3339"
Expand All @@ -46,7 +46,7 @@ pub struct Timestamp {
/// or "month". It is related to Timestamp in that the difference between
/// two Timestamp values is a Duration and it can be added or subtracted
/// from a Timestamp. Range is approximately +-10,000 years.
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Duration {
/// Signed seconds of the span of time. Must be from -315,576,000,000
/// to +315,576,000,000 inclusive. Note: these bounds are computed from:
Expand Down
3 changes: 1 addition & 2 deletions proto/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,12 @@ pub fn protobuf_struct_conveniences_example() {

#[test]
pub fn test_response_exception_from() {
assert_eq!(ResponseException::from("string").error, "string");
assert_eq!(
ResponseException::from(String::from("string")).error,
"string"
);
assert_eq!(
ResponseException::from(&String::from("string")).error,
ResponseException::from(String::from("string")).error,
"string"
);
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ echo "INFO: Preparing release of rs-tenderdash-abci version $rs_tenderdash_abci_

echo INFO: Update the version in the Cargo.toml files.

sed -i "s/^version = .*/version = \"$rs_tenderdash_abci_version\"/" ./*/Cargo.toml
set -ex
# Update the version in the Cargo.toml files.
sed -i "s/^version = .*/version = \"$rs_tenderdash_abci_version\"/" ./Cargo.toml
sed -i "s/^\s*const DEFAULT_VERSION: &str = \".*\";/const DEFAULT_VERSION: \&str = \"v$td_version\";/" ./proto/build.rs
cargo fmt -- ./proto/build.rs 2>/dev/null

Expand Down
Loading