types

package
v0.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const CommitmentBytesLen uint = 32

CommitmentBytesLen is the number of bytes in a CommR, CommD, CommP, and CommRStar.

View Source
const MessageVersion = 0
View Source
const PoStChallengeSeedBytesLen uint = 32

PoStChallengeSeedBytesLen is the number of bytes in the Proof of SpaceTime challenge seed.

Variables

View Source
var BlockGasLimit = gas.NewGas(100e6)

BlockGasLimit is the maximum amount of gas that can be used to execute messages in a single block.

View Source
var EmptyMessagesCID cid.Cid

EmptyMessagesCID is the cid of an empty collection of messages.

View Source
var EmptyReceiptsCID cid.Cid

EmptyReceiptsCID is the cid of an empty collection of receipts.

View Source
var EmptyTxMetaCID cid.Cid

EmptyTxMetaCID is the cid of a TxMeta wrapping empty cids

View Source
var ErrNotFound = fmt.Errorf("Not found")

ErrNotFound is not the error you are looking for.

View Source
var ZeroAttoFIL = specsbig.Zero()

ZeroAttoFIL is the zero value for an AttoFIL, exported for consistency in construction of AttoFILs

Functions

func AssertCidsEqual

func AssertCidsEqual(t *testing.T, m cid.Cid, n cid.Cid)

AssertCidsEqual asserts that two CIDS are identical.

func AssertHaveSameCid

func AssertHaveSameCid(t *testing.T, m HasCid, n HasCid)

AssertHaveSameCid asserts that two values have identical CIDs.

func BigToUint64

func BigToUint64(bi specsbig.Int) (uint64, error)

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 CidFromString

func CidFromString(t *testing.T, input string) cid.Cid

CidFromString generates Cid from string input

func MsgCidsEqual

func MsgCidsEqual(m1, m2 *UnsignedMessage) bool

MsgCidsEqual returns true if the message cids are equal. It panics if it can't get their cid.

func MustGenerateBLSKeyInfo

func MustGenerateBLSKeyInfo(n int, seed byte) []crypto.KeyInfo

MustGenerateBLSKeyInfo produces n distinct BLS keyinfos.

func MustGenerateKeyInfo

func MustGenerateKeyInfo(n int, seed byte) []crypto.KeyInfo

MustGenerateKeyInfo generates `n` distinct keyinfos using seed `seed`. The result is deterministic (for stable tests), don't use this for real keys!

func MustGenerateMixedKeyInfo

func MustGenerateMixedKeyInfo(m int, n int) []crypto.KeyInfo

MustGenerateMixedKeyInfo produces m bls keys and n secp keys. BLS and Secp will be interleaved. The keys will be valid, but not deterministic.

func NewAttoTokenFromToken

func NewAttoTokenFromToken(x uint64) abi.TokenAmount

NewAttoTokenFromToken should be moved when we cleanup the types Dragons: clean up and likely move to specs-actors

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 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() *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 SmsgCidsEqual

func SmsgCidsEqual(m1, m2 *SignedMessage) bool

SmsgCidsEqual returns true if the SignedMessage cids are equal. It panics if it can't get their cid.

func Uint64ToBig

func Uint64ToBig(u uint64) specsbig.Int

Uint64ToBig converts a uint64 to a big Int. Precodition: don't overflow int64.

Types

type AttoFIL

type AttoFIL = specsabi.TokenAmount

AttoFIL represents a signed multi-precision integer quantity of attofilecoin (atto is metric for 10**-18). The zero value for AttoFIL represents the value 0.

Reasons for embedding a big.Int instead of *big.Int:

  • We don't have check for nil in every method that does calculations.
  • Serialization "symmetry" when serializing AttoFIL{}.

func NewAttoFIL

func NewAttoFIL(x *big.Int) AttoFIL

NewAttoFIL allocates and returns a new AttoFIL set to x.

func NewAttoFILFromBytes

func NewAttoFILFromBytes(buf []byte) (AttoFIL, error)

NewAttoFILFromBytes allocates and returns a new AttoFIL set to the value of buf as the bytes of a big-endian unsigned integer.

func NewAttoFILFromFIL

func NewAttoFILFromFIL(x uint64) AttoFIL

NewAttoFILFromFIL returns a new AttoFIL representing a quantity of attofilecoin equal to x filecoin.

