Documentation ¶
Overview ¶
Governance contract: Users can apply for a candidate node to join consensus selection, deposit ZPT to vote for candidate nodes, quit selection and unVote for candidate nodes through this contract. ZPT deposited in the contract can get GALA bonus which come from transaction fee of the network.
Index ¶
- Constants
- Variables
- func ApproveCandidate(native *native.NativeService) ([]byte, error)
- func BlackNode(native *native.NativeService) ([]byte, error)
- func CallSplit(native *native.NativeService) ([]byte, error)
- func CheckVBFTConfig(configuration *config.VBFTConfig) error
- func CheckVoteInfo(native *native.NativeService) ([]byte, error)
- func CommitDpos(native *native.NativeService) ([]byte, error)
- func GetBytesUint32(b []byte) (uint32, error)
- func GetPeerpoolInfo(native *native.NativeService) ([]byte, error)
- func GetUint32Bytes(num uint32) ([]byte, error)
- func GetView(native *native.NativeService, contract common.Address) (uint32, error)
- func GetVoteInfo(native *native.NativeService) ([]byte, error)
- func InitConfig(native *native.NativeService) ([]byte, error)
- func InitGovernance()
- func QuitNode(native *native.NativeService) ([]byte, error)
- func RegisterCandidate(native *native.NativeService) ([]byte, error)
- func RegisterCandidateTransferFrom(native *native.NativeService) ([]byte, error)
- func RegisterGovernanceContract(native *native.NativeService)
- func RejectCandidate(native *native.NativeService) ([]byte, error)
- func TransferPenalty(native *native.NativeService) ([]byte, error)
- func UnRegisterCandidate(native *native.NativeService) ([]byte, error)
- func UnVoteForPeer(native *native.NativeService) ([]byte, error)
- func UpdateConfig(native *native.NativeService) ([]byte, error)
- func UpdateGlobalParam(native *native.NativeService) ([]byte, error)
- func UpdateSplitCurve(native *native.NativeService) ([]byte, error)
- func VoteForPeer(native *native.NativeService) ([]byte, error)
- func VoteForPeerTransferFrom(native *native.NativeService) ([]byte, error)
- func WhiteNode(native *native.NativeService) ([]byte, error)
- func Withdraw(native *native.NativeService) ([]byte, error)
- func WithdrawGala(native *native.NativeService) ([]byte, error)
- type ApproveCandidateParam
- type BlackListItem
- type BlackNodeParam
- type CandidateSplitInfo
- type CheckVoteInfoParam
- type Configuration
- type GetVoteInfoParam
- type GlobalParam
- type GovernanceView
- type PeerPoolItem
- type PeerPoolList
- type PeerPoolMap
- type PeerStakeInfo
- type PenaltyStake
- type QuitNodeParam
- type RegisterCandidateParam
- type RejectCandidateParam
- type SplitCurve
- type Status
- type SyncNodeSplitInfo
- type TotalStake
- type TransferPenaltyParam
- type UnRegisterCandidateParam
- type VoteForPeerParam
- type VoteInfo
- type WhiteNodeParam
- type WithdrawGalaParam
- type WithdrawParam
Constants ¶
const ( //function name INIT_CONFIG = "initConfig" REGISTER_CANDIDATE = "registerCandidate" REGISTER_CANDIDATE_TRANSFER_FROM = "registerCandidateTransferFrom" UNREGISTER_CANDIDATE = "unRegisterCandidate" APPROVE_CANDIDATE = "approveCandidate" REJECT_CANDIDATE = "rejectCandidate" BLACK_NODE = "blackNode" WHITE_NODE = "whiteNode" QUIT_NODE = "quitNode" VOTE_FOR_PEER = "voteForPeer" VOTE_FOR_PEER_TRANSFER_FROM = "voteForPeerTransferFrom" UNVOTE_FOR_PEER = "unVoteForPeer" WITHDRAW = "withdraw" COMMIT_DPOS = "commitDpos" UPDATE_CONFIG = "updateConfig" UPDATE_GLOBAL_PARAM = "updateGlobalParam" UPDATE_SPLIT_CURVE = "updateSplitCurve" CALL_SPLIT = "callSplit" TRANSFER_PENALTY = "transferPenalty" WITHDRAW_GALA = "withdrawGala" GET_PEERPOOL_INFO = "getPeerPoolInfo" GET_VOTE_INFO = "getVoteInfo" CHECK_VOTE_INFO = "checkVoteInfo" //key prefix GLOBAL_PARAM = "globalParam" VBFT_CONFIG = "vbftConfig" GOVERNANCE_VIEW = "governanceView" CANDIDITE_INDEX = "candidateIndex" PEER_POOL = "peerPool" VOTE_INFO_POOL = "voteInfoPool" PEER_INDEX = "peerIndex" BLACK_LIST = "blackList" TOTAL_STAKE = "totalStake" PENALTY_STAKE = "penaltyStake" SPLIT_CURVE = "splitCurve" //global PRECISE = 1000000 )
Variables ¶
var MinCandidateFee = uint64(math.Pow(10, constants.GALA_DECIMALS))
candidate fee must >= 1 Gala
var Xi = []uint32{}/* 101 elements not displayed */
Functions ¶
func ApproveCandidate ¶
func ApproveCandidate(native *native.NativeService) ([]byte, error)
Approve a registered candidate node, used by admin. Only approved candidate node can participate in consensus selection and get gala bonus.
func BlackNode ¶
func BlackNode(native *native.NativeService) ([]byte, error)
Put a node into black list, remove node from pool, used by admin. Whole of initPos of black node will be punished, and several percent of vote deposit will be punished too. Node in black list can't be registered.
func CheckVBFTConfig ¶
func CheckVBFTConfig(configuration *config.VBFTConfig) error
func CheckVoteInfo ¶
func CheckVoteInfo(native *native.NativeService) ([]byte, error)
func CommitDpos ¶
func CommitDpos(native *native.NativeService) ([]byte, error)
Go to next consensus epoch
func GetBytesUint32 ¶
func GetPeerpoolInfo ¶
func GetPeerpoolInfo(native *native.NativeService) ([]byte, error)
Get peerpool info, used by users.
func GetUint32Bytes ¶
func GetVoteInfo ¶
func GetVoteInfo(native *native.NativeService) ([]byte, error)
func InitConfig ¶
func InitConfig(native *native.NativeService) ([]byte, error)
Init governance contract, include vbft config, global param and Gid admin.
func QuitNode ¶
func QuitNode(native *native.NativeService) ([]byte, error)
Quit a registered node, used by node owner. Remove node from pool and unfreeze deposit next epoch(candidate node) / next next epoch(consensus node)
func RegisterCandidate ¶
func RegisterCandidate(native *native.NativeService) ([]byte, error)
Register a candidate node, used by users. Users can register a candidate node with a authorized Gid. Candidate node can be voted and become consensus node according to their pos. Candidate node can get gala bonus according to their pos.
func RegisterCandidateTransferFrom ¶
func RegisterCandidateTransferFrom(native *native.NativeService) ([]byte, error)
Register a candidate node, used by contracts. Contracts can register a candidate node with a authorized Gid after approving ZPT to governance contract before invoke this function. Candidate node can be voted and become consensus node according to their pos. Candidate node can get gala bonus according to their pos.
func RegisterGovernanceContract ¶
func RegisterGovernanceContract(native *native.NativeService)
Register methods of governance contract
func RejectCandidate ¶
func RejectCandidate(native *native.NativeService) ([]byte, error)
Reject a registered candidate node, remove node from pool and unfreeze deposit zpt, used by admin. Only approved candidate node can participate in consensus selection and get gala bonus.
func TransferPenalty ¶
func TransferPenalty(native *native.NativeService) ([]byte, error)
Transfer all punished ZPT of a black node to a certain address
func UnRegisterCandidate ¶
func UnRegisterCandidate(native *native.NativeService) ([]byte, error)
Unregister a registered candidate node, will remove node from pool, and unfreeze deposit zpt.
func UnVoteForPeer ¶
func UnVoteForPeer(native *native.NativeService) ([]byte, error)
UnVote for a node by redeeming ZPT from this governance contract
func UpdateConfig ¶
func UpdateConfig(native *native.NativeService) ([]byte, error)
Update VBFT config
func UpdateGlobalParam ¶
func UpdateGlobalParam(native *native.NativeService) ([]byte, error)
Update global params of this governance contract
func UpdateSplitCurve ¶
func UpdateSplitCurve(native *native.NativeService) ([]byte, error)
Update split curve
func VoteForPeer ¶
func VoteForPeer(native *native.NativeService) ([]byte, error)
Vote for a node by depositing ZPT in this governance contract, used by users
func VoteForPeerTransferFrom ¶
func VoteForPeerTransferFrom(native *native.NativeService) ([]byte, error)
Vote for a node by depositing ZPT in this governance contract, used by contracts
func WhiteNode ¶
func WhiteNode(native *native.NativeService) ([]byte, error)
Remove a node from black list, allow it to be registered, used by admin.
func Withdraw ¶
func Withdraw(native *native.NativeService) ([]byte, error)
Withdraw unfreezed ZPT deposited in this governance contract.
func WithdrawGala ¶
func WithdrawGala(native *native.NativeService) ([]byte, error)
Withdraw unbounded GALA according to deposit ZPT in this governance contract
Types ¶
type ApproveCandidateParam ¶
type ApproveCandidateParam struct {
PeerPubkey string
}
func (*ApproveCandidateParam) Deserialize ¶
func (this *ApproveCandidateParam) Deserialize(r io.Reader) error
type BlackListItem ¶
func (*BlackListItem) Deserialize ¶
func (this *BlackListItem) Deserialize(r io.Reader) error
type BlackNodeParam ¶
type BlackNodeParam struct {
PeerPubkeyList []string
}
func (*BlackNodeParam) Deserialize ¶
func (this *BlackNodeParam) Deserialize(r io.Reader) error
type CandidateSplitInfo ¶
type CheckVoteInfoParam ¶
type CheckVoteInfoParam struct {
PeerPubkey string
}
func (*CheckVoteInfoParam) Deserialize ¶
func (this *CheckVoteInfoParam) Deserialize(r io.Reader) error
type Configuration ¶
type Configuration struct { N uint32 C uint32 K uint32 L uint32 BlockMsgDelay uint32 HashMsgDelay uint32 PeerHandshakeTimeout uint32 MaxBlockChangeView uint32 }
func (*Configuration) Deserialize ¶
func (this *Configuration) Deserialize(r io.Reader) error
type GetVoteInfoParam ¶
func (*GetVoteInfoParam) Deserialize ¶
func (this *GetVoteInfoParam) Deserialize(r io.Reader) error
type GlobalParam ¶
type GlobalParam struct { CandidateFee uint64 //unit: 10^-4 gala MinInitStake uint64 CandidateNum uint32 PosLimit uint32 A uint32 B uint32 Yita uint32 Penalty uint32 }
func (*GlobalParam) Deserialize ¶
func (this *GlobalParam) Deserialize(r io.Reader) error
type GovernanceView ¶
func GetGovernanceView ¶
func GetGovernanceView(native *native.NativeService, contract common.Address) (*GovernanceView, error)
func (*GovernanceView) Deserialize ¶
func (this *GovernanceView) Deserialize(r io.Reader) error
type PeerPoolItem ¶
type PeerPoolItem struct { Index uint32 PeerPubkey string Address common.Address Status Status InitPos uint64 TotalPos uint64 }
func (*PeerPoolItem) Deserialize ¶
func (this *PeerPoolItem) Deserialize(r io.Reader) error
func (*PeerPoolItem) DeserializeNew ¶
func (this *PeerPoolItem) DeserializeNew(r io.Reader) error
type PeerPoolList ¶
type PeerPoolList struct {
Peers []*PeerPoolItem
}
type PeerPoolMap ¶
type PeerPoolMap struct {
PeerPoolMap map[string]*PeerPoolItem
}
func GetPeerPoolMap ¶
func GetPeerPoolMap(native *native.NativeService, contract common.Address, view uint32) (*PeerPoolMap, error)
func (*PeerPoolMap) Deserialize ¶
func (this *PeerPoolMap) Deserialize(r io.Reader) error
func (*PeerPoolMap) DeserializeNew ¶
func (this *PeerPoolMap) DeserializeNew(r io.Reader) error
type PeerStakeInfo ¶
type PenaltyStake ¶
type PenaltyStake struct { PeerPubkey string InitPos uint64 VotePos uint64 TimeOffset uint32 Amount uint64 }
func (*PenaltyStake) Deserialize ¶
func (this *PenaltyStake) Deserialize(r io.Reader) error
type QuitNodeParam ¶
func (*QuitNodeParam) Deserialize ¶
func (this *QuitNodeParam) Deserialize(r io.Reader) error
type RegisterCandidateParam ¶
type RegisterCandidateParam struct { PeerPubkey string Address common.Address InitPos uint64 Caller []byte KeyNo uint32 }
func (*RegisterCandidateParam) Deserialize ¶
func (this *RegisterCandidateParam) Deserialize(r io.Reader) error
type RejectCandidateParam ¶
type RejectCandidateParam struct {
PeerPubkey string
}
func (*RejectCandidateParam) Deserialize ¶
func (this *RejectCandidateParam) Deserialize(r io.Reader) error
type SplitCurve ¶
type SplitCurve struct {
Yi []uint32
}
func (*SplitCurve) Deserialize ¶
func (this *SplitCurve) Deserialize(r io.Reader) error
type SyncNodeSplitInfo ¶
type TotalStake ¶
func (*TotalStake) Deserialize ¶
func (this *TotalStake) Deserialize(r io.Reader) error
type TransferPenaltyParam ¶
func (*TransferPenaltyParam) Deserialize ¶
func (this *TransferPenaltyParam) Deserialize(r io.Reader) error
type UnRegisterCandidateParam ¶
func (*UnRegisterCandidateParam) Deserialize ¶
func (this *UnRegisterCandidateParam) Deserialize(r io.Reader) error
type VoteForPeerParam ¶
func (*VoteForPeerParam) Deserialize ¶
func (this *VoteForPeerParam) Deserialize(r io.Reader) error
type VoteInfo ¶
type WhiteNodeParam ¶
type WhiteNodeParam struct {
PeerPubkey string
}
func (*WhiteNodeParam) Deserialize ¶
func (this *WhiteNodeParam) Deserialize(r io.Reader) error
type WithdrawGalaParam ¶
func (*WithdrawGalaParam) Deserialize ¶
func (this *WithdrawGalaParam) Deserialize(r io.Reader) error
type WithdrawParam ¶
func (*WithdrawParam) Deserialize ¶
func (this *WithdrawParam) Deserialize(r io.Reader) error