Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

valoper.gno

1.92 Kb · 58 lines
 1package params
 2
 3import (
 4	prms "sys/params"
 5)
 6
 7// Valoper sys-param keys consumed by r/gnops/valopers (Register +
 8// UpdateSigningKey). Governance can update them via the generic
 9// NewSysParam*PropRequest factories — no realm-side gate is needed
10// because the values only affect fees and throttle inside valopers.
11const (
12	valoperSubmodule = "valoper"
13
14	valoperRegisterFeeKey          = "register_fee"
15	valoperRotationFeeKey          = "rotation_fee"
16	valoperRotationPeriodBlocksKey = "rotation_period_blocks"
17)
18
19// Default values used when the sys-param has never been set by
20// governance. Zero fees (GNOT transfers are disabled chain-wide
21// pre-fork) and a ~1-hour throttle at 6s/block.
22const (
23	defaultValoperRegisterFee          = uint64(0)
24	defaultValoperRotationFee          = uint64(0)
25	defaultValoperRotationPeriodBlocks = int64(600)
26)
27
28// GetValoperRegisterFee returns the fee (in ugnot) required to call
29// valopers.Register. Defaults to 0 if governance hasn't set it.
30func GetValoperRegisterFee() uint64 {
31	v, ok := prms.GetSysParamUint64(nodeModulePrefix, valoperSubmodule, valoperRegisterFeeKey)
32	if !ok {
33		return defaultValoperRegisterFee
34	}
35	return v
36}
37
38// GetValoperRotationFee returns the fee (in ugnot) required to call
39// valopers.UpdateSigningKey. Defaults to 0.
40func GetValoperRotationFee() uint64 {
41	v, ok := prms.GetSysParamUint64(nodeModulePrefix, valoperSubmodule, valoperRotationFeeKey)
42	if !ok {
43		return defaultValoperRotationFee
44	}
45	return v
46}
47
48// GetValoperRotationPeriodBlocks returns the per-operator rotation
49// throttle (in blocks). Defaults to ~1h worth at 6s/block (600).
50// This is the primary anti-spam defense pre-fee while rotation_fee
51// stays at 0; tightens further once non-zero fees become enforceable.
52func GetValoperRotationPeriodBlocks() int64 {
53	v, ok := prms.GetSysParamInt64(nodeModulePrefix, valoperSubmodule, valoperRotationPeriodBlocksKey)
54	if !ok {
55		return defaultValoperRotationPeriodBlocks
56	}
57	return v
58}