Documentation ¶
Index ¶
- Constants
- Variables
- func AddressToRegisterOwner(address Address) string
- func ByReferenceOrder(nodeIDs []Identifier) func(*Identity, *Identity) int
- func Canonical[T GenericIdentity](identity1 *T, identity2 *T) int
- func CheckConcatSum(sum Identifier, fps ...Identifier) bool
- func CheckMerkleRoot(root Identifier, ids ...Identifier) bool
- func CompatibleAlgorithms(sigAlgo crypto.SigningAlgorithm, hashAlgo hash.HashingAlgorithm) bool
- func ContractKey(contractName string) string
- func Deduplicate[T IDEntity](entities []T) []T
- func EncodeAccountPrivateKey(a AccountPrivateKey) ([]byte, error)
- func EncodeAccountPublicKey(a AccountPublicKey) ([]byte, error)
- func EncodeRuntimeAccountPublicKey(a AccountPublicKey) ([]byte, error)
- func EncodeRuntimeAccountPublicKeys(keys []AccountPublicKey) ([]cadence.Value, error)
- func IdToCid(f Identifier) cid.Cid
- func IdentifierCanonical(id1 Identifier, id2 Identifier) int
- func IdentityListEqualTo(lhs, rhs IdentityList) bool
- func IdentitySkeletonListEqualTo(lhs, rhs IdentitySkeletonList) bool
- func IdsToBytes(identifiers []Identifier) [][]byte
- func IsCanonical[T GenericIdentity](i1, i2 *T) bool
- func IsContractKey(key string) bool
- func IsContractNamesRegisterID(registerID RegisterID) bool
- func IsIdentifierCanonical(i1, i2 Identifier) bool
- func IsIdentifierListCanonical(il IdentifierList) bool
- func IsIdentityListCanonical[T GenericIdentity](il GenericIdentityList[T]) bool
- func IsInvalidSealingSegmentError(err error) bool
- func IsSlabIndexKey(key string) bool
- func KeyContractName(key string) string
- func NormalizedExecutionTimePerComputationUnit(execTime time.Duration, computationUsed uint64) float64
- func ToDKGParticipantLookup(participants IdentitySkeletonList, keys []crypto.PublicKey) (map[Identifier]DKGParticipant, error)
- type Account
- type AccountPrivateKey
- type AccountPublicKey
- type Address
- type AddressGenerator
- type AggregatedSignature
- type AssignmentList
- type Attestation
- type Block
- type BlockDigest
- type BlockEvents
- type BlockExecutionDataRoot
- type BlockStatus
- type CertifiedBlock
- type Chain
- type ChainID
- type ChainIDList
- 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
- type ClusterList
- func (cl ClusterList) Assignments() AssignmentList
- func (cl ClusterList) ByIndex(index uint) (IdentitySkeletonList, bool)
- func (cl ClusterList) ByNodeID(nodeID Identifier) (IdentitySkeletonList, uint, bool)
- func (cl ClusterList) ByTxID(txID Identifier) (IdentitySkeletonList, bool)
- func (cl ClusterList) IndexOf(cluster IdentitySkeletonList) (uint, bool)
- type ClusterQCVoteData
- type Collection
- type CollectionGuarantee
- type CollectionList
- type DKGEndState
- type DKGParticipant
- func (part DKGParticipant) EncodeRLP(w io.Writer) error
- func (part DKGParticipant) MarshalCBOR() ([]byte, error)
- func (part DKGParticipant) MarshalJSON() ([]byte, error)
- func (part DKGParticipant) MarshalMsgpack() ([]byte, error)
- func (part *DKGParticipant) UnmarshalCBOR(b []byte) error
- func (part *DKGParticipant) UnmarshalJSON(b []byte) error
- func (part *DKGParticipant) UnmarshalMsgpack(b []byte) error
- type DynamicIdentity
- type DynamicIdentityEntry
- type DynamicIdentityEntryList
- func (ll DynamicIdentityEntryList) ByNodeID(nodeID Identifier) (*DynamicIdentityEntry, bool)
- func (ll DynamicIdentityEntryList) Copy() DynamicIdentityEntryList
- func (ll DynamicIdentityEntryList) Lookup() map[Identifier]*DynamicIdentityEntry
- func (ll DynamicIdentityEntryList) Sort(less IdentifierOrder) DynamicIdentityEntryList
- func (ll DynamicIdentityEntryList) Sorted(less IdentifierOrder) bool
- type Entity
- type EpochCommit
- func (commit *EpochCommit) EncodeRLP(w io.Writer) error
- func (commit *EpochCommit) EqualTo(other *EpochCommit) bool
- func (commit *EpochCommit) ID() Identifier
- func (commit *EpochCommit) MarshalCBOR() ([]byte, error)
- func (commit EpochCommit) MarshalJSON() ([]byte, error)
- func (commit *EpochCommit) MarshalMsgpack() ([]byte, error)
- func (commit *EpochCommit) ServiceEvent() ServiceEvent
- func (commit *EpochCommit) UnmarshalCBOR(b []byte) error
- func (commit *EpochCommit) UnmarshalJSON(b []byte) error
- func (commit *EpochCommit) UnmarshalMsgpack(b []byte) error
- type EpochExtension
- type EpochParticipationStatus
- type EpochPhase
- type EpochRecover
- type EpochSetup
- type EpochStateContainer
- type EpochStateEntry
- type Event
- type EventIDs
- type EventType
- type EventsList
- 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 ExecutionReceiptMetaGroupedList
- type ExecutionReceiptMetaGroupingFunction
- type ExecutionReceiptMetaList
- func (l ExecutionReceiptMetaList) GroupBy(grouper ExecutionReceiptMetaGroupingFunction) ExecutionReceiptMetaGroupedList
- func (l ExecutionReceiptMetaList) GroupByExecutorID() ExecutionReceiptMetaGroupedList
- func (l ExecutionReceiptMetaList) GroupByResultID() ExecutionReceiptMetaGroupedList
- func (l ExecutionReceiptMetaList) Lookup() map[Identifier]*ExecutionReceiptMeta
- func (l ExecutionReceiptMetaList) Size() int
- type ExecutionResult
- func (er ExecutionResult) Checksum() Identifier
- func (er ExecutionResult) FinalStateCommitment() (StateCommitment, error)
- func (er ExecutionResult) ID() Identifier
- func (er ExecutionResult) InitialStateCommit() (StateCommitment, error)
- func (er ExecutionResult) MarshalJSON() ([]byte, error)
- func (er ExecutionResult) ValidateChunksLength() bool
- type ExecutionResultGroupedList
- type ExecutionResultGroupingFunction
- type ExecutionResultList
- func (l ExecutionResultList) GroupBy(grouper ExecutionResultGroupingFunction) ExecutionResultGroupedList
- func (l ExecutionResultList) GroupByExecutedBlockID() ExecutionResultGroupedList
- func (l ExecutionResultList) GroupByPreviousResultID() ExecutionResultGroupedList
- func (l ExecutionResultList) Lookup() map[Identifier]*ExecutionResult
- func (l ExecutionResultList) Size() int
- type GenericIdentity
- type GenericIdentityList
- func (il GenericIdentityList[T]) ByIndex(index uint) (*T, bool)
- func (il GenericIdentityList[T]) ByNetworkingKey(key crypto.PublicKey) (*T, bool)
- func (il GenericIdentityList[T]) ByNodeID(nodeID Identifier) (*T, bool)
- func (il GenericIdentityList[T]) Checksum() Identifier
- func (il GenericIdentityList[T]) Copy() GenericIdentityList[T]
- func (il GenericIdentityList[T]) Count() uint
- func (il GenericIdentityList[T]) Exists(target *T) bool
- func (il GenericIdentityList[T]) Filter(filter IdentityFilter[T]) GenericIdentityList[T]
- func (il GenericIdentityList[T]) GetIndex(target Identifier) (uint, bool)
- func (il GenericIdentityList[T]) ID() Identifier
- func (il GenericIdentityList[T]) IdentifierExists(target Identifier) bool
- func (il GenericIdentityList[T]) Lookup() map[Identifier]*T
- func (il GenericIdentityList[T]) Map(f IdentityMapFunc[T]) GenericIdentityList[T]
- func (il GenericIdentityList[T]) NodeIDs() IdentifierList
- func (il GenericIdentityList[T]) PublicStakingKeys() []crypto.PublicKey
- func (il GenericIdentityList[T]) Sample(size uint) (GenericIdentityList[T], error)
- func (il GenericIdentityList[T]) SamplePct(pct float64) (GenericIdentityList[T], error)
- func (il GenericIdentityList[T]) Selector() IdentityFilter[T]
- func (il GenericIdentityList[T]) Shuffle() (GenericIdentityList[T], error)
- func (il GenericIdentityList[T]) Sort(less IdentityOrder[T]) GenericIdentityList[T]
- func (il GenericIdentityList[T]) Sorted(less IdentityOrder[T]) bool
- func (il GenericIdentityList[T]) ToSkeleton() IdentitySkeletonList
- func (il GenericIdentityList[T]) TotalWeight() uint64
- func (il GenericIdentityList[T]) Union(other GenericIdentityList[T]) GenericIdentityList[T]
- type GetProtocolStateEntryFunc
- type GetResultFunc
- type GetSealByBlockIDFunc
- 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) MarshalCBOR() ([]byte, error)
- func (h Header) MarshalJSON() ([]byte, error)
- func (h Header) MarshalMsgpack() ([]byte, error)
- func (h Header) QuorumCertificate() *QuorumCertificate
- func (h *Header) UnmarshalCBOR(data []byte) error
- func (h *Header) UnmarshalJSON(data []byte) error
- func (h *Header) UnmarshalMsgpack(data []byte) error
- type IDEntity
- type Identifier
- func ByteSliceToId(b []byte) (Identifier, error)
- func CidToId(c cid.Cid) (Identifier, error)
- func ConcatSum(ids ...Identifier) Identifier
- func EntitiesToIDs[T Entity](entities []T) []Identifier
- func EventsMerkleRootHash(el EventsList) (Identifier, error)
- func HashToID(hash []byte) Identifier
- func HexStringToIdentifier(hexString string) (Identifier, error)
- func MakeID(entity interface{}) Identifier
- func MakeIDFromFingerPrint(fingerPrint []byte) Identifier
- func MerkleRoot(ids ...Identifier) Identifier
- func MustHexStringToIdentifier(hexString string) Identifier
- func PublicKeyToID(pk crypto.PublicKey) (Identifier, error)
- func Sample(size uint, ids ...Identifier) ([]Identifier, error)
- type IdentifierFilter
- type IdentifierList
- func (il IdentifierList) Checksum() Identifier
- func (il IdentifierList) Contains(target Identifier) bool
- func (il IdentifierList) Copy() IdentifierList
- func (il IdentifierList) Filter(filter IdentifierFilter) IdentifierList
- func (il IdentifierList) ID() Identifier
- func (il IdentifierList) Len() int
- func (il IdentifierList) Less(i, j int) bool
- func (il IdentifierList) Lookup() map[Identifier]struct{}
- func (il IdentifierList) Sample(size uint) (IdentifierList, error)
- func (il IdentifierList) Sort(less IdentifierOrder) IdentifierList
- func (il IdentifierList) Strings() []string
- func (il IdentifierList) Swap(i, j int)
- func (il IdentifierList) Union(other IdentifierList) IdentifierList
- type IdentifierOrder
- type Identity
- func (iy Identity) Checksum() Identifier
- func (iy Identity) EncodeRLP(w io.Writer) error
- func (iy *Identity) EqualTo(other *Identity) bool
- func (iy Identity) ID() Identifier
- func (iy Identity) MarshalCBOR() ([]byte, error)
- func (iy Identity) MarshalJSON() ([]byte, error)
- func (iy Identity) MarshalMsgpack() ([]byte, error)
- func (iy Identity) String() string
- func (iy *Identity) UnmarshalCBOR(b []byte) error
- func (iy *Identity) UnmarshalJSON(b []byte) error
- func (iy *Identity) UnmarshalMsgpack(b []byte) error
- type IdentityFilter
- type IdentityList
- type IdentityMapFunc
- type IdentityOrder
- type IdentitySkeleton
- func (iy IdentitySkeleton) EncodeRLP(w io.Writer) error
- func (iy *IdentitySkeleton) EqualTo(other *IdentitySkeleton) bool
- func (iy IdentitySkeleton) GetInitialWeight() uint64
- func (iy IdentitySkeleton) GetNetworkPubKey() crypto.PublicKey
- func (iy IdentitySkeleton) GetNodeID() Identifier
- func (iy IdentitySkeleton) GetRole() Role
- func (iy IdentitySkeleton) GetSkeleton() IdentitySkeleton
- func (iy IdentitySkeleton) GetStakingPubKey() crypto.PublicKey
- func (iy IdentitySkeleton) MarshalCBOR() ([]byte, error)
- func (iy IdentitySkeleton) MarshalJSON() ([]byte, error)
- func (iy IdentitySkeleton) MarshalMsgpack() ([]byte, error)
- func (iy IdentitySkeleton) String() string
- func (iy *IdentitySkeleton) UnmarshalCBOR(b []byte) error
- func (iy *IdentitySkeleton) UnmarshalJSON(b []byte) error
- func (iy *IdentitySkeleton) UnmarshalMsgpack(b []byte) error
- type IdentitySkeletonList
- type IncorporatedResult
- 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 InvalidSealingSegmentError
- type LightCollection
- type LightTransactionResult
- type MinEpochStateEntry
- type MonotonicAddressGenerator
- type PSKeyValueStoreData
- type Payload
- type ProposalKey
- type ProtocolStateEntryWrapperdeprecated
- type ProtocolStateVersionUpgrade
- type QuorumCertificate
- type QuorumCertificateWithSignerIDs
- type RegisterEntries
- type RegisterEntry
- type RegisterID
- func AccountStatusRegisterID(address Address) RegisterID
- func CadenceRegisterID(owner []byte, key []byte) RegisterID
- func ContractNamesRegisterID(address Address) RegisterID
- func ContractRegisterID(address Address, contractName string) RegisterID
- func NewRegisterID(owner Address, key string) RegisterID
- func PublicKeyRegisterID(address Address, index uint32) RegisterID
- func UUIDRegisterID(partition byte) RegisterID
- type RegisterIDs
- type RegisterValue
- type ResultApproval
- type ResultApprovalBody
- type RichEpochStateEntry
- type Role
- type RoleList
- type Seal
- type SealedVersionBeacon
- type SealingSegment
- func (segment *SealingSegment) AllBlocks() []*Block
- func (segment *SealingSegment) Finalized() *Block
- func (segment *SealingSegment) FinalizedSeal() (*Seal, error)
- func (segment *SealingSegment) Highest() *Block
- func (segment *SealingSegment) IsSporkRoot() bool
- func (segment *SealingSegment) LatestProtocolStateEntry() *ProtocolStateEntryWrapper
- func (segment *SealingSegment) Sealed() *Block
- func (segment *SealingSegment) Validate() error
- type SealingSegmentBuilder
- type ServiceEvent
- type ServiceEventList
- type ServiceEventMarshaller
- type ServiceEventType
- type Slashable
- type Spock
- type StateCommitment
- type StorageProof
- type TimeoutCertificate
- 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 uint32, sig []byte) *TransactionBody
- func (tb *TransactionBody) AddPayloadSignature(address Address, keyID uint32, 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) InclusionEffort() uint64
- func (tb *TransactionBody) MissingFields() []string
- func (tb *TransactionBody) PayloadMessage() []byte
- func (tb *TransactionBody) SetArguments(args [][]byte) *TransactionBody
- func (tb *TransactionBody) SetComputeLimit(limit uint64) *TransactionBody
- func (tb *TransactionBody) SetPayer(address Address) *TransactionBody
- func (tb *TransactionBody) SetProposalKey(address Address, keyID uint32, sequenceNum uint64) *TransactionBody
- func (tb *TransactionBody) SetReferenceBlockID(blockID Identifier) *TransactionBody
- func (tb *TransactionBody) SetScript(script []byte) *TransactionBody
- func (tb *TransactionBody) Sign(message []byte, privateKey crypto.PrivateKey, hasher hash.Hasher) ([]byte, error)
- func (tb *TransactionBody) SignEnvelope(address Address, keyID uint32, privateKey crypto.PrivateKey, ...) error
- func (tb *TransactionBody) SignPayload(address Address, keyID uint32, privateKey crypto.PrivateKey, ...) error
- type TransactionField
- type TransactionResult
- type TransactionResultErrorMessage
- type TransactionResults
- type TransactionSignature
- type TransactionStatus
- type TransactionTiming
- type VersionBeacon
- type VersionBoundary
Constants ¶
const ( // Service level keys (owner is empty): UUIDKeyPrefix = "uuid" AddressStateKey = "account_address_state" // Account level keys AccountKeyPrefix = "a." AccountStatusKey = AccountKeyPrefix + "s" CodeKeyPrefix = "code." ContractNamesKey = "contract_names" PublicKeyKeyPrefix = "public_key_" )
const AddressLength = (linearCodeN + 7) >> 3
AddressLength is the size of an account address in bytes. (n) is the size of an account address in bits.
const DefaultApprovalRequestsThreshold = uint64(10)
threshold for re-requesting approvals: min height difference between the latest finalized block and the block incorporating a result
const DefaultChunkAssignmentAlpha = 3
DefaultChunkAssignmentAlpha is the default number of verifiers that should be assigned to each chunk.
const DefaultEmergencySealingActive = false
DefaultEmergencySealingActive is a flag which indicates when emergency sealing is active, this is a temporary measure to make fire fighting easier while seal & verification is under development.
const DefaultInitialWeight = 100
DefaultInitialWeight is the default initial weight for a node identity. It is equal to the default initial weight in the FlowIDTableStaking smart contract.
const DefaultMaxCollectionByteSize = 3_000_000 // ~3MB. This is should always be higher than the limit on single tx size.
DefaultMaxCollectionByteSize is the default maximum value for a collection byte size.
const DefaultMaxCollectionSize = 100
DefaultMaxCollectionSize is the default maximum number of transactions allowed inside a collection.
const DefaultMaxCollectionTotalGas = 10_000_000 // 10M
DefaultMaxCollectionTotalGas is the default maximum value for total gas allowed to be included in a collection.
const DefaultMaxTransactionByteSize = 1_500_000
DefaultMaxTransactionByteSize is the default maximum transaction byte size. (~1.5MB)
const DefaultMaxTransactionGasLimit = 9999
DefaultMaxTransactionGasLimit is the default maximum value for the transaction gas limit.
const DefaultProtocolVersion uint = 0
DefaultProtocolVersion is the default protocol version, indicating none was explicitly set during bootstrapping.
const DefaultRequiredApprovalsForSealConstruction = uint(1)
DefaultRequiredApprovalsForSealConstruction is the default number of approvals required to construct a candidate seal for subsequent inclusion in block. when set to 1, it requires at least 1 approval to build a seal when set to 0, it can build seal without any approval
const DefaultRequiredApprovalsForSealValidation = 0
DefaultRequiredApprovalsForSealValidation is the default number of approvals that should be present and valid for each chunk. Setting this to 0 will disable counting of chunk approvals this can be used temporarily to ease the migration to new chunk based sealing. TODO:
- This value will result in consensus not depending on verification at all for sealing (no approvals required)
- Full protocol should be +2/3 of all currently authorized verifiers.
const DefaultTransactionExpiry = 10 * 60
DefaultTransactionExpiry is the default expiry for transactions, measured in blocks. The default value is equivalent to 10 minutes for a 1-second block time.
Let E by the transaction expiry. If a transaction T specifies a reference block R with height H, then T may be included in any block B where: * R<-*B - meaning B has R as an ancestor, and * R.height < B.height <= R.height+E
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 DefaultValueLogGCWaitDuration time.Duration = 10 * time.Minute
DefaultValueLogGCWaitDuration is the default wait duration before we repeatedly call the badger value log GC.
const DomainTagLength = 32
DomainTagLength is set to 32 bytes.
Signatures on Flow that needs to be scoped to a certain domain need to have the same length in order to avoid tag collision issues, when prefixing the message to sign.
const EpochSetupRandomSourceLength = 16
EpochSetupRandomSourceLength is the required length of the random source included in an EpochSetup service event.
const EstimatedComputationPerMillisecond = 9999.0 / 1000.0
EstimatedComputationPerMillisecond is the approximate number of computation units that can be performed in a millisecond. this was calibrated during the Variable Transaction Fees: Execution Effort FLIP https://github.com/onflow/flow/pull/753. Updated after the FLIP: https://github.com/onflow/flips/blob/14c5ec4/governance/20240508-computation-limit-hike.md#flip-267-increasing-the-transaction-computation-limit
const IdentifierLen = 32
const SlabIndexPrefix = '$'
const TransactionTagString = "FLOW-V0.0-transaction"
Variables ¶
var ( // CAUTION: Json and MsgPack are to be used only for trusted data sources ServiceEventJSONMarshaller = marshallerImpl{ // contains filtered or unexported fields } // CAUTION: Json and MsgPack are to be used only for trusted data sources ServiceEventMSGPACKMarshaller = marshallerImpl{ // contains filtered or unexported fields } ServiceEventCBORMarshaller = marshallerImpl{ // contains filtered or unexported fields } )
var AddressStateRegisterID = RegisterID{ Owner: "", Key: AddressStateKey, }
var DummyStateCommitment = StateCommitment(hash.DummyHash)
DummyStateCommitment is an arbitrary value used in function failure cases, although it can represent a valid state commitment.
var EmptyAddress = BytesToAddress(nil)
EmptyAddress is the default value of a variable of type Address
var ErrNoChunks = errors.New("execution result has no chunks")
GenesisTime defines the timestamp of the genesis block.
var TransactionDomainTag = paddedDomainTag(TransactionTagString)
TransactionDomainTag is the prefix of all signed transaction payloads.
The tag is the string `TransactionTagString` 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 AddressToRegisterOwner ¶ added in v0.33.30
AddressToRegisterOwner converts 8-byte address to register owner. If given address is ZeroAddress, register owner is "" (global register).
func ByReferenceOrder ¶ added in v0.33.1
func ByReferenceOrder(nodeIDs []Identifier) func(*Identity, *Identity) int
ByReferenceOrder return a function for sorting identities based on the order of the given nodeIDs
func Canonical ¶ added in v0.33.1
func Canonical[T GenericIdentity](identity1 *T, identity2 *T) int
Canonical is a function that defines a weak strict ordering "<" for identities. It returns:
- a strict negative number if id1 < id2
- a strict positive number if id2 < id1
- zero if id1 and id2 are equal
By definition, two identities (id1, id2) are in canonical order if id1's NodeID is lexicographically _strictly_ smaller than id2's NodeID. The strictness is important, meaning that identities with equal NodeIDs do not satisfy canonical ordering (order is irreflexive). Hence, only a returned strictly negative value means the pair is in canonical order. Use `IsCanonical` for canonical order checks.
The current function is based on the identifiers bytes lexicographic comparison.
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 ContractKey ¶ added in v0.33.30
func Deduplicate ¶ added in v0.33.19
func Deduplicate[T IDEntity](entities []T) []T
Deduplicate entities in a slice by the ID method The original order of the entities is preserved.
func EncodeAccountPrivateKey ¶
func EncodeAccountPrivateKey(a AccountPrivateKey) ([]byte, error)
func EncodeAccountPublicKey ¶
func EncodeAccountPublicKey(a AccountPublicKey) ([]byte, error)
func EncodeRuntimeAccountPublicKey ¶
func EncodeRuntimeAccountPublicKey(a AccountPublicKey) ([]byte, error)
func EncodeRuntimeAccountPublicKeys ¶ added in v0.27.0
func EncodeRuntimeAccountPublicKeys(keys []AccountPublicKey) ([]cadence.Value, error)
func IdToCid ¶ added in v0.25.0
func IdToCid(f Identifier) cid.Cid
func IdentifierCanonical ¶ added in v0.33.1
func IdentifierCanonical(id1 Identifier, id2 Identifier) int
IdentifierCanonical is a function that defines a weak strict ordering "<" for identifiers. It returns:
- a strict negative number if id1 < id2
- a strict positive number if id2 < id1
- zero if id1 and id2 are equal
By definition, two Identifiers (id1, id2) are in canonical order if id1 is lexicographically _strictly_ smaller than id2. The strictness is important, meaning that duplicates do not satisfy canonical ordering (order is irreflexive). Hence, only a returned strictly negative value means the pair is in canonical order. Use `IsIdentifierCanonical` for canonical order checks.
The current function is based on the identifiers bytes lexicographic comparison. Example:
IdentifierCanonical(Identifier{1}, Identifier{2}) // -1 IdentifierCanonical(Identifier{2}, Identifier{1}) // 1 IdentifierCanonical(Identifier{1}, Identifier{1}) // 0 IdentifierCanonical(Identifier{0, 1}, Identifier{0, 2}) // -1
func IdentityListEqualTo ¶ added in v0.33.30
func IdentityListEqualTo(lhs, rhs IdentityList) bool
IdentityListEqualTo checks if the other list if the same, that it contains the same elements in the same order. NOTE: currently a generic comparison is not possible, so we have to use a specific function.
func IdentitySkeletonListEqualTo ¶ added in v0.33.30
func IdentitySkeletonListEqualTo(lhs, rhs IdentitySkeletonList) bool
IdentitySkeletonListEqualTo checks if the other list if the same, that it contains the same elements in the same order. NOTE: currently a generic comparison is not possible, so we have to use a specific function.
func IdsToBytes ¶ added in v0.25.0
func IdsToBytes(identifiers []Identifier) [][]byte
func IsCanonical ¶ added in v0.33.1
func IsCanonical[T GenericIdentity](i1, i2 *T) bool
IsCanonical returns true if and only if the given Identities are in canonical order.
By convention, two Identities (i1, i2) are in canonical order if i1's NodeID bytes are lexicographically _strictly_ smaller than i2's NodeID bytes.
The strictness is important, meaning that two identities with the same NodeID do not satisfy the canonical order. This also implies that the canonical order is irreflexive ((i,i) isn't in canonical order).
func IsContractKey ¶ added in v0.33.30
func IsContractNamesRegisterID ¶ added in v0.33.30
func IsContractNamesRegisterID(registerID RegisterID) bool
func IsIdentifierCanonical ¶ added in v0.33.1
func IsIdentifierCanonical(i1, i2 Identifier) bool
IsIdentifierCanonical returns true if and only if the given identifiers are in canonical order.
By convention, two identifiers (i1, i2) are in canonical order if i1's bytes are lexicographically _strictly_ smaller than i2's bytes.
The strictness is important, meaning that the canonical order is irreflexive ((i,i) isn't in canonical order).
func IsIdentifierListCanonical ¶ added in v0.33.1
func IsIdentifierListCanonical(il IdentifierList) bool
IsIdentifierListCanonical returns true if and only if the given list is _strictly_ sorted with regards to the canonical order.
The strictness is important here, meaning that a list with 2 equal identifiers isn't considered well sorted.
func IsIdentityListCanonical ¶ added in v0.33.1
func IsIdentityListCanonical[T GenericIdentity](il GenericIdentityList[T]) bool
IsIdentityListCanonical returns true if and only if the given IdentityList is _strictly_ sorted with regards to the canonical order.
The strictness is important here, meaning that a list with 2 successive entities with equal NodeID isn't considered well sorted.
func IsInvalidSealingSegmentError ¶ added in v0.33.30
IsInvalidSealingSegmentError returns true if err is or wraps an instance of InvalidSealingSegmentError.
func IsSlabIndexKey ¶ added in v0.33.30
func KeyContractName ¶ added in v0.33.30
func NormalizedExecutionTimePerComputationUnit ¶ added in v0.33.30
func NormalizedExecutionTimePerComputationUnit(execTime time.Duration, computationUsed uint64) float64
NormalizedExecutionTimePerComputationUnit returns the normalized time per computation unit If the computation estimation is correct (as per the FLIP https://github.com/onflow/flow/pull/753) the value should be 1. If the value is greater than 1, the computation estimation is too low; we are underestimating transaction complexity (and thus undercharging). If the value is less than 1, the computation estimation is too high; we are overestimating transaction complexity (and thus overcharging).
func ToDKGParticipantLookup ¶ added in v0.17.0
func ToDKGParticipantLookup(participants IdentitySkeletonList, keys []crypto.PublicKey) (map[Identifier]DKGParticipant, error)
ToDKGParticipantLookup constructs a DKG participant lookup from an identity list and a key list. The identity list must be EXACTLY the same (order and contents) as that used when initializing the corresponding DKG instance. TODO(EFM, #6214): Once DKGIndexMap is populated we can remove this and use EpochCommit directly
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 uint32 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 uint32) (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 ConvertAddress ¶ added in v0.30.0
func ConvertAddress(b [AddressLength]byte) Address
func HexToAddress ¶
HexToAddress converts a hex string to an Address.
func StringToAddress ¶ added in v0.33.30
StringToAddress converts a string to an Address and return an error if the string is malformed
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 IdentifierList }
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) CardinalitySignerSet ¶ added in v0.19.0
func (a *AggregatedSignature) CardinalitySignerSet() int
CardinalitySignerSet returns the number of _distinct_ signer IDs in the AggregatedSignature. We explicitly de-duplicate here to prevent repetition attacks.
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
type AssignmentList ¶
type AssignmentList []IdentifierList
AssignmentList is a list of identifier lists. Each list of identifiers lists the identities that are part of the given cluster.
func (AssignmentList) EqualTo ¶ added in v0.19.0
func (al AssignmentList) EqualTo(other AssignmentList) bool
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 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 BlockDigest ¶ added in v0.33.30
type BlockDigest struct { Height uint64 Timestamp time.Time // contains filtered or unexported fields }
BlockDigest holds lightweight block information which includes only block id, block height and block timestamp
func NewBlockDigest ¶ added in v0.33.30
func NewBlockDigest( id Identifier, height uint64, timestamp time.Time, ) *BlockDigest
NewBlockDigest constructs a new block digest.
func (*BlockDigest) ID ¶ added in v0.33.30
func (b *BlockDigest) ID() Identifier
ID returns the id of the BlockDigest.
type BlockEvents ¶
type BlockEvents struct { BlockID Identifier BlockHeight uint64 BlockTimestamp time.Time Events []Event }
BlockEvents contains events emitted in a single block.
type BlockExecutionDataRoot ¶ added in v0.32.0
type BlockExecutionDataRoot struct { // BlockID is the ID of the block, whose result this execution data is for. BlockID Identifier // ChunkExecutionDataIDs is a list of the root CIDs for each serialized execution_data.ChunkExecutionData // associated with this block. ChunkExecutionDataIDs []cid.Cid }
BlockExecutionDataRoot represents the root of a serialized execution_data.BlockExecutionData. The hash of the serialized BlockExecutionDataRoot is the ExecutionDataID used within an flow.ExecutionResult. Context:
- The trie updates in BlockExecutionDataRoot contain the _mutated_ registers only, which is helpful for clients to truslessly replicate the state.
- In comparison, the chunk data packs contains all the register values at the chunk's starting state that were _touched_ (written and/or read). This is necessary for Verification Nodes to re-run the chunk the computation.
func (BlockExecutionDataRoot) MarshalMsgpack ¶ added in v0.33.36
func (b BlockExecutionDataRoot) MarshalMsgpack() ([]byte, error)
MarshalMsgpack implements the msgpack.Marshaler interface
func (*BlockExecutionDataRoot) UnmarshalMsgpack ¶ added in v0.33.36
func (b *BlockExecutionDataRoot) UnmarshalMsgpack(data []byte) error
UnmarshalMsgpack implements the msgpack.Unmarshaler interface
type BlockStatus ¶ added in v0.29.0
type BlockStatus int
BlockStatus represents the status of a block.
const ( // BlockStatusUnknown indicates that the block status is not known. BlockStatusUnknown BlockStatus = iota // BlockStatusFinalized is the status of a finalized block. BlockStatusFinalized // BlockStatusSealed is the status of a sealed block. BlockStatusSealed )
func (BlockStatus) String ¶ added in v0.29.0
func (s BlockStatus) String() string
String returns the string representation of a transaction status.
type CertifiedBlock ¶ added in v0.30.2
type CertifiedBlock struct { Block *Block CertifyingQC *QuorumCertificate }
CertifiedBlock holds a certified block, which is a block and a QC that is pointing to the block. A QC is the aggregated form of votes from a supermajority of HotStuff and therefore proves validity of the block. A certified block satisfies: Block.View == QC.View and Block.BlockID == QC.BlockID
func NewCertifiedBlock ¶ added in v0.30.2
func NewCertifiedBlock(block *Block, qc *QuorumCertificate) (CertifiedBlock, error)
NewCertifiedBlock constructs a new certified block. It checks the consistency requirements and errors otherwise:
Block.View == QC.View and Block.BlockID == QC.BlockID
func (*CertifiedBlock) Height ¶ added in v0.30.2
func (b *CertifiedBlock) Height() uint64
Height returns height of the block.
func (*CertifiedBlock) ID ¶ added in v0.30.2
func (b *CertifiedBlock) ID() Identifier
ID returns unique identifier for the block. To avoid repeated computation, we use value from the QC.
func (*CertifiedBlock) View ¶ added in v0.30.2
func (b *CertifiedBlock) View() uint64
View returns view where the block was produced.
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 ChainID() ChainID // 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 ( // Mainnet is the chain ID for the mainnet chain. Mainnet ChainID = "flow-mainnet" // Testnet is the chain ID for the testnet chain. Testnet ChainID = "flow-testnet" // Sandboxnet is the chain ID for internal sandboxnet chain. Sandboxnet ChainID = "flow-sandboxnet" // Previewet is the chain ID for an external preview chain. Previewnet ChainID = "flow-previewnet" // Benchnet is the chain ID for the transient benchmarking chain. Benchnet ChainID = "flow-benchnet" // Localnet is the chain ID for the local development chain. Localnet ChainID = "flow-localnet" // Emulator is the chain ID for the emulated chain. Emulator ChainID = "flow-emulator" // BftTestnet is the chain ID for testing attack vector scenarios. BftTestnet ChainID = "flow-bft-test-net" // MonotonicEmulator is the chain ID for the emulated node chain with monotonic address generation. MonotonicEmulator ChainID = "flow-emulator-monotonic" )
type ChainIDList ¶ added in v0.31.0
type ChainIDList []ChainID
func AllChainIDs ¶ added in v0.33.1
func AllChainIDs() ChainIDList
AllChainIDs returns a list of all supported chain IDs.
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 NewChunk ¶ added in v0.30.0
func NewChunk( blockID Identifier, collectionIndex int, startState StateCommitment, numberOfTransactions int, eventCollection Identifier, endState StateCommitment, totalComputationUsed uint64, ) *Chunk
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 // ID of the chunk this data pack is for StartState StateCommitment // commitment for starting state Proof StorageProof // proof for all registers touched (read or written) during the chunk execution Collection *Collection // collection executed in this chunk // ExecutionDataRoot is the root data structure of an execution_data.BlockExecutionData. // It contains the necessary information for a verification node to validate that the // BlockExecutionData produced is valid. ExecutionDataRoot BlockExecutionDataRoot }
ChunkDataPack holds all register touches (any read, or write).
Note that we have to include merkle paths as storage proof for all registers touched (read or written) for the _starting_ state of the chunk (i.e. before the chunk computation updates the registers). For instance, if an execution state contains three registers: { A: 1, B: 2, C: 3}, and a certain chunk has a tx that assigns A = A + B, then its chunk data pack should include the merkle paths for { A: 1, B: 2 } as storage proof. C is not included because it's neither read or written by the chunk. B is included because it's read by the chunk. A is included because it's updated by the chunk, and its value 1 is included because it's the value before the chunk computation. This is necessary for Verification Nodes to (i) check that the read register values are consistent with the starting state's root hash and (ii) verify the correctness of the resulting state after the chunk computation. `Proof` includes merkle proofs for all touched registers during the execution of the chunk. Register proofs order must not be correlated to the order of register reads during the chunk execution in order to enforce the SPoCK secret high entropy.
func NewChunkDataPack ¶ added in v0.30.0
func NewChunkDataPack( chunkID Identifier, startState StateCommitment, proof StorageProof, collection *Collection, execDataRoot BlockExecutionDataRoot, ) *ChunkDataPack
NewChunkDataPack returns an initialized chunk data pack.
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
TODO: This is the basic version of the list, we need to substitute it with something like Merkle 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
type ClusterList ¶
type ClusterList []IdentitySkeletonList
ClusterList is a list of identity lists. Each `IdentityList` represents the nodes assigned to a specific cluster.
func NewClusterList ¶
func NewClusterList(assignments AssignmentList, collectors IdentitySkeletonList) (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 (cl ClusterList) Assignments() AssignmentList
Assignments returns the assignment list for a cluster.
func (ClusterList) ByIndex ¶
func (cl ClusterList) ByIndex(index uint) (IdentitySkeletonList, bool)
ByIndex retrieves the list of identities that are part of the given cluster.
func (ClusterList) ByNodeID ¶
func (cl ClusterList) ByNodeID(nodeID Identifier) (IdentitySkeletonList, 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) (IdentitySkeletonList, 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 IdentitySkeletonList) (uint, bool)
IndexOf returns the index of the given cluster.
type ClusterQCVoteData ¶ added in v0.17.1
type ClusterQCVoteData struct { SigData crypto.Signature // the aggregated signature over all the votes VoterIDs []Identifier // the set of voters that contributed to the qc }
ClusterQCVoteData represents the votes for a cluster quorum certificate, as gathered by the ClusterQC smart contract. It contains the aggregated signature over the root block for the cluster as well as the set of voters.
func ClusterQCVoteDataFromQC ¶ added in v0.17.1
func ClusterQCVoteDataFromQC(qc *QuorumCertificateWithSignerIDs) ClusterQCVoteData
ClusterQCVoteDataFromQC converts a quorum certificate to the representation used by the smart contract, essentially discarding the block ID and view (which are protocol-defined given the EpochSetup event).
func ClusterQCVoteDatasFromQCs ¶ added in v0.17.1
func ClusterQCVoteDatasFromQCs(qcs []*QuorumCertificateWithSignerIDs) []ClusterQCVoteData
func (*ClusterQCVoteData) EqualTo ¶ added in v0.19.0
func (c *ClusterQCVoteData) EqualTo(other *ClusterQCVoteData) bool
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 ChainID ChainID // the chainID of the cluster in order to determine which cluster this guarantee belongs to SignerIndices []byte // encoded indices of the signers 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) Fingerprint ¶
func (cl *CollectionList) Fingerprint() Identifier
func (*CollectionList) Insert ¶
func (cl *CollectionList) Insert(ch *Collection)
func (*CollectionList) Items ¶
func (cl *CollectionList) Items() []*Collection
type DKGEndState ¶ added in v0.23.9
type DKGEndState uint32
DKGEndState captures the final state of a completed DKG.
const ( // DKGEndStateUnknown - zero value for this enum, indicates unset value DKGEndStateUnknown DKGEndState = iota // DKGEndStateSuccess - the DKG completed, this node has a valid beacon key. DKGEndStateSuccess // DKGEndStateInconsistentKey - the DKG completed, this node has an invalid beacon key. DKGEndStateInconsistentKey // DKGEndStateNoKey - this node did not store a key, typically caused by a crash mid-DKG. DKGEndStateNoKey // DKGEndStateDKGFailure - the underlying DKG library reported an error. DKGEndStateDKGFailure )
func (DKGEndState) String ¶ added in v0.23.9
func (state DKGEndState) String() string
type DKGParticipant ¶
type DKGParticipant struct { Index uint }
func (DKGParticipant) MarshalCBOR ¶ added in v0.21.0
func (part DKGParticipant) MarshalCBOR() ([]byte, error)
func (DKGParticipant) MarshalJSON ¶
func (part DKGParticipant) MarshalJSON() ([]byte, error)
func (DKGParticipant) MarshalMsgpack ¶
func (part DKGParticipant) MarshalMsgpack() ([]byte, error)
func (*DKGParticipant) UnmarshalCBOR ¶ added in v0.21.0
func (part *DKGParticipant) UnmarshalCBOR(b []byte) error
func (*DKGParticipant) UnmarshalJSON ¶
func (part *DKGParticipant) UnmarshalJSON(b []byte) error
func (*DKGParticipant) UnmarshalMsgpack ¶
func (part *DKGParticipant) UnmarshalMsgpack(b []byte) error
type DynamicIdentity ¶ added in v0.33.30
type DynamicIdentity struct {
EpochParticipationStatus
}
DynamicIdentity represents the dynamic part of public identity of one network participant (node).
func (*DynamicIdentity) EqualTo ¶ added in v0.33.30
func (iy *DynamicIdentity) EqualTo(other *DynamicIdentity) bool
func (*DynamicIdentity) IsEjected ¶ added in v0.33.30
func (iy *DynamicIdentity) IsEjected() bool
IsEjected returns true if the node is ejected from the network.
type DynamicIdentityEntry ¶ added in v0.33.30
type DynamicIdentityEntry struct { NodeID Identifier Ejected bool }
DynamicIdentityEntry encapsulates nodeID and dynamic portion of identity.
type DynamicIdentityEntryList ¶ added in v0.33.30
type DynamicIdentityEntryList []*DynamicIdentityEntry
func DynamicIdentityEntryListFromIdentities ¶ added in v0.33.30
func DynamicIdentityEntryListFromIdentities(identities IdentityList) DynamicIdentityEntryList
DynamicIdentityEntryListFromIdentities converts IdentityList to DynamicIdentityEntryList.
func (DynamicIdentityEntryList) ByNodeID ¶ added in v0.33.30
func (ll DynamicIdentityEntryList) ByNodeID(nodeID Identifier) (*DynamicIdentityEntry, bool)
ByNodeID gets a node from the list by node ID.
func (DynamicIdentityEntryList) Copy ¶ added in v0.33.30
func (ll DynamicIdentityEntryList) Copy() DynamicIdentityEntryList
Copy returns a copy of the DynamicIdentityEntryList. 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.
CAUTION: All Identity fields are deep-copied, _except_ for their keys, which are copied by reference.
func (DynamicIdentityEntryList) Lookup ¶ added in v0.33.30
func (ll DynamicIdentityEntryList) Lookup() map[Identifier]*DynamicIdentityEntry
func (DynamicIdentityEntryList) Sort ¶ added in v0.33.30
func (ll DynamicIdentityEntryList) Sort(less IdentifierOrder) DynamicIdentityEntryList
Sort sorts the list by the input ordering. Returns a new, sorted list without modifying the input. CAUTION: All Identity fields are deep-copied, _except_ for their keys, which are copied by reference.
func (DynamicIdentityEntryList) Sorted ¶ added in v0.33.30
func (ll DynamicIdentityEntryList) Sorted(less IdentifierOrder) bool
Sorted returns whether the list is sorted by the input ordering.
type Entity ¶
type Entity interface { IDEntity // 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 include nested entities, they only include pointers to other entities. For example, they keep a slice of entity commits instead of keeping a slice of entity object itself. This simplifies storage, signature and validation of entities.
type EpochCommit ¶
type EpochCommit struct { // Counter is the epoch counter of the epoch being committed Counter uint64 // ClusterQCs is an ordered list of root quorum certificates, one per cluster. // EpochCommit.ClustersQCs[i] is the QC for EpochSetup.Assignments[i] ClusterQCs []ClusterQCVoteData // DKGGroupKey is the group public key produced by the DKG associated with this epoch. // It is used to verify Random Beacon signatures for the epoch with counter, Counter. DKGGroupKey crypto.PublicKey // DKGParticipantKeys is a list of public keys, one per DKG participant, ordered by Random Beacon index. // This list is the output of the DKG associated with this epoch. // It is used to verify Random Beacon signatures for the epoch with counter, Counter. // CAUTION: This list may include keys for nodes which do not exist in the consensus committee // and may NOT include keys for all nodes in the consensus committee. DKGParticipantKeys []crypto.PublicKey // DKGIndexMap is always nil and is not used. This field exists to avoid data-model changes in a future version. // Deprecated: This field is always nil and should not be used (it isn't really deprecated -- "pre-un-deprecated", maybe -- // but marking it as such makes Go tooling flag it in a way that is useful for this circumstance) // // TODO(EFM, #6214): Parse this field from service event and make use of it. // Here is what the godoc should look like once we do that: // DKGIndexMap is a mapping from node identifier to Random Beacon index. // It has the following invariants: // - len(DKGParticipantKeys) == len(DKGIndexMap) // - DKGIndexMap values form the set {0, 1, ..., n-1} where n=len(DKGParticipantKeys) // CAUTION: This mapping may include identifiers for nodes which do not exist in the consensus committee // and may NOT include identifiers for all nodes in the consensus committee. // DKGIndexMap map[Identifier]int }
EpochCommit is a service event emitted when the preparation process for the next epoch is complete. EpochCommit events must:
- be emitted exactly once per epoch after the corresponding EpochSetup event
- be emitted prior to the epoch commitment deadline (defined by EpochCommitSafetyThreshold)
If either of the above constraints are not met, the service event will be rejected and Epoch Fallback Mode [EFM] will be triggered.
When an EpochCommit event is accepted and incorporated into the Protocol State, this guarantees that the network will proceed through that epoch's defined view range with its defined committee. It also causes the current epoch to enter the EpochPhaseCommitted phase.
TERMINOLOGY NOTE: In the context of the Epoch Preparation Protocol and the EpochCommit event, artifacts produced by the DKG are referred to with the "DKG" prefix (for example, DKGGroupKey). These artifacts are *produced by* the DKG, but used for the Random Beacon. As such, other components refer to these same artifacts with the "RandomBeacon" prefix.
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. NOTE: DecodeRLP is not needed, as this is only used for hashing.
func (*EpochCommit) EqualTo ¶ added in v0.19.0
func (commit *EpochCommit) EqualTo(other *EpochCommit) bool
func (*EpochCommit) ID ¶
func (commit *EpochCommit) ID() Identifier
ID returns the hash of the event contents.
func (*EpochCommit) MarshalCBOR ¶ added in v0.21.0
func (commit *EpochCommit) MarshalCBOR() ([]byte, error)
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) UnmarshalCBOR ¶ added in v0.21.0
func (commit *EpochCommit) UnmarshalCBOR(b []byte) error
func (*EpochCommit) UnmarshalJSON ¶
func (commit *EpochCommit) UnmarshalJSON(b []byte) error
func (*EpochCommit) UnmarshalMsgpack ¶
func (commit *EpochCommit) UnmarshalMsgpack(b []byte) error
type EpochExtension ¶ added in v0.37.1
EpochExtension represents a range of views, which contiguously extends this epoch.
type EpochParticipationStatus ¶ added in v0.33.30
type EpochParticipationStatus int
EpochParticipationStatus represents the status of a node's participation. Depending on what changes were applied to the protocol state, a node may be in one of four states: / - joining - the node is not active in the current epoch and will be active in the next epoch. / - active - the node was included in the EpochSetup event for the current epoch and is actively participating in the current epoch. / - leaving - the node was active in the previous epoch but is not active in the current epoch. / - ejected - the node has been permanently removed from the network.
/ EpochSetup / ┌────────────⬤ unregistered ◯◄───────────┐ / ┌─────▼─────┐ ┌───────────┐ ┌─────┴─────┐ / │ JOINING ├───────►│ ACTIVE ├───────►│ LEAVING │ / └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ / │ ┌─────▼─────┐ │ / └─────────────►│ EJECTED │◄─────────────┘ / └───────────┘
Only active nodes are allowed to perform certain tasks relative to other nodes. Nodes which are registered to join at the next epoch will appear in the identity table but aren't considered active until their first epoch begins. Likewise, nodes which were registered in the previous epoch but have left at the most recent epoch boundary will appear in the identity table with leaving participation status. A node may be ejected by either:
- requesting self-ejection to protect its stake in case the node operator suspects the node's keys to be compromised
- committing a serious protocol violation or multiple smaller misdemeanours.
const ( EpochParticipationStatusJoining EpochParticipationStatus = iota EpochParticipationStatusActive EpochParticipationStatusLeaving EpochParticipationStatusEjected )
func ParseEpochParticipationStatus ¶ added in v0.33.30
func ParseEpochParticipationStatus(s string) (EpochParticipationStatus, error)
ParseEpochParticipationStatus converts string representation of EpochParticipationStatus into a typed value. An exception will be returned if failed to convert.
func (EpochParticipationStatus) EncodeRLP ¶ added in v0.33.30
func (s EpochParticipationStatus) EncodeRLP(w io.Writer) error
EncodeRLP performs RLP encoding of custom type, it's need to be able to hash structures that include EpochParticipationStatus. No errors are expected during normal operations.
func (EpochParticipationStatus) String ¶ added in v0.33.30
func (s EpochParticipationStatus) String() string
String returns string representation of enum value.
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. During normal operations, each Epoch transitions through the phases:
║ Epoch N ║ ╭─────────────────────────────────┴─────────────────────────────────╮ ║ finalize view EpochSetup EpochCommit ║ in epoch N service event service event ║ ⇣ ⇣ ⇣ ║ ┌─────────────────┐ ┌───────────────┐ ┌───────────────────┐ ║ │EpochPhaseStaking├─────►EpochPhaseSetup├─────►EpochPhaseCommitted├ ┄> ║ └─────────────────┘ └───────────────┘ └───────────────────┘ ║ ⇣ ⇣ ⇣ ║ EpochTransition EpochSetupPhaseStarted EpochCommittedPhaseStarted ║ Notification Notification Notification
However, if the Protocol State encounters any unexpected epoch service events, or the subsequent epoch fails to be committed by the `EpochCommitSafetyThreshold`, then we enter Epoch Fallback Mode [EFM]. Depending on whether the subsequent epoch has already been committed, the EFM progress differs slightly. In a nutshell, we always enter the _latest_ epoch already committed on the happy path (if there is any) and then follow the fallback protocol.
SCENARIO A: the future Epoch N is already committed, when we enter EFM
║ Epoch N-1 Epoch N ║ ···──┴─────────────────────────╮ ╭─────────────┴───────────────────────────────────────────────╮ ║ invalid service finalize view EpochRecover ║ event in epoch N service event ║ ⇣ ⇣ ┊ ⇣ ║ ┌──────────────────────────┐ ┌────────────────────┊────┐ ┌───────────────────────────┐ ║ │ EpochPhaseCommitted ├────► EpochPhaseFallback ├─────► EpochPhaseCommitted ├ ┄> ║ └──────────────────────────┘ └────────────────────┊────┘ └───────────────────────────┘ ║ ⇣ ⇣ ┊ ⇣ ║ EpochFallbackModeTriggered EpochTransition EpochExtended* EpochFallbackModeExited ║ Notification Notification Notification + EpochCommittedPhaseStarted Notifications ║ ┆ ┆ ║ ╰┄┄┄┄┄┄┄┄┄┄ EpochFallbackTriggered is true ┄┄┄┄┄┄┄┄┄┄┄┄╯
With 'EpochExtended*' we denote that there can be zero, one, or more Epoch Extension (depending on when we receive a valid EpochRecover service event.
SCENARIO B: we are in Epoch N without any subsequent epoch being committed when entering EFM
║ Epoch N ║ ···────────────────────────┴───────────────────────────────────────────────────────────────╮ ║ invalid service event or EpochRecover ║ EpochCommitSafetyThreshold reached service event ║ ⇣ ┊ ⇣ ║ ┌────────────────────┐ ┌──────────────────────┊──────┐ ┌───────────────────────────┐ ║ │ EpochPhaseStaking │ │ EpochPhaseFallback │ │ EpochPhaseCommitted │ ║ │ or EpochPhaseSetup ├───► ┊ ├─────► ├ ┄> ║ └────────────────────┘ └──────────────────────┊──────┘ └───────────────────────────┘ ║ ⇣ ┊ ⇣ ║ EpochFallbackModeTriggered EpochExtended* EpochFallbackModeExited ║ Notification Notification + EpochCommittedPhaseStarted Notifications ║ ┆ ┆ ║ ╰┄┄ EpochFallbackTriggered true ┄┄┄┄╯
A state machine diagram containing all possible phase transitions is below:
┌──────────────────────────────────────────────────────────┐ ┌────────▼────────┐ ┌───────────────┐ ┌───────────────────┐ │ │EpochPhaseStaking├─────►EpochPhaseSetup├─────►EpochPhaseCommitted├─┘ └────────┬────────┘ └───────────┬───┘ └───┬──────────▲────┘ │ ┌─▼─────────────▼──┐ │ └────────────────────────►EpochPhaseFallback├───────┘ └──────────────────┘
const ( EpochPhaseUndefined EpochPhase = iota EpochPhaseStaking EpochPhaseSetup EpochPhaseCommitted EpochPhaseFallback )
func GetEpochPhase ¶ added in v0.23.9
func GetEpochPhase(phase string) EpochPhase
func (EpochPhase) String ¶
func (p EpochPhase) String() string
type EpochRecover ¶ added in v0.37.1
type EpochRecover struct { EpochSetup EpochCommit }
EpochRecover service event is emitted when network is in Epoch Fallback Mode(EFM) in an attempt to return to happy path. It contains data from EpochSetup, and EpochCommit events to so replicas can create a committed epoch from which they can continue operating on the happy path.
func (*EpochRecover) EqualTo ¶ added in v0.37.1
func (er *EpochRecover) EqualTo(other *EpochRecover) bool
func (*EpochRecover) ID ¶ added in v0.37.1
func (er *EpochRecover) ID() Identifier
ID returns the hash of the event contents.
func (*EpochRecover) ServiceEvent ¶ added in v0.37.1
func (er *EpochRecover) ServiceEvent() ServiceEvent
type EpochSetup ¶
type EpochSetup struct { Counter uint64 // the number of the epoch being setup (current+1) FirstView uint64 // the first view of the epoch being setup DKGPhase1FinalView uint64 // the final view of DKG phase 1 DKGPhase2FinalView uint64 // the final view of DKG phase 2 DKGPhase3FinalView uint64 // the final view of DKG phase 3 FinalView uint64 // the final view of the epoch Participants IdentitySkeletonList // all participants of the epoch in canonical order Assignments AssignmentList // cluster assignment for the epoch RandomSource []byte // source of randomness for epoch-specific setup tasks TargetDuration uint64 // desired real-world duration for the epoch [seconds] TargetEndTime uint64 // desired real-world end time for the epoch in UNIX time [seconds] }
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. EpochSetup is a service event emitted when the preparation process for the next epoch begins. EpochSetup events must:
- be emitted exactly once per epoch before the corresponding EpochCommit event
- be emitted prior to the epoch commitment deadline (defined by EpochCommitSafetyThreshold)
If either of the above constraints are not met, the service event will be rejected and Epoch Fallback Mode [EFM] will be triggered.
When an EpochSetup event is accepted and incorporated into the Protocol State, this triggers the Distributed Key Generation [DKG] and cluster QC voting process for the next epoch. It also causes the current epoch to enter the EpochPhaseSetup phase.
func (*EpochSetup) EqualTo ¶ added in v0.19.0
func (setup *EpochSetup) EqualTo(other *EpochSetup) bool
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 EpochStateContainer ¶ added in v0.33.30
type EpochStateContainer struct { // ID of setup event for this epoch, never nil. SetupID Identifier // ID of commit event for this epoch. Could be ZeroID if epoch was not committed. CommitID Identifier // ActiveIdentities contains the dynamic identity properties for the nodes that // are active in this epoch. Active means that these nodes are authorized to contribute to // extending the chain. Nodes are listed in `ActiveIdentities` if and only if // they are part of the EpochSetup event for the respective epoch. // The dynamic identity properties can change from block to block. Each non-deferred // identity-mutating operation is applied independently to the `ActiveIdentities` // of the relevant epoch's EpochStateContainer separately. // Identities are always sorted in canonical order. // // Context: In comparison, nodes that are joining in the next epoch or left as of this // epoch are only allowed to listen to the network but not actively contribute. Such // nodes are _not_ part of `Identities`. ActiveIdentities DynamicIdentityEntryList // EpochExtensions contains potential EFM-extensions of this epoch. In the happy path // it is nil or empty. An Epoch in which Epoch-Fallback-Mode [EFM] is triggered, will // have at least one extension. By convention, the initial extension must satisfy // EpochSetup.FinalView + 1 = EpochExtensions[0].FirstView // and each consecutive pair of slice elements must obey // EpochExtensions[i].FinalView+1 = EpochExtensions[i+1].FirstView EpochExtensions []EpochExtension }
EpochStateContainer holds the data pertaining to a _single_ epoch but no information about any adjacent epochs. To perform a transition from epoch N to N+1, EpochStateContainers for both epochs are necessary.
func (*EpochStateContainer) Copy ¶ added in v0.33.30
func (c *EpochStateContainer) Copy() *EpochStateContainer
Copy returns a full copy of the entry. Embedded Identities are deep-copied, _except_ for their keys, which are copied by reference. Per convention, the ID of a `nil` EpochStateContainer is `flow.ZeroID`.
func (*EpochStateContainer) EventIDs ¶ added in v0.33.30
func (c *EpochStateContainer) EventIDs() EventIDs
EventIDs returns the `flow.EventIDs` with the hashes of the EpochSetup and EpochCommit events. Per convention, for a `nil` EpochStateContainer, we return `flow.ZeroID` for both events.
func (*EpochStateContainer) ID ¶ added in v0.33.30
func (c *EpochStateContainer) ID() Identifier
ID returns an identifier for this EpochStateContainer by hashing internal fields. Per convention, the ID of a `nil` EpochStateContainer is `flow.ZeroID`.
type EpochStateEntry ¶ added in v0.37.1
type EpochStateEntry struct { *MinEpochStateEntry // by convention, all epoch service events are immutable PreviousEpochSetup *EpochSetup PreviousEpochCommit *EpochCommit CurrentEpochSetup *EpochSetup CurrentEpochCommit *EpochCommit NextEpochSetup *EpochSetup NextEpochCommit *EpochCommit }
EpochStateEntry is a MinEpochStateEntry that has additional fields that are cached from the storage layer for convenience. It holds all the information needed to construct a snapshot of the identity table (set of all notes authorized to be part of the network) at some specific block without any database queries. Specifically, `MinEpochStateEntry` is a snapshot of the variable portion of the identity table. The portion of the identity table that is constant throughout an epoch is contained in the Epoch Setup and Epoch Commit events. Convention:
- CurrentEpochSetup and CurrentEpochCommit are for the same epoch. Never nil.
- PreviousEpochSetup and PreviousEpochCommit are for the same epoch. Can be nil.
- NextEpochSetup and NextEpochCommit are for the same epoch. Can be nil.
func NewEpochStateEntry ¶ added in v0.37.1
func NewEpochStateEntry( epochState *MinEpochStateEntry, previousEpochSetup *EpochSetup, previousEpochCommit *EpochCommit, currentEpochSetup *EpochSetup, currentEpochCommit *EpochCommit, nextEpochSetup *EpochSetup, nextEpochCommit *EpochCommit, ) (*EpochStateEntry, error)
NewEpochStateEntry constructs a EpochStateEntry from an MinEpochStateEntry and additional data. No errors are expected during normal operation. All errors indicate inconsistent or invalid inputs.
func (*EpochStateEntry) Copy ¶ added in v0.37.1
func (e *EpochStateEntry) Copy() *EpochStateEntry
Copy returns a full copy of the EpochStateEntry.
- Embedded service events are copied by reference (not deep-copied).
func (*EpochStateEntry) CurrentEpochFinalView ¶ added in v0.37.1
func (e *EpochStateEntry) CurrentEpochFinalView() uint64
CurrentEpochFinalView returns the final view of the current epoch, taking into account possible epoch extensions. If there are no epoch extensions, the final view is the final view of the current epoch setup, otherwise it is the final view of the last epoch extension.
func (*EpochStateEntry) EpochCounter ¶ added in v0.37.1
func (e *EpochStateEntry) EpochCounter() uint64
EpochCounter returns the current epoch counter. The receiver RichEpochStateEntry must be properly constructed.
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) Checksum ¶ added in v0.21.0
func (e Event) Checksum() Identifier
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.
func (*EventIDs) ID ¶ added in v0.33.30
func (e *EventIDs) ID() Identifier
ID returns hash of the event IDs.
type EventsList ¶ added in v0.19.0
type EventsList []Event
func (EventsList) ByteSize ¶ added in v0.28.7
func (el EventsList) ByteSize() int
byteSize returns an approximate number of bytes needed to store the wrapped version of the event.
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 Spocks []crypto.Signature ExecutorSignature crypto.Signature }
ExecutionReceipt is the full execution receipt, as sent by the Execution Node. Specifically, it contains the detailed execution result.
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 fields from the Execution Receipts that vary from one executor to another (assuming they commit to the same result). It only contains the ID (cryptographic hash) of the execution result the receipt commits to. The ExecutionReceiptMeta is useful for storing results and receipts separately in a composable way.
func (*ExecutionReceiptMeta) Checksum ¶ added in v0.16.0
func (er *ExecutionReceiptMeta) Checksum() Identifier
Checksum returns a checksum for the execution receipt including the signatures.
func (*ExecutionReceiptMeta) ID ¶ added in v0.16.0
func (er *ExecutionReceiptMeta) ID() Identifier
ID returns the canonical ID of the execution receipt. It is identical to the ID of the full receipt.
func (ExecutionReceiptMeta) MarshalJSON ¶ added in v0.23.2
func (er ExecutionReceiptMeta) MarshalJSON() ([]byte, error)
type ExecutionReceiptMetaGroupedList ¶ added in v0.16.1
type ExecutionReceiptMetaGroupedList map[Identifier]ExecutionReceiptMetaList
ExecutionReceiptMetaGroupedList is a partition of an ExecutionReceiptMetaList
func (ExecutionReceiptMetaGroupedList) GetGroup ¶ added in v0.16.1
func (g ExecutionReceiptMetaGroupedList) GetGroup(groupID Identifier) ExecutionReceiptMetaList
GetGroup returns the receipts that were mapped to the same identifier by the grouping function. Returns an empty (nil) ExecutionReceiptMetaList if groupID does not exist.
func (ExecutionReceiptMetaGroupedList) NumberGroups ¶ added in v0.16.1
func (g ExecutionReceiptMetaGroupedList) NumberGroups() int
NumberGroups returns the number of groups
type ExecutionReceiptMetaGroupingFunction ¶ added in v0.16.1
type ExecutionReceiptMetaGroupingFunction func(*ExecutionReceiptMeta) Identifier
ExecutionReceiptMetaGroupingFunction is a function that assigns an identifier to each receipt meta
type ExecutionReceiptMetaList ¶ added in v0.16.1
type ExecutionReceiptMetaList []*ExecutionReceiptMeta
ExecutionReceiptMetaList is a slice of ExecutionResultMetas with the additional functionality to group them by various properties
func (ExecutionReceiptMetaList) GroupBy ¶ added in v0.16.1
func (l ExecutionReceiptMetaList) GroupBy(grouper ExecutionReceiptMetaGroupingFunction) ExecutionReceiptMetaGroupedList
GroupBy partitions the ExecutionReceiptMetaList. 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 (ExecutionReceiptMetaList) GroupByExecutorID ¶ added in v0.16.1
func (l ExecutionReceiptMetaList) GroupByExecutorID() ExecutionReceiptMetaGroupedList
GroupByExecutorID partitions the ExecutionReceiptMetaList by the receipts' ExecutorIDs. Within each group, the order and multiplicity of the receipts is preserved.
func (ExecutionReceiptMetaList) GroupByResultID ¶ added in v0.16.1
func (l ExecutionReceiptMetaList) GroupByResultID() ExecutionReceiptMetaGroupedList
GroupByResultID partitions the ExecutionReceiptMetaList by the receipts' Result IDs. Within each group, the order and multiplicity of the receipts is preserved.
func (ExecutionReceiptMetaList) Lookup ¶ added in v0.16.1
func (l ExecutionReceiptMetaList) Lookup() map[Identifier]*ExecutionReceiptMeta
Lookup generates a map from ExecutionReceipt ID to ExecutionReceiptMeta
func (ExecutionReceiptMetaList) Size ¶ added in v0.16.1
func (l ExecutionReceiptMetaList) Size() int
Size returns the number of receipts in the list
type ExecutionResult ¶
type ExecutionResult struct { PreviousResultID Identifier // commit of the previous ER BlockID Identifier // commit of the current block Chunks ChunkList ServiceEvents ServiceEventList ExecutionDataID Identifier // hash commitment to flow.BlockExecutionDataRoot }
ExecutionResult is cryptographic commitment to the computation result(s) from executing a block
func NewExecutionResult ¶ added in v0.30.0
func NewExecutionResult( previousResultID Identifier, blockID Identifier, chunks ChunkList, serviceEvents ServiceEventList, executionDataID Identifier, ) *ExecutionResult
func (ExecutionResult) FinalStateCommitment ¶ added in v0.11.0
func (er ExecutionResult) FinalStateCommitment() (StateCommitment, error)
FinalStateCommitment returns the Execution Result's commitment to the final execution state of the block, i.e. the last chunk's output state.
This function is side-effect free. The only possible error it returns is of type:
- ErrNoChunks: if there are no chunks (ExecutionResult is malformed)
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, error)
InitialStateCommit returns a commitment to the execution state used as input for computing the block, i.e. the leading chunk's input state.
This function is side-effect free. The only possible error it returns is of type
- ErrNoChunks: if there are no chunks (ExecutionResult is malformed)
func (ExecutionResult) MarshalJSON ¶ added in v0.23.2
func (er ExecutionResult) MarshalJSON() ([]byte, error)
func (ExecutionResult) ValidateChunksLength ¶ added in v0.17.0
func (er ExecutionResult) ValidateChunksLength() bool
ValidateChunksLength checks whether the number of chuncks is zero.
It returns false if the number of chunks is zero (invalid). By protocol definition, each ExecutionReceipt must contain at least one chunk (system chunk).
type ExecutionResultGroupedList ¶ added in v0.16.1
type ExecutionResultGroupedList map[Identifier]ExecutionResultList
ExecutionResultGroupedList is a partition of an ExecutionResultList
func (ExecutionResultGroupedList) GetGroup ¶ added in v0.16.1
func (g ExecutionResultGroupedList) GetGroup(groupID Identifier) ExecutionResultList
GetGroup returns the ExecutionResults that were mapped to the same identifier by the grouping function. Returns an empty (nil) ExecutionResultList if groupID does not exist.
func (ExecutionResultGroupedList) NumberGroups ¶ added in v0.16.1
func (g ExecutionResultGroupedList) NumberGroups() int
NumberGroups returns the number of groups
type ExecutionResultGroupingFunction ¶ added in v0.16.1
type ExecutionResultGroupingFunction func(*ExecutionResult) Identifier
ExecutionResultGroupingFunction is a function that assigns an identifier to each ExecutionResult
type ExecutionResultList ¶ added in v0.16.1
type ExecutionResultList []*ExecutionResult
ExecutionResultList is a slice of ExecutionResults with the additional functionality to group them by various properties
func (ExecutionResultList) GroupBy ¶ added in v0.16.1
func (l ExecutionResultList) GroupBy(grouper ExecutionResultGroupingFunction) ExecutionResultGroupedList
GroupBy partitions the ExecutionResultList. All ExecutionResults 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 ExecutionResults is preserved.
func (ExecutionResultList) GroupByExecutedBlockID ¶ added in v0.16.1
func (l ExecutionResultList) GroupByExecutedBlockID() ExecutionResultGroupedList
GroupByExecutedBlockID partitions the ExecutionResultList by the IDs of the executed blocks. Within each group, the order and multiplicity of the ExecutionResults is preserved.
func (ExecutionResultList) GroupByPreviousResultID ¶ added in v0.16.1
func (l ExecutionResultList) GroupByPreviousResultID() ExecutionResultGroupedList
GroupByPreviousResultID partitions the ExecutionResultList by the their PreviousResultIDs. Within each group, the order and multiplicity of the ExecutionResults is preserved.
func (ExecutionResultList) Lookup ¶ added in v0.16.1
func (l ExecutionResultList) Lookup() map[Identifier]*ExecutionResult
Lookup generates a map from ExecutionResult ID to ExecutionResult
func (ExecutionResultList) Size ¶ added in v0.16.1
func (l ExecutionResultList) Size() int
Size returns the number of ExecutionResults in the list
type GenericIdentity ¶ added in v0.33.30
type GenericIdentity interface { Identity | IdentitySkeleton GetNodeID() Identifier GetRole() Role GetStakingPubKey() crypto.PublicKey GetNetworkPubKey() crypto.PublicKey GetInitialWeight() uint64 GetSkeleton() IdentitySkeleton }
GenericIdentity defines a constraint for generic identities. Golang doesn't support constraint with fields(for time being) so we have to define this interface with getter methods. Details here: https://github.com/golang/go/issues/51259.
type GenericIdentityList ¶ added in v0.33.30
type GenericIdentityList[T GenericIdentity] []*T
func (GenericIdentityList[T]) ByIndex ¶ added in v0.33.30
func (il GenericIdentityList[T]) ByIndex(index uint) (*T, bool)
ByIndex returns the node at the given index.
func (GenericIdentityList[T]) ByNetworkingKey ¶ added in v0.33.30
func (il GenericIdentityList[T]) ByNetworkingKey(key crypto.PublicKey) (*T, bool)
ByNetworkingKey gets a node from the list by network public key.
func (GenericIdentityList[T]) ByNodeID ¶ added in v0.33.30
func (il GenericIdentityList[T]) ByNodeID(nodeID Identifier) (*T, bool)
ByNodeID gets a node from the list by node ID.
func (GenericIdentityList[T]) Checksum ¶ added in v0.33.30
func (il GenericIdentityList[T]) Checksum() Identifier
Checksum generates a cryptographic commitment to the full IdentityList, including mutable fields. The checksum for the same group of identities (by NodeID) may change from block to block.
func (GenericIdentityList[T]) Copy ¶ added in v0.33.30
func (il GenericIdentityList[T]) Copy() GenericIdentityList[T]
Copy returns a copy of IdentityList. 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.
CAUTION: All Identity fields are deep-copied, _except_ for their keys, which are copied by reference as they are treated as immutable by convention.
func (GenericIdentityList[T]) Count ¶ added in v0.33.30
func (il GenericIdentityList[T]) Count() uint
Count returns the count of identities.
func (GenericIdentityList[T]) Exists ¶ added in v0.33.30
func (il GenericIdentityList[T]) Exists(target *T) bool
Exists takes a previously sorted Identity list and searches it for the target identity by its NodeID. CAUTION:
- Other identity fields are not compared.
- The identity list MUST be sorted prior to calling this method.
func (GenericIdentityList[T]) Filter ¶ added in v0.33.30
func (il GenericIdentityList[T]) Filter(filter IdentityFilter[T]) GenericIdentityList[T]
Filter will apply a filter to the identity list. The resulting list will only contain entries that match the filtering criteria.
func (GenericIdentityList[T]) GetIndex ¶ added in v0.33.30
func (il GenericIdentityList[T]) GetIndex(target Identifier) (uint, bool)
GetIndex returns the index of the identifier in the IdentityList and true if the identifier is found.
func (GenericIdentityList[T]) ID ¶ added in v0.33.30
func (il GenericIdentityList[T]) ID() Identifier
ID uniquely identifies a list of identities, by node ID. This can be used to perpetually identify a group of nodes, even if mutable fields of some nodes are changed, as node IDs are immutable. CAUTION:
- An IdentityList's ID is a cryptographic commitment to only node IDs. A node operator can freely choose the ID for their node. There is no relationship whatsoever between a node's ID and keys.
- To generate a cryptographic commitment for the full IdentityList, use method `Checksum()`.
- The outputs of `IdentityList.ID()` and `IdentityList.Checksum()` are both order-sensitive. Therefore, the `IdentityList` must be in canonical order, unless explicitly specified otherwise by the protocol.
func (GenericIdentityList[T]) IdentifierExists ¶ added in v0.33.30
func (il GenericIdentityList[T]) IdentifierExists(target Identifier) bool
IdentifierExists takes a previously sorted Identity list and searches it for the target value target: value to search for CAUTION: The identity list MUST be sorted prior to calling this method
func (GenericIdentityList[T]) Lookup ¶ added in v0.33.30
func (il GenericIdentityList[T]) Lookup() map[Identifier]*T
Lookup converts the identity slice to a map using the NodeIDs as keys. This is useful when _repeatedly_ querying identities by their NodeIDs. The conversation from slice to map incurs cost O(n), for `n` the slice length. For a _single_ lookup, use method `ByNodeID(Identifier)` (avoiding conversion).
func (GenericIdentityList[T]) Map ¶ added in v0.33.30
func (il GenericIdentityList[T]) Map(f IdentityMapFunc[T]) GenericIdentityList[T]
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 (GenericIdentityList[T]) NodeIDs ¶ added in v0.33.30
func (il GenericIdentityList[T]) NodeIDs() IdentifierList
NodeIDs returns the NodeIDs of the nodes in the list (order preserving).
func (GenericIdentityList[T]) PublicStakingKeys ¶ added in v0.33.30
func (il GenericIdentityList[T]) PublicStakingKeys() []crypto.PublicKey
PublicStakingKeys returns a list with the public staking keys (order preserving).
func (GenericIdentityList[T]) Sample ¶ added in v0.33.30
func (il GenericIdentityList[T]) Sample(size uint) (GenericIdentityList[T], error)
Sample returns non-deterministic random sample from the `IdentityList`
func (GenericIdentityList[T]) SamplePct ¶ added in v0.33.30
func (il GenericIdentityList[T]) SamplePct(pct float64) (GenericIdentityList[T], error)
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 in the interval [0, 1.0]
func (GenericIdentityList[T]) Selector ¶ added in v0.33.30
func (il GenericIdentityList[T]) Selector() IdentityFilter[T]
Selector returns an identity filter function that selects only identities within this identity list.
func (GenericIdentityList[T]) Shuffle ¶ added in v0.33.30
func (il GenericIdentityList[T]) Shuffle() (GenericIdentityList[T], error)
Shuffle randomly shuffles the identity list (non-deterministic), and returns the shuffled list without modifying the receiver.
func (GenericIdentityList[T]) Sort ¶ added in v0.33.30
func (il GenericIdentityList[T]) Sort(less IdentityOrder[T]) GenericIdentityList[T]
Sort will sort the list using the given ordering. This is not recommended for performance. Expand the 'less' function in place for best performance, and don't use this function.
func (GenericIdentityList[T]) Sorted ¶ added in v0.33.30
func (il GenericIdentityList[T]) Sorted(less IdentityOrder[T]) bool
Sorted returns whether the list is sorted by the input ordering.
func (GenericIdentityList[T]) ToSkeleton ¶ added in v0.33.30
func (il GenericIdentityList[T]) ToSkeleton() IdentitySkeletonList
ToSkeleton converts the identity list to a list of identity skeletons.
func (GenericIdentityList[T]) TotalWeight ¶ added in v0.33.30
func (il GenericIdentityList[T]) TotalWeight() uint64
TotalWeight returns the total weight of all given identities.
func (GenericIdentityList[T]) Union ¶ added in v0.33.30
func (il GenericIdentityList[T]) Union(other GenericIdentityList[T]) GenericIdentityList[T]
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. In case an entry with the same NodeID exists in the receiver `il` as well as in `other`, the identity from `il` is included in the output. Receiver `il` and/or method input `other` can be nil or empty. The returned IdentityList is sorted in canonical order.
type GetProtocolStateEntryFunc ¶ added in v0.33.30
type GetProtocolStateEntryFunc func(protocolStateID Identifier) (*ProtocolStateEntryWrapper, error)
GetProtocolStateEntryFunc is a getter function for protocol state entries No errors are expected during normal operation.
type GetResultFunc ¶ added in v0.23.9
type GetResultFunc func(resultID Identifier) (*ExecutionResult, error)
GetResultFunc is a getter function for results by ID. No errors are expected during normal operation.
type GetSealByBlockIDFunc ¶ added in v0.23.9
type GetSealByBlockIDFunc func(blockID Identifier) (*Seal, error)
GetSealByBlockIDFunc is a getter function for seals by block ID, returning the latest seals incorporated as of the given block. No errors are expected during normal operation.
type Header ¶
type Header struct { // ChainID is a chain-specific value to prevent replay attacks. ChainID ChainID // ParentID is the ID of this block's parent. ParentID Identifier // Height is the height of the parent + 1 Height uint64 // PayloadHash is a hash of the payload of this block. PayloadHash Identifier // Timestamp is the time at which this block was proposed. // The proposer can choose any time, so this should not be trusted as accurate. Timestamp time.Time // View number at which this block was proposed. View uint64 // ParentView number at which parent block was proposed. ParentView uint64 // ParentVoterIndices is a bitvector that represents all the voters for the parent block. ParentVoterIndices []byte // ParentVoterSigData is an aggregated signature over the parent block. Not a single cryptographic // signature since the data represents cryptographic signatures serialized in some way (concatenation or other) // A quorum certificate can be extracted from the header. // This field is the SigData field of the extracted quorum certificate. ParentVoterSigData []byte // ProposerID is a proposer identifier for the block ProposerID Identifier // ProposerSigData is a signature of the proposer over the new block. Not a single cryptographic // signature since the data represents cryptographic signatures serialized in some way (concatenation or other) ProposerSigData []byte // LastViewTC is a timeout certificate for previous view, it can be nil // it has to be present if previous round ended with timeout. LastViewTC *TimeoutCertificate }
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) MarshalCBOR ¶ added in v0.21.0
MarshalCBOR makes sure the timestamp is encoded in UTC.
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) QuorumCertificate ¶ added in v0.30.0
func (h Header) QuorumCertificate() *QuorumCertificate
QuorumCertificate returns quorum certificate that is incorporated in the block header.
func (*Header) UnmarshalCBOR ¶ added in v0.21.0
UnmarshalCBOR makes sure the timestamp is decoded 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 IDEntity ¶ added in v0.33.19
type IDEntity interface { // ID returns a unique id for this entity using a hash of the immutable // fields of the entity. ID() Identifier }
type Identifier ¶
type Identifier [IdentifierLen]byte
Identifier represents a 32-byte unique identifier for an entity.
var EmptyEventCollectionID Identifier
func ByteSliceToId ¶ added in v0.25.0
func ByteSliceToId(b []byte) (Identifier, error)
func CidToId ¶ added in v0.25.0
func CidToId(c cid.Cid) (Identifier, error)
func ConcatSum ¶
func ConcatSum(ids ...Identifier) Identifier
func EntitiesToIDs ¶ added in v0.31.7
func EntitiesToIDs[T Entity](entities []T) []Identifier
func EventsMerkleRootHash ¶ added in v0.23.9
func EventsMerkleRootHash(el EventsList) (Identifier, error)
EventsMerkleRootHash calculates the root hash of events inserted into a merkle trie with the hash of event as the key and encoded event as value
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 MakeIDFromFingerPrint ¶ added in v0.27.0
func MakeIDFromFingerPrint(fingerPrint []byte) Identifier
MakeIDFromFingerPrint is similar to MakeID but skipping fingerprinting step.
func MerkleRoot ¶
func MerkleRoot(ids ...Identifier) Identifier
func MustHexStringToIdentifier ¶ added in v0.19.0
func MustHexStringToIdentifier(hexString string) Identifier
func PublicKeyToID ¶
func PublicKeyToID(pk crypto.PublicKey) (Identifier, error)
PublicKeyToID creates an ID from a public key.
func Sample ¶
func Sample(size uint, ids ...Identifier) ([]Identifier, error)
Sample returns non-deterministic random sample of length 'size' of the ids
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) IsSampled ¶ added in v0.22.0
func (id Identifier) IsSampled(sensitivity uint) bool
IsSampled is a utility method to sample entities based on their ids the range is from [0, 64]. 0 is 100% (all data will be collected) 1 is ~50% 2 is ~25% 3 is ~12.5% ... >64 is 0% (no data will be collected)
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 ByteSlicesToIds ¶ added in v0.25.0
func ByteSlicesToIds(b [][]byte) (IdentifierList, error)
func GetIDs ¶
func GetIDs[T Entity](entities []T) IdentifierList
GetIDs gets the IDs for a slice of entities.
func (IdentifierList) Checksum ¶ added in v0.30.0
func (il IdentifierList) Checksum() Identifier
Checksum returns a cryptographic commitment to the list of identifiers.
func (IdentifierList) Contains ¶ added in v0.17.0
func (il IdentifierList) Contains(target Identifier) bool
Contains returns whether this identifier list contains the target identifier.
func (IdentifierList) Copy ¶ added in v0.17.1
func (il IdentifierList) Copy() IdentifierList
func (IdentifierList) Filter ¶ added in v0.21.0
func (il IdentifierList) Filter(filter IdentifierFilter) IdentifierList
Filter will apply a filter to the identifier list.
func (IdentifierList) ID ¶ added in v0.30.0
func (il IdentifierList) ID() Identifier
ID returns a cryptographic commitment to the list of identifiers. Since an IdentifierList has no mutable fields, it is equal to the checksum.
func (IdentifierList) Len ¶
func (il IdentifierList) Len() int
Len returns length of the IdentifierList 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) Lookup ¶ added in v0.17.1
func (il IdentifierList) Lookup() map[Identifier]struct{}
Lookup converts the Identifiers to a lookup table.
func (IdentifierList) Sample ¶ added in v0.21.0
func (il IdentifierList) Sample(size uint) (IdentifierList, error)
Sample returns random sample of length 'size' of the ids
func (IdentifierList) Sort ¶ added in v0.26.1
func (il IdentifierList) Sort(less IdentifierOrder) IdentifierList
Sort returns a sorted _copy_ of the IdentifierList, leaving the original invariant.
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.
func (IdentifierList) Union ¶ added in v0.21.1
func (il IdentifierList) Union(other IdentifierList) IdentifierList
Union returns a new identifier list containing the union of `il` and `other`. There are no duplicates in the output.
type IdentifierOrder ¶ added in v0.26.1
type IdentifierOrder func(Identifier, Identifier) int
IdentifierOrder is an order function for identifiers.
It defines a strict weak ordering between identifiers. It returns a negative number if the first identifier is "strictly less" than the second, a positive number if the second identifier is "strictly less" than the first, and zero if the two identifiers are equal.
`IdentifierOrder` can be used to sort identifiers with https://pkg.go.dev/golang.org/x/exp/slices#SortFunc.
type Identity ¶
type Identity struct { IdentitySkeleton DynamicIdentity }
Identity is combined from static and dynamic part and represents the full public identity of one network participant (node).
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, persistent identifier for the identity. CAUTION: the ID may be chosen by a node operator, so long as it is unique.
func (Identity) MarshalCBOR ¶ added in v0.21.0
func (Identity) MarshalJSON ¶
func (Identity) MarshalMsgpack ¶
func (*Identity) UnmarshalCBOR ¶ added in v0.21.0
func (*Identity) UnmarshalJSON ¶
func (*Identity) UnmarshalMsgpack ¶
type IdentityFilter ¶
type IdentityFilter[T GenericIdentity] func(*T) bool
IdentityFilter is a filter on identities. Mathematically, an IdentityFilter F can be described as a function F: 𝓘 → 𝐼, where 𝓘 denotes the set of all identities and 𝐼 ⊆ 𝓘. For an input identity i, F(i) returns true if and only if i passed the filter, i.e. i ∈ 𝐼. Returning false means that some necessary criterion was violated and identity i should be dropped, i.e. i ∉ 𝐼.
type IdentityList ¶
type IdentityList = GenericIdentityList[Identity]
IdentityList is a list of nodes. We use a type alias instead of defining a new type since go generics doesn't support implicit conversion between types.
func BuildIdentityTable ¶ added in v0.33.30
func BuildIdentityTable( targetEpochIdentitySkeletons IdentitySkeletonList, targetEpochDynamicIdentities DynamicIdentityEntryList, adjacentEpochIdentitySkeletons IdentitySkeletonList, adjacentEpochDynamicIdentities DynamicIdentityEntryList, adjacentIdentitiesStatus EpochParticipationStatus, ) (IdentityList, error)
BuildIdentityTable constructs the full identity table for the target epoch by combining data from:
- The IdentitySkeletons for the nodes that are _active_ in the target epoch (recorded in EpochSetup event and immutable throughout the epoch).
- The Dynamic Identities for the nodes that are _active_ in the target epoch (i.e. the dynamic identity fields for the IdentitySkeletons contained in the EpochSetup event for the respective epoch).
Optionally, identity information for an adjacent epoch is given if and only if an adjacent epoch exists. For a target epoch N, the epochs N-1 and N+1 are defined to be adjacent. Adjacent epochs do not necessarily exist (e.g. consider a spork comprising only a single epoch), in which case the respective inputs are nil or empty.
- [optional] An adjacent epoch's IdentitySkeletons as recorded in the adjacent epoch's setup event.
- [optional] An adjacent epoch's Dynamic Identities.
- An adjacent epoch's identities participation status, this could be joining or leaving depending on epoch phase.
The function enforces that the input slices pertaining to the same epoch contain the same identities (compared by nodeID) in the same order. Otherwise, an exception is returned. No errors are expected during normal operation. All errors indicate inconsistent or invalid inputs.
func ComposeFullIdentities ¶ added in v0.33.30
func ComposeFullIdentities( skeletons IdentitySkeletonList, dynamics DynamicIdentityEntryList, defaultEpochParticipationStatus EpochParticipationStatus, ) (IdentityList, error)
ComposeFullIdentities combines identity skeletons and dynamic identities to produce a flow.IdentityList. It enforces that the input slices `skeletons` and `dynamics` list the same identities (compared by nodeID) in the same order. Otherwise, an exception is returned. For each identity i, we set `i.EpochParticipationStatus` to the `defaultEpochParticipationStatus` _unless_ i is ejected. No errors are expected during normal operations.
type IdentityMapFunc ¶ added in v0.12.0
type IdentityMapFunc[T GenericIdentity] func(T) T
IdentityMapFunc is a modifier function for map operations for identities. Identities are COPIED from the source slice.
type IdentityOrder ¶
type IdentityOrder[T GenericIdentity] func(*T, *T) int
IdentityOrder is an order function for identities.
It defines a strict weak ordering between identities. It returns a negative number if the first identity is "strictly less" than the second, a positive number if the second identity is "strictly less" than the first, and zero if the two identities are equal.
`IdentityOrder` can be used to sort identities with https://pkg.go.dev/golang.org/x/exp/slices#SortFunc.
type IdentitySkeleton ¶ added in v0.33.30
type IdentitySkeleton 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 is the network address where the node can be reached. Address string // Role is the node's role in the network and defines its abilities and // responsibilities. Role Role // InitialWeight is a 'trust score' initially assigned by EpochSetup event after // the staking phase. The initial weights define the supermajority thresholds for // the cluster and security node consensus throughout the Epoch. InitialWeight uint64 StakingPubKey crypto.PublicKey NetworkPubKey crypto.PublicKey }
IdentitySkeleton represents the static part of a network participant's (i.e. node's) public identity.
func (IdentitySkeleton) EncodeRLP ¶ added in v0.33.30
func (iy IdentitySkeleton) EncodeRLP(w io.Writer) error
func (*IdentitySkeleton) EqualTo ¶ added in v0.33.30
func (iy *IdentitySkeleton) EqualTo(other *IdentitySkeleton) bool
func (IdentitySkeleton) GetInitialWeight ¶ added in v0.33.30
func (iy IdentitySkeleton) GetInitialWeight() uint64
GetInitialWeight returns initial weight for the identity. It is needed to satisfy GenericIdentity constraint.
func (IdentitySkeleton) GetNetworkPubKey ¶ added in v0.33.30
func (iy IdentitySkeleton) GetNetworkPubKey() crypto.PublicKey
GetNetworkPubKey returns network public key for the identity. It is needed to satisfy GenericIdentity constraint.
func (IdentitySkeleton) GetNodeID ¶ added in v0.33.30
func (iy IdentitySkeleton) GetNodeID() Identifier
GetNodeID returns node ID for the identity. It is needed to satisfy GenericIdentity constraint.
func (IdentitySkeleton) GetRole ¶ added in v0.33.30
func (iy IdentitySkeleton) GetRole() Role
GetRole returns a node role for the identity. It is needed to satisfy GenericIdentity constraint.
func (IdentitySkeleton) GetSkeleton ¶ added in v0.33.30
func (iy IdentitySkeleton) GetSkeleton() IdentitySkeleton
GetSkeleton returns the skeleton part for the identity. It is needed to satisfy GenericIdentity constraint.
func (IdentitySkeleton) GetStakingPubKey ¶ added in v0.33.30
func (iy IdentitySkeleton) GetStakingPubKey() crypto.PublicKey
GetStakingPubKey returns staking public key for the identity. It is needed to satisfy GenericIdentity constraint.
func (IdentitySkeleton) MarshalCBOR ¶ added in v0.33.30
func (iy IdentitySkeleton) MarshalCBOR() ([]byte, error)
func (IdentitySkeleton) MarshalJSON ¶ added in v0.33.30
func (iy IdentitySkeleton) MarshalJSON() ([]byte, error)
func (IdentitySkeleton) MarshalMsgpack ¶ added in v0.33.30
func (iy IdentitySkeleton) MarshalMsgpack() ([]byte, error)
func (IdentitySkeleton) String ¶ added in v0.33.30
func (iy IdentitySkeleton) String() string
String returns a string representation of the identity.
func (*IdentitySkeleton) UnmarshalCBOR ¶ added in v0.33.30
func (iy *IdentitySkeleton) UnmarshalCBOR(b []byte) error
func (*IdentitySkeleton) UnmarshalJSON ¶ added in v0.33.30
func (iy *IdentitySkeleton) UnmarshalJSON(b []byte) error
func (*IdentitySkeleton) UnmarshalMsgpack ¶ added in v0.33.30
func (iy *IdentitySkeleton) UnmarshalMsgpack(b []byte) error
type IdentitySkeletonList ¶ added in v0.33.30
type IdentitySkeletonList = GenericIdentityList[IdentitySkeleton]
IdentitySkeletonList is a list of nodes skeletons. We use a type alias instead of defining a new type since go generics doesn't support implicit conversion between types.
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 }
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) 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) 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.
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
GroupByExecutedBlockID 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
GroupByIncorporatedBlockID 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 // the header of the executed block // useful for indexing the seal by height in the mempool in order for fast pruning Header *Header }
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 ResultIDs []Identifier ProtocolStateID Identifier }
type InvalidSealingSegmentError ¶ added in v0.33.30
type InvalidSealingSegmentError struct {
// contains filtered or unexported fields
}
InvalidSealingSegmentError is returned either when building or validating a SealingSegment, when the segment is found to be invalid, or when attempting to add an entity to a segment under construction would cause the resulting SealingSegment to become invalid.
func NewInvalidSealingSegmentError ¶ added in v0.33.30
func NewInvalidSealingSegmentError(msg string, args ...any) InvalidSealingSegmentError
func (InvalidSealingSegmentError) Error ¶ added in v0.33.30
func (err InvalidSealingSegmentError) Error() string
func (InvalidSealingSegmentError) Unwrap ¶ added in v0.33.30
func (err InvalidSealingSegmentError) Unwrap() error
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 LightTransactionResult ¶ added in v0.32.0
type LightTransactionResult struct { // TransactionID is the ID of the transaction this result was emitted from. TransactionID Identifier // Failed is true if the transaction's execution failed resulting in an error, false otherwise. Failed bool // ComputationUsed is amount of computation used while executing the transaction. ComputationUsed uint64 }
LightTransactionResult represents a TransactionResult, omitting any fields that are prone to non-determinism; i.e. the error message and memory used estimate.
While the net causes of a transaction failing are deterministic, the specific error and message propagated back to FVM are prone to bugs resulting in slight variations. Rather than including the error and risking execution forks if an undetected bug is introduced, we simplify it to just a boolean value. This will likely change in the future to include some additional information about the error.
Additionally, MemoryUsed is omitted because it is an estimate from the specific execution node, and will vary across nodes.
type MinEpochStateEntry ¶ added in v0.37.1
type MinEpochStateEntry struct { PreviousEpoch *EpochStateContainer // minimal dynamic properties for previous epoch [optional, nil for first epoch after spork, genesis] CurrentEpoch EpochStateContainer // minimal dynamic properties for current epoch NextEpoch *EpochStateContainer // minimal dynamic properties for next epoch [optional, nil iff we are in staking phase] // EpochFallbackTriggered encodes whether an invalid epoch transition // has been detected in this fork. Under normal operations, this value is false. // Node-internally, the EpochFallback notification is emitted when a block is // finalized that changes this flag from false to true. // A state transition from true -> false is possible only when protocol undergoes epoch recovery. EpochFallbackTriggered bool }
MinEpochStateEntry is the most compact snapshot of the epoch state and identity table (set of all notes authorized to be part of the network) at some specific block. This struct is optimized for persisting the identity table in the database, in that it only includes data that is variable during the course of an epoch to avoid storage of redundant data. The Epoch Setup and Commit events, which carry the portion of the identity table that is constant throughout an epoch, are only referenced by their hash commitment. Note that a MinEpochStateEntry does not hold the entire data for the identity table directly. It allows reconstructing the identity table with the referenced epoch setup events and dynamic identities.
func (*MinEpochStateEntry) Copy ¶ added in v0.37.1
func (e *MinEpochStateEntry) Copy() *MinEpochStateEntry
Copy returns a full copy of the entry. Embedded Identities are deep-copied, _except_ for their keys, which are copied by reference.
func (*MinEpochStateEntry) EpochPhase ¶ added in v0.37.1
func (e *MinEpochStateEntry) EpochPhase() EpochPhase
EpochPhase returns the current epoch phase. The receiver MinEpochStateEntry must be properly constructed. See flow.EpochPhase for detailed documentation.
func (*MinEpochStateEntry) ID ¶ added in v0.37.1
func (e *MinEpochStateEntry) ID() Identifier
ID returns hash of entry by hashing all fields.
type MonotonicAddressGenerator ¶
type MonotonicAddressGenerator struct {
// contains filtered or unexported fields
}
func (*MonotonicAddressGenerator) AddressCount ¶ added in v0.18.3
func (gen *MonotonicAddressGenerator) AddressCount() uint64
AddressCount returns the total number of addresses generated so far
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 PSKeyValueStoreData ¶ added in v0.33.30
PSKeyValueStoreData is a binary blob with a version attached, specifying the format of the marshaled data. In a nutshell, it serves as a binary snapshot of a ProtocolKVStore. This structure is useful for version-agnostic storage, where snapshots with different versions can co-exist. The PSKeyValueStoreData is a generic format that can be later decoded to potentially different strongly typed structures based on version. When reading from the store, callers must know how to deal with the binary representation.
type Payload ¶
type Payload struct { // Guarantees are ordered in execution order. May be empty, in which case // only the system chunk is executed for this block. Guarantees []*CollectionGuarantee // Seals holds block seals for ancestor blocks. // The oldest seal must connect to the latest seal in the fork extended by this block. // Seals must be internally connected, containing no seals with duplicate block IDs or heights. // Seals may be empty. It presents a set, i.e. there is no protocol-defined ordering. Seals []*Seal Receipts ExecutionReceiptMetaList Results ExecutionResultList // ProtocolStateID is the root hash of protocol state. Per convention, this is the resulting // state after applying all identity-changing operations potentially contained in the block. // The block payload itself is validated wrt to the protocol state committed to by its parent. // Thereby, we are only accepting protocol states that have been certified by a valid QC. ProtocolStateID Identifier }
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
MarshalJSON defines the JSON marshalling for block payloads. Enforce a consistent representation for empty slices.
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 ProtocolStateEntryWrapper
deprecated
added in
v0.33.30
type ProtocolStateEntryWrapper struct { KVStore PSKeyValueStoreData EpochEntry *RichEpochStateEntry }
ProtocolStateEntryWrapper is a wrapper coupling two data sources. Conceptually, the SealingSegment stores one Protocol State Entry (aka `KVStoreEntry`) per unique ProtocolStateID field within the segment's blocks. Currently, although epoch data is conceptually a part of the protocol data entry associated with each block, it is stored separately as a matter of technical debt (only a hash commitment `RichEpochStateEntry.ID()` is stored within the `KVStoreEntry`.
Deprecated: avoid using this in new code; this is a temporary measure until epoch data is moved into protocol KV store TODO: move epoch data into the KVStore as part of a future upgrade
type ProtocolStateVersionUpgrade ¶ added in v0.33.30
ProtocolStateVersionUpgrade is a service event emitted by the FlowServiceAccount to signal an upgrade to the Protocol State version. `NewProtocolStateVersion` must be strictly greater than the currently active Protocol State Version, otherwise the service event is ignored. If the node software supports `NewProtocolStateVersion`, then it uses the specified Protocol State Version, beginning with the first block `X` where BOTH:
- The `ProtocolStateVersionUpgrade` service event has been sealed in X's ancestry
- X.view >= `ActiveView`
NOTE: A ProtocolStateVersionUpgrade event `E` is accepted while processing block `B` which seals `E` if and only if E.ActiveView > B.View + SafetyThreshold. SafetyThreshold is a protocol parameter set so that it is overwhelmingly likely that block `B` is finalized (ergo the protocol version switch at the specified view `E.ActiveView`) within any stretch of SafetyThreshold-many views. TODO: This concept mirrors `EpochCommitSafetyThreshold` and `versionBoundaryFreezePeriod` These parameters should be consolidated.
Otherwise, the node software stops processing blocks, until it is manually updated to a compatible software version. The Protocol State version must be incremented when:
- a change is made to the Protocol State Machine
- a new key is added or removed from the Protocol State Key-Value Store
func (*ProtocolStateVersionUpgrade) EqualTo ¶ added in v0.33.30
func (u *ProtocolStateVersionUpgrade) EqualTo(other *ProtocolStateVersionUpgrade) bool
EqualTo returns true if the two events are equivalent.
func (*ProtocolStateVersionUpgrade) ServiceEvent ¶ added in v0.33.30
func (u *ProtocolStateVersionUpgrade) ServiceEvent() ServiceEvent
ServiceEvent returns the event as a generic ServiceEvent type.
type QuorumCertificate ¶
type QuorumCertificate struct { View uint64 BlockID Identifier // SignerIndices encodes the HotStuff participants whose vote is included in this QC. // For `n` authorized consensus nodes, `SignerIndices` is an n-bit vector (padded with tailing // zeros to reach full bytes). We list the nodes in their canonical order, as defined by the protocol. SignerIndices []byte // For consensus cluster, the SigData is a serialization of the following fields // - SigType []byte, bit-vector indicating the type of sig produced by the signer. // - AggregatedStakingSig []byte // - AggregatedRandomBeaconSig []byte // - ReconstructedRandomBeaconSig crypto.Signature // For collector cluster HotStuff, SigData is simply the aggregated staking signatures // from all signers. 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.
func (*QuorumCertificate) ID ¶ added in v0.29.0
func (qc *QuorumCertificate) ID() Identifier
ID returns the QuorumCertificate's identifier
type QuorumCertificateWithSignerIDs ¶ added in v0.26.1
type QuorumCertificateWithSignerIDs struct { View uint64 BlockID Identifier SignerIDs []Identifier SigData []byte }
QuorumCertificateWithSignerIDs is a QuorumCertificate, where the signing nodes are identified via their `flow.Identifier`s instead of indices. Working with IDs as opposed to indices is less efficient, but simpler, because we don't require a canonical node order. It is used for bootstrapping new Epochs, because the FlowEpoch smart contract has no notion of node ordering.
type RegisterEntries ¶ added in v0.10.0
type RegisterEntries []RegisterEntry
handy container for sorting TODO(ramtin): add canonical encoding and fingerprint for RegisterEntries
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 AccountStatusRegisterID ¶ added in v0.30.0
func AccountStatusRegisterID(address Address) RegisterID
func CadenceRegisterID ¶ added in v0.30.0
func CadenceRegisterID(owner []byte, key []byte) RegisterID
func ContractNamesRegisterID ¶ added in v0.30.0
func ContractNamesRegisterID(address Address) RegisterID
func ContractRegisterID ¶ added in v0.30.0
func ContractRegisterID(address Address, contractName string) RegisterID
func NewRegisterID ¶ added in v0.10.0
func NewRegisterID(owner Address, key string) RegisterID
func PublicKeyRegisterID ¶ added in v0.30.0
func PublicKeyRegisterID(address Address, index uint32) RegisterID
func UUIDRegisterID ¶ added in v0.30.0
func UUIDRegisterID(partition byte) RegisterID
func (*RegisterID) Bytes ¶ added in v0.19.0
func (r *RegisterID) Bytes() []byte
Bytes returns a bytes representation of the RegisterID.
The encoding uses the injective fingerprint module.
func (RegisterID) IsInternalState ¶ added in v0.30.0
func (id RegisterID) IsInternalState() bool
IsInternalState returns true if the register id is controlled by flow-go and return false otherwise (key controlled by the cadence env).
func (RegisterID) IsSlabIndex ¶ added in v0.30.0
func (id RegisterID) IsSlabIndex() bool
IsSlabIndex returns true if the key is a slab index for an account's ordered fields map.
In general, each account's regular fields are stored in ordered map known only to cadence. Cadence encodes this map into bytes and split the bytes into slab chunks before storing the slabs into the ledger.
func (RegisterID) String ¶ added in v0.10.0
func (id RegisterID) String() string
String returns formatted string representation of the RegisterID.
type RegisterIDs ¶ added in v0.30.0
type RegisterIDs []RegisterID
handy container for sorting
func (RegisterIDs) Len ¶ added in v0.30.0
func (d RegisterIDs) Len() int
func (RegisterIDs) Less ¶ added in v0.30.0
func (d RegisterIDs) Less(i, j int) bool
func (RegisterIDs) Swap ¶ added in v0.30.0
func (d RegisterIDs) Swap(i, j int)
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
func (ResultApprovalBody) PartialID ¶ added in v0.17.1
func (rab ResultApprovalBody) PartialID() Identifier
PartialID generates a unique identifier using Attestation + ApproverID
type RichEpochStateEntry ¶ added in v0.37.1
type RichEpochStateEntry struct { *EpochStateEntry CurrentEpochIdentityTable IdentityList NextEpochIdentityTable IdentityList }
RichEpochStateEntry is a EpochStateEntry that additionally holds the canonical representation of the identity table (set of all notes authorized to be part of the network) at some specific block. This data structure is optimized for frequent reads of the same identity table, which is the prevalent case during normal operations (node ejections and epoch fallback are rare). Conventions:
- Invariants inherited from EpochStateEntry.
- CurrentEpochIdentityTable is the full (dynamic) identity table for the current epoch. Identities are sorted in canonical order. Without duplicates. Never nil.
- NextEpochIdentityTable is the full (dynamic) identity table for the next epoch. Can be nil.
NOTE regarding `CurrentEpochIdentityTable` and `NextEpochIdentityTable`: The Identity Table is generally a super-set of the identities listed in the Epoch Service Events for the respective epoch. This is because the service events only list nodes that are authorized to _actively_ contribute to extending the chain. In contrast, the Identity Table additionally contains nodes (with weight zero) from the previous or upcoming epoch, which are transitioning into / out of the network and are only allowed to listen but not to actively contribute.
func NewRichEpochStateEntry ¶ added in v0.37.1
func NewRichEpochStateEntry( epochState *EpochStateEntry, ) (*RichEpochStateEntry, error)
NewRichEpochStateEntry constructs a RichEpochStateEntry from an EpochStateEntry. No errors are expected during normal operation. All errors indicate inconsistent or invalid inputs.
func (*RichEpochStateEntry) Copy ¶ added in v0.37.1
func (e *RichEpochStateEntry) Copy() *RichEpochStateEntry
Copy returns a full copy of the RichEpochStateEntry.
- Embedded service events are copied by reference (not deep-copied).
- CurrentEpochIdentityTable and NextEpochIdentityTable are deep-copied, _except_ for their keys, which are copied by reference.
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 }
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
func (Seal) MarshalJSON ¶ added in v0.23.2
type SealedVersionBeacon ¶ added in v0.31.0
type SealedVersionBeacon struct { *VersionBeacon SealHeight uint64 }
SealedVersionBeacon is a VersionBeacon with a SealHeight field. Version beacons are effective only after the results containing the version beacon are sealed.
type SealingSegment ¶ added in v0.23.2
type SealingSegment struct { // Blocks contain the chain `B <- ... <- Head` in ascending height order. // Formally, Blocks contains exactly (not more!) the history to satisfy condition // (see sealing_segment.md for details): // (i) The highest sealed block as of `head` needs to be included in the sealing segment. // This is relevant if `head` does not contain any seals. Blocks []*Block // ExtraBlocks [optional] holds ancestors of `Blocks` in ascending height order. // Formally, ExtraBlocks contains at least the additional history to satisfy conditions // (see sealing_segment.md for details): // (ii) All blocks that are sealed by `head`. This is relevant if `head` contains _multiple_ seals. // (iii) The sealing segment holds the history of all non-expired collection guarantees, i.e. // limitHeight := max(blockSealedAtHead.Height - flow.DefaultTransactionExpiry, SporkRootBlockHeight) // where blockSealedAtHead is the block sealed by `head` block. // (Potentially longer history is permitted) ExtraBlocks []*Block // ExecutionResults contain any results which are referenced by receipts // or seals in the sealing segment, but not included in any segment block // payloads. // // Due to decoupling of execution receipts from execution results, // it's possible that blocks from the sealing segment will be referring to // execution results incorporated in blocks that aren't part of the segment. ExecutionResults ExecutionResultList // LatestSeals is a mapping from block ID to the ID of the latest seal // incorporated as of that block. Note: we store the seals' IDs here // (instead of the full seals), because the seals for all blocks, except for // the lowest one, are contained in the blocks of the sealing segment. LatestSeals map[Identifier]Identifier // FirstSeal contains the latest seal as of the first block in the segment. // Per convention, this field holds a seal that was included _prior_ to the // first block of the sealing segment. If the first block in the segment // contains a seal, then this field is `nil`. // This information is needed for the `Commit` method of protocol snapshot // to return the sealed state, when the first block contains no seal. FirstSeal *Seal // ProtocolStateEntries contains every protocol state entry committed to // by any block in the SealingSegment (including ExtraBlocks). ProtocolStateEntries map[Identifier]*ProtocolStateEntryWrapper }
SealingSegment is a continuous segment of recently finalized blocks that contains enough history for a new node to execute its business logic normally. It is part of the data need to initialize a new node to join the network. DETAILED SPECIFICATION: ./sealing_segment.md
├═══════════┤ ├───────────────────────┤ ExtraBlocks ^ Blocks ^ B head
Lets denote the highest block in the sealing segment as `head`. Per convention, `head` must be a finalized block. Consider the chain of blocks leading up to `head` (included). The highest block in chain leading up to `head` that is sealed, we denote as B. In other words, head is the last finalized block, and B is the last sealed block, block at height (B.Height + 1) is not sealed.
func (*SealingSegment) AllBlocks ¶ added in v0.29.6
func (segment *SealingSegment) AllBlocks() []*Block
AllBlocks returns all blocks within the sealing segment, including extra blocks, in ascending height order.
func (*SealingSegment) Finalized ¶ added in v0.30.7
func (segment *SealingSegment) Finalized() *Block
Finalized returns the last finalized block, which is an alias of Highest
func (*SealingSegment) FinalizedSeal ¶ added in v0.26.6
func (segment *SealingSegment) FinalizedSeal() (*Seal, error)
FinalizedSeal returns the seal that seals the lowest block. Per specification, this seal must be included in a SealingSegment. The SealingSegment must be validated. No errors are expected during normal operation.
func (*SealingSegment) Highest ¶ added in v0.23.2
func (segment *SealingSegment) Highest() *Block
Highest is the highest block in the sealing segment and the reference block from snapshot that was used to produce this sealing segment.
func (*SealingSegment) IsSporkRoot ¶ added in v0.33.30
func (segment *SealingSegment) IsSporkRoot() bool
IsSporkRoot returns true if this SealingSegment represents a spork root snapshot. The Flow protocol explicitly defines a spork root block (incl. also the network's genesis block) to be finalized and sealed and to have a specific execution state commitment attached. Mathematically, this is a protocol axiom, as no block exists that contains an execution result or seal for the spork root block (nor any children at the time of the spork that could possibly finalize the root block). Therefore, a spork root block is a degenerate sealing segment with a length of 1.
func (*SealingSegment) LatestProtocolStateEntry ¶ added in v0.33.30
func (segment *SealingSegment) LatestProtocolStateEntry() *ProtocolStateEntryWrapper
LatestProtocolStateEntry returns the Protocol State entry corresponding to the highest block in the sealing segment. This represents the Dynamic Protocol State after applying all state changes sealed in `SealingSegment.Highest().Payload`. Caution: `segment` must be a valid SealingSegment.
func (*SealingSegment) Sealed ¶ added in v0.29.6
func (segment *SealingSegment) Sealed() *Block
Sealed returns the most recently sealed block based on head of sealing segment(highest block).
func (*SealingSegment) Validate ¶ added in v0.23.9
func (segment *SealingSegment) Validate() error
Validate validates the sealing segment structure and returns an error if the segment isn't valid. This is done by re-building the segment from scratch, re-using the validation logic already present in the SealingSegmentBuilder. The node logic requires a valid sealing segment to bootstrap. Errors expected during normal operation:
- InvalidSealingSegmentError if `segment` is an invalid SealingSegment.
type SealingSegmentBuilder ¶ added in v0.23.2
type SealingSegmentBuilder struct {
// contains filtered or unexported fields
}
SealingSegmentBuilder is a utility for incrementally building a sealing segment.
func NewSealingSegmentBuilder ¶ added in v0.23.2
func NewSealingSegmentBuilder(resultLookup GetResultFunc, sealLookup GetSealByBlockIDFunc, protocolStateLookup GetProtocolStateEntryFunc) *SealingSegmentBuilder
NewSealingSegmentBuilder returns *SealingSegmentBuilder
func (*SealingSegmentBuilder) AddBlock ¶ added in v0.23.2
func (builder *SealingSegmentBuilder) AddBlock(block *Block) error
AddBlock appends a block to the sealing segment under construction. Errors expected during normal operation:
- InvalidSealingSegmentError if the added block would cause an invalid resulting segment
func (*SealingSegmentBuilder) AddExtraBlock ¶ added in v0.29.6
func (builder *SealingSegmentBuilder) AddExtraBlock(block *Block) error
AddExtraBlock appends an extra block to sealing segment under construction. Extra blocks needs to be added in descending order and the first block must connect to the lowest block of sealing segment, this way they form a continuous chain. Errors expected during normal operation:
- InvalidSealingSegmentError if the added block would cause an invalid resulting segment
func (*SealingSegmentBuilder) SealingSegment ¶ added in v0.23.2
func (builder *SealingSegmentBuilder) SealingSegment() (*SealingSegment, error)
SealingSegment completes building the sealing segment, validating the segment constructed so far, and returning it as a SealingSegment if it is valid.
Errors expected during normal operation:
- InvalidSealingSegmentError if the added block would cause an invalid resulting segment
type ServiceEvent ¶
type ServiceEvent struct { Type ServiceEventType 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 (*ServiceEvent) EqualTo ¶ added in v0.19.0
func (se *ServiceEvent) EqualTo(other *ServiceEvent) (bool, error)
EqualTo checks whether two service events are equal, as defined by the underlying Event type. Inputs must have already been independently validated and well-formed. No errors are expected during normal operation.
func (*ServiceEvent) UnmarshalCBOR ¶ added in v0.21.0
func (se *ServiceEvent) UnmarshalCBOR(b []byte) error
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 ServiceEventList ¶ added in v0.19.0
type ServiceEventList []ServiceEvent
ServiceEventList is a handy container to enable comparisons
func (ServiceEventList) EqualTo ¶ added in v0.19.0
func (sel ServiceEventList) EqualTo(other ServiceEventList) (bool, error)
type ServiceEventMarshaller ¶ added in v0.31.0
type ServiceEventMarshaller interface { // UnmarshalWrapped unmarshals the service event and returns it as a wrapped ServiceEvent type. // The input bytes must be encoded as a generic wrapped ServiceEvent type. // Forwards errors from the underlying marshaller (treat errors as you would from eg. json.Unmarshal) UnmarshalWrapped(b []byte) (ServiceEvent, error) // UnmarshalWithType unmarshals the service event and returns it as a wrapped ServiceEvent type. // The input bytes must be encoded as a specific event type (for example, EpochSetup). // Forwards errors from the underlying marshaller (treat errors as you would from eg. json.Unmarshal) UnmarshalWithType(b []byte, eventType ServiceEventType) (ServiceEvent, error) }
ServiceEventMarshaller marshals and unmarshals all types of service events.
type ServiceEventType ¶ added in v0.31.0
type ServiceEventType string
const ( ServiceEventSetup ServiceEventType = "setup" ServiceEventCommit ServiceEventType = "commit" ServiceEventRecover ServiceEventType = "recover" ServiceEventVersionBeacon ServiceEventType = "version-beacon" // VersionBeacon only controls version of ENs, describing software compatability via semantic versioning ServiceEventProtocolStateVersionUpgrade ServiceEventType = "protocol-state-version-upgrade" // Protocol State version applies to all nodes and uses an _integer version_ of the _protocol_ )
func (ServiceEventType) String ¶ added in v0.31.0
func (set ServiceEventType) String() string
String returns the string representation of the service event type. TODO: this should not be needed. We should use ServiceEventType directly everywhere.
type Slashable ¶ added in v0.29.0
type Slashable[T any] struct { OriginID Identifier // this will become the inspector object, once we have message forensics Message T }
Slashable represents an message we got from a different node, whose validity has not been _entirely_ confirmed. We want to retain information about the origin that published this particular message within the network, so we can potentially raise a slashing challenge against the origin, should we discover that this message is evidence of a protocol violation. TODO: this struct does not have its final form. We only retain the ID of the node where the message originated. However, this will not allow us to prove to somebody else that `OriginID` really sent this message, as we could have tempered with the message and then erroneously accuse `OriginID` of a protocol violation. In the mature protocol, `OriginID` will be replaced by an inspector object (generated by the networking layer) that allows us to generate a cryptographic proof of who sent the message.
func NoSlashable ¶ added in v0.29.0
NoSlashable returns the zero value for Slashable[T].
type StateCommitment ¶
StateCommitment holds the root hash of the tree (Snapshot) TODO: solve the circular dependency and define StateCommitment as ledger.State
func ToStateCommitment ¶ added in v0.17.0
func ToStateCommitment(stateBytes []byte) (StateCommitment, error)
ToStateCommitment converts a byte slice into a StateCommitment. It returns an error if the slice has an invalid length. The returned error indicates that the given byte slice is not a valid root hash of an execution state. As the function is side-effect free, all failures are simply a no-op.
func (StateCommitment) MarshalJSON ¶ added in v0.23.2
func (s StateCommitment) MarshalJSON() ([]byte, error)
func (*StateCommitment) UnmarshalJSON ¶ added in v0.23.2
func (s *StateCommitment) UnmarshalJSON(data []byte) error
type StorageProof ¶
type StorageProof = []byte
StorageProof (proof of a read or update to the state, Merkle path of some sort)
type TimeoutCertificate ¶ added in v0.29.0
type TimeoutCertificate struct { View uint64 // NewestQCViews lists for each signer (in the same order) the view of the newest QC they supplied // as part of their TimeoutObject message (specifically TimeoutObject.NewestQC.View). NewestQCViews []uint64 // NewestQC is the newest QC from all TimeoutObject that were aggregated for this certificate. NewestQC *QuorumCertificate // SignerIndices encodes the HotStuff participants whose TimeoutObjects are included in this TC. // For `n` authorized consensus nodes, `SignerIndices` is an n-bit vector (padded with tailing // zeros to reach full bytes). We list the nodes in their canonical order, as defined by the protocol. SignerIndices []byte // SigData is an aggregated signature from multiple TimeoutObjects, each from a different replica. // In their TimeoutObjects, replicas sign the pair (View, NewestQCView) with their staking keys. SigData crypto.Signature }
TimeoutCertificate proves that a super-majority of consensus participants want to abandon the specified View. At its core, a timeout certificate is an aggregation of TimeoutObjects, which individual nodes send to signal their intent to leave the active view.
func (*TimeoutCertificate) ID ¶ added in v0.29.0
func (t *TimeoutCertificate) ID() Identifier
ID returns the TimeoutCertificate's identifier
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 uint32, 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 uint32, 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) InclusionEffort ¶ added in v0.29.0
func (tb TransactionBody) InclusionEffort() uint64
InclusionEffort returns the inclusion effort of the transaction
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) SetComputeLimit ¶ added in v0.33.30
func (tb *TransactionBody) SetComputeLimit(limit uint64) *TransactionBody
SetComputeLimit 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 uint32, 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) Sign ¶ added in v0.26.0
func (tb *TransactionBody) Sign( message []byte, privateKey crypto.PrivateKey, hasher hash.Hasher, ) ([]byte, error)
Sign signs the data (transaction_tag + message) with the specified private key and hasher.
This function returns an error if:
- crypto.InvalidInputsError if the private key cannot sign with the given hasher
- other error if an unexpected error occurs
func (*TransactionBody) SignEnvelope ¶
func (tb *TransactionBody) SignEnvelope( address Address, keyID uint32, privateKey crypto.PrivateKey, hasher hash.Hasher, ) error
SignEnvelope signs the full transaction (TransactionDomainTag + payload + payload signatures) with the specified account key using the default transaction domain tag.
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 uint32, privateKey crypto.PrivateKey, hasher hash.Hasher, ) error
SignPayload signs the transaction payload (TransactionDomainTag + payload) with the specified account key using the default transaction domain tag.
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 // Computation used ComputationUsed uint64 // Memory used (estimation) MemoryUsed uint64 }
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 TransactionResultErrorMessage ¶
type TransactionResultErrorMessage struct { // TransactionID is the ID of the transaction this result error was emitted from. TransactionID Identifier // Index is the index of the transaction this result error was emitted from. Index uint32 // ErrorMessage contains the error message of any error that may have occurred when the transaction was executed. ErrorMessage string // Executor node ID of the execution node that the message was received from. ExecutorID Identifier }
TransactionResultErrorMessage represents an error message resulting from a transaction's execution. This struct holds the transaction's ID, its index, any error message generated during execution, and the identifier of the execution node that provided the error message.
type TransactionResults ¶ added in v0.30.0
type TransactionResults []TransactionResult
TODO(ramtin): add canonical encoding and ID
type TransactionSignature ¶
type TransactionSignature struct { Address Address SignerIndex int KeyIndex uint32 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 Sealed 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
type VersionBeacon ¶ added in v0.30.5
type VersionBeacon struct { VersionBoundaries []VersionBoundary Sequence uint64 }
VersionBeacon represents a service event specifying the required software versions for executing upcoming blocks. It ensures that Execution and Verification Nodes are using consistent versions of Cadence when executing the same blocks.
It contains a VersionBoundaries field, which is an ordered list of VersionBoundary (sorted by VersionBoundary.BlockHeight). While heights are strictly increasing, versions must be equal or greater when compared using semver semantics. It must contain at least one entry. The first entry is for a past block height. The remaining entries are for all future block heights. Future version boundaries can be removed, in which case the emitted event will not contain the removed version boundaries. VersionBeacon is produced by the NodeVersionBeacon smart contract.
Sequence is the event sequence number, which can be used to verify that no event has been skipped by the follower. Every time the smart contract emits a new event, it increments the sequence number by one.
func (*VersionBeacon) EqualTo ¶ added in v0.30.5
func (v *VersionBeacon) EqualTo(other *VersionBeacon) bool
EqualTo returns true if two VersionBeacons are equal. If any of the VersionBeacons has a malformed version, it will return false.
func (*VersionBeacon) ServiceEvent ¶ added in v0.30.5
func (v *VersionBeacon) ServiceEvent() ServiceEvent
func (*VersionBeacon) String ¶ added in v0.32.1
func (v *VersionBeacon) String() string
func (*VersionBeacon) Validate ¶ added in v0.31.0
func (v *VersionBeacon) Validate() error
Validate validates the internal structure of a flow.VersionBeacon. An error with an appropriate message is returned if any validation fails.
type VersionBoundary ¶ added in v0.30.5
VersionBoundary represents a boundary between semver versions. BlockHeight is the first block height that must be run by the given Version (inclusive). Version is a semver string.
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
- dkg.go
- entity.go
- epoch.go
- event.go
- executed_transaction.go
- execution_receipt.go
- execution_result.go
- header.go
- identifier.go
- identifierList.go
- identifier_order.go
- identity.go
- identity_list.go
- identity_order.go
- incorporated_result.go
- incorporated_result_seal.go
- index.go
- ledger.go
- payload.go
- protocol_state.go
- quorum_certificate.go
- resultApproval.go
- role.go
- seal.go
- sealing_segment.go
- service_event.go
- slashable.go
- timeout_certificate.go
- transaction.go
- transaction_result.go
- transaction_timing.go
- version_beacon.go