Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeLogDataFromBytes(data []byte) (topic string, tags []string, payload interface{}, err error)
- func EncodeMessage(action ActionType, payload Msg) ([]byte, error)
- func EndBlock(staking *Staking) core.BlockHookFn
- func MakeSign(msg Msg, key *ecdsa.PrivateKey) ([]byte, error)
- type ActionType
- type Evidence
- type EvidenceDoubleSign
- type EvidenceDoubleSignV5
- type EvidenceInactive
- type LogData
- type Message
- type Msg
- type PenaltyRecord
- type SignInfo
- type SlashData
- type SlashDataV5
- type SlashWithdrawRecord
- type Staking
- type TxConverter
- type TxCreateValidator
- type TxDelegation
- type TxDelegationSettle
- type TxUpdateValidator
- type TxValidatorChangeStatus
- type TxValidatorDeposit
- type TxValidatorSettle
- type TxValidatorWithdraw
Constants ¶
const ( //Module name of the module Module = "staking" // 0x000000000000000000000000000000000000000000000000007374616b696e67 //logs topic name LogTopicCreate = "create" // 0x0000000000000000000000000000000000000000000000000000637265617465 LogTopicUpdate = "update" // 0x0000000000000000000000000000000000000000000000000000757064617465 LogTopicDeposit = "deposit" // 0x000000000000000000000000000000000000000000000000006465706f736974 LogTopicDepositFailed = "deposit_failed" // 0x0000000000000000000000000000000000006465706f7369745f6661696c6564 LogTopicWithdraw = "withdraw" // 0x0000000000000000000000000000000000000000000000007769746864726177 LogTopicWithdrawEffect = "withdraw_effect" // 0x000000000000000000000000000000000077697468647261775f656666656374 // LogTopicWithdrawResult // Topics[1] : operator address // data: // [0,19] [20,31] // receipt arrivalAmount LogTopicWithdrawResult = "withdraw_result" // 0x000000000000000000000000000000000077697468647261775f726573756c74 LogTopicRewards = "rewards" // 0x0000000000000000000000000000000000000000000000000072657761726473 LogTopicSlashing = "slashing" // 0x000000000000000000000000000000000000000000000000736c617368696e67 LogTopicChangeStatus = "change_status" // 0x000000000000000000000000000000000000006368616e67655f737461747573 LogTopicChangeStatusFailed = "change_status_failed" // 0x0000000000000000000000006368616e67655f7374617475735f6661696c6564 LogTopicSettle = "settle" // 0x0000000000000000000000000000000000000000000000000000736574746c65 // topics of pending delegation transaction, // the "data" is a combined data as follow: // [0,8) [8,32) // take-effects-on-which-block-number final-delegation-tokens-after-the-transaction-take-effects (ignore it for settle) LogTopicDelegationPending = "delegation_op_pending" // 0x000000000000000000000064656c65676174696f6e5f6f705f70656e64696e67 LogTopicDelegationAddFailed = "delegation_add_failed" // 0x000000000000000000000064656c65676174696f6e5f6164645f6661696c6564 LogTopicDelegationSubFailed = "delegation_sub_failed" // 0x000000000000000000000064656c65676174696f6e5f7375625f6661696c6564 LogTopicDelegationSubEffect = "delegation_sub_effect" // 0x000000000000000000000064656c65676174696f6e5f7375625f656666656374 LogTopicProposerRewards = "proposer_rewards" // 0x0000000000000000000000000000000070726f706f7365725f72657761726473 //0x00007265636f7665725f66726f6d5f657870697265645f657870656c6c696e67 LogTopicRecoverFromExpiredExpelling = "recover_from_expired_expelling" )
const ( //EvidenceTypeDoubleSign name of duplicate vote EvidenceTypeDoubleSign = "doublesign" //EvidenceTypeInactive name of inactive EvidenceTypeInactive = "inactive" EvidenceTypeDoubleSignV5 = "doublesignv5" )
const ( VoteNone uint8 = iota Propose Prevote Precommit NextIndex Certificate )
ucon vote type
Variables ¶
var ( //EventTypeDoubleSign type of slashdata EventTypeDoubleSign uint8 = 0x0 //EventTypeInactive type of slashdata EventTypeInactive uint8 = 0x1 )
Functions ¶
func DecodeLogDataFromBytes ¶
func DecodeLogDataFromBytes(data []byte) (topic string, tags []string, payload interface{}, err error)
DecodeLogDataFromBytes .
func EncodeMessage ¶
func EncodeMessage(action ActionType, payload Msg) ([]byte, error)
EncodeMessage will do a PreCheck for the detailed-action-message and then pack it up to a staking-common-message using rlp encode.
func EndBlock ¶
func EndBlock(staking *Staking) core.BlockHookFn
EndBlock process slashing and rewarding for block
Types ¶
type ActionType ¶
type ActionType uint8
DelegateActionType is the type of delegate action
const ( ValidatorCreate ActionType = 0x1 + iota ValidatorUpdate ValidatorDeposit ValidatorWithDraw ValidatorChangeStatus ValidatorSettle )
split actions to groups
const ( DelegationAdd ActionType = 0x10 + iota // add delegation DelegationSub // subtract delegation DelegationSettle // settle delegation rewards )
type Evidence ¶
type Evidence struct { Type string `json:"type"` Data []byte `json:"data"` // contains filtered or unexported fields }
Evidence the evidence of validator's action
type EvidenceDoubleSign ¶
EvidenceDoubleSign data of dup-vote Deprecated: using EvidenceDoubleSignV5 instead.
type EvidenceDoubleSignV5 ¶ added in v1.0.0
type EvidenceDoubleSignV5 struct { Round uint64 RoundIndex uint32 SignerIdx uint32 VoteType uint8 Signs []*SignInfo }
EvidenceDoubleSignV5 is the data of dup-vote with bls signature.
type EvidenceInactive ¶
EvidenceInactive data of inactive
type LogData ¶
type LogData struct { Topic string `json:"topic"` Tags []string `json:"tags"` Data []byte `json:"data"` }
LogData LogData
type Message ¶
type Message struct { Action ActionType Payload []byte }
Message is the base message of a staking transaction
type Msg ¶
type Msg interface { PreCheck() error Hash() common.Hash Verify(nonce uint64, master common.Address) bool }
Msg is a interface for detailed action message
type PenaltyRecord ¶ added in v1.0.0
type SlashData ¶
type SlashData struct { Type uint8 `json:"type"` MainAddress common.Address `json:"mainAddress"` Total *big.Int `json:"penaltyAmount"` // total Records []*SlashWithdrawRecord `json:"records"` // from withdraw records Evidence interface{} `json:"evidence"` // confirmed evidence // contains filtered or unexported fields }
SlashData .
type SlashDataV5 ¶ added in v1.0.0
type SlashDataV5 struct { Type uint8 `json:"type"` MainAddress common.Address `json:"mainAddress"` Total *big.Int `json:"penaltyAmount"` // total FromWithdraw []*SlashWithdrawRecord `json:"fromWithdraw"` // from withdraw records FromDeposit []*PenaltyRecord `json:"fromDeposit"` }
type SlashWithdrawRecord ¶
type SlashWithdrawRecord struct { Token *big.Int `json:"token"` Record *state.WithdrawRecord `json:"record"` }
SlashWithdrawRecord save modified withdraw record
type Staking ¶
type Staking struct {
// contains filtered or unexported fields
}
Staking staking container
type TxConverter ¶
type TxConverter struct { }
func (*TxConverter) ApplyMessage ¶
func (t *TxConverter) ApplyMessage(msgCtx *core.MessageContext) ([]byte, uint64, bool, error)
func (*TxConverter) IntrinsicGas ¶
type TxCreateValidator ¶
type TxCreateValidator struct { Name string `json:"name"` // alias name for validator OperatorAddress common.Address `json:"operatorAddress"` // operator is the address who can manage the validator Coinbase common.Address `json:"coinbase"` // coinbase is the address that mining rewards will be send to MainPubKey hexutil.Bytes `json:"mainPubKey"` BlsPubKey hexutil.Bytes `json:"blsPubKey"` Value *big.Int `json:"value"` Nonce uint64 `json:"nonce"` CommissionRate uint16 `json:"commissionRate"` // number over ten-thousandth RiskObligation uint16 `json:"riskObligation"` AcceptDelegation uint16 `json:"acceptDelegation"` Role params.ValidatorRole `json:"role"` Sign hexutil.Bytes `json:"sign"` //hash(m.Hash().Bytes()) }
TxCreateValidator create a new validator
func (*TxCreateValidator) Hash ¶
func (m *TxCreateValidator) Hash() common.Hash
func (*TxCreateValidator) PreCheck ¶
func (m *TxCreateValidator) PreCheck() error
type TxDelegation ¶
type TxDelegation struct { Validator common.Address //validator main address Value *big.Int // the value to add or subtract }
TxDelegation contains module specific detail data for a delegation transaction
func (*TxDelegation) Hash ¶
func (t *TxDelegation) Hash() common.Hash
func (*TxDelegation) PreCheck ¶
func (t *TxDelegation) PreCheck() error
type TxDelegationSettle ¶
func (*TxDelegationSettle) Hash ¶
func (t *TxDelegationSettle) Hash() common.Hash
func (*TxDelegationSettle) PreCheck ¶
func (t *TxDelegationSettle) PreCheck() error
type TxUpdateValidator ¶
type TxUpdateValidator struct { Nonce uint64 `json:"nonce"` Name string `json:"name"` MainAddress common.Address `json:"mainAddress"` OperatorAddress common.Address `json:"operatorAddress"` Coinbase common.Address `json:"coinbase"` CommissionRate uint16 `json:"commissionRate"` // number over ten-thousandth RiskObligation uint16 `json:"riskObligation"` AcceptDelegation uint16 `json:"acceptDelegation"` Sign hexutil.Bytes `json:"sign"` // hash(m.Hash().Bytes()) }
TxUpdateValidator 修改validator的信息
func (*TxUpdateValidator) Hash ¶
func (m *TxUpdateValidator) Hash() common.Hash
func (*TxUpdateValidator) PreCheck ¶
func (m *TxUpdateValidator) PreCheck() error
type TxValidatorChangeStatus ¶
type TxValidatorChangeStatus struct { MainAddress common.Address `json:"mainAddress"` Status uint8 `json:"status"` Nonce uint64 `json:"nonce"` Sign hexutil.Bytes `json:"sign"` }
TxValidatorChangeStatus .
func (*TxValidatorChangeStatus) Hash ¶
func (m *TxValidatorChangeStatus) Hash() common.Hash
func (*TxValidatorChangeStatus) PreCheck ¶
func (m *TxValidatorChangeStatus) PreCheck() error
type TxValidatorDeposit ¶
type TxValidatorDeposit struct { MainAddress common.Address `json:"mainAddress"` Value *big.Int `json:"value"` Nonce uint64 `json:"nonce"` Sign hexutil.Bytes `json:"sign"` // hash(m.Hash().Bytes()) }
TxValidatorDeposit more deposit for validator
func (*TxValidatorDeposit) Hash ¶
func (m *TxValidatorDeposit) Hash() common.Hash
func (*TxValidatorDeposit) PreCheck ¶
func (m *TxValidatorDeposit) PreCheck() error
type TxValidatorSettle ¶
func (*TxValidatorSettle) Hash ¶
func (m *TxValidatorSettle) Hash() common.Hash
func (*TxValidatorSettle) PreCheck ¶
func (m *TxValidatorSettle) PreCheck() error
type TxValidatorWithdraw ¶
type TxValidatorWithdraw struct { MainAddress common.Address `json:"mainAddress"` Recipient common.Address `json:"recipient"` // tokens will be refunded to this account Value *big.Int `json:"value"` // tokens that the validator wants to withdraw Nonce uint64 `json:"nonce"` Sign hexutil.Bytes `json:"sign"` // hash(m.Hash().Bytes()) }
TxValidatorWithdraw .
func (*TxValidatorWithdraw) Hash ¶
func (m *TxValidatorWithdraw) Hash() common.Hash
func (*TxValidatorWithdraw) PreCheck ¶
func (m *TxValidatorWithdraw) PreCheck() error