Skip to content

Commit

Permalink
Reapply rust version
Browse files Browse the repository at this point in the history
  • Loading branch information
otaliptus committed Jan 4, 2024
1 parent cb1f3dc commit c788b48
Show file tree
Hide file tree
Showing 23 changed files with 314 additions and 49 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/delete_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See <https://github.com/BuildJet/cache-delete>. Useful for debugging/solving
# caching issues. To identify the name of the cache key to delete, look for the line
# `Cache restored from key: <cache key>` in the logs of the caching step.

name: Manually delete a BuildJet cache entry

on:
workflow_dispatch:
inputs:
cache_key:
description: "BuildJet cache key to delete"
required: true
type: string

jobs:
manually-delete-buildjet-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: buildjet/cache-delete@v1
with:
cache_key: ${{ inputs.cache_key }}
16 changes: 16 additions & 0 deletions .github/workflows/dependency_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
with:
fail-on-severity: critical
23 changes: 23 additions & 0 deletions .github/workflows/prerelease_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Pre-release checks"
on:
schedule:
# At 10:00am UTC every Monday.
# See:
# - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# - https://crontab.guru/
- cron: "0 10 * * 1"
# Allow manual triggering: <https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch>.
workflow_dispatch:
# Anytime a PR modifies the list of packages to publish.
pull_request:
paths:
- "packages_to_publish.yml"

jobs:
check-missing-dependency-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: ./scripts/check_missing_dependency_versions.sh
shell: bash
working-directory: .
177 changes: 177 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Rust

# On Rust, GitHub Actions, and caching
# ===========
# Here's a list of things to keep in mind if you find yourself maintaining this
# CI:
#
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
#
# - Always install and select the desired Rust toolchain *before* running
# `Swatinem/rust-cache`. This is because the active Rust toolchain is used as
# a cache key.
# - You can use `rustup show` to install and select the right Rust toolchain if
# you have a `rust-toolchain.toml` file:
# https://github.com/rust-lang/rustup/issues/1397.
# - When caching Rust compilation artifacts, keep in mind that different `cargo`
# commands will use different profiles
# (https://doc.rust-lang.org/cargo/reference/profiles.html). Learn what you
# can reuse between one job and another and don't assume two commands will
# just share caches without conflicts.
# - Be extremely aware of cache thrashing a.k.a. churning. GitHub Actions' cache
# allows for 10GiB of data which is easily exceeded if not careful.
# Sometimes it's better not to cache than cache excessively.
# Disabling cache writes for non-default branches altogether if cache churning
# is unacceptably high is supposed to help with this.
# - Learn cache invalidation rules of `Swatinem/rust-cache` before making
# changes, e.g. what happens when `rustc --version` changes or `Cargo.lock`
# changes (or is missing).
# - The jobs dependency tree is the way it is to accommodate for sharing caches,
# not necessarily because it makes logical sense to run one job after the
# other. This is due to the fact that we can't share caches between jobs that
# run in parallel.
# - `sccache` is a good alternative to `Swatinem/rust-cache`, but it behaves
# poorly with GHA and often incurs into cache requests rate limits. We should
# probably explore `sccache` with a different backend.
# - If a job makes good use of extra cores, consider give it a bigger machine.
# GHA larger runners increase in cost linearly with the number of cores
# (https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions),
# so you're not wasting money unless several cores are sitting idle for long.

on:
# Relevant docs:
# - https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue#how-merge-queues-work
# - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group
merge_group:
types: ["checks_requested"]
push:
branches: ["nightly", "stable", "talip/ci-cd"]
pull_request:
branches: ["nightly", "stable"]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
EXCLUDE_BTC: 1
RUST_VERSION_STABLE: 1.75.0
RUST_VERSION_BETA: 1.76.0
# RUST_VERSION_NIGHTLY: nightly-2023-12-31


# Automatically cancels a job if a new commit if pushed to the same PR, branch, or tag.
# Source: <https://stackoverflow.com/a/72408109/5148606>
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Except in `nightly` and `stable` branches! Any cancelled job will cause the
# CI run to fail, and we want to keep a clean history for major branches.
cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/stable') && (github.ref != 'refs/heads/talip/ci-cd') }}

jobs:
check:
name: check
runs-on: [self-hosted]
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: rui314/setup-mold@v1
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: beta
# toolchain: "1.76.0"
# target: "x86_64-unknown-linux-gnu"
override: true
components: rustfmt, clippy
- name: Rustup update
run: rustup update && rustup show && rustup install nightly && rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu # Nightly is needed for our configuration of cargo fmt
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain
run: cargo risczero install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: Swatinem/rust-cache@v2
with:
shared-key: cargo-check-cache
save-if: ${{ github.ref == 'refs/heads/nightly' }}
workspaces: |
.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run lint
run: |
if ! SKIP_GUEST_BUILD=1 make lint ; then
echo "Linting or formatting errors detected, please run 'make lint-fix' to fix it";
exit 1
fi
check_no_std:
runs-on: [self-hosted]
steps:
- uses: actions/checkout@v3
- name: Install Rust Bare Metal
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: thumbv6m-none-eabi
override: true
- name: Install Rust WASM
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: cargo install cargo-hack
uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/nightly' }}
- name: Run check
run: make check-no-std

