Skip to content
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

chore(release): bump version to v2.4.11 #514

Merged
merged 21 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DashSync.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Pod::Spec.new do |s|
s.ios.framework = 'UIKit'
s.macos.framework = 'Cocoa'
s.compiler_flags = '-Wno-comma'
s.dependency 'DashSharedCore', '0.4.10'
s.dependency 'DashSharedCore', '0.4.11'
s.dependency 'CocoaLumberjack', '3.7.2'
s.ios.dependency 'DWAlertController', '0.2.1'
s.dependency 'DSDynamicOptions', '0.1.2'
Expand Down
4 changes: 2 additions & 2 deletions DashSync/shared/DashSync.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ - (void)startSyncForChain:(DSChain *)chain {
- (void)stopSyncAllChains {
NSArray *chains = [[DSChainsManager sharedInstance] chains];
for (DSChain *chain in chains) {
[[[DSChainsManager sharedInstance] chainManagerForChain:chain].peerManager disconnect];
[[[DSChainsManager sharedInstance] chainManagerForChain:chain].peerManager disconnect: DSDisconnectReason_ChainWipe];
}
}

Expand All @@ -136,7 +136,7 @@ - (void)wipePeerDataForChain:(DSChain *)chain inContext:(NSManagedObjectContext

[self stopSyncForChain:chain];
[[[DSChainsManager sharedInstance] chainManagerForChain:chain].peerManager removeTrustedPeerHost];
[[[DSChainsManager sharedInstance] chainManagerForChain:chain].peerManager clearPeers];
[[[DSChainsManager sharedInstance] chainManagerForChain:chain].peerManager clearPeers:DSDisconnectReason_ChainWipe];
[context performBlockAndWait:^{
DSChainEntity *chainEntity = [chain chainEntityInContext:context];
[DSPeerEntity deletePeersForChainEntity:chainEntity];
Expand Down
562 changes: 276 additions & 286 deletions DashSync/shared/Models/Chain/DSChain.m

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)updateAttributesFromSimplifiedMasternodeEntry:(DSSimplifiedMasternodeEnt

- (void)updateAttributesFromSimplifiedMasternodeEntry:(DSSimplifiedMasternodeEntry *)simplifiedMasternodeEntry atBlockHeight:(uint32_t)blockHeight knownOperatorAddresses:(NSDictionary<NSString *, DSAddressEntity *> *)knownOperatorAddresses knownVotingAddresses:(NSDictionary<NSString *, DSAddressEntity *> *)knownVotingAddresses localMasternodes:(NSDictionary<NSData *, DSLocalMasternodeEntity *> *)localMasternodes {
if (self.updateHeight < blockHeight) {
NSAssert(simplifiedMasternodeEntry.updateHeight == blockHeight, @"the block height should be the same as the entry update height");
//NSAssert(simplifiedMasternodeEntry.updateHeight == blockHeight, @"the block height should be the same as the entry update height");
pankcuf marked this conversation as resolved.
Show resolved Hide resolved
self.updateHeight = blockHeight;
//we should only update if the data received is the most recent
if (!uint128_eq(self.ipv6Address.UInt128, simplifiedMasternodeEntry.address)) {
Expand Down
18 changes: 11 additions & 7 deletions DashSync/shared/Models/Managers/Chain Managers/DSChainManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,8 @@ - (double)combinedSyncProgress {
DSLog(@"combinedSyncProgress breakdown %f %f %f", self.terminalHeaderSyncProgress, self.masternodeManager.masternodeListAndQuorumsSyncProgress, self.chainSyncProgress);
#endif
if ((self.terminalHeaderSyncWeight + self.chainSyncWeight + self.masternodeListSyncWeight) == 0) {
if (self.peerManager.connected) {
return 1;
} else {
return 0;
@synchronized (self.peerManager) {
return self.peerManager.connected ? 1 : 0;
}
} else {
double progress = self.terminalHeaderSyncProgress * self.terminalHeaderSyncWeight + self.masternodeManager.masternodeListAndQuorumsSyncProgress * self.masternodeListSyncWeight + self.chainSyncProgress * self.chainSyncWeight;
Expand Down Expand Up @@ -471,11 +469,12 @@ - (void)startSync {
object:nil
userInfo:@{DSChainManagerNotificationChainKey: self.chain}];
});
DSLog(@"startSync -> peerManager::connect");
[self.peerManager connect];
}

- (void)stopSync {
[self.peerManager disconnect];
[self.peerManager disconnect:DSDisconnectReason_ChainSwitch];
self.syncPhase = DSChainSyncPhase_Offline;
}

Expand All @@ -497,6 +496,7 @@ - (void)disconnectedMasternodeListAndBlocksRescan {
object:nil
userInfo:@{DSChainManagerNotificationChainKey: self.chain}];
});
DSLog(@"disconnectedMasternodeListAndBlocksRescan -> peerManager::connect");
[self.peerManager connect];
}

Expand All @@ -510,6 +510,7 @@ - (void)disconnectedMasternodeListRescan {
object:nil
userInfo:@{DSChainManagerNotificationChainKey: self.chain}];
});
DSLog(@"disconnectedMasternodeListRescan -> peerManager::connect");
[self.peerManager connect];
}

Expand All @@ -523,6 +524,7 @@ - (void)disconnectedSyncBlocksRescan {
object:nil
userInfo:@{DSChainManagerNotificationChainKey: self.chain}];
});
DSLog(@"disconnectedSyncBlocksRescan -> peerManager::connect");
[self.peerManager connect];
}

