-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Rb staking pallet validator commission change event #10827
Rb staking pallet validator commission change event #10827
Conversation
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.
LGTM except the test being a bit superfluous.
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 don't really see the point of this. do_add_validate
just inserts the validator into storage after all checks have passed, but the function args are never modified in any way (as can happen with e.g. bond
if you try to bond more than your free balance).
This event is completely redundant because you can already look for the staking.validate
extrinsic, check the system.Extrinsic{Success, Failure}
event, and (if success), log the provided origin
and prefs
from the extrinsic data. As in, the function signature is this event.
The
It would also be good for the node to not spew out every single extrinsic event to every single connection, but rather allow front end apps to choose which events they wish to receive, thus saving bandwidth and overall processing time. I am not sure if work has been done on this, like giving your provider a list of events you want it to report. I can't see anything mentioned in Polkadot JS API docs. |
This is just not at all true. You are assuming that there's one way to build an application - subscribe to events from a full node - and that the application has only one purpose - displaying events to a user. The back end to an application like 1kv doesn't need millisecond latency to display this to a user (it's making decisions on 6 or 24 hour timeframes). It could easily fetch each block and check for But not just specific to this application, if information can be derived from the function signature and its success/failure, then emitting an event is redundant and wasteful. |
Historically, I've been much more on @joepetrowski's side on this discussion that applications should try and decode the chain as much as possible, not the chain bending itself and spitting bite-size pieces of data for all sorts of applications. It is true that you can easily scan blocks (both new and historical), and know exactly what commission changes happened by looking at extrinsics. In fact, looking at the block transactions and their success status is better, because you are slightly less dependent on old state. FYI, this is what @joepetrowski and I are proposing: https://polkadot.js.org/docs/api/cookbook/blocks#how-do-i-determine-if-an-extrinsic-succeededfailed |
Yes, as things stand I am leaning towards this now too. Thanks for the useful insights. |
@joepetrowski while you generally accurate that there is another (much more convoluted way to track this), it does not mean that having an event is not the right choice here. Events are automatically indexed by most block explorers, and easy to subscribe to via most client libraries. The goal of events is to present information to user applications which are relevant, and I think that one of the fundamental events of the staking pallet is when a validator updates their commission. So I really don't see the harm here in adding this event, and the overall story we want to tell here (connected to 1kv program), this would be the expected way for things to exist. |
So are extrinsics 🤷♂️ On one extreme, events (in general) are completely unnecessary because the runtime is stored on-chain, so if you want to know how a storage item got set, you can just sync the chain executing in Wasm and see where the storage item changed. Of course, that's a bit tricky and requires lots of tooling. Events are really convenient. So on the other extreme, you could just emit an event for every state change. But we don't because that convenience does come at a price. I think so far we've taken the approach that we should add events for things that are non-trivial to calculate. For example, with This event is just telling you that some storage item was Its name is also misleading, as it doesn't account for new validators, who haven't updated their preferences but have merely set them as part of their intention to validate. In order to make it accurate, you either need to (a) put this in an Likewise, the function for chilling a stash just tells you when a stash is chilled, but doesn't tell you if it was a nominator or validator (or what their if chilled_as_validator || chilled_as_nominator {
Self::deposit_event(Event::<T>::Chilled(stash.clone()));
} |
I also don't see the harm of adding this on a practical level. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
we are gonna follow up on this, talked to joe |
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.
Would change the name to reflect the info it conveys, but otherwise OK.
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Those name changes have been committed. |
@rossbulat can you make this build so we can merge it? |
No problem @kianenigma . All checks have passed. |
bot merge |
* commission-changed-event-and-deposit * deposit_event fix * commission_changed_event_works * fmt * CommissionChanged -> ValidatorPrefsUpdated * event ValidatorPrefs * updated commet * fmt * Update frame/staking/src/pallet/mod.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/staking/src/pallet/mod.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/staking/src/tests.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* commission-changed-event-and-deposit * deposit_event fix * commission_changed_event_works * fmt * CommissionChanged -> ValidatorPrefsUpdated * event ValidatorPrefs * updated commet * fmt * Update frame/staking/src/pallet/mod.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/staking/src/pallet/mod.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/staking/src/tests.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This is a PR for #10802.
Update:
ValidatorPrefsUpdated
to account forblocked
andcommission
.CommissionChanged
event has been added to the staking pallet, which is deposited upon a successfulvalidate()
call.commission_changed_event_works
test has been added, that tests whether the correct event was deposited upon a newvalidate()
call by controller account 10 / stash account 11.Notes:
src/pallet/mod.rs line 987
prefs
originally changed ownership when passed todo_add_validator
. To keep the convention of calling an event after all updates, prefs was cloned fordo_add_validator
and consumed by the event deposit.