Skip to content

Conversation

@jaoleal
Copy link
Collaborator

@jaoleal jaoleal commented Jan 13, 2025

After noticing that Consensus was just a wrapper for ChainParams and the file chain_params.rs was only holding some Dns related methods and the struct ChainParams alone, i made some changes to merge them and do some code organization/documentation.

Hope this helps to simplify our codebase.

@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 13, 2025

Since this can be a complicated PR to review, ill be commiting any changes and squashing them after tagging this as Ready to Merge

@jaoleal jaoleal force-pushed the merge_chainparams_to_consensus branch 3 times, most recently from e106055 to 759247c Compare January 22, 2025 14:48
@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 22, 2025

759247c applies linting too.

I dont think theres more work to be done here.

@jaoleal jaoleal marked this pull request as ready for review January 22, 2025 14:49
/// The parameters of the chain we are validating, it is usually hardcoded
/// constants. See [ChainParams] for more information.
pub parameters: ChainParams,
pub struct ConsensusParameters {
Copy link
Member

Choose a reason for hiding this comment

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

1c3a4aa

I'm not sure about this struct. I find it nicer to have the validation methods separated from parameters, like core does

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's interesting... But I also don't see the point in keeping just one struct if the function of this struct is just to be a wrapper of another one that is mainly used.
Maybe in another code reform we can make this separation... We talked in private about such a reform, I believe that this separation would ideally be addressed in this reform. What do you think?

),
}
}
/// Validates the locktime of a transaction input.
Copy link
Member

Choose a reason for hiding this comment

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

46dc77e
nit: empty line between the functions, and use the attribute before a comment.

@jaoleal jaoleal force-pushed the merge_chainparams_to_consensus branch from 759247c to 10e2cfa Compare January 24, 2025 15:25
@jaoleal jaoleal force-pushed the merge_chainparams_to_consensus branch from 10e2cfa to 53276a3 Compare January 24, 2025 15:27
@Davidson-Souza
Copy link
Member

This needs rebase. Also there are some functions that needs an empty line between them, like in the CONTRIBUTING file

@JoseSK999
Copy link
Contributor

Mmm I agree with @Davidson-Souza that the chain params should be in a different file, as they are right now (and as Core does). I think it is very important to keep the consensus functions and the params isolated in their own files.

The consensus.rs file will likely keep growing and it will be harder to audit if we have the params + assume-utreexo + assume-valid + DNS seeds as well.

@jaoleal jaoleal closed this Mar 6, 2025
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.

3 participants