oxen-io / oxen-core

Oxen core repository, containing oxend and oxen cli wallets
https://oxen.io
Other
317 stars 120 forks source link

Exits and liquidations #1716

Closed Doy-lee closed 2 months ago

Doy-lee commented 2 months ago

A whole bunch of stuff, and, also a bunch of stuff that still needs to be done. But I've marked them as TODO.

The general gist is nodes that are deregistered by the protocol or those that have initiated a voluntary exit (and the necessary exit time has elapsed, UNLOCK_DURATION => 24hrs for stagenet, 15 days on mainnet), then nodes are erased from the SNL and moved into a staging buffer called the recently_removed_nodes list. This is an extension of what Sean started with but I've fleshed it out more.

All nodes in the recently_removed_nodes list are eligible to exit the smart contract by aggregating a signature from the network. If they don't exit in a timely manner (ETH_EXIT_BUFFER => 2hrs on stagenet, 1 week on mainnet), these nodes then become eligible to be liquidated.

Once eligible for exit/liquidation SN's will accept a request to sign a request to remove the node. You can then submit this to the smart contract and that will be witnessed by Oxen thereby removing it from the recently_removed_nodes.

I have some concerns about the SNL and smart contract going out of sync from potential bugs I haven't addressed here but we should mitigate. The smart contract has a stop-gap for this that it also starts, independently from the network a 30 day timer in which you can evict the a node from the smart contract without a signature. (Again another point of potential desync between the SNL and the smart contract).

But, the PR here should be good enough for the feature release and the remainder is more guarding against adversarial cases around the system.

Here's a short list of new things that need to be addressed:

jagerman commented 2 months ago

The smart contract has a stop-gap for this that it also starts, independently from the network a 30 day timer in which you can evict the a node from the smart contract without a signature. (Again another point of potential desync between the SNL and the smart contract).

I think this one is self-correcting: when removeBLSPublicKeyAfterWaitTime gets called we'll still a ServiceNodeRemoval event that should get witnessed and confirmed by Oxen. (But maybe Oxen currently rejects it, because it didn't see the unlock initiation?)

jagerman commented 2 months ago

Merging this as-is; we still have a bunch of TODO's as laid out in the PR description, but those will come in other PRs.