-
Notifications
You must be signed in to change notification settings - Fork 370
refactor milestone signature parameters to be configurable #1322
refactor milestone signature parameters to be configurable #1322
Conversation
|
||
if (milestoneIndex < 0 || milestoneIndex >= 0x200000) { | ||
if (milestoneIndex < 0 || milestoneIndex >= maxMilestoneIndex) { |
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 will allow higher depths of trees. (and tighter validation for lower trees)
} | ||
|
||
@JsonProperty("COORDINATOR_SIGNATURE_MODE") | ||
@Parameter(names = "--testnet-coordinator-signature-mode", description = MilestoneConfig.Descriptions.COORDINATOR_SIGNATURE_MODE) |
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 originally added a converter and validator, a la compass
https://github.com/iotaledger/compass/blob/3aaf05763cded4a229cc23f8e9cd3d53256948db/compass/conf/BaseConfiguration.java#L49
but the default validation is really good (see PR::test)
/** | ||
* @return {@value Descriptions#NUMBER_OF_KEYS_IN_A_MILESTONE} | ||
*/ | ||
int getNumberOfKeysInMilestone(); |
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.
Maybe add default value to the description like in #1159?
private ConsensusConfig config; | ||
private boolean skipValidation; | ||
|
||
private int maxMilestoneIndex; |
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.
Why did you decide to extract those from the config object and not just use the getters like before.
In my opinion this just saves lots of lines of code...
I think the nicer thing to do is to have HashFactory.ADDRESS.create(config.getCoordinator())
.
I suppose maxMilestoneIndex = 1 << config.getNumberOfKeysInMilestone();
can also be done as an automatically calculated config in my opinion.
The thing is that if we do this change here, we will have to do the same design in the rest of the code.
So what I am asking for you is either:
- Explain why you think it is better to not use config getters. In this case then I insist that at least the fields will be
final
. According to DDD services should be stateless. I say that at the very least they should be immutable. (TheHash
field won't be immutable, as you well know, but we will solve it) - Move everything back to the config and use getters (what I prefer). There is a reason why the setters are not visible
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.
It may be interesting to have a MilestoneService instance that can validate milestones coming from another coo than the one configured (wink, wink ...)
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.
The reason is that these parameters are fetched, constructed and calculated often. I think it's not efficient to do that, but I get the point of not storing state.
Anyways, I'm not sure I'll be available this week to make the change, if you find time to do it great, if not I'll update when I get to it.
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 wouldn't expect this to be the bottleneck in any scenario.
Doing a get
should be really fast
I would expect that the HotSpots compiler will optimize inefficiencies that occur
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.
Ready for configurable!
private ConsensusConfig config; | ||
private boolean skipValidation; | ||
|
||
private int maxMilestoneIndex; |
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.
It may be interesting to have a MilestoneService instance that can validate milestones coming from another coo than the one configured (wink, wink ...)
coordinatorSignatureMode = config.getCoordinatorSignatureMode(); | ||
coordinatorSecurityLevel = config.getCoordinatorSecurityLevel(); | ||
numberOfKeysInMilestone = config.getNumberOfKeysInMilestone(); | ||
skipValidation = (config.isTestnet() && config.isDontValidateTestnetMilestoneSig()); |
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.
Avoids very very ugly line
# Conflicts: # src/main/java/com/iota/iri/service/milestone/impl/MilestoneServiceImpl.java
bd6b8b5
to
458a5e4
Compare
a1cb46f
to
78d7d64
Compare
78d7d64
to
0b2698c
Compare
great changes! Approved. |
Description
Refactor of milestone signatures to allow easy configuration of a different Coordinator.
with higher Merkle tree depth.
Fixes # (issue)
Type of change
How Has This Been Tested?
--testnet-coordinator-signature-mode
a bad value, likeKERM
would give the following error: