-
Notifications
You must be signed in to change notification settings - Fork 83
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
chore: staking python script #847
base: master
Are you sure you want to change the base?
Conversation
@nud3l tagging you at your request |
Thanks for this excellent summary! We got two options:
FixI need to think a bit about that one. @daniel-savu or @gregdhill do you have any ideas? Something for us to work on once we wrap up AMM, lending, and the capacity model. WorkaroundI think there are two options/directions:
Option 1 would be the only viable workaround to me. Overall, I think it's also an OK solution to have an upper bound on nominators. Worst case, vault operators would just need to spin up multiple vaults to get more nominators. |
Option 1 does not work well imho because it would require introducing a minimum delegation amount per Vault. Otherwise, if we set the bound to 10 delegators per Vault, the Vault might only get 10 * 1 DOT delegations (instead of e.g. 10 * 100k DOT). As discussed with Sander, a better option 3 is: Meaning, we do not allow new delegations until the previous slashing is completely processed. We can then have the Vault operator call the function (in his own interest to unlock new delegations), Bob himself, and as a backup we have a Bot running. On the UI, we would show Bob: "this Vault is processing a slashing event, come back a bit later". Plus, we can show Bob a "Speed up (cost: x INTR)" button which iterates off-chain and makes Imho this is the better solution. |
Option 3 would mean that the existing nominators can neither deposit nor withdraw stake. If the vault client is offline, that would mean stake gets locked (which is anyway sort of an issue but leaving that aside for now). I think option 3 works well if we do it as follows:
|
Yes, that makes sense. The extrinsic should be callable by anyone. |
To add to that, I think we'd need to have a |
I think in full-blown weights v2, we also need an upper limit on that vector. But yes, needs some more work in the lib but I don't see a good way around that. |
Also agree with the proposed solution (option 3), this should allow us to revise the staking architecture (i.e. remove |
This PR adds a python script that models the staking pallet, but with only a single vault, and 2 nominators. It illustrates a fundamental problem with our approach to slashing (which is required for nomination).
The problem occurs when a vault gets slashed twice, and in between the two slashes another nominator deposits or withdraws stake. So
What actually happens when a vault gets slashed is that the
SlashedPerToken
value increases. The stake of the individual nominators is only updated lazily based on this value - every time a nominator changes its stake or withdraws rewards, its stake gets updated based on itsstake
,SlashPerToken
andSlashTally
.Let's take a closer look at the example. The state prior to this is as follows:
The
compute_stake
function correctly returns:Everything good so far. Now we execute step 4. The
slash_stake
function setsslash_per_token
to0.6 + 10 / 70 = 0.7428571428571429
. Thecompute_stake
function returns incorrect values (expected output would be 15):In total, 10 stake is indeed slashed, but the slash that Alice receives is disproportionate. This is because its
stake
storage value is higher (50, compared to bob's 20). The system does not take into account that the effective stake of Alice is actually lower due to the previous slash.