func NewAttoFILFromFILString

func NewAttoFILFromFILString(s string) (AttoFIL, bool)

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

func NewAttoFILFromString(s string, base int) (AttoFIL, bool)

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 NewGasPrice

func NewGasPrice(price int64) AttoFIL

NewGasPrice constructs a gas price (in AttoFIL) from the given number.

type CommD

type CommD [CommitmentBytesLen]byte

CommD is the merkle root of the original user data. It is an output of the sector sealing (PoRep) process.

type CommP

type CommP [CommitmentBytesLen]byte

CommP is the merkle root of a piece of data included within the original user data. It is generated by the client, and the miner must generated a piece inclusion proof from CommP to CommD.

type CommR

type CommR [CommitmentBytesLen]byte

CommR is the merkle root of the replicated data. It is an output of the sector sealing (PoRep) process.

type CommRStar

type CommRStar [CommitmentBytesLen]byte

CommRStar is a hash of intermediate layers. It is an output of the sector sealing (PoRep) process.

type Commitments

type Commitments struct {
	CommD     *CommD
	CommR     *CommR
	CommRStar *CommRStar
}

Commitments is a struct containing the replica and data commitments produced when sealing a sector.

type HasCid

type HasCid interface {
	Cid() cid.Cid
}

HasCid allows two values with CIDs to be compared.

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

func (MockSigner) SignBytes

func (ms MockSigner) SignBytes(_ context.Context, data []byte, addr address.Address) (crypto.Signature, error)

SignBytes cryptographically signs `data` using the Address `addr`.

type PoStChallengeSeed

type PoStChallengeSeed [PoStChallengeSeedBytesLen]byte

PoStChallengeSeed is an input to the proof-of-spacetime generation and verification methods.

type SignedMessage

type SignedMessage struct {
	Message   UnsignedMessage  `json:"meteredMessage"`
	Signature crypto.Signature `json:"signature"`
	// contains filtered or unexported fields
}

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) Cid

func (smsg *SignedMessage) Cid() (cid.Cid, error)

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) Marshal

func (smsg *SignedMessage) Marshal() ([]byte, error)

Marshal the SignedMessage into bytes.

func (*SignedMessage) OnChainLen

func (smsg *SignedMessage) OnChainLen() int

OnChainLen returns the amount of bytes used to represent the message on chain. TODO we can save this redundant encoding if we plumbed the size through from when the message was originally decoded from the network.

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) Unmarshal

func (smsg *SignedMessage) Unmarshal(b []byte) error

Unmarshal a SignedMessage from the given bytes.

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 TxMeta

type TxMeta struct {
	BLSRoot  e.Cid `json:"blsRoot"`
	SecpRoot e.Cid `json:"secpRoot"`
	// contains filtered or unexported fields
}

TxMeta tracks the merkleroots of both secp and bls messages separately

func (TxMeta) String

func (m TxMeta) String() string

String returns a readable printing string of TxMeta

type UnsignedMessage

type UnsignedMessage struct {
	Version int64 `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.
	CallSeqNum uint64 `json:"callSeqNum"`

	Value AttoFIL `json:"value"`

	GasPrice AttoFIL  `json:"gasPrice"`
	GasLimit gas.Unit `json:"gasLimit"`

	Method abi.MethodNum `json:"method"`
	Params []byte        `json:"params"`
	// contains filtered or unexported fields
}

UnsignedMessage is an exchange of information between two actors modeled as a function call.

func NewMeteredMessage

func NewMeteredMessage(from, to address.Address, nonce uint64, value AttoFIL, method abi.MethodNum, params []byte, price AttoFIL, limit gas.Unit) *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 AttoFIL, method abi.MethodNum, params []byte) *UnsignedMessage

NewUnsignedMessage creates a new message.

func (*UnsignedMessage) Cid

func (msg *UnsignedMessage) Cid() (cid.Cid, error)

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) Marshal

func (msg *UnsignedMessage) Marshal() ([]byte, error)

Marshal the message into bytes.

func (*UnsignedMessage) OnChainLen

func (msg *UnsignedMessage) OnChainLen() int

OnChainLen returns the amount of bytes used to represent the message on chain.

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) Unmarshal

func (msg *UnsignedMessage) Unmarshal(b []byte) error

Unmarshal a message from the given bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL