Skip to content

First part of DIP3 implementation - #2246

Merged
UdjinM6 merged 11 commits into
dashpay:developfrom
codablock:pr_dip3
Aug 30, 2018
Merged

First part of DIP3 implementation#2246
UdjinM6 merged 11 commits into
dashpay:developfrom
codablock:pr_dip3

Conversation

@codablock

@codablock codablock commented Aug 30, 2018

Copy link
Copy Markdown

This is extracted from #2083. It only contains ProRegTx, the deterministic masternode manager and RPCs for ProRegTx.

With this PR, it's possible to create, validate and mine ProRegTx on-chain. The commits in this PR have the refactorings included which happened later in #2083 squashed-in.

@UdjinM6 Please merge in non-squashed mode again :)

Allows easier commit/rollback handling, especially useful when AcceptBlock
fails and things need to be reverted.
@UdjinM6 UdjinM6 added this to the 12.4 milestone Aug 30, 2018

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See inline comments

Comment thread src/evo/providertx.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

proTx.nProtocolVersion > PROTOCOL_VERSION will cause old nodes to reject new MNs during every migration with protobump (and fork off). I doubt it's a good idea tbh.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah, forgot to apply a change that happened later in #2083. Will do in a few minutes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It was de51377 and I squashed that into this PR now

Comment thread src/evo/providertx.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is going to break IBD/reindex if/when we are going to bump CProRegTx::CURRENT_VERSION. ptx.nVersion > CProRegTx::CURRENT_VERSION would solve this for future versions but old nodes are still going to suffer and will reject MNs with new CProRegTx::CURRENT_VERSION (and fork off)... is this really what we want?

@codablock codablock Aug 30, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Whenever we bump CURRENT_VERSION, we'll have to use some kind of deployment logic...either BIP9 or a spork to activate it. So, new versions would only be allowed after it's ensured most of the network has upgraded. And at the same time, we'd modify this if to allow both versions (or only the new one after activation).

I fear that allowing ptx.nVersion >= CProRegTx::CURRENT_VERSION would allow people to put whatever version they want on-chain, making it later hard to do real version bumps.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

By ptx.nVersion > CProRegTx::CURRENT_VERSION I meant that we would reject any protx with version above currently known one while still accepting/processing the old ones. The logic for different/additional checks for new version protxes would then follow this one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah now I understand. I'll change it to ptx.nVersion > CProRegTx::CURRENT_VERSION then. In the case of bumping the version, the thing with the deployment logic applies. Or do I still miss something?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No, that's it - adding this fix is all I wanted for now (assuming that deployment logic for new version is smth to be added whenever we decide to actually bump it) :)

Comment thread src/evo/providertx.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should probably be uint16_t too?

Comment thread src/version.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

70210 and pre-70210 (mainnet) nodes are not able to recognise special txes, so 70211 maybe?

Comment thread src/evo/deterministicmns.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should be removed

@codablock
codablock force-pushed the pr_dip3 branch 3 times, most recently from 995268b to 72336d2 Compare August 30, 2018 14:54
@codablock

Copy link
Copy Markdown
Author

Applied review fixes (squashed into original commits)

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see inline comments

Comment thread src/evo/deterministicmns.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should be removed

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

let's follow naming convention for all the ints above

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

naming

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

naming

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

naming

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's maybe move non-oneliners/non-serialization/non-op implementations to cpp?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done, except for template functiond and the boost::adaptors stuff in CDeterministicMNList as I want to make sure these get inlined.

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

naming

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmmm... This is not what it seems to be at the first sight. I expected this to be a (max) number of cached entries but from CDeterministicMNManager::CleanupCache() code it seems that it's not the case and LISTS_CACHE_SIZE is actually a number of blocks to keep the cache. That's confusing imo. Why don't we actually define a size of a cache and store up to N recent entries instead of trying to figure out LISTS_CACHE_SIZE vs SNAPSHOT_LIST_PERIOD relationship to get the idea how many cache entries we are going to store?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This was my initial plan, but then I realized that someone might be able to come up with a way to rotate the cache multiple times in a single block, causing GetListForBlock to not use any cached entries and thus slow down block processing. Not sure if this would be really possible as of now, but if we ever introduce some special transaction that accesses old lists this might become an attack vector. So I preferred to use a caching mechanism that did a cleanup after block processing.

Just checked the implementation of CacheMap from cachemap.h. If we add a boolean template parameter to this map that disables automatic pruning and instead allows manual pruning, we could use that map implementation for this kind of "cleanup" behavior. What do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ok, the argument about organising cache this way makes sense, I agree.

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  1. this is actually a pointer
  2. state is already used as an instance of CValidationState all over the place

Let's maybe rename this to pdmnState or smth like that?

Same (confusing naming i.e. no p prefix) applies to a bunch of other *CPtrs actually but this one is the most confusing one imo.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll change this one for now but leave the other ones as they are. The "dmn" is used in all commits from #2083 and it will be a hell to fix this in all commits.

Comment thread src/evo/evodb.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: you should update your template to 2018 :)

@codablock

Copy link
Copy Markdown
Author

Pushed more review fixes, including the naming convention fixes. All as squashed changed.

I omitted the caching change for now and will add this later after we're done with the discussion.

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

utACK

Comment thread src/evo/deterministicmns.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ok, the argument about organising cache this way makes sense, I agree.

@UdjinM6
UdjinM6 merged commit 74629e4 into dashpay:develop Aug 30, 2018
UdjinM6 added a commit to UdjinM6/dash that referenced this pull request Oct 13, 2020
… register_*` to be known by the wallet

This requirement was introduced in the initial implementation when we were signing protx payload with the owner key (dashpay#2246). This was changed later when we implemented external collateral references (dashpay#2366). The owner key is not used for anything in ProTxReg but to get CKeyID since then which we can do by simply decoding an address instead. This simplifies masternode registration process by letting an Operator to issue `protx register_prepare` on its own instead of asking an Owner. An Owner still have to sign the message provided by an Operator with his collateral address to prove collateral ownership (and authorize masternode registration).

Note: `protx register_*` rpc will no longer accept privkeys for ownerAddress. Some 3-rd party software like DMT might need to be patched to work correctly with nodes running with this fix.
UdjinM6 added a commit that referenced this pull request Oct 28, 2020
… register_*` to be known by the wallet (#3773)

This requirement was introduced in the initial implementation when we were signing protx payload with the owner key (#2246). This was changed later when we implemented external collateral references (#2366). The owner key is not used for anything in ProTxReg but to get CKeyID since then which we can do by simply decoding an address instead. This simplifies masternode registration process by letting an Operator to issue `protx register_prepare` on its own instead of asking an Owner. An Owner still have to sign the message provided by an Operator with his collateral address to prove collateral ownership (and authorize masternode registration).

Note: `protx register_*` rpc will no longer accept privkeys for ownerAddress. Some 3-rd party software like DMT might need to be patched to work correctly with nodes running with this fix.
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 15, 2022
… register_*` to be known by the wallet

This requirement was introduced in the initial implementation when we were signing protx payload with the owner key (dashpay#2246). This was changed later when we implemented external collateral references (dashpay#2366). The owner key is not used for anything in ProTxReg but to get CKeyID since then which we can do by simply decoding an address instead. This simplifies masternode registration process by letting an Operator to issue `protx register_prepare` on its own instead of asking an Owner. An Owner still have to sign the message provided by an Operator with his collateral address to prove collateral ownership (and authorize masternode registration).

Note: `protx register_*` rpc will no longer accept privkeys for ownerAddress. Some 3-rd party software like DMT might need to be patched to work correctly with nodes running with this fix.
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.

4 participants