Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/serde-all
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Oct 8, 2024
2 parents 1a1508a + aad72f4 commit d1d7b2a
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: docker logs tenderdash > tenderdash.log 2>&1

- name: Archive docker logs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure()
with:
name: tenderdash.log
Expand Down
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.2.1+1.3.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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ The repository contains the following crates:

## Version Compatibility

The major and minor versions of this library are designed to match those of [Tenderdash]. For instance, if you're working with `Tenderdash 1.2.34`, you should use `rs-tenderdash-abci 1.2.*` to ensure compatibility.
Versioning of this library follows the Semantic Versioning 2.0.0 specification. Specifically, it consists of
`MAJOR.MINOR.PATCH+BUILD`, where `BUILD` denotes minimum version of [Tenderdash] required.

For instance, if you're working with `Tenderdash 1.3.0`, you should use `rs-tenderdash-abci 1.2.0+1.3.0`.

This library also includes built-in support for ABCI protocol version verification. The ABCI protocol version, as defined in Tenderdash's [version.go](https://github.com/dashpay/tenderdash/blob/HEAD/version/version.go) under the `ABCISemVer` constant, must align with the ABCI protocol version of this library. You can find the library's ABCI protocol version in [proto/src/tenderdash.rs](proto/src/tenderdash.rs) under the `ABCI_VERSION` constant.

Expand Down
21 changes: 8 additions & 13 deletions abci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
version = "1.1.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 @@ -48,7 +51,6 @@ tenderdash-proto = { path = "../proto", default-features = false, features = [
"serde",
] }
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 All @@ -60,11 +62,11 @@ url = { version = "2.5.0" }
semver = { version = "1.0.22" }
lhash = { version = "1.1.0", features = ["sha256"], optional = true }
hex = { version = "0.4.3" }
tokio-util = { version = "0.7.10", features = [
tokio-util = { version = "0.7.12", features = [
"net",
"codec",
], default-features = false, optional = true }
tokio = { version = "1.37.0", features = [
tokio = { version = "1.40", features = [
"net",
"io-util",
"rt-multi-thread",
Expand All @@ -77,16 +79,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.40", 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" }
6 changes: 2 additions & 4 deletions abci/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## tendermint-abci
# tendermint-abci

[![Crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
Expand Down Expand Up @@ -85,9 +85,7 @@ Copyright © 2021 Informal Systems

Licensed under the Apache License, Version 2.0 (the "License");
you may not use the files in this repository except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0
You may obtain a copy of the License at <https://www.apache.org/licenses/LICENSE-2.0> .

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
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};

#[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::{
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.1.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
4 changes: 4 additions & 0 deletions proto-compiler/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,8 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
".tendermint.types.VersionParams.app_version",
QUOTED_WITH_DEFAULT,
),
(
".tendermint.types.VersionParams.consensus_version",
QUOTED_WITH_DEFAULT,
),
];
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.1.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 Down Expand Up @@ -46,32 +49,32 @@ grpc = [
serde = ["dep:serde", "bytes/serde"]

[dependencies]
bytes = { version = "1.6.0", default-features = false }
prost = { version = "0.12.4", default-features = false, features = [
bytes = { version = "1.7", default-features = false }
prost = { version = "0.13", default-features = false, features = [
"prost-derive",
] }
tonic = { version = "0.11.0", optional = true }
serde = { version = "1.0.197", default-features = false, features = [
tonic = { version = "0.12", optional = true }
serde = { version = "1.0.208", default-features = false, features = [
"derive",
], optional = true }
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
2 changes: 1 addition & 1 deletion proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tenderdash_proto_compiler::GenerationMode;

fn main() {
// default Tenderdash version to use if TENDERDASH_COMMITISH is not set
const DEFAULT_VERSION: &str = "v1.1.0";
const DEFAULT_VERSION: &str = "v1.3.0";

// check if TENDERDASH_COMMITISH is already set; if not, set it to the current
// version
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)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
#[cfg_attr(
feature = "serde",
Expand Down Expand Up @@ -50,7 +50,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
Loading

0 comments on commit d1d7b2a

Please sign in to comment.