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

Service node checkpointing: rebased on relaxed deregistration #662

Merged
merged 12 commits into from
Jun 26, 2019

Conversation

Doy-lee
Copy link
Collaborator

@Doy-lee Doy-lee commented Jun 24, 2019

This gets checkpointing back to feature parity from my ServiceNodeCheckpointing5 branch, i.e. fixing some synchronisation bugs that deleted checkpoints prematurely, adding checkpoints in the add_new_block step instead of wholesale in protocol handler stage.

Still no deregistration, this is all just manual merging what I had and using the new things setup in the relaxed registration.

Also fixes the unit_tests/core_tests that were not working and pop_blocks not calling the detached hooks persisting checkpoints after a reorg.

jagerman and others added 10 commits June 24, 2019 20:03
The replaces the deregistration mechanism with a new state change
mechanism (beginning at the v12 fork) which can change a service node's
network status via three potential values (and is extensible in the
future to handle more):

- deregistered -- this is the same as the existing deregistration; the
SN is instantly removed from the SN list.
- decommissioned -- this is a sort of temporary deregistration: your SN
remains in the service node list, but is removed from the rewards list
and from any network duties.
- recommissioned -- this tx is sent by a quorum if they observe a
decommissioned SN sending uptime proofs again.  Upon reception, the SN
is reactivated and put on the end of the reward list.

The new parameters added to service_node_rules.h control how this works:

    // Service node decommissioning: as service nodes stay up they earn "credits" (measured in blocks)
    // towards a future outage.  A new service node starts out with INITIAL_CREDIT, and then builds up
    // CREDIT_PER_DAY for each day the service node remains active up to a maximum of
    // DECOMMISSION_MAX_CREDIT.
    //
    // If a service node stops sending uptime proofs, a quorum will consider whether the service node
    // has built up enough credits (at least MINIMUM): if so, instead of submitting a deregistration,
    // it instead submits a decommission.  This removes the service node from the list of active
    // service nodes both for rewards and for any active network duties.  If the service node comes
    // back online (i.e. starts sending the required performance proofs again) before the credits run
    // out then a quorum will reinstate the service node using a recommission transaction, which adds
    // the service node back to the bottom of the service node reward list, and resets its accumulated
    // credits to 0.  If it does not come back online within the required number of blocks (i.e. the
    // accumulated credit at the point of decommissioning) then a quorum will send a permanent
    // deregistration transaction to the network, starting a 30-day deregistration count down.

This commit currently includes values (which are not necessarily
finalized):
- 8 hours (240 blocks) of credit required for activation of a
decommission (rather than a deregister)
- 0 initial credits at registration
- a maximum of 24 hours (720 blocks) of credits
- credits accumulate at a rate that you hit 24 hours of credits after 30
days of operation.

Miscellaneous other details of this PR:

- a new TX extra tag is used for the state change (including
deregistrations).  The old extra tag has no version or type tag, so
couldn't be reused.  The data in the new tag is slightly more
efficiently packed than the old deregistration transaction, so it gets
used for deregistrations (starting at the v12 fork) as well.

- Correct validator/worker selection required generalizing the shuffle
function to be able to shuffle just part of a vector.  This lets us
stick any down service nodes at the end of the potential list, then
select validators by only shuffling the part of the index vector that
contains active service indices.  Once the validators are selected, the
remainder of the list (this time including decommissioned SN indices) is
shuffled to select quorum workers to check, thus allowing decommisioned
nodes to be randomly included in the nodes to check without being
selected as a validator.

- Swarm recalculation was not quite right: swarms were recalculated on
SN registrations, even if those registrations were include shared node
registrations, but *not* recalculated on stakes.  Starting at v12 this
behaviour is fixed.
This moves the credit calculation into its own function so that the RPC
code can access it.
- revert storage of vote pools to a std::vector
- abstract service node tests into a single function (currently just
  checks uptime).
- fix various bugs related to state change vote submissions
- improved/added various debugging statements (at L2) in the voting,
  vote transmission, and vote reception code.
src/cryptonote_core/cryptonote_core.h Outdated Show resolved Hide resolved
src/p2p/net_node.inl Outdated Show resolved Hide resolved
src/cryptonote_core/tx_pool.cpp Outdated Show resolved Hide resolved
src/cryptonote_core/service_node_rules.h Outdated Show resolved Hide resolved
src/cryptonote_core/service_node_voting.cpp Outdated Show resolved Hide resolved
src/cryptonote_core/service_node_quorum_cop.cpp Outdated Show resolved Hide resolved
@Doy-lee Doy-lee merged commit fdc340b into oxen-io:dev Jun 26, 2019
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