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

Some refactorings to sc-consensus-subspace #99

Merged
merged 11 commits into from
Nov 4, 2021

Conversation

liuchengxu
Copy link
Contributor

@liuchengxu liuchengxu commented Oct 31, 2021

Part of #80.

This PR refactors verify_solution and separates out authorship.rs and archiver.rs(no code changes in these new modules) in sc-consensus-subspace, for better maintainability and future refactorings. Should be reviewed per commit.

Copy link
Member

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

Modules separation makes a lot of sense, but I'm not so sure about splitting verification into multiple functions that just convert boolean to Result<>, it seems to me that it only makes it harder to read as a whole when things are split so far.

@@ -26,7 +26,7 @@ use sp_core::Public;
use sp_runtime::{traits::DigestItemFor, traits::Header, RuntimeAppPublic};
use subspace_archiving::archiver;
use subspace_core_primitives::{crypto, Piece, Randomness, Salt, Sha256Hash};
use subspace_solving::SubspaceCodec;
use subspace_solving::{derive_global_challenge, derive_local_challenge, SubspaceCodec};
Copy link
Member

Choose a reason for hiding this comment

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

It was an intentional decision to not import functions in the codebase anywhere. They often have generic names and thus it makes sense to instead import a module they are contained in (think channel() vs mpsc::channel()).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair for some common topics, but not sure it's wise to apply it globally default.

crates/subspace-solving/src/lib.rs Outdated Show resolved Hide resolved
crates/subspace-solving/src/lib.rs Outdated Show resolved Hide resolved
crates/pallet-subspace/src/mock.rs Outdated Show resolved Hide resolved
crates/sc-consensus-subspace/src/verification.rs Outdated Show resolved Hide resolved
crates/sc-consensus-subspace/src/lib.rs Outdated Show resolved Hide resolved
crates/sc-consensus-subspace/src/lib.rs Outdated Show resolved Hide resolved
crates/sc-consensus-subspace/src/verification.rs Outdated Show resolved Hide resolved
@liuchengxu
Copy link
Contributor Author

liuchengxu commented Nov 1, 2021

but I'm not so sure about splitting verification into multiple functions that just convert boolean to Result<>, it seems to me that it only makes it harder to read as a whole when things are split so far.

  • For me, the whole function can fit into the screen easily now, I don't have to scroll to have an overall idea of this function as long as these small function names make sense. If I want to dive into any part of the checking, I'll just jump into that private function.
  • schnorrkel::SignatureError now bubbles up when the signature is invalid.

@liuchengxu liuchengxu force-pushed the refactor-verify-solution branch 2 times, most recently from 7f6150e to b8d3c5f Compare November 1, 2021 15:50
@liuchengxu liuchengxu merged commit 31520f3 into main Nov 4, 2021
@liuchengxu liuchengxu deleted the refactor-verify-solution branch November 4, 2021 06:28
@liuchengxu liuchengxu mentioned this pull request Nov 4, 2021
12 tasks
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

2 participants