Documentation ¶
Index ¶
- Constants
- Variables
- func CalcAntiWhalingScore(delegationState []*types.ValidatorData, totalStakeD num.Decimal, ...) map[string]num.Decimal
- func CalcDelegation(validators map[string]struct{}, delegationState []*types.ValidatorData) ([]*types.ValidatorData, num.Decimal)
- func CalcValidatorScore(valStake, totalStake, numVal num.Decimal, ...) num.Decimal
- func NewValidatorPerformance(log *logging.Logger) *validatorPerformance
- func SignAnnounceNode(an *commandspb.AnnounceNode, vegaSigner Signer, ethSigner Signer) error
- func VerifyAnnounceNode(an *commandspb.AnnounceNode) error
- type Broker
- type Commander
- type Config
- type ERC20Signatures
- func (s *ERC20Signatures) EmitNewValidatorsSignatures(ctx context.Context, validators []NodeIDAddress, currentTime time.Time, ...)
- func (s *ERC20Signatures) EmitPromotionsSignatures(ctx context.Context, currentTime time.Time, epochSeq uint64, ...)
- func (s *ERC20Signatures) EmitRemoveValidatorsSignatures(ctx context.Context, remove []NodeIDAddress, validators []NodeIDAddress, ...)
- func (s *ERC20Signatures) SetNonce(t time.Time)
- type GenesisState
- type MultiSigTopology
- type NodeIDAddress
- type NodeWallets
- type NodeWalletsWrapper
- type Notary
- type PendingEthereumKeyRotation
- type PendingKeyRotation
- type Resource
- type Signatures
- type Signer
- type StatusAddress
- type TimeService
- type Topology
- func (t *Topology) AddForwarder(pubKey string)
- func (t *Topology) AddKeyRotate(ctx context.Context, nodeID string, currentBlockHeight uint64, ...) error
- func (t *Topology) AddNewNode(ctx context.Context, nr *commandspb.AnnounceNode, status ValidatorStatus) error
- func (t *Topology) AllNodeIDs() []string
- func (t *Topology) AllVegaPubKeys() []string
- func (t *Topology) BeginBlock(ctx context.Context, req abcitypes.RequestBeginBlock)
- func (t *Topology) Checkpoint() ([]byte, error)
- func (t *Topology) Get(key string) *ValidatorData
- func (t *Topology) GetAllPendingKeyRotations() []*PendingKeyRotation
- func (t *Topology) GetPendingEthereumKeyRotation(blockHeight uint64, nodeID string) *PendingEthereumKeyRotation
- func (t *Topology) GetPendingKeyRotation(blockHeight uint64, nodeID string) *PendingKeyRotation
- func (t *Topology) GetRewardsScores(ctx context.Context, epochSeq string, delegationState []*types.ValidatorData, ...) (*types.ScoreData, *types.ScoreData)
- func (t *Topology) GetState(k string) ([]byte, []types.StateProvider, error)
- func (t *Topology) GetValidatorPowerUpdates() []tmtypes.ValidatorUpdate
- func (t *Topology) HasChanged(k string) bool
- func (t *Topology) IsSelfTendermintValidator() bool
- func (t *Topology) IsTendermintValidator(pubkey string) (ok bool)
- func (t *Topology) IsValidator() bool
- func (t *Topology) IsValidatorNodeID(nodeID string) bool
- func (t *Topology) IsValidatorVegaPubKey(pubkey string) (ok bool)
- func (t *Topology) Keys() []string
- func (t *Topology) Len() int
- func (t *Topology) Load(ctx context.Context, data []byte) error
- func (t *Topology) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
- func (t *Topology) LoadValidatorsOnGenesis(ctx context.Context, rawstate []byte) (err error)
- func (t *Topology) Name() types.CheckpointName
- func (t *Topology) Namespace() types.SnapshotNamespace
- func (t *Topology) NotifyOnKeyChange(fns ...func(ctx context.Context, oldPubKey, newPubKey string))
- func (t *Topology) NumberOfTendermintValidators() uint
- func (t *Topology) OnEpochEvent(ctx context.Context, epoch types.Epoch)
- func (t *Topology) OnEpochLengthUpdate(ctx context.Context, l time.Duration) error
- func (t *Topology) OnEpochRestore(_ context.Context, epoch types.Epoch)
- func (t *Topology) ProcessAnnounceNode(ctx context.Context, an *commandspb.AnnounceNode) error
- func (t *Topology) ProcessValidatorHeartbeat(ctx context.Context, vh *commandspb.ValidatorHeartbeat, ...) error
- func (t *Topology) RecalcValidatorSet(ctx context.Context, epochSeq string, delegationState []*types.ValidatorData, ...)
- func (t *Topology) ReloadConf(cfg Config)
- func (t *Topology) RotateEthereumKey(ctx context.Context, publicKey string, currentBlockHeight uint64, ...) error
- func (t *Topology) SelfNodeID() string
- func (t *Topology) SelfVegaPubKey() string
- func (t *Topology) SetIsValidator()
- func (t *Topology) SetNotary(notary Notary)
- func (t *Topology) SetSignatures(signatures Signatures)
- func (t *Topology) Stopped() bool
- func (t *Topology) UpdateErsatzValidatorsFactor(_ context.Context, ersatzFactor num.Decimal) error
- func (t *Topology) UpdateMinimumEthereumEventsForNewValidator(_ context.Context, minimumEthereumEventsForNewValidator *num.Uint) error
- func (t *Topology) UpdateMinimumRequireSelfStake(_ context.Context, minStake num.Decimal) error
- func (t *Topology) UpdateNumberEthMultisigSigners(_ context.Context, numberEthMultisigSigners *num.Uint) error
- func (t *Topology) UpdateNumberOfTendermintValidators(_ context.Context, noValidators *num.Uint) error
- func (t *Topology) UpdateValidatorIncumbentBonusFactor(_ context.Context, incumbentBonusFactor num.Decimal) error
- type ValidatorData
- type ValidatorMapping
- type ValidatorPerformance
- type ValidatorStatus
- type ValidatorTopology
- type Verifier
- type Wallet
- type Witness
- func (w *Witness) AddNodeCheck(_ context.Context, nv *commandspb.NodeVote, key crypto.PublicKey) error
- func (w *Witness) GetState(k string) ([]byte, []types.StateProvider, error)
- func (w *Witness) HasChanged(k string) bool
- func (w *Witness) Keys() []string
- func (w *Witness) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
- func (w *Witness) Namespace() types.SnapshotNamespace
- func (w *Witness) OnDefaultValidatorsVoteRequiredUpdate(ctx context.Context, d num.Decimal) error
- func (w *Witness) OnTick(ctx context.Context, t time.Time)
- func (w *Witness) ReloadConf(cfg Config)
- func (w *Witness) RestoreResource(r Resource, cb func(interface{}, bool)) error
- func (w *Witness) StartCheck(r Resource, cb func(interface{}, bool), checkUntil time.Time) error
- func (w *Witness) Stop()
- func (w *Witness) Stopped() bool
Constants ¶
const ( ValidatorStatusPending = iota ValidatorStatusErsatz ValidatorStatusTendermint )
Variables ¶
var ( ErrVegaNodeAlreadyRegisterForChain = errors.New("a vega node is already registered with the blockchain node") ErrInvalidChainPubKey = errors.New("invalid blockchain public key") )
var ( ErrTargetBlockHeightMustBeGraterThanCurrentHeight = errors.New("target block height must be greater then current block") ErrNewVegaPubKeyIndexMustBeGreaterThenCurrentPubKeyIndex = errors.New("a new vega public key index must be greather then current public key index") ErrInvalidVegaPubKeyForNode = errors.New("current vega public key is invalid for node") ErrNodeAlreadyHasPendingKeyRotation = errors.New("node already has a pending key rotation") ErrCurrentPubKeyHashDoesNotMatch = errors.New("current public key hash does not match") )
var ( ErrUnknownValidator = errors.New("unknown validator ID") ErrUnexpectedSignedBlockHeight = errors.New("unexpected signed block height") PerformanceIncrement = num.DecimalFromFloat(0.1) DecimalOne = num.DecimalFromFloat(1) VotingPowerScalingFactor, _ = num.DecimalFromString("10000") )
var ( ErrResourceDuplicate = errors.New("resource duplicate") ErrCheckUntilInvalid = errors.New("invalid time to check until") ErrInvalidResourceIDForNodeVote = errors.New("invalid resource ID") ErrVoteFromNonValidator = errors.New("vote from non validator") ErrDuplicateVoteFromNode = errors.New("duplicate vote from node") )
var ErrCurrentEthAddressDoesNotMatch = errors.New("current Ethereum address does not match")
var ErrMissingRequiredAnnounceNodeFields = errors.New("missing required announce node fields")
var (
ErrSnapshotKeyDoesNotExist = errors.New("unknown key for witness snapshot")
)
var ValidatorStatusToName = map[ValidatorStatus]string{ ValidatorStatusPending: "pending", ValidatorStatusErsatz: "ersatz", ValidatorStatusTendermint: "tendermint", }
Functions ¶
func CalcAntiWhalingScore ¶
func CalcAntiWhalingScore(delegationState []*types.ValidatorData, totalStakeD num.Decimal, stakeScoreParams types.StakeScoreParams) map[string]num.Decimal
CalcAntiWhalingScore calculates the anti-whaling stake score for the validators represented in the given delegation set.
func CalcDelegation ¶
func CalcDelegation(validators map[string]struct{}, delegationState []*types.ValidatorData) ([]*types.ValidatorData, num.Decimal)
CalcDelegation extracts the delegation of the validator set from the delegation state slice and returns the total delegation.
func CalcValidatorScore ¶
func CalcValidatorScore(valStake, totalStake, numVal num.Decimal, stakeScoreParams types.StakeScoreParams) num.Decimal
calcValidatorScore calculates the stake based raw validator score with anti whaling.
func NewValidatorPerformance ¶
func SignAnnounceNode ¶
func SignAnnounceNode( an *commandspb.AnnounceNode, vegaSigner Signer, ethSigner Signer, ) error
SignAnnounceNode adds the signature for the ethereum and Vega address / pubkeys.
func VerifyAnnounceNode ¶
func VerifyAnnounceNode(an *commandspb.AnnounceNode) error
SignAnnounceNode adds the signature for the ethereum and Vega address / pubkeys.
Types ¶
type Config ¶
Config represents governance specific configuration.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration.
type ERC20Signatures ¶
type ERC20Signatures struct {
// contains filtered or unexported fields
}
func NewSignatures ¶
func NewSignatures( log *logging.Logger, notary Notary, nw NodeWallets, broker Broker, isValidatorSetup bool, ) *ERC20Signatures
func (*ERC20Signatures) EmitNewValidatorsSignatures ¶
func (s *ERC20Signatures) EmitNewValidatorsSignatures( ctx context.Context, validators []NodeIDAddress, currentTime time.Time, epochSeq uint64, )
func (*ERC20Signatures) EmitPromotionsSignatures ¶
func (s *ERC20Signatures) EmitPromotionsSignatures( ctx context.Context, currentTime time.Time, epochSeq uint64, previousState map[string]StatusAddress, newState map[string]StatusAddress, )
func (*ERC20Signatures) EmitRemoveValidatorsSignatures ¶
func (s *ERC20Signatures) EmitRemoveValidatorsSignatures( ctx context.Context, remove []NodeIDAddress, validators []NodeIDAddress, currentTime time.Time, epochSeq uint64, )
func (*ERC20Signatures) SetNonce ¶
func (s *ERC20Signatures) SetNonce(t time.Time)
type GenesisState ¶
type GenesisState ValidatorMapping
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
func LoadGenesisState ¶
func LoadGenesisState(bytes []byte) (GenesisState, error)
type MultiSigTopology ¶
type NodeIDAddress ¶
type NodeWallets ¶
type NodeWalletsWrapper ¶
type NodeWalletsWrapper struct {
*nodewallets.NodeWallets
}
func WrapNodeWallets ¶
func WrapNodeWallets(nw *nodewallets.NodeWallets) *NodeWalletsWrapper
func (*NodeWalletsWrapper) GetEthereum ¶
func (w *NodeWalletsWrapper) GetEthereum() Signer
func (*NodeWalletsWrapper) GetEthereumAddress ¶
func (w *NodeWalletsWrapper) GetEthereumAddress() string
func (*NodeWalletsWrapper) GetTendermintPubkey ¶
func (w *NodeWalletsWrapper) GetTendermintPubkey() string
func (*NodeWalletsWrapper) GetVega ¶
func (w *NodeWalletsWrapper) GetVega() Wallet
type Notary ¶
type Notary interface { StartAggregate(resID string, kind types.NodeSignatureKind, signature []byte) IsSigned(ctx context.Context, id string, kind types.NodeSignatureKind) ([]types.NodeSignature, bool) OfferSignatures(kind types.NodeSignatureKind, f func(resources string) []byte) }
Notary ...
type PendingKeyRotation ¶
type Signatures ¶
type Signatures interface { EmitPromotionsSignatures( ctx context.Context, currentTime time.Time, epochSeq uint64, previousState map[string]StatusAddress, newState map[string]StatusAddress, ) EmitNewValidatorsSignatures( ctx context.Context, validators []NodeIDAddress, currentTime time.Time, epochSeq uint64, ) EmitRemoveValidatorsSignatures( ctx context.Context, remove []NodeIDAddress, validators []NodeIDAddress, currentTime time.Time, epochSeq uint64, ) SetNonce(t time.Time) }
type StatusAddress ¶
type StatusAddress struct { Status ValidatorStatus EthAddress string }
type TimeService ¶
type Topology ¶
type Topology struct {
// contains filtered or unexported fields
}
func NewTopology ¶
func NewTopology( log *logging.Logger, cfg Config, wallets NodeWallets, broker Broker, isValidatorSetup bool, cmd Commander, msTopology MultiSigTopology, timeService TimeService, ) *Topology
func (*Topology) AddForwarder ¶
AddForwarder records the times that a validator fowards an eth event.
func (*Topology) AddKeyRotate ¶
func (t *Topology) AddKeyRotate(ctx context.Context, nodeID string, currentBlockHeight uint64, kr *commandspb.KeyRotateSubmission) error
func (*Topology) AddNewNode ¶
func (t *Topology) AddNewNode(ctx context.Context, nr *commandspb.AnnounceNode, status ValidatorStatus) error
func (*Topology) AllNodeIDs ¶
AllNodeIDs returns all the validators node IDs keys.
func (*Topology) AllVegaPubKeys ¶
AllVegaPubKeys returns all the validators vega public keys.
func (*Topology) BeginBlock ¶
func (t *Topology) BeginBlock(ctx context.Context, req abcitypes.RequestBeginBlock)
func (*Topology) Checkpoint ¶
func (*Topology) Get ¶
func (t *Topology) Get(key string) *ValidatorData
Get returns validator data based on validator master public key.
func (*Topology) GetAllPendingKeyRotations ¶
func (t *Topology) GetAllPendingKeyRotations() []*PendingKeyRotation
func (*Topology) GetPendingEthereumKeyRotation ¶
func (t *Topology) GetPendingEthereumKeyRotation(blockHeight uint64, nodeID string) *PendingEthereumKeyRotation
func (*Topology) GetPendingKeyRotation ¶
func (t *Topology) GetPendingKeyRotation(blockHeight uint64, nodeID string) *PendingKeyRotation
func (*Topology) GetRewardsScores ¶
func (t *Topology) GetRewardsScores(ctx context.Context, epochSeq string, delegationState []*types.ValidatorData, stakeScoreParams types.StakeScoreParams) (*types.ScoreData, *types.ScoreData)
GetRewardsScores returns the reward scores (raw, performance, multisig, validator_score, and normalised) for tm and ersatz validaor sets.
func (*Topology) GetValidatorPowerUpdates ¶
func (t *Topology) GetValidatorPowerUpdates() []tmtypes.ValidatorUpdate
GetValidatorPowerUpdates returns the voting power changes if this is the first block of an epoch.
func (*Topology) HasChanged ¶
func (*Topology) IsSelfTendermintValidator ¶
func (*Topology) IsTendermintValidator ¶
IsValidatorVegaPubKey returns true if the given key is a Vega validator public key and the validators is of status Tendermint.
func (*Topology) IsValidator ¶
func (*Topology) IsValidatorNodeID ¶
IsValidatorNodeID takes a nodeID and returns true if the node is a validator node.
func (*Topology) IsValidatorVegaPubKey ¶
IsValidatorVegaPubKey returns true if the given key is a Vega validator public key.
func (*Topology) Len ¶
Len return the number of validators with status Tendermint, the only validators that matter.
func (*Topology) LoadValidatorsOnGenesis ¶
func (*Topology) Name ¶
func (t *Topology) Name() types.CheckpointName
func (*Topology) Namespace ¶
func (t *Topology) Namespace() types.SnapshotNamespace
func (*Topology) NotifyOnKeyChange ¶
func (*Topology) NumberOfTendermintValidators ¶
func (*Topology) OnEpochEvent ¶
func (*Topology) OnEpochLengthUpdate ¶
OnEpochLengthUpdate updates the duration of an epoch - which is used to calculate the number of blocks to keep a malperforming validators. The number of blocks is calculated as 10 epochs x duration of epoch in seconds, assuming block time is 1s.
func (*Topology) OnEpochRestore ¶
OnEpochRestore is the epochtime service telling us the restored epoch data.
func (*Topology) ProcessAnnounceNode ¶
func (t *Topology) ProcessAnnounceNode( ctx context.Context, an *commandspb.AnnounceNode, ) error
func (*Topology) ProcessValidatorHeartbeat ¶
func (t *Topology) ProcessValidatorHeartbeat(ctx context.Context, vh *commandspb.ValidatorHeartbeat, verifyVegaSig func(message, signature, pubkey []byte) error, verifyEthSig func(message, signature []byte, hexAddress string) error, ) error
ProcessValidatorHeartbeat is verifying the signatures from a validator's transaction and records the status.
func (*Topology) RecalcValidatorSet ¶
func (t *Topology) RecalcValidatorSet(ctx context.Context, epochSeq string, delegationState []*types.ValidatorData, stakeScoreParams types.StakeScoreParams)
RecalcValidatorSet is called at the before a new epoch is started to update the validator sets. the delegation state corresponds to the epoch about to begin.
func (*Topology) ReloadConf ¶
ReloadConf updates the internal configuration.
func (*Topology) RotateEthereumKey ¶
func (t *Topology) RotateEthereumKey( ctx context.Context, publicKey string, currentBlockHeight uint64, kr *commandspb.EthereumKeyRotateSubmission, ) error
func (*Topology) SelfNodeID ¶
func (*Topology) SelfVegaPubKey ¶
func (*Topology) SetIsValidator ¶
func (t *Topology) SetIsValidator()
SetIsValidator will set the flag for `self` so that it is considered a real validator for example, when a node has announced itself and is accepted as a PENDING validator.
func (*Topology) SetNotary ¶
SetNotary this is not good, the topology depends on the notary which in return also depends on the topology... Luckily they do not require recursive calls as for each calls are one offs... anyway we may want to extract the code requiring the notary somewhere else or have different pattern somehow...
func (*Topology) SetSignatures ¶
func (t *Topology) SetSignatures(signatures Signatures)
SetSignatures this is not good, same issue as for SetNotary method. This is only used as a helper for testing..
func (*Topology) UpdateErsatzValidatorsFactor ¶
UpdateErsatzValidatorsFactor updates the ratio between the tendermint validators list and the ersatz validators list.
func (*Topology) UpdateMinimumEthereumEventsForNewValidator ¶
func (t *Topology) UpdateMinimumEthereumEventsForNewValidator(_ context.Context, minimumEthereumEventsForNewValidator *num.Uint) error
UpdateMinimumEthereumEventsForNewValidator updates the minimum number of events forwarded by / voted for by the joining validator.
func (*Topology) UpdateMinimumRequireSelfStake ¶
UpdateMinimumRequireSelfStake updates the minimum requires stake for a validator.
func (*Topology) UpdateNumberEthMultisigSigners ¶
func (t *Topology) UpdateNumberEthMultisigSigners(_ context.Context, numberEthMultisigSigners *num.Uint) error
UpdateNumberEthMultisigSigners updates the required number of multisig signers.
func (*Topology) UpdateNumberOfTendermintValidators ¶
func (t *Topology) UpdateNumberOfTendermintValidators(_ context.Context, noValidators *num.Uint) error
UpdateNumberOfTendermintValidators updates with the quota for tendermint validators. It updates accordingly the number of slots for ersatzvalidators.
type ValidatorData ¶
type ValidatorData struct { ID string `json:"id"` VegaPubKey string `json:"vega_pub_key"` VegaPubKeyIndex uint32 `json:"vega_pub_key_index"` EthereumAddress string `json:"ethereum_address"` TmPubKey string `json:"tm_pub_key"` InfoURL string `json:"info_url"` Country string `json:"country"` Name string `json:"name"` AvatarURL string `json:"avatar_url"` FromEpoch uint64 `json:"from_epoch"` }
func (ValidatorData) HashVegaPubKey ¶
func (v ValidatorData) HashVegaPubKey() (string, error)
HashVegaPubKey returns hash VegaPubKey encoded as hex string.
func (ValidatorData) IsValid ¶
func (v ValidatorData) IsValid() bool
type ValidatorMapping ¶
type ValidatorMapping map[string]ValidatorData
ValidatorMapping maps a tendermint pubkey with a vega pubkey.
type ValidatorPerformance ¶
type ValidatorStatus ¶
type ValidatorStatus int32
type ValidatorTopology ¶
type Witness ¶
type Witness struct {
// contains filtered or unexported fields
}
func NewWitness ¶
func NewWitness(log *logging.Logger, cfg Config, top ValidatorTopology, cmd Commander, tsvc TimeService) (w *Witness)
func (*Witness) AddNodeCheck ¶
func (w *Witness) AddNodeCheck(_ context.Context, nv *commandspb.NodeVote, key crypto.PublicKey) error
AddNodeCheck registers a vote from a validator node for a given resource.
func (*Witness) HasChanged ¶
func (*Witness) Namespace ¶
func (w *Witness) Namespace() types.SnapshotNamespace
func (*Witness) OnDefaultValidatorsVoteRequiredUpdate ¶
func (*Witness) ReloadConf ¶
ReloadConf updates the internal configuration.
func (*Witness) RestoreResource ¶
func (*Witness) StartCheck ¶
Source Files ¶
- announce_node.go
- config.go
- genesis.go
- heartbeat.go
- node_wallet_wrapper.go
- signatures.go
- topology.go
- topology_checkpoint.go
- topology_eth_key_rotate.go
- topology_key_rotate.go
- topology_snapshot.go
- validator_performance.go
- validator_performance_snapshot.go
- validator_score.go
- validator_set.go
- witness.go
- witness_snapshot.go