Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Removing dead code from the consensus package #554

Merged
merged 16 commits into from
Jan 17, 2019
Merged

Removing dead code from the consensus package #554

merged 16 commits into from
Jan 17, 2019

Conversation

CjHare
Copy link
Contributor

@CjHare CjHare commented Jan 14, 2019

…lliJ

PR description

Removing code identified by the 'unused declaration' analysis in IntelliJ in the consensus package (main, test & integration-test)

@CjHare CjHare requested review from rain-on and jframe January 14, 2019 06:29
@CjHare CjHare changed the title Removing dead code from consensus package Removing dead code from the consensus package Jan 14, 2019

public class SignerRateLimitValidationRuleTest {

// Implicitly conducted by NodeCanProduceNextBlockTest.
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of deleting the test can we add a small test for this validation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...but if you have a test in mind, then don't let me stop you ;)

@@ -55,11 +55,6 @@ public void discard(final Address address) {
proposals.remove(address);
}

/** Discards all pending votes */
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to keep this here as a symmetry issue - i.e. even if not used, we should offer the functions assumed of a list style class.

Copy link
Contributor Author

@CjHare CjHare Jan 15, 2019

Choose a reason for hiding this comment

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

No.

On this point I could extoll the virtues of minimalism or the ideals of software craftmanship but ultimately it’s most basic form, it’s cost / benefit.

The intent of this class, like most others in the consensus package, are not to be packaged and published for general consumption as an API. (i.e. compare for example our approach to the libraries of Vertex, Spring or Apache commons).

The cost here is writing, testing (I know I’m assumptions there, which may, or may not hold true) and maintaining code.
What is the benefit? The code is not being used, it is not intended for public use as an API. In the future someone may have use it, but equally they may not.

When the benefit of something is close to zero, no matter the cost it’s a poor deal.

Does that perspective make sense?

@@ -137,10 +135,6 @@ public void setRoundChangeCertificate(final RoundChangeCertificate roundChangeCe
this.roundChangeCertificate = roundChangeCertificate;
}

public void setProposalPayload(final SignedData<ProposalPayload> proposalPayload) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given this is a builder, it should offer the ability to set all fields, even if not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will move & investigate on how it's used in the tests

@@ -51,18 +49,6 @@ public MessageValidator createMessageValidator(
parentHeader);
}

public RoundChangeMessageValidator createRoundChangeMessageValidator(
Copy link
Contributor

Choose a reason for hiding this comment

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

For completeness this should remain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should be using this in the RoundChangeManager instead of using the constructor.

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 do you mean? (I'm not seeing RoundChangeManager reference the MessageValidatorFactory)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussion outcome: will rollback this delete

@@ -227,20 +227,6 @@ public void lastestPreparedCertificateMatchesNewRoundProposalIsSuccessful() {
final SignedData<ProposalPayload> proposal =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock);

final ConsensusRoundIdentifier preparedRound =
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to go back in, the preparedCertificate should be being used in the RoundChange

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you saying that the test 'should' be using the preparedCert but wasn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...as the removed code, definitely was unreferenced.i.e. not being used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After discussion: will rewrite the test to have both certs in the proposal

@@ -1,42 +0,0 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Given this is from ibftLegacy, I'd be tempted to keep this - Legacy was never completed, so will have dead code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is IbftLegacy? Why keep code in the repo for functionality that was never completed?

@CjHare CjHare merged commit 8823d2e into PegaSysEng:master Jan 17, 2019
@CjHare CjHare deleted the removing_unused_code branch January 17, 2019 02:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants