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

Make narHash in ValidPathInfo not optional #3899

Merged
merged 7 commits into from Aug 14, 2020

Conversation

meditans
Copy link
Member

@meditans meditans commented Aug 5, 2020

No description provided.

@meditans meditans changed the title Make narHash in ValidPathInfo not optional WIP Make narHash in ValidPathInfo not optional Aug 5, 2020
@Ericson2314
Copy link
Member

We realized we need to remove Hash::operator bool (), and then we will catch a bunch more stuff.

@meditans meditans changed the title WIP Make narHash in ValidPathInfo not optional WIP: Make narHash in ValidPathInfo not optional Aug 5, 2020
Since the hash is not optional anymore
@meditans meditans changed the title WIP: Make narHash in ValidPathInfo not optional Make narHash in ValidPathInfo not optional Aug 5, 2020
ValidPathInfo(StorePath && path) : path(std::move(path)) { };
ValidPathInfo(const StorePath & path) : path(path) { };
ValidPathInfo(StorePath && path) : path(std::move(path)), narHash(Hash::dummy) { };
ValidPathInfo(const StorePath & path) : path(path), narHash(Hash::dummy) { };
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd require a narHash at construction time. Do you know if there are any places where we construct a ValidPathInfo and we don't know the narHash?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. We should make this an argument, and at the very least callers would opt into using Hash::dummy and then initialize later, though better yet Hash::dummy can go away altogether.

@Ericson2314
Copy link
Member

@edolstra OK the Hash::dummy usage is pretty minimal now.

Comment on lines +96 to +97
/* No longer support missing NAR hash */
assert(GET_PROTOCOL_MINOR(conn->remoteVersion) >= 4);
Copy link
Member

Choose a reason for hiding this comment

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

One of the more interesting changes

Comment on lines +121 to +122
if (s == "")
throw Error("NAR hash is now mandatory");
Copy link
Member

Choose a reason for hiding this comment

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

Another notable change

ValidPathInfo info(makeFixedOutputPath(method, *h, name));
ValidPathInfo info {
makeFixedOutputPath(method, *h, name),
Hash::dummy, // Will be fixed in addToStore, which recomputes nar hash
Copy link
Member

Choose a reason for hiding this comment

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

This is rather tricky. Because the other one calculates the Nar hash, I think we should eventually make an addToStoreFromDump out of it, and then this tricky bit can go away.

ValidPathInfo info(computeStorePathForText(name, s, references));
ValidPathInfo info {
computeStorePathForText(name, s, references),
Hash::dummy, // Will be fixed in addToStore, which recomputes nar hash
Copy link
Member

Choose a reason for hiding this comment

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

To get rid of this like we do above, we would need addToStoreFromDump to also support references, but I think that's a good idea anyways.

@edolstra edolstra merged commit d81f13f into NixOS:master Aug 14, 2020
@Ericson2314 Ericson2314 deleted the make-narHash-not-optional branch August 14, 2020 15:00
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.

None yet

3 participants