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

Remove some duplicated types in RPC #115

Merged
merged 12 commits into from
Nov 7, 2021
Merged

Remove some duplicated types in RPC #115

merged 12 commits into from
Nov 7, 2021

Conversation

liuchengxu
Copy link
Contributor

I make it a draft PR because I'm unsure about some leftover on the duplicated types that unavoidably pull in some types from the substrate, e.g., public_key in Solution, slot in NewSlotInfo. Should be reviewed per commit.

Close #103

#[cfg_attr(feature = "std", derive(Debug))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
pub struct FarmerMetadata {
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 prefer it FarmerConfig or something as metadata is sort of a special word for me.

Suggested change
pub struct FarmerMetadata {
pub struct FarmerConfig {

Copy link
Member

Choose a reason for hiding this comment

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

Arguably this is closer to the core primitives, but not really. Another data structure that kind of belongs to a separate crate altogether.

It is called metadata because it is not a static configuration, but rather something that is derived from the blockchain itself. Maybe metadata is not the best word, but I don't feel like this is a configuration 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.

How about FarmerProperty? Also not good at naming though :D ...

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.

What do you think about creating a separate crate subspace-rpc-primitives or something like that and put these moved data structures and the rest of RPC-related data structures there?

crates/subspace-archiving/Cargo.toml Outdated Show resolved Hide resolved
crates/sc-consensus-subspace/src/lib.rs Outdated Show resolved Hide resolved
crates/subspace-core-primitives/src/lib.rs Outdated Show resolved Hide resolved
#[cfg_attr(feature = "std", derive(Debug))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
pub struct FarmerMetadata {
Copy link
Member

Choose a reason for hiding this comment

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

Arguably this is closer to the core primitives, but not really. Another data structure that kind of belongs to a separate crate altogether.

It is called metadata because it is not a static configuration, but rather something that is derived from the blockchain itself. Maybe metadata is not the best word, but I don't feel like this is a configuration either.

@liuchengxu
Copy link
Contributor Author

What do you think about creating a separate crate subspace-rpc-primitives or something like that and put these moved data structures and the rest of RPC-related data structures there?

Let's do that as I don't see any other solution at present.

crates/sc-consensus-subspace-rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/sc-consensus-subspace-rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/subspace-rpc-primitives/src/lib.rs Outdated Show resolved Hide resolved
crates/subspace-rpc-primitives/Cargo.toml Outdated Show resolved Hide resolved
nazar-pc
nazar-pc previously approved these changes Nov 7, 2021
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.

Thanks, let's squash on merge

@liuchengxu
Copy link
Contributor Author

liuchengxu commented Nov 7, 2021

let's squash on merge

Sure, always a fan of squash merge and I still think we should make it the default behavior :D. It's hard (at least for me) to maintain a pretty meaningful commit history per PR, and we'll also definitely have a lot of updates based on the review feedback. If we really want to know about the rationale bebind the code changes, we could go read the discussions under the related PR.

@nazar-pc
Copy link
Member

nazar-pc commented Nov 7, 2021

The challenge with using squash merge is that for complex changes it is impossible to understand what was happening after the fact from the main branch and going to PRs for every commit is also not very productive, it is much nicer to be able to use git directly to see the whole meaningful history. I think it is extremely important to see why things were changed, what was the thought process and how things were moved around instead of just seeing 2 snapshots with a lot of invisible intermediate steps in between.

For instance see https://github.com/subspace/subspace/pull/91/commits, there are just 2 commits: one moves code without meaningful changes (so you don't need to review it) and another implements what needed to be implemented. Initially it was ~8 commits where code was copied in modified form first, then changed a few times and then old version was replaced with a call to a new one. I think it is obvious what is easier to read and review, both in PR and in the main branch. If we squash those 2 commits then you can no longer skip reviewing both old and new code because you can't quickly distinguish what has changed and what hasn't. It also helps with git bisect when you refactor things, such that you can find where precisely something went wrong.

So while it is fine to squash merge simpler changes, for big changes it is extremely important IMHO to have useful history for prosperity and useful commits in the PR itself to save reviewer's time.

Don't get me wrong, I don't always create perfect commits right away either, but I try to put things into a better shape when PR time comes, such that squash merge is not needed as the result.

@liuchengxu
Copy link
Contributor Author

For the huge non-trivial code changes, we could split it into multiple meaningful PRs instead of maintaining multiple commits in one PR. I agree reading the PRs is probably less productive in some cases, but on the other hand, I believe it can convey more background by the discussions compared to using git directly.

The nice small diff could tell a lot, but won't tell everything. I'm not sure how you see the commit history of subspace and substrate, for me, the commit history of substrate gives much more clean useful information when I skim the commit history. Just a thought, I can live with the current merge process :D.

@nazar-pc
Copy link
Member

nazar-pc commented Nov 7, 2021

No offense to anyone, but when I see this from maintainers I want to cry: https://github.com/paritytech/substrate/pull/9394/commits and typically it gets merged with the same kinds of "useful" facepalms: paritytech/substrate@1d5abf0

So not everything other people do should necessarily be replicated.

@liuchengxu
Copy link
Contributor Author

liuchengxu commented Nov 7, 2021

Well, I'll ignore the other commit messages and they will be folded when being squash merge, the very first commit message that will be retained and displayed just makes sense and implies the meat of that PR. 🙈

@liuchengxu liuchengxu merged commit 004d401 into main Nov 7, 2021
@liuchengxu liuchengxu deleted the duplicated-types branch November 7, 2021 04:58
@liuchengxu liuchengxu mentioned this pull request Nov 7, 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.

Refactor the duplicated RPC types
2 participants