Documentation ¶
Index ¶
- Constants
- func ContractKey(contractName string) string
- func FlowFeesAddress(chain flow.Chain) flow.Address
- func IsServiceEvent(event cadence.Event, chain flow.ChainID) (bool, error)
- func IsValidAccountKeyHashAlgo(algo hash.HashingAlgorithm) bool
- func IsValidAccountKeySignAlgo(algo crypto.SigningAlgorithm) bool
- func KeyPublicKey(index uint64) string
- func NewAccountFreezer(serviceAddress flow.Address, accounts Accounts, ...) *accountFreezer
- func NewAccountKeyUpdater(tracer *Tracer, meter Meter, accounts Accounts, ...) *accountKeyUpdater
- func NewAccountPublicKey(publicKey *runtime.PublicKey, hashAlgo sema.HashAlgorithm, keyIndex int, ...) (*flow.AccountPublicKey, error)
- func NewContractUpdater(tracer *Tracer, meter Meter, accounts Accounts, ...) *contractUpdater
- func NewContractUpdaterForTesting(accounts Accounts, stubs ContractUpdaterStubs) *contractUpdater
- func NewUUIDGenerator(tracer *Tracer, meter Meter, txnState *state.TransactionState) *uUIDGenerator
- func RegisterSize(address flow.Address, key string, value flow.RegisterValue) int
- func ServiceAddress(chain flow.Chain) flow.Address
- func StorageMBUFixToBytesUInt(result cadence.Value) uint64
- type AccountCreator
- type AccountFreezer
- type AccountInfo
- type AccountKeyReader
- type AccountKeyUpdater
- type AccountStatus
- func (a *AccountStatus) IsAccountFrozen() bool
- func (a *AccountStatus) PublicKeyCount() uint64
- func (a *AccountStatus) SetFrozenFlag(frozen bool)
- func (a *AccountStatus) SetPublicKeyCount(count uint64)
- func (a *AccountStatus) SetStorageIndex(index atree.StorageIndex)
- func (a *AccountStatus) SetStorageUsed(used uint64)
- func (a *AccountStatus) StorageIndex() atree.StorageIndex
- func (a *AccountStatus) StorageUsed() uint64
- func (a *AccountStatus) ToBytes() []byte
- type Accounts
- type AddressGenerator
- type BlockInfo
- type BlockInfoParams
- type Blocks
- type BlocksFinder
- type BootstrapAccountCreator
- type ContractFunctionSpec
- type ContractReader
- func (reader *ContractReader) GetAccountContractCode(address runtime.Address, name string) (code []byte, err error)
- func (reader *ContractReader) GetAccountContractNames(address runtime.Address) ([]string, error)
- func (reader *ContractReader) GetCode(location runtime.Location) ([]byte, error)
- func (reader *ContractReader) ResolveLocation(identifiers []runtime.Identifier, location runtime.Location) ([]runtime.ResolvedLocation, error)
- type ContractUpdater
- type ContractUpdaterParams
- type ContractUpdaterStubs
- type CryptoLibrary
- type Environment
- type EnvironmentParams
- type EventCollection
- func (collection *EventCollection) AppendEvent(event flow.Event, size uint64) error
- func (collection *EventCollection) AppendServiceEvent(event flow.Event, size uint64) error
- func (collection *EventCollection) Events() []flow.Event
- func (collection *EventCollection) ServiceEvents() []flow.Event
- func (collection *EventCollection) TotalByteSize() uint64
- func (collection *EventCollection) TotalEventCounter() uint32
- type EventEmitter
- type EventEmitterParams
- type Meter
- type MetricsReporter
- type NoAccountCreator
- type NoAccountFreezer
- type NoAccountKeyUpdater
- func (NoAccountKeyUpdater) AddAccountKey(address runtime.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (NoAccountKeyUpdater) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error
- func (NoAccountKeyUpdater) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
- func (NoAccountKeyUpdater) RevokeEncodedAccountKey(address runtime.Address, index int) ([]byte, error)
- type NoContractUpdater
- func (NoContractUpdater) Commit() ([]programs.ContractUpdateKey, error)
- func (NoContractUpdater) RemoveAccountContractCode(address runtime.Address, name string) error
- func (NoContractUpdater) Reset()
- func (NoContractUpdater) UpdateAccountContractCode(address runtime.Address, name string, code []byte) error
- type NoEventEmitter
- type NoTransactionInfo
- func (NoTransactionInfo) GetSigningAccounts() ([]runtime.Address, error)
- func (NoTransactionInfo) IsServiceAccountAuthorizer() bool
- func (NoTransactionInfo) LimitAccountStorage() bool
- func (NoTransactionInfo) SigningAccounts() []runtime.Address
- func (NoTransactionInfo) TransactionFeesEnabled() bool
- func (NoTransactionInfo) TxID() flow.Identifier
- func (NoTransactionInfo) TxIndex() uint32
- type NoopBlockFinder
- type NoopMetricsReporter
- type ParseRestrictedAccountCreator
- type ParseRestrictedAccountFreezer
- type ParseRestrictedAccountInfo
- func (info ParseRestrictedAccountInfo) GetAccount(address flow.Address) (*flow.Account, error)
- func (info ParseRestrictedAccountInfo) GetAccountAvailableBalance(address common.Address) (uint64, error)
- func (info ParseRestrictedAccountInfo) GetAccountBalance(address common.Address) (uint64, error)
- func (info ParseRestrictedAccountInfo) GetStorageCapacity(address common.Address) (uint64, error)
- func (info ParseRestrictedAccountInfo) GetStorageUsed(address common.Address) (uint64, error)
- type ParseRestrictedAccountKeyReader
- type ParseRestrictedAccountKeyUpdater
- func (updater ParseRestrictedAccountKeyUpdater) AddAccountKey(address runtime.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (updater ParseRestrictedAccountKeyUpdater) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error
- func (updater ParseRestrictedAccountKeyUpdater) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
- func (updater ParseRestrictedAccountKeyUpdater) RevokeEncodedAccountKey(address runtime.Address, index int) ([]byte, error)
- type ParseRestrictedBlockInfo
- type ParseRestrictedContractUpdater
- func (updater ParseRestrictedContractUpdater) Commit() ([]programs.ContractUpdateKey, error)
- func (updater ParseRestrictedContractUpdater) RemoveAccountContractCode(address runtime.Address, name string) error
- func (updater ParseRestrictedContractUpdater) Reset()
- func (updater ParseRestrictedContractUpdater) UpdateAccountContractCode(address runtime.Address, name string, code []byte) error
- type ParseRestrictedCryptoLibrary
- func (lib ParseRestrictedCryptoLibrary) BLSAggregatePublicKeys(keys []*runtime.PublicKey) (*runtime.PublicKey, error)
- func (lib ParseRestrictedCryptoLibrary) BLSAggregateSignatures(sigs [][]byte) ([]byte, error)
- func (lib ParseRestrictedCryptoLibrary) BLSVerifyPOP(pk *runtime.PublicKey, sig []byte) (bool, error)
- func (lib ParseRestrictedCryptoLibrary) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
- func (lib ParseRestrictedCryptoLibrary) ValidatePublicKey(pk *runtime.PublicKey) error
- func (lib ParseRestrictedCryptoLibrary) VerifySignature(signature []byte, tag string, signedData []byte, publicKey []byte, ...) (bool, error)
- type ParseRestrictedEventEmitter
- type ParseRestrictedTransactionInfo
- func (info ParseRestrictedTransactionInfo) GetSigningAccounts() ([]runtime.Address, error)
- func (info ParseRestrictedTransactionInfo) IsServiceAccountAuthorizer() bool
- func (info ParseRestrictedTransactionInfo) LimitAccountStorage() bool
- func (info ParseRestrictedTransactionInfo) SigningAccounts() []runtime.Address
- func (info ParseRestrictedTransactionInfo) TransactionFeesEnabled() bool
- func (info ParseRestrictedTransactionInfo) TxID() flow.Identifier
- func (info ParseRestrictedTransactionInfo) TxIndex() uint32
- type ParseRestrictedUUIDGenerator
- type ParseRestrictedUnsafeRandomGenerator
- type ParseRestrictedValueStore
- func (store ParseRestrictedValueStore) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)
- func (store ParseRestrictedValueStore) GetValue(owner []byte, key []byte) ([]byte, error)
- func (store ParseRestrictedValueStore) SetValue(owner []byte, key []byte, value []byte) error
- func (store ParseRestrictedValueStore) ValueExists(owner []byte, key []byte) (bool, error)
- type ProgramLogger
- func (logger *ProgramLogger) ImplementationDebugLog(message string) error
- func (logger *ProgramLogger) Logger() *zerolog.Logger
- func (logger *ProgramLogger) Logs() []string
- func (logger *ProgramLogger) ProgramChecked(location common.Location, duration time.Duration)
- func (logger *ProgramLogger) ProgramInterpreted(location common.Location, duration time.Duration)
- func (logger *ProgramLogger) ProgramLog(message string) error
- func (logger *ProgramLogger) ProgramParsed(location common.Location, duration time.Duration)
- func (logger *ProgramLogger) RecordTrace(operation string, location common.Location, duration time.Duration, ...)
- func (logger *ProgramLogger) ValueDecoded(duration time.Duration)
- func (logger *ProgramLogger) ValueEncoded(duration time.Duration)
- type ProgramLoggerParams
- type Programs
- type Runtime
- type RuntimeParams
- type StatefulAccounts
- func (a *StatefulAccounts) AllocateStorageIndex(address flow.Address) (atree.StorageIndex, error)
- func (a *StatefulAccounts) AppendPublicKey(address flow.Address, publicKey flow.AccountPublicKey) error
- func (a *StatefulAccounts) CheckAccountNotFrozen(address flow.Address) error
- func (a *StatefulAccounts) ContractExists(contractName string, address flow.Address) (bool, error)
- func (a *StatefulAccounts) Create(publicKeys []flow.AccountPublicKey, newAddress flow.Address) error
- func (a *StatefulAccounts) DeleteContract(contractName string, address flow.Address) error
- func (a *StatefulAccounts) Exists(address flow.Address) (bool, error)
- func (a *StatefulAccounts) Get(address flow.Address) (*flow.Account, error)
- func (a *StatefulAccounts) GetAccountFrozen(address flow.Address) (bool, error)
- func (a *StatefulAccounts) GetContract(contractName string, address flow.Address) ([]byte, error)
- func (a *StatefulAccounts) GetContractNames(address flow.Address) ([]string, error)
- func (a *StatefulAccounts) GetPublicKey(address flow.Address, keyIndex uint64) (flow.AccountPublicKey, error)
- func (a *StatefulAccounts) GetPublicKeyCount(address flow.Address) (uint64, error)
- func (a *StatefulAccounts) GetPublicKeys(address flow.Address) (publicKeys []flow.AccountPublicKey, err error)
- func (a *StatefulAccounts) GetStorageUsed(address flow.Address) (uint64, error)
- func (a *StatefulAccounts) GetValue(address flow.Address, key string) (flow.RegisterValue, error)
- func (a *StatefulAccounts) SetAccountFrozen(address flow.Address, frozen bool) error
- func (a *StatefulAccounts) SetAllPublicKeys(address flow.Address, publicKeys []flow.AccountPublicKey) error
- func (a *StatefulAccounts) SetContract(contractName string, address flow.Address, contract []byte) error
- func (a *StatefulAccounts) SetPublicKey(address flow.Address, keyIndex uint64, publicKey flow.AccountPublicKey) (encodedPublicKey []byte, err error)
- func (a *StatefulAccounts) SetValue(address flow.Address, key string, value flow.RegisterValue) error
- func (a *StatefulAccounts) TouchContract(contractName string, address flow.Address)
- type SystemContracts
- func (sys *SystemContracts) AccountAvailableBalance(address common.Address) (cadence.Value, error)
- func (sys *SystemContracts) AccountBalance(address common.Address) (cadence.Value, error)
- func (sys *SystemContracts) AccountStorageCapacity(address common.Address) (cadence.Value, error)
- func (sys *SystemContracts) AccountsStorageCapacity(addresses []common.Address) (cadence.Value, error)
- func (sys *SystemContracts) DeductTransactionFees(payer flow.Address, inclusionEffort uint64, executionEffort uint64) (cadence.Value, error)
- func (sys *SystemContracts) Invoke(spec ContractFunctionSpec, arguments []cadence.Value) (cadence.Value, error)
- func (sys *SystemContracts) SetupNewAccount(flowAddress flow.Address, payer common.Address) (cadence.Value, error)
- func (sys *SystemContracts) UseContractAuditVoucher(address common.Address, code string) (bool, error)
- type Tracer
- type TracerParams
- type TransactionInfo
- type TransactionInfoParams
- type TransactionPrograms
- type UUIDGenerator
- type UnsafeRandomGenerator
- type ValueStore
Constants ¶
const ( FungibleTokenAccountIndex = 2 FlowTokenAccountIndex = 3 FlowFeesAccountIndex = 4 )
const ( ComputationKindHash common.ComputationKind ComputationKindVerifySignature ComputationKindAddAccountKey ComputationKindAddEncodedAccountKey ComputationKindAllocateStorageIndex ComputationKindCreateAccount ComputationKindEmitEvent ComputationKindGenerateUUID ComputationKindGetAccountAvailableBalance ComputationKindGetAccountBalance ComputationKindGetAccountContractCode ComputationKindGetAccountContractNames ComputationKindGetAccountKey ComputationKindGetBlockAtHeight ComputationKindGetCode ComputationKindGetCurrentBlockHeight ComputationKindGetProgram ComputationKindGetStorageCapacity ComputationKindGetStorageUsed ComputationKindGetValue ComputationKindRemoveAccountContractCode ComputationKindResolveLocation ComputationKindRevokeAccountKey ComputationKindRevokeEncodedAccountKey ComputationKindSetProgram ComputationKindSetValue ComputationKindUpdateAccountContractCode ComputationKindValidatePublicKey ComputationKindValueExists )
const (
DefaultEventCollectionByteSizeLimit = 256_000 // 256KB
)
const (
MaxPublicKeyCount = math.MaxUint64
)
Variables ¶
This section is empty.
Functions ¶
func ContractKey ¶
func IsServiceEvent ¶
IsServiceEvent determines whether or not an emitted Cadence event is considered a service event for the given chain.
func IsValidAccountKeyHashAlgo ¶
func IsValidAccountKeyHashAlgo(algo hash.HashingAlgorithm) bool
func IsValidAccountKeySignAlgo ¶
func IsValidAccountKeySignAlgo(algo crypto.SigningAlgorithm) bool
func KeyPublicKey ¶
func NewAccountFreezer ¶
func NewAccountFreezer( serviceAddress flow.Address, accounts Accounts, transactionInfo TransactionInfo, ) *accountFreezer
func NewAccountKeyUpdater ¶
func NewAccountKeyUpdater( tracer *Tracer, meter Meter, accounts Accounts, txnState *state.TransactionState, env Environment, ) *accountKeyUpdater
func NewAccountPublicKey ¶
func NewAccountPublicKey(publicKey *runtime.PublicKey, hashAlgo sema.HashAlgorithm, keyIndex int, weight int, ) ( *flow.AccountPublicKey, error, )
NewAccountPublicKey construct an account public key given a runtime public key.
func NewContractUpdater ¶
func NewContractUpdater( tracer *Tracer, meter Meter, accounts Accounts, transactionInfo TransactionInfo, chain flow.Chain, params ContractUpdaterParams, logger *ProgramLogger, systemContracts *SystemContracts, runtime *Runtime, ) *contractUpdater
func NewContractUpdaterForTesting ¶
func NewContractUpdaterForTesting( accounts Accounts, stubs ContractUpdaterStubs, ) *contractUpdater
func NewUUIDGenerator ¶
func NewUUIDGenerator( tracer *Tracer, meter Meter, txnState *state.TransactionState, ) *uUIDGenerator
func RegisterSize ¶
func StorageMBUFixToBytesUInt ¶
StorageMBUFixToBytesUInt converts the return type of storage capacity which is a UFix64 with the unit of megabytes to UInt with the unit of bytes
Types ¶
type AccountCreator ¶
func NewAccountCreator ¶
func NewAccountCreator( txnState *state.TransactionState, chain flow.Chain, accounts Accounts, isServiceAccountEnabled bool, tracer *Tracer, meter Meter, metrics MetricsReporter, systemContracts *SystemContracts, ) AccountCreator
func NewParseRestrictedAccountCreator ¶
func NewParseRestrictedAccountCreator( txnState *state.TransactionState, creator AccountCreator, ) AccountCreator
type AccountFreezer ¶
type AccountFreezer interface { // Note that the script variant will return OperationNotSupportedError. SetAccountFrozen(address common.Address, frozen bool) error FrozenAccounts() []common.Address Reset() }
AccountFreezer disables accounts.
Note that scripts cannot freeze accounts, but must expose the API in compliance with the environment interface.
func NewParseRestrictedAccountFreezer ¶
func NewParseRestrictedAccountFreezer( txnState *state.TransactionState, impl AccountFreezer, ) AccountFreezer
type AccountInfo ¶
type AccountInfo interface { GetStorageUsed(address common.Address) (uint64, error) GetStorageCapacity(address common.Address) (uint64, error) GetAccountBalance(address common.Address) (uint64, error) GetAccountAvailableBalance(address common.Address) (uint64, error) GetAccount(address flow.Address) (*flow.Account, error) }
AccountInfo exposes various account balance and storage statistics.
func NewAccountInfo ¶
func NewAccountInfo( tracer *Tracer, meter Meter, accounts Accounts, systemContracts *SystemContracts, serviceAccountEnabled bool, ) AccountInfo
func NewParseRestrictedAccountInfo ¶
func NewParseRestrictedAccountInfo( txnState *state.TransactionState, impl AccountInfo, ) AccountInfo
type AccountKeyReader ¶
type AccountKeyReader interface { // GetAccountKey retrieves a public key by index from an existing account. // // This function returns a nil key with no errors, if a key doesn't exist at // the given index. An error is returned if the specified account does not // exist, the provided index is not valid, or if the key retrieval fails. GetAccountKey( address runtime.Address, keyIndex int, ) ( *runtime.AccountKey, error, ) }
AccountKeyReader provide read access to account keys.
func NewAccountKeyReader ¶
func NewAccountKeyReader( tracer *Tracer, meter Meter, accounts Accounts, ) AccountKeyReader
func NewParseRestrictedAccountKeyReader ¶ added in v0.28.1
func NewParseRestrictedAccountKeyReader( txnState *state.TransactionState, impl AccountKeyReader, ) AccountKeyReader
type AccountKeyUpdater ¶
type AccountKeyUpdater interface { // AddEncodedAccountKey adds an encoded public key to an existing account. // // This function returns an error if the specified account does not exist or // if the key insertion fails. // // Note that the script variant will return OperationNotSupportedError. AddEncodedAccountKey(address runtime.Address, publicKey []byte) error // RevokeEncodedAccountKey revokes a public key by index from an existing // account. // // This function returns an error if the specified account does not exist, // the provided key is invalid, or if key revoking fails. // // Note that the script variant will return OperationNotSupportedError. RevokeEncodedAccountKey( address runtime.Address, index int, ) ( []byte, error, ) // AddAccountKey adds a public key to an existing account. // // This function returns an error if the specified account does not exist or // if the key insertion fails. // // Note that the script variant will return OperationNotSupportedError. AddAccountKey( address runtime.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, ) // RevokeAccountKey revokes a public key by index from an existing account, // and returns the revoked key. // // This function returns a nil key with no errors, if a key doesn't exist // at the given index. An error is returned if the specified account does // not exist, the provided index is not valid, or if the key revoking // fails. // // Note that the script variant will return OperationNotSupportedError. RevokeAccountKey( address runtime.Address, keyIndex int, ) ( *runtime.AccountKey, error, ) }
AccountKeyUpdater handles all account keys modification.
Note that scripts cannot modify account keys, but must expose the API in compliance with the runtime environment interface.
type AccountStatus ¶
type AccountStatus [accountStatusSize]byte
AccountStatus holds meta information about an account
currently modelled as a byte array with on-demand encoding/decoding of sub arrays the first byte captures flags (e.g. frozen) the next 8 bytes (big-endian) captures storage used by an account the next 8 bytes (big-endian) captures the storage index of an account and the last 8 bytes (big-endian) captures the number of public keys stored on this account
func AccountStatusFromBytes ¶
func AccountStatusFromBytes(inp []byte) (*AccountStatus, error)
AccountStatusFromBytes constructs an AccountStatus from the given byte slice
func NewAccountStatus ¶
func NewAccountStatus() *AccountStatus
NewAccountStatus returns a new AccountStatus sets the storage index to the init value
func (*AccountStatus) IsAccountFrozen ¶
func (a *AccountStatus) IsAccountFrozen() bool
IsAccountFrozen returns true if account's frozen flag is set
func (*AccountStatus) PublicKeyCount ¶
func (a *AccountStatus) PublicKeyCount() uint64
PublicKeyCount returns the public key count of the account
func (*AccountStatus) SetFrozenFlag ¶
func (a *AccountStatus) SetFrozenFlag(frozen bool)
SetFrozenFlag sets the frozen flag
func (*AccountStatus) SetPublicKeyCount ¶
func (a *AccountStatus) SetPublicKeyCount(count uint64)
SetPublicKeyCount updates the public key count of the account
func (*AccountStatus) SetStorageIndex ¶
func (a *AccountStatus) SetStorageIndex(index atree.StorageIndex)
SetStorageIndex updates the storage index of the account
func (*AccountStatus) SetStorageUsed ¶
func (a *AccountStatus) SetStorageUsed(used uint64)
SetStorageUsed updates the storage used by the account
func (*AccountStatus) StorageIndex ¶
func (a *AccountStatus) StorageIndex() atree.StorageIndex
StorageIndex returns the storage index of the account
func (*AccountStatus) StorageUsed ¶
func (a *AccountStatus) StorageUsed() uint64
StorageUsed returns the storage used by the account
func (*AccountStatus) ToBytes ¶
func (a *AccountStatus) ToBytes() []byte
ToBytes converts AccountStatus to a byte slice
this has been kept this way in case one day we decided to move on to use an struct to represent account status.
type Accounts ¶
type Accounts interface { Exists(address flow.Address) (bool, error) Get(address flow.Address) (*flow.Account, error) GetPublicKeyCount(address flow.Address) (uint64, error) AppendPublicKey(address flow.Address, key flow.AccountPublicKey) error GetPublicKey(address flow.Address, keyIndex uint64) (flow.AccountPublicKey, error) SetPublicKey(address flow.Address, keyIndex uint64, publicKey flow.AccountPublicKey) ([]byte, error) GetContractNames(address flow.Address) ([]string, error) GetContract(contractName string, address flow.Address) ([]byte, error) ContractExists(contractName string, address flow.Address) (bool, error) SetContract(contractName string, address flow.Address, contract []byte) error DeleteContract(contractName string, address flow.Address) error Create(publicKeys []flow.AccountPublicKey, newAddress flow.Address) error GetValue(address flow.Address, key string) (flow.RegisterValue, error) CheckAccountNotFrozen(address flow.Address) error GetStorageUsed(address flow.Address) (uint64, error) SetValue(address flow.Address, key string, value flow.RegisterValue) error AllocateStorageIndex(address flow.Address) (atree.StorageIndex, error) SetAccountFrozen(address flow.Address, frozen bool) error }
type AddressGenerator ¶
type AddressGenerator interface { Bytes() []byte NextAddress() (flow.Address, error) CurrentAddress() flow.Address AddressCount() uint64 }
func NewAddressGenerator ¶
func NewAddressGenerator( txnState *state.TransactionState, chain flow.Chain, ) AddressGenerator
type BlockInfo ¶
type BlockInfo interface { // GetCurrentBlockHeight returns the current block height. GetCurrentBlockHeight() (uint64, error) // GetBlockAtHeight returns the block at the given height. GetBlockAtHeight( height uint64, ) ( runtime.Block, bool, error, ) }
func NewBlockInfo ¶
func NewParseRestrictedBlockInfo ¶ added in v0.28.1
func NewParseRestrictedBlockInfo( txnState *state.TransactionState, impl BlockInfo, ) BlockInfo
type BlockInfoParams ¶
func DefaultBlockInfoParams ¶
func DefaultBlockInfoParams() BlockInfoParams
type Blocks ¶
type Blocks interface { // ByHeight returns the block at the given height in the chain ending in `header` (or finalized // if `header` is nil). This enables querying un-finalized blocks by height with respect to the // chain defined by the block we are executing. ByHeightFrom(height uint64, header *flow.Header) (*flow.Header, error) }
func NewBlockFinder ¶
NewBlockFinder constructs a new block finder
type BlocksFinder ¶
type BlocksFinder struct {
// contains filtered or unexported fields
}
BlocksFinder finds blocks and return block headers
func (*BlocksFinder) ByHeightFrom ¶
ByHeightFrom returns the block header by height.
type BootstrapAccountCreator ¶
type BootstrapAccountCreator interface { CreateBootstrapAccount( publicKeys []flow.AccountPublicKey, ) ( flow.Address, error, ) }
func NewBootstrapAccountCreator ¶
func NewBootstrapAccountCreator( txnState *state.TransactionState, chain flow.Chain, accounts Accounts, ) BootstrapAccountCreator
type ContractFunctionSpec ¶
type ContractFunctionSpec struct { AddressFromChain func(flow.Chain) flow.Address LocationName string FunctionName string ArgumentTypes []sema.Type }
ContractFunctionSpec specify all the information, except the function's address and arguments, needed to invoke the contract function.
type ContractReader ¶
type ContractReader struct {
// contains filtered or unexported fields
}
ContractReader provide read access to contracts.
func NewContractReader ¶
func NewContractReader( tracer *Tracer, meter Meter, accounts Accounts, ) *ContractReader
func (*ContractReader) GetAccountContractCode ¶
func (*ContractReader) GetAccountContractNames ¶
func (reader *ContractReader) GetAccountContractNames( address runtime.Address, ) ( []string, error, )
func (*ContractReader) GetCode ¶
func (reader *ContractReader) GetCode( location runtime.Location, ) ( []byte, error, )
func (*ContractReader) ResolveLocation ¶
func (reader *ContractReader) ResolveLocation( identifiers []runtime.Identifier, location runtime.Location, ) ( []runtime.ResolvedLocation, error, )
type ContractUpdater ¶
type ContractUpdater interface { // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. UpdateAccountContractCode( address runtime.Address, name string, code []byte, ) error // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. RemoveAccountContractCode(address runtime.Address, name string) error Commit() ([]programs.ContractUpdateKey, error) Reset() }
ContractUpdater handles all smart contracts modification. It also captures all changes as deltas and only commit them when called so smart contract updates can be delayed until end of the tx execution.
Note that scripts cannot modify smart contracts, but must expose the API in compliance with the runtime environment interface.
type ContractUpdaterParams ¶
type ContractUpdaterParams struct { // Depricated: RestrictedDeploymentEnabled is deprecated use // SetIsContractDeploymentRestrictedTransaction instead. // Can be removed after all networks are migrated to // SetIsContractDeploymentRestrictedTransaction RestrictContractDeployment bool RestrictContractRemoval bool }
func DefaultContractUpdaterParams ¶
func DefaultContractUpdaterParams() ContractUpdaterParams
type ContractUpdaterStubs ¶
type ContractUpdaterStubs interface { RestrictedDeploymentEnabled() bool RestrictedRemovalEnabled() bool GetAuthorizedAccounts(path cadence.Path) []common.Address UseContractAuditVoucher(address runtime.Address, code []byte) (bool, error) }
Expose stub interface for testing.
type CryptoLibrary ¶
type CryptoLibrary interface { Hash( data []byte, tag string, hashAlgorithm runtime.HashAlgorithm, ) ( []byte, error, ) VerifySignature( signature []byte, tag string, signedData []byte, publicKey []byte, signatureAlgorithm runtime.SignatureAlgorithm, hashAlgorithm runtime.HashAlgorithm, ) ( bool, error, ) ValidatePublicKey(pk *runtime.PublicKey) error BLSVerifyPOP( pk *runtime.PublicKey, sig []byte, ) ( bool, error, ) BLSAggregateSignatures(sigs [][]byte) ([]byte, error) BLSAggregatePublicKeys( keys []*runtime.PublicKey, ) ( *runtime.PublicKey, error, ) }
func NewCryptoLibrary ¶
func NewCryptoLibrary(tracer *Tracer, meter Meter) CryptoLibrary
func NewParseRestrictedCryptoLibrary ¶ added in v0.28.1
func NewParseRestrictedCryptoLibrary( txnState *state.TransactionState, impl CryptoLibrary, ) CryptoLibrary
type Environment ¶
type Environment interface { runtime.Interface // Tracer StartSpanFromRoot(name trace.SpanName) otelTrace.Span Meter // Runtime BorrowCadenceRuntime() *reusableRuntime.ReusableCadenceRuntime ReturnCadenceRuntime(*reusableRuntime.ReusableCadenceRuntime) TransactionInfo // ProgramLogger Logger() *zerolog.Logger Logs() []string // EventEmitter Events() []flow.Event ServiceEvents() []flow.Event // SystemContracts AccountsStorageCapacity(addresses []common.Address) (cadence.Value, error) DeductTransactionFees( payer flow.Address, inclusionEffort uint64, executionEffort uint64, ) ( cadence.Value, error, ) // AccountInfo GetAccount(address flow.Address) (*flow.Account, error) AccountFreezer // FlushPendingUpdates flushes pending updates from the stateful environment // modules (i.e., ContractUpdater) to the state transaction, and return // corresponding modified sets invalidator. FlushPendingUpdates() ( programs.ModifiedSetsInvalidator, error, ) // Reset resets all stateful environment modules (e.g., ContractUpdater, // EventEmitter, AccountFreezer) to initial state. Reset() }
Environment implements the accounts business logic and exposes cadence runtime interface methods for the runtime.
func NewScriptEnvironment ¶
func NewScriptEnvironment( ctx context.Context, params EnvironmentParams, txnState *state.TransactionState, programs TransactionPrograms, ) Environment
func NewTransactionEnvironment ¶
func NewTransactionEnvironment( params EnvironmentParams, txnState *state.TransactionState, programs TransactionPrograms, ) Environment
type EnvironmentParams ¶
type EnvironmentParams struct { Chain flow.Chain // NOTE: The ServiceAccountEnabled option is used by the playground // https://github.com/onflow/flow-playground-api/blob/1ad967055f31db8f1ce88e008960e5fc14a9fbd1/compute/computer.go#L76 ServiceAccountEnabled bool RuntimeParams TracerParams ProgramLoggerParams EventEmitterParams BlockInfoParams TransactionInfoParams ContractUpdaterParams }
func DefaultEnvironmentParams ¶
func DefaultEnvironmentParams() EnvironmentParams
type EventCollection ¶
type EventCollection struct {
// contains filtered or unexported fields
}
func NewEventCollection ¶
func NewEventCollection(meter Meter) *EventCollection
func (*EventCollection) AppendEvent ¶
func (collection *EventCollection) AppendEvent(event flow.Event, size uint64) error
func (*EventCollection) AppendServiceEvent ¶
func (collection *EventCollection) AppendServiceEvent( event flow.Event, size uint64, ) error
func (*EventCollection) Events ¶
func (collection *EventCollection) Events() []flow.Event
func (*EventCollection) ServiceEvents ¶
func (collection *EventCollection) ServiceEvents() []flow.Event
func (*EventCollection) TotalByteSize ¶
func (collection *EventCollection) TotalByteSize() uint64
func (*EventCollection) TotalEventCounter ¶
func (collection *EventCollection) TotalEventCounter() uint32
type EventEmitter ¶
type EventEmitter interface { // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. EmitEvent(event cadence.Event) error Events() []flow.Event ServiceEvents() []flow.Event Reset() }
EventEmitter collect events, separates out service events, and enforces event size limits.
Note that scripts do not emit events, but must expose the API in compliance with the runtime environment interface.
func NewEventEmitter ¶
func NewEventEmitter( tracer *Tracer, meter Meter, chain flow.Chain, txInfo TransactionInfoParams, params EventEmitterParams, ) EventEmitter
NewEventEmitter constructs a new eventEmitter
func NewParseRestrictedEventEmitter ¶ added in v0.28.1
func NewParseRestrictedEventEmitter( txnState *state.TransactionState, impl EventEmitter, ) EventEmitter
type EventEmitterParams ¶
type EventEmitterParams struct { ServiceEventCollectionEnabled bool EventCollectionByteSizeLimit uint64 }
func DefaultEventEmitterParams ¶
func DefaultEventEmitterParams() EventEmitterParams
type Meter ¶
type Meter interface { MeterComputation(common.ComputationKind, uint) error ComputationUsed() uint64 MeterMemory(usage common.MemoryUsage) error MemoryEstimate() uint64 MeterEmittedEvent(byteSize uint64) error TotalEmittedEventBytes() uint64 }
func NewCancellableMeter ¶
func NewCancellableMeter( ctx context.Context, txnState *state.TransactionState, ) Meter
func NewMeter ¶
func NewMeter(txnState *state.TransactionState) Meter
type MetricsReporter ¶
type MetricsReporter interface { RuntimeTransactionParsed(time.Duration) RuntimeTransactionChecked(time.Duration) RuntimeTransactionInterpreted(time.Duration) RuntimeSetNumberOfAccounts(count uint64) }
MetricsReporter captures and reports metrics to back to the execution environment it is a setup passed to the context.
type NoAccountFreezer ¶
type NoAccountFreezer struct{}
func (NoAccountFreezer) FrozenAccounts ¶
func (NoAccountFreezer) FrozenAccounts() []common.Address
func (NoAccountFreezer) Reset ¶
func (NoAccountFreezer) Reset()
func (NoAccountFreezer) SetAccountFrozen ¶
func (NoAccountFreezer) SetAccountFrozen(_ common.Address, _ bool) error
type NoAccountKeyUpdater ¶
type NoAccountKeyUpdater struct{}
func (NoAccountKeyUpdater) AddAccountKey ¶
func (NoAccountKeyUpdater) AddAccountKey( address runtime.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, )
func (NoAccountKeyUpdater) AddEncodedAccountKey ¶
func (NoAccountKeyUpdater) AddEncodedAccountKey( address runtime.Address, publicKey []byte, ) error
func (NoAccountKeyUpdater) RevokeAccountKey ¶
func (NoAccountKeyUpdater) RevokeAccountKey( address runtime.Address, keyIndex int, ) ( *runtime.AccountKey, error, )
func (NoAccountKeyUpdater) RevokeEncodedAccountKey ¶
type NoContractUpdater ¶
type NoContractUpdater struct{}
func (NoContractUpdater) Commit ¶
func (NoContractUpdater) Commit() ([]programs.ContractUpdateKey, error)
func (NoContractUpdater) RemoveAccountContractCode ¶
func (NoContractUpdater) RemoveAccountContractCode( address runtime.Address, name string, ) error
func (NoContractUpdater) Reset ¶
func (NoContractUpdater) Reset()
func (NoContractUpdater) UpdateAccountContractCode ¶
type NoEventEmitter ¶
type NoEventEmitter struct{}
NoEventEmitter is usually used in the environment for script execution, where emitting an event does nothing.
func (NoEventEmitter) Events ¶
func (NoEventEmitter) Events() []flow.Event
func (NoEventEmitter) Reset ¶
func (NoEventEmitter) Reset()
func (NoEventEmitter) ServiceEvents ¶
func (NoEventEmitter) ServiceEvents() []flow.Event
type NoTransactionInfo ¶
type NoTransactionInfo struct { }
Scripts have no associated transaction information.
func (NoTransactionInfo) GetSigningAccounts ¶
func (NoTransactionInfo) GetSigningAccounts() ([]runtime.Address, error)
func (NoTransactionInfo) IsServiceAccountAuthorizer ¶
func (NoTransactionInfo) IsServiceAccountAuthorizer() bool
func (NoTransactionInfo) LimitAccountStorage ¶
func (NoTransactionInfo) LimitAccountStorage() bool
func (NoTransactionInfo) SigningAccounts ¶
func (NoTransactionInfo) SigningAccounts() []runtime.Address
func (NoTransactionInfo) TransactionFeesEnabled ¶
func (NoTransactionInfo) TransactionFeesEnabled() bool
func (NoTransactionInfo) TxID ¶
func (NoTransactionInfo) TxID() flow.Identifier
func (NoTransactionInfo) TxIndex ¶
func (NoTransactionInfo) TxIndex() uint32
type NoopBlockFinder ¶
type NoopBlockFinder struct{}
NoopBlockFinder implements the Blocks interface. It is used in the bootstrapping process.
func (NoopBlockFinder) ByHeightFrom ¶
type NoopMetricsReporter ¶
type NoopMetricsReporter struct{}
NoopMetricsReporter is a MetricReporter that does nothing.
func (NoopMetricsReporter) RuntimeSetNumberOfAccounts ¶
func (NoopMetricsReporter) RuntimeSetNumberOfAccounts(count uint64)
RuntimeSetNumberOfAccounts is a noop
func (NoopMetricsReporter) RuntimeTransactionChecked ¶
func (NoopMetricsReporter) RuntimeTransactionChecked(time.Duration)
RuntimeTransactionChecked is a noop
func (NoopMetricsReporter) RuntimeTransactionInterpreted ¶
func (NoopMetricsReporter) RuntimeTransactionInterpreted(time.Duration)
RuntimeTransactionInterpreted is a noop
func (NoopMetricsReporter) RuntimeTransactionParsed ¶
func (NoopMetricsReporter) RuntimeTransactionParsed(time.Duration)
RuntimeTransactionParsed is a noop
type ParseRestrictedAccountCreator ¶
type ParseRestrictedAccountCreator struct {
// contains filtered or unexported fields
}
This ensures cadence can't access unexpected operations while parsing programs.
func (ParseRestrictedAccountCreator) CreateAccount ¶
type ParseRestrictedAccountFreezer ¶
type ParseRestrictedAccountFreezer struct {
// contains filtered or unexported fields
}
func (ParseRestrictedAccountFreezer) FrozenAccounts ¶
func (freezer ParseRestrictedAccountFreezer) FrozenAccounts() []common.Address
func (ParseRestrictedAccountFreezer) Reset ¶
func (freezer ParseRestrictedAccountFreezer) Reset()
func (ParseRestrictedAccountFreezer) SetAccountFrozen ¶
func (freezer ParseRestrictedAccountFreezer) SetAccountFrozen( address common.Address, frozen bool, ) error
type ParseRestrictedAccountInfo ¶
type ParseRestrictedAccountInfo struct {
// contains filtered or unexported fields
}
func (ParseRestrictedAccountInfo) GetAccount ¶
func (ParseRestrictedAccountInfo) GetAccountAvailableBalance ¶
func (info ParseRestrictedAccountInfo) GetAccountAvailableBalance( address common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountInfo) GetAccountBalance ¶
func (info ParseRestrictedAccountInfo) GetAccountBalance( address common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountInfo) GetStorageCapacity ¶
func (info ParseRestrictedAccountInfo) GetStorageCapacity( address common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountInfo) GetStorageUsed ¶
func (info ParseRestrictedAccountInfo) GetStorageUsed( address common.Address, ) ( uint64, error, )
type ParseRestrictedAccountKeyReader ¶ added in v0.28.1
type ParseRestrictedAccountKeyReader struct {
// contains filtered or unexported fields
}
func (ParseRestrictedAccountKeyReader) GetAccountKey ¶ added in v0.28.1
func (reader ParseRestrictedAccountKeyReader) GetAccountKey( address runtime.Address, keyIndex int, ) ( *runtime.AccountKey, error, )
type ParseRestrictedAccountKeyUpdater ¶
type ParseRestrictedAccountKeyUpdater struct {
// contains filtered or unexported fields
}
func NewParseRestrictedAccountKeyUpdater ¶
func NewParseRestrictedAccountKeyUpdater( txnState *state.TransactionState, impl AccountKeyUpdater, ) ParseRestrictedAccountKeyUpdater
func (ParseRestrictedAccountKeyUpdater) AddAccountKey ¶
func (updater ParseRestrictedAccountKeyUpdater) AddAccountKey( address runtime.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, )
func (ParseRestrictedAccountKeyUpdater) AddEncodedAccountKey ¶
func (updater ParseRestrictedAccountKeyUpdater) AddEncodedAccountKey( address runtime.Address, publicKey []byte, ) error
func (ParseRestrictedAccountKeyUpdater) RevokeAccountKey ¶
func (updater ParseRestrictedAccountKeyUpdater) RevokeAccountKey( address runtime.Address, keyIndex int, ) ( *runtime.AccountKey, error, )
func (ParseRestrictedAccountKeyUpdater) RevokeEncodedAccountKey ¶
type ParseRestrictedBlockInfo ¶ added in v0.28.1
type ParseRestrictedBlockInfo struct {
// contains filtered or unexported fields
}
func (ParseRestrictedBlockInfo) GetBlockAtHeight ¶ added in v0.28.1
func (ParseRestrictedBlockInfo) GetCurrentBlockHeight ¶ added in v0.28.1
func (info ParseRestrictedBlockInfo) GetCurrentBlockHeight() (uint64, error)
type ParseRestrictedContractUpdater ¶
type ParseRestrictedContractUpdater struct {
// contains filtered or unexported fields
}
func NewParseRestrictedContractUpdater ¶
func NewParseRestrictedContractUpdater( txnState *state.TransactionState, impl ContractUpdater, ) ParseRestrictedContractUpdater
func (ParseRestrictedContractUpdater) Commit ¶
func (updater ParseRestrictedContractUpdater) Commit() ( []programs.ContractUpdateKey, error, )
func (ParseRestrictedContractUpdater) RemoveAccountContractCode ¶
func (updater ParseRestrictedContractUpdater) RemoveAccountContractCode( address runtime.Address, name string, ) error
func (ParseRestrictedContractUpdater) Reset ¶
func (updater ParseRestrictedContractUpdater) Reset()
func (ParseRestrictedContractUpdater) UpdateAccountContractCode ¶
type ParseRestrictedCryptoLibrary ¶ added in v0.28.1
type ParseRestrictedCryptoLibrary struct {
// contains filtered or unexported fields
}
func (ParseRestrictedCryptoLibrary) BLSAggregatePublicKeys ¶ added in v0.28.1
func (ParseRestrictedCryptoLibrary) BLSAggregateSignatures ¶ added in v0.28.1
func (lib ParseRestrictedCryptoLibrary) BLSAggregateSignatures( sigs [][]byte, ) ( []byte, error, )
func (ParseRestrictedCryptoLibrary) BLSVerifyPOP ¶ added in v0.28.1
func (ParseRestrictedCryptoLibrary) Hash ¶ added in v0.28.1
func (lib ParseRestrictedCryptoLibrary) Hash( data []byte, tag string, hashAlgorithm runtime.HashAlgorithm, ) ( []byte, error, )
func (ParseRestrictedCryptoLibrary) ValidatePublicKey ¶ added in v0.28.1
func (lib ParseRestrictedCryptoLibrary) ValidatePublicKey( pk *runtime.PublicKey, ) error
func (ParseRestrictedCryptoLibrary) VerifySignature ¶ added in v0.28.1
func (lib ParseRestrictedCryptoLibrary) VerifySignature( signature []byte, tag string, signedData []byte, publicKey []byte, signatureAlgorithm runtime.SignatureAlgorithm, hashAlgorithm runtime.HashAlgorithm, ) ( bool, error, )
type ParseRestrictedEventEmitter ¶ added in v0.28.1
type ParseRestrictedEventEmitter struct {
// contains filtered or unexported fields
}
func (ParseRestrictedEventEmitter) EmitEvent ¶ added in v0.28.1
func (emitter ParseRestrictedEventEmitter) EmitEvent(event cadence.Event) error
func (ParseRestrictedEventEmitter) Events ¶ added in v0.28.1
func (emitter ParseRestrictedEventEmitter) Events() []flow.Event
func (ParseRestrictedEventEmitter) Reset ¶ added in v0.28.1
func (emitter ParseRestrictedEventEmitter) Reset()
func (ParseRestrictedEventEmitter) ServiceEvents ¶ added in v0.28.1
func (emitter ParseRestrictedEventEmitter) ServiceEvents() []flow.Event
type ParseRestrictedTransactionInfo ¶
type ParseRestrictedTransactionInfo struct {
// contains filtered or unexported fields
}
func (ParseRestrictedTransactionInfo) GetSigningAccounts ¶
func (info ParseRestrictedTransactionInfo) GetSigningAccounts() ( []runtime.Address, error, )
func (ParseRestrictedTransactionInfo) IsServiceAccountAuthorizer ¶
func (info ParseRestrictedTransactionInfo) IsServiceAccountAuthorizer() bool
func (ParseRestrictedTransactionInfo) LimitAccountStorage ¶
func (info ParseRestrictedTransactionInfo) LimitAccountStorage() bool
func (ParseRestrictedTransactionInfo) SigningAccounts ¶
func (info ParseRestrictedTransactionInfo) SigningAccounts() []runtime.Address
func (ParseRestrictedTransactionInfo) TransactionFeesEnabled ¶
func (info ParseRestrictedTransactionInfo) TransactionFeesEnabled() bool
func (ParseRestrictedTransactionInfo) TxID ¶
func (info ParseRestrictedTransactionInfo) TxID() flow.Identifier
func (ParseRestrictedTransactionInfo) TxIndex ¶
func (info ParseRestrictedTransactionInfo) TxIndex() uint32
type ParseRestrictedUUIDGenerator ¶ added in v0.28.1
type ParseRestrictedUUIDGenerator struct {
// contains filtered or unexported fields
}
func (ParseRestrictedUUIDGenerator) GenerateUUID ¶ added in v0.28.1
func (generator ParseRestrictedUUIDGenerator) GenerateUUID() (uint64, error)
type ParseRestrictedUnsafeRandomGenerator ¶ added in v0.28.1
type ParseRestrictedUnsafeRandomGenerator struct {
// contains filtered or unexported fields
}
func (ParseRestrictedUnsafeRandomGenerator) UnsafeRandom ¶ added in v0.28.1
func (gen ParseRestrictedUnsafeRandomGenerator) UnsafeRandom() ( uint64, error, )
type ParseRestrictedValueStore ¶ added in v0.28.1
type ParseRestrictedValueStore struct {
// contains filtered or unexported fields
}
func (ParseRestrictedValueStore) AllocateStorageIndex ¶ added in v0.28.1
func (store ParseRestrictedValueStore) AllocateStorageIndex( owner []byte, ) ( atree.StorageIndex, error, )
func (ParseRestrictedValueStore) GetValue ¶ added in v0.28.1
func (store ParseRestrictedValueStore) GetValue( owner []byte, key []byte, ) ( []byte, error, )
func (ParseRestrictedValueStore) SetValue ¶ added in v0.28.1
func (store ParseRestrictedValueStore) SetValue( owner []byte, key []byte, value []byte, ) error
func (ParseRestrictedValueStore) ValueExists ¶ added in v0.28.1
func (store ParseRestrictedValueStore) ValueExists( owner []byte, key []byte, ) ( bool, error, )
type ProgramLogger ¶
type ProgramLogger struct { ProgramLoggerParams // contains filtered or unexported fields }
func NewProgramLogger ¶
func NewProgramLogger( tracer *Tracer, params ProgramLoggerParams, ) *ProgramLogger
func (*ProgramLogger) ImplementationDebugLog ¶
func (logger *ProgramLogger) ImplementationDebugLog(message string) error
func (*ProgramLogger) Logger ¶
func (logger *ProgramLogger) Logger() *zerolog.Logger
func (*ProgramLogger) Logs ¶
func (logger *ProgramLogger) Logs() []string
func (*ProgramLogger) ProgramChecked ¶
func (logger *ProgramLogger) ProgramChecked(location common.Location, duration time.Duration)
ProgramChecked captures time spent on checking a code at specific location
func (*ProgramLogger) ProgramInterpreted ¶
func (logger *ProgramLogger) ProgramInterpreted(location common.Location, duration time.Duration)
ProgramInterpreted captures time spent on interpreting a code at specific location
func (*ProgramLogger) ProgramLog ¶
func (logger *ProgramLogger) ProgramLog(message string) error
func (*ProgramLogger) ProgramParsed ¶
func (logger *ProgramLogger) ProgramParsed(location common.Location, duration time.Duration)
ProgramParsed captures time spent on parsing a code at specific location
func (*ProgramLogger) RecordTrace ¶
func (*ProgramLogger) ValueDecoded ¶
func (logger *ProgramLogger) ValueDecoded(duration time.Duration)
ValueDecoded accumulates time spend on runtime value decoding
func (*ProgramLogger) ValueEncoded ¶
func (logger *ProgramLogger) ValueEncoded(duration time.Duration)
ValueEncoded accumulates time spend on runtime value encoding
type ProgramLoggerParams ¶
type ProgramLoggerParams struct { zerolog.Logger CadenceLoggingEnabled bool MetricsReporter }
func DefaultProgramLoggerParams ¶
func DefaultProgramLoggerParams() ProgramLoggerParams
type Programs ¶
type Programs struct {
// contains filtered or unexported fields
}
Programs manages operations around cadence program parsing.
Note that cadence guarantees that Get/Set methods are called in a LIFO manner. Hence, we create new nested transactions on Get calls and commit these nested transactions on Set calls in order to capture the states needed for parsing the programs.
func NewPrograms ¶
func NewPrograms( tracer *Tracer, meter Meter, txnState *state.TransactionState, accounts Accounts, transactionPrograms TransactionPrograms, ) *Programs
NewPrograms construts a new ProgramHandler
func (*Programs) DecodeArgument ¶
func (*Programs) GetProgram ¶
func (*Programs) SetProgram ¶
type Runtime ¶
type Runtime struct { RuntimeParams // contains filtered or unexported fields }
Runtime expose the cadence runtime to the rest of the envionment package.
func NewRuntime ¶
func NewRuntime(params RuntimeParams) *Runtime
func (*Runtime) BorrowCadenceRuntime ¶
func (runtime *Runtime) BorrowCadenceRuntime() *runtime.ReusableCadenceRuntime
func (*Runtime) ReturnCadenceRuntime ¶
func (runtime *Runtime) ReturnCadenceRuntime( reusable *runtime.ReusableCadenceRuntime, )
func (*Runtime) SetEnvironment ¶
func (runtime *Runtime) SetEnvironment(env Environment)
type RuntimeParams ¶
type RuntimeParams struct {
runtime.ReusableCadenceRuntimePool
}
func DefaultRuntimeParams ¶
func DefaultRuntimeParams() RuntimeParams
type StatefulAccounts ¶
type StatefulAccounts struct {
// contains filtered or unexported fields
}
func NewAccounts ¶
func NewAccounts(txnState *state.TransactionState) *StatefulAccounts
func (*StatefulAccounts) AllocateStorageIndex ¶
func (a *StatefulAccounts) AllocateStorageIndex(address flow.Address) (atree.StorageIndex, error)
func (*StatefulAccounts) AppendPublicKey ¶
func (a *StatefulAccounts) AppendPublicKey(address flow.Address, publicKey flow.AccountPublicKey) error
func (*StatefulAccounts) CheckAccountNotFrozen ¶
func (a *StatefulAccounts) CheckAccountNotFrozen(address flow.Address) error
handy function to error out if account is frozen
func (*StatefulAccounts) ContractExists ¶
func (*StatefulAccounts) Create ¶
func (a *StatefulAccounts) Create(publicKeys []flow.AccountPublicKey, newAddress flow.Address) error
Create account sets all required registers on an address.
func (*StatefulAccounts) DeleteContract ¶
func (a *StatefulAccounts) DeleteContract(contractName string, address flow.Address) error
func (*StatefulAccounts) Exists ¶
func (a *StatefulAccounts) Exists(address flow.Address) (bool, error)
func (*StatefulAccounts) GetAccountFrozen ¶
func (a *StatefulAccounts) GetAccountFrozen(address flow.Address) (bool, error)
func (*StatefulAccounts) GetContract ¶
func (*StatefulAccounts) GetContractNames ¶
func (a *StatefulAccounts) GetContractNames(address flow.Address) ([]string, error)
GetContractNames gets a sorted list of names of contracts deployed on an address
func (*StatefulAccounts) GetPublicKey ¶
func (a *StatefulAccounts) GetPublicKey(address flow.Address, keyIndex uint64) (flow.AccountPublicKey, error)
func (*StatefulAccounts) GetPublicKeyCount ¶
func (a *StatefulAccounts) GetPublicKeyCount(address flow.Address) (uint64, error)
func (*StatefulAccounts) GetPublicKeys ¶
func (a *StatefulAccounts) GetPublicKeys(address flow.Address) (publicKeys []flow.AccountPublicKey, err error)
func (*StatefulAccounts) GetStorageUsed ¶
func (a *StatefulAccounts) GetStorageUsed(address flow.Address) (uint64, error)
GetStorageUsed returns the amount of storage used in bytes by this account
func (*StatefulAccounts) GetValue ¶
func (a *StatefulAccounts) GetValue(address flow.Address, key string) (flow.RegisterValue, error)
func (*StatefulAccounts) SetAccountFrozen ¶
func (a *StatefulAccounts) SetAccountFrozen(address flow.Address, frozen bool) error
func (*StatefulAccounts) SetAllPublicKeys ¶
func (a *StatefulAccounts) SetAllPublicKeys(address flow.Address, publicKeys []flow.AccountPublicKey) error
func (*StatefulAccounts) SetContract ¶
func (*StatefulAccounts) SetPublicKey ¶
func (a *StatefulAccounts) SetPublicKey( address flow.Address, keyIndex uint64, publicKey flow.AccountPublicKey, ) (encodedPublicKey []byte, err error)
func (*StatefulAccounts) SetValue ¶
func (a *StatefulAccounts) SetValue(address flow.Address, key string, value flow.RegisterValue) error
SetValue sets a value in address' storage
func (*StatefulAccounts) TouchContract ¶
func (a *StatefulAccounts) TouchContract(contractName string, address flow.Address)
type SystemContracts ¶
type SystemContracts struct {
// contains filtered or unexported fields
}
SystemContracts provides methods for invoking system contract functions as service account.
func NewSystemContracts ¶
func NewSystemContracts( chain flow.Chain, tracer *Tracer, logger *ProgramLogger, runtime *Runtime, ) *SystemContracts
func (*SystemContracts) AccountAvailableBalance ¶
func (sys *SystemContracts) AccountAvailableBalance( address common.Address, ) (cadence.Value, error)
AccountAvailableBalance executes the get available balance contract on the storage fees contract.
func (*SystemContracts) AccountBalance ¶
AccountBalance executes the get available balance contract on the service account.
func (*SystemContracts) AccountStorageCapacity ¶
func (sys *SystemContracts) AccountStorageCapacity( address common.Address, ) (cadence.Value, error)
AccountStorageCapacity executes the get storage capacity contract on the service account.
func (*SystemContracts) AccountsStorageCapacity ¶
func (sys *SystemContracts) AccountsStorageCapacity( addresses []common.Address, ) (cadence.Value, error)
AccountsStorageCapacity gets storage capacity for multiple accounts at once.
func (*SystemContracts) DeductTransactionFees ¶
func (sys *SystemContracts) DeductTransactionFees( payer flow.Address, inclusionEffort uint64, executionEffort uint64, ) (cadence.Value, error)
DeductTransactionFees executes the fee deduction contract on the service account.
func (*SystemContracts) Invoke ¶
func (sys *SystemContracts) Invoke( spec ContractFunctionSpec, arguments []cadence.Value, ) ( cadence.Value, error, )
func (*SystemContracts) SetupNewAccount ¶
func (sys *SystemContracts) SetupNewAccount( flowAddress flow.Address, payer common.Address, ) (cadence.Value, error)
SetupNewAccount executes the new account setup contract on the service account.
func (*SystemContracts) UseContractAuditVoucher ¶
func (sys *SystemContracts) UseContractAuditVoucher( address common.Address, code string, ) (bool, error)
UseContractAuditVoucher executes the use a contract deployment audit voucher contract.
type Tracer ¶
type Tracer struct {
TracerParams
}
func NewTracer ¶
func NewTracer(params TracerParams) *Tracer
func (*Tracer) RecordSpanFromRoot ¶
func (*Tracer) StartExtensiveTracingSpanFromRoot ¶
type TracerParams ¶
func DefaultTracerParams ¶
func DefaultTracerParams() TracerParams
type TransactionInfo ¶
type TransactionInfo interface { TxIndex() uint32 TxID() flow.Identifier TransactionFeesEnabled() bool LimitAccountStorage() bool SigningAccounts() []runtime.Address IsServiceAccountAuthorizer() bool // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. GetSigningAccounts() ([]runtime.Address, error) }
TransactionInfo exposes information associated with the executing transaction.
Note that scripts have no associated transaction information, but must expose the API in compliance with the runtime environment interface.
func NewParseRestrictedTransactionInfo ¶
func NewParseRestrictedTransactionInfo( txnState *state.TransactionState, impl TransactionInfo, ) TransactionInfo
func NewTransactionInfo ¶
func NewTransactionInfo( params TransactionInfoParams, tracer *Tracer, serviceAccount flow.Address, ) TransactionInfo
type TransactionInfoParams ¶
type TransactionInfoParams struct { TxIndex uint32 TxId flow.Identifier TxBody *flow.TransactionBody TransactionFeesEnabled bool LimitAccountStorage bool }
func DefaultTransactionInfoParams ¶
func DefaultTransactionInfoParams() TransactionInfoParams
type TransactionPrograms ¶
type TransactionPrograms interface { Get(loc common.Location) (*interpreter.Program, *state.State, bool) Set(loc common.Location, prog *interpreter.Program, state *state.State) }
TODO(patrick): remove and switch to *programs.TransactionPrograms once emulator is updated.
type UUIDGenerator ¶
func NewParseRestrictedUUIDGenerator ¶ added in v0.28.1
func NewParseRestrictedUUIDGenerator( txnState *state.TransactionState, impl UUIDGenerator, ) UUIDGenerator
type UnsafeRandomGenerator ¶
type UnsafeRandomGenerator interface { // UnsafeRandom returns a random uint64, where the process of random number // derivation is not cryptographically secure. UnsafeRandom() (uint64, error) }
func NewParseRestrictedUnsafeRandomGenerator ¶ added in v0.28.1
func NewParseRestrictedUnsafeRandomGenerator( txnState *state.TransactionState, impl UnsafeRandomGenerator, ) UnsafeRandomGenerator
func NewUnsafeRandomGenerator ¶
func NewUnsafeRandomGenerator( tracer *Tracer, blockHeader *flow.Header, ) UnsafeRandomGenerator
type ValueStore ¶
type ValueStore interface { GetValue(owner []byte, key []byte) ([]byte, error) SetValue(owner, key, value []byte) error ValueExists(owner []byte, key []byte) (bool, error) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) }
ValueStore provides read/write access to the account storage.
func NewParseRestrictedValueStore ¶ added in v0.28.1
func NewParseRestrictedValueStore( txnState *state.TransactionState, impl ValueStore, ) ValueStore
func NewValueStore ¶
func NewValueStore(tracer *Tracer, meter Meter, accounts Accounts) ValueStore
Source Files ¶
- account_creator.go
- account_freezer.go
- account_info.go
- account_key_reader.go
- account_key_updater.go
- accounts.go
- accounts_status.go
- block_info.go
- blocks.go
- contract_reader.go
- contract_updater.go
- crypto_library.go
- env.go
- event_emitter.go
- facade_env.go
- meter.go
- parse_restricted_checker.go
- program_logger.go
- programs.go
- runtime.go
- system_contracts.go
- tracer.go
- transaction_info.go
- unsafe_random_generator.go
- uuids.go
- value_store.go