Documentation ¶
Index ¶
- Constants
- Variables
- func BloomLookup(bin Bloom, topic bytesBacked) bool
- func Bytestoi(arr []byte) uint64
- func CalculateRootHash(items []common.Bytes) common.Hash
- func Itobytes(val uint64) []byte
- func ReadRecord(file *os.File, obj interface{}) (uint64, error)
- func ResetTestBlocks()
- func WriteLastCheckpoint(writer *bufio.Writer, lastCheckpoint *LastCheckpoint) error
- func WriteMetadata(writer *bufio.Writer, metadata *SnapshotMetadata) error
- func WriteRecord(writer *bufio.Writer, k, v common.Bytes) error
- func WriteSnapshotHeader(writer *bufio.Writer, snapshotHeader *SnapshotHeader) error
- type AggregatedEENVotes
- func (a *AggregatedEENVotes) Abs() int
- func (a *AggregatedEENVotes) Copy() *AggregatedEENVotes
- func (a *AggregatedEENVotes) Merge(b *AggregatedEENVotes) (*AggregatedEENVotes, error)
- func (a *AggregatedEENVotes) Pick(b *AggregatedEENVotes) (*AggregatedEENVotes, error)
- func (a *AggregatedEENVotes) String() string
- func (a *AggregatedEENVotes) Validate(eenp EliteEdgeNodePool) result.Result
- type AggregatedVotes
- func (a *AggregatedVotes) Abs() int
- func (a *AggregatedVotes) Copy() *AggregatedVotes
- func (a *AggregatedVotes) Merge(b *AggregatedVotes) (*AggregatedVotes, error)
- func (a *AggregatedVotes) Pick(b *AggregatedVotes) (*AggregatedVotes, error)
- func (a *AggregatedVotes) Sign(key *bls.SecretKey, signerIdx int) bool
- func (a *AggregatedVotes) String() string
- func (a *AggregatedVotes) Validate(gcp *GuardianCandidatePool) result.Result
- type BackupBlock
- type Block
- type BlockHeader
- func (h *BlockHeader) CalculateHash() common.Hash
- func (h *BlockHeader) DecodeRLP(stream *rlp.Stream) error
- func (h *BlockHeader) EncodeRLP(w io.Writer) error
- func (h *BlockHeader) Hash() common.Hash
- func (h *BlockHeader) SetSignature(sig *crypto.Signature)
- func (h *BlockHeader) SignBytes() common.Bytes
- func (h *BlockHeader) String() string
- func (h *BlockHeader) UpdateHash() common.Hash
- func (h *BlockHeader) Validate(chainID string) result.Result
- type BlockStatus
- func (bs BlockStatus) IsCommitted() bool
- func (bs BlockStatus) IsDirectlyFinalized() bool
- func (bs BlockStatus) IsFinalized() bool
- func (bs BlockStatus) IsIndirectlyFinalized() bool
- func (bs BlockStatus) IsInvalid() bool
- func (bs BlockStatus) IsPending() bool
- func (bs BlockStatus) IsTrusted() bool
- func (bs BlockStatus) IsValid() bool
- type Bloom
- func (b *Bloom) Add(d *big.Int)
- func (b Bloom) Big() *big.Int
- func (b Bloom) Bytes() []byte
- func (b Bloom) MarshalText() ([]byte, error)
- func (b *Bloom) SetBytes(d []byte)
- func (b Bloom) Test(test *big.Int) bool
- func (b Bloom) TestBytes(test []byte) bool
- func (b *Bloom) UnmarshalText(input []byte) error
- type ByID
- type CommitCertificate
- type ConsensusEngine
- type EENBlsSigMsg
- type EENVote
- type EliteEdgeNode
- func (een *EliteEdgeNode) DepositStake(source common.Address, amount *big.Int) error
- func (een *EliteEdgeNode) ReturnStake(source common.Address, currentHeight uint64) (*Stake, error)
- func (een *EliteEdgeNode) String() string
- func (een *EliteEdgeNode) WithdrawStake(source common.Address, currentHeight uint64) (*Stake, error)
- type EliteEdgeNodePool
- type ExtendedBlock
- func (eb *ExtendedBlock) DecodeRLP(stream *rlp.Stream) error
- func (eb *ExtendedBlock) EncodeRLP(w io.Writer) error
- func (eb *ExtendedBlock) Hash() common.Hash
- func (eb *ExtendedBlock) MarshalJSON() ([]byte, error)
- func (eb *ExtendedBlock) ShortString() string
- func (eb *ExtendedBlock) String() string
- type ExtendedBlockInnerJSON
- type Guardian
- type GuardianCandidatePool
- func (gcp *GuardianCandidatePool) Add(g *Guardian) bool
- func (gcp *GuardianCandidatePool) Contains(g common.Address) bool
- func (gcp *GuardianCandidatePool) DepositStake(source common.Address, holder common.Address, amount *big.Int, ...) (err error)
- func (gcp *GuardianCandidatePool) GetWithHolderAddress(addr common.Address) *Guardian
- func (gcp *GuardianCandidatePool) Hash() common.Hash
- func (gcp *GuardianCandidatePool) Index(pubkey *bls.PublicKey) int
- func (gcp *GuardianCandidatePool) Len() int
- func (gcp *GuardianCandidatePool) Less(i, j int) bool
- func (gcp *GuardianCandidatePool) PubKeys() []*bls.PublicKey
- func (gcp *GuardianCandidatePool) Remove(g common.Address) bool
- func (gcp *GuardianCandidatePool) ReturnStakes(currentHeight uint64) []*Stake
- func (gcp *GuardianCandidatePool) Swap(i, j int)
- func (gcp *GuardianCandidatePool) WithStake() *GuardianCandidatePool
- func (gcp *GuardianCandidatePool) WithdrawStake(source common.Address, holder common.Address, currentHeight uint64) error
- type HardcodeBlockHash
- type LastCheckpoint
- type Ledger
- type Proposal
- type RewardDistribution
- type SnapshotBlockTrio
- type SnapshotFirstBlock
- type SnapshotHeader
- type SnapshotMetadata
- type SnapshotSecondBlock
- type SnapshotThirdBlock
- type SnapshotTrieRecord
- type Stake
- type StakeHolder
- type StakeJSON
- type TxInfo
- type VCPProof
- func (vp *VCPProof) DecodeRLP(stream *rlp.Stream) error
- func (vp VCPProof) EncodeRLP(w io.Writer) error
- func (vp *VCPProof) Get(key []byte) (value []byte, err error)
- func (vp VCPProof) GetKvs() []*proofKV
- func (vp *VCPProof) Has(key []byte) (bool, error)
- func (vp *VCPProof) Put(key []byte, value []byte) error
- type Validator
- type ValidatorCandidatePool
- func (vcp *ValidatorCandidatePool) DepositStake(source common.Address, holder common.Address, amount *big.Int, ...) (err error)
- func (vcp *ValidatorCandidatePool) FindStakeDelegate(delegateAddr common.Address) *StakeHolder
- func (vcp *ValidatorCandidatePool) GetTopStakeHolders(maxNumStakeHolders int) []*StakeHolder
- func (vcp *ValidatorCandidatePool) ReturnStakes(currentHeight uint64) []*Stake
- func (vcp *ValidatorCandidatePool) WithdrawStake(source common.Address, holder common.Address, currentHeight uint64) error
- type ValidatorManager
- type ValidatorSet
- func (s *ValidatorSet) AddValidator(validator Validator)
- func (s *ValidatorSet) Copy() *ValidatorSet
- func (s *ValidatorSet) Equals(t *ValidatorSet) bool
- func (s *ValidatorSet) GetValidator(id common.Address) (Validator, error)
- func (s *ValidatorSet) HasMajority(votes *VoteSet) bool
- func (s *ValidatorSet) HasMajorityVotes(votes []Vote) bool
- func (s *ValidatorSet) SetValidators(validators []Validator)
- func (s *ValidatorSet) Size() int
- func (s *ValidatorSet) String() string
- func (s *ValidatorSet) TotalStake() *big.Int
- func (s *ValidatorSet) Validators() []Validator
- type ViewSelector
- type Vote
- type VoteByID
- type VoteSet
- func (s *VoteSet) AddVote(vote Vote)
- func (s *VoteSet) Copy() *VoteSet
- func (s *VoteSet) DecodeRLP(stream *rlp.Stream) error
- func (s *VoteSet) EncodeRLP(w io.Writer) error
- func (s *VoteSet) FilterByValidators(validators *ValidatorSet) *VoteSet
- func (s *VoteSet) IsEmpty() bool
- func (s *VoteSet) MarshalJSON() ([]byte, error)
- func (s *VoteSet) Merge(another *VoteSet) *VoteSet
- func (s *VoteSet) Size() int
- func (s *VoteSet) String() string
- func (s *VoteSet) UniqueVoter() *VoteSet
- func (s *VoteSet) UniqueVoterAndBlock() *VoteSet
- func (s *VoteSet) UnmarshalJSON(b []byte) error
- func (s *VoteSet) Validate() result.Result
- func (s *VoteSet) Votes() []Vote
Constants ¶
const ( // BloomByteLength represents the number of bytes used in a header log bloom. BloomByteLength = 256 // BloomBitLength represents the number of bits used in a header log bloom. BloomBitLength = 8 * BloomByteLength )
const ( MainnetChainID = "mainnet" MainnetGenesisBlockHash = "0xd8836c6cf3c3ccea0b015b4ed0f9efb0ffe6254db793a515843c9d0f68cbab65" GenesisBlockHeight = uint64(0) )
const ( SVStart = iota SVEnd )
const ( StakeForValidator uint8 = 0 StakeForGuardian uint8 = 1 StakeForEliteEdgeNode uint8 = 2 ReturnLockingPeriod uint64 = 28800 // number of blocks, approximately 2 days with 6 second block time InvalidReturnHeight uint64 = ^uint64(0) // max uint64 )
const BlockTrioStoreKeyPrefix = "prooftrio_"
const ( // MaxNumRegularTxsPerBlock represents the max number of regular transaction can be inclulded in one block MaxNumRegularTxsPerBlock int = 512 )
const SnapshotHeaderMagic = "ThetaToDaMoon"
Variables ¶
var ( EmptyRootHash = CalculateRootHash([]common.Bytes{}) SuicidedCodeHash = common.HexToHash("deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead") )
var ( MinEliteEdgeNodeStakeDeposit *big.Int MaxEliteEdgeNodeStakeDeposit *big.Int )
var ( MinGuardianStakeDeposit *big.Int MinGuardianStakeDeposit1000 *big.Int )
var ( MinValidatorStakeDeposit *big.Int MinValidatorStakeDeposit200K *big.Int )
var Bloom9 = bloom9
var DefaultSigner *crypto.PrivateKey
var ( // ErrValidatorNotFound for ID is not found in validator set. ErrValidatorNotFound = errors.New("ValidatorNotFound") )
var HardcodeBlockHashes = map[uint64]string{}
HardcodeBlockHashes maps block heights to hardcode block hashes
var TestBlocksLock = &sync.Mutex{}
var (
Zero *big.Int
)
Functions ¶
func BloomLookup ¶
func ResetTestBlocks ¶
func ResetTestBlocks()
func WriteLastCheckpoint ¶
func WriteLastCheckpoint(writer *bufio.Writer, lastCheckpoint *LastCheckpoint) error
func WriteMetadata ¶
func WriteMetadata(writer *bufio.Writer, metadata *SnapshotMetadata) error
func WriteSnapshotHeader ¶
func WriteSnapshotHeader(writer *bufio.Writer, snapshotHeader *SnapshotHeader) error
Types ¶
type AggregatedEENVotes ¶
type AggregatedEENVotes struct { Block common.Hash // Hash of the block. Multiplies []uint32 // Multiplies of each signer. Addresses []common.Address // Addresses of each signer Signature *bls.Signature // Aggregated signature. }
AggregatedEENVotes represents the aggregated elite edge node votes on a block.
func NewAggregatedEENVotes ¶
func NewAggregatedEENVotes(block common.Hash) *AggregatedEENVotes
func (*AggregatedEENVotes) Abs ¶
func (a *AggregatedEENVotes) Abs() int
Abs returns the number of voted elite edge nodes in the vote
func (*AggregatedEENVotes) Copy ¶
func (a *AggregatedEENVotes) Copy() *AggregatedEENVotes
Copy clones the aggregated votes
func (*AggregatedEENVotes) Merge ¶
func (a *AggregatedEENVotes) Merge(b *AggregatedEENVotes) (*AggregatedEENVotes, error)
Merge creates a new aggregation that combines two vote sets. Returns nil, nil if input vote is a subset of current vote.
func (*AggregatedEENVotes) Pick ¶
func (a *AggregatedEENVotes) Pick(b *AggregatedEENVotes) (*AggregatedEENVotes, error)
Pick selects better vote from two votes.
func (*AggregatedEENVotes) String ¶
func (a *AggregatedEENVotes) String() string
func (*AggregatedEENVotes) Validate ¶
func (a *AggregatedEENVotes) Validate(eenp EliteEdgeNodePool) result.Result
Validate performs basic validation of the voteset.
type AggregatedVotes ¶
type AggregatedVotes struct { Block common.Hash // Hash of the block. Gcp common.Hash // Hash of guardian candidate pool. Multiplies []uint32 // Multiplies of each signer. Signature *bls.Signature // Aggregated signiature. }
AggregatedVotes represents votes on a block.
func NewAggregateVotes ¶
func NewAggregateVotes(block common.Hash, gcp *GuardianCandidatePool) *AggregatedVotes
func (*AggregatedVotes) Abs ¶
func (a *AggregatedVotes) Abs() int
Abs returns the number of voted guardians in the vote
func (*AggregatedVotes) Copy ¶
func (a *AggregatedVotes) Copy() *AggregatedVotes
Copy clones the aggregated votes
func (*AggregatedVotes) Merge ¶
func (a *AggregatedVotes) Merge(b *AggregatedVotes) (*AggregatedVotes, error)
Merge creates a new aggregation that combines two vote sets. Returns nil, nil if input vote is a subset of current vote.
func (*AggregatedVotes) Pick ¶
func (a *AggregatedVotes) Pick(b *AggregatedVotes) (*AggregatedVotes, error)
Pick selects better vote from two votes.
func (*AggregatedVotes) Sign ¶
func (a *AggregatedVotes) Sign(key *bls.SecretKey, signerIdx int) bool
Sign adds signer's signature. Returns false if signer has already signed.
func (*AggregatedVotes) String ¶
func (a *AggregatedVotes) String() string
func (*AggregatedVotes) Validate ¶
func (a *AggregatedVotes) Validate(gcp *GuardianCandidatePool) result.Result
Validate verifies the voteset.
type BackupBlock ¶
type BackupBlock struct { Block *ExtendedBlock Votes *VoteSet `rlp:"nil"` }
func (*BackupBlock) String ¶
func (b *BackupBlock) String() string
type Block ¶
type Block struct { *BlockHeader Txs []common.Bytes `json:"transactions"` }
Block represents a block in chain.
func CreateTestBlock ¶
CreateTestBlock creates a block for testing.
func GetTestBlock ¶
type BlockHeader ¶
type BlockHeader struct { ChainID string Epoch uint64 Height uint64 Parent common.Hash HCC CommitCertificate GuardianVotes *AggregatedVotes `rlp:"nil"` // Added in Theta2.0 fork. EliteEdgeNodeVotes *AggregatedEENVotes `rlp:"nil"` // Added in Theta3.0 fork. TxHash common.Hash ReceiptHash common.Hash `json:"-"` Bloom Bloom `json:"-"` StateHash common.Hash Timestamp *big.Int Proposer common.Address Signature *crypto.Signature // contains filtered or unexported fields }
BlockHeader contains the essential information of a block.
func (*BlockHeader) CalculateHash ¶
func (h *BlockHeader) CalculateHash() common.Hash
func (*BlockHeader) DecodeRLP ¶
func (h *BlockHeader) DecodeRLP(stream *rlp.Stream) error
DecodeRLP implements RLP Decoder interface.
func (*BlockHeader) EncodeRLP ¶
func (h *BlockHeader) EncodeRLP(w io.Writer) error
EncodeRLP implements RLP Encoder interface.
func (*BlockHeader) SetSignature ¶
func (h *BlockHeader) SetSignature(sig *crypto.Signature)
SetSignature sets given signature in header.
func (*BlockHeader) SignBytes ¶
func (h *BlockHeader) SignBytes() common.Bytes
SignBytes returns raw bytes to be signed.
func (*BlockHeader) String ¶
func (h *BlockHeader) String() string
func (*BlockHeader) UpdateHash ¶
func (h *BlockHeader) UpdateHash() common.Hash
UpdateHash recalculate hash of header.
type BlockStatus ¶
type BlockStatus byte
const ( BlockStatusPending BlockStatus = BlockStatus(iota) BlockStatusValid BlockStatusInvalid BlockStatusCommitted BlockStatusDirectlyFinalized BlockStatusIndirectlyFinalized BlockStatusTrusted BlockStatusDisposed )
Block status transitions:
+-------+ +-------+ +-------------------+ |Pending+---+------>Invalid| +----->IndirectlyFinalized| +-------+ | +-------+ | +-------------------+
| | | +-----+ +---------+ | +-----------------+ +------>Valid+-------->Committed+---+----->DirectlyFinalized| +-----+ +---------+ +-----------------+
func (BlockStatus) IsCommitted ¶
func (bs BlockStatus) IsCommitted() bool
func (BlockStatus) IsDirectlyFinalized ¶
func (bs BlockStatus) IsDirectlyFinalized() bool
func (BlockStatus) IsFinalized ¶
func (bs BlockStatus) IsFinalized() bool
func (BlockStatus) IsIndirectlyFinalized ¶
func (bs BlockStatus) IsIndirectlyFinalized() bool
func (BlockStatus) IsInvalid ¶
func (bs BlockStatus) IsInvalid() bool
func (BlockStatus) IsPending ¶
func (bs BlockStatus) IsPending() bool
func (BlockStatus) IsTrusted ¶
func (bs BlockStatus) IsTrusted() bool
func (BlockStatus) IsValid ¶
func (bs BlockStatus) IsValid() bool
IsValid returns whether block has been validated.
type Bloom ¶
type Bloom [BloomByteLength]byte
Bloom represents a 2048 bit bloom filter.
func BytesToBloom ¶
BytesToBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.
func (Bloom) MarshalText ¶
MarshalText encodes b as a hex string with 0x prefix.
func (*Bloom) SetBytes ¶
SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.
func (*Bloom) UnmarshalText ¶
UnmarshalText b as a hex string with 0x prefix.
type CommitCertificate ¶
CommitCertificate represents a commit made a majority of validators.
func (CommitCertificate) Copy ¶
func (cc CommitCertificate) Copy() CommitCertificate
Copy creates a copy of this commit certificate.
func (CommitCertificate) IsValid ¶
func (cc CommitCertificate) IsValid(validators *ValidatorSet) bool
IsValid checks if a CommitCertificate is valid.
func (CommitCertificate) String ¶
func (cc CommitCertificate) String() string
type ConsensusEngine ¶
type ConsensusEngine interface { ID() string PrivateKey() *crypto.PrivateKey GetTip(includePendingBlockingLeaf bool) *ExtendedBlock GetEpoch() uint64 GetLedger() Ledger AddMessage(msg interface{}) FinalizedBlocks() chan *Block GetLastFinalizedBlock() *ExtendedBlock }
ConsensusEngine is the interface of a consensus engine.
type EENBlsSigMsg ¶
type EENVote ¶
type EENVote struct { Block common.Hash // Hash of the block. Height uint64 // Height of the block, just for reference Address common.Address // Address of the edge node. Signature *bls.Signature // Aggregated signiature. Timestamp *big.Int // Unix timestamp when the EENVote was created, just for reference }
EENVote represents the vote for a block from an elite edge node.
func NewEENVote ¶
type EliteEdgeNode ¶
type EliteEdgeNode struct { *StakeHolder Pubkey *bls.PublicKey `json:"-"` }
func NewEliteEdgeNode ¶
func NewEliteEdgeNode(stakeHolder *StakeHolder, pubkey *bls.PublicKey) *EliteEdgeNode
func (*EliteEdgeNode) DepositStake ¶
func (*EliteEdgeNode) ReturnStake ¶
func (*EliteEdgeNode) String ¶
func (een *EliteEdgeNode) String() string
func (*EliteEdgeNode) WithdrawStake ¶
type EliteEdgeNodePool ¶
type EliteEdgeNodePool interface { Contains(eenAddr common.Address) bool GetPubKeys(eenAddrs []common.Address) []*bls.PublicKey Get(eenAddr common.Address) *EliteEdgeNode Upsert(een *EliteEdgeNode) GetAll(withstake bool) []*EliteEdgeNode DepositStake(source common.Address, holder common.Address, amount *big.Int, pubkey *bls.PublicKey, blockHeight uint64) (err error) WithdrawStake(source common.Address, holder common.Address, currentHeight uint64) (*Stake, error) RandomRewardWeight(block common.Hash, eenAddr common.Address) int }
type ExtendedBlock ¶
type ExtendedBlock struct { *Block Children []common.Hash `json:"children"` Status BlockStatus `json:"status"` HasValidatorUpdate bool }
ExtendedBlock is wrapper over Block, containing extra information related to the block.
func (*ExtendedBlock) DecodeRLP ¶
func (eb *ExtendedBlock) DecodeRLP(stream *rlp.Stream) error
DecodeRLP implements RLP Decoder interface.
func (*ExtendedBlock) EncodeRLP ¶
func (eb *ExtendedBlock) EncodeRLP(w io.Writer) error
EncodeRLP implements RLP Encoder interface.
func (*ExtendedBlock) MarshalJSON ¶
func (eb *ExtendedBlock) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
func (*ExtendedBlock) ShortString ¶
func (eb *ExtendedBlock) ShortString() string
ShortString returns a short string describing the block.
func (*ExtendedBlock) String ¶
func (eb *ExtendedBlock) String() string
type ExtendedBlockInnerJSON ¶
type ExtendedBlockInnerJSON ExtendedBlock
type Guardian ¶
type Guardian struct { *StakeHolder Pubkey *bls.PublicKey `json:"-"` }
type GuardianCandidatePool ¶
type GuardianCandidatePool struct {
SortedGuardians []*Guardian // Guardians sorted by holder address.
}
func NewGuardianCandidatePool ¶
func NewGuardianCandidatePool() *GuardianCandidatePool
NewGuardianCandidatePool creates a new instance of GuardianCandidatePool.
func (*GuardianCandidatePool) Add ¶
func (gcp *GuardianCandidatePool) Add(g *Guardian) bool
Add inserts guardian into the pool; returns false if guardian is already added.
func (*GuardianCandidatePool) Contains ¶
func (gcp *GuardianCandidatePool) Contains(g common.Address) bool
Contains checks if given address is in the pool.
func (*GuardianCandidatePool) DepositStake ¶
func (*GuardianCandidatePool) GetWithHolderAddress ¶
func (gcp *GuardianCandidatePool) GetWithHolderAddress(addr common.Address) *Guardian
GetWithHolderAddress returns the guardian node correspond to the stake holder in the pool. Returns nil if not found.
func (*GuardianCandidatePool) Hash ¶
func (gcp *GuardianCandidatePool) Hash() common.Hash
Hash calculates the hash of gcp.
func (*GuardianCandidatePool) Index ¶
func (gcp *GuardianCandidatePool) Index(pubkey *bls.PublicKey) int
Index returns index of a public key in the pool. Returns -1 if not found.
func (*GuardianCandidatePool) Len ¶
func (gcp *GuardianCandidatePool) Len() int
Implements sort.Interface for Guardians based on the Address field.
func (*GuardianCandidatePool) Less ¶
func (gcp *GuardianCandidatePool) Less(i, j int) bool
func (*GuardianCandidatePool) PubKeys ¶
func (gcp *GuardianCandidatePool) PubKeys() []*bls.PublicKey
PubKeys exports guardians' public keys.
func (*GuardianCandidatePool) Remove ¶
func (gcp *GuardianCandidatePool) Remove(g common.Address) bool
Remove removes a guardian from the pool; returns false if guardian is not found.
func (*GuardianCandidatePool) ReturnStakes ¶
func (gcp *GuardianCandidatePool) ReturnStakes(currentHeight uint64) []*Stake
func (*GuardianCandidatePool) Swap ¶
func (gcp *GuardianCandidatePool) Swap(i, j int)
func (*GuardianCandidatePool) WithStake ¶
func (gcp *GuardianCandidatePool) WithStake() *GuardianCandidatePool
WithStake returns a new pool with withdrawn guardians filtered out.
func (*GuardianCandidatePool) WithdrawStake ¶
type HardcodeBlockHash ¶
type LastCheckpoint ¶
type LastCheckpoint struct { CheckpointHeader *BlockHeader IntermediateHeaders []*BlockHeader }
type Ledger ¶
type Ledger interface { GetCurrentBlock() *Block ScreenTxUnsafe(rawTx common.Bytes) result.Result ScreenTx(rawTx common.Bytes) (priority *TxInfo, res result.Result) ProposeBlockTxs(block *Block, shouldIncludeValidatorUpdateTxs bool) (stateRootHash common.Hash, blockRawTxs []common.Bytes, res result.Result) ApplyBlockTxs(block *Block) result.Result ApplyBlockTxsForChainCorrection(block *Block) (common.Hash, result.Result) //ResetState(height uint64, rootHash common.Hash) result.Result ResetState(block *Block) result.Result FinalizeState(height uint64, rootHash common.Hash) result.Result GetFinalizedValidatorCandidatePool(blockHash common.Hash, isNext bool) (*ValidatorCandidatePool, error) GetGuardianCandidatePool(blockHash common.Hash) (*GuardianCandidatePool, error) GetEliteEdgeNodePoolOfLastCheckpoint(blockHash common.Hash) (EliteEdgeNodePool, error) PruneState(endHeight uint64) error }
Ledger defines the interface of the ledger
type Proposal ¶
type Proposal struct { Block *Block `rlp:"nil"` ProposerID common.Address Votes *VoteSet `rlp:"nil"` }
Proposal represents a proposal of a new block.
type RewardDistribution ¶
type RewardDistribution struct { StakeHolder common.Address // the stake delegate, i.e. a guardian node or an elite edge node address Beneficiary common.Address // the beneficiary to split the reward SplitBasisPoint uint // An integer between 0 and 10000, representing the fraction of the reward the beneficiary should get (in terms of 1/10000), https://en.wikipedia.org/wiki/Basis_point }
func NewRewardDistribution ¶
type SnapshotBlockTrio ¶
type SnapshotBlockTrio struct { First SnapshotFirstBlock Second SnapshotSecondBlock Third SnapshotThirdBlock }
type SnapshotFirstBlock ¶
type SnapshotFirstBlock struct { Header *BlockHeader Proof VCPProof }
type SnapshotHeader ¶
type SnapshotMetadata ¶
type SnapshotMetadata struct { ProofTrios []SnapshotBlockTrio TailTrio SnapshotBlockTrio }
type SnapshotSecondBlock ¶
type SnapshotSecondBlock struct {
Header *BlockHeader
}
type SnapshotThirdBlock ¶
type SnapshotThirdBlock struct { Header *BlockHeader VoteSet *VoteSet }
type SnapshotTrieRecord ¶
type Stake ¶
type Stake struct { Holder common.Address `rlp:"-"` // Keep reference to holder in memory to process split Source common.Address Amount *big.Int Withdrawn bool ReturnHeight uint64 }
func (Stake) MarshalJSON ¶
func (*Stake) UnmarshalJSON ¶
type StakeHolder ¶
TODO: Should rename StakeHolder to StakeDelegate
func NewStakeHolder ¶
func NewStakeHolder(holder common.Address, stakes []*Stake) *StakeHolder
func (*StakeHolder) String ¶
func (sh *StakeHolder) String() string
func (*StakeHolder) TotalStake ¶
func (sh *StakeHolder) TotalStake() *big.Int
type StakeJSON ¶
type StakeJSON struct { Source common.Address `json:"source"` Amount *common.JSONBig `json:"amount"` Withdrawn bool `json:"withdrawn"` ReturnHeight *common.JSONBig `json:"return_height"` }
func NewStakeJSON ¶
type VCPProof ¶
type VCPProof struct {
// contains filtered or unexported fields
}
type Validator ¶
Validator contains the public information of a validator.
func NewValidator ¶
NewValidator creates a new validator instance.
type ValidatorCandidatePool ¶
type ValidatorCandidatePool struct {
SortedCandidates []*StakeHolder
}
func (*ValidatorCandidatePool) DepositStake ¶
func (*ValidatorCandidatePool) FindStakeDelegate ¶
func (vcp *ValidatorCandidatePool) FindStakeDelegate(delegateAddr common.Address) *StakeHolder
func (*ValidatorCandidatePool) GetTopStakeHolders ¶
func (vcp *ValidatorCandidatePool) GetTopStakeHolders(maxNumStakeHolders int) []*StakeHolder
func (*ValidatorCandidatePool) ReturnStakes ¶
func (vcp *ValidatorCandidatePool) ReturnStakes(currentHeight uint64) []*Stake
func (*ValidatorCandidatePool) WithdrawStake ¶
type ValidatorManager ¶
type ValidatorManager interface { SetConsensusEngine(consensus ConsensusEngine) GetProposer(blockHash common.Hash, epoch uint64) Validator GetNextProposer(blockHash common.Hash, epoch uint64) Validator GetValidatorSet(blockHash common.Hash) *ValidatorSet GetNextValidatorSet(blockHash common.Hash) *ValidatorSet }
ValidatorManager is the component for managing validator related logic for consensus engine.
type ValidatorSet ¶
type ValidatorSet struct {
// contains filtered or unexported fields
}
ValidatorSet represents a set of validators.
func NewValidatorSet ¶
func NewValidatorSet() *ValidatorSet
NewValidatorSet returns a new instance of ValidatorSet.
func (*ValidatorSet) AddValidator ¶
func (s *ValidatorSet) AddValidator(validator Validator)
AddValidator adds a validator to the validator set.
func (*ValidatorSet) Copy ¶
func (s *ValidatorSet) Copy() *ValidatorSet
Copy creates a copy of this validator set.
func (*ValidatorSet) Equals ¶
func (s *ValidatorSet) Equals(t *ValidatorSet) bool
Equals checks whether the validator set is the same as another validator set
func (*ValidatorSet) GetValidator ¶
func (s *ValidatorSet) GetValidator(id common.Address) (Validator, error)
GetValidator returns a validator if a matching ID is found.
func (*ValidatorSet) HasMajority ¶
func (s *ValidatorSet) HasMajority(votes *VoteSet) bool
HasMajority checks whether a vote set has reach majority.
func (*ValidatorSet) HasMajorityVotes ¶
func (s *ValidatorSet) HasMajorityVotes(votes []Vote) bool
HasMajorityVotes checks whether a vote set has reach majority.
func (*ValidatorSet) SetValidators ¶
func (s *ValidatorSet) SetValidators(validators []Validator)
SetValidators sets validators
func (*ValidatorSet) Size ¶
func (s *ValidatorSet) Size() int
Size returns the number of the validators in the validator set.
func (*ValidatorSet) String ¶
func (s *ValidatorSet) String() string
String represents the string representation of the validator set
func (*ValidatorSet) TotalStake ¶
func (s *ValidatorSet) TotalStake() *big.Int
TotalStake returns the total stake of the validators in the set.
func (*ValidatorSet) Validators ¶
func (s *ValidatorSet) Validators() []Validator
Validators returns a slice of validators.
type ViewSelector ¶
type ViewSelector int
const ( DeliveredView ViewSelector = 1 CheckedView ViewSelector = 2 ScreenedView ViewSelector = 3 )
type Vote ¶
type Vote struct { Block common.Hash // Hash of the tip as seen by the voter. Height uint64 // Height of the tip Epoch uint64 // Voter's current epoch. It doesn't need to equal the epoch in the block above. ID common.Address // Voter's address. Signature *crypto.Signature }
Vote represents a vote on a block by a validaor.
func (*Vote) SetSignature ¶
SetSignature sets given signature in vote.
func (*Vote) Sign ¶
func (v *Vote) Sign(priv *crypto.PrivateKey)
Sign signs the vote using given private key.
type VoteByID ¶
type VoteByID []Vote
VoteByID implements sort.Interface for []Vote based on Voter's ID.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet represents a set of votes on a proposal.
func (*VoteSet) FilterByValidators ¶
func (s *VoteSet) FilterByValidators(validators *ValidatorSet) *VoteSet
FilterByValidators removes votes from non-validators.
func (*VoteSet) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*VoteSet) UniqueVoter ¶
UniqueVoter consolidate vote set by removing votes from the same voter in older epoches.
func (*VoteSet) UniqueVoterAndBlock ¶
UniqueVoterAndBlock consolidate vote set by removing votes from the same voter to same block in older epoches.
func (*VoteSet) UnmarshalJSON ¶
UnmarshalJSON implements json.Marshaler