osmosis-labs / mesh-security-sdk

MIT License
24 stars 12 forks source link

Send misbehaviour time during slashing event #139

Open maurolacy opened 9 months ago

maurolacy commented 9 months ago

Related to / follow up of #125.

As part of slashing message info to the virtual-staking contract, the infraction time has to be sent as well.

Infraction time is:

This is important since the infraction time time is used on the external-staking contract to filter out slashing of un delegations (for pending undelegations that started before the infraction)

See also: https://github.com/osmosis-labs/mesh-security/issues/177

maurolacy commented 9 months ago

This hasn't been done yet because the infraction time is not passed to the Slash() handler. So, this requires interfacing with / decorating HandleEquivocationEvidence() (that is, the evidence keeper), where that info is still present.

For offline infractions, the current block time can be sent in place of the evidence historical infraction time. This can (perhaps) be done in the SlashWithInfractionHeight decorator.

maurolacy commented 9 months ago

As discussed offline, a good way to do this could be:

Decorating the evidence keeper / HandleEquivocationEvidence, and first calling the real equivocation evidence handler in the decorator.

Then, checking if the validator is now jailed / tombstoned, and building a full slash message for the contracts in case it is.

The good thing about this is that the original evidence handler can be called unmodified. And, that it isn't necessary to reproduce / copy its logic in the decorator.

For robustness, you can check for jailing / slashing before calling the real handler, then check again after calling it, and only generate a slash message if there's a state transition to jailing / tombstoning.