Documentation ¶
Overview ¶
(c) 2019 Dapper Labs - ALL RIGHTS RESERVED
Index ¶
- Constants
- Variables
- func CheckConcatSum(sum Identifier, fps ...Identifier) bool
- func CheckMerkleRoot(root Identifier, ids ...Identifier) bool
- func CompatibleAlgorithms(sigAlgo crypto.SigningAlgorithm, hashAlgo hash.HashingAlgorithm) bool
- func EncodeAccountPrivateKey(a AccountPrivateKey) ([]byte, error)
- func EncodeAccountPublicKey(a AccountPublicKey) ([]byte, error)
- func EncodeRuntimeAccountPublicKey(a AccountPublicKey) ([]byte, error)
- type Account
- type AccountPrivateKey
- type AccountPublicKey
- type Address
- type AddressGenerator
- type AggregatedSignature
- type AssignmentList
- type Attestation
- type Batch
- type Block
- type BlockEvents
- type Chain
- type ChainID
- type Chunk
- type ChunkBody
- type ChunkDataPack
- type ChunkList
- func (cl ChunkList) ByChecksum(cs Identifier) (*Chunk, bool)
- func (cl ChunkList) ByIndex(i uint64) (*Chunk, bool)
- func (cl ChunkList) Empty() bool
- func (cl ChunkList) Fingerprint() Identifier
- func (cl ChunkList) Indices() []uint64
- func (cl *ChunkList) Insert(ch *Chunk)
- func (cl ChunkList) Items() []*Chunk
- func (cl ChunkList) Len() int
- func (cl ChunkList) Less(i, j int) bool
- func (cl ChunkList) Swap(i, j int)
- type ClusterList
- func (clusters ClusterList) Assignments() AssignmentList
- func (cl ClusterList) ByIndex(index uint) (IdentityList, bool)
- func (cl ClusterList) ByNodeID(nodeID Identifier) (IdentityList, uint, bool)
- func (cl ClusterList) ByTxID(txID Identifier) (IdentityList, bool)
- func (cl ClusterList) IndexOf(cluster IdentityList) (uint, bool)
- type Collection
- type CollectionGuarantee
- type CollectionList
- func (cl *CollectionList) ByChecksum(cs Identifier) (*Collection, bool)
- func (cl *CollectionList) ByIndex(i uint64) *Collection
- func (cl *CollectionList) ByIndexWithProof(i uint64) (*Collection, Proof)
- func (cl *CollectionList) Fingerprint() Identifier
- func (cl *CollectionList) Insert(ch *Collection)
- func (cl *CollectionList) Items() []*Collection
- type DKGParticipant
- type Entity
- type EntityList
- type EntitySet
- type EpochCommit
- func (commit *EpochCommit) EncodeRLP(w io.Writer) error
- func (commit *EpochCommit) ID() Identifier
- func (commit *EpochCommit) MarshalJSON() ([]byte, error)
- func (commit *EpochCommit) MarshalMsgpack() ([]byte, error)
- func (commit *EpochCommit) ServiceEvent() ServiceEvent
- func (commit *EpochCommit) UnmarshalJSON(b []byte) error
- func (commit *EpochCommit) UnmarshalMsgpack(b []byte) error
- type EpochPhase
- type EpochSetup
- type EpochStatus
- type Event
- type EventIDs
- type EventType
- type ExecutedTransaction
- type ExecutionReceipt
- type ExecutionReceiptGroupedList
- type ExecutionReceiptGroupingFunction
- type ExecutionReceiptList
- func (l ExecutionReceiptList) GroupBy(grouper ExecutionReceiptGroupingFunction) ExecutionReceiptGroupedList
- func (l ExecutionReceiptList) GroupByExecutorID() ExecutionReceiptGroupedList
- func (l ExecutionReceiptList) GroupByResultID() ExecutionReceiptGroupedList
- func (l ExecutionReceiptList) Size() int
- type ExecutionReceiptMeta
- type ExecutionResult
- type Header
- func (h Header) Body() interface{}
- func (h Header) Checksum() Identifier
- func (h Header) Fingerprint() []byte
- func (h Header) ID() Identifier
- func (h Header) MarshalJSON() ([]byte, error)
- func (h Header) MarshalMsgpack() ([]byte, error)
- func (h *Header) UnmarshalJSON(data []byte) error
- func (h *Header) UnmarshalMsgpack(data []byte) error
- type Identifier
- func ConcatSum(ids ...Identifier) Identifier
- func GetIDs(value interface{}) []Identifier
- func HashToID(hash []byte) Identifier
- func HexStringToIdentifier(hexString string) (Identifier, error)
- func MakeID(entity interface{}) Identifier
- func MerkleRoot(ids ...Identifier) Identifier
- func PublicKeyToID(pub crypto.PublicKey) (Identifier, error)
- func Sample(size uint, ids ...Identifier) []Identifier
- type IdentifierFilter
- type IdentifierList
- type Identity
- func (iy Identity) Checksum() Identifier
- func (iy Identity) ID() Identifier
- func (iy Identity) MarshalJSON() ([]byte, error)
- func (iy Identity) MarshalMsgpack() ([]byte, error)
- func (iy Identity) String() string
- func (iy *Identity) UnmarshalJSON(b []byte) error
- func (iy *Identity) UnmarshalMsgpack(b []byte) error
- type IdentityFilter
- type IdentityList
- func (il IdentityList) ByIndex(index uint) (*Identity, bool)
- func (il IdentityList) ByNodeID(nodeID Identifier) (*Identity, bool)
- func (il IdentityList) Copy() IdentityList
- func (il IdentityList) Count() uint
- func (il IdentityList) DeterministicSample(size uint, seed int64) IdentityList
- func (il IdentityList) Filter(filter IdentityFilter) IdentityList
- func (il IdentityList) Fingerprint() Identifier
- func (il IdentityList) Lookup() map[Identifier]struct{}
- func (il IdentityList) Map(f IdentityMapFunc) IdentityList
- func (il IdentityList) NodeIDs() []Identifier
- func (il IdentityList) Order(less IdentityOrder) IdentityList
- func (il IdentityList) Sample(size uint) IdentityList
- func (il IdentityList) SamplePct(pct float64) IdentityList
- func (il IdentityList) Selector() IdentityFilter
- func (il IdentityList) StakingKeys() []crypto.PublicKey
- func (il IdentityList) TotalStake() uint64
- func (il IdentityList) Union(other IdentityList) IdentityList
- type IdentityMapFunc
- type IdentityOrder
- type IncorporatedResult
- func (ir *IncorporatedResult) AddSignature(chunkIndex uint64, signerID Identifier, signature crypto.Signature)
- func (ir *IncorporatedResult) Checksum() Identifier
- func (ir *IncorporatedResult) GetAggregatedSignatures() []AggregatedSignature
- func (ir *IncorporatedResult) GetChunkSignatures(chunkIndex uint64) (*AggregatedSignature, bool)
- func (ir *IncorporatedResult) GetSignature(chunkIndex uint64, signerID Identifier) (*crypto.Signature, bool)
- func (ir *IncorporatedResult) ID() Identifier
- func (ir *IncorporatedResult) NumberSignatures(chunkIndex uint64) uint
- type IncorporatedResultGroupedList
- type IncorporatedResultGroupingFunction
- type IncorporatedResultList
- func (l IncorporatedResultList) GroupBy(grouper IncorporatedResultGroupingFunction) IncorporatedResultGroupedList
- func (l IncorporatedResultList) GroupByExecutedBlockID() IncorporatedResultGroupedList
- func (l IncorporatedResultList) GroupByIncorporatedBlockID() IncorporatedResultGroupedList
- func (l IncorporatedResultList) GroupByResultID() IncorporatedResultGroupedList
- func (l IncorporatedResultList) Size() int
- type IncorporatedResultSeal
- type Index
- type LightCollection
- type MonotonicAddressGenerator
- type Payload
- type PendingBlock
- type Proof
- type ProposalKey
- type QuorumCertificate
- type Range
- type RegisterEntries
- type RegisterEntry
- type RegisterID
- type RegisterValue
- type ResultApproval
- type ResultApprovalBody
- type Role
- type RoleList
- type Seal
- type ServiceEvent
- type SignatureCollector
- type Spock
- type StateCommitment
- type StorageProof
- type Transaction
- type TransactionBody
- func (tb *TransactionBody) AddArgument(arg []byte) *TransactionBody
- func (tb *TransactionBody) AddAuthorizer(address Address) *TransactionBody
- func (tb *TransactionBody) AddEnvelopeSignature(address Address, keyID uint64, sig []byte) *TransactionBody
- func (tb *TransactionBody) AddPayloadSignature(address Address, keyID uint64, sig []byte) *TransactionBody
- func (tb TransactionBody) ByteSize() uint
- func (tb TransactionBody) Checksum() Identifier
- func (tb *TransactionBody) EnvelopeMessage() []byte
- func (tb TransactionBody) Fingerprint() []byte
- func (tb TransactionBody) ID() Identifier
- func (tb *TransactionBody) MissingFields() []string
- func (tb *TransactionBody) PayloadMessage() []byte
- func (tb *TransactionBody) SetArguments(args [][]byte) *TransactionBody
- func (tb *TransactionBody) SetGasLimit(limit uint64) *TransactionBody
- func (tb *TransactionBody) SetPayer(address Address) *TransactionBody
- func (tb *TransactionBody) SetProposalKey(address Address, keyID uint64, sequenceNum uint64) *TransactionBody
- func (tb *TransactionBody) SetReferenceBlockID(blockID Identifier) *TransactionBody
- func (tb *TransactionBody) SetScript(script []byte) *TransactionBody
- func (tb *TransactionBody) SignEnvelope(address Address, keyID uint64, privateKey crypto.PrivateKey, ...) error
- func (tb *TransactionBody) SignPayload(address Address, keyID uint64, privateKey crypto.PrivateKey, ...) error
- type TransactionField
- type TransactionResult
- type TransactionSignature
- type TransactionStatus
- type TransactionTiming
Constants ¶
const ( ServiceEventSetup = "setup" ServiceEventCommit = "commit" )
const ( // AddressLength is the size of an account address in bytes. // (n) is the size of an account address in bits. AddressLength = (linearCodeN + 7) >> 3 )
const DefaultAuctionWindow = 50000
DefaultAuctionWindow defines the length of the auction window at the beginning of an epoch, during which nodes can bid for seats in the committee. Valid epoch events such as setup and commit can only be submitted after this window has passed.
const DefaultGracePeriod = 25000
DefaultGracePeriod defines the minimum number of views before the final view of an epoch where we need to have an epoch setup and an epoch commit event. This is in order to give all nodes the chance to have the information before entering the next epoch.
const DefaultMaxGasLimit = 9999
DefaultMaxGasLimit is the default maximum value for the transaction gas limit.
const DefaultMaxTxSizeLimit = 1500000
DefaultMaxTxSizeLimit is the default maximum transaction byte size. (1.5MB)
const DefaultTransactionExpiry = 10 * 60
DefaultTransactionExpiry is the default expiry for transactions, measured in blocks. Equivalent to 10 minutes for a 1-second block time.
const DefaultTransactionExpiryBuffer = 30
DefaultTransactionExpiryBuffer is the default buffer time between a transaction being ingested by a collection node and being included in a collection and block.
const DefaultValueLogGCFrequency = 10 * 60
DefaultValueLogGCFrequency is the default frequency in blocks that we call the badger value log GC. Equivalent to 10 mins for a 1 second block time
const DomainTagLength = 32
const EpochSetupRandomSourceLength = crypto.SignatureLenBLSBLS12381
EpochSetupRandomSourceLength is the required length of the random source included in an EpochSetup service event.
Variables ¶
var EmptyAddress = Address{}
EmptyAddress is the default value of a variable of type Address
GenesisTime defines the timestamp of the genesis block.
var TransactionDomainTag = paddedDomainTag("FLOW-V0.0-transaction")
TransactionDomainTag is the prefix of all signed transaction payloads.
A domain tag is encoded as UTF-8 bytes, right padded to a total length of 32 bytes.
var UserDomainTag = paddedDomainTag("FLOW-V0.0-user")
UserDomainTag is the prefix of all signed user space payloads.
A domain tag is encoded as UTF-8 bytes, right padded to a total length of 32 bytes.
var ( // ZeroID is the lowest value in the 32-byte ID space. ZeroID = Identifier{} )
Functions ¶
func CheckConcatSum ¶
func CheckConcatSum(sum Identifier, fps ...Identifier) bool
func CheckMerkleRoot ¶
func CheckMerkleRoot(root Identifier, ids ...Identifier) bool
func CompatibleAlgorithms ¶
func CompatibleAlgorithms(sigAlgo crypto.SigningAlgorithm, hashAlgo hash.HashingAlgorithm) bool
CompatibleAlgorithms returns true if the signature and hash algorithms are compatible.
func EncodeAccountPrivateKey ¶
func EncodeAccountPrivateKey(a AccountPrivateKey) ([]byte, error)
func EncodeAccountPublicKey ¶
func EncodeAccountPublicKey(a AccountPublicKey) ([]byte, error)
func EncodeRuntimeAccountPublicKey ¶
func EncodeRuntimeAccountPublicKey(a AccountPublicKey) ([]byte, error)
Types ¶
type Account ¶
type Account struct { Address Address Balance uint64 Keys []AccountPublicKey Contracts map[string][]byte }
Account represents an account on the Flow network.
An account can be an externally owned account or a contract account with code.
type AccountPrivateKey ¶
type AccountPrivateKey struct { PrivateKey crypto.PrivateKey SignAlgo crypto.SigningAlgorithm HashAlgo hash.HashingAlgorithm }
AccountPrivateKey is a private key associated with an account.
func DecodeAccountPrivateKey ¶
func DecodeAccountPrivateKey(b []byte) (AccountPrivateKey, error)
func (AccountPrivateKey) MarshalJSON ¶
func (a AccountPrivateKey) MarshalJSON() ([]byte, error)
func (AccountPrivateKey) PublicKey ¶
func (a AccountPrivateKey) PublicKey(weight int) AccountPublicKey
PublicKey returns a weighted public key.
type AccountPublicKey ¶
type AccountPublicKey struct { Index int PublicKey crypto.PublicKey SignAlgo crypto.SigningAlgorithm HashAlgo hash.HashingAlgorithm SeqNumber uint64 Weight int Revoked bool }
AccountPublicKey is a public key associated with an account.
An account public key contains the public key, signing and hashing algorithms, and a key weight.
func DecodeAccountPublicKey ¶
func DecodeAccountPublicKey(b []byte, index uint64) (AccountPublicKey, error)
func DecodeRuntimeAccountPublicKey ¶
func DecodeRuntimeAccountPublicKey(b []byte, seqNumber uint64) (AccountPublicKey, error)
DecodeRuntimeAccountPublicKey decode bytes into AccountPublicKey but it is designed to accept byte-format used by Cadence runtime (currently same as SDK, but we don't want to keep explicit dependency on SDK)
func (AccountPublicKey) MarshalJSON ¶
func (a AccountPublicKey) MarshalJSON() ([]byte, error)
func (*AccountPublicKey) UnmarshalJSON ¶
func (a *AccountPublicKey) UnmarshalJSON(data []byte) error
func (AccountPublicKey) Validate ¶
func (a AccountPublicKey) Validate() error
Validate returns an error if this account key is invalid.
An account key can be invalid for the following reasons: - It specifies an incompatible signature/hash algorithm pairing - (TODO) It specifies a negative key weight
type Address ¶
type Address [AddressLength]byte
Address represents the 8 byte address of an account.
func BytesToAddress ¶
BytesToAddress returns Address with value b.
If b is larger than 8, b will be cropped from the left. If b is smaller than 8, b will be appended by zeroes at the front.
func HexToAddress ¶
HexToAddress converts a hex string to an Address.
func (Address) HexWithPrefix ¶
HexWithPrefix returns the hex string representation of the address, including the 0x prefix.
func (Address) MarshalJSON ¶
func (Address) Short ¶
Short returns the string representation of the address with leading zeros removed.
func (*Address) UnmarshalJSON ¶
type AddressGenerator ¶
type AggregatedSignature ¶ added in v0.9.6
type AggregatedSignature struct { // List of signatures VerifierSignatures []crypto.Signature // List of signer identifiers SignerIDs []Identifier }
AggregatedSignature contains a set of of signatures from verifiers attesting to the validity of an execution result chunk. TODO: this will be replaced with BLS aggregation
func (*AggregatedSignature) HasSigner ¶ added in v0.14.0
func (a *AggregatedSignature) HasSigner(signerID Identifier) bool
HasSigner returns true if and only if signer's signature is part of this aggregated signature
func (*AggregatedSignature) NumberSigners ¶ added in v0.14.0
func (a *AggregatedSignature) NumberSigners() int
NumberSigners returns the number of signers that contributed to the AggregatedSignature
type AssignmentList ¶
type AssignmentList [][]Identifier
AssignmentList is a list of identifier lists. Each list of identifiers lists the identities that are part of the given cluster.
type Attestation ¶
type Attestation struct { BlockID Identifier // ID of the block included the collection ExecutionResultID Identifier // ID of the execution result ChunkIndex uint64 // index of the approved chunk }
Attestation confirms correctness of a chunk of an exec result
func (Attestation) ID ¶
func (a Attestation) ID() Identifier
ID generates a unique identifier using attestation
type Batch ¶
type Batch struct {
BlockIDs []Identifier
}
Batch is a set of block IDs we want to request.
type Block ¶
Block (currently) includes the header, the payload hashes as well as the payload contents.
func (Block) Checksum ¶
func (b Block) Checksum() Identifier
Checksum returns the checksum of the header.
func (*Block) SetPayload ¶
SetPayload sets the payload and updates the payload hash.
type BlockEvents ¶
type BlockEvents struct { BlockID Identifier BlockHeight uint64 BlockTimestamp time.Time Events []Event }
BlockEvents contains events emitted in a single block.
type Chain ¶
type Chain interface { NewAddressGenerator() AddressGenerator AddressAtIndex(index uint64) (Address, error) ServiceAddress() Address BytesToAddressGenerator(b []byte) AddressGenerator IsValid(Address) bool IndexFromAddress(address Address) (uint64, error) String() string // contains filtered or unexported methods }
Chain is the interface for address generation implementations.
type ChainID ¶
type ChainID string
A ChainID is a unique identifier for a specific Flow network instance.
Chain IDs are used used to prevent replay attacks and to support network-specific address generation.
const Emulator ChainID = "flow-emulator"
Emulator is the chain ID for the emulated node chain.
const Mainnet ChainID = "flow-mainnet"
Mainnet is the chain ID for the mainnet node chain.
const MonotonicEmulator ChainID = "flow-emulator-monotonic"
MonotonicEmulator is the chain ID for the emulated node chain with monotonic address generation.
const Testnet ChainID = "flow-testnet"
Testnet is the chain ID for the testnet node chain.
type Chunk ¶
type Chunk struct { ChunkBody Index uint64 // chunk index inside the ER (starts from zero) // EndState inferred from next chunk or from the ER EndState StateCommitment }
func (*Chunk) Checksum ¶
func (ch *Chunk) Checksum() Identifier
Checksum provides a cryptographic commitment for a chunk content
type ChunkBody ¶
type ChunkBody struct { CollectionIndex uint // execution info StartState StateCommitment // start state when starting executing this chunk EventCollection Identifier // Events generated by executing results BlockID Identifier // Block id of the execution result this chunk belongs to // Computation consumption info TotalComputationUsed uint64 // total amount of computation used by running all txs in this chunk NumberOfTransactions uint64 // number of transactions inside the collection }
type ChunkDataPack ¶
type ChunkDataPack struct { ChunkID Identifier StartState StateCommitment Proof StorageProof CollectionID Identifier }
ChunkDataPack holds all register touches (any read, or write) note that we have to capture a read proof for each write before updating the registers
func (*ChunkDataPack) Checksum ¶
func (c *ChunkDataPack) Checksum() Identifier
Checksum returns the checksum of the chunk data pack.
func (*ChunkDataPack) ID ¶
func (c *ChunkDataPack) ID() Identifier
ID returns the unique identifier for the concrete view, which is the ID of the chunk the view is for.
type ChunkList ¶
type ChunkList []*Chunk
Note that this is the basic version of the List, we need to substitute it with something like Merkel tree at some point
func (ChunkList) ByChecksum ¶
func (cl ChunkList) ByChecksum(cs Identifier) (*Chunk, bool)
ByChecksum returns an entity from the list by entity fingerprint
func (ChunkList) ByIndex ¶
ByIndex returns an entity from the list by index if requested chunk is within range of list, it returns chunk and true if requested chunk is out of the range, it returns nil and false boolean return value indicates whether requested chunk is within range
func (ChunkList) Empty ¶ added in v0.15.0
Empty returns true if the chunk list is empty. Otherwise it returns false.
func (ChunkList) Fingerprint ¶
func (cl ChunkList) Fingerprint() Identifier
func (ChunkList) Len ¶
Len returns the number of Chunks in the list. It is also part of the sort interface that makes ChunkList sortable
type ClusterList ¶
type ClusterList []IdentityList
ClusterList is a list of identity lists. Each `IdentityList` represents the nodes assigned to a specific cluster.
func NewClusterList ¶
func NewClusterList(assignments AssignmentList, collectors IdentityList) (ClusterList, error)
NewClusterList creates a new cluster list based on the given cluster assignment and the provided list of identities.
func (ClusterList) Assignments ¶ added in v0.15.0
func (clusters ClusterList) Assignments() AssignmentList
Assignments returns the assignment list for a cluster.
func (ClusterList) ByIndex ¶
func (cl ClusterList) ByIndex(index uint) (IdentityList, bool)
ByIndex retrieves the list of identities that are part of the given cluster.
func (ClusterList) ByNodeID ¶
func (cl ClusterList) ByNodeID(nodeID Identifier) (IdentityList, uint, bool)
ByNodeID select the cluster that the node with the given ID is part of.
Nodes will be divided into equally sized clusters as far as possible. The last return value will indicate if the look up was successful
func (ClusterList) ByTxID ¶
func (cl ClusterList) ByTxID(txID Identifier) (IdentityList, bool)
ByTxID selects the cluster that should receive the transaction with the given transaction ID.
For evenly distributed transaction IDs, this will evenly distribute transactions between clusters.
func (ClusterList) IndexOf ¶
func (cl ClusterList) IndexOf(cluster IdentityList) (uint, bool)
IndexOf returns the index of the given cluster.
type Collection ¶
type Collection struct {
Transactions []*TransactionBody
}
Collection is set of transactions.
func CollectionFromTransactions ¶
func CollectionFromTransactions(transactions []*Transaction) Collection
CollectionFromTransactions creates a new collection from the list of transactions.
func (Collection) Checksum ¶
func (c Collection) Checksum() Identifier
func (Collection) Fingerprint ¶
func (c Collection) Fingerprint() []byte
func (*Collection) Guarantee ¶
func (c *Collection) Guarantee() CollectionGuarantee
Guarantee returns a collection guarantee for this collection.
func (Collection) ID ¶
func (c Collection) ID() Identifier
func (Collection) Len ¶
func (c Collection) Len() int
func (Collection) Light ¶
func (c Collection) Light() LightCollection
Light returns the light, reference-only version of the collection.
type CollectionGuarantee ¶
type CollectionGuarantee struct { CollectionID Identifier // ID of the collection being guaranteed ReferenceBlockID Identifier // defines expiry of the collection SignerIDs []Identifier // list of guarantors Signature crypto.Signature // guarantor signatures }
CollectionGuarantee is a signed hash for a collection, which is used to announce collections to consensus nodes.
func (*CollectionGuarantee) Checksum ¶
func (cg *CollectionGuarantee) Checksum() Identifier
Checksum returns a checksum of the collection guarantee including the signatures.
func (*CollectionGuarantee) ID ¶
func (cg *CollectionGuarantee) ID() Identifier
ID returns the fingerprint of the collection guarantee.
type CollectionList ¶
type CollectionList struct {
// contains filtered or unexported fields
}
Note that this is the basic version of the List, we need to substitute it with something like Merkle tree at some point
func (*CollectionList) ByChecksum ¶
func (cl *CollectionList) ByChecksum(cs Identifier) (*Collection, bool)
ByChecksum returns an entity from the list by entity fingerprint
func (*CollectionList) ByIndex ¶
func (cl *CollectionList) ByIndex(i uint64) *Collection
ByIndex returns an entity from the list by index
func (*CollectionList) ByIndexWithProof ¶
func (cl *CollectionList) ByIndexWithProof(i uint64) (*Collection, Proof)
ByIndexWithProof returns an entity from the list by index and proof of membership
func (*CollectionList) Fingerprint ¶
func (cl *CollectionList) Fingerprint() Identifier
func (*CollectionList) Insert ¶
func (cl *CollectionList) Insert(ch *Collection)
func (*CollectionList) Items ¶
func (cl *CollectionList) Items() []*Collection
type DKGParticipant ¶
type DKGParticipant struct { Index uint }
func (DKGParticipant) MarshalJSON ¶
func (part DKGParticipant) MarshalJSON() ([]byte, error)
func (DKGParticipant) MarshalMsgpack ¶
func (part DKGParticipant) MarshalMsgpack() ([]byte, error)
func (*DKGParticipant) UnmarshalJSON ¶
func (part *DKGParticipant) UnmarshalJSON(b []byte) error
func (*DKGParticipant) UnmarshalMsgpack ¶
func (part *DKGParticipant) UnmarshalMsgpack(b []byte) error
type Entity ¶
type Entity interface { // ID returns a unique id for this entity using a hash of the immutable // fields of the entity. ID() Identifier // Checksum returns a unique checksum for the entity, including the mutable // data such as signatures. Checksum() Identifier }
Entity defines how flow entities should be defined Entities are flat data structures holding multiple data fields. Entities don't includes nested entities, they only include pointers to other entities. for example they keep an slice of entity commits instead of keeping an slice of entity object itself. This simplifies storage, signature and validation of entities.
type EntityList ¶
type EntityList interface { EntitySet // HasIndex checks if the list has an entity at the given index. HasIndex(i uint) bool // ByIndex returns an entity from the list by index ByIndex(i uint) (Entity, bool) // ByIndexWithProof returns an entity from the list by index and proof of membership ByIndexWithProof(i uint) (Entity, Proof, bool) }
EntityList is a list of entities of the same type
type EntitySet ¶
type EntitySet interface { // Insert adds an entity to the data structure. Insert(Entity) bool // Remove removes an entity from the data structure. Remove(Entity) bool // Items returns all items of the collection. Items() []Entity // Size returns the number of entities in the data structure. Size() uint // Fingerprint returns a unique identifier for all entities of the data // structure. Fingerprint() Identifier // ByID returns the entity with the given fingerprint. ByID(id Identifier) (Entity, bool) // if the set has an specific member providing proof of membership ByIDWithProof(id Identifier) (bool, Proof, error) }
EntitySet holds a set of entities (order doesn't matter)
type EpochCommit ¶
type EpochCommit struct { Counter uint64 // the number of the epoch ClusterQCs []*QuorumCertificate // quorum certificates for each cluster DKGGroupKey crypto.PublicKey // group key from DKG DKGParticipants map[Identifier]DKGParticipant // public keys for DKG participants }
EpochCommit is a service event emitted when epoch setup has been completed. When an EpochCommit event is emitted, the network is ready to transition to the epoch.
func (*EpochCommit) EncodeRLP ¶
func (commit *EpochCommit) EncodeRLP(w io.Writer) error
EncodeRLP encodes the commit as RLP. The RLP encoding needs to be handled differently from JSON/msgpack, because it does not handle custom encoders within map types.
func (*EpochCommit) ID ¶
func (commit *EpochCommit) ID() Identifier
ID returns the hash of the event contents.
func (*EpochCommit) MarshalJSON ¶
func (commit *EpochCommit) MarshalJSON() ([]byte, error)
func (*EpochCommit) MarshalMsgpack ¶
func (commit *EpochCommit) MarshalMsgpack() ([]byte, error)
func (*EpochCommit) ServiceEvent ¶
func (commit *EpochCommit) ServiceEvent() ServiceEvent
func (*EpochCommit) UnmarshalJSON ¶
func (commit *EpochCommit) UnmarshalJSON(b []byte) error
func (*EpochCommit) UnmarshalMsgpack ¶
func (commit *EpochCommit) UnmarshalMsgpack(b []byte) error
type EpochPhase ¶
type EpochPhase int
EpochPhase represents a phase of the Epoch Preparation Protocol. The phase of an epoch is resolved based on a block reference and is fork-dependent. An epoch begins in the staking phase, then transitions to the setup phase in the block containing the EpochSetup service event, then to the committed phase in the block containing the EpochCommit service event. |<-- EpochPhaseStaking -->|<-- EpochPhaseSetup -->|<-- EpochPhaseCommitted -->|<-- EpochPhaseStaking -->... |<------------------------------- Epoch N ------------------------------------>|<-- Epoch N + 1 --...
const ( EpochPhaseUndefined EpochPhase = iota EpochPhaseStaking EpochPhaseSetup EpochPhaseCommitted )
func (EpochPhase) String ¶
func (p EpochPhase) String() string
type EpochSetup ¶
type EpochSetup struct { Counter uint64 // the number of the epoch FirstView uint64 // the first view of the epoch FinalView uint64 // the final view of the epoch Participants IdentityList // all participants of the epoch Assignments AssignmentList // cluster assignment for the epoch RandomSource []byte // source of randomness for epoch-specific setup tasks }
EpochSetup is a service event emitted when the network is ready to set up for the upcoming epoch. It contains the participants in the epoch, the length, the cluster assignment, and the seed for leader selection.
func (*EpochSetup) ID ¶
func (setup *EpochSetup) ID() Identifier
ID returns the hash of the event contents.
func (*EpochSetup) ServiceEvent ¶
func (setup *EpochSetup) ServiceEvent() ServiceEvent
type EpochStatus ¶
type EpochStatus struct { PreviousEpoch EventIDs // EpochSetup and EpochCommit events for the previous epoch CurrentEpoch EventIDs // EpochSetup and EpochCommit events for the current epoch NextEpoch EventIDs // EpochSetup and EpochCommit events for the next epoch }
EpochStatus represents the status of the current and next epoch with respect to a reference block. Concretely, it contains the IDs for all relevant service events emitted as of the reference block. Events not yet emitted are represented by ZeroID.
func NewEpochStatus ¶
func NewEpochStatus(previousSetup, previousCommit, currentSetup, currentCommit, nextSetup, nextCommit Identifier) (*EpochStatus, error)
func (*EpochStatus) Check ¶ added in v0.15.0
func (es *EpochStatus) Check() error
Check checks that the status is well-formed, returning an error if it is not.
func (*EpochStatus) HasPrevious ¶ added in v0.15.0
func (es *EpochStatus) HasPrevious() bool
func (*EpochStatus) Phase ¶
func (es *EpochStatus) Phase() (EpochPhase, error)
Phase returns the phase for the CURRENT epoch, given this epoch status.
type Event ¶
type Event struct { // Type is the qualified event type. Type EventType // TransactionID is the ID of the transaction this event was emitted from. TransactionID Identifier // TransactionIndex defines the index of the transaction this event was emitted from within the block. // The first transaction has index 0, the second has index 1, and so on. TransactionIndex uint32 // EventIndex defines the ordering of events in a transaction. // The first event emitted has index 0, the second has index 1, and so on. EventIndex uint32 // Payload contains the encoded event data. Payload []byte }
func (*Event) Body ¶
func (e *Event) Body() interface{}
Body returns the body of the execution receipt.
func (Event) Encode ¶
Encode returns the canonical encoding of this event, containing only the fields necessary to uniquely identify it.
func (Event) Fingerprint ¶
func (Event) ID ¶
func (e Event) ID() Identifier
ID returns a canonical identifier that is guaranteed to be unique.
type EventIDs ¶
type EventIDs struct { // SetupID is the ID of the EpochSetup event for the respective Epoch SetupID Identifier // CommitID is the ID of the EpochCommit event for the respective Epoch CommitID Identifier }
EventIDs is a container for IDs of epoch service events.
type ExecutedTransaction ¶
type ExecutedTransaction struct { Tx *Transaction GasSpent uint64 MaxGas uint64 StartState StateCommitment EndState StateCommitment }
ExecutedTransaction are generated by computer and pass to chunker
type ExecutionReceipt ¶
type ExecutionReceipt struct { ExecutorID Identifier ExecutionResult ExecutionResult Spocks []crypto.Signature ExecutorSignature crypto.Signature }
func ExecutionReceiptFromMeta ¶
func ExecutionReceiptFromMeta(meta ExecutionReceiptMeta, result ExecutionResult) *ExecutionReceipt
func (*ExecutionReceipt) Checksum ¶
func (er *ExecutionReceipt) Checksum() Identifier
Checksum returns a checksum for the execution receipt including the signatures.
func (*ExecutionReceipt) ID ¶
func (er *ExecutionReceipt) ID() Identifier
ID returns the canonical ID of the execution receipt.
func (*ExecutionReceipt) Meta ¶
func (er *ExecutionReceipt) Meta() *ExecutionReceiptMeta
Meta returns the receipt metadata for the receipt.
type ExecutionReceiptGroupedList ¶ added in v0.15.0
type ExecutionReceiptGroupedList map[Identifier]ExecutionReceiptList
ExecutionReceiptGroupedList is a partition of an ExecutionReceiptList
func (ExecutionReceiptGroupedList) GetGroup ¶ added in v0.15.0
func (g ExecutionReceiptGroupedList) GetGroup(groupID Identifier) ExecutionReceiptList
GetGroup returns the receipts that were mapped to the same identifier by the grouping function. Returns an empty (nil) ExecutionReceiptList if groupID does not exist.
func (ExecutionReceiptGroupedList) NumberGroups ¶ added in v0.15.0
func (g ExecutionReceiptGroupedList) NumberGroups() int
NumberGroups returns the number of groups
type ExecutionReceiptGroupingFunction ¶ added in v0.15.0
type ExecutionReceiptGroupingFunction func(*ExecutionReceipt) Identifier
ExecutionReceiptGroupingFunction is a function that assigns an identifier to each receipt
type ExecutionReceiptList ¶ added in v0.15.0
type ExecutionReceiptList []*ExecutionReceipt
ExecutionReceiptList is a slice of ExecutionReceipts with the additional functionality to group receipts by various properties
func (ExecutionReceiptList) GroupBy ¶ added in v0.15.0
func (l ExecutionReceiptList) GroupBy(grouper ExecutionReceiptGroupingFunction) ExecutionReceiptGroupedList
GroupBy partitions the ExecutionReceiptList. All receipts that are mapped by the grouping function to the same identifier are placed in the same group. Within each group, the order and multiplicity of the receipts is preserved.
func (ExecutionReceiptList) GroupByExecutorID ¶ added in v0.15.0
func (l ExecutionReceiptList) GroupByExecutorID() ExecutionReceiptGroupedList
GroupByExecutorID partitions the ExecutionReceiptList by the receipts' ExecutorIDs. Within each group, the order and multiplicity of the receipts is preserved.
func (ExecutionReceiptList) GroupByResultID ¶ added in v0.15.0
func (l ExecutionReceiptList) GroupByResultID() ExecutionReceiptGroupedList
GroupByResultID partitions the ExecutionReceiptList by the receipts' Result IDs. Within each group, the order and multiplicity of the receipts is preserved.
func (ExecutionReceiptList) Size ¶ added in v0.15.0
func (l ExecutionReceiptList) Size() int
Size returns the number of receipts in the list
type ExecutionReceiptMeta ¶
type ExecutionReceiptMeta struct { ExecutorID Identifier ResultID Identifier Spocks []crypto.Signature ExecutorSignature crypto.Signature }
ExecutionReceiptMeta contains the metadata the distinguishes an execution receipt from an execution result. This is used for storing results and receipts separately in a composable way.
type ExecutionResult ¶
type ExecutionResult struct { PreviousResultID Identifier // commit of the previous ER BlockID Identifier // commit of the current block Chunks ChunkList ServiceEvents []ServiceEvent }
ExecutionResult ...
func (ExecutionResult) FinalStateCommitment ¶ added in v0.11.0
func (er ExecutionResult) FinalStateCommitment() (StateCommitment, bool)
FinalStateCommitment returns the Execution Result's commitment to the final execution state of the block, i.e. the last chunk's output state.
By protocol definition, each ExecutionReceipt must contain at least one chunk (system chunk). Convention: publishing an ExecutionReceipt without a final state commitment is a slashable protocol violation. TODO: change bool to error return with a sentinel error
func (ExecutionResult) ID ¶
func (er ExecutionResult) ID() Identifier
ID returns the hash of the execution result body
func (ExecutionResult) InitialStateCommit ¶ added in v0.11.0
func (er ExecutionResult) InitialStateCommit() (StateCommitment, bool)
InitialStateCommit returns a commitment to the execution state used as input for computing the block the block, i.e. the leading chunk's input state.
By protocol definition, each ExecutionReceipt must contain at least one chunk (system chunk). Convention: publishing an ExecutionReceipt without an initial state commitment is a slashable protocol violation. TODO: change bool to error return with a sentinel error
type Header ¶
type Header struct { ChainID ChainID // ChainID is a chain-specific value to prevent replay attacks. ParentID Identifier // ParentID is the ID of this block's parent. Height uint64 PayloadHash Identifier // PayloadHash is a hash of the payload of this block. Timestamp time.Time // Timestamp is the time at which this block was proposed. The proposing node can choose any time, so this should not be trusted as accurate. View uint64 // View is the view number at which this block was proposed. ParentVoterIDs []Identifier // list of voters who signed the parent block ParentVoterSig crypto.Signature // aggregated signature over the parent block ProposerID Identifier // proposer identifier for the block ProposerSig crypto.Signature // signature of the proposer over the new block }
Header contains all meta-data for a block, as well as a hash representing the combined payload of the entire block. It is what consensus nodes agree on after validating the contents against the payload hash.
func (Header) Body ¶
func (h Header) Body() interface{}
Body returns the immutable part of the block header.
func (Header) Checksum ¶
func (h Header) Checksum() Identifier
Checksum returns the checksum of the header.
func (Header) Fingerprint ¶
func (Header) ID ¶
func (h Header) ID() Identifier
ID returns a unique ID to singularly identify the header and its block within the flow system.
func (Header) MarshalJSON ¶
MarshalJSON makes sure the timestamp is encoded in UTC.
func (Header) MarshalMsgpack ¶
MarshalMsgpack makes sure the timestamp is encoded in UTC.
func (*Header) UnmarshalJSON ¶
UnmarshalJSON makes sure the timestamp is decoded in UTC.
func (*Header) UnmarshalMsgpack ¶
UnmarshalMsgpack makes sure the timestamp is decoded in UTC.
type Identifier ¶
type Identifier [32]byte
Identifier represents a 32-byte unique identifier for an entity.
func ConcatSum ¶
func ConcatSum(ids ...Identifier) Identifier
func GetIDs ¶
func GetIDs(value interface{}) []Identifier
GetIDs gets the IDs for a slice of entities.
func HashToID ¶
func HashToID(hash []byte) Identifier
func HexStringToIdentifier ¶
func HexStringToIdentifier(hexString string) (Identifier, error)
HexStringToIdentifier converts a hex string to an identifier. The input must be 64 characters long and contain only valid hex characters.
func MakeID ¶
func MakeID(entity interface{}) Identifier
MakeID creates an ID from a hash of encoded data. MakeID uses `model.Fingerprint() []byte` to get the byte representation of the entity, which uses RLP to encode the data. If the input defines its own canonical encoding by implementing Fingerprinter, it uses that instead. That allows removal of non-unique fields from structs or overwriting of the used encoder. We are using Fingerprint instead of the default encoding for two reasons: a) JSON (the default encoding) does not specify an order for the elements of arrays and objects, which could lead to different hashes depending on the JSON implementation and b) the Fingerprinter interface allows to exclude fields not needed in the pre-image of the hash that comprises the Identifier, which could be different from the encoding for sending entities in messages or for storing them.
func MerkleRoot ¶
func MerkleRoot(ids ...Identifier) Identifier
func PublicKeyToID ¶
func PublicKeyToID(pub crypto.PublicKey) (Identifier, error)
PublicKeyToID creates an ID from a public key.
func Sample ¶
func Sample(size uint, ids ...Identifier) []Identifier
Sample returns random sample of length 'size' of the ids [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
func (Identifier) Format ¶
func (id Identifier) Format(state fmt.State, verb rune)
Format handles formatting of id for different verbs. This is called when formatting an identifier with fmt.
func (Identifier) MarshalText ¶
func (id Identifier) MarshalText() ([]byte, error)
func (Identifier) String ¶
func (id Identifier) String() string
String returns the hex string representation of the identifier.
func (*Identifier) UnmarshalText ¶
func (id *Identifier) UnmarshalText(text []byte) error
type IdentifierFilter ¶ added in v0.14.0
type IdentifierFilter func(Identifier) bool
IdentifierFilter is a filter on identifiers.
type IdentifierList ¶
type IdentifierList []Identifier
IdentifierList defines a sortable list of identifiers
func (IdentifierList) Len ¶
func (il IdentifierList) Len() int
Len returns length of the IdentiferList in the number of stored identifiers. It satisfies the sort.Interface making the IdentifierList sortable.
func (IdentifierList) Less ¶
func (il IdentifierList) Less(i, j int) bool
Less returns true if element i in the IdentifierList is less than j based on its identifier. Otherwise it returns true. It satisfies the sort.Interface making the IdentifierList sortable.
func (IdentifierList) Strings ¶ added in v0.13.0
func (il IdentifierList) Strings() []string
func (IdentifierList) Swap ¶
func (il IdentifierList) Swap(i, j int)
Swap swaps the element i and j in the IdentifierList. It satisfies the sort.Interface making the IdentifierList sortable.
type Identity ¶
type Identity struct { // NodeID uniquely identifies a particular node. A node's ID is fixed for // the duration of that node's participation in the network. NodeID Identifier Address string Role Role // Stake represents the node's *weight*. The stake (quantity of $FLOW held // in escrow during the node's participation) is strictly managed by the // service account. The protocol software strictly considers weight, which // represents how much voting power a given node has. // // NOTE: Nodes that are registered for an upcoming epoch, or that are in // the process of un-staking, have 0 weight. // // TODO: to be renamed to Weight Stake uint64 // Ejected represents whether a node has been permanently removed from the // network. A node may be ejected for either: // * committing one protocol felony // * committing a series of protocol misdemeanours Ejected bool StakingPubKey crypto.PublicKey NetworkPubKey crypto.PublicKey }
Identity represents a node identity.
func ParseIdentity ¶
ParseIdentity parses a string representation of an identity.
func (Identity) Checksum ¶
func (iy Identity) Checksum() Identifier
Checksum returns a checksum for the identity including mutable attributes.
func (Identity) ID ¶
func (iy Identity) ID() Identifier
ID returns a unique identifier for the identity.
func (Identity) MarshalJSON ¶
func (Identity) MarshalMsgpack ¶
func (*Identity) UnmarshalJSON ¶
func (*Identity) UnmarshalMsgpack ¶
type IdentityFilter ¶
IdentityFilter is a filter on identities.
type IdentityList ¶
type IdentityList []*Identity
IdentityList is a list of nodes.
func (IdentityList) ByIndex ¶
func (il IdentityList) ByIndex(index uint) (*Identity, bool)
ByIndex returns the node at the given index.
func (IdentityList) ByNodeID ¶
func (il IdentityList) ByNodeID(nodeID Identifier) (*Identity, bool)
ByNodeID gets a node from the list by node ID.
func (IdentityList) Copy ¶ added in v0.12.0
func (il IdentityList) Copy() IdentityList
Copy returns a copy of the receiver. The resulting slice uses a different backing array, meaning appends and insert operations on either slice are guaranteed to only affect that slice.
Copy should be used when modifying an existing identity list by either appending new elements, re-ordering, or inserting new elements in an existing index.
func (IdentityList) Count ¶
func (il IdentityList) Count() uint
Count returns the count of identities.
func (IdentityList) DeterministicSample ¶
func (il IdentityList) DeterministicSample(size uint, seed int64) IdentityList
DeterministicSample returns deterministic random sample from the `IdentityList` using the given seed
func (IdentityList) Filter ¶
func (il IdentityList) Filter(filter IdentityFilter) IdentityList
Filter will apply a filter to the identity list.
func (IdentityList) Fingerprint ¶
func (il IdentityList) Fingerprint() Identifier
func (IdentityList) Lookup ¶ added in v0.12.0
func (il IdentityList) Lookup() map[Identifier]struct{}
func (IdentityList) Map ¶ added in v0.12.0
func (il IdentityList) Map(f IdentityMapFunc) IdentityList
Map returns a new identity list with the map function f applied to a copy of each identity.
CAUTION: this relies on structure copy semantics. Map functions that modify an object referenced by the input Identity structure will modify identities in the source slice as well.
func (IdentityList) NodeIDs ¶
func (il IdentityList) NodeIDs() []Identifier
NodeIDs returns the NodeIDs of the nodes in the list.
func (IdentityList) Order ¶
func (il IdentityList) Order(less IdentityOrder) IdentityList
Order will sort the list using the given sort function.
func (IdentityList) Sample ¶
func (il IdentityList) Sample(size uint) IdentityList
Sample returns simple random sample from the `IdentityList`
func (IdentityList) SamplePct ¶
func (il IdentityList) SamplePct(pct float64) IdentityList
SamplePct returns a random sample from the receiver identity list. The sample contains `pct` percentage of the list. The sample is rounded up if `pct>0`, so this will always select at least one identity.
NOTE: The input must be between 0-1.
func (IdentityList) Selector ¶
func (il IdentityList) Selector() IdentityFilter
Selector returns an identity filter function that selects only identities within this identity list.
func (IdentityList) StakingKeys ¶
func (il IdentityList) StakingKeys() []crypto.PublicKey
StakingKeys returns a list of the staking public keys for the identities.
func (IdentityList) TotalStake ¶
func (il IdentityList) TotalStake() uint64
TotalStake returns the total stake of all given identities.
func (IdentityList) Union ¶ added in v0.10.1
func (il IdentityList) Union(other IdentityList) IdentityList
Union returns a new identity list containing every identity that occurs in either `il`, or `other`, or both. There are no duplicates in the output, where duplicates are identities with the same node ID.
type IdentityMapFunc ¶ added in v0.12.0
IdentityMapFunc is a modifier function for map operations for identities. Identities are COPIED from the source slice.
type IdentityOrder ¶
IdentityOrder is a sort for identities.
type IncorporatedResult ¶ added in v0.11.0
type IncorporatedResult struct { // IncorporatedBlockID is the ID of the first block on its fork where a // receipt for this result was incorporated. Within a fork, multiple blocks // may contain receipts for the same result; only the first one is used to // compute the random beacon of the result's chunk assignment. IncorporatedBlockID Identifier // Result is the ExecutionResult contained in the ExecutionReceipt that was // incorporated in the payload of IncorporatedBlockID. Result *ExecutionResult // contains filtered or unexported fields }
IncorporatedResult is a wrapper around an ExecutionResult which contains the ID of the first block on its fork in which it was incorporated.
func NewIncorporatedResult ¶ added in v0.11.0
func NewIncorporatedResult(incorporatedBlockID Identifier, result *ExecutionResult) *IncorporatedResult
func (*IncorporatedResult) AddSignature ¶ added in v0.11.0
func (ir *IncorporatedResult) AddSignature(chunkIndex uint64, signerID Identifier, signature crypto.Signature)
AddSignature adds a signature to the collection of AggregatedSignatures
func (*IncorporatedResult) Checksum ¶ added in v0.11.0
func (ir *IncorporatedResult) Checksum() Identifier
CheckSum implements flow.Entity.CheckSum for IncorporatedResult to make it capable of being stored directly in mempools and storage.
func (*IncorporatedResult) GetAggregatedSignatures ¶ added in v0.11.0
func (ir *IncorporatedResult) GetAggregatedSignatures() []AggregatedSignature
GetAggregatedSignatures returns all the aggregated signatures orderd by chunk index
func (*IncorporatedResult) GetChunkSignatures ¶ added in v0.14.0
func (ir *IncorporatedResult) GetChunkSignatures(chunkIndex uint64) (*AggregatedSignature, bool)
GetChunkSignatures returns the AggregatedSignature for a specific chunk
func (*IncorporatedResult) GetSignature ¶ added in v0.11.0
func (ir *IncorporatedResult) GetSignature(chunkIndex uint64, signerID Identifier) (*crypto.Signature, bool)
GetSignature returns a signature by chunk index and signer ID
func (*IncorporatedResult) ID ¶ added in v0.11.0
func (ir *IncorporatedResult) ID() Identifier
ID implements flow.Entity.ID for IncorporatedResult to make it capable of being stored directly in mempools and storage.
func (*IncorporatedResult) NumberSignatures ¶ added in v0.15.0
func (ir *IncorporatedResult) NumberSignatures(chunkIndex uint64) uint
NumberSignatures returns the number of stored (distinct) signatures for the given chunk
type IncorporatedResultGroupedList ¶ added in v0.15.0
type IncorporatedResultGroupedList map[Identifier]IncorporatedResultList
IncorporatedResultGroupedList is a partition of an IncorporatedResultList
func (IncorporatedResultGroupedList) GetGroup ¶ added in v0.15.0
func (g IncorporatedResultGroupedList) GetGroup(groupID Identifier) IncorporatedResultList
GetGroup returns the IncorporatedResults that were mapped to the same identifier by the grouping function. Returns an empty (nil) IncorporatedResultList if groupID does not exist.
func (IncorporatedResultGroupedList) NumberGroups ¶ added in v0.15.0
func (g IncorporatedResultGroupedList) NumberGroups() int
NumberGroups returns the number of groups
type IncorporatedResultGroupingFunction ¶ added in v0.15.0
type IncorporatedResultGroupingFunction func(*IncorporatedResult) Identifier
IncorporatedResultGroupingFunction is a function that assigns an identifier to each IncorporatedResult
type IncorporatedResultList ¶ added in v0.15.0
type IncorporatedResultList []*IncorporatedResult
IncorporatedResultList is a slice of IncorporatedResults with the additional functionality to group them by various properties
func (IncorporatedResultList) GroupBy ¶ added in v0.15.0
func (l IncorporatedResultList) GroupBy(grouper IncorporatedResultGroupingFunction) IncorporatedResultGroupedList
GroupBy partitions the IncorporatedResultList. All IncorporatedResults that are mapped by the grouping function to the same identifier are placed in the same group. Within each group, the order and multiplicity of the IncorporatedResults is preserved.
func (IncorporatedResultList) GroupByExecutedBlockID ¶ added in v0.15.0
func (l IncorporatedResultList) GroupByExecutedBlockID() IncorporatedResultGroupedList
GroupByResultID partitions the IncorporatedResultList by the IDs of the executed blocks. Within each group, the order and multiplicity of the IncorporatedResults is preserved.
func (IncorporatedResultList) GroupByIncorporatedBlockID ¶ added in v0.15.0
func (l IncorporatedResultList) GroupByIncorporatedBlockID() IncorporatedResultGroupedList
GroupByExecutorID partitions the IncorporatedResultList by the ID of the block that incorporates the result. Within each group, the order and multiplicity of the IncorporatedResults is preserved.
func (IncorporatedResultList) GroupByResultID ¶ added in v0.15.0
func (l IncorporatedResultList) GroupByResultID() IncorporatedResultGroupedList
GroupByResultID partitions the IncorporatedResultList by the Results' IDs. Within each group, the order and multiplicity of the IncorporatedResults is preserved.
func (IncorporatedResultList) Size ¶ added in v0.15.0
func (l IncorporatedResultList) Size() int
Size returns the number of IncorporatedResults in the list
type IncorporatedResultSeal ¶ added in v0.11.0
type IncorporatedResultSeal struct { // IncorporatedResult is the incorporated result (result + ID of block where // it was incorporated) that the seal is for. IncorporatedResult *IncorporatedResult // Seal is a seal for the result contained in IncorporatedResult. Seal *Seal }
IncorporatedResultSeal is a wrapper around a seal that keeps track of which IncorporatedResult the seal corresponds to. Sealing is a function of result And the ID of the block in which the result was incorporated, which is all contained in IncorporatedResult.
func (*IncorporatedResultSeal) Checksum ¶ added in v0.11.0
func (s *IncorporatedResultSeal) Checksum() Identifier
CheckSum implements flow.Entity.CheckSum for IncorporatedResultSeal to make it capable of being stored directly in mempools and storage.
func (*IncorporatedResultSeal) ID ¶ added in v0.11.0
func (s *IncorporatedResultSeal) ID() Identifier
ID implements flow.Entity.ID for IncorporatedResultSeal to make it capable of being stored directly in mempools and storage.
type Index ¶
type Index struct { CollectionIDs []Identifier SealIDs []Identifier ReceiptIDs []Identifier }
type LightCollection ¶
type LightCollection struct {
Transactions []Identifier
}
LightCollection is a collection containing references to the constituent transactions rather than full transaction bodies. It is used for indexing transactions by collection and for computing the collection fingerprint.
func (LightCollection) Checksum ¶
func (lc LightCollection) Checksum() Identifier
func (LightCollection) Has ¶
func (lc LightCollection) Has(txID Identifier) bool
func (LightCollection) ID ¶
func (lc LightCollection) ID() Identifier
func (LightCollection) Len ¶
func (lc LightCollection) Len() int
type MonotonicAddressGenerator ¶
type MonotonicAddressGenerator struct {
// contains filtered or unexported fields
}
func (*MonotonicAddressGenerator) Bytes ¶
func (gen *MonotonicAddressGenerator) Bytes() []byte
Bytes converts an address index into a slice of bytes
func (*MonotonicAddressGenerator) CurrentAddress ¶
func (gen *MonotonicAddressGenerator) CurrentAddress() Address
CurrentAddress returns the address corresponding to the internal index.
func (*MonotonicAddressGenerator) NextAddress ¶
func (gen *MonotonicAddressGenerator) NextAddress() (Address, error)
NextAddress increments the internal index and generates the new address corresponding to the new index.
type Payload ¶
type Payload struct { Guarantees []*CollectionGuarantee Seals []*Seal Receipts []*ExecutionReceipt }
Payload is the actual content of each block.
func EmptyPayload ¶ added in v0.12.0
func EmptyPayload() Payload
EmptyPayload returns an empty block payload.
func (*Payload) MarshalJSON ¶ added in v0.15.0
JSONMarshal defines the JSON marshalling for block payloads. Enforce a consistent representation for empty slices.
type PendingBlock ¶
type PendingBlock struct { OriginID Identifier Header *Header Payload *Payload }
PendingBlock is a wrapper type representing a block that cannot yet be processed. The block header, payload, and sender ID are stored together while waiting for the block to become processable.
type ProposalKey ¶
A ProposalKey is the key that specifies the proposal key and sequence number for a transaction.
func (ProposalKey) ByteSize ¶ added in v0.11.0
func (p ProposalKey) ByteSize() int
ByteSize returns the byte size of the proposal key
type QuorumCertificate ¶
type QuorumCertificate struct { View uint64 BlockID Identifier SignerIDs []Identifier SigData []byte }
QuorumCertificate represents a quorum certificate for a block proposal as defined in the HotStuff algorithm. A quorum certificate is a collection of votes for a particular block proposal. Valid quorum certificates contain signatures from a super-majority of consensus committee members.
type RegisterEntries ¶ added in v0.10.0
type RegisterEntries []RegisterEntry
handy container for sorting
func (RegisterEntries) IDs ¶ added in v0.10.0
func (d RegisterEntries) IDs() []RegisterID
func (RegisterEntries) Len ¶ added in v0.10.0
func (d RegisterEntries) Len() int
func (RegisterEntries) Less ¶ added in v0.10.0
func (d RegisterEntries) Less(i, j int) bool
func (RegisterEntries) Swap ¶ added in v0.10.0
func (d RegisterEntries) Swap(i, j int)
func (RegisterEntries) Values ¶ added in v0.10.0
func (d RegisterEntries) Values() []RegisterValue
type RegisterEntry ¶ added in v0.10.0
type RegisterEntry struct { Key RegisterID Value RegisterValue }
type RegisterID ¶
func NewRegisterID ¶ added in v0.10.0
func NewRegisterID(owner, controller, key string) RegisterID
func (*RegisterID) String ¶ added in v0.10.0
func (r *RegisterID) String() string
type ResultApproval ¶
type ResultApproval struct { Body ResultApprovalBody VerifierSignature crypto.Signature // signature over all above fields }
ResultApproval includes an approval for a chunk, verified by a verification node
func (ResultApproval) Checksum ¶
func (ra ResultApproval) Checksum() Identifier
Checksum generates checksum using the result approval full content
func (ResultApproval) ID ¶
func (ra ResultApproval) ID() Identifier
ID generates a unique identifier using result approval body
type ResultApprovalBody ¶
type ResultApprovalBody struct { Attestation ApproverID Identifier // node id generating this result approval AttestationSignature crypto.Signature // signature over attestation, this has been separated for BLS aggregation Spock crypto.Signature // proof of re-computation, one per each chunk }
ResultApprovalBody holds body part of a result approval
func (ResultApprovalBody) ID ¶
func (rab ResultApprovalBody) ID() Identifier
ID generates a unique identifier using ResultApprovalBody
type Role ¶
type Role uint8
Role represents a role in the flow system.
const ( RoleCollection Role = 1 RoleConsensus Role = 2 RoleExecution Role = 3 RoleVerification Role = 4 RoleAccess Role = 5 )
Enumeration of the available flow node roles.
func (Role) MarshalText ¶
func (*Role) UnmarshalText ¶
type RoleList ¶ added in v0.12.0
type RoleList []Role
RoleList defines a slice of roles in flow system.
func (RoleList) Contains ¶ added in v0.12.0
Contains returns true if RoleList contains the role, otherwise false.
func (RoleList) ID ¶ added in v0.14.0
func (r RoleList) ID() Identifier
ID returns hash of the content of RoleList. It first sorts the RoleList and then takes its hash value.
func (RoleList) Len ¶ added in v0.14.0
Len returns length of the RoleList in the number of stored roles. It satisfies the sort.Interface making the RoleList sortable.
func (RoleList) Less ¶ added in v0.14.0
Less returns true if element i in the RoleList is less than j based on the numerical value of its role. Otherwise it returns true. It satisfies the sort.Interface making the RoleList sortable.
type Seal ¶
type Seal struct { BlockID Identifier ResultID Identifier FinalState StateCommitment AggregatedApprovalSigs []AggregatedSignature // one AggregatedSignature per chunk // Service Events are copied from the Execution Result. Therefore, repeating the // the service events here opens the possibility for a data-inconsistency attack. // It is _not_ necessary to repeat the ServiceEvents here, as an Execution Result // must be incorporated into the fork before it can be sealed. // TODO: include ServiceEvents in Execution Result and remove from Seal ServiceEvents []ServiceEvent }
A Seal is produced when an Execution Result (referenced by `ResultID`) for particular block (referenced by `BlockID`) is committed into the chain. A Seal for a block B can be included in the payload B's descendants. Only in the respective fork where the seal for B is included, the referenced result is considered committed. Different forks might contain different seals for the same result (or in edge cases, even for different results).
NOTES (1) As Seals are (currently) included in the payload, they are not strictly entities. (Entities can be sent between nodes as self-contained messages whose integrity is protected by a signature). By itself, a seal does _not_ contain enough information to determine its validity (verifier assignment cannot be computed) and its integrity is not protected by a signature of a node that is authorized to generate it. A seal should only be processed in the context of the block, which contains it.
(2) Even though seals are not strictly entities, they still implement the Entity interface. This allows us to store and retrieve seals individually. CAUTION: As seals are part of the block payload, their _exact_ content must be preserved by the storage system. This includes the exact list of approval signatures (incl. order). While it is possible to construct different valid seals for the same result (using different subsets of assigned verifiers), they cannot be treated as equivalent for the following reason:
- Swapping a seal in a block with a different once changes the binary representation of the block payload containing the seal.
- Changing the binary block representation would invalidate the block proposer's signature.
Therefore, to retrieve valid blocks from storage, it is required that the Seal.ID includes all fields with independent degrees of freedom (such as AggregatedApprovalSigs).
func (Seal) Checksum ¶
func (s Seal) Checksum() Identifier
func (Seal) ID ¶
func (s Seal) ID() Identifier
type ServiceEvent ¶
type ServiceEvent struct { Type string Event interface{} }
ServiceEvent represents a service event, which is a special event that when emitted from a service account smart contract, is propagated to the protocol and included in blocks. Service events typically cause changes to the protocol state. See EpochSetup and EpochCommit events in this package for examples.
This type represents a generic service event and primarily exists to simplify encoding and decoding.
func ConvertServiceEvent ¶ added in v0.15.0
func ConvertServiceEvent(event Event) (*ServiceEvent, error)
ConvertServiceEvent converts a service event encoded as the generic flow.Event type to a ServiceEvent type for use within protocol software and protocol state. This acts as the conversion from the Cadence type to the flow-go type.
TODO implement once Cadence types are defined
func (*ServiceEvent) UnmarshalJSON ¶
func (se *ServiceEvent) UnmarshalJSON(b []byte) error
func (*ServiceEvent) UnmarshalMsgpack ¶ added in v0.14.0
func (se *ServiceEvent) UnmarshalMsgpack(b []byte) error
type SignatureCollector ¶ added in v0.14.0
type SignatureCollector struct {
// contains filtered or unexported fields
}
SignatureCollector contains a set of of signatures from verifiers attesting to the validity of an execution result chunk. NOT concurrency safe. TODO: this will be replaced with stateful BLS aggregation
func NewSignatureCollector ¶ added in v0.14.0
func NewSignatureCollector() *SignatureCollector
NewSignatureCollector instantiates a new SignatureCollector
func (*SignatureCollector) Add ¶ added in v0.14.0
func (c *SignatureCollector) Add(signerID Identifier, signature crypto.Signature)
Add appends a signature. Only the _first_ signature is retained for each signerID.
func (*SignatureCollector) BySigner ¶ added in v0.14.0
func (c *SignatureCollector) BySigner(signerID Identifier) (*crypto.Signature, bool)
BySigner returns a signer's signature if it exists
func (*SignatureCollector) NumberSignatures ¶ added in v0.15.0
func (c *SignatureCollector) NumberSignatures() uint
NumberSignatures returns the number of stored (distinct) signatures
func (*SignatureCollector) ToAggregatedSignature ¶ added in v0.14.0
func (c *SignatureCollector) ToAggregatedSignature() AggregatedSignature
ToAggregatedSignature generates an aggregated signature from all signatures in the SignatureCollector
type StateCommitment ¶
type StateCommitment = []byte
StateCommitment holds the root hash of the tree (Snapshot)
type StorageProof ¶
type StorageProof = []byte
StorageProof (proof of a read or update to the state, Merkle path of some sort)
type Transaction ¶
type Transaction struct { TransactionBody Status TransactionStatus Events []Event ComputationSpent uint64 StartState StateCommitment EndState StateCommitment }
Transaction is the smallest unit of task.
func (*Transaction) Checksum ¶
func (tx *Transaction) Checksum() Identifier
Checksum provides a cryptographic commitment for a chunk content
func (*Transaction) PayloadMessage ¶
func (tx *Transaction) PayloadMessage() []byte
func (*Transaction) String ¶
func (tx *Transaction) String() string
type TransactionBody ¶
type TransactionBody struct { // A reference to a previous block // A transaction is expired after specific number of blocks (defined by network) counting from this block // for example, if block reference is pointing to a block with height of X and network limit is 10, // a block with x+10 height is the last block that is allowed to include this transaction. // user can adjust this reference to older blocks if he/she wants to make tx expire faster ReferenceBlockID Identifier // the transaction script as UTF-8 encoded Cadence source code Script []byte // arguments passed to the Cadence transaction Arguments [][]byte // Max amount of computation which is allowed to be done during this transaction GasLimit uint64 // Account key used to propose the transaction ProposalKey ProposalKey // Account that pays for this transaction fees Payer Address // A ordered (ascending) list of addresses that scripts will touch their assets (including payer address) // Accounts listed here all have to provide signatures // Each account might provide multiple signatures (sum of weight should be at least 1) // If code touches accounts that is not listed here, tx fails Authorizers []Address // List of account signatures excluding signature of the payer account PayloadSignatures []TransactionSignature // payer signature over the envelope (payload + payload signatures) EnvelopeSignatures []TransactionSignature }
TransactionBody includes the main contents of a transaction
func NewTransactionBody ¶
func NewTransactionBody() *TransactionBody
NewTransactionBody initializes and returns an empty transaction body
func (*TransactionBody) AddArgument ¶
func (tb *TransactionBody) AddArgument(arg []byte) *TransactionBody
AddArgument adds an argument to the Cadence arguments list for this transaction.
func (*TransactionBody) AddAuthorizer ¶
func (tb *TransactionBody) AddAuthorizer(address Address) *TransactionBody
AddAuthorizer adds an authorizer account to this transaction.
func (*TransactionBody) AddEnvelopeSignature ¶
func (tb *TransactionBody) AddEnvelopeSignature(address Address, keyID uint64, sig []byte) *TransactionBody
AddEnvelopeSignature adds an envelope signature to the transaction for the given address and key ID.
func (*TransactionBody) AddPayloadSignature ¶
func (tb *TransactionBody) AddPayloadSignature(address Address, keyID uint64, sig []byte) *TransactionBody
AddPayloadSignature adds a payload signature to the transaction for the given address and key ID.
func (TransactionBody) ByteSize ¶ added in v0.11.0
func (tb TransactionBody) ByteSize() uint
func (TransactionBody) Checksum ¶
func (tb TransactionBody) Checksum() Identifier
func (*TransactionBody) EnvelopeMessage ¶
func (tb *TransactionBody) EnvelopeMessage() []byte
EnvelopeMessage returns the signable message for transaction envelope.
This message is only signed by the payer account.
func (TransactionBody) Fingerprint ¶
func (tb TransactionBody) Fingerprint() []byte
func (TransactionBody) ID ¶
func (tb TransactionBody) ID() Identifier
func (*TransactionBody) MissingFields ¶
func (tb *TransactionBody) MissingFields() []string
MissingFields checks if a transaction is missing any required fields and returns those that are missing.
func (*TransactionBody) PayloadMessage ¶
func (tb *TransactionBody) PayloadMessage() []byte
func (*TransactionBody) SetArguments ¶
func (tb *TransactionBody) SetArguments(args [][]byte) *TransactionBody
SetArguments sets the Cadence arguments list for this transaction.
func (*TransactionBody) SetGasLimit ¶
func (tb *TransactionBody) SetGasLimit(limit uint64) *TransactionBody
SetGasLimit sets the gas limit for this transaction.
func (*TransactionBody) SetPayer ¶
func (tb *TransactionBody) SetPayer(address Address) *TransactionBody
SetPayer sets the payer account for this transaction.
func (*TransactionBody) SetProposalKey ¶
func (tb *TransactionBody) SetProposalKey(address Address, keyID uint64, sequenceNum uint64) *TransactionBody
SetProposalKey sets the proposal key and sequence number for this transaction.
The first two arguments specify the account key to be used, and the last argument is the sequence number being declared.
func (*TransactionBody) SetReferenceBlockID ¶
func (tb *TransactionBody) SetReferenceBlockID(blockID Identifier) *TransactionBody
SetReferenceBlockID sets the reference block ID for this transaction.
func (*TransactionBody) SetScript ¶
func (tb *TransactionBody) SetScript(script []byte) *TransactionBody
SetScript sets the Cadence script for this transaction.
func (*TransactionBody) SignEnvelope ¶
func (tb *TransactionBody) SignEnvelope(address Address, keyID uint64, privateKey crypto.PrivateKey, hasher hash.Hasher) error
SignEnvelope signs the full transaction (payload + payload signatures) with the specified account key.
The resulting signature is combined with the account address and key ID before being added to the transaction.
This function returns an error if the signature cannot be generated.
func (*TransactionBody) SignPayload ¶
func (tb *TransactionBody) SignPayload(address Address, keyID uint64, privateKey crypto.PrivateKey, hasher hash.Hasher) error
SignPayload signs the transaction payload with the specified account key.
The resulting signature is combined with the account address and key ID before being added to the transaction.
This function returns an error if the signature cannot be generated.
type TransactionField ¶
type TransactionField int
TransactionField represents a required transaction field.
const ( TransactionFieldUnknown TransactionField = iota TransactionFieldScript TransactionFieldRefBlockID TransactionFieldPayer )
func (TransactionField) String ¶
func (f TransactionField) String() string
String returns the string representation of a transaction field.
type TransactionResult ¶
type TransactionResult struct { // TransactionID is the ID of the transaction this error was emitted from. TransactionID Identifier // ErrorMessage contains the error message of any error that may have occurred when the transaction was executed ErrorMessage string }
TransactionResult contains the artifacts generated after executing a Cadence transaction.
func (*TransactionResult) Checksum ¶
func (te *TransactionResult) Checksum() Identifier
func (TransactionResult) ID ¶
func (t TransactionResult) ID() Identifier
ID returns a canonical identifier that is guaranteed to be unique.
func (TransactionResult) String ¶
func (t TransactionResult) String() string
String returns the string representation of this error.
type TransactionSignature ¶
type TransactionSignature struct { Address Address SignerIndex int KeyIndex uint64 Signature []byte }
A TransactionSignature is a signature associated with a specific account key.
func (TransactionSignature) ByteSize ¶ added in v0.11.0
func (s TransactionSignature) ByteSize() int
ByteSize returns the byte size of the transaction signature
func (TransactionSignature) Fingerprint ¶
func (s TransactionSignature) Fingerprint() []byte
func (TransactionSignature) String ¶ added in v0.12.0
func (s TransactionSignature) String() string
String returns the string representation of a transaction signature.
type TransactionStatus ¶
type TransactionStatus int
TransactionStatus represents the status of a transaction.
const ( // TransactionStatusUnknown indicates that the transaction status is not known. TransactionStatusUnknown TransactionStatus = iota // TransactionStatusPending is the status of a pending transaction. TransactionStatusPending // TransactionStatusFinalized is the status of a finalized transaction. TransactionStatusFinalized // TransactionStatusExecuted is the status of an executed transaction. TransactionStatusExecuted // TransactionStatusSealed is the status of a sealed transaction. TransactionStatusSealed // TransactionStatusExpired is the status of an expired transaction. TransactionStatusExpired )
func (TransactionStatus) String ¶
func (s TransactionStatus) String() string
String returns the string representation of a transaction status.
type TransactionTiming ¶
type TransactionTiming struct { TransactionID Identifier Received time.Time Finalized time.Time Executed time.Time }
TransactionTiming is used to track the timing/durations of a transaction through the system
func (TransactionTiming) Checksum ¶
func (t TransactionTiming) Checksum() Identifier
func (TransactionTiming) ID ¶
func (t TransactionTiming) ID() Identifier
Source Files ¶
- account.go
- account_encoder.go
- address.go
- aggregated_signature.go
- block.go
- chain.go
- chunk.go
- cluster.go
- collection.go
- collectionGuarantee.go
- constants.go
- entity.go
- epoch.go
- event.go
- executed_transaction.go
- execution_receipt.go
- execution_result.go
- header.go
- identifier.go
- identifierList.go
- identity.go
- incorporated_result.go
- incorporated_result_seal.go
- index.go
- ledger.go
- payload.go
- quorum_certificate.go
- range.go
- resultApproval.go
- role.go
- seal.go
- service_event.go
- transaction.go
- transaction_result.go
- transaction_timing.go