Expand Down Expand Up @@ -650,7 +652,8 @@ - (void)chainShouldStartSyncingBlockchain:(DSChain *)chain onPeer:(DSPeer *)peer
}

- (void)chainFinishedSyncingInitialHeaders:(DSChain *)chain fromPeer:(DSPeer *)peer onMainChain:(BOOL)onMainChain {
if (onMainChain && peer && (peer == self.peerManager.downloadPeer)) self.lastChainRelayTime = [NSDate timeIntervalSince1970];
if (onMainChain && peer && (peer == self.peerManager.downloadPeer)) [self relayedNewItem];

[self.peerManager chainSyncStopped];
if (([[DSOptionsManager sharedInstance] syncType] & DSSyncType_MasternodeList)) {
// make sure we care about masternode lists
Expand All @@ -659,7 +662,7 @@ - (void)chainFinishedSyncingInitialHeaders:(DSChain *)chain fromPeer:(DSPeer *)p
}

- (void)chainFinishedSyncingTransactionsAndBlocks:(DSChain *)chain fromPeer:(DSPeer *)peer onMainChain:(BOOL)onMainChain {
if (onMainChain && peer && (peer == self.peerManager.downloadPeer)) self.lastChainRelayTime = [NSDate timeIntervalSince1970];
if (onMainChain && peer && (peer == self.peerManager.downloadPeer)) [self relayedNewItem];
DSLog(@"chain finished syncing");
self.chainSyncStartHeight = 0;
self.syncPhase = DSChainSyncPhase_Synced;
Expand All @@ -678,6 +681,7 @@ - (void)syncBlockchain {
if (self.syncPhase == DSChainSyncPhase_InitialTerminalBlocks) {
self.syncPhase = DSChainSyncPhase_ChainSync;
}
DSLog(@"syncBlockchain -> peerManager::connect");
[self.peerManager connect];
} else if (!self.peerManager.masternodeList && self.masternodeManager.currentMasternodeList) {
[self.peerManager useMasternodeList:self.masternodeManager.currentMasternodeList withConnectivityNonce:self.sessionConnectivityNonce];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ - (DSGovernanceVote *)peer:(DSPeer *_Nullable)peer requestedVote:(UInt256)voteHa

- (void)peer:(DSPeer *)peer ignoredGovernanceSync:(DSGovernanceRequestState)governanceRequestState {
[self.peerManager peerMisbehaving:peer errorMessage:@"Ignored Governance Sync"];
DSLog(@"ignoredGovernanceSync -> peerManager::connect");
[self.peerManager connect];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ - (uint32_t)estimatedMasternodeListsToSync {
}

- (double)masternodeListAndQuorumsSyncProgress {
double amountLeft = self.masternodeListRetrievalQueueCount;
double maxAmount = self.masternodeListRetrievalQueueMaxAmount;
if (!amountLeft) {
return self.store.masternodeListsAndQuorumsIsSynced;
@synchronized (self) {
double amountLeft = self.masternodeListRetrievalQueueCount;
double maxAmount = self.masternodeListRetrievalQueueMaxAmount;
if (!amountLeft) {
return self.store.masternodeListsAndQuorumsIsSynced;
}
double progress = MAX(MIN((maxAmount - amountLeft) / maxAmount, 1), 0);
return progress;
}
double progress = MAX(MIN((maxAmount - amountLeft) / maxAmount, 1), 0);
return progress;
}

- (BOOL)currentMasternodeListIsInLast24Hours {
Expand Down Expand Up @@ -361,7 +363,9 @@ - (BOOL)requestMasternodeListForBlockHeight:(uint32_t)blockHeight error:(NSError
- (BOOL)requestMasternodeListForBlockHash:(UInt256)blockHash {
self.store.lastQueriedBlockHash = blockHash;
NSData *blockHashData = uint256_data(blockHash);
[self.store.masternodeListQueriesNeedingQuorumsValidated addObject:blockHashData];
@synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) {
[self.store.masternodeListQueriesNeedingQuorumsValidated addObject:blockHashData];
}
// this is safe
[self getMasternodeListsForBlockHashes:[NSOrderedSet orderedSetWithObject:blockHashData]];
return TRUE;
Expand Down Expand Up @@ -501,14 +505,21 @@ - (void)processMasternodeListDiffResult:(DSMnDiffProcessingResult *)result forPe
DSLog(@"•••• processMasternodeListDiffResult: missingMasternodeLists: %@", [self logListSet:neededMissingMasternodeLists]);
UInt256 masternodeListBlockHash = masternodeList.blockHash;
NSData *masternodeListBlockHashData = uint256_data(masternodeListBlockHash);
if ([neededMissingMasternodeLists count] && [self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:masternodeListBlockHashData]) {
BOOL hasAwaitingQuorumValidation;
@synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) {
hasAwaitingQuorumValidation = [self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:masternodeListBlockHashData];
}

if ([neededMissingMasternodeLists count] && hasAwaitingQuorumValidation) {
[self.masternodeListDiffService removeFromRetrievalQueue:masternodeListBlockHashData];
[self processMissingMasternodeLists:neededMissingMasternodeLists forMasternodeList:masternodeList];
completion();
} else {
if (uint256_eq(self.store.lastQueriedBlockHash, masternodeListBlockHash)) {
self.masternodeListDiffService.currentMasternodeList = masternodeList;
[self.store.masternodeListQueriesNeedingQuorumsValidated removeObject:masternodeListBlockHashData];
@synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) {
[self.store.masternodeListQueriesNeedingQuorumsValidated removeObject:masternodeListBlockHashData];
}
}
DSLog(@"••• updateStoreWithMasternodeList: %u: %@ (%@)", masternodeList.height, uint256_hex(masternodeListBlockHash), uint256_reverse_hex(masternodeListBlockHash));
[self updateStoreWithMasternodeList:masternodeList addedMasternodes:result.addedMasternodes modifiedMasternodes:result.modifiedMasternodes addedQuorums:result.addedQuorums completion:^(NSError *error) {
Expand Down Expand Up @@ -579,47 +590,53 @@ - (void)processQRInfoResult:(DSQRInfoProcessingResult *)result forPeer:(DSPeer *
NSData *blockHashDataAtH2C = uint256_data(blockHashAtH2C);
NSData *blockHashDataAtH3C = uint256_data(blockHashAtH3C);
NSData *blockHashDataAtH4C = uint256_data(blockHashAtH4C);
NSMutableSet<NSData *> *masternodeListQueriesNeedingQuorumsValidated;
@synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) {
masternodeListQueriesNeedingQuorumsValidated = self.store.masternodeListQueriesNeedingQuorumsValidated;
}
if (![self.quorumRotationService shouldProcessDiffResult:mnListDiffResultAtH4C skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else if (![missingMasternodeListsAtH4C count] || ![self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH4C]) {
} else if (![missingMasternodeListsAtH4C count] || ![masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH4C]) {
DSLog(@"••• updateStoreWithMasternodeList (h-4c): %u: %@ (%@)", masternodeListAtH4C.height, uint256_hex(blockHashAtH4C), uint256_reverse_hex(blockHashAtH4C));
[self updateStoreWithMasternodeList:masternodeListAtH4C addedMasternodes:mnListDiffResultAtH4C.addedMasternodes modifiedMasternodes:mnListDiffResultAtH4C.modifiedMasternodes addedQuorums:mnListDiffResultAtH4C.addedQuorums completion:^(NSError *error) {}];
}
if (![self.quorumRotationService shouldProcessDiffResult:mnListDiffResultAtH3C skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else if (![missingMasternodeListsAtH3C count] || ![self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH3C]) {
} else if (![missingMasternodeListsAtH3C count] || ![masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH3C]) {
DSLog(@"••• updateStoreWithMasternodeList (h-3c): %u: %@ (%@)", masternodeListAtH3C.height, uint256_hex(blockHashAtH3C), uint256_reverse_hex(blockHashAtH3C));
[self updateStoreWithMasternodeList:masternodeListAtH3C addedMasternodes:mnListDiffResultAtH3C.addedMasternodes modifiedMasternodes:mnListDiffResultAtH3C.modifiedMasternodes addedQuorums:mnListDiffResultAtH3C.addedQuorums completion:^(NSError *error) {}];
}
if (![self.quorumRotationService shouldProcessDiffResult:mnListDiffResultAtH2C skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else if (![missingMasternodeListsAtH2C count] || ![self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH2C]) {
} else if (![missingMasternodeListsAtH2C count] || ![masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH2C]) {
DSLog(@"••• updateStoreWithMasternodeList (h-2c): %u: %@ (%@)", masternodeListAtH2C.height, uint256_hex(blockHashAtH2C), uint256_reverse_hex(blockHashAtH2C));
[self updateStoreWithMasternodeList:masternodeListAtH2C addedMasternodes:mnListDiffResultAtH2C.addedMasternodes modifiedMasternodes:mnListDiffResultAtH2C.modifiedMasternodes addedQuorums:mnListDiffResultAtH2C.addedQuorums completion:^(NSError *error) {}];
}
if (![self.quorumRotationService shouldProcessDiffResult:mnListDiffResultAtHC skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else if (![missingMasternodeListsAtHC count] || ![self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtHC]) {
} else if (![missingMasternodeListsAtHC count] || ![masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtHC]) {
DSLog(@"••• updateStoreWithMasternodeList (h-c): %u: %@ (%@)", masternodeListAtHC.height, uint256_hex(blockHashAtHC), uint256_reverse_hex(blockHashAtHC));
[self updateStoreWithMasternodeList:masternodeListAtHC addedMasternodes:mnListDiffResultAtHC.addedMasternodes modifiedMasternodes:mnListDiffResultAtHC.modifiedMasternodes addedQuorums:mnListDiffResultAtHC.addedQuorums completion:^(NSError *error) {}];
}
if (![self.quorumRotationService shouldProcessDiffResult:mnListDiffResultAtH skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else if (![missingMasternodeListsAtH count] || ![self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH]) {
} else if (![missingMasternodeListsAtH count] || ![masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtH]) {
DSLog(@"••• updateStoreWithMasternodeList (h): %u: %@ (%@)", masternodeListAtH.height, uint256_hex(blockHashAtH), uint256_reverse_hex(blockHashAtH));
[self updateStoreWithMasternodeList:masternodeListAtH addedMasternodes:mnListDiffResultAtH.addedMasternodes modifiedMasternodes:mnListDiffResultAtH.modifiedMasternodes addedQuorums:mnListDiffResultAtH.addedQuorums completion:^(NSError *error) {}];
}

if (![self.quorumRotationService shouldProcessDiffResult:mnListDiffResultAtTip skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else {
if ([missingMasternodeListsAtTip count] && [self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtTip]) {
if ([missingMasternodeListsAtTip count] && [masternodeListQueriesNeedingQuorumsValidated containsObject:blockHashDataAtTip]) {
[self.quorumRotationService removeFromRetrievalQueue:blockHashDataAtTip];
[self processMissingMasternodeLists:missingMasternodeLists forMasternodeList:masternodeListAtTip];
} else {
if (uint256_eq(self.store.lastQueriedBlockHash, blockHashAtTip)) {
self.quorumRotationService.currentMasternodeList = masternodeListAtTip;
[self.store.masternodeListQueriesNeedingQuorumsValidated removeObject:blockHashDataAtTip];
@synchronized (self.store.masternodeListQueriesNeedingQuorumsValidated) {
[self.store.masternodeListQueriesNeedingQuorumsValidated removeObject:blockHashDataAtTip];
}
}
DSLog(@"••• updateStoreWithMasternodeList (tip): %u: %@ (%@)", masternodeListAtTip.height, uint256_hex(blockHashAtTip), uint256_reverse_hex(blockHashAtTip));
[self updateStoreWithMasternodeList:masternodeListAtTip addedMasternodes:mnListDiffResultAtTip.addedMasternodes modifiedMasternodes:mnListDiffResultAtTip.modifiedMasternodes addedQuorums:mnListDiffResultAtTip.addedQuorums completion:^(NSError *error) {}];
Expand All @@ -639,7 +656,7 @@ - (void)processQRInfoResult:(DSQRInfoProcessingResult *)result forPeer:(DSPeer *
NSData *diffBlockHashData = uint256_data(diffBlockHash);
if (![self.quorumRotationService shouldProcessDiffResult:diffResult skipPresenceInRetrieval:YES]) {
[self.quorumRotationService issueWithMasternodeListFromPeer:peer];
} else if (![diffResult.neededMissingMasternodeLists count] || ![self.store.masternodeListQueriesNeedingQuorumsValidated containsObject:diffBlockHashData]) {
} else if (![diffResult.neededMissingMasternodeLists count] || ![masternodeListQueriesNeedingQuorumsValidated containsObject:diffBlockHashData]) {
[self updateStoreWithMasternodeList:diffMasternodeList addedMasternodes:diffResult.addedMasternodes modifiedMasternodes:diffResult.modifiedMasternodes addedQuorums:diffResult.addedQuorums completion:^(NSError *error) {}];
}
}
Expand Down Expand Up @@ -684,7 +701,9 @@ - (void)updateStoreWithMasternodeList:(DSMasternodeList *)masternodeList addedMa

- (void)peer:(DSPeer *)peer relayedMasternodeDiffMessage:(NSData *)message {
DSLog(@"•••• -> received mnlistdiff: %@", uint256_hex(message.SHA256));
self.masternodeListDiffService.timedOutAttempt = 0;
@synchronized (self.masternodeListDiffService) {
self.masternodeListDiffService.timedOutAttempt = 0;
}
dispatch_async(self.processingQueue, ^{
dispatch_group_enter(self.processingGroup);
DSMasternodeProcessorContext *ctx = [self createDiffMessageContext:self.chain.isTestnet isFromSnapshot:NO isDIP0024:NO peer:peer merkleRootLookup:^UInt256(UInt256 blockHash) {
Expand Down Expand Up @@ -719,7 +738,9 @@ - (void)peer:(DSPeer *)peer relayedMasternodeDiffMessage:(NSData *)message {

- (void)peer:(DSPeer *)peer relayedQuorumRotationInfoMessage:(NSData *)message {
DSLog(@"•••• -> received qrinfo: %@", uint256_hex(message.SHA256));
self.quorumRotationService.timedOutAttempt = 0;
@synchronized (self.quorumRotationService) {
self.quorumRotationService.timedOutAttempt = 0;
}
dispatch_async(self.processingQueue, ^{
dispatch_group_enter(self.processingGroup);
MerkleRootFinder merkleRootLookup = ^UInt256(UInt256 blockHash) {
Expand Down
Loading