-
Notifications
You must be signed in to change notification settings - Fork 115
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
runtime node slashing (ADR 0005) #3640
Conversation
f2d964e
to
0ab8e88
Compare
71c815f
to
a37dc25
Compare
Codecov Report
@@ Coverage Diff @@
## master #3640 +/- ##
==========================================
+ Coverage 66.66% 66.77% +0.10%
==========================================
Files 393 394 +1
Lines 38373 38821 +448
==========================================
+ Hits 25581 25922 +341
- Misses 9119 9157 +38
- Partials 3673 3742 +69
Continue to review full report at Codecov.
|
8f89667
to
030b662
Compare
849b34f
to
4fde045
Compare
dd78a6f
to
879b43e
Compare
c75ee0f
to
6e4096e
Compare
d7f6eec
to
5d1c759
Compare
return err | ||
} | ||
|
||
if len(rtState.Runtime.Staking.Slashing) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go doesn't require this extra check, right? we already rely on the Slashing[xxx]
to return a zeroed Slash
struct if it's not found, and then we return the same error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it could be nil and derefing a nil map is an error. In case of Slashing
from the (global) staking consensus parameters, the Slashing()
state accessor method returns a non-nil map in case the parameters are unset/nil but here this is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://golang.org/ref/spec#Index_expressions language spec says reading from a nil map gives the zero value
// TODO: part of slashed amount (configurable) should be transferred to the transaction submitter. | ||
// If the caller is a node, distribute slashed funds to the controlling entity instead of the | ||
// caller directly. | ||
rewardAddr := ctx.CallerAddress() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if people frontrun transactions like these, to take the reward for themselves
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a valid concern. Incentivizing evidence submission seems like it introduces more problems than it solves :-)
5d1c759
to
1f87036
Compare
return fmt.Errorf("tendermint/roothash: runtimeAccReward.Quo(100): %w", err) | ||
} | ||
runtimeAddr := staking.NewRuntimeAddress(runtimeID) | ||
if _, err := stakeState.TransferFromCommon(ctx, runtimeAddr, runtimeAccReward, false); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently these rewards ignore the commission schedule and the whole reward is split between all delegators of the entity, is this fine or should the owning entity be able to take commission?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note: this comment should be in line 193, here we transfer to the runtime account anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, actually currently the delegators get nothing, it is treated the same as if the entity just increased its self-delegation. Do we want the delegators to get a cut as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right yeah i miss-checked that. I think that probably yes? (since if the node is slashed, delegators do lose proportionately). But i'm not sure if it's currently worth the additional complexity. Maybe a good future improvement. I would at least add some notes that runtime slashing rewards are not rewarded to delegators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I changed the code to take all delegators and commission into account.
361e4c2
to
97a1aa3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ Thanks for finishing the PR (can't actually approve as i'm the author).
} | ||
|
||
// If escrow is requested, escrow the transferred stake immediately. | ||
if escrow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I think (not 100% sure, didn't check in detail) we can now also simplify the AddRewards
method by calling TransferFromCommon
from the accounts loop.
432d32e
to
9dd2bbd
Compare
9dd2bbd
to
253376f
Compare
SlashRuntimeIncorrectResults