Skip to content
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

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

hanbu97
Copy link
Contributor

@hanbu97 hanbu97 commented Oct 26, 2022

@hanbu97
Copy link
Contributor Author

hanbu97 commented Oct 26, 2022

#1631
finished

@hanbu97
Copy link
Contributor Author

hanbu97 commented Oct 27, 2022

Please rerun the workflow, clippy is fixed. Thank you.

@shawnrader
Copy link

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

@hanbu97
Copy link
Contributor Author

hanbu97 commented Nov 10, 2022

Got it. Clippy in tests fixed.

@vmx vmx requested a review from shawnrader November 10, 2022 13:05
Copy link
Contributor

@DrPeterVanNostrand DrPeterVanNostrand left a 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:

  1. PorepConfig::new_groth16 should be named new until additional proof systems are supported.
  2. 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
Copy link
Contributor

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.

@@ -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 {
Copy link
Contributor

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 {
Copy link
Contributor

@DrPeterVanNostrand DrPeterVanNostrand Nov 10, 2022

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.

@vmx
Copy link
Contributor

vmx commented Nov 10, 2022

1. `PorepConfig::new_groth16` should be named `new` until additional proof systems are supported.

I proposed in the original issue at #1632 naming it new_groth16(). I still think it's a good idea (and less hassle for the future), but if @DrPeterVanNostrand feels strongly about it, we can also change it to just new().

storojs72
storojs72 previously approved these changes Nov 10, 2022
Copy link
Contributor

@storojs72 storojs72 left a 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.

@hanbu97
Copy link
Contributor Author

hanbu97 commented Nov 11, 2022

What should I do next, or some tasks else.

@hanbu97 hanbu97 requested review from DrPeterVanNostrand and removed request for shawnrader November 11, 2022 04:49
@vmx
Copy link
Contributor

vmx commented Nov 11, 2022

@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 new or new_groth16 and let you know once we've come to a decision.

vmx
vmx previously approved these changes Nov 14, 2022
Copy link
Contributor

@vmx vmx left a 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!

Copy link
Contributor

@DrPeterVanNostrand DrPeterVanNostrand left a 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.

self.0.write().expect("POREP_MINIMUM_CHALLENGES poisoned")
}

pub fn porep_partitions(&self, sector_size: u64) -> usize {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

vmx
vmx previously approved these changes Nov 17, 2022
Copy link
Contributor

@vmx vmx left a 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.

@DrPeterVanNostrand
Copy link
Contributor

Looks good to me. Thanks @hanbu97!

vmx
vmx previously approved these changes Dec 8, 2022
Copy link
Contributor

@vmx vmx left a 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.

@hanbu97
Copy link
Contributor Author

hanbu97 commented Dec 9, 2022

@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.

Unable to squash. Squashing replays all commits up to the last one required for the squash. A merge commit cannot exist among those commits.

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.
@vmx
Copy link
Contributor

vmx commented Dec 9, 2022

@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 git rebase -i master and the fixed up the commits.

@hanbu97
Copy link
Contributor Author

hanbu97 commented Dec 10, 2022

Sure go ahead. Let's make it done. Thank you.

@vmx vmx merged commit 62ed86f into filecoin-project:master Dec 12, 2022
@vmx
Copy link
Contributor

vmx commented Dec 12, 2022

Thanks again @hanbu97 and sorry that it took so long to get it merged.

storojs72 pushed a commit that referenced this pull request Jan 11, 2023
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>
storojs72 pushed a commit that referenced this pull request Jan 11, 2023
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>
storojs72 added a commit that referenced this pull request Jan 19, 2023
* 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>
storojs72 added a commit that referenced this pull request Jan 19, 2023
* 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>
storojs72 added a commit that referenced this pull request Jan 19, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants