Skip to content

Commit fdc7a55

Browse files
authored
Remove dusk-plonk dependency & make crates lighter (#122)
* refactored kate-recovery to replace dp deps * refactored kate package to replace dp * updated benchmarks * fixed features * fixed tests * deep cleaning * more cleaning * dedup & more cleaning * add placeholders for removed error_type * add log dependency and improve error handling in reconstruction
1 parent 5e11ad8 commit fdc7a55

23 files changed

Lines changed: 391 additions & 646 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target
2-
kate/.DS_Store
2+
.gdb_history
33
.DS_Store
4+
.vscode

.rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ match_block_trailing_comma = true
77
# group_imports = "StdExternalCrate"
88
use_field_init_shorthand = true
99
edition = "2018"
10-
hard_tabs = true
10+
hard_tabs = true

Cargo.lock

Lines changed: 13 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ criterion = { version = "0.4", default-features = false }
3737
serde = { version = "1.0.196", default-features = false, features = ["derive", "alloc"] }
3838
hex = { version = "0.4", default-features = false, features = ["alloc", "serde"] }
3939
serde_json = { version = "1", default-features = false }
40-
dusk-bytes = { version = "0.1.6", default-features = false }
4140
impl-serde = { version = "0.5.0", default-features = false }
4241

4342
# Crypto
@@ -49,10 +48,7 @@ blake2b_simd = { version = "1.0.2", default-features = false }
4948
sha2 = { version = "0.10.7", default-features = false }
5049
sha3 = { version = "0.10.0", default-features = false }
5150

52-
poly-multiproof = { git = "https://github.com/availproject/poly-multiproof", ref="494468b86ac8e16dca21d465d921990c578eaad3", default-features = false, features = ['ark-bls12-381', "blst"]}
53-
54-
dusk-plonk = { git = "https://github.com/availproject/plonk.git", default-features = false, features = ["alloc"], tag = "v0.12.0-polygon-2" }
55-
51+
poly-multiproof = { git = "https://github.com/availproject/poly-multiproof", ref="494468b86ac8e16dca21d465d921990c578eaad3", default-features = false, features = ["ark-bls12-381", "blst"]}
5652
hash-db = { version = "0.16.0", default-features = false }
5753

5854
# Others
@@ -69,10 +65,6 @@ sp-crypto-ec-utils = { git = "https://github.com/availproject/polkadot-sdk", tag
6965
[profile.dev.package]
7066
nalgebra = { opt-level = 3 }
7167
blst = { opt-level = 3 }
72-
dusk-bls12_381 = { opt-level = 3 }
73-
dusk-plonk = { opt-level = 3 }
74-
dusk-jubjub = { opt-level = 3 }
75-
dusk-bytes = { opt-level = 3 }
7668
rayon = { opt-level = 3 }
7769
rayon-core = { opt-level = 3 }
7870
poly-multiproof = { opt-level = 3 }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Data Availability Core
22

33
# Dev Notes
4-
When changes are made make sure to run `build_test.sh`. This will check if everything works correctly under all feature permutations
4+
When changes are made make sure to run `build_test.sh`. This will check if everything works correctly under all feature permutations.

core/src/header/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ where
119119
let extrinsics_root = self.extrinsics_root.as_ref();
120120

121121
f.debug_struct("Header")
122-
.field("parent_hash", &HexDisplay(&parent_hash))
122+
.field("parent_hash", &HexDisplay(parent_hash))
123123
.field("number", &self.number)
124-
.field("state_root", &HexDisplay(&state_root))
125-
.field("extrinsics_root", &HexDisplay(&extrinsics_root))
124+
.field("state_root", &HexDisplay(state_root))
125+
.field("extrinsics_root", &HexDisplay(extrinsics_root))
126126
.field("digest", &self.digest)
127127
.field("extension", &self.extension)
128128
.finish()

kate/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ avail-core = { path = "../core", default-features = false }
1313
kate-recovery = { path = "recovery", default-features = false }
1414

1515
# Crypto
16-
dusk-plonk = { workspace = true }
1716
poly-multiproof = { workspace = true, default-features = false, features = ["blst"] }
1817

1918
# Parity & Substrate
@@ -26,7 +25,6 @@ derive_more.workspace = true
2625
static_assertions.workspace = true
2726
thiserror-no-std.workspace = true
2827

29-
dusk-bytes = { workspace = true, optional = true }
3028
hex = { workspace = true }
3129
hex-literal.workspace = true
3230
log = { workspace = true, optional = true }
@@ -47,14 +45,12 @@ test-case.workspace = true
4745

4846
[features]
4947
default = [ "std" ]
50-
alloc = [ "dusk-plonk/alloc", "nalgebra/alloc" ]
48+
alloc = [ "nalgebra/alloc" ]
5149
parallel = [ "criterion/rayon", "rayon" ]
5250

5351
std = [
5452
"avail-core/std",
5553
"codec/std",
56-
"dusk-bytes",
57-
"dusk-plonk/std",
5854
"kate-recovery/std",
5955
"log",
6056
"nalgebra/std",

kate/benches/reconstruct.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
use avail_core::{AppExtrinsic, AppId, BlockLengthColumns, BlockLengthRows, DataLookup};
22
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
3-
use dusk_plonk::prelude::BlsScalar;
4-
use kate::{
5-
com::{Cell, *},
6-
metrics::IgnoreMetrics,
7-
Seed, Serializable as _,
8-
};
3+
use kate::gridgen::core::AsBytes;
4+
use kate::{com::build_proof, com::par_build_commitments, com::Cell, metrics::IgnoreMetrics, Seed};
95
use kate_recovery::{
106
com::reconstruct_extrinsics,
117
commitments,
8+
commons::ArkScalar,
129
data::{self, DataCell},
1310
matrix::Position,
1411
proof, testnet,
@@ -39,7 +36,7 @@ fn load_xts() -> Vec<Vec<AppIdData>> {
3936
serde_json::from_str(XTS_JSON_SETS).expect("Autogenerated Json file .qed")
4037
}
4138

42-
fn sample_cells_from_matrix(matrix: &DMatrix<BlsScalar>, columns: Option<&[u16]>) -> Vec<DataCell> {
39+
fn sample_cells_from_matrix(matrix: &DMatrix<ArkScalar>, columns: Option<&[u16]>) -> Vec<DataCell> {
4340
fn random_indexes(length: usize, seed: Seed) -> Vec<usize> {
4441
// choose random len/2 (unique) indexes
4542
let mut idx = (0..length).collect::<Vec<_>>();
@@ -74,7 +71,7 @@ fn sample_cells_from_matrix(matrix: &DMatrix<BlsScalar>, columns: Option<&[u16]>
7471
let position = Position::new(row_pos, col_idx);
7572
debug_assert!(*row_idx < col_view.len());
7673
let data = col_view[*row_idx].to_bytes();
77-
DataCell::new(position, data)
74+
DataCell::new(position, data.unwrap())
7875
})
7976
.collect::<Vec<_>>()
8077
})
@@ -146,7 +143,11 @@ fn reconstruct(xts: &[AppExtrinsic]) {
146143
}
147144

148145
let dims_cols: u32 = dims.cols().into();
149-
let public_params = testnet::public_params(usize::try_from(dims_cols).unwrap());
146+
// let public_params = testnet::public_params(usize::try_from(dims_cols).unwrap());
147+
let public_params = testnet::multiproof_params(
148+
usize::try_from(dims_cols).unwrap(),
149+
usize::try_from(dims_cols).unwrap(),
150+
);
150151
for cell in random_cells(dims.cols(), dims.rows(), Percent::one()) {
151152
let row: u32 = cell.row.into();
152153

@@ -166,7 +167,7 @@ fn reconstruct(xts: &[AppExtrinsic]) {
166167

167168
let extended_dims = dims.try_into().unwrap();
168169
let commitment = commitments::from_slice(&commitments).unwrap()[row as usize];
169-
let verification = proof::verify(&public_params, extended_dims, &commitment, &cell);
170+
let verification = proof::verify_v2(&public_params, extended_dims, &commitment, &cell);
170171
assert!(verification.is_ok());
171172
assert!(verification.unwrap());
172173
}

0 commit comments

Comments
 (0)