Detect a stale Avalanche L1 validator weight message
A relayer can deliver validly signed validator weight messages in a different order from their creation. The P-Chain tracks a minimum nonce for each registration to prevent stale updates from overwriting newer weights.
Compare the update with the registration’s minimum
Use the validation ID in the signed L1ValidatorWeightMessage and the current P-Chain record. A nonzero weight update accepts a nonce at or above the current minimum. The nonce need not advance by exactly one from the previous update. The weight is an absolute target.
minimum_nonce = 8
accepted_nonce = 12
new_weight = 40
assert accepted_nonce >= minimum_nonce and new_weight > 0
next_minimum = accepted_nonce + 1
assert 11 < next_minimum
Recover from out-of-order delivery
With minimum 8, accepting nonce 12 and weight 40 advances the minimum to 13. An older message carrying nonce 11 cannot now set weight 30 even if its signatures remain valid. Mark the older attempt superseded and reconcile the manager’s acknowledgement against the intended change. Weight zero invokes removal semantics and requires separate handling.