Skip to content

Commit 66f3d0a

Browse files
committed
fix(test): use row-pair leaves in merkle_root_parity GPU tests
gpu_merkle_root / gpu_ext3_merkle_root called keccak_leaves_base/ext3 with rows_per_leaf=1 (per-row, num_rows leaves) but compare the resulting root against the CPU commit_rows_bit_reversed, which uses the row-pair layout (ROWS_PER_LEAF=2, num_rows/2 leaves, each hashing a bit-reversed row pair). Different leaf count and bytes => different root, so the two cases never matched main's row-pair commitment scheme. Pass rows_per_leaf=2 so the generic GPU keccak-leaves + Merkle path uses the same bit-reversed row-pair layout as the CPU reference. keccak_leaves.rs already proves keccak_leaves_base(.., 2) matches the CPU row-pair prover, and the production-pipeline parity cases (new_row_major_pipeline_*) already pass, so this only realigns the generic-helper cases with main. Test-only change; the proving path uses the fused row-pair pipeline and is unaffected. GPU tests don't run in CI (no nvcc) — to be confirmed on a GPU.
1 parent 7f6b85e commit 66f3d0a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

crypto/math-cuda/tests/merkle_root_parity.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ fn gpu_merkle_root(columns: &[Vec<u64>], blowup: usize, weights: &[u64]) -> [u8;
5555
}
5656
}
5757

58-
// Per-row leaves (rows_per_leaf = 1): this parity test compares the generic
59-
// keccak-leaves + Merkle primitives against a per-row CPU reference.
60-
let gpu_leaves = math_cuda::merkle::keccak_leaves_base(&flat, n_lde, num_cols, n_lde, 1)
58+
// Row-pair leaves (rows_per_leaf = 2, matching `ROWS_PER_LEAF`): the CPU
59+
// reference is `commit_rows_bit_reversed`, which hashes bit-reversed row
60+
// pairs into each leaf, so the generic GPU keccak-leaves + Merkle path must
61+
// use the same row-pair layout to produce a matching root.
62+
let gpu_leaves = math_cuda::merkle::keccak_leaves_base(&flat, n_lde, num_cols, n_lde, 2)
6163
.expect("GPU keccak leaves");
6264
let nodes =
6365
math_cuda::merkle::build_merkle_tree_on_device(&gpu_leaves).expect("GPU Merkle tree");
@@ -191,8 +193,10 @@ fn gpu_ext3_merkle_root(columns: &[Vec<Fp3>], blowup: usize, weights: &[u64]) ->
191193
}
192194
}
193195

196+
// Row-pair leaves (rows_per_leaf = 2, matching `ROWS_PER_LEAF`) to match the
197+
// row-pair `commit_rows_bit_reversed` CPU reference below.
194198
let gpu_leaves =
195-
math_cuda::merkle::keccak_leaves_ext3(&flat_for_keccak, lde_size, num_cols, lde_size, 1)
199+
math_cuda::merkle::keccak_leaves_ext3(&flat_for_keccak, lde_size, num_cols, lde_size, 2)
196200
.expect("GPU ext3 keccak leaves");
197201
let nodes =
198202
math_cuda::merkle::build_merkle_tree_on_device(&gpu_leaves).expect("GPU Merkle tree");

0 commit comments

Comments
 (0)