nextest:
name: nextest
runs-on: self-hosted
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: rui314/setup-mold@v1
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: beta
# toolchain: "1.76.0"
# target: "x86_64-unknown-linux-gnu"
override: true
components: rustfmt, clippy
- name: Rustup update
run: rustup update && rustup show && rustup install nightly && rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu # Nightly is needed for our configuration of cargo fmt
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain
run: cargo risczero install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# `cargo-nextest` is much faster than standard `cargo test`.
- uses: taiki-e/install-action@nextest
- name: Install Rust
run: rustup show
- uses: Swatinem/rust-cache@v2
with:
# cache-provider: "buildjet"
save-if: ${{ github.ref == 'refs/heads/nightly' }}
- run: SKIP_GUEST_BUILD=1 cargo nextest run --workspace --all-features
9 changes: 7 additions & 2 deletions adapters/bitcoin/src/helpers/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub fn sign_blob_with_private_key(
))
}

#[allow(clippy::ptr_arg)]
fn get_size(
inputs: &Vec<TxIn>,
outputs: &Vec<TxOut>,
Expand All @@ -74,6 +75,7 @@ fn get_size(
);
}

#[allow(clippy::unnecessary_unwrap)]
if tx.input.len() == 1 && script.is_some() && control_block.is_some() {
tx.input[0].witness.push(script.unwrap());
tx.input[0].witness.push(control_block.unwrap().serialize());
Expand All @@ -82,7 +84,7 @@ fn get_size(
tx.vsize()
}

fn choose_utxos(utxos: &Vec<UTXO>, amount: u64) -> Result<(Vec<UTXO>, u64), anyhow::Error> {
fn choose_utxos(utxos: &[UTXO], amount: u64) -> Result<(Vec<UTXO>, u64), anyhow::Error> {
let mut bigger_utxos: Vec<&UTXO> = utxos.iter().filter(|utxo| utxo.amount >= amount).collect();
let mut sum: u64 = 0;

Expand Down Expand Up @@ -221,6 +223,7 @@ fn build_commit_transaction(
Ok(tx)
}

#[allow(clippy::too_many_arguments)]
fn build_reveal_transaction(
input_utxo: TxOut,
input_txid: Txid,
Expand Down Expand Up @@ -269,6 +272,7 @@ fn build_reveal_transaction(
// TODO: parametrize hardness
// so tests are easier
// Creates the inscription transactions (commit and reveal)
#[allow(clippy::too_many_arguments)]
pub fn create_inscription_transactions(
rollup_name: &str,
body: Vec<u8>,
Expand Down Expand Up @@ -510,6 +514,7 @@ mod tests {
std::fs::remove_file("reveal_test_tx.tx").unwrap();
}

#[allow(clippy::type_complexity)]
fn get_mock_data() -> (&'static str, Vec<u8>, Vec<u8>, Vec<u8>, Address, Vec<UTXO>) {
let rollup_name = "test_rollup";
let body = vec![100; 1000];
Expand Down Expand Up @@ -773,7 +778,7 @@ mod tests {
fn build_reveal_transaction() {
let (_, _, _, _, address, utxos) = get_mock_data();

let utxo = utxos.get(0).unwrap();
let utxo = utxos.first().unwrap();
let script = ScriptBuf::from_hex("62a58f2674fd840b6144bea2e63ebd35c16d7fd40252a2f28b2a01a648df356343e47976d7906a0e688bf5e134b6fd21bd365c016b57b1ace85cf30bf1206e27").unwrap();
let control_block = ControlBlock::decode(&[
193, 165, 246, 250, 6, 222, 28, 9, 130, 28, 217, 67, 171, 11, 229, 62, 48, 206, 219,
Expand Down
20 changes: 10 additions & 10 deletions adapters/bitcoin/src/helpers/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand Down Expand Up @@ -219,7 +219,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("not-sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand All @@ -246,7 +246,7 @@ mod tests {
.push_opcode(OP_FALSE)
.push_opcode(OP_IF)
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand Down Expand Up @@ -296,7 +296,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
.push_int(0)
.push_slice(PushBytesBuf::try_from(BODY_TAG.to_vec()).unwrap())
Expand All @@ -320,7 +320,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand All @@ -343,7 +343,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(BODY_TAG.to_vec()).unwrap())
Expand Down Expand Up @@ -396,7 +396,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_opcode(OP_TRUE)
.push_opcode(OP_IF)
.push_x_only_key(&XOnlyPublicKey::from_slice(&[1; 32]).unwrap())
Expand Down Expand Up @@ -426,7 +426,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand All @@ -441,7 +441,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([1u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([1u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![1u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand Down Expand Up @@ -471,7 +471,7 @@ mod tests {
.push_slice(PushBytesBuf::try_from(ROLLUP_NAME_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from("sov-btc".as_bytes().to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(SIGNATURE_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from([0u8; 64]).unwrap())
.push_slice(PushBytesBuf::from([0u8; 64]))
.push_slice(PushBytesBuf::try_from(PUBLICKEY_TAG.to_vec()).unwrap())
.push_slice(PushBytesBuf::try_from(vec![0u8; 64]).unwrap())
.push_slice(PushBytesBuf::try_from(RANDOM_TAG.to_vec()).unwrap())
Expand Down
Loading

0 comments on commit c788b48

Please sign in to comment.