Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
self-hosted-runner:
# Labels of self-hosted runner in array of strings.
labels:
- buildjet-2vcpu-ubuntu-2204
- buildjet-4vcpu-ubuntu-2204
- buildjet-8vcpu-ubuntu-2204
- buildjet-16vcpu-ubuntu-2204
# Configuration variables in array of strings defined in your repository or
# organization. `null` means disabling configuration variables check.
# Empty array means no configuration variable is allowed.
config-variables: null
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# pnpm is handled by the "npm" package ecosystem
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
15 changes: 15 additions & 0 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint GitHub Actions workflows
on: [push, pull_request]

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash
- name: Check workflow files
run: ${{ steps.get_actionlint.outputs.executable }} -color
shell: bash
62 changes: 62 additions & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
on:
push:
branches:
- main
pull_request:
branches:
- "*"
types:
- opened
- synchronize
- reopened
- ready_for_review

name: js-tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
js:
name: js tests
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo
**/target
**/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/Cargo.lock', '**/pnpm-lock.yaml') }}

- name: Run hasher.rs tests
working-directory: hasher.rs
run: |
pnpm install
pnpm build
pnpm test
53 changes: 53 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
push:
branches:
- main
paths:
- ".cargo/**"
- "**/*.rs"
- "**/Cargo.*"
- ".github/workflows/rust.yml"
pull_request:
branches:
- "*"
paths:
- "**/*.rs"
- "**/Cargo.*"
- ".github/workflows/rust.yml"

types:
- opened
- synchronize
- reopened
- ready_for_review

name: rust

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo
**/target
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}

- name: Check formatting, lint & run tests
run: |
./scripts/lint.sh
6 changes: 3 additions & 3 deletions bounded-vec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ mod test {
}

for element in vec.iter_mut() {
*element = *element * 2;
*element *= 2;
}

