Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into doc-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Mar 20, 2024
2 parents 8ec6ff7 + 17ed6e7 commit 5cba1db
Show file tree
Hide file tree
Showing 45 changed files with 2,546 additions and 593 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/target/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
9 changes: 4 additions & 5 deletions .github/actions/deps/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ runs:
shell: bash
run: |
curl -Lo /tmp/protoc.zip \
https://github.com/protocolbuffers/protobuf/releases/download/v22.0/protoc-22.0-linux-x86_64.zip
https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-x86_64.zip
unzip /tmp/protoc.zip -d ${HOME}/.local
echo "PROTOC=${HOME}/.local/bin/protoc" >> $GITHUB_ENV
export PATH="${PATH}:${HOME}/.local/bin"
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
proto/src/prost
- name: Compile Protobuf definitions

- name: "Compile Protobuf definitions (needed by fmt, doc, etc.)"
shell: bash
run: cargo build -p tenderdash-proto
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache cargo bin
uses: actions/cache@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
tenderdash:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/deps
- name: Build source code
shell: bash
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Docker

on:
workflow_dispatch:
pull_request:
paths-ignore:
- "docs/**"
push:
paths-ignore:
- "docs/**"
branches:
- master
- "v*.*.*"

jobs:
build:
strategy:
matrix:
os: [alpine, debian]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: amd64

- name: Set up Docker Build
uses: docker/[email protected]

# ARM build takes very long time, so we build PRs for AMD64 only
- name: Select target platform
id: select_platforms
run: |
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]] ; then
echo "build_platforms=linux/amd64" >> $GITHUB_ENV
else
echo "build_platforms=linux/amd64,linux/arm64" >> $GITHUB_ENV
fi
- name: Build Docker sample image
id: docker_build
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile-${{ matrix.os }}
build-args: |
REVISION=${{ github.ref }}
platforms: ${{ env.build_platforms }}
push: false
cache-from: |
type=gha
cache-to: |
type=gha,mode=max
- name: Show Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
5 changes: 2 additions & 3 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v2

uses: actions/checkout@v3
- name: Install Rust toolchain and deps
uses: ./.github/actions/deps

Expand All @@ -42,7 +41,7 @@ jobs:
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/deps
- name: Check code formatting
shell: bash
Expand All @@ -32,7 +32,7 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/deps
- name: Check documentation generation
shell: bash
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:
RUST_TEST_TIME_INTEGRATION: "3000,6000"
RUST_TEST_TIME_DOCTEST: "3000,6000"
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- uses: ./.github/actions/deps
with:
toolchain: nightly
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ Cargo.lock
# These are log files emitted by model-based tests
**/*.log

# These are intelj files
.idea

# Proptest regressions dumps
**/*.proptest-regressions
.vscode/launch.json
*.profraw

# Mac spotlight
.DS_Store
Empty file added .gitmodules
Empty file.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]

resolver = "2"
members = ["abci", "proto-compiler", "proto"]
56 changes: 56 additions & 0 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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

RUN apk add --no-cache \
git \
wget \
alpine-sdk \
openssl-dev \
libc6-compat \
perl \
unzip \
bash

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

# one of: aarch_64, x86_64
# ARG PROTOC_ARCH=x86_64
ARG TARGETPLATFORM
ARG BUILDPLATFORM

