Documentation
¶
Index ¶
- Constants
- Variables
- func CidArrsContains(a []cid.Cid, b cid.Cid) bool
- func CidArrsEqual(a, b []cid.Cid) bool
- func CidArrsSubset(a, b []cid.Cid) bool
- func ReverseFullBlock(chain []*FullTipSet)
- type BeaconEntry
- type Block
- func (b *Block) Cid() cid.Cid
- func (b *Block) Equals(other *Block) bool
- func (b *Block) LastTicket() *Ticket
- func (t *Block) MarshalCBOR(w io.Writer) error
- func (b *Block) Serialize() ([]byte, error)
- func (b *Block) SignatureData() []byte
- func (b *Block) String() string
- func (b *Block) ToNode() node.Node
- func (b *Block) ToStorageBlock() (blocks.Block, error)
- func (t *Block) UnmarshalCBOR(r io.Reader) error
- type BlockMessagesInfo
- type BlockMsg
- type CISlice
- type ChainInfo
- type ElectionProof
- type FullBlock
- type FullTipSet
- type MiningBaseInfo
- type PoStProof
- type Ticket
- type TipSet
- func (ts *TipSet) At(i int) *Block
- func (ts *TipSet) Blocks() []*Block
- func (ts *TipSet) Defined() bool
- func (ts *TipSet) EnsureHeight() abi.ChainEpoch
- func (ts *TipSet) EnsureParents() TipSetKey
- func (ts *TipSet) Equals(ts2 *TipSet) bool
- func (ts *TipSet) Height() (abi.ChainEpoch, error)
- func (ts *TipSet) IsChildOf(parent *TipSet) bool
- func (ts *TipSet) Key() TipSetKey
- func (ts *TipSet) Len() int
- func (ts *TipSet) MarshalJSON() ([]byte, error)
- func (ts *TipSet) MinTicket() Ticket
- func (ts *TipSet) MinTicketBlock() *Block
- func (ts *TipSet) MinTimestamp() uint64
- func (ts *TipSet) ParentWeight() (fbig.Int, error)
- func (ts *TipSet) Parents() (TipSetKey, error)
- func (ts TipSet) String() string
- func (ts *TipSet) ToSlice() []*Block
- func (ts *TipSet) UnmarshalJSON(b []byte) error
- type TipSetKey
- func (tipsetKey TipSetKey) Bytes() []byte
- func (tipsetKey TipSetKey) Cids() []cid.Cid
- func (tipsetKey TipSetKey) ContainsAll(other TipSetKey) bool
- func (tipsetKey TipSetKey) Equals(other TipSetKey) bool
- func (tipsetKey TipSetKey) Has(id cid.Cid) bool
- func (tipsetKey TipSetKey) IsEmpty() bool
- func (tipsetKey TipSetKey) MarshalCBOR(w io.Writer) error
- func (tipsetKey TipSetKey) MarshalJSON() ([]byte, error)
- func (tipsetKey TipSetKey) String() string
- func (tipsetKey *TipSetKey) UnmarshalCBOR(r io.Reader) error
- func (tipsetKey *TipSetKey) UnmarshalJSON(b []byte) error
- type VRFPi
Constants ¶
const IndexMessagesField = 10
IndexMessagesField is the message field position in the encoded block
const IndexParentsField = 5
IndexParentsField is the parents field position in the encoded block
Variables ¶
var BlocksPerEpoch = uint64(constants.ExpectedLeadersPerEpoch)
Blocks (e)
var EmptyTSK = TipSetKey{}
var MaxWinCount = 3 * int64(BlocksPerEpoch)
var UndefTipSet = &TipSet{}
UndefTipSet is a singleton representing a nil or undefined tipset.
Functions ¶
func CidArrsContains ¶
func CidArrsContains(a []cid.Cid, b cid.Cid) bool
func CidArrsEqual ¶
func CidArrsEqual(a, b []cid.Cid) bool
func CidArrsSubset ¶
func CidArrsSubset(a, b []cid.Cid) bool
func ReverseFullBlock ¶
func ReverseFullBlock(chain []*FullTipSet)
Reverse reverses the order of the slice `chain`.
Types ¶
type BeaconEntry ¶
func (*BeaconEntry) MarshalCBOR ¶
func (t *BeaconEntry) MarshalCBOR(w io.Writer) error
func (*BeaconEntry) UnmarshalCBOR ¶
func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) error
type Block ¶
type Block struct { // Miner is the address of the miner actor that mined this block. Miner address.Address `json:"miner"` // Ticket is the ticket submitted with this block. Ticket Ticket `json:"ticket"` // ElectionProof is the vrf proof giving this block's miner authoring rights ElectionProof *ElectionProof `json:"electionProof"` // BeaconEntries contain the verifiable oracle randomness used to elect // this block's author leader BeaconEntries []*BeaconEntry `json:"beaconEntries"` // WinPoStProof are the winning post proofs WinPoStProof []PoStProof `json:"winPoStProof"` // Parents is the set of parents this block was based on. Typically one, // but can be several in the case where there were multiple winning ticket- // holders for an epoch. Parents TipSetKey `json:"parents"` // ParentWeight is the aggregate chain weight of the parent set. ParentWeight fbig.Int `json:"parentWeight"` // Height is the chain height of this block. Height abi.ChainEpoch `json:"height"` // ParentStateRoot is the CID of the root of the state tree after application of the messages in the parent tipset // to the parent tipset's state root. ParentStateRoot cid.Cid `json:"parentStateRoot,omitempty"` // ParentMessageReceipts is a list of receipts corresponding to the application of the messages in the parent tipset // to the parent tipset's state root (corresponding to this block's ParentStateRoot). ParentMessageReceipts cid.Cid `json:"parentMessageReceipts,omitempty"` // Messages is the set of messages included in this block Messages cid.Cid `json:"messages,omitempty"` // The aggregate signature of all BLS signed messages in the block BLSAggregate *crypto.Signature `json:"BLSAggregate"` // The timestamp, in seconds since the Unix epoch, at which this block was created. Timestamp uint64 `json:"timestamp"` // The signature of the miner's worker key over the block BlockSig *crypto.Signature `json:"blocksig"` // ForkSignaling is extra data used by miners to communicate ForkSignaling uint64 `json:"forkSignaling"` ParentBaseFee abi.TokenAmount `json:"parentBaseFee"` // contains filtered or unexported fields }
Block is a block in the blockchain.
func DecodeBlock ¶
DecodeBlock decodes raw cbor bytes into a Block.
func (*Block) LastTicket ¶
func (*Block) SignatureData ¶
SignatureData returns the block's bytes with a null signature field for signature creation and verification
type BlockMessagesInfo ¶
type BlockMessagesInfo struct { BlsMessages []types.ChainMsg SecpkMessages []types.ChainMsg Block *Block }
BlockMessagesInfo contains messages for one block in a tipset.
type BlockMsg ¶
type BlockMsg struct { Header *Block BlsMessages []cid.Cid SecpkMessages []cid.Cid }
type CISlice ¶
type CISlice []*ChainInfo
CISlice is for sorting chain infos
type ChainInfo ¶
type ChainInfo struct { // The originator of the TipSetKey propagation wave. Source peer.ID // The peer that sent us the TipSetKey message. Sender peer.ID Head *TipSet }
ChainInfo is used to track metadata about a peer and its chain.
func NewChainInfo ¶
NewChainInfo creates a chain info from a peer id a head tipset key and a chain height.
type ElectionProof ¶
type ElectionProof struct { WinCount int64 // A proof output by running a VRF on the VRFProof of the parent ticket VRFProof VRFPi }
func (*ElectionProof) ComputeWinCount ¶
func (ep *ElectionProof) ComputeWinCount(power abi.StoragePower, totalPower abi.StoragePower) int64
ComputeWinCount uses VRFProof to compute number of wins The algorithm is based on Algorand's Sortition with Binomial distribution replaced by Poisson distribution.
func (*ElectionProof) MarshalCBOR ¶
func (t *ElectionProof) MarshalCBOR(w io.Writer) error
func (*ElectionProof) UnmarshalCBOR ¶
func (t *ElectionProof) UnmarshalCBOR(r io.Reader) error
type FullBlock ¶
type FullBlock struct { Header *Block BLSMessages []*types.UnsignedMessage SECPMessages []*types.SignedMessage }
FullBlock carries a block header and the message and receipt collections referenced from the header.
type FullTipSet ¶
type FullTipSet struct { Blocks []*FullBlock // contains filtered or unexported fields }
FullTipSet is an expanded version of the TipSet that contains all the blocks and messages
func NewFullTipSet ¶
func NewFullTipSet(blks []*FullBlock) *FullTipSet
func (*FullTipSet) Cids ¶
func (fts *FullTipSet) Cids() []cid.Cid
func (*FullTipSet) TipSet ¶
func (fts *FullTipSet) TipSet() *TipSet
TipSet returns a narrower view of this FullTipSet elliding the block messages.
type MiningBaseInfo ¶
type MiningBaseInfo struct { MinerPower abi.StoragePower NetworkPower abi.StoragePower Sectors []builtin.SectorInfo WorkerKey address.Address SectorSize abi.SectorSize PrevBeaconEntry BeaconEntry BeaconEntries []BeaconEntry EligibleForMining bool }
type PoStProof ¶
type PoStProof struct { PoStProof abi.RegisteredPoStProof ProofBytes []byte }
func FromAbiProof ¶
func FromAbiProofArr ¶
func (PoStProof) AsAbiProof ¶
type Ticket ¶
type Ticket struct { // A proof output by running a VRF on the VRFProof of the parent ticket VRFProof VRFPi }
A Ticket is a marker of a tick of the blockchain's clock. It is the source of randomness for proofs of storage and leader election. It is generated by the miner of a block using a VRF.
type TipSet ¶
type TipSet struct {
// contains filtered or unexported fields
}
TipSet is a non-empty, immutable set of blocks at the same height with the same parent set. Blocks in a tipset are canonically ordered by ticket. Blocks may be iterated either via ToSlice() (which involves a shallow copy) or efficiently by index with At(). TipSet is a lightweight value type; passing by pointer is usually unnecessary.
Canonical tipset block ordering does not match the order of CIDs in a TipSetKey used as a tipset "key".
func NewTipSet ¶
NewTipSet builds a new TipSet from a collection of blocks. The blocks must be distinct (different CIDs), have the same height, and same parent set.
func RequireNewTipSet ¶
RequireNewTipSet instantiates and returns a new tipset of the given blocks and requires that the setup validation succeed.
func (*TipSet) At ¶
At returns the i'th block in the tipset. An index outside the half-open range [0, Len()) will panic.
func (*TipSet) Defined ¶
Defined checks whether the tipset is defined. Invoking any other methods on an undefined tipset will result in undefined behaviour (c.f. cid.Undef)
func (*TipSet) EnsureHeight ¶
func (ts *TipSet) EnsureHeight() abi.ChainEpoch
Height returns the height of a tipset.
func (*TipSet) EnsureParents ¶
func (*TipSet) Equals ¶
Equals tests whether the tipset contains the same blocks as another. Equality is not tested deeply: two tipsets are considered equal if their keys (ordered block CIDs) are equal.
func (*TipSet) Height ¶
func (ts *TipSet) Height() (abi.ChainEpoch, error)
Height returns the height of a tipset.
func (*TipSet) MarshalJSON ¶
func (*TipSet) MinTicketBlock ¶
func (*TipSet) MinTimestamp ¶
func (*TipSet) ParentWeight ¶
ParentWeight returns the tipset's ParentWeight in fixed point form.
func (TipSet) String ¶
String returns a formatted string of the CIDs in the TipSet. "{ <cid1> <cid2> <cid3> }" Note: existing callers use this as a unique key for the tipset. We should change them to use the TipSetKey explicitly
func (*TipSet) UnmarshalJSON ¶
type TipSetKey ¶
type TipSetKey struct {
// contains filtered or unexported fields
}
A TipSetKey is an immutable collection of CIDs forming a unique key for a tipset. The CIDs are assumed to be distinct and in canonical order. Two keys with the same CIDs in a different order are not considered equal. TipSetKey is a lightweight value type, and may be compared for equality with ==.
func NewTipSetKey ¶
func NewTipSetKey(cids ...cid.Cid) TipSetKey
NewTipSetKey builds a new key from a slice of CIDs. The CIDs are assumed to be ordered correctly.
func TipSetKeyFromBytes ¶
TipSetKeyFromBytes wraps an encoded key, validating correct decoding.
func (TipSetKey) Cids ¶
func (tipsetKey TipSetKey) Cids() []cid.Cid
Cids returns a slice of the CIDs comprising this key.
func (TipSetKey) ContainsAll ¶
ContainsAll checks if another set is a subset of this one. We can assume that the relative order of members of one key is maintained in the other since we assume that all ids are sorted by corresponding block ticket value.