Repository navigation
feat: support core 20 - #230
Conversation
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
fix: toJson method Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
…ltRiskAnalysis Signed-off-by: HashEngineering <[email protected]>
* Signatures and Keys are not a child objects Signed-off-by: HashEngineering <[email protected]>
* chore: deprecate default constructor Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
…essfully to each peer Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
…te managers Signed-off-by: HashEngineering <[email protected]>
* set current protocol to 70230 Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
* set v20 activation height in TestNet3Params Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
* This will help with masternode and quorum list sync when receiving transactions Signed-off-by: HashEngineering <[email protected]>
…Discovery Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feature-core-20 #230 +/- ##
=====================================================
+ Coverage 47.11% 47.50% +0.38%
- Complexity 6472 6580 +108
=====================================================
Files 408 408
Lines 45879 46144 +265
Branches 6481 6518 +37
=====================================================
+ Hits 21618 21919 +301
+ Misses 21891 21843 -48
- Partials 2370 2382 +12
☔ View full report in Codecov by Sentry. |
| Sha256Hash getHashModifier(LLMQParameters llmqParams, StoredBlock quorumBaseBlock) { | ||
| StoredBlock workBlock = getBlockAncestor(quorumBaseBlock, quorumBaseBlock.getHeight() - 8); | ||
|
|
||
| if (params.isV20Active(workBlock.getHeight())) { | ||
| // v20 is active: calculate modifier using the new way. | ||
| BLSSignature bestCLSignature = getCoinbaseChainlock(workBlock); | ||
| log.info("getHashModifier(..., {})\n work: {}\n sig: {}", quorumBaseBlock.getHeader().getHash(), workBlock.getHeader().getHash(), bestCLSignature); | ||
| if (bestCLSignature != null) { | ||
| // We have a non-null CL signature: calculate modifier using this CL signature | ||
|
|
||
| return LLMQUtils.buildLLMQBlockHash(llmqParams.getType(), workBlock.getHeight(), bestCLSignature); | ||
| } else { | ||
| log.info("cannot find CL for block {}", workBlock.getHeader().getHash()); | ||
| } | ||
| // No non-null CL signature found in coinbase: calculate modifier using block hash only | ||
| return LLMQUtils.buildLLMQBlockHash(llmqParams.getType(), workBlock.getHeader().getHash()); | ||
| } | ||
|
|
||
| // v20 isn't active yet: calculate modifier using the usual way | ||
| if (llmqParams.useRotation()) { | ||
| return LLMQUtils.buildLLMQBlockHash(llmqParams.getType(), workBlock.getHeader().getHash()); | ||
| } | ||
| return LLMQUtils.buildLLMQBlockHash(llmqParams.getType(), quorumBaseBlock.getHeader().getHash()); | ||
| } |
There was a problem hiding this comment.
This method calculates the hash value used to determine quorum membership.
| //0.14 format include quorum information | ||
| if(payload.length > cursor - offset) { |
There was a problem hiding this comment.
This if statement is removed because we don't need to support Dash Core 0.13 protocols
|
|
||
|
|
||
| public abstract class SpecialTxPayload extends Message { | ||
| public abstract class SpecialTxPayload extends ChildMessage { |
There was a problem hiding this comment.
ChildMessage contains a parent field.
| LinkedHashMap<Sha256Hash, ChainLockSignature> coinbaseChainlockMap = new LinkedHashMap<Sha256Hash, ChainLockSignature>() { | ||
| @Override | ||
| protected boolean removeEldestEntry(Map.Entry entry) { | ||
| return size() > 5000; | ||
| } | ||
| }; |
There was a problem hiding this comment.
This will be an in-memory-only hash table that associates a block with the coinbase chainlock signature.
| if (cursor < payload.length) { | ||
| // TODO: parse the chainlockMap here | ||
| } |
There was a problem hiding this comment.
This should be removed if there is no plan to save the chainlock maps.
| if (tx.getVersionShort() > Transaction.MAX_STANDARD_VERSION || tx.getVersionShort() < Transaction.MIN_STANDARD_VERSION || | ||
| tx.getType().getValue() >= Transaction.Type.TRANSACTION_TYPE_MAX.getValue()) { | ||
| log.warn("TX considered non-standard due to unknown version number {} or type {}", tx.getVersionShort(), tx.getType()); | ||
| return RuleViolation.VERSION; | ||
| } |
There was a problem hiding this comment.
without this change, a version 3 transaction with a type other than 0 would be counted as non-standard. One such example would be a coinbase transaction (type = 5).
| Sha256Hash modifier = LLMQUtils.buildLLMQBlockHash(llmqParameters.getType(), workBlock.getHeader().getHash()); | ||
| Sha256Hash modifier = getHashModifier(llmqParameters, cycleQuorumBaseBlock); |
There was a problem hiding this comment.
Any place where getHashModifier is used is a v20 change for DIP29.
Signed-off-by: HashEngineering <[email protected]>
| final StoredBlock workBlock = quorumBaseBlock.getAncestor(store, quorumBaseBlock.getHeight() - 8); | ||
| final Sha256Hash modifier = LLMQUtils.buildLLMQBlockHash(llmqType, workBlock.getHeader().getHash()); | ||
| final StoredBlock workBlock = cycleQuorumBaseBlock.getAncestor(store, cycleQuorumBaseBlock.getHeight() - 8); | ||
| final Sha256Hash modifier = getHashModifier(llmqParameters, cycleQuorumBaseBlock); |
There was a problem hiding this comment.
Another v20 change in getMNUsageBySnapshot
| public ArrayList<Masternode> getAllQuorumMembers(LLMQParameters.LLMQType llmqType, Sha256Hash blockHash) { | ||
| public ArrayList<Masternode> getAllQuorumMembers(LLMQParameters.LLMQType llmqType, Sha256Hash quorumBaseBlockHash) { | ||
| StoredBlock quorumBaseBlock = getBlockFromHash(quorumBaseBlockHash); | ||
| return computeQuorumMembers(llmqType, quorumBaseBlock); | ||
| } | ||
|
|
||
| protected ArrayList<Masternode> computeQuorumMembers(LLMQParameters.LLMQType llmqType, StoredBlock quorumBaseBlock) { | ||
| boolean evoOnly = (params.getLlmqPlatform() == llmqType) && params.isV19Active(quorumBaseBlock); | ||
| LLMQParameters llmqParameters = params.getLlmqs().get(llmqType); | ||
| SimplifiedMasternodeList allMns = getListForBlock(blockHash); | ||
| if (allMns != null) { | ||
| Sha256Hash modifier = LLMQUtils.buildLLMQBlockHash(llmqType, blockHash); | ||
| boolean hmpnOnly = (params.getLlmqPlatform() == llmqType) && params.isV19Active(allMns.getStoredBlock()); | ||
| return allMns.calculateQuorum(llmqParameters.getSize(), modifier, hmpnOnly); | ||
| checkNotNull(llmqParameters); | ||
| if (llmqParameters.useRotation() || quorumBaseBlock.getHeight() % llmqParameters.getDkgInterval() != 0) { | ||
| return Lists.newArrayList(); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| StoredBlock workBlock = params.isV20Active(quorumBaseBlock) ? | ||
| getBlockAncestor(quorumBaseBlock, quorumBaseBlock.getHeight() - 8) : | ||
| quorumBaseBlock; | ||
|
|
||
| Sha256Hash modifier = getHashModifier(llmqParameters, quorumBaseBlock); | ||
| SimplifiedMasternodeList allMns = getListForBlock(workBlock.getHeader().getHash()); | ||
| return allMns != null ? allMns.calculateQuorum(llmqParameters.getSize(), modifier, evoOnly) : null; | ||
| } |
There was a problem hiding this comment.
this is a refactor or non-rotated quorum membership calculation to match more closely to Core v20's code, but it also includes the update for v20 Change for DIP29 with getHashModifier..
| final StoredBlock workBlock = quorumBaseBlock.getAncestor(store, quorumBaseBlock.getHeight() - 8); | ||
|
|
||
| Sha256Hash modifier = LLMQUtils.buildLLMQBlockHash(llmqParameters.getType(), workBlock.getHeader().getHash()); | ||
| final StoredBlock workBlock = cycleQuorumBaseBlock.getAncestor(store, cycleQuorumBaseBlock.getHeight() - 8); | ||
| final Sha256Hash modifier = getHashModifier(llmqParameters, cycleQuorumBaseBlock); |
There was a problem hiding this comment.
v20 Change for DIP29.
Signed-off-by: HashEngineering <[email protected]>
Signed-off-by: HashEngineering <[email protected]>
| llmqTypePlatform = LLMQParameters.LLMQType.LLMQ_25_67; | ||
| llmqTypeDIP0024InstantSend = LLMQParameters.LLMQType.LLMQ_60_75; | ||
| llmqTypeMnhf = LLMQParameters.LLMQType.LLMQ_50_60; | ||
| llmqTypeAssetLocks = LLMQParameters.LLMQType.LLMQ_50_60; |
There was a problem hiding this comment.
Yes, it is the same quorum type. This is the code from Dash Core.
consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_50_60;
consensus.llmqTypeAssetLocks = Consensus::LLMQType::LLMQ_50_60;
Issue being fixed or feature implemented
What was done?
How Has This Been Tested?
Breaking Changes
Checklist:
For repository code-owners and collaborators only