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

design: initial node on staking,slashing and delegation #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LHerskind
Copy link
Contributor

Providing a simple design for staking/slashing/delegation.

- The list MUST have no gaps to avoid issues with sampling
- The list MAY contain duplicate `proposer`
- MUST support adding a new operator to the list, given that they pass some permissionless anti-sybil mechanism
- MUST support punishing an operator in the set if the misbehave
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- MUST support punishing an operator in the set if the misbehave
- MUST support punishing an operator in the set if they misbehave

The `status` indicate whether the operator is currently `VALIDATING`, `LIVING` or `EXITING`:

- `VALIDATING` meaning that it is currently active,
- `LIVING` being that it is not participating in block production but also not exiting the system currently. It is possible to land in this state if a slash cause the validator to fall below the `MINIMUM_STAKE`.
Copy link
Member

Choose a reason for hiding this comment

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

LIMBO rather than LIVING?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, we can do that 🤷

The `SLASHER` can then be implemented as a variant of the `Governance.sol` contract, that skips the wider vote and allow direct execution of the payload if the validators agree. In this manner, the node software itself can be responsible for detecting misbehaviour and submitting slashing proposals, giving us a lot of flexibility as it is mainly off-chain code.

> [!info] Top-ups
> We are not supporting "topping up" the account, since it introduce a few additional code paths that we simple are not interested in for this minimal setup.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> We are not supporting "topping up" the account, since it introduce a few additional code paths that we simple are not interested in for this minimal setup.
> We are not supporting "topping up" the account, since it introduce a few additional code paths that we simply are not interested in for this minimal setup.


Joining and exiting is done directly on the contract, likely using a frontend or CLI but connected to a cold-storage wallet. These actions are seldom and deal with value so it is important to keep it safe.

As mentioned, the voting on slashing is to be done by the node itself by "slashing-modules". Essentially a small pieces of code that the node is running that will identify misbehaviour and submit or vote on slashing proposal. Votes are collected in the same manner as the `GovernanceProposer` used for governance proposals, with the caveat that if it is "to be proposed" it will go to the slasher where it becomes executable - it does not need to pass a normal governance vote.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
As mentioned, the voting on slashing is to be done by the node itself by "slashing-modules". Essentially a small pieces of code that the node is running that will identify misbehaviour and submit or vote on slashing proposal. Votes are collected in the same manner as the `GovernanceProposer` used for governance proposals, with the caveat that if it is "to be proposed" it will go to the slasher where it becomes executable - it does not need to pass a normal governance vote.
As mentioned, the voting on slashing is to be done by the node itself by "slashing-modules". Essentially a small pieces of code that the node is running that will identify misbehaviour and submit or vote on slashing proposal. Votes are collected in the same manner as the `GovernanceProposer` is used for governance proposals, with the caveat that if it is "to be proposed" it will go to the slasher where it becomes executable - it does not need to pass a normal governance vote.

// Living -> Not participating as validator, but have funds in setup,
// hit if slashes and going below the minimum
// Exiting -> In the process of exiting the system
enum ApeStatus { NONE, VALIDATING, LIVING, EXITING }
Copy link
Member

Choose a reason for hiding this comment

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

Ape?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

struct OperatorInfo {
uint256 stake;
address withdrawer;
address proposer;
Copy link
Member

Choose a reason for hiding this comment

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

bytes32 for proposer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

- `LIVING` being that it is not participating in block production but also not exiting the system currently. It is possible to land in this state if a slash cause the validator to fall below the `MINIMUM_STAKE`.
- `EXITING` the operator is currently waiting to exit or yet to claim the funds

The `withdrawer` is a separate actor, specified per operator that is able to initialise a removal of the operator from the set - without the help of the `proposer` or `attester`. The `withdrawer` can initiate a withdrawal of the `stake` to some `recipient`, moving the status from `VALIDATING|LIVING` to `EXITING`, removing the operator from the set and start the delay. After the delay, the funds can be relayed to the specified `recipient`. This ensure that it is possible to keep the "account in control" in cold store or be a contract itself - lending itself well to supporting LST's
Copy link
Contributor

Choose a reason for hiding this comment

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

Can withdrawer be a contract?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see it addressed below

constructor(address _slasher, ERC20 _stakingAsset, uint256 _minimumStake) {
SLASHER = _slasher;
STAKING_ASSET = _stakingAsset;
MINIMUM_STAKE = _minimumStake;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think previously we discussed having MINIMUM_STAKE specified by the Rollup instance instead of directly on the staking contract. Any thoughts on why this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

require(_args.amount >= MINIMUM_STAKE, "insufficient stake");
require(info[_args.attester].status == ApeStatus.NONE, "already registered");
// If BLS, need to check posession of private key to avoid attacks.
require(attesters.add(_args.attester), "already in set");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is entering the attester set expected to be immediate? Or is this supposed to be handled by the rollup via use of snapshots etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it is already immediate, so it was just kept that way. It is essentially unrelated to the staking itself.

The `SLASHER` can then be implemented as a variant of the `Governance.sol` contract, that skips the wider vote and allow direct execution of the payload if the validators agree. In this manner, the node software itself can be responsible for detecting misbehaviour and submitting slashing proposals, giving us a lot of flexibility as it is mainly off-chain code.

> [!info] Top-ups
> We are not supporting "topping up" the account, since it introduce a few additional code paths that we simple are not interested in for this minimal setup.
Copy link
Contributor

Choose a reason for hiding this comment

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

For validators that want to compound earnings, they must fire up another validator? Like Ethereum currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our setup there is 0 earnings benefit from increasing the balance of a validator. So ye, run multiple validators.

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.

design: minimal slashing design: minimal delegation
4 participants