Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type Address
- type Block
- type BlockInfo
- type BlockNumber
- type Committee
- type CommitteeState
- type ConflictSignature
- type ConflictingVotes
- type Decision
- type DisputePayload
- type ElectionPayload
- type EpochReward
- type EpochState
- type H256
- type LedgerInfo
- type LedgerInfoWithSignatures
- func (info *LedgerInfoWithSignatures) AggregatedPublicKey(committee Committee) (*bls12381.PointG1, error)
- func (info *LedgerInfoWithSignatures) EncodeBCS() []byte
- func (info *LedgerInfoWithSignatures) NextCommittee() (Committee, bool)
- func (info *LedgerInfoWithSignatures) NextEpochValidatorsSorted() []common.Hash
- func (info *LedgerInfoWithSignatures) ValidatorsSorted() []common.Hash
- func (info *LedgerInfoWithSignatures) Verify(committee Committee) (bool, error)
- type NodeLockStatus
- type NodeVotingPower
- type PivotBlockDecision
- type PoSAccounts
- type RegisterPayload
- type RetirePayload
- type Reward
- type RpcCommittee
- type RpcTermData
- type Signature
- type Status
- type Transaction
- type TransactionPayload
- type UpdateVotingPowerPayload
- type ValidatorConsensusInfo
- type ValidatorVerifier
- type VoteParamsInfo
- type VotePowerState
Constants ¶
const ( L = 64 H_IN_CHUNK_SIZE = 64 H_OUT_CHUNK_SIZE = 32 )
Variables ¶
var (
DST []byte = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_")
)
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Address Address `json:"address"` BlockNumber hexutil.Uint64 `json:"blockNumber"` Status NodeLockStatus `json:"status"` }
type Block ¶
type Block struct { Hash common.Hash `json:"hash"` Height hexutil.Uint64 `json:"height"` Epoch hexutil.Uint64 `json:"epoch"` Round hexutil.Uint64 `json:"round"` LastTxNumber hexutil.Uint64 `json:"lastTxNumber"` Miner *Address `json:"miner"` ParentHash common.Hash `json:"parentHash"` Timestamp hexutil.Uint64 `json:"timestamp"` PivotDecision *Decision `json:"pivotDecision"` // Transactions BlockTransactions `json:"transactions"` Signatures []Signature `json:"signatures"` }
type BlockInfo ¶ added in v1.5.4
type BlockInfo struct { /// Epoch number corresponds to the set of validators that are active for /// this block. Epoch hexutil.Uint64 `json:"epoch"` /// The consensus protocol is executed in rounds, which monotonically /// increase per epoch. Round hexutil.Uint64 `json:"round"` /// The identifier (hash) of the block. Id hexutil.Bytes `json:"id"` /// The accumulator root hash after executing this block. ExecutedStateId hexutil.Bytes `json:"executedStateId"` /// The version of the latest transaction after executing this block. Version hexutil.Uint64 `json:"version"` /// The timestamp this block was proposed by a proposer. TimestampUsecs hexutil.Uint64 `json:"timestampUsecs"` /// An optional field containing the next epoch info NextEpochState *EpochState `json:"nextEpochState"` /// TODO(lpl): Remove Option? /// The last pivot block selection after executing this block. /// None means choosing TreeGraph genesis as the first pivot block. Pivot *PivotBlockDecision `json:"pivot"` }
/ This structure contains all the information needed for tracking a block / without having access to the block or its execution output state. It / assumes that the block is the last block executed within the ledger.
type BlockNumber ¶
type BlockNumber struct {
// contains filtered or unexported fields
}
var ( BlockEarliest *BlockNumber = &BlockNumber{"earliest", 0} BlockLatestCommitted *BlockNumber = &BlockNumber{"latest_committed", 0} BlockLatestVoted *BlockNumber = &BlockNumber{"latest_voted", 0} )
func NewBlockNumber ¶
func NewBlockNumber(number uint64) BlockNumber
func (BlockNumber) MarshalText ¶
func (e BlockNumber) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*BlockNumber) String ¶
func (e *BlockNumber) String() string
String implements the fmt.Stringer interface
func (*BlockNumber) UnmarshalJSON ¶
func (e *BlockNumber) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Committee ¶ added in v1.5.7
type Committee struct {
// contains filtered or unexported fields
}
type CommitteeState ¶
type CommitteeState struct { CurrentCommittee RpcCommittee `json:"currentCommittee"` Elections []RpcTermData `json:"elections"` }
type ConflictSignature ¶
type ConflictingVotes ¶ added in v1.4.4
type DisputePayload ¶
type DisputePayload struct { Address Address `json:"address"` BlsPublicKey string `json:"blsPublicKey"` VrfPublicKey string `json:"vrfPublicKey"` ConflictingVotes ConflictingVotes `json:"conflictingVotes"` }
type ElectionPayload ¶
type EpochReward ¶
type EpochState ¶ added in v1.5.4
type EpochState struct { Epoch hexutil.Uint64 `json:"epoch"` Verifier ValidatorVerifier `json:"verifier"` VrfSeed hexutil.Bytes `json:"vrfSeed"` }
EpochState represents a trusted validator set to validate messages from the specific epoch, it could be updated with EpochChangeProof.
type LedgerInfo ¶ added in v1.5.4
type LedgerInfoWithSignatures ¶ added in v1.5.4
type LedgerInfoWithSignatures struct { LedgerInfo LedgerInfo `json:"ledgerInfo"` // The validator is identified by its account address: in order to verify // a signature one needs to retrieve the public key of the validator // for the given epoch. // // BLS signature in uncompressed format Signatures map[common.Hash]hexutil.Bytes `json:"signatures"` // Validators with uncompressed BLS public key (in 96 bytes) if next epoch // state available. Generally, this is used to verify BLS signatures at client side. NextEpochValidators map[common.Hash]hexutil.Bytes `json:"nextEpochValidators"` // Aggregated BLS signature in 192 bytes. AggregatedSignature hexutil.Bytes `json:"aggregatedSignature"` }
/ The validator node returns this structure which includes signatures / from validators that confirm the state. The client needs to only pass back / the LedgerInfo element since the validator node doesn't need to know the / signatures again when the client performs a query, those are only there for / the client to be able to verify the state
func (*LedgerInfoWithSignatures) AggregatedPublicKey ¶ added in v1.5.8
func (info *LedgerInfoWithSignatures) AggregatedPublicKey(committee Committee) (*bls12381.PointG1, error)
func (*LedgerInfoWithSignatures) EncodeBCS ¶ added in v1.5.7
func (info *LedgerInfoWithSignatures) EncodeBCS() []byte
func (*LedgerInfoWithSignatures) NextCommittee ¶ added in v1.5.7
func (info *LedgerInfoWithSignatures) NextCommittee() (Committee, bool)
func (*LedgerInfoWithSignatures) NextEpochValidatorsSorted ¶ added in v1.5.8
func (info *LedgerInfoWithSignatures) NextEpochValidatorsSorted() []common.Hash
func (*LedgerInfoWithSignatures) ValidatorsSorted ¶ added in v1.5.8
func (info *LedgerInfoWithSignatures) ValidatorsSorted() []common.Hash
type NodeLockStatus ¶
type NodeLockStatus struct { InQueue []VotePowerState `json:"inQueue"` Locked hexutil.Uint64 `json:"locked"` OutQueue []VotePowerState `json:"outQueue"` Unlocked hexutil.Uint64 `json:"unlocked"` // Equals to the summation of in_queue + locked AvailableVotes hexutil.Uint64 `json:"availableVotes"` ForceRetired *hexutil.Uint64 `json:"forceRetired"` // If the staking is forfeited, the unlocked votes before forfeiting is // exempted. Forfeited hexutil.Uint64 `json:"forfeited"` }
type NodeVotingPower ¶
type PivotBlockDecision ¶
type PoSAccounts ¶ added in v1.5.8
func (PoSAccounts) Len ¶ added in v1.5.8
func (s PoSAccounts) Len() int
func (PoSAccounts) Less ¶ added in v1.5.8
func (s PoSAccounts) Less(i, j int) bool
func (PoSAccounts) Swap ¶ added in v1.5.8
func (s PoSAccounts) Swap(i, j int)
type RegisterPayload ¶
type RetirePayload ¶
type Reward ¶
type Reward struct { PosAddress Address `json:"posAddress"` PowAddress cfxaddress.Address `json:"powAddress"` Reward hexutil.Big `json:"reward"` }
type RpcCommittee ¶
type RpcTermData ¶
type RpcTermData struct { StartBlockNumber hexutil.Uint64 `json:"startBlockNumber"` IsFinalized bool `json:"isFinalized"` TopElectingNodes []NodeVotingPower `json:"topElectingNodes"` }
type Transaction ¶
type Transaction struct { Hash common.Hash `json:"hash"` From Address `json:"from"` BlockHash *common.Hash `json:"blockHash"` BlockNumber *hexutil.Uint64 `json:"blockNumber"` Timestamp *hexutil.Uint64 `json:"timestamp"` Number hexutil.Uint64 `json:"number"` Payload *TransactionPayload `json:"payload"` Status *string `json:"status"` Type string `json:"type"` }
func (*Transaction) UnmarshalJSON ¶
func (b *Transaction) UnmarshalJSON(data []byte) error
type TransactionPayload ¶
type TransactionPayload struct { ElectionPayload RetirePayload RegisterPayload UpdateVotingPowerPayload PivotBlockDecision DisputePayload // contains filtered or unexported fields }
func (TransactionPayload) MarshalJSON ¶
func (b TransactionPayload) MarshalJSON() ([]byte, error)
func (*TransactionPayload) SetTransactionType ¶
func (t *TransactionPayload) SetTransactionType(txType string)
func (*TransactionPayload) UnmarshalJSON ¶
func (b *TransactionPayload) UnmarshalJSON(data []byte) error
type ValidatorConsensusInfo ¶ added in v1.5.4
type ValidatorConsensusInfo struct { PublicKey hexutil.Bytes `json:"publicKey"` // compressed BLS public key VrfPublicKey *hexutil.Bytes `json:"vrfPublicKey,omitempty"` // nil if VRF not needed VotingPower hexutil.Uint64 `json:"votingPower"` }
Helper struct to manage validator information for validation
type ValidatorVerifier ¶ added in v1.5.4
type ValidatorVerifier struct { // An ordered map of each validator's on-chain account address to its // pubkeys and voting power. AddressToValidatorInfo map[common.Hash]ValidatorConsensusInfo `json:"addressToValidatorInfo"` // The minimum voting power required to achieve a quorum QuorumVotingPower hexutil.Uint64 `json:"quorumVotingPower"` // Total voting power of all validators (cached from // address_to_validator_info) TotalVotingPower hexutil.Uint64 `json:"totalVotingPower"` }
Supports validation of signatures for known authors with individual voting powers. This struct can be used for all signature verification operations including block and network signature verification, respectively.