Technical explanation of the Harpoon module’s architecture and implementation
StakingHooks
interface plus the additional BeforeValidatorSlashedWithTokensToBurn
method. This extended interface (StakingHooksBeforeValidatorSlashedHasTokensToBurn
) exists only in Neutron’s fork of the Cosmos SDK and allows contracts to receive the actual tokensToBurn
argument during slashing events.
These hooks are registered in the application’s initialization code (typically in app.go
):
AfterValidatorCreated
: Called after a new validator is createdBeforeValidatorModified
: Called before an existing validator is modifiedAfterValidatorRemoved
: Called after a validator is removedAfterValidatorBonded
: Called after a validator is bondedAfterValidatorBeginUnbonding
: Called after a validator begins the unbonding processBeforeDelegationCreated
: Called before a new delegation is createdBeforeDelegationSharesModified
: Called before an existing delegation’s shares are modifiedBeforeDelegationRemoved
: Called before a delegation is removedAfterDelegationModified
: Called after a delegation is modifiedBeforeValidatorSlashed
: Special case - this method panics and should never be calledBeforeValidatorSlashedWithTokensToBurn
: The actual implementation for slashing hooksAfterUnbondingInitiated
: Called after the unbonding process is initiatedtokensToBurn
) compared to the standard slashing hook.
sudo
method on each subscribed contract. Each hook type has its own specific message format.
ManageHookSubscription
message can only be executed by the module’s authority (governance).
UpdateHookSubscription
method handles subscription changes: