Skip to content

Masternode related refactorings in preparation of DIP3#2212

Merged
UdjinM6 merged 7 commits intodashpay:developfrom
codablock:pr_dip3_masternoderefactorings
Aug 11, 2018
Merged

Masternode related refactorings in preparation of DIP3#2212
UdjinM6 merged 7 commits intodashpay:developfrom
codablock:pr_dip3_masternoderefactorings

Conversation

@codablock
Copy link

@codablock codablock commented Aug 10, 2018

This is a set of commits extracted from #2083. These are mostly independent from DIP3 and can thus be merged before.

These refactorings are included:

Split CActiveMasternode into CActiveMasternodeInfo and CLegacyActiveMasternodeManager

This splits out the locally active masternode's state into it's own class/object. The actual handling/management of the active masternode is now in CLegacyActiveMasternodeManager. DIP3 will later introduce a new manager, which is then responsible for the deterministic version of the active masternode. After DIP3 deployment is completed, a cleanup PR will remove the legacy masternode manager.

## Update masternode outpoint in case a MNB arrives with a changed outpoint
This is not really a refactoring but a new feature. It allows to restart a masternode based on a new collateral. This is likely not so useful for regular MNOs, but quite useful for integration tests and large devnets as it avoids restarting of MNs.

Use CKeyID instead of CPubKey whenever possible in masternode code

This avoids using CPubKey when actually only the key hash is enough. This gets important in DIP3 when the masternode key is split into multiple keys and DIP3 special transactions actually never include the full public key but only the key hash.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

757b6e5 doesn't fit refactoring title (and I don't quite understand the need for it tbh), should be removed from this PR imo. See other comments below.

Copy link

Choose a reason for hiding this comment

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

Should probably change the name to activeMasternodeInfo for it to be a bit more descriptive.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm agree. I tried to reduce the number of changed lines so I left this out 🙈
Adding new commit on top for this.

Copy link

Choose a reason for hiding this comment

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

s/class/struct/

Copy link

Choose a reason for hiding this comment

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

Should drop pub prefix i.e. s/pubKeyIDMasternode/keyIDMasternode/. Same for all other new CKeyIDs.

Copy link
Author

Choose a reason for hiding this comment

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

Done in separate commits. I'll probably go crazy because of this when doing the rebase of DIP3 🙈 :D

@UdjinM6 UdjinM6 added this to the 12.4 milestone Aug 10, 2018
@codablock codablock force-pushed the pr_dip3_masternoderefactorings branch from 1885332 to 6a6e9a6 Compare August 10, 2018 12:15
@codablock
Copy link
Author

Done the suggested renaming and removed 757b6e5. I don't remember exactly anymore why/when it was needed, will have to figure this out again later when doing the DIP3 rebase.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

@UdjinM6
Copy link

UdjinM6 commented Aug 10, 2018

Needs rebase

@codablock codablock force-pushed the pr_dip3_masternoderefactorings branch from 6a6e9a6 to 9dd511f Compare August 11, 2018 13:16
@codablock
Copy link
Author

Rebased and fixed last nit (squashed into the original commit)

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

Fixes look 👍 Just noticed one more thing though, see below 🙈

READWRITE(addr);
READWRITE(pubKeyCollateralAddress);
READWRITE(pubKeyMasternode);
READWRITE(keyIDCollateralAddress);
Copy link

Choose a reason for hiding this comment

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

Should probably bump CMasternodeMan::SERIALIZATION_VERSION_STRING (masternodeman.cpp#L29) because of changes in serialization.

@UdjinM6
Copy link

UdjinM6 commented Aug 11, 2018

Build fails at

if (Lookup("127.0.0.1", activeMasternode.service, GetListenPort(), false)) {

activemasternode.cpp:164:33: error: 'activeMasternode' was not declared in this scope
         if (Lookup("127.0.0.1", activeMasternode.service, GetListenPort(), false)) {
                                 ^~~~~~~~~~~~~~~~
activemasternode.cpp:164:33: note: suggested alternative: 'activeMasternodeInfo'

@codablock
Copy link
Author

Whoops, sorry about that one. Resulted from the recent rebase...verifying fix locally now and then pushing again.

UdjinM6
UdjinM6 previously approved these changes Aug 11, 2018
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

Looks good now imo 👍

Let's see if Travis thinks the same :)

#include "primitives/transaction.h"

class CActiveMasternode;
class CActiveMasternodeInfo;
Copy link

Choose a reason for hiding this comment

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

Heh, compiling locally and

In file included from activemasternode.cpp:5:
./activemasternode.h:25:1: warning: 'CActiveMasternodeInfo' defined as a struct here but previously declared as a class [-Wmismatched-tags]
struct CActiveMasternodeInfo {
^
./activemasternode.h:13:1: note: did you mean struct here?
class CActiveMasternodeInfo;
^~~~~
struct
1 warning generated.

:)

Copy link
Author

Choose a reason for hiding this comment

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

These fancy Mac users :P
Added a commit to fix it ;)

Copy link

Choose a reason for hiding this comment

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

😛

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

re-utACK

@UdjinM6 UdjinM6 merged commit d946f21 into dashpay:develop Aug 11, 2018
@codablock codablock deleted the pr_dip3_masternoderefactorings branch September 14, 2018 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants