-
Notifications
You must be signed in to change notification settings - Fork 867
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
Added log for validator selection mode transition #2909
Conversation
...qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/QbftTransitionNotifier.java
Outdated
Show resolved
Hide resolved
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class QbftTransitionNotifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more specific than ordinary transitions, perhaps QbftValidatorSelectionTransitionLogger? Though is rather a long name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's already in the qbft package, can we drop the Qbft?
Another suggestion: ValidatorModeTransitionLogger...'mode' has been used elsewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with ValidatorModeTransitionLogger
this.msgConsumer = msgConsumer; | ||
} | ||
|
||
public void checkTransitionChange(final BlockHeader parentHeader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really checking anything it doesn't return a value. Maybe just logTransitionChange?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
private String parseConfigToLog(final QbftConfigOptions configOptions) { | ||
if (configOptions.getValidatorContractAddress().isPresent()) { | ||
return String.format("ADDRESS(%s)", configOptions.getValidatorContractAddress().get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract mode (%s) instead of ADDRESS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make this clear it's the validator contract address? In case someone who doesn't know the detail of how this feature works may read the log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can expect that operators (people running Besu nodes) have a fair bit of knowledge. If they are using a feature that requires smart contracts etc. they need to know what they are doing.
if (configOptions.getValidatorContractAddress().isPresent()) { | ||
return String.format("ADDRESS(%s)", configOptions.getValidatorContractAddress().get()); | ||
} else { | ||
return "BLOCKHEADER"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blockheader mode instead of BLOCKHEADER in caps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw we already have the word mode
in the phrase.
|
||
return !currentConfig | ||
.getValidatorContractAddress() | ||
.equals(nextConfig.getValidatorContractAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: equalsignorecase??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make more sense to normalize this inside QbftConfigOptions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
} | ||
|
||
@VisibleForTesting | ||
public QbftTransitionNotifier( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could be package-private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
private static final Logger LOG = LogManager.getLogger(); | ||
|
||
private final BftForksSchedule<QbftConfigOptions> bftForksSchedule; | ||
private final Consumer<String> msgConsumer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this pattern as a way of testing logging 👍
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
a6ae00b
to
dd4299a
Compare
this.roundFactory = roundFactory; | ||
this.finalState = finalState; | ||
this.messageValidatorFactory = messageValidatorFactory; | ||
this.messageFactory = messageFactory; | ||
this.qbftTransitionNotifier = validatorModeTransitionLogger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the field name be updated to match the constructor arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops!
BftForkSpec<BftConfigOptions> forkSpecA = | ||
new BftForkSpec<>(0, createQbftConfigOptionsForBlockHeader()); | ||
BftForkSpec<BftConfigOptions> forkSpecB = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these can be made final in all the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
* Added log for validator selection mode transition Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
* Added log for validator selection mode transition Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
PR description
QbftTransitionNotifier
QbftBlockHeighManager
in the corresponding factory. That means that we notify before the transition actually happens, to help diagnose any issues with the transition that is about to happen (e.g. wrong address for the validator contract).Example messages:
Fixed Issue(s)
fixes #2784
Changelog