for (i, element) in vec.iter().enumerate() {
Expand Down Expand Up @@ -1492,13 +1492,13 @@ mod test {

#[test]
fn test_cyclic_bounded_vec_first() {
let mut vec = CyclicBoundedVec::with_capacity(500);
let mut vec = CyclicBoundedVec::<u32>::with_capacity(500);

assert!(vec.first().is_none());

for i in 0..1000 {
vec.push(i);
assert_eq!(vec.first(), Some(&((i as u64).saturating_sub(499))));
assert_eq!(vec.first(), Some(&((i).saturating_sub(499))));
}
}

Expand Down
4 changes: 2 additions & 2 deletions bounded-vec/src/offset/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ mod test {
assert_eq!(offset, 0);
let vec: BoundedVec<i64> = read_bounded_vec_at(&buf, &mut offset, &metadata);
for (i, element) in vec.iter().enumerate() {
assert_eq!(i as i64, -(*element as i64));
assert_eq!(i as i64, -*element);
}
assert_eq!(offset, 256);

Expand All @@ -223,7 +223,7 @@ mod test {
assert_eq!(offset, 256);
let vec: BoundedVec<u64> = read_bounded_vec_at(&buf, &mut offset, &metadata);
for (i, element) in vec.iter().enumerate() {
assert_eq!(i as u64, *element as u64);
assert_eq!(i as u64, *element);
}
assert_eq!(offset, 512);

Expand Down
1 change: 1 addition & 0 deletions concurrent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ where

fn update_canopy(&mut self, first_changelog_index: usize, num_leaves: usize) {
for i in 0..num_leaves {
println!("canopy: {:?}", self.canopy);
let changelog_index = (first_changelog_index + i) % self.changelog.capacity();
for (i, path_node) in self.changelog[changelog_index]
.path
Expand Down
8 changes: 4 additions & 4 deletions concurrent/src/zero_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
}
}

impl<'a, H, const HEIGHT: usize> Deref for ConcurrentMerkleTreeZeroCopy<'a, H, HEIGHT>
impl<H, const HEIGHT: usize> Deref for ConcurrentMerkleTreeZeroCopy<'_, H, HEIGHT>
where
H: Hasher,
{
Expand All @@ -139,7 +139,7 @@ where
}
}

impl<'a, H, const HEIGHT: usize> Drop for ConcurrentMerkleTreeZeroCopy<'a, H, HEIGHT>
impl<H, const HEIGHT: usize> Drop for ConcurrentMerkleTreeZeroCopy<'_, H, HEIGHT>
where
H: Hasher,
{
Expand Down Expand Up @@ -244,7 +244,7 @@ where
}
}

impl<'a, H, const HEIGHT: usize> Deref for ConcurrentMerkleTreeZeroCopyMut<'a, H, HEIGHT>
impl<H, const HEIGHT: usize> Deref for ConcurrentMerkleTreeZeroCopyMut<'_, H, HEIGHT>
where
H: Hasher,
{
Expand All @@ -254,7 +254,7 @@ where
&self.0.merkle_tree
}
}
impl<'a, H, const HEIGHT: usize> DerefMut for ConcurrentMerkleTreeZeroCopyMut<'a, H, HEIGHT>
impl<H, const HEIGHT: usize> DerefMut for ConcurrentMerkleTreeZeroCopyMut<'_, H, HEIGHT>
where
H: Hasher,
{
Expand Down
34 changes: 16 additions & 18 deletions concurrent/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ fn invalid_updates<H, const HEIGHT: usize, const CHANGELOG: usize>(
let res = merkle_tree.update(
changelog_index,
&invalid_old_leaf,
&new_leaf,
new_leaf,
0,
&mut proof_clone,
);
Expand Down Expand Up @@ -392,9 +392,8 @@ where
];
let mut expected_canopy = Vec::new();

for canopy_level in 0..CANOPY {
println!("canopy_level: {canopy_level}");
expected_canopy.extend_from_slice(&canopy_levels[canopy_level]);
for canopy_level in canopy_levels[..CANOPY].iter() {
expected_canopy.extend_from_slice(canopy_level);
}

assert_eq!(merkle_tree.changelog_index(), 4 % CHANGELOG);
Expand Down Expand Up @@ -468,8 +467,8 @@ where
][..],
];
let mut expected_canopy = Vec::new();
for canopy_level in 0..CANOPY {
expected_canopy.extend_from_slice(&canopy_levels[canopy_level]);
for canopy_level in canopy_levels[..CANOPY].iter() {
expected_canopy.extend_from_slice(canopy_level);
}

assert_eq!(merkle_tree.changelog_index(), 5 % CHANGELOG);
Expand Down Expand Up @@ -542,8 +541,8 @@ where
][..],
];
let mut expected_canopy = Vec::new();
for canopy_level in 0..CANOPY {
expected_canopy.extend_from_slice(&canopy_levels[canopy_level]);
for canopy_level in canopy_levels[..CANOPY].iter() {
expected_canopy.extend_from_slice(canopy_level);
}

assert_eq!(merkle_tree.changelog_index(), 6 % CHANGELOG);
Expand Down Expand Up @@ -615,8 +614,8 @@ where
][..],
];
let mut expected_canopy = Vec::new();
for canopy_level in 0..CANOPY {
expected_canopy.extend_from_slice(&canopy_levels[canopy_level]);
for canopy_level in canopy_levels[..CANOPY].iter() {
expected_canopy.extend_from_slice(canopy_level);
}

assert_eq!(merkle_tree.changelog_index(), 7 % CHANGELOG);
Expand Down Expand Up @@ -688,8 +687,8 @@ where
][..],
];
let mut expected_canopy = Vec::new();
for canopy_level in 0..CANOPY {
expected_canopy.extend_from_slice(&canopy_levels[canopy_level]);
for canopy_level in canopy_levels[..CANOPY].iter() {
expected_canopy.extend_from_slice(canopy_level);
}

assert_eq!(merkle_tree.changelog_index(), 8 % CHANGELOG);
Expand Down Expand Up @@ -1395,7 +1394,7 @@ async fn test_spl_compat() {
.update(changelog_index, &old_leaf, &new_leaf, 0, &mut proof)
.unwrap();
spl_concurrent_mt
.set_leaf(root, old_leaf, new_leaf, proof.as_slice(), 0 as u32)
.set_leaf(root, old_leaf, new_leaf, proof.as_slice(), 0_u32)
.unwrap();
reference_tree.update(&new_leaf, 0).unwrap();

Expand Down Expand Up @@ -2170,8 +2169,7 @@ pub fn test_100_nullify_mt() {
let leaf_cell = queue.get_unmarked_bucket(queue_index).unwrap().unwrap();
let leaf_index = crank_merkle_tree
.get_leaf_index(&leaf_cell.value_bytes())
.unwrap()
.clone();
.unwrap();

let mut proof = crank_merkle_tree
.get_proof_of_leaf(leaf_index, false)
Expand Down Expand Up @@ -2397,7 +2395,7 @@ fn test_subtree_updates() {
spl_concurrent_mt.initialize().unwrap();
con_mt.init().unwrap();
assert_eq!(ref_mt.root(), con_mt.root());
for (_, leaf) in LEAVES_WITH_NULLIFICATIONS.iter().enumerate() {
for leaf in LEAVES_WITH_NULLIFICATIONS.iter() {
match leaf.1 {
Some(index) => {
let change_log_index = con_mt.changelog_index();
Expand Down Expand Up @@ -3377,7 +3375,7 @@ where
tree.append(&leaf_0).unwrap();
tree.append(&leaf_1).unwrap();
tree.append(&leaf_2).unwrap();
let old_canopy = tree.canopy.as_slice()[0].clone();
let old_canopy = tree.canopy.as_slice()[0];

let new_leaf_0 = [1; 32];
let mut leaf_0_proof = BoundedVec::with_capacity(2);
Expand All @@ -3390,7 +3388,7 @@ where
&mut leaf_0_proof,
)
.unwrap();
let new_canopy = tree.canopy.as_slice()[0].clone();
let new_canopy = tree.canopy.as_slice()[0];

assert_ne!(old_canopy, new_canopy);

Expand Down
Loading
Loading