Documentation ¶
Overview ¶
Package actor implements tooling to write and manipulate actors in go.
Index ¶
- Constants
- Variables
- func AssertCidsEqual(t *testing.T, m cid.Cid, n cid.Cid)
- func AssertHaveSameCid(t *testing.T, m HasCid, n HasCid)
- func BigCmp(a, b BigInt) int
- func BigToUint64(bi specsbig.Int) (uint64, error)
- func CidArrsContains(a []cid.Cid, b cid.Cid) bool
- func CidArrsEqual(a, b []cid.Cid) bool
- func CidArrsSubset(a, b []cid.Cid) bool
- func CidFromString(t *testing.T, input string) cid.Cid
- func DeciStr(bi BigInt) string
- func MustGenerateBLSKeyInfo(n int, seed byte) []crypto.KeyInfo
- func MustGenerateKeyInfo(n int, seed byte) []crypto.KeyInfo
- func MustGenerateMixedKeyInfo(m int, n int) []crypto.KeyInfo
- func MustParseAddress(addr string) address.Address
- func NewAttoFIL(x *big.Int) specsbig.Int
- func NewAttoFILFromBytes(buf []byte) (specsbig.Int, error)
- func NewAttoFILFromFIL(x uint64) specsbig.Int
- func NewAttoFILFromFILString(s string) (specsbig.Int, bool)
- func NewAttoFILFromString(s string, base int) (specsbig.Int, bool)
- func NewCidForTestGetter() func() cid.Cid
- func NewForTestGetter() func() address.Address
- func NewGasFeeCap(price int64) abi.TokenAmount
- func NewGasPremium(price int64) abi.TokenAmount
- func NewMessageForTestGetter() func() *UnsignedMessage
- func NewSignedMessageForTestGetter(ms MockSigner) func(uint64) *SignedMessage
- func RequireIDAddress(t *testing.T, i int) address.Address
- func ReverseFullBlock(chain []*FullTipSet)
- func ReverseTipSet(chain []*TipSet)
- func SizeStr(bi BigInt) string
- func Uint64ToBig(u uint64) specsbig.Int
- type Actor
- type BeaconEntry
- type BigInt
- type BlockHeader
- func (b *BlockHeader) Cid() cid.Cid
- func (b *BlockHeader) Equals(other *BlockHeader) bool
- func (b *BlockHeader) IsValidated() bool
- func (b *BlockHeader) LastTicket() *Ticket
- func (t *BlockHeader) MarshalCBOR(w io.Writer) error
- func (b *BlockHeader) Serialize() ([]byte, error)
- func (b *BlockHeader) SetValidated()
- func (b *BlockHeader) SignatureData() []byte
- func (b *BlockHeader) String() string
- func (b *BlockHeader) ToNode() node.Node
- func (b *BlockHeader) ToStorageBlock() (blocks.Block, error)
- func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error
- type BlockMessagesInfo
- type BlockMsg
- type CISlice
- type ChainInfo
- type ChainMsg
- type ElectionProof
- type ExecutionTrace
- type FIL
- type FullBlock
- type FullTipSet
- type GasTrace
- type HasCid
- type InvocResult
- type KeyType
- type Loc
- type Message
- type MessageMaker
- type MessageReceipt
- type MessageSendSpec
- type MockSigner
- type MsgGasCost
- type PCHDir
- type PaychStatus
- type ReceiptMaker
- type SignedMessage
- func (smsg *SignedMessage) ChainLength() int
- func (smsg *SignedMessage) Cid() cid.Cid
- func (smsg *SignedMessage) Equals(other *SignedMessage) bool
- func (t *SignedMessage) MarshalCBOR(w io.Writer) error
- func (smsg *SignedMessage) Serialize() ([]byte, error)
- func (smsg *SignedMessage) String() string
- func (smsg *SignedMessage) ToNode() (ipld.Node, error)
- func (smsg *SignedMessage) ToStorageBlock() (blocks.Block, error)
- func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error
- func (smsg *SignedMessage) VMMessage() *UnsignedMessage
- type Signer
- type Ticket
- type TipSet
- func (ts *TipSet) At(i int) *BlockHeader
- func (ts *TipSet) Blocks() []*BlockHeader
- func (ts *TipSet) Cids() []cid.Cid
- func (ts *TipSet) Defined() bool
- func (ts *TipSet) Equals(ts2 *TipSet) bool
- func (ts *TipSet) Height() abi.ChainEpoch
- 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() *BlockHeader
- func (ts *TipSet) MinTimestamp() uint64
- func (ts *TipSet) ParentWeight() fbig.Int
- func (ts *TipSet) Parents() TipSetKey
- func (ts TipSet) String() string
- func (ts *TipSet) ToSlice() []*BlockHeader
- 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 TxMeta
- type UnsignedMessage
- func DecodeMessage(b []byte) (*UnsignedMessage, error)
- func NewMeteredMessage(from, to address.Address, nonce uint64, value abi.TokenAmount, ...) *UnsignedMessage
- func NewMsgs(n int) []*UnsignedMessage
- func NewMsgsWithAddrs(n int, a []address.Address) []*UnsignedMessage
- func NewUnsignedMessage(from, to address.Address, nonce uint64, value abi.TokenAmount, ...) *UnsignedMessage
- func (msg *UnsignedMessage) ChainLength() int
- func (msg *UnsignedMessage) Cid() cid.Cid
- func (msg *UnsignedMessage) Equals(other *UnsignedMessage) bool
- func (t *UnsignedMessage) MarshalCBOR(w io.Writer) error
- func (msg *UnsignedMessage) RequiredFunds() abi.TokenAmount
- func (msg *UnsignedMessage) String() string
- func (msg *UnsignedMessage) ToNode() (ipld.Node, error)
- func (msg *UnsignedMessage) ToStorageBlock() (blocks.Block, error)
- func (t *UnsignedMessage) UnmarshalCBOR(r io.Reader) error
- func (msg *UnsignedMessage) VMMessage() *UnsignedMessage
- func (msg *UnsignedMessage) ValidForBlockInclusion(minGas int64, version network.Version) error
- type VRFPi
Constants ¶
const BigIntMaxSerializedLen = 128 // is this big enough? or too big?
const DefaultGasCost = 100
DefaultGasCost is default gas cost for the actor calls.
const IndexMessagesField = 10
IndexMessagesField is the message field position in the encoded newBlock
const IndexParentsField = 5
IndexParentsField is the parents field position in the encoded newBlock
const MessageVersion = 0
Variables ¶
var ( ErrKeyInfoNotFound = fmt.Errorf("key info not found") ErrKeyExists = fmt.Errorf("key already exists") )
var BlocksPerEpoch = uint64(constants.ExpectedLeadersPerEpoch)
Blocks (e)
var DefaultDefaultMaxFee = MustParseFIL("0.007")
var DefaultMessageSendSpec = MessageSendSpec{ MaxFee: abi.NewTokenAmount(int64(constants.FilecoinPrecision) / 10), }
var EmptyInt = BigInt{}
var EmptyTSK = TipSetKey{}
var EmptyTokenAmount = abi.TokenAmount{}
var ErrActorNotFound = errors.New("actor not found")
var ErrNotFound = fmt.Errorf("Not found")
ErrNotFound is not the error you are looking for.
var MaxWinCount = 3 * int64(BlocksPerEpoch)
var TotalFilecoinInt = FromFil(constants.FilBase)
var UndefTipSet = &TipSet{}
UndefTipSet is a singleton representing a nil or undefined tipset.
var ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a")
the 'f' prefix doesn't matter
var ZeroFIL = specsbig.Zero()
ZeroFIL is the zero value for an AttoFIL, exported for consistency in construction of AttoFILs
Functions ¶
func AssertCidsEqual ¶
AssertCidsEqual asserts that two CIDS are identical.
func AssertHaveSameCid ¶
AssertHaveSameCid asserts that two values have identical CIDs.
func BigToUint64 ¶
BigToUint64 converts a big Int to a uint64. It will error if the Int is too big to fit into 64 bits or is negative
func CidArrsContains ¶ added in v0.9.1
func CidArrsContains(a []cid.Cid, b cid.Cid) bool
func CidArrsEqual ¶ added in v0.9.1
func CidArrsEqual(a, b []cid.Cid) bool
func CidArrsSubset ¶ added in v0.9.1
func CidArrsSubset(a, b []cid.Cid) bool
func CidFromString ¶
CidFromString generates Cid from string input
func MustGenerateBLSKeyInfo ¶
MustGenerateBLSKeyInfo produces n distinct BLS keyinfos.
func MustGenerateKeyInfo ¶
MustGenerateKeyInfo generates `n` distinct keyinfos using seed `seed`. The result is deterministic (for stable tests), don't use this for real keys!
func MustGenerateMixedKeyInfo ¶
MustGenerateMixedKeyInfo produces m bls keys and n secp keys. BLS and Secp will be interleaved. The keys will be valid, but not deterministic.
func MustParseAddress ¶ added in v0.9.1
func MustParseAddress(addr string) address.Address
func NewAttoFIL ¶
NewAttoFIL allocates and returns a new AttoFIL set to x.
func NewAttoFILFromBytes ¶
NewAttoFILFromBytes allocates and returns a new AttoFIL set to the value of buf as the bytes of a big-endian unsigned integer.
func NewAttoFILFromFIL ¶
NewAttoFILFromFIL returns a new AttoFIL representing a quantity of attofilecoin equal to x filecoin.
func NewAttoFILFromFILString ¶
NewAttoFILFromFILString allocates a new AttoFIL set to the value of s filecoin, interpreted as a decimal in base 10, and returns it and a boolean indicating success.
func NewAttoFILFromString ¶
NewAttoFILFromString allocates a new AttoFIL set to the value of s attofilecoin, interpreted in the given base, and returns it and a boolean indicating success.
func NewCidForTestGetter ¶
func NewCidForTestGetter() func() cid.Cid
NewCidForTestGetter returns a closure that returns a Cid unique to that invocation. The Cid is unique wrt the closure returned, not globally. You can use this function in tests.
func NewForTestGetter ¶
func NewForTestGetter() func() address.Address
NewForTestGetter returns a closure that returns an address unique to that invocation. The address is unique wrt the closure returned, not globally.
func NewGasFeeCap ¶
func NewGasFeeCap(price int64) abi.TokenAmount
func NewGasPremium ¶
func NewGasPremium(price int64) abi.TokenAmount
func NewMessageForTestGetter ¶
func NewMessageForTestGetter() func() *UnsignedMessage
NewMessageForTestGetter returns a closure that returns a message unique to that invocation. The message is unique wrt the closure returned, not globally. You can use this function in tests instead of manually creating messages -- it both reduces duplication and gives us exactly one place to create valid messages for tests if messages require validation in the future.
func NewSignedMessageForTestGetter ¶
func NewSignedMessageForTestGetter(ms MockSigner) func(uint64) *SignedMessage
NewSignedMessageForTestGetter returns a closure that returns a SignedMessage unique to that invocation. The message is unique wrt the closure returned, not globally. You can use this function in tests instead of manually creating messages -- it both reduces duplication and gives us exactly one place to create valid messages for tests if messages require validation in the future. TODO support chosing from address
func RequireIDAddress ¶
func ReverseFullBlock ¶ added in v0.9.1
func ReverseFullBlock(chain []*FullTipSet)
Reverse reverses the order of the slice `chain`.
func ReverseTipSet ¶ added in v0.9.1
func ReverseTipSet(chain []*TipSet)
Reverse reverses the order of the slice `chain`.
func Uint64ToBig ¶
Uint64ToBig converts a uint64 to a big Int. Precodition: don't overflow int64.
Types ¶
type Actor ¶
type Actor struct { // Code is a CID of the VM code for this actor's implementation (or a constant for actors implemented in Go code). // Code may be nil for an uninitialized actor (which exists because it has received a balance). Code cid.Cid // Head is the CID of the root of the actor's state tree. Head cid.Cid // Nonce is the number expected on the next message from this actor. // Messages are processed in strict, contiguous order. Nonce uint64 // Balance is the amount of attoFIL in the actor's account. Balance abi.TokenAmount }
Actor is the central abstraction of entities in the system.
Both individual accounts, as well as contracts (user & system level) are represented as actors. An actor has the following core functionality implemented on a system level: - track a Filecoin balance, using the `Balance` field - execute code stored in the `Code` field - read & write memory - replay protection, using the `Nonce` field
Value sent to a non-existent address will be tracked as an empty actor that has a Balance but nil Code and Memory. You must nil check Code cids before comparing them.
More specific capabilities for individual accounts or contract specific must be implemented inside the code.
Not safe for concurrent access.
func NewActor ¶
func NewActor(code cid.Cid, balance abi.TokenAmount, head cid.Cid) *Actor
NewActor constructs a new actor.
func (*Actor) IncrementSeqNum ¶
func (a *Actor) IncrementSeqNum()
IncrementSeqNum increments the seq number.
type BeaconEntry ¶ added in v0.9.1
func (*BeaconEntry) MarshalCBOR ¶ added in v0.9.1
func (t *BeaconEntry) MarshalCBOR(w io.Writer) error
func (*BeaconEntry) UnmarshalCBOR ¶ added in v0.9.1
func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) error
type BigInt ¶ added in v0.9.1
func BigFromBytes ¶ added in v0.9.1
func BigFromString ¶ added in v0.9.1
type BlockHeader ¶ added in v0.9.1
type BlockHeader struct { // Miner is the address of the miner actor that mined this newBlock. Miner address.Address `json:"miner"` // Ticket is the ticket submitted with this newBlock. Ticket Ticket `json:"ticket"` // ElectionProof is the vrf proof giving this newBlock's miner authoring rights ElectionProof *ElectionProof `json:"electionProof"` // BeaconEntries contain the verifiable oracle randomness used to elect // this newBlock's author leader BeaconEntries []*BeaconEntry `json:"beaconEntries"` // WinPoStProof are the winning post proofs WinPoStProof []proof2.PoStProof `json:"winPoStProof"` // Parents is the set of parents this newBlock 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 newBlock. 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 newBlock's ParentStateRoot). ParentMessageReceipts cid.Cid `json:"parentMessageReceipts,omitempty"` // Messages is the set of messages included in this newBlock Messages cid.Cid `json:"messages,omitempty"` // The aggregate signature of all BLS signed messages in the newBlock BLSAggregate *crypto.Signature `json:"BLSAggregate"` // The timestamp, in seconds since the Unix epoch, at which this newBlock was created. Timestamp uint64 `json:"timestamp"` // The signature of the miner's worker key over the newBlock 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 }
BlockHeader is a newBlock in the blockchain.
func DecodeBlock ¶ added in v0.9.1
func DecodeBlock(b []byte) (*BlockHeader, error)
DecodeBlock decodes raw cbor bytes into a BlockHeader.
func (*BlockHeader) Cid ¶ added in v0.9.1
func (b *BlockHeader) Cid() cid.Cid
Cid returns the content id of this newBlock.
func (*BlockHeader) Equals ¶ added in v0.9.1
func (b *BlockHeader) Equals(other *BlockHeader) bool
Equals returns true if the BlockHeader is equal to other.
func (*BlockHeader) IsValidated ¶ added in v0.9.1
func (b *BlockHeader) IsValidated() bool
func (*BlockHeader) LastTicket ¶ added in v0.9.1
func (b *BlockHeader) LastTicket() *Ticket
func (*BlockHeader) MarshalCBOR ¶ added in v0.9.1
func (t *BlockHeader) MarshalCBOR(w io.Writer) error
func (*BlockHeader) Serialize ¶ added in v0.9.1
func (b *BlockHeader) Serialize() ([]byte, error)
func (*BlockHeader) SetValidated ¶ added in v0.9.1
func (b *BlockHeader) SetValidated()
func (*BlockHeader) SignatureData ¶ added in v0.9.1
func (b *BlockHeader) SignatureData() []byte
SignatureData returns the newBlock's bytes with a null signature field for signature creation and verification
func (*BlockHeader) String ¶ added in v0.9.1
func (b *BlockHeader) String() string
func (*BlockHeader) ToNode ¶ added in v0.9.1
func (b *BlockHeader) ToNode() node.Node
ToNode converts the BlockHeader to an IPLD node.
func (*BlockHeader) ToStorageBlock ¶ added in v0.9.1
func (b *BlockHeader) ToStorageBlock() (blocks.Block, error)
func (*BlockHeader) UnmarshalCBOR ¶ added in v0.9.1
func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error
type BlockMessagesInfo ¶ added in v0.9.1
type BlockMessagesInfo struct { BlsMessages []ChainMsg SecpkMessages []ChainMsg Block *BlockHeader }
BlockMessagesInfo contains messages for one newBlock in a tipset.
type BlockMsg ¶ added in v0.9.1
type BlockMsg struct { Header *BlockHeader BlsMessages []cid.Cid SecpkMessages []cid.Cid }
type CISlice ¶ added in v0.9.1
type CISlice []*ChainInfo
CISlice is for sorting chain infos
type ChainInfo ¶ added in v0.9.1
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 ¶ added in v0.9.1
NewChainInfo creates a chain info from a peer id a head tipset key and a chain height.
type ChainMsg ¶
type ChainMsg interface { Cid() cid.Cid VMMessage() *UnsignedMessage ToStorageBlock() (blocks.Block, error) // FIXME: This is the *message* length, this name is misleading. ChainLength() int cbor2.Marshaler cbor2.Unmarshaler }
type ElectionProof ¶ added in v0.9.1
type ElectionProof struct { WinCount int64 // A proof output by running a VRF on the VRFProof of the parent ticket VRFProof VRFPi }
func (*ElectionProof) ComputeWinCount ¶ added in v0.9.1
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 ¶ added in v0.9.1
func (t *ElectionProof) MarshalCBOR(w io.Writer) error
func (*ElectionProof) UnmarshalCBOR ¶ added in v0.9.1
func (t *ElectionProof) UnmarshalCBOR(r io.Reader) error
type ExecutionTrace ¶
type ExecutionTrace struct { Msg *UnsignedMessage MsgRct *MessageReceipt Error string Duration time.Duration GasCharges []*GasTrace Subcalls []ExecutionTrace }
type FullBlock ¶ added in v0.9.1
type FullBlock struct { Header *BlockHeader BLSMessages []*UnsignedMessage SECPMessages []*SignedMessage }
FullBlock carries a newBlock header and the message and receipt collections referenced from the header.
type FullTipSet ¶ added in v0.9.1
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 ¶ added in v0.9.1
func NewFullTipSet(blks []*FullBlock) *FullTipSet
func (*FullTipSet) Cids ¶ added in v0.9.1
func (fts *FullTipSet) Cids() []cid.Cid
func (*FullTipSet) TipSet ¶ added in v0.9.1
func (fts *FullTipSet) TipSet() *TipSet
TipSet returns a narrower view of this FullTipSet elliding the newBlock messages.
type GasTrace ¶
type GasTrace struct { Name string Location []Loc `json:"loc"` TotalGas int64 `json:"tg"` ComputeGas int64 `json:"cg"` StorageGas int64 `json:"sg"` TotalVirtualGas int64 `json:"vtg"` VirtualComputeGas int64 `json:"vcg"` VirtualStorageGas int64 `json:"vsg"` TimeTaken time.Duration `json:"tt"` Extra interface{} `json:"ex,omitempty"` Callers []uintptr `json:"-"` }
func (*GasTrace) MarshalJSON ¶
type HasCid ¶
type HasCid interface {
Cid() cid.Cid
}
HasCid allows two values with CIDs to be compared.
type InvocResult ¶ added in v0.9.1
type InvocResult struct { MsgCid cid.Cid Msg *UnsignedMessage MsgRct *MessageReceipt GasCost *MsgGasCost ExecutionTrace *ExecutionTrace Error string Duration time.Duration }
type KeyType ¶ added in v0.9.1
type KeyType string
KeyType defines a type of a key
func (*KeyType) UnmarshalJSON ¶ added in v0.9.1
type Message ¶ added in v0.9.1
type Message = UnsignedMessage
type MessageMaker ¶
type MessageMaker struct { DefaultGasFeeCap specsbig.Int DefaultGasPremium specsbig.Int DefaultGasUnits int64 // contains filtered or unexported fields }
MessageMaker creates unique, signed messages for use in tests.
func NewMessageMaker ¶
func NewMessageMaker(t *testing.T, keys []crypto.KeyInfo) *MessageMaker
NewMessageMaker creates a new message maker with a set of signing keys.
func (*MessageMaker) Addresses ¶
func (mm *MessageMaker) Addresses() []address.Address
Addresses returns the addresses for which this maker can sign messages.
func (*MessageMaker) NewSignedMessage ¶
func (mm *MessageMaker) NewSignedMessage(from address.Address, nonce uint64) *SignedMessage
NewSignedMessage creates a new signed message.
func (*MessageMaker) NewUnsignedMessage ¶
func (mm *MessageMaker) NewUnsignedMessage(from address.Address, nonce uint64) *UnsignedMessage
NewUnsignedMessage creates a new message.
func (*MessageMaker) Signer ¶
func (mm *MessageMaker) Signer() *MockSigner
Signer returns the signer with which this maker signs messages.
type MessageReceipt ¶
type MessageReceipt struct { ExitCode exitcode.ExitCode `json:"exitCode"` ReturnValue []byte `json:"return"` GasUsed int64 `json:"gasUsed"` }
MessageReceipt is what is returned by executing a message on the vm.
func EmptyReceipts ¶
func EmptyReceipts(n int) []*MessageReceipt
EmptyReceipts returns a slice of n empty receipts.
func Failure ¶
func Failure(exitCode exitcode.ExitCode, gasAmount int64) MessageReceipt
Failure returns with a non-zero exit code.
func (*MessageReceipt) MarshalCBOR ¶
func (t *MessageReceipt) MarshalCBOR(w io.Writer) error
func (*MessageReceipt) String ¶
func (r *MessageReceipt) String() string
func (*MessageReceipt) UnmarshalCBOR ¶
func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error
type MessageSendSpec ¶
type MessageSendSpec struct {
MaxFee abi.TokenAmount
}
func (*MessageSendSpec) Get ¶
func (ms *MessageSendSpec) Get() MessageSendSpec
type MockSigner ¶
type MockSigner struct { AddrKeyInfo map[address.Address]crypto.KeyInfo Addresses []address.Address PubKeys [][]byte }
MockSigner implements the Signer interface
func NewMockSigner ¶
func NewMockSigner(kis []crypto.KeyInfo) MockSigner
NewMockSigner returns a new mock signer, capable of signing data with keys (addresses derived from) in keyinfo
func NewMockSignersAndKeyInfo ¶
func NewMockSignersAndKeyInfo(numSigners int) (MockSigner, []crypto.KeyInfo)
NewMockSignersAndKeyInfo is a convenience function to generate a mock signers with some keys.
func (MockSigner) GetAddressForPubKey ¶
func (ms MockSigner) GetAddressForPubKey(pk []byte) (address.Address, error)
GetAddressForPubKey looks up a KeyInfo address associated with a given PublicKeyForSecpSecretKey for a MockSigner
func (MockSigner) HasAddress ¶
func (ms MockSigner) HasAddress(_ context.Context, addr address.Address) (bool, error)
HasAddress returns whether the signer can sign with this address
type MsgGasCost ¶ added in v0.9.1
type MsgGasCost struct { Message cid.Cid // Can be different than requested, in case it was replaced, but only gas values changed GasUsed abi.TokenAmount BaseFeeBurn abi.TokenAmount OverEstimationBurn abi.TokenAmount MinerPenalty abi.TokenAmount MinerTip abi.TokenAmount Refund abi.TokenAmount TotalCost abi.TokenAmount }
type PaychStatus ¶ added in v0.9.1
type PaychStatus struct { ControlAddr address.Address Direction PCHDir }
type ReceiptMaker ¶
type ReceiptMaker struct {
// contains filtered or unexported fields
}
ReceiptMaker generates unique receipts
func NewReceiptMaker ¶
func NewReceiptMaker() *ReceiptMaker
NewReceiptMaker creates a new receipt maker
func (*ReceiptMaker) NewReceipt ¶
func (rm *ReceiptMaker) NewReceipt() MessageReceipt
NewReceipt creates a new distinct receipt.
type SignedMessage ¶
type SignedMessage struct { Message UnsignedMessage `json:"message"` Signature crypto.Signature `json:"signature"` }
SignedMessage contains a message and its signature TODO do not export these fields as it increases the chances of producing a `SignedMessage` with an empty signature.
func NewSignedMessage ¶
func NewSignedMessage(ctx context.Context, msg UnsignedMessage, s Signer) (*SignedMessage, error)
NewSignedMessage accepts a message `msg` and a signer `s`. NewSignedMessage returns a `SignedMessage` containing a signature derived from the serialized `msg` and `msg.From` NOTE: this method can only sign message with From being a public-key type address, not an ID address. We should deprecate this and move to more explicit signing via an address resolver.
func NewSignedMsgs ¶
func NewSignedMsgs(n uint, ms MockSigner) []*SignedMessage
NewSignedMsgs returns n signed messages. The messages returned are unique to this invocation but are not unique globally (ie, a second call to NewSignedMsgs will return the same set of messages).
func SignMsgs ¶
func SignMsgs(ms MockSigner, msgs []*UnsignedMessage) ([]*SignedMessage, error)
SignMsgs returns a slice of signed messages where the original messages are `msgs`, if signing one of the `msgs` fails an error is returned
func (*SignedMessage) ChainLength ¶
func (smsg *SignedMessage) ChainLength() int
func (*SignedMessage) Cid ¶
func (smsg *SignedMessage) Cid() cid.Cid
Cid returns the canonical CID for the SignedMessage.
func (*SignedMessage) Equals ¶
func (smsg *SignedMessage) Equals(other *SignedMessage) bool
Equals tests whether two signed messages are equal.
func (*SignedMessage) MarshalCBOR ¶
func (t *SignedMessage) MarshalCBOR(w io.Writer) error
func (*SignedMessage) Serialize ¶
func (smsg *SignedMessage) Serialize() ([]byte, error)
func (*SignedMessage) String ¶
func (smsg *SignedMessage) String() string
func (*SignedMessage) ToNode ¶
func (smsg *SignedMessage) ToNode() (ipld.Node, error)
ToNode converts the SignedMessage to an IPLD node.
func (*SignedMessage) ToStorageBlock ¶
func (smsg *SignedMessage) ToStorageBlock() (blocks.Block, error)
func (*SignedMessage) UnmarshalCBOR ¶
func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error
func (*SignedMessage) VMMessage ¶
func (smsg *SignedMessage) VMMessage() *UnsignedMessage
type Signer ¶
type Signer interface { SignBytes(ctx context.Context, data []byte, addr address.Address) (*crypto.Signature, error) HasAddress(ctx context.Context, addr address.Address) (bool, error) }
Signer signs data with a private key obtained internally from a provided address.
type Ticket ¶ added in v0.9.1
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 newBlock using a VRF.
type TipSet ¶ added in v0.9.1
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 newBlock ordering does not match the order of CIDs in a TipSetKey used as a tipset "key".
func NewTipSet ¶ added in v0.9.1
func NewTipSet(blocks ...*BlockHeader) (*TipSet, error)
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 ¶ added in v0.9.1
func RequireNewTipSet(t *testing.T, blks ...*BlockHeader) *TipSet
RequireNewTipSet instantiates and returns a new tipset of the given blocks and requires that the setup validation succeed.
func (*TipSet) At ¶ added in v0.9.1
func (ts *TipSet) At(i int) *BlockHeader
At returns the i'th newBlock in the tipset. An index outside the half-open range [0, Len()) will panic.
func (*TipSet) Blocks ¶ added in v0.9.1
func (ts *TipSet) Blocks() []*BlockHeader
func (*TipSet) Defined ¶ added in v0.9.1
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) Equals ¶ added in v0.9.1
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 newBlock CIDs) are equal.
func (*TipSet) Height ¶ added in v0.9.1
func (ts *TipSet) Height() abi.ChainEpoch
Height returns the height of a tipset.
func (*TipSet) MarshalJSON ¶ added in v0.9.1
func (*TipSet) MinTicket ¶ added in v0.9.1
MinTicket returns the smallest ticket of all blocks in the tipset.
func (*TipSet) MinTicketBlock ¶ added in v0.9.1
func (ts *TipSet) MinTicketBlock() *BlockHeader
func (*TipSet) MinTimestamp ¶ added in v0.9.1
func (*TipSet) ParentWeight ¶ added in v0.9.1
ParentWeight returns the tipset's ParentWeight in fixed point form.
func (*TipSet) Parents ¶ added in v0.9.1
Parents returns the CIDs of the parents of the blocks in the tipset.
func (TipSet) String ¶ added in v0.9.1
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) ToSlice ¶ added in v0.9.1
func (ts *TipSet) ToSlice() []*BlockHeader
ToSlice returns an ordered slice of pointers to the tipset's blocks.
func (*TipSet) UnmarshalJSON ¶ added in v0.9.1
type TipSetKey ¶ added in v0.9.1
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 ¶ added in v0.9.1
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 ¶ added in v0.9.1
TipSetKeyFromBytes wraps an encoded key, validating correct decoding.
func (TipSetKey) Cids ¶ added in v0.9.1
func (tipsetKey TipSetKey) Cids() []cid.Cid
Cids returns a slice of the CIDs comprising this key.
func (TipSetKey) ContainsAll ¶ added in v0.9.1
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 newBlock ticket value.
func (TipSetKey) Equals ¶ added in v0.9.1
Equals checks whether the set contains exactly the same CIDs as another.
func (TipSetKey) MarshalCBOR ¶ added in v0.9.1
func (TipSetKey) MarshalJSON ¶ added in v0.9.1
func (TipSetKey) String ¶ added in v0.9.1
String() returns a human-readable representation of the key.
func (*TipSetKey) UnmarshalCBOR ¶ added in v0.9.1
func (*TipSetKey) UnmarshalJSON ¶ added in v0.9.1
type TxMeta ¶
type TxMeta struct { BLSRoot cid.Cid `json:"blsRoot"` SecpRoot cid.Cid `json:"secpRoot"` }
TxMeta tracks the merkleroots of both secp and bls messages separately
type UnsignedMessage ¶
type UnsignedMessage struct { Version uint64 `json:"version"` To address.Address `json:"to"` From address.Address `json:"from"` // When receiving a message from a user account the nonce in // the message must match the expected nonce in the from actor. // This prevents replay attacks. Nonce uint64 `json:"nonce"` Value abi.TokenAmount `json:"value"` GasLimit int64 `json:"gasLimit"` GasFeeCap abi.TokenAmount `json:"gasFeeCap"` GasPremium abi.TokenAmount `json:"gasPremium"` Method abi.MethodNum `json:"method"` Params []byte `json:"params"` }
UnsignedMessage is an exchange of information between two actors modeled as a function call.
func DecodeMessage ¶
func DecodeMessage(b []byte) (*UnsignedMessage, error)
func NewMeteredMessage ¶
func NewMeteredMessage(from, to address.Address, nonce uint64, value abi.TokenAmount, method abi.MethodNum, params []byte, gasFeeCap, gasPremium abi.TokenAmount, limit int64) *UnsignedMessage
NewMeteredMessage adds gas price and gas limit to the message
func NewMsgs ¶
func NewMsgs(n int) []*UnsignedMessage
NewMsgs returns n messages. The messages returned are unique to this invocation but are not unique globally (ie, a second call to NewMsgs will return the same set of messages).
func NewMsgsWithAddrs ¶
func NewMsgsWithAddrs(n int, a []address.Address) []*UnsignedMessage
NewMsgsWithAddrs returns a slice of `n` messages who's `From` field's are pulled from `a`. This method should be used when the addresses returned are to be signed at a later point.
func NewUnsignedMessage ¶
func NewUnsignedMessage(from, to address.Address, nonce uint64, value abi.TokenAmount, method abi.MethodNum, params []byte) *UnsignedMessage
NewUnsignedMessage creates a new message.
func (*UnsignedMessage) ChainLength ¶
func (msg *UnsignedMessage) ChainLength() int
func (*UnsignedMessage) Cid ¶
func (msg *UnsignedMessage) Cid() cid.Cid
Cid returns the canonical CID for the message. TODO: can we avoid returning an error?
func (*UnsignedMessage) Equals ¶
func (msg *UnsignedMessage) Equals(other *UnsignedMessage) bool
Equals tests whether two messages are equal
func (*UnsignedMessage) MarshalCBOR ¶
func (t *UnsignedMessage) MarshalCBOR(w io.Writer) error
func (*UnsignedMessage) RequiredFunds ¶
func (msg *UnsignedMessage) RequiredFunds() abi.TokenAmount
func (*UnsignedMessage) String ¶
func (msg *UnsignedMessage) String() string
func (*UnsignedMessage) ToNode ¶
func (msg *UnsignedMessage) ToNode() (ipld.Node, error)
ToNode converts the Message to an IPLD node.
func (*UnsignedMessage) ToStorageBlock ¶
func (msg *UnsignedMessage) ToStorageBlock() (blocks.Block, error)
func (*UnsignedMessage) UnmarshalCBOR ¶
func (t *UnsignedMessage) UnmarshalCBOR(r io.Reader) error
func (*UnsignedMessage) VMMessage ¶
func (msg *UnsignedMessage) VMMessage() *UnsignedMessage
func (*UnsignedMessage) ValidForBlockInclusion ¶
func (msg *UnsignedMessage) ValidForBlockInclusion(minGas int64, version network.Version) error
Source Files ¶
- actor.go
- address.go
- atto_fil.go
- beacon.go
- bigint.go
- block.go
- block_message.go
- blockmsg.go
- cbor_gen.go
- chain_info.go
- fil.go
- full_block.go
- fulltipset.go
- gas_trace.go
- keystore.go
- message.go
- not_found.go
- paych.go
- signed_message.go
- signer.go
- testing.go
- testing_messages.go
- ticket.go
- tipset.go
- tipset_key.go
- vrf.go