-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] feat: Halo2 compatible vanilla Hashers #1560
base: master
Are you sure you want to change the base?
Conversation
137c053
to
ad5955e
Compare
ad5955e
to
1cbb33f
Compare
f1af449
to
a8be7e8
Compare
a8be7e8
to
a088c29
Compare
.circleci/config.yml
Outdated
cargo +$(cat rust-toolchain) test -p storage-proofs-update --features isolated-testing --release test_empty_sector_update_circuit_8kib | ||
cargo +$(cat rust-toolchain) test -p storage-proofs-update --features isolated-testing --release test_empty_sector_update_circuit_16kib | ||
cargo +$(cat rust-toolchain) test -p storage-proofs-update --features isolated-testing --release test_empty_sector_update_circuit_32kib | ||
cargo +$(cat rust-toolchain) test -p storage-proofs-update --features isolated-testing --release circuit_1kib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this change was necessary because I changed the ESU and ESU-Poseidon test names.
f992e1b
to
220308f
Compare
fn cache_porep_params<Tree>(porep_config: PoRepConfig) | ||
where | ||
Tree: 'static + MerkleTreeTrait, | ||
<Tree::Hasher as Hasher>::Domain: Domain<Field = Fr>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Groth16 params can only be generated for the field Fr
.
) { | ||
fn cache_empty_sector_update_params<Tree>(porep_config: PoRepConfig) | ||
where | ||
Tree: 'static + MerkleTreeTrait<Hasher = TreeRHasher<Fr>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESU can only use TreeRs whose hasher is TreeRHasher
.
) -> anyhow::Result<((u64, u64), (u64, u64), (u64, u64))> | ||
where | ||
Tree: 'static + MerkleTreeTrait, | ||
<Tree::Hasher as Hasher>::Domain: Domain<Field = Fr>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: for now, only bench using the field Fr
.
fn get_porep_info<Tree>(porep_config: PoRepConfig) -> CircuitInfo | ||
where | ||
Tree: 'static + MerkleTreeTrait, | ||
<Tree::Hasher as Hasher>::Domain: Domain<Field = Fr>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Groth16 circuits can only be created using the field Fr
.
) -> Result<()> | ||
where | ||
Tree: 'static + MerkleTreeTrait, | ||
<Tree::Hasher as Hasher>::Domain: Domain<Field = Fr>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: for now, only generate parent cache for the production field Fr
.
@@ -32,7 +34,7 @@ opencl = ["bellperson/opencl", "neptune/opencl"] | |||
|
|||
# available hashers | |||
blake2s = ["blake2s_simd"] | |||
poseidon = ["neptune", "lazy_static"] | |||
poseidon = ["neptune", "lazy_static", "typemap"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: typemap
allows us to lookup the Poseidon constants for a field and arity.
@@ -26,6 +30,60 @@ lazy_static! { | |||
pub static ref POSEIDON_CONSTANTS_11: PoseidonConstants::<Fr, U11> = PoseidonConstants::new(); | |||
pub static ref POSEIDON_MD_CONSTANTS: PoseidonConstants::<Fr, PoseidonMDArity> = | |||
PoseidonConstants::new(); | |||
pub static ref POSEIDON_CONSTANTS_2_PALLAS: PoseidonConstants::<Fp, U2> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: create Poseidon constants for the three hasher fields; put the constants into a lookup table keyed by (field, arity)
filecoin-hashers/src/types.rs
Outdated
@@ -27,21 +28,49 @@ pub trait Domain: | |||
+ Eq | |||
+ Send | |||
+ Sync | |||
// TODO (halo): remove once we have Pasta GPU support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Domain: From<Fr> + Into<Fr>
is used as a stopgap to cause GPU code to panic when using Pasta fields; these bounds should be removed once the GPU work has finished.
4003a25
to
952341e
Compare
fr32/Cargo.toml
Outdated
@@ -20,6 +20,8 @@ blstrs = "0.4.0" | |||
bitvec = "0.17" | |||
criterion = "0.3" | |||
itertools = "0.9" | |||
# pasta_curves = "0.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: change before merging
3f4d23b
to
ab090d7
Compare
filecoin-hashers/Cargo.toml
Outdated
# neptune = { version = "5.1.0", optional = true, features = ["arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] } | ||
# pasta_curves = "0.3.0" | ||
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "wip-fr-as-trait", optional = true, features = ["arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] } | ||
pasta_curves = { git = "https://github.com/vmx/pasta_curves", branch = "ec-gpu", features = ["gpu"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is status on dep branches here? I saw this one updated (https://github.com/filecoin-project/neptune/pull/135/files)?
I'm not enough qualified to judge on the essence of the introduced changes... But this PR seems to be too monstrous (+4,912 −2,710). If this huge change is going to be merged, probably it is better to split this single PR on multiply PRs and introduce / review / merge them incrementally. WDYT, @DrPeterVanNostrand? |
069954d
to
e769deb
Compare
@storojs72 You're right, it's an ugly PR (which I'm also not happy about). I'm totally in favor of small precise PRs, just this one is kind of difficult to merge incrementally. The reason why it hasn't been split into multiple features/PRs is because this PR essentially adds a single feature to Also, much of this PR repeats the same 2 or 3 interface changes. For example, adding this one additional trait bound probably accounts for 500 additional lines in the diff.
|
@storojs72 Appreciate the feedback, and thanks for taking a look! This particular PR we knew was going to be a monster and the team had a sync review session for calibration on it not that long ago. These types of PRs don't happen necessarily all that often (thankfully), but we are in the middle of a sort of large re-factor for pending future work. |
@DrPeterVanNostrand Still reviewing, but I expect to be complete by tomorrow (just FYI) |
2fd142d
to
84496a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally all looks good to me. The only concern is how we're handling the dependencies that haven't been merged/released yet.
84496a9
to
93e8ec5
Compare
93e8ec5
to
7edf855
Compare
ff = "0.11.0" | ||
anyhow = "1.0.34" | ||
serde = "1.0.117" | ||
rand = "0.8.0" | ||
|
||
neptune = { version = "5.1.0", optional = true, features = ["arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] } | ||
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "fr-as-trait", optional = true, features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: change neptune
dependencies once this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to keep that branch for now until there's a proper pasta_curves
release.
F