-
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
chore: Introduce PoRepConfig::new_groth16() #1635
Conversation
#1631 |
Please rerun the workflow, clippy is fixed. Thank you. |
I am still showing some clippy issues after re-running the workflow (some unused imports): https://app.circleci.com/pipelines/github/filecoin-project/rust-fil-proofs/4397/workflows/fd19d319-f5cf-422e-9885-8ff4b8314310/jobs/96937?invite=true#step-105-355 |
Got it. Clippy in tests fixed. |
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.
Thank you!
I definitely like the idea of having a simple PorepConfig
constructor.
My only concerns with this PR are:
PorepConfig::new_groth16
should be namednew
until additional proof systems are supported.- Minimum PoRep challenges should be kept as a mutable setting to allow
benchy
to benchmark non-default PoRep configurations.
.write() | ||
.expect("POREP_MINIMUM_CHALLENGES poisoned") | ||
.insert(inputs.sector_size_bytes(), inputs.porep_challenges); | ||
// POREP_MINIMUM_CHALLENGES |
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.
I think that it still makes sense to allow benchy
to configure the number of PoRep challenges, as benchy
is used to benchmark varrying PoRep configurations, not just the the default/production configurations.
filecoin-proofs/src/constants.rs
Outdated
@@ -47,24 +47,25 @@ pub const PUBLISHED_SECTOR_SIZES: [u64; 10] = [ | |||
SECTOR_SIZE_64_GIB, | |||
]; | |||
|
|||
pub struct PorepMinimumChallenges; | |||
impl PorepMinimumChallenges { | |||
pub const fn porep_partitions(sector_size: u64) -> usize { |
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.
I think that a better name for this function would be from_sector_size
, however to allow for varying PoRep configurations during benchmarking (e.g. benchy
), I think that it's better to leave this as a mutable HashMap
rather than hardcoded constants.
@@ -54,6 +55,22 @@ impl From<PoRepConfig> for SectorSize { | |||
} | |||
|
|||
impl PoRepConfig { | |||
/// construct PoRepConfig by groth16 | |||
pub fn new_groth16(sector_size: u64, porep_id: [u8; 32], api_version: ApiVersion) -> Self { |
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.
Until additional proof systems are supported in rust-fil-proofs
, I think that it's better to exclude the groth16
identifier from the function name as Groth16 is the only proof system currently supported. If/when additional proof systems are supported, I definitely think that it makes sense to use the function name new_groth16
, but for now, I think that new
is a better name.
I proposed in the original issue at #1632 naming it |
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.
I support this change (though it still requires to fix merge conflicts), as it removes more lines of code than adds (+88; -218), that makes codebase a bit more readable.
What should I do next, or some tasks else. |
@hanbu97 The comment about making things again a mutable HashMap is something you could work on. I'll talk with @DrPeterVanNostrand directly whether it should be |
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.
Thanks a lot, I really like the changes!
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.
Looks good to me. My only concern is the naming of the function PorepMinimumChallenges::porep_partitions
.
filecoin-proofs/src/constants.rs
Outdated
self.0.write().expect("POREP_MINIMUM_CHALLENGES poisoned") | ||
} | ||
|
||
pub fn porep_partitions(&self, sector_size: u64) -> usize { |
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.
To me, the name of this function implies that we are deriving the partition count from the number of porep challenges. I think that a better name for this function would be something like from_sector_size
or for_sector_size
as we are retrieving the minimum challenge count for a given sector size.
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.
I agree with you, will make it more readable. Changes done.
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.
Awesome, thank you!
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.
Looks good to me. I'm just waiting for @DrPeterVanNostrand for final approval.
Looks good to me. Thanks @hanbu97! |
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.
As @DrPeterVanNostrand also approved it, I hereby approve it.
@hanbu97 could you please rebase one more time? Best would be if you would squash it into a single commit.
When I tried to squash commits. Some error occurs.
It seems because I merged some changes at developing time. I will pay attention to it next time. If the squash is required I may create a new branch. |
Instead of constructing the `PoRepConfig` directly, use a constructor function. This simplifies the code and makes things less error-prone. Fixes filecoin-project#1632.
@hanbu97 I dared to squash it into a single commit for you. Please let me know if you agree with that commit and the commit message. I did a |
Sure go ahead. Let's make it done. Thank you. |
Thanks again @hanbu97 and sorry that it took so long to get it merged. |
Instead of constructing the `PoRepConfig` directly, use a constructor function. This simplifies the code and makes things less error-prone. Fixes #1632. Co-authored-by: 卜翰 <buhan970731@gmail.com>
Instead of constructing the `PoRepConfig` directly, use a constructor function. This simplifies the code and makes things less error-prone. Fixes #1632. Co-authored-by: 卜翰 <buhan970731@gmail.com>
* fix: use current process binding to limit thread cores (#1633) Use the current processes bound cores to limit the possible cores that threads can be bound to. This allows core binding to work properly when the lotus-worker service is limited to certain CPUs by cgroups. * fix: update ec-gpu-gen (#1638) `ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that depend on yanked version. It's an indirect dependency of `bellperson` and `neptune`, which are upgraded here. Moving from `memmap` (which is deprecated) to `memmap2` was also needed als dependencies also switched. `chrono` updated their API, so there was also a small change needed. * fix: broken Links in README.md #1637 (#1649) * feat: Introduce PoRepConfig::new_groth16() (#1635) Instead of constructing the `PoRepConfig` directly, use a constructor function. This simplifies the code and makes things less error-prone. Fixes #1632. Co-authored-by: 卜翰 <buhan970731@gmail.com> * fix: clean up tree definitions (#1655) There were quite a few public type definitions, that were mostly replaced by the `SectorShape*` types. This commit cleans them up and moves them around if appropriate. This should make the code easier to follow and the public API surface smaller. BREAKING CHANGE: `BinaryLCMerkleTree`, `BinaryMerkleTree`, `BinarySubMerkleTree`, `LCMerkleTree`, `LCStore`, `MerkleStore`, `MerkleTree`, `OctLCMerkleTree`, `OctLCSubMerkleTree`, `OctLCTopMerkleTree`, `OctMerkleTree`, `OctSubMerkleTree`, `OctTopMerkleTree`, `QuadLCMerkleTree` and `QuadMerkleTree` are removed from the public interface. * fix: update ec-gpu-gen (#1638) `ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that depend on yanked version. It's an indirect dependency of `bellperson` and `neptune`, which are upgraded here. Moving from `memmap` (which is deprecated) to `memmap2` was also needed als dependencies also switched. `chrono` updated their API, so there was also a small change needed. * chore: update Cargo.lock * fix: there was a memmap -> memmap2 missing * fix: make poseidon tests pass Neptune currently is a fork of pasta_curves. That needs patching as well, in order to get the correct names for the fields out. * ci: Apply rustfmt and fix clippy * Pick relevant branch of neptune * fix: Use SHA256 hasher for binary trees Co-authored-by: Clint Armstrong <clint@clintarmstrong.net> Co-authored-by: Volker Mische <volker.mische@gmail.com> Co-authored-by: hanbu97 <98807352+hanbu97@users.noreply.github.com> Co-authored-by: 卜翰 <buhan970731@gmail.com>
* fix: use current process binding to limit thread cores (#1633) Use the current processes bound cores to limit the possible cores that threads can be bound to. This allows core binding to work properly when the lotus-worker service is limited to certain CPUs by cgroups. * fix: update ec-gpu-gen (#1638) `ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that depend on yanked version. It's an indirect dependency of `bellperson` and `neptune`, which are upgraded here. Moving from `memmap` (which is deprecated) to `memmap2` was also needed als dependencies also switched. `chrono` updated their API, so there was also a small change needed. * fix: broken Links in README.md #1637 (#1649) * feat: Introduce PoRepConfig::new_groth16() (#1635) Instead of constructing the `PoRepConfig` directly, use a constructor function. This simplifies the code and makes things less error-prone. Fixes #1632. Co-authored-by: 卜翰 <buhan970731@gmail.com> * fix: clean up tree definitions (#1655) There were quite a few public type definitions, that were mostly replaced by the `SectorShape*` types. This commit cleans them up and moves them around if appropriate. This should make the code easier to follow and the public API surface smaller. BREAKING CHANGE: `BinaryLCMerkleTree`, `BinaryMerkleTree`, `BinarySubMerkleTree`, `LCMerkleTree`, `LCStore`, `MerkleStore`, `MerkleTree`, `OctLCMerkleTree`, `OctLCSubMerkleTree`, `OctLCTopMerkleTree`, `OctMerkleTree`, `OctSubMerkleTree`, `OctTopMerkleTree`, `QuadLCMerkleTree` and `QuadMerkleTree` are removed from the public interface. * fix: update ec-gpu-gen (#1638) `ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that depend on yanked version. It's an indirect dependency of `bellperson` and `neptune`, which are upgraded here. Moving from `memmap` (which is deprecated) to `memmap2` was also needed als dependencies also switched. `chrono` updated their API, so there was also a small change needed. * chore: update Cargo.lock * fix: there was a memmap -> memmap2 missing * fix: make poseidon tests pass Neptune currently is a fork of pasta_curves. That needs patching as well, in order to get the correct names for the fields out. * ci: Apply rustfmt and fix clippy * Pick relevant branch of neptune * fix: Use SHA256 hasher for binary trees Co-authored-by: Clint Armstrong <clint@clintarmstrong.net> Co-authored-by: Volker Mische <volker.mische@gmail.com> Co-authored-by: hanbu97 <98807352+hanbu97@users.noreply.github.com> Co-authored-by: 卜翰 <buhan970731@gmail.com>
* fix: use current process binding to limit thread cores (#1633) Use the current processes bound cores to limit the possible cores that threads can be bound to. This allows core binding to work properly when the lotus-worker service is limited to certain CPUs by cgroups. * fix: update ec-gpu-gen (#1638) `ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that depend on yanked version. It's an indirect dependency of `bellperson` and `neptune`, which are upgraded here. Moving from `memmap` (which is deprecated) to `memmap2` was also needed als dependencies also switched. `chrono` updated their API, so there was also a small change needed. * fix: broken Links in README.md #1637 (#1649) * feat: Introduce PoRepConfig::new_groth16() (#1635) Instead of constructing the `PoRepConfig` directly, use a constructor function. This simplifies the code and makes things less error-prone. Fixes #1632. Co-authored-by: 卜翰 <buhan970731@gmail.com> * fix: clean up tree definitions (#1655) There were quite a few public type definitions, that were mostly replaced by the `SectorShape*` types. This commit cleans them up and moves them around if appropriate. This should make the code easier to follow and the public API surface smaller. BREAKING CHANGE: `BinaryLCMerkleTree`, `BinaryMerkleTree`, `BinarySubMerkleTree`, `LCMerkleTree`, `LCStore`, `MerkleStore`, `MerkleTree`, `OctLCMerkleTree`, `OctLCSubMerkleTree`, `OctLCTopMerkleTree`, `OctMerkleTree`, `OctSubMerkleTree`, `OctTopMerkleTree`, `QuadLCMerkleTree` and `QuadMerkleTree` are removed from the public interface. * fix: update ec-gpu-gen (#1638) `ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that depend on yanked version. It's an indirect dependency of `bellperson` and `neptune`, which are upgraded here. Moving from `memmap` (which is deprecated) to `memmap2` was also needed als dependencies also switched. `chrono` updated their API, so there was also a small change needed. * chore: update Cargo.lock * fix: there was a memmap -> memmap2 missing * fix: make poseidon tests pass Neptune currently is a fork of pasta_curves. That needs patching as well, in order to get the correct names for the fields out. * ci: Apply rustfmt and fix clippy * Pick relevant branch of neptune * fix: Use SHA256 hasher for binary trees Co-authored-by: Clint Armstrong <clint@clintarmstrong.net> Co-authored-by: Volker Mische <volker.mische@gmail.com> Co-authored-by: hanbu97 <98807352+hanbu97@users.noreply.github.com> Co-authored-by: 卜翰 <buhan970731@gmail.com>
https://github.com/filecoin-project/rust-fil-proofs/issues/1632