From 5ac7ed2c47078a56386758935f9d421f4da10bcb Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Tue, 6 Feb 2024 10:12:32 -0500 Subject: [PATCH 01/13] Update CI --- .github/workflows/byzantine.yml | 45 ------ .github/workflows/ci.yml | 257 ++++++++++++++++++++++++++++++ .github/workflows/conformance.yml | 45 ------ .github/workflows/docs.yml | 45 ------ .github/workflows/e2e.yml | 45 ------ .github/workflows/lint.yml | 66 -------- .github/workflows/unit.yml | 41 ----- 7 files changed, 257 insertions(+), 287 deletions(-) delete mode 100644 .github/workflows/byzantine.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/conformance.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/e2e.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/unit.yml diff --git a/.github/workflows/byzantine.yml b/.github/workflows/byzantine.yml deleted file mode 100644 index 8fab3cc..0000000 --- a/.github/workflows/byzantine.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: ci-byzantine-tests - -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -permissions: - contents: write - -jobs: - e2e: - name: avalanchego byzantine tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '1.19' - - - name: Run e2e tests - run: scripts/tests.avalanchego-byzantine.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ad9a831 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,257 @@ +name: ci + +on: + push: + branches: + - main + tags: + - '*' + pull_request: + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Remove unnecessary files + run: | + docker rmi `docker images -q` + sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d + sudo apt -y autoremove --purge + sudo apt -y autoclean + sudo apt clean + rm -rf "$AGENT_TOOLSDIRECTORY" + df -h + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + large-packages: true + swap-storage: true + - name: Install protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + shared-key: 'ci' + - name: Build binaries + run: cargo build --all --tests --all-features + + fmt: + runs-on: ubuntu-latest + steps: + - run: 'echo hello world' + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - name: Run static analysis tests + shell: bash + run: cargo fmt --all --check + + unit: + name: unit tests + needs: build + runs-on: ubuntu-latest + steps: + - name: Remove unnecessary files + run: | + docker rmi `docker images -q` + sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d + sudo apt -y autoremove --purge + sudo apt -y autoclean + sudo apt clean + rm -rf "$AGENT_TOOLSDIRECTORY" + df -h + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + large-packages: true + swap-storage: true + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Check Rust version + run: rustc --version + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # with: + # version: '3.x' + # repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout + uses: actions/checkout@v3 + + - uses: Swatinem/rust-cache@v2 + with: + shared-key: 'ci' + + - name: Run unit tests + run: cargo test --all-features -p avalanche-types -p avalanche-consensus + + avalanchego-integration-tests: + needs: build + runs-on: ubuntu-latest + steps: + - run: 'echo hello world' + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Remove unnecessary files + # run: | + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf "$AGENT_TOOLSDIRECTORY" + # - name: Install linker + # run: | + # sudo apt-get update + # sudo apt-get install -y --no-install-recommends \ + # gcc-multilib + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # with: + # version: '3.x' + # repo-token: ${{ secrets.GITHUB_TOKEN }} + + # - name: Install Rust + # uses: dtolnay/rust-toolchain@stable + + # - name: Install Go + # uses: actions/setup-go@v4 + # with: + # go-version: '1.19' + + # - name: Run e2e tests + # run: scripts/tests.avalanchego-e2e.sh + + avalanchego-conformance-tests: + needs: build + runs-on: ubuntu-latest + steps: + - run: 'echo hello world' + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Remove unnecessary files + # run: | + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf "$AGENT_TOOLSDIRECTORY" + # - name: Install linker + # run: | + # sudo apt-get update + # sudo apt-get install -y --no-install-recommends \ + # gcc-multilib + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # with: + # version: '3.x' + # repo-token: ${{ secrets.GITHUB_TOKEN }} + + # - name: Install Rust + # uses: dtolnay/rust-toolchain@stable + + # - name: Install Go + # uses: actions/setup-go@v4 + # with: + # go-version: '1.19' + + # - name: Run e2e tests + # run: scripts/tests.avalanchego-conformance.sh + + avalanchego-byzantine-tests: + needs: build + runs-on: ubuntu-latest + steps: + - run: 'echo hello world' + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Remove unnecessary files + # run: | + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf "$AGENT_TOOLSDIRECTORY" + # - name: Install linker + # run: | + # sudo apt-get update + # sudo apt-get install -y --no-install-recommends \ + # gcc-multilib + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # with: + # version: '3.x' + # repo-token: ${{ secrets.GITHUB_TOKEN }} + + # - name: Install Rust + # uses: dtolnay/rust-toolchain@stable + + # - name: Install Go + # uses: actions/setup-go@v4 + # with: + # go-version: '1.19' + + # - name: Run e2e tests + # run: scripts/tests.avalanchego-byzantine.sh + clippy: + needs: build + runs-on: ubuntu-latest + steps: + - run: 'echo hello world' + # - name: Remove unnecessary files + # run: | + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf "$AGENT_TOOLSDIRECTORY" + # - name: Install linker + # run: | + # sudo apt-get update + # sudo apt-get install -y --no-install-recommends \ + # gcc-multilib + # - name: Install Rust + # uses: dtolnay/rust-toolchain@stable + # - name: Check Rust version + # run: rustc --version + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # with: + # version: '3.x' + # repo-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Run static analysis tests + # shell: bash + # run: cargo clippy --all --all-features --tests --benches --examples + + docs: + runs-on: ubuntu-latest + steps: + - run: 'echo hello world' + # - name: Remove unnecessary files + # run: | + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf "$AGENT_TOOLSDIRECTORY" + # - name: Install linker + # run: | + # sudo apt-get update + # sudo apt-get install -y --no-install-recommends \ + # gcc-multilib + # - name: Install Rust + # uses: dtolnay/rust-toolchain@stable + # - name: Check Rust version + # run: rustc --version + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # with: + # version: '3.x' + # repo-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Set env var + # shell: bash + # run: export 'RUSTFLAGS=-D warnings' + # # Fails the CI build if there are documentation warnings. + # - name: Run doc tests + # shell: bash + # run: cargo doc --no-deps --all-features -p avalanche-consensus -p avalanche-types diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml deleted file mode 100644 index bc92df9..0000000 --- a/.github/workflows/conformance.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: ci-conformance-tests - -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -permissions: - contents: write - -jobs: - e2e: - name: avalanchego conformance tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '1.19' - - - name: Run e2e tests - run: scripts/tests.avalanchego-conformance.sh diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 1be5791..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: ci-doc-tests - -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -permissions: - contents: write - -jobs: - docs: - name: docs - runs-on: ubuntu-latest - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - name: Check Rust version - run: rustc --version - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v3 - - name: Set env var - shell: bash - run: export 'RUSTFLAGS=-D warnings' - # Fails the CI build if there are documentation warnings. - - name: Run doc tests - shell: bash - run: cargo doc --no-deps --all-features -p avalanche-consensus -p avalanche-types diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 50a385c..0000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: ci-e2e-tests - -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -permissions: - contents: write - -jobs: - e2e: - name: avalanchego integration tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '1.19' - - - name: Run e2e tests - run: scripts/tests.avalanchego-e2e.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index bbe3772..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: ci-clippy - -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -permissions: - contents: write - -jobs: - fmt: - runs-on: ubuntu-latest - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - name: Check Rust version - run: rustc --version - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v3 - - name: Run static analysis tests - shell: bash - run: cargo fmt --all --check - clippy: - runs-on: ubuntu-latest - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - name: Check Rust version - run: rustc --version - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v3 - - name: Run static analysis tests - shell: bash - run: cargo clippy --all --all-features --tests --benches --examples diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml deleted file mode 100644 index e832614..0000000 --- a/.github/workflows/unit.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: ci-unit-tests - -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -permissions: - contents: write - -jobs: - unit: - name: unit tests - runs-on: ubuntu-latest - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install linker - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - name: Check Rust version - run: rustc --version - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: "3.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v3 - - name: Run unit tests - shell: bash - run: scripts/tests.unit.sh From 41bd0b11afa47047f59083f5168302612b0d73f6 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 11:53:44 -0500 Subject: [PATCH 02/13] FAILURE --- crates/avalanche-types/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/avalanche-types/src/lib.rs b/crates/avalanche-types/src/lib.rs index 925fb89..f078a6d 100644 --- a/crates/avalanche-types/src/lib.rs +++ b/crates/avalanche-types/src/lib.rs @@ -30,6 +30,7 @@ pub mod units; pub mod utils; pub mod verify; + #[cfg(feature = "avalanchego")] #[cfg_attr(docsrs, doc(cfg(feature = "avalanchego")))] pub mod avalanchego; From b95373dd9a60f3d0d7bce2dafa9d25d699911999 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 11:55:07 -0500 Subject: [PATCH 03/13] Revert "FAILURE" This reverts commit a3b0828492e5d92296f55a77d5f496d33919887b. --- crates/avalanche-types/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/avalanche-types/src/lib.rs b/crates/avalanche-types/src/lib.rs index f078a6d..925fb89 100644 --- a/crates/avalanche-types/src/lib.rs +++ b/crates/avalanche-types/src/lib.rs @@ -30,7 +30,6 @@ pub mod units; pub mod utils; pub mod verify; - #[cfg(feature = "avalanchego")] #[cfg_attr(docsrs, doc(cfg(feature = "avalanchego")))] pub mod avalanchego; From 76df42569775baf8e25ee9105402abad98d6e801 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 12:39:28 -0500 Subject: [PATCH 04/13] Docs --- .github/workflows/ci.yml | 45 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad9a831..5b220ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,19 @@ jobs: shell: bash run: cargo fmt --all --check + docs: + runs-on: ubuntu-latest + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + with: + shared-key: 'ci' + - name: Run doc tests + run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items -p avalanche-consensus -p avalanche-types + unit: name: unit tests needs: build @@ -223,35 +236,3 @@ jobs: # - name: Run static analysis tests # shell: bash # run: cargo clippy --all --all-features --tests --benches --examples - - docs: - runs-on: ubuntu-latest - steps: - - run: 'echo hello world' - # - name: Remove unnecessary files - # run: | - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf "$AGENT_TOOLSDIRECTORY" - # - name: Install linker - # run: | - # sudo apt-get update - # sudo apt-get install -y --no-install-recommends \ - # gcc-multilib - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - # - name: Check Rust version - # run: rustc --version - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # with: - # version: '3.x' - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Set env var - # shell: bash - # run: export 'RUSTFLAGS=-D warnings' - # # Fails the CI build if there are documentation warnings. - # - name: Run doc tests - # shell: bash - # run: cargo doc --no-deps --all-features -p avalanche-consensus -p avalanche-types From 1a1a631470d8a8a524e6eb3546d01de9d110e457 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 16:26:20 -0500 Subject: [PATCH 05/13] Clippy --- .github/workflows/ci.yml | 53 ++++++++++++---------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b220ae..464e105 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,21 @@ jobs: - name: Run doc tests run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items -p avalanche-consensus -p avalanche-types + clippy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + with: + shared-key: 'ci' + - name: Run static analysis tests + shell: bash + run: cargo clippy --all --all-features --tests --benches --examples -- -D warnings + unit: name: unit tests needs: build @@ -92,21 +107,11 @@ jobs: swap-storage: true - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Check Rust version - run: rustc --version - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # with: - # version: '3.x' - # repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 with: shared-key: 'ci' - - name: Run unit tests run: cargo test --all-features -p avalanche-types -p avalanche-consensus @@ -208,31 +213,3 @@ jobs: # - name: Run e2e tests # run: scripts/tests.avalanchego-byzantine.sh - clippy: - needs: build - runs-on: ubuntu-latest - steps: - - run: 'echo hello world' - # - name: Remove unnecessary files - # run: | - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf "$AGENT_TOOLSDIRECTORY" - # - name: Install linker - # run: | - # sudo apt-get update - # sudo apt-get install -y --no-install-recommends \ - # gcc-multilib - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - # - name: Check Rust version - # run: rustc --version - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # with: - # version: '3.x' - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Run static analysis tests - # shell: bash - # run: cargo clippy --all --all-features --tests --benches --examples From 31ec2a48297920a6c47365c6ed5e0c82e8805328 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 16:40:06 -0500 Subject: [PATCH 06/13] Cache jobs separately --- .github/workflows/ci.yml | 44 ---------------------------------------- 1 file changed, 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 464e105..bf238d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,39 +12,6 @@ permissions: contents: write jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Remove unnecessary files - run: | - docker rmi `docker images -q` - sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d - sudo apt -y autoremove --purge - sudo apt -y autoclean - sudo apt clean - rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - large-packages: true - swap-storage: true - - name: Install protoc - uses: arduino/setup-protoc@v1 - with: - version: '3.x' - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - shared-key: 'ci' - - name: Build binaries - run: cargo build --all --tests --all-features - fmt: runs-on: ubuntu-latest steps: @@ -65,13 +32,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - with: - shared-key: 'ci' - name: Run doc tests run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items -p avalanche-consensus -p avalanche-types clippy: - needs: build runs-on: ubuntu-latest steps: - name: Install Rust @@ -79,15 +43,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - with: - shared-key: 'ci' - name: Run static analysis tests shell: bash run: cargo clippy --all --all-features --tests --benches --examples -- -D warnings unit: name: unit tests - needs: build runs-on: ubuntu-latest steps: - name: Remove unnecessary files @@ -110,13 +71,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - with: - shared-key: 'ci' - name: Run unit tests run: cargo test --all-features -p avalanche-types -p avalanche-consensus avalanchego-integration-tests: - needs: build runs-on: ubuntu-latest steps: - run: 'echo hello world' @@ -149,7 +107,6 @@ jobs: # run: scripts/tests.avalanchego-e2e.sh avalanchego-conformance-tests: - needs: build runs-on: ubuntu-latest steps: - run: 'echo hello world' @@ -182,7 +139,6 @@ jobs: # run: scripts/tests.avalanchego-conformance.sh avalanchego-byzantine-tests: - needs: build runs-on: ubuntu-latest steps: - run: 'echo hello world' From 0afa66b86d204f5b112b2e77c244cb29f59ee424 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 17:27:32 -0500 Subject: [PATCH 07/13] Clippy fixes --- .../scripts/protobuf_codegen.sh | 2 +- crates/avalanche-types/src/proto/mod.rs | 1 + .../subnet/rpc/database/corruptabledb/mod.rs | 2 +- .../src/subnet/rpc/database/memdb/iterator.rs | 6 ++++- .../src/subnet/rpc/database/memdb/mod.rs | 16 +++++------ .../src/subnet/rpc/database/mod.rs | 2 +- .../src/subnet/rpc/database/nodb.rs | 2 +- .../rpc/database/rpcdb/client/iterator.rs | 6 ++++- .../subnet/rpc/database/rpcdb/client/mod.rs | 10 +++---- .../subnet/rpc/database/rpcdb/server/mod.rs | 2 +- .../subnet/rpc/database/versiondb/iterator.rs | 2 +- .../src/subnet/rpc/database/versiondb/mod.rs | 4 +-- .../src/subnet/rpc/http/client.rs | 2 +- .../src/subnet/rpc/http/server.rs | 2 +- .../snow/engine/common/appsender/server.rs | 4 +-- .../src/subnet/rpc/snow/engine/common/vm.rs | 1 + .../src/subnet/rpc/vm/server.rs | 2 +- .../tests/rpc/database/batch.rs | 12 ++++----- .../tests/rpc/database/concurrency.rs | 6 ++--- .../tests/rpc/database/iterator.rs | 20 +++++++------- .../avalanche-types/tests/rpc/database/mod.rs | 27 ++++++++++--------- crates/avalanche-types/tests/rpc/shutdown.rs | 6 ++--- 22 files changed, 74 insertions(+), 63 deletions(-) diff --git a/crates/avalanche-types/scripts/protobuf_codegen.sh b/crates/avalanche-types/scripts/protobuf_codegen.sh index fe63026..2b9bf93 100755 --- a/crates/avalanche-types/scripts/protobuf_codegen.sh +++ b/crates/avalanche-types/scripts/protobuf_codegen.sh @@ -14,7 +14,7 @@ if ! [[ "$0" =~ scripts/protobuf_codegen.sh ]]; then fi # ref. https://docs.buf.build/installation -BUF_VERSION='1.26.1' +BUF_VERSION='1.29.0' if [[ $(buf --version | cut -f2 -d' ') != "${BUF_VERSION}" ]]; then echo "could not find buf ${BUF_VERSION}, is it installed + in PATH?" exit 255 diff --git a/crates/avalanche-types/src/proto/mod.rs b/crates/avalanche-types/src/proto/mod.rs index 10473ce..c52ed80 100644 --- a/crates/avalanche-types/src/proto/mod.rs +++ b/crates/avalanche-types/src/proto/mod.rs @@ -1,6 +1,7 @@ //! Generated protobuf stubs and helpers for Avalanche. //! //! ref. +#[allow(clippy::all)] pub mod pb; #[doc(hidden)] diff --git a/crates/avalanche-types/src/subnet/rpc/database/corruptabledb/mod.rs b/crates/avalanche-types/src/subnet/rpc/database/corruptabledb/mod.rs index fd140fb..9f7fb18 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/corruptabledb/mod.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/corruptabledb/mod.rs @@ -17,7 +17,7 @@ pub struct Database { } impl Database { - pub fn new(db: BoxedDatabase) -> BoxedDatabase { + pub fn new_boxed(db: BoxedDatabase) -> BoxedDatabase { Box::new(Self { db, corrupted: Arc::new(Mutex::new(utils::Errors::new())), diff --git a/crates/avalanche-types/src/subnet/rpc/database/memdb/iterator.rs b/crates/avalanche-types/src/subnet/rpc/database/memdb/iterator.rs index 28ef066..562615e 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/memdb/iterator.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/memdb/iterator.rs @@ -21,7 +21,11 @@ pub struct Iterator { } impl Iterator { - pub fn new(keys: Vec>, values: Vec>, closed: Arc) -> BoxedIterator { + pub fn new_boxed( + keys: Vec>, + values: Vec>, + closed: Arc, + ) -> BoxedIterator { Box::new(Self { keys, values, diff --git a/crates/avalanche-types/src/subnet/rpc/database/memdb/mod.rs b/crates/avalanche-types/src/subnet/rpc/database/memdb/mod.rs index f1e55f3..7f331c4 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/memdb/mod.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/memdb/mod.rs @@ -34,7 +34,7 @@ pub struct Database { } impl Database { - pub fn new() -> BoxedDatabase { + pub fn new_boxed() -> BoxedDatabase { Box::new(Self { state: Arc::new(RwLock::new(HashMap::new())), closed: Arc::new(AtomicBool::new(false)), @@ -157,7 +157,7 @@ impl super::iterator::Iteratee for Database { } } - Ok(iterator::Iterator::new( + Ok(iterator::Iterator::new_boxed( keys, values, Arc::clone(&self.closed), @@ -180,39 +180,39 @@ impl crate::subnet::rpc::database::Database for Database {} #[tokio::test] async fn test_memdb() { - let mut db = Database::new(); + let mut db = Database::new_boxed(); let _ = db.put("foo".as_bytes(), "bar".as_bytes()).await; let resp = db.get("notfound".as_bytes()).await; assert!(resp.is_err()); assert_eq!(resp.err().unwrap().kind(), io::ErrorKind::NotFound); - let mut db = Database::new(); + let mut db = Database::new_boxed(); let _ = db.close().await; let resp = db.put("foo".as_bytes(), "bar".as_bytes()).await; assert!(resp.is_err()); assert_eq!(resp.err().unwrap().to_string(), "database closed"); - let db = Database::new(); + let db = Database::new_boxed(); let _ = db.close().await; let resp = db.get("foo".as_bytes()).await; print!("found {:?}", resp); assert!(resp.is_err()); assert_eq!(resp.err().unwrap().to_string(), "database closed"); - let mut db = Database::new(); + let mut db = Database::new_boxed(); let _ = db.put("foo".as_bytes(), "bar".as_bytes()).await; let resp = db.has("foo".as_bytes()).await; assert!(resp.is_ok()); assert!(resp.unwrap()); - let mut db = Database::new(); + let mut db = Database::new_boxed(); let _ = db.put("foo".as_bytes(), "bar".as_bytes()).await; let _ = db.delete("foo".as_bytes()).await; let resp = db.has("foo".as_bytes()).await; assert!(resp.is_ok()); assert!(!resp.unwrap()); - let db = Database::new(); + let db = Database::new_boxed(); let resp = db.health_check().await; assert!(resp.is_ok()); let _ = db.close().await; diff --git a/crates/avalanche-types/src/subnet/rpc/database/mod.rs b/crates/avalanche-types/src/subnet/rpc/database/mod.rs index 143690e..b529f70 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/mod.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/mod.rs @@ -81,7 +81,7 @@ pub trait VersionedDatabase { #[tokio::test] async fn clone_box_test() { // create box and mutate underlying hashmap - let mut db = memdb::Database::new(); + let mut db = memdb::Database::new_boxed(); let resp = db.put("foo".as_bytes(), "bar".as_bytes()).await; assert!(resp.is_ok()); diff --git a/crates/avalanche-types/src/subnet/rpc/database/nodb.rs b/crates/avalanche-types/src/subnet/rpc/database/nodb.rs index f61cb89..3d65aff 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/nodb.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/nodb.rs @@ -10,7 +10,7 @@ pub struct Iterator { /// /// ref. impl Iterator { - pub fn new(err: Option) -> BoxedIterator { + pub fn new_boxed(err: Option) -> BoxedIterator { Box::new(Iterator { err }) } } diff --git a/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/iterator.rs b/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/iterator.rs index 7cd9c1d..24f3b1a 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/iterator.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/iterator.rs @@ -36,7 +36,11 @@ pub struct Iterator { } impl Iterator { - pub fn new(db: DatabaseClient, id: u64, closed: Arc) -> BoxedIterator { + pub fn new_boxed( + db: DatabaseClient, + id: u64, + closed: Arc, + ) -> BoxedIterator { Box::new(Self { id, data: vec![], diff --git a/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/mod.rs b/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/mod.rs index 6ac689e..89958d8 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/mod.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/rpcdb/client/mod.rs @@ -41,7 +41,7 @@ pub struct DatabaseClient { } impl DatabaseClient { - pub fn new(client_conn: Channel) -> BoxedDatabase { + pub fn new_boxed(client_conn: Channel) -> BoxedDatabase { Box::new(Self { inner: RpcDbDatabaseClient::new(client_conn) .max_decoding_message_size(usize::MAX) @@ -186,14 +186,14 @@ impl database::iterator::Iteratee for DatabaseClient { }) .await { - Ok(resp) => Ok(iterator::Iterator::new( + Ok(resp) => Ok(iterator::Iterator::new_boxed( self.inner.clone(), resp.into_inner().id, Arc::clone(&self.closed), )), - Err(s) => Ok(crate::subnet::rpc::database::nodb::Iterator::new(Some( - errors::from_status(s), - ))), + Err(s) => Ok(crate::subnet::rpc::database::nodb::Iterator::new_boxed( + Some(errors::from_status(s)), + )), } } } diff --git a/crates/avalanche-types/src/subnet/rpc/database/rpcdb/server/mod.rs b/crates/avalanche-types/src/subnet/rpc/database/rpcdb/server/mod.rs index 4222c21..65cc5c8 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/rpcdb/server/mod.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/rpcdb/server/mod.rs @@ -39,7 +39,7 @@ pub struct Server { } impl Server { - pub fn new(db: BoxedDatabase) -> impl pb::rpcdb::database_server::Database { + pub fn new_boxed(db: BoxedDatabase) -> impl pb::rpcdb::database_server::Database { Self { inner: Arc::new(RwLock::new(db)), iterators: Arc::new(RwLock::new(HashMap::new())), diff --git a/crates/avalanche-types/src/subnet/rpc/database/versiondb/iterator.rs b/crates/avalanche-types/src/subnet/rpc/database/versiondb/iterator.rs index 285c761..7b2e9f3 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/versiondb/iterator.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/versiondb/iterator.rs @@ -34,7 +34,7 @@ pub struct ValueDelete { } impl Iterator { - pub fn new( + pub fn new_boxed( keys: Vec>, values: Vec, closed: Arc, diff --git a/crates/avalanche-types/src/subnet/rpc/database/versiondb/mod.rs b/crates/avalanche-types/src/subnet/rpc/database/versiondb/mod.rs index 4e8932e..2c442b4 100644 --- a/crates/avalanche-types/src/subnet/rpc/database/versiondb/mod.rs +++ b/crates/avalanche-types/src/subnet/rpc/database/versiondb/mod.rs @@ -184,7 +184,7 @@ impl database::iterator::Iteratee for Database { } } - Ok(iterator::Iterator::new( + Ok(iterator::Iterator::new_boxed( keys, values, Arc::clone(&self.closed), @@ -252,7 +252,7 @@ async fn iterate_test() { iterator::Iteratee, memdb, Commitable, KeyValueReaderWriterDeleter, }; - let base_db = memdb::Database::new(); + let base_db = memdb::Database::new_boxed(); let batch = base_db.new_batch().await.unwrap(); let mut db = Database::new(base_db, batch); diff --git a/crates/avalanche-types/src/subnet/rpc/http/client.rs b/crates/avalanche-types/src/subnet/rpc/http/client.rs index 06172f7..ee48c1e 100644 --- a/crates/avalanche-types/src/subnet/rpc/http/client.rs +++ b/crates/avalanche-types/src/subnet/rpc/http/client.rs @@ -10,7 +10,7 @@ pub struct Client { } impl Client { - pub fn new(client_conn: Channel) -> Box { + pub fn new_handler(client_conn: Channel) -> Box { Box::new(Client { inner: pb::http::http_client::HttpClient::new(client_conn) .max_decoding_message_size(usize::MAX) diff --git a/crates/avalanche-types/src/subnet/rpc/http/server.rs b/crates/avalanche-types/src/subnet/rpc/http/server.rs index 6d14d6f..7cbc513 100644 --- a/crates/avalanche-types/src/subnet/rpc/http/server.rs +++ b/crates/avalanche-types/src/subnet/rpc/http/server.rs @@ -20,7 +20,7 @@ impl Server where T: Handle + Send + Sync + 'static, { - pub fn new(handler: T) -> impl pb::http::http_server::Http { + pub fn new(handler: T) -> Self { Server { handle: Arc::new(handler), } diff --git a/crates/avalanche-types/src/subnet/rpc/snow/engine/common/appsender/server.rs b/crates/avalanche-types/src/subnet/rpc/snow/engine/common/appsender/server.rs index c2296fc..57442b8 100644 --- a/crates/avalanche-types/src/subnet/rpc/snow/engine/common/appsender/server.rs +++ b/crates/avalanche-types/src/subnet/rpc/snow/engine/common/appsender/server.rs @@ -24,9 +24,7 @@ pub struct Server { /// A gRPC server which wraps a subnet::rpc::database::Database impl allowing client control over over RPC. impl Server { - pub fn new( - appsender: Box, - ) -> impl pb::appsender::app_sender_server::AppSender { + pub fn new(appsender: Box) -> Self { Server { inner: Arc::new(RwLock::new(appsender)), } diff --git a/crates/avalanche-types/src/subnet/rpc/snow/engine/common/vm.rs b/crates/avalanche-types/src/subnet/rpc/snow/engine/common/vm.rs index cb061dd..5aaa395 100644 --- a/crates/avalanche-types/src/subnet/rpc/snow/engine/common/vm.rs +++ b/crates/avalanche-types/src/subnet/rpc/snow/engine/common/vm.rs @@ -30,6 +30,7 @@ pub trait CommonVm: AppHandler + Connector + Checkable { type StaticHandler: Handle; type ValidatorState: validators::State; + #[allow(clippy::too_many_arguments)] async fn initialize( &mut self, ctx: Option>, diff --git a/crates/avalanche-types/src/subnet/rpc/vm/server.rs b/crates/avalanche-types/src/subnet/rpc/vm/server.rs index ec7e9ee..efaaf47 100644 --- a/crates/avalanche-types/src/subnet/rpc/vm/server.rs +++ b/crates/avalanche-types/src/subnet/rpc/vm/server.rs @@ -157,7 +157,7 @@ where })?; let vdb = versioned_database::VersionedDatabase::new( - corruptabledb::Database::new(DatabaseClient::new(client_conn)), + corruptabledb::Database::new_boxed(DatabaseClient::new_boxed(client_conn)), version, ); versioned_dbs.push(vdb); diff --git a/crates/avalanche-types/tests/rpc/database/batch.rs b/crates/avalanche-types/tests/rpc/database/batch.rs index 04a2e01..a611df7 100644 --- a/crates/avalanche-types/tests/rpc/database/batch.rs +++ b/crates/avalanche-types/tests/rpc/database/batch.rs @@ -16,7 +16,7 @@ use tonic::transport::Channel; // Ensure batched writes work as expected. #[tokio::test] async fn batch_put_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -30,7 +30,7 @@ async fn batch_put_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key = "hello".as_bytes(); let value = "world".as_bytes(); @@ -66,7 +66,7 @@ async fn batch_put_test() { #[tokio::test] async fn batch_delete_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -80,7 +80,7 @@ async fn batch_delete_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key = "hello".as_bytes(); let value = "world".as_bytes(); @@ -111,7 +111,7 @@ async fn batch_delete_test() { // when it is reset. #[tokio::test] async fn batch_reset_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -125,7 +125,7 @@ async fn batch_reset_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key = "hello".as_bytes(); let value = "world".as_bytes(); diff --git a/crates/avalanche-types/tests/rpc/database/concurrency.rs b/crates/avalanche-types/tests/rpc/database/concurrency.rs index 525fab3..e0f0993 100644 --- a/crates/avalanche-types/tests/rpc/database/concurrency.rs +++ b/crates/avalanche-types/tests/rpc/database/concurrency.rs @@ -11,8 +11,8 @@ use tonic::transport::Channel; #[tokio::test(flavor = "multi_thread")] async fn rpcdb_mutation_test() { - let db = MemDb::new(); - let server = RpcDb::new(db); + let db = MemDb::new_boxed(); + let server = RpcDb::new_boxed(db); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -26,7 +26,7 @@ async fn rpcdb_mutation_test() { .await .unwrap(); - let client = DatabaseClient::new(client_conn); + let client = DatabaseClient::new_boxed(client_conn); let mut futures = FuturesUnordered::new(); // 1000 requests for i in 0..1000_i32 { diff --git a/crates/avalanche-types/tests/rpc/database/iterator.rs b/crates/avalanche-types/tests/rpc/database/iterator.rs index 3ad576b..ce918a1 100644 --- a/crates/avalanche-types/tests/rpc/database/iterator.rs +++ b/crates/avalanche-types/tests/rpc/database/iterator.rs @@ -14,7 +14,7 @@ use tonic::transport::Channel; // contents lexicographically. #[tokio::test] async fn iterator_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -28,7 +28,7 @@ async fn iterator_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key1 = "hello1".as_bytes(); let value1 = "world1".as_bytes(); @@ -63,7 +63,7 @@ async fn iterator_test() { // start mid way through the database. #[tokio::test] async fn iterator_start_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -77,7 +77,7 @@ async fn iterator_start_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key1 = "hello1".as_bytes(); let value1 = "world1".as_bytes(); @@ -104,7 +104,7 @@ async fn iterator_start_test() { // keys missing the provided prefix. #[tokio::test] async fn iterator_prefix_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -118,7 +118,7 @@ async fn iterator_prefix_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key1 = "hello1".as_bytes(); let value1 = "world1".as_bytes(); @@ -152,7 +152,7 @@ async fn iterator_prefix_test() { // next() can still serve its current value after the underlying DB was closed. #[tokio::test] async fn iterator_error_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -166,7 +166,7 @@ async fn iterator_error_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key1 = "hello1".as_bytes(); let value1 = "world1".as_bytes(); @@ -200,7 +200,7 @@ async fn iterator_error_test() { // released still reports the error correctly. #[tokio::test] async fn iterator_error_after_release_test() { - let server = RpcDb::new(MemDb::new()); + let server = RpcDb::new_boxed(MemDb::new_boxed()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -214,7 +214,7 @@ async fn iterator_error_after_release_test() { .await .unwrap(); - let mut db = CorruptableDb::new(DatabaseClient::new(client_conn)); + let mut db = CorruptableDb::new_boxed(DatabaseClient::new_boxed(client_conn)); let key1 = "hello1".as_bytes(); let value1 = "world1".as_bytes(); diff --git a/crates/avalanche-types/tests/rpc/database/mod.rs b/crates/avalanche-types/tests/rpc/database/mod.rs index 6f9979b..982338c 100644 --- a/crates/avalanche-types/tests/rpc/database/mod.rs +++ b/crates/avalanche-types/tests/rpc/database/mod.rs @@ -25,8 +25,8 @@ async fn rpcdb_mutation_test() { let bar_value = "bar".as_bytes().to_vec(); let baz_value = "baz".as_bytes().to_vec(); - let db = MemDb::new(); - let server = RpcDb::new(db); + let db = MemDb::new_boxed(); + let server = RpcDb::new_boxed(db); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -40,7 +40,7 @@ async fn rpcdb_mutation_test() { .await .unwrap(); - let mut client = DatabaseClient::new(client_conn); + let mut client = DatabaseClient::new_boxed(client_conn); log::info!("put foo:bar"); let resp = client.put("foo".as_bytes(), "bar".as_bytes()).await; @@ -97,8 +97,8 @@ async fn corruptibledb_mutation_test() { let bar_value = "bar".as_bytes().to_vec(); - let memdb = MemDb::new(); - let mut corruptible = CorruptableDb::new(memdb); + let memdb = MemDb::new_boxed(); + let mut corruptible = CorruptableDb::new_boxed(memdb); log::info!("put foo:bar"); let resp = corruptible.put("foo".as_bytes(), "bar".as_bytes()).await; @@ -148,8 +148,8 @@ async fn test_rpcdb_corruptible() { let bar_value = "bar".as_bytes().to_vec(); let baz_value = "baz".as_bytes().to_vec(); - let memdb = MemDb::new(); - let rpc_server = RpcDb::new(memdb); + let memdb = MemDb::new_boxed(); + let rpc_server = RpcDb::new_boxed(memdb); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -163,8 +163,8 @@ async fn test_rpcdb_corruptible() { .await .unwrap(); - let db = DatabaseClient::new(client_conn); - let mut client = CorruptableDb::new(db); + let db = DatabaseClient::new_boxed(client_conn); + let mut client = CorruptableDb::new_boxed(db); log::info!("put foo:bar"); let resp = client.put("foo".as_bytes(), "bar".as_bytes()).await; @@ -223,8 +223,8 @@ async fn test_db_manager() { let bar_value = "bar".as_bytes().to_vec(); let baz_value = "baz".as_bytes().to_vec(); - let memdb = MemDb::new(); - let rpc_server = RpcDb::new(memdb); + let memdb = MemDb::new_boxed(); + let rpc_server = RpcDb::new_boxed(memdb); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); @@ -238,7 +238,10 @@ async fn test_db_manager() { .await .unwrap(); - let vdb = VersionedDatabase::new(DatabaseClient::new(client_conn), Version::new(0, 0, 1)); + let vdb = VersionedDatabase::new( + DatabaseClient::new_boxed(client_conn), + Version::new(0, 0, 1), + ); let databases: Vec = vec![vdb]; diff --git a/crates/avalanche-types/tests/rpc/shutdown.rs b/crates/avalanche-types/tests/rpc/shutdown.rs index a015ce8..48ab913 100644 --- a/crates/avalanche-types/tests/rpc/shutdown.rs +++ b/crates/avalanche-types/tests/rpc/shutdown.rs @@ -19,8 +19,8 @@ async fn test_shutdown() { let (tx, _rx): (Sender<()>, Receiver<()>) = tokio::sync::broadcast::channel(1); // setup rpcdb service - let memdb = MemDb::new(); - let server = RpcDb::new(memdb); + let memdb = MemDb::new_boxed(); + let server = RpcDb::new_boxed(memdb); let svc = DatabaseServer::new(server); let addr = utils::new_socket_addr(); @@ -35,7 +35,7 @@ async fn test_shutdown() { .connect() .await .unwrap(); - let mut client = DatabaseClient::new(client_conn); + let mut client = DatabaseClient::new_boxed(client_conn); // client request ok let resp = client.put("foo".as_bytes(), "bar".as_bytes()).await; From c3274dfeb5219ddd658cff1e6f20e6d57abede4c Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 07:34:25 -0500 Subject: [PATCH 08/13] Add protoc back to ci jobs --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf238d7..669b161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,11 @@ jobs: steps: - name: Install Rust uses: dtolnay/rust-toolchain@stable + - name: Install protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 @@ -68,6 +73,11 @@ jobs: swap-storage: true - name: Install Rust uses: dtolnay/rust-toolchain@stable + - name: Install protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 From 099afcc67acfd7f088067093ebe93714f74c734f Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 07:47:06 -0500 Subject: [PATCH 09/13] Fix docs --- crates/avalanche-types/src/jsonrpc/client/mod.rs | 10 +--------- crates/avalanche-types/src/subnet/rpc/snowman/block.rs | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/crates/avalanche-types/src/jsonrpc/client/mod.rs b/crates/avalanche-types/src/jsonrpc/client/mod.rs index 7e2acc8..a91b4cf 100644 --- a/crates/avalanche-types/src/jsonrpc/client/mod.rs +++ b/crates/avalanche-types/src/jsonrpc/client/mod.rs @@ -1,13 +1,5 @@ //! JSON-RPC client methods and URL utilities. -//! -//! Includes the following modules: -//! - [admin](crate::jsonrpc::client::admin) -//! - [evm](crate::jsonrpc::client::evm) -//! - [health](crate::jsonrpc::client::health) -//! - [info](crate::jsonrpc::client::info) -//! - [p](crate::jsonrpc::client::p) -//! - [url](crate::jsonrpc::client::url) -//! - [x](crate::jsonrpc::client::x) + pub mod admin; pub mod evm; pub mod health; diff --git a/crates/avalanche-types/src/subnet/rpc/snowman/block.rs b/crates/avalanche-types/src/subnet/rpc/snowman/block.rs index 7d3693b..1eb3f9b 100644 --- a/crates/avalanche-types/src/subnet/rpc/snowman/block.rs +++ b/crates/avalanche-types/src/subnet/rpc/snowman/block.rs @@ -31,8 +31,8 @@ pub trait ChainVm: CommonVm + BatchedChainVm + Getter + Parser { /// TODO: Remove after v1.11.x activates. async fn verify_height_index(&self) -> Result<()>; - /// Returns the ID of the block that was accepted with [height]. - /// Returns ErrNotFound if the [height] index is unknown. + /// Returns the ID of the block that was accepted with `height`. + /// Returns ErrNotFound if the `height` index is unknown. async fn get_block_id_at_height(&self, height: u64) -> Result; /// Returns whether state sync is enabled. From 996d6283f67cf088c14f279a05289be81bdbb5c7 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 08:13:23 -0500 Subject: [PATCH 10/13] Last clippy fix --- core/network/src/cert_manager/x509.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/network/src/cert_manager/x509.rs b/core/network/src/cert_manager/x509.rs index 0898b43..17f45cb 100644 --- a/core/network/src/cert_manager/x509.rs +++ b/core/network/src/cert_manager/x509.rs @@ -355,7 +355,7 @@ fn test_csr() { } } - fs::remove_file(&ca_key_path).unwrap(); + fs::remove_file(ca_key_path).unwrap(); fs::remove_file(&ca_cert_path).unwrap(); fs::remove_file(&csr_key_path).unwrap(); From db4df19b3645d4b50e8851f4a158e54100af8e8d Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 08:17:35 -0500 Subject: [PATCH 11/13] Speed up Free Space --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 669b161..25c6b2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,10 +67,10 @@ jobs: df -h - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - large-packages: true - swap-storage: true + # with: + # tool-cache: true + # large-packages: true + # swap-storage: true - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Install protoc From 79f686d232e2204cb0733041b1a6e67b62f2024d Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 08:27:46 -0500 Subject: [PATCH 12/13] Optimize CI --- .github/workflows/ci.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25c6b2c..79b745c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,12 @@ on: tags: - '*' pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true permissions: contents: write @@ -56,21 +62,10 @@ jobs: name: unit tests runs-on: ubuntu-latest steps: - - name: Remove unnecessary files - run: | - docker rmi `docker images -q` - sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d - sudo apt -y autoremove --purge - sudo apt -y autoclean - sudo apt clean - rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main - # with: - # tool-cache: true - # large-packages: true - # swap-storage: true + with: + large-packages: false - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Install protoc From 20775753cd67b1b4c6acb30b61f357226d91985a Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 08:38:19 -0500 Subject: [PATCH 13/13] Turn on the rest of the jobs --- .github/workflows/ci.yml | 144 ++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 84 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79b745c..c31483e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,95 +82,71 @@ jobs: avalanchego-integration-tests: runs-on: ubuntu-latest steps: - - run: 'echo hello world' - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Remove unnecessary files - # run: | - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf "$AGENT_TOOLSDIRECTORY" - # - name: Install linker - # run: | - # sudo apt-get update - # sudo apt-get install -y --no-install-recommends \ - # gcc-multilib - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # with: - # version: '3.x' - # repo-token: ${{ secrets.GITHUB_TOKEN }} - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - # - name: Install Go - # uses: actions/setup-go@v4 - # with: - # go-version: '1.19' - - # - name: Run e2e tests - # run: scripts/tests.avalanchego-e2e.sh + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + large-packages: false + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: '1.19' + - name: Run e2e tests + run: scripts/tests.avalanchego-e2e.sh avalanchego-conformance-tests: runs-on: ubuntu-latest steps: - - run: 'echo hello world' - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Remove unnecessary files - # run: | - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf "$AGENT_TOOLSDIRECTORY" - # - name: Install linker - # run: | - # sudo apt-get update - # sudo apt-get install -y --no-install-recommends \ - # gcc-multilib - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # with: - # version: '3.x' - # repo-token: ${{ secrets.GITHUB_TOKEN }} - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - # - name: Install Go - # uses: actions/setup-go@v4 - # with: - # go-version: '1.19' - - # - name: Run e2e tests - # run: scripts/tests.avalanchego-conformance.sh + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + large-packages: false + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: '1.19' + - name: Run e2e tests + run: scripts/tests.avalanchego-conformance.sh avalanchego-byzantine-tests: runs-on: ubuntu-latest steps: - - run: 'echo hello world' - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Remove unnecessary files - # run: | - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf "$AGENT_TOOLSDIRECTORY" - # - name: Install linker - # run: | - # sudo apt-get update - # sudo apt-get install -y --no-install-recommends \ - # gcc-multilib - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # with: - # version: '3.x' - # repo-token: ${{ secrets.GITHUB_TOKEN }} - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - # - name: Install Go - # uses: actions/setup-go@v4 - # with: - # go-version: '1.19' - - # - name: Run e2e tests - # run: scripts/tests.avalanchego-byzantine.sh + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + large-packages: false + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: '1.19' + - name: Run e2e tests + run: scripts/tests.avalanchego-byzantine.sh