Conversation
|
bot fmt |
|
@gpestana https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/4828478 was started for your command Comment |
|
@gpestana Command |
OnStakingUpdateOnStakingUpdate trait
| /// Fired when an existing validator updates their preferences. | ||
| /// | ||
| /// Note validator preference changes are not communicated, but could be added if needed. | ||
| fn on_validator_update(_who: &AccountId) {} |
There was a problem hiding this comment.
Wouldn't this also need old and new self stake params?
| fn on_stake_update(_who: &AccountId, _prev_stake: Option<Stake<Balance>>) {} | ||
| fn on_stake_update( | ||
| _who: &AccountId, | ||
| _prev_stake: Option<Stake<Balance>>, |
There was a problem hiding this comment.
Should we have both _prev_stake and _stake as same type? Either Stake<Balance> or Option<Stake<Balance>>. If Stake<Balance>, we can pass a zero value.
|
Closing as these changes have been included in the stake tracker PR #1933 and only make sense in that context. |
* fix on-demand parachain relay behavior during target chain reorgs * fix compilation
This PR refactors the
OnStakingUpdatetrait to make its usage simpler and less error prone in the context of pallet-staking and the pallet-stake-tracker. The main goal is to make readily available more information/data required by theOnStakingUpdatelistener (e.g. new stake onon_stake_update) through the interface methods.With this refactor, the event emitter needs to explicitly call the events with more information about the event. The advantage is that this new interface design prevents potential issues with data sync, e.g. the event emitter does not necessarily need to update the staking state before emitting the events and the
OnStakingUpdateimplementor does not need to rely as much on the staking interface, making the interface less error prone.Examples
Currently, on the
OnStakingUpdateimplemetor, we havewith the new interface design, the implementor will have all the most important information implicitly in the method interface:
Although the new design is less error prone, it is more opinionated and the design is highly affected by how the staking pallet will use this interface. Evidently, it is not possible to cover all the inputs that all the
OnStakingUpdateimplementors may need (depending on the use case), but the refactor aims at striking a good balance between safety for the usage in the context of staking and generality.