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

feat: certs part 2 #14

Merged
merged 33 commits into from
Oct 15, 2024
Merged

feat: certs part 2 #14

merged 33 commits into from
Oct 15, 2024

Conversation

ruseinov
Copy link
Contributor

@ruseinov ruseinov commented Oct 4, 2024

Closes ChainSafe/forest#4693

This is now only missing the verification bit as we don't have the crypto library yet. I think we can close this issue, I will introduce a new one for that piece.

UPD: ChainSafe/forest#4887

@ruseinov ruseinov marked this pull request as ready for review October 14, 2024 12:08
@ruseinov ruseinov requested a review from a team as a code owner October 14, 2024 12:08
@ruseinov ruseinov requested review from lemmih and LesnyRumcajs and removed request for a team October 14, 2024 12:08
@ruseinov ruseinov requested a review from hanabi1224 October 14, 2024 12:09
@@ -141,9 +150,9 @@ mod tests {
let step = Phase::Commit;
let supplemental_data = SupplementalData {
commitments: keccak_hash::H256::zero(),
power_table: vec![],
power_table: Cid::default(),
Copy link
Member

Choose a reason for hiding this comment

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

Would a possible lack of power table be better represented by Option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not represented as an option in Go version (in this case a reference), so I don't think we should either. What they do is they check if the Cid is empty, just like us. I think it makes sense. Because an empty CID is not necessarily None.

Copy link
Member

Choose a reason for hiding this comment

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

Default CID means that there's no power table, correct? The default CID still has a set multihash and version and, subjectively, checking if something is not of certain value to assert it's not there is bug-prone. If it's an Option then the developer knows that they need to check whether it exists and not deduce that they need to check against a particular hard-coded CID.

Not a terribly strong feeling, but I'd advise to reconsider the approach. It's similar to an Address - it can be defaulted to something, but what is the meaning of it? It's the reason that it's hidden in FVM under the testing feature. It's similar thing to a checksum of something - having a checksum of 00000 would mean (to me) that you actually ran the digest method and you somehow obtained all zeroes therefore you should quit your job and buy yourself an island from the billions you made on crypto. :)

Copy link
Contributor Author

@ruseinov ruseinov Oct 14, 2024

Choose a reason for hiding this comment

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

In our case we just use Cid::default() as we would any other Cid value - simply to fill the property with something. It's completely irrelevant for this test and reads better than a hardcoded string.
It isn't nullable in the reference code, so it should not be nullable here either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we look through the codebase - it's also not being used for anything rather than comparison to another cid that's manually hashed, so there is no reason to change the approach.

Comment on lines 19 to 21
# we are using a trick to enable a `test-utils` feature in the `f3-gpbft` which
# triggers a false positive.
crate == 'filecoin-f3-gpbft'
Copy link
Member

Choose a reason for hiding this comment

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

nit: why not crate == 'quickcheck' && crates.include?('quickcheck_macros') or crate == 'filecoin-f3-gpbft'?

Copy link
Contributor Author

@ruseinov ruseinov Oct 14, 2024

Choose a reason for hiding this comment

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

I think it's much more readable like it is right now. If we need to introduce more deps - perhaps we have to revisit the approach. Having a long chain of && and or isn't much better IMHO. No strong opinion.

Copy link
Member

Choose a reason for hiding this comment

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

Might I suggest:

  [
    # `quickcheck` is required implicitly by `quickcheck_macros`
    crate == 'quickcheck' && crates.include?('quickcheck_macros'),
    # we are using a trick to enable a `test-utils` feature in the `f3-gpbft` which
    # triggers a false positive.
    crate == 'filecoin-f3-gpbft'
  ].any?

?

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 like this

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

LGTM, I'll let @hanabi1224 do the final pass here.

@@ -37,7 +38,34 @@ impl Ord for PowerEntry {
}
}

impl Serialize for PowerEntry {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Possible to use serde_tuple to avoid the manual implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a validation there as well to match the Go code. But we can at least derive deserialize.

hanabi1224
hanabi1224 previously approved these changes Oct 14, 2024
gpbft/src/test_utils.rs Outdated Show resolved Hide resolved
gpbft/src/chain.rs Outdated Show resolved Hide resolved
gpbft/src/chain.rs Outdated Show resolved Hide resolved
certs/Cargo.toml Outdated
@@ -5,5 +5,10 @@ edition = "2021"

[dependencies]
ahash = { workspace = true }
anyhow = { workspace = true }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a dev-dependency, I think.

gpbft/Cargo.toml Outdated
@@ -9,10 +9,20 @@ edition.workspace = true

[dependencies]
ahash = { workspace = true }
anyhow = "1.0.86"
anyhow = { workspace = true }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also dev-dependency.

ruseinov and others added 5 commits October 15, 2024 13:48
Co-authored-by: David Himmelstrup <lemmih@gmail.com>
Co-authored-by: David Himmelstrup <lemmih@gmail.com>
@ruseinov ruseinov added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit a9325c1 Oct 15, 2024
5 checks passed
@ruseinov ruseinov deleted the ru/feature/certs-2 branch October 15, 2024 11:56
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.

[F3] Implement GPBFT primitives that certs package uses and port certs
4 participants