# Install protoc - protobuf compiler
# The one shipped with Alpine does not work
RUN if [[ "$BUILDPLATFORM" == "linux/arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64 ; fi; \
wget -q -O /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-${PROTOC_ARCH}.zip && \
unzip -qd /opt/protoc /tmp/protoc.zip && \
rm /tmp/protoc.zip && \
ln -s /opt/protoc/bin/protoc /usr/bin/

# Create a dummy package
RUN cargo init /usr/src/abci-app
WORKDIR /usr/src/abci-app

# Let's display ABCI version instead of "hello world"
RUN sed -i'' -e 's/println!("Hello, world!");/println!("ABCI version: {}",tenderdash_abci::proto::ABCI_VERSION);/' src/main.rs

# revspec or SHA of commit/branch/tag to use
ARG REVISION="refs/heads/master"

# Add tenderdash-abci as a dependency and build the package
#
# Some notes here:
# 1. All these --mount... are to cache reusable info between runs.
# See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
# 2. We add `--config net.git-fetch-with-cli=true` to address ARM build issue,
# see https://github.com/rust-lang/cargo/issues/10781#issuecomment-1441071052
# 3. To preserve space on github cache, we call `cargo clean`.
RUN --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \
--mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \
--mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \
cargo add --config net.git-fetch-with-cli=true \
--git https://github.com/dashpay/rs-tenderdash-abci --rev "${REVISION}" tenderdash-abci && \
cargo build --config net.git-fetch-with-cli=true && \
cargo run --config net.git-fetch-with-cli=true && \
cargo clean
47 changes: 47 additions & 0 deletions Dockerfile-debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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

RUN --mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
--mount=type=cache,sharing=locked,target=/var/cache/apt \
rm -f /etc/apt/apt.conf.d/docker-clean && \
apt-get update -qq && \
apt-get install -qq --yes \
git \
wget \
bash

# Install protoc - protobuf compiler
# The one shipped with Alpine does not work
RUN if [[ "$BUILDPLATFORM" == "linux/arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64 ; fi; \
wget -q -O /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-${PROTOC_ARCH}.zip && \
unzip -qd /opt/protoc /tmp/protoc.zip && \
rm /tmp/protoc.zip && \
ln -s /opt/protoc/bin/protoc /usr/bin/

# Create a dummy package
RUN cargo init /usr/src/abci-app
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:
# 1. All these --mount... are to cache reusable info between runs.
# See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
# 2. We add `--config net.git-fetch-with-cli=true` to address ARM build issue,
# see https://github.com/rust-lang/cargo/issues/10781#issuecomment-1441071052
# 3. To preserve space on github cache, we call `cargo clean`.
RUN --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \
--mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \
--mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \
cargo add --config net.git-fetch-with-cli=true \
--git https://github.com/dashpay/rs-tenderdash-abci --rev "${REVISION}" tenderdash-abci && \
cargo build --config net.git-fetch-with-cli=true && \
cargo clean
63 changes: 52 additions & 11 deletions abci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.14.0-dev.9"
name = "tenderdash-abci"
version = "0.12.0-dev.1"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand All @@ -13,29 +13,70 @@ description = """tenderdash-abci provides a simple framework with which to build
low-level applications on top of Tenderdash."""

[features]
default = ["server", "docker-tests"]
default = [
"server",
"docker-tests",
"crypto",
"tcp",
"unix",
"grpc",
"tracing-span",
]
# docker-tests includes integration tests that require docker to be available
docker-tests = ["server"]
server = ["tracing-subscriber/fmt"]
server = [
"tracing-subscriber/fmt",
"dep:tokio",
"dep:tokio-util",
"dep:futures",
]

grpc = ["tenderdash-proto/grpc"]
crypto = ["dep:lhash"]
tcp = ["server"]
unix = ["server"]
tracing-span = ["dep:uuid"]

[[example]]
name = "echo_socket"
required-features = ["server"]

[dependencies]
uuid = { version = "1.4.1", features = ["v4", "fast-rng"], optional = true }
tenderdash-proto = { path = "../proto" }
bytes = { version = "1.0" }
prost = { version = "0.11" }
tenderdash-proto = { version = "0.12.0-dev.1", default-features = false, path = "../proto" }
prost = { version = "0.12" }
tracing = { version = "0.1", default-features = false }
tracing-subscriber = { version = "0.3", optional = true, default-features = false }
thiserror = "1.0.39"
tracing-subscriber = { version = "0.3", optional = true, default-features = false, features = [
"ansi",
"env-filter",
] }
thiserror = { version = "1.0.39" }
url = { version = "2.3.1" }
semver = { version = "1.0.17" }
lhash = { version = "1.0.1", features = ["sha256"], optional = true }
hex = { version = "0.4" }
tokio-util = { version = "0.7.8", features = [
"net",
"codec",
], default-features = false, optional = true }
tokio = { version = "1.28", features = [
"net",
"io-util",
"rt-multi-thread",
"sync",
"macros",
], default-features = false, optional = true }
futures = { version = "0.3.28", optional = true }

[dev-dependencies]
anyhow = "1.0.69"
bincode = "2.0.0-rc.2"
blake2 = "0.10.6"
bollard = { version = "0.14.0" }
anyhow = { version = "1.0.69" }
bincode = { version = "2.0.0-rc.2" }
blake2 = { version = "0.10.6" }
bollard = { version = "0.16.0" }
futures = { version = "0.3.26" }
tokio = { version = "1", features = ["macros", "signal", "time", "io-std"] }
hex = { version = "0.4" }
lazy_static = { version = "1.4" }
# For tests of gRPC server
tonic = { version = "0.11" }
Loading

0 comments on commit 5cba1db

Please sign in to comment.