Documentation ¶
Index ¶
- Constants
- func FlowFeesAddress(chain flow.Chain) flow.Address
- func FlowToRuntimeAccountKey(flowKey flow.AccountPublicKey) (*runtime.AccountKey, error)
- func IsServiceEvent(event cadence.Event, chain flow.ChainID) (bool, error)
- func IsValidAccountKeyHashAlgo(algo hash.HashingAlgorithm) bool
- func IsValidAccountKeySignAlgo(algo crypto.SigningAlgorithm) bool
- func NewAccountKeyUpdater(tracer tracing.TracerSpan, meter Meter, accounts Accounts, ...) *accountKeyUpdater
- func NewAccountPublicKey(publicKey *runtime.PublicKey, hashAlgo sema.HashAlgorithm, keyIndex int, ...) (*flow.AccountPublicKey, error)
- func NewScriptEnv(ctx context.Context, tracer tracing.TracerSpan, params EnvironmentParams, ...) *facadeEnvironment
- func NewScriptEnvironment(ctx context.Context, tracer tracing.TracerSpan, params EnvironmentParams, ...) *facadeEnvironment
- func NewScriptEnvironmentFromStorageSnapshot(params EnvironmentParams, storageSnapshot state.StorageSnapshot) *facadeEnvironment
- func NewTransactionEnvironment(tracer tracing.TracerSpan, params EnvironmentParams, ...) *facadeEnvironment
- func NewUUIDGenerator(tracer tracing.TracerSpan, meter Meter, txnState state.NestedTransaction) *uUIDGenerator
- func RegisterSize(id flow.RegisterID, value flow.RegisterValue) int
- func ServiceAddress(chain flow.Chain) flow.Address
- func StorageMBUFixToBytesUInt(result cadence.Value) uint64
- type AccountCreator
- type AccountInfo
- type AccountKeyReader
- type AccountKeyUpdater
- type AccountStatus
- func (a *AccountStatus) PublicKeyCount() uint64
- 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 CadenceEventEncoder
- type ContractFunctionSpec
- type ContractReader
- func (reader *ContractReader) GetAccountContractCode(location common.AddressLocation) ([]byte, error)
- func (reader *ContractReader) GetAccountContractNames(runtimeAddress common.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 ContractUpdate
- type ContractUpdater
- type ContractUpdaterImpl
- func (updater *ContractUpdaterImpl) Commit() (ContractUpdates, error)
- func (updater *ContractUpdaterImpl) HasUpdates() bool
- func (updater *ContractUpdaterImpl) RemoveAccountContractCode(location common.AddressLocation) error
- func (updater *ContractUpdaterImpl) RemoveContract(location common.AddressLocation, signingAccounts []flow.Address) (err error)
- func (updater *ContractUpdaterImpl) Reset()
- func (updater *ContractUpdaterImpl) SetContract(location common.AddressLocation, code []byte, signingAccounts []flow.Address) error
- func (updater *ContractUpdaterImpl) UpdateAccountContractCode(location common.AddressLocation, code []byte) error
- type ContractUpdaterParams
- type ContractUpdaterStubs
- type ContractUpdates
- type CryptoLibrary
- type DerivedDataInvalidator
- type Environment
- type EnvironmentParams
- type EventCollection
- func (collection *EventCollection) AppendEvent(event flow.Event, size uint64) error
- func (collection *EventCollection) AppendServiceEvent(chain flow.Chain, event flow.Event, size uint64) error
- func (collection *EventCollection) ConvertedServiceEvents() flow.ServiceEventList
- func (collection *EventCollection) Events() flow.EventsList
- func (collection *EventCollection) ServiceEvents() flow.EventsList
- func (collection *EventCollection) TotalByteSize() uint64
- func (collection *EventCollection) TotalEventCounter() uint32
- type EventEmitter
- type EventEmitterParams
- type EventEncoder
- type Meter
- type MeterParamOverridesInvalidator
- type MetricsReporter
- type NoAccountCreator
- type NoAccountKeyUpdater
- func (NoAccountKeyUpdater) AddAccountKey(runtimeAddress common.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (NoAccountKeyUpdater) AddEncodedAccountKey(runtimeAddress common.Address, publicKey []byte) error
- func (NoAccountKeyUpdater) RevokeAccountKey(runtimeAddress common.Address, keyIndex int) (*runtime.AccountKey, error)
- func (NoAccountKeyUpdater) RevokeEncodedAccountKey(runtimeAddress common.Address, index int) ([]byte, error)
- type NoContractUpdater
- type NoEventEmitter
- type NoTransactionInfo
- func (NoTransactionInfo) GetSigningAccounts() ([]common.Address, error)
- func (NoTransactionInfo) IsServiceAccountAuthorizer() bool
- func (NoTransactionInfo) LimitAccountStorage() bool
- func (NoTransactionInfo) TransactionFeesEnabled() bool
- func (NoTransactionInfo) TxID() flow.Identifier
- func (NoTransactionInfo) TxIndex() uint32
- type NoopBlockFinder
- type NoopMetricsReporter
- func (NoopMetricsReporter) RuntimeSetNumberOfAccounts(count uint64)
- func (NoopMetricsReporter) RuntimeTransactionChecked(time.Duration)
- func (NoopMetricsReporter) RuntimeTransactionInterpreted(time.Duration)
- func (NoopMetricsReporter) RuntimeTransactionParsed(time.Duration)
- func (NoopMetricsReporter) RuntimeTransactionProgramsCacheHit()
- func (NoopMetricsReporter) RuntimeTransactionProgramsCacheMiss()
- type ParseRestrictedAccountCreator
- type ParseRestrictedAccountInfo
- func (info ParseRestrictedAccountInfo) GetAccount(address flow.Address) (*flow.Account, error)
- func (info ParseRestrictedAccountInfo) GetAccountAvailableBalance(runtimeAddress common.Address) (uint64, error)
- func (info ParseRestrictedAccountInfo) GetAccountBalance(runtimeAddress common.Address) (uint64, error)
- func (info ParseRestrictedAccountInfo) GetStorageCapacity(runtimeAddress common.Address) (uint64, error)
- func (info ParseRestrictedAccountInfo) GetStorageUsed(runtimeAddress common.Address) (uint64, error)
- type ParseRestrictedAccountKeyReader
- type ParseRestrictedAccountKeyUpdater
- func (updater ParseRestrictedAccountKeyUpdater) AddAccountKey(runtimeAddress common.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (updater ParseRestrictedAccountKeyUpdater) AddEncodedAccountKey(runtimeAddress common.Address, publicKey []byte) error
- func (updater ParseRestrictedAccountKeyUpdater) RevokeAccountKey(runtimeAddress common.Address, keyIndex int) (*runtime.AccountKey, error)
- func (updater ParseRestrictedAccountKeyUpdater) RevokeEncodedAccountKey(runtimeAddress common.Address, index int) ([]byte, error)
- type ParseRestrictedBlockInfo
- type ParseRestrictedContractUpdater
- func (updater ParseRestrictedContractUpdater) Commit() (ContractUpdates, error)
- func (updater ParseRestrictedContractUpdater) RemoveAccountContractCode(location common.AddressLocation) error
- func (updater ParseRestrictedContractUpdater) Reset()
- func (updater ParseRestrictedContractUpdater) UpdateAccountContractCode(location common.AddressLocation, 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
- func (emitter ParseRestrictedEventEmitter) ConvertedServiceEvents() flow.ServiceEventList
- func (emitter ParseRestrictedEventEmitter) EmitEvent(event cadence.Event) error
- func (emitter ParseRestrictedEventEmitter) Events() flow.EventsList
- func (emitter ParseRestrictedEventEmitter) Reset()
- func (emitter ParseRestrictedEventEmitter) ServiceEvents() flow.EventsList
- type ParseRestrictedTransactionInfo
- func (info ParseRestrictedTransactionInfo) GetSigningAccounts() ([]common.Address, error)
- func (info ParseRestrictedTransactionInfo) IsServiceAccountAuthorizer() bool
- func (info ParseRestrictedTransactionInfo) LimitAccountStorage() bool
- 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 ProgramInvalidator
- 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) 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) 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(id flow.RegisterID) (flow.RegisterValue, 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(id flow.RegisterID, value flow.RegisterValue) error
- type SystemContracts
- func (sys *SystemContracts) AccountAvailableBalance(address flow.Address) (cadence.Value, error)
- func (sys *SystemContracts) AccountBalance(address flow.Address) (cadence.Value, error)
- func (sys *SystemContracts) AccountStorageCapacity(address flow.Address) (cadence.Value, error)
- func (sys *SystemContracts) AccountsStorageCapacity(addresses []flow.Address, payer flow.Address, maxTxFees uint64) (cadence.Value, error)
- func (sys *SystemContracts) CheckPayerBalanceAndGetMaxTxFees(payer flow.Address, inclusionEffort uint64, maxExecutionEffort uint64) (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 flow.Address) (cadence.Value, error)
- type TransactionInfo
- type TransactionInfoParams
- type UUIDGenerator
- type UnsafeRandomGenerator
- type ValueStore
Constants ¶
const ( FungibleTokenAccountIndex = 2 FlowTokenAccountIndex = 3 FlowFeesAccountIndex = 4 )
const ( // [2_000, 3_000) reserved for the FVM ComputationKindHash = 2001 ComputationKindVerifySignature = 2002 ComputationKindAddAccountKey = 2003 ComputationKindAddEncodedAccountKey = 2004 ComputationKindAllocateStorageIndex = 2005 ComputationKindCreateAccount = 2006 ComputationKindEmitEvent = 2007 ComputationKindGenerateUUID = 2008 ComputationKindGetAccountAvailableBalance = 2009 ComputationKindGetAccountBalance = 2010 ComputationKindGetAccountContractCode = 2011 ComputationKindGetAccountContractNames = 2012 ComputationKindGetAccountKey = 2013 ComputationKindGetBlockAtHeight = 2014 ComputationKindGetCode = 2015 ComputationKindGetCurrentBlockHeight = 2016 ComputationKindGetStorageCapacity = 2018 ComputationKindGetStorageUsed = 2019 ComputationKindGetValue = 2020 ComputationKindRemoveAccountContractCode = 2021 ComputationKindResolveLocation = 2022 ComputationKindRevokeAccountKey = 2023 ComputationKindRevokeEncodedAccountKey = 2024 ComputationKindSetValue = 2026 ComputationKindUpdateAccountContractCode = 2027 ComputationKindValidatePublicKey = 2028 ComputationKindValueExists = 2029 ComputationKindAccountKeysCount = 2030 ComputationKindBLSVerifyPOP = 2031 ComputationKindBLSAggregateSignatures = 2032 ComputationKindBLSAggregatePublicKeys = 2033 ComputationKindGetOrLoadProgram = 2034 )
const (
DefaultEventCollectionByteSizeLimit = 256_000 // 256KB
)
const (
MaxPublicKeyCount = math.MaxUint64
)
Variables ¶
This section is empty.
Functions ¶
func FlowToRuntimeAccountKey ¶ added in v0.29.0
func FlowToRuntimeAccountKey( flowKey flow.AccountPublicKey, ) ( *runtime.AccountKey, error, )
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 NewAccountKeyUpdater ¶
func NewAccountKeyUpdater( tracer tracing.TracerSpan, meter Meter, accounts Accounts, txnState state.NestedTransaction, 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 NewScriptEnv ¶ added in v0.30.0
func NewScriptEnv( ctx context.Context, tracer tracing.TracerSpan, params EnvironmentParams, txnState storage.Transaction, ) *facadeEnvironment
func NewScriptEnvironment ¶
func NewScriptEnvironment( ctx context.Context, tracer tracing.TracerSpan, params EnvironmentParams, nestedTxn state.NestedTransaction, derivedTxn derived.DerivedTransactionCommitter, ) *facadeEnvironment
TODO(patrick): remove once emulator is updated.
func NewScriptEnvironmentFromStorageSnapshot ¶ added in v0.30.0
func NewScriptEnvironmentFromStorageSnapshot( params EnvironmentParams, storageSnapshot state.StorageSnapshot, ) *facadeEnvironment
This is mainly used by command line tools, the emulator, and cadence tools testing.
func NewTransactionEnvironment ¶
func NewTransactionEnvironment( tracer tracing.TracerSpan, params EnvironmentParams, txnState storage.Transaction, ) *facadeEnvironment
func NewUUIDGenerator ¶
func NewUUIDGenerator( tracer tracing.TracerSpan, meter Meter, txnState state.NestedTransaction, ) *uUIDGenerator
func RegisterSize ¶
func RegisterSize(id flow.RegisterID, value flow.RegisterValue) int
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 ¶
type AccountCreator interface {
CreateAccount(runtimePayer common.Address) (common.Address, error)
}
func NewAccountCreator ¶
func NewAccountCreator( txnState state.NestedTransaction, chain flow.Chain, accounts Accounts, isServiceAccountEnabled bool, tracer tracing.TracerSpan, meter Meter, metrics MetricsReporter, systemContracts *SystemContracts, ) AccountCreator
func NewParseRestrictedAccountCreator ¶
func NewParseRestrictedAccountCreator( txnState state.NestedTransaction, creator AccountCreator, ) AccountCreator
type AccountInfo ¶
type AccountInfo interface { // Cadence's runtime APIs. GetStorageUsed(runtimeaddress common.Address) (uint64, error) GetStorageCapacity(runtimeAddress common.Address) (uint64, error) GetAccountBalance(runtimeAddress common.Address) (uint64, error) GetAccountAvailableBalance(runtimeAddress common.Address) (uint64, error) GetAccount(address flow.Address) (*flow.Account, error) }
AccountInfo exposes various account balance and storage statistics.
func NewAccountInfo ¶
func NewAccountInfo( tracer tracing.TracerSpan, meter Meter, accounts Accounts, systemContracts *SystemContracts, serviceAccountEnabled bool, ) AccountInfo
func NewParseRestrictedAccountInfo ¶
func NewParseRestrictedAccountInfo( txnState state.NestedTransaction, 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( runtimeAddress common.Address, keyIndex int, ) ( *runtime.AccountKey, error, ) AccountKeysCount(runtimeAddress common.Address) (uint64, error) }
AccountKeyReader provide read access to account keys.
func NewAccountKeyReader ¶
func NewAccountKeyReader( tracer tracing.TracerSpan, meter Meter, accounts Accounts, ) AccountKeyReader
func NewParseRestrictedAccountKeyReader ¶ added in v0.28.1
func NewParseRestrictedAccountKeyReader( txnState state.NestedTransaction, 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(runtimeAddress common.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( runtimeAddress common.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( runtimeAddress common.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( runtimeAddress common.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 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) PublicKeyCount ¶
func (a *AccountStatus) PublicKeyCount() uint64
PublicKeyCount returns the public key count of the account
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(id flow.RegisterID) (flow.RegisterValue, error) GetStorageUsed(address flow.Address) (uint64, error) SetValue(id flow.RegisterID, value flow.RegisterValue) error AllocateStorageIndex(address flow.Address) (atree.StorageIndex, error) }
type AddressGenerator ¶
type AddressGenerator interface { Bytes() []byte NextAddress() (flow.Address, error) CurrentAddress() flow.Address AddressCount() uint64 }
func NewAddressGenerator ¶
func NewAddressGenerator( txnState state.NestedTransaction, 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 storageTxn.Transaction, 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.NestedTransaction, chain flow.Chain, accounts Accounts, ) BootstrapAccountCreator
type CadenceEventEncoder ¶ added in v0.29.0
type CadenceEventEncoder struct{}
func NewCadenceEventEncoder ¶ added in v0.29.0
func NewCadenceEventEncoder() *CadenceEventEncoder
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 tracing.TracerSpan, meter Meter, accounts Accounts, ) *ContractReader
func (*ContractReader) GetAccountContractCode ¶
func (reader *ContractReader) GetAccountContractCode( location common.AddressLocation, ) ( []byte, error, )
func (*ContractReader) GetAccountContractNames ¶
func (reader *ContractReader) GetAccountContractNames( runtimeAddress common.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 ContractUpdate ¶ added in v0.29.0
type ContractUpdate struct { Location common.AddressLocation Code []byte }
type ContractUpdater ¶
type ContractUpdater interface { // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. UpdateAccountContractCode( location common.AddressLocation, code []byte, ) error // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. RemoveAccountContractCode(location common.AddressLocation) error Commit() (ContractUpdates, error) Reset() }
ContractUpdater handles all smart contracts modification. It captures contract updates and defer the updates to the end of the txn execution.
Note that scripts cannot modify smart contracts, but must expose the API in compliance with the runtime environment interface.
type ContractUpdaterImpl ¶ added in v0.29.0
type ContractUpdaterImpl struct { ContractUpdaterStubs // contains filtered or unexported fields }
func NewContractUpdater ¶
func NewContractUpdater( tracer tracing.TracerSpan, meter Meter, accounts Accounts, signingAccounts []flow.Address, chain flow.Chain, params ContractUpdaterParams, logger *ProgramLogger, systemContracts *SystemContracts, runtime *Runtime, ) *ContractUpdaterImpl
func NewContractUpdaterForTesting ¶
func NewContractUpdaterForTesting( accounts Accounts, stubs ContractUpdaterStubs, ) *ContractUpdaterImpl
func (*ContractUpdaterImpl) Commit ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) Commit() (ContractUpdates, error)
func (*ContractUpdaterImpl) HasUpdates ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) HasUpdates() bool
func (*ContractUpdaterImpl) RemoveAccountContractCode ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) RemoveAccountContractCode( location common.AddressLocation, ) error
func (*ContractUpdaterImpl) RemoveContract ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) RemoveContract( location common.AddressLocation, signingAccounts []flow.Address, ) (err error)
func (*ContractUpdaterImpl) Reset ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) Reset()
func (*ContractUpdaterImpl) SetContract ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) SetContract( location common.AddressLocation, code []byte, signingAccounts []flow.Address, ) error
func (*ContractUpdaterImpl) UpdateAccountContractCode ¶ added in v0.29.0
func (updater *ContractUpdaterImpl) UpdateAccountContractCode( location common.AddressLocation, code []byte, ) error
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) []flow.Address }
Expose stub interface for testing.
type ContractUpdates ¶ added in v0.30.0
type ContractUpdates struct { Updates []common.AddressLocation Deploys []common.AddressLocation Deletions []common.AddressLocation }
func (ContractUpdates) Any ¶ added in v0.30.0
func (u ContractUpdates) Any() bool
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 tracing.TracerSpan, meter Meter) CryptoLibrary
func NewParseRestrictedCryptoLibrary ¶ added in v0.28.1
func NewParseRestrictedCryptoLibrary( txnState state.NestedTransaction, impl CryptoLibrary, ) CryptoLibrary
type DerivedDataInvalidator ¶ added in v0.29.0
type DerivedDataInvalidator struct { ContractUpdates MeterParamOverridesUpdated bool }
func NewDerivedDataInvalidator ¶ added in v0.29.0
func NewDerivedDataInvalidator( contractUpdates ContractUpdates, serviceAddress flow.Address, executionSnapshot *state.ExecutionSnapshot, ) DerivedDataInvalidator
TODO(patrick): extract contractKeys from executionSnapshot
func (DerivedDataInvalidator) MeterParamOverridesInvalidator ¶ added in v0.29.0
func (invalidator DerivedDataInvalidator) MeterParamOverridesInvalidator() derived.MeterParamOverridesInvalidator
func (DerivedDataInvalidator) ProgramInvalidator ¶ added in v0.29.0
func (invalidator DerivedDataInvalidator) ProgramInvalidator() derived.ProgramInvalidator
type Environment ¶
type Environment interface { runtime.Interface // Tracer StartChildSpan( name trace.SpanName, options ...otelTrace.SpanStartOption, ) tracing.TracerSpan Meter // Runtime BorrowCadenceRuntime() *reusableRuntime.ReusableCadenceRuntime ReturnCadenceRuntime(*reusableRuntime.ReusableCadenceRuntime) TransactionInfo // ProgramLogger Logger() *zerolog.Logger Logs() []string // EventEmitter Events() flow.EventsList ServiceEvents() flow.EventsList ConvertedServiceEvents() flow.ServiceEventList // SystemContracts AccountsStorageCapacity( addresses []flow.Address, payer flow.Address, maxTxFees uint64, ) ( cadence.Value, error, ) CheckPayerBalanceAndGetMaxTxFees( payer flow.Address, inclusionEffort uint64, executionEffort uint64, ) ( cadence.Value, error, ) DeductTransactionFees( payer flow.Address, inclusionEffort uint64, executionEffort uint64, ) ( cadence.Value, error, ) // AccountInfo GetAccount(address flow.Address) (*flow.Account, error) // FlushPendingUpdates flushes pending updates from the stateful environment // modules (i.e., ContractUpdater) to the state transaction, and return // the updated contract keys. FlushPendingUpdates() ( ContractUpdates, error, ) // Reset resets all stateful environment modules (e.g., ContractUpdater, // EventEmitter) to initial state. Reset() }
Environment implements the accounts business logic and exposes cadence runtime interface methods for the runtime.
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 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 (*EventCollection) ConvertedServiceEvents ¶ added in v0.30.0
func (collection *EventCollection) ConvertedServiceEvents() flow.ServiceEventList
func (*EventCollection) Events ¶
func (collection *EventCollection) Events() flow.EventsList
func (*EventCollection) ServiceEvents ¶
func (collection *EventCollection) ServiceEvents() flow.EventsList
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.EventsList ServiceEvents() flow.EventsList ConvertedServiceEvents() flow.ServiceEventList 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 tracing.TracerSpan, 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.NestedTransaction, impl EventEmitter, ) EventEmitter
type EventEmitterParams ¶
type EventEmitterParams struct { ServiceEventCollectionEnabled bool EventCollectionByteSizeLimit uint64 EventEncoder EventEncoder }
func DefaultEventEmitterParams ¶
func DefaultEventEmitterParams() EventEmitterParams
type EventEncoder ¶ added in v0.29.0
type Meter ¶
type Meter interface { MeterComputation(common.ComputationKind, uint) error ComputationUsed() (uint64, error) ComputationIntensities() meter.MeteredComputationIntensities MeterMemory(usage common.MemoryUsage) error MemoryUsed() (uint64, error) MeterEmittedEvent(byteSize uint64) error TotalEmittedEventBytes() uint64 InteractionUsed() (uint64, error) }
func NewCancellableMeter ¶
func NewCancellableMeter( ctx context.Context, txnState state.NestedTransaction, ) Meter
func NewMeter ¶
func NewMeter(txnState state.NestedTransaction) Meter
type MeterParamOverridesInvalidator ¶ added in v0.29.0
type MeterParamOverridesInvalidator struct {
DerivedDataInvalidator
}
func (MeterParamOverridesInvalidator) ShouldInvalidateEntries ¶ added in v0.29.0
func (invalidator MeterParamOverridesInvalidator) ShouldInvalidateEntries() bool
func (MeterParamOverridesInvalidator) ShouldInvalidateEntry ¶ added in v0.29.0
func (invalidator MeterParamOverridesInvalidator) ShouldInvalidateEntry( _ struct{}, _ derived.MeterParamOverrides, _ *state.ExecutionSnapshot, ) bool
type MetricsReporter ¶
type MetricsReporter interface { RuntimeTransactionParsed(time.Duration) RuntimeTransactionChecked(time.Duration) RuntimeTransactionInterpreted(time.Duration) RuntimeSetNumberOfAccounts(count uint64) RuntimeTransactionProgramsCacheMiss() RuntimeTransactionProgramsCacheHit() }
MetricsReporter captures and reports metrics to back to the execution environment it is a setup passed to the context.
type NoAccountKeyUpdater ¶
type NoAccountKeyUpdater struct{}
func (NoAccountKeyUpdater) AddAccountKey ¶
func (NoAccountKeyUpdater) AddAccountKey( runtimeAddress common.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, )
func (NoAccountKeyUpdater) AddEncodedAccountKey ¶
func (NoAccountKeyUpdater) AddEncodedAccountKey( runtimeAddress common.Address, publicKey []byte, ) error
func (NoAccountKeyUpdater) RevokeAccountKey ¶
func (NoAccountKeyUpdater) RevokeAccountKey( runtimeAddress common.Address, keyIndex int, ) ( *runtime.AccountKey, error, )
func (NoAccountKeyUpdater) RevokeEncodedAccountKey ¶
type NoContractUpdater ¶
type NoContractUpdater struct{}
func (NoContractUpdater) Commit ¶
func (NoContractUpdater) Commit() (ContractUpdates, error)
func (NoContractUpdater) RemoveAccountContractCode ¶
func (NoContractUpdater) RemoveAccountContractCode( _ common.AddressLocation, ) error
func (NoContractUpdater) Reset ¶
func (NoContractUpdater) Reset()
func (NoContractUpdater) UpdateAccountContractCode ¶
func (NoContractUpdater) UpdateAccountContractCode( _ common.AddressLocation, _ []byte, ) error
type NoEventEmitter ¶
type NoEventEmitter struct{}
NoEventEmitter is usually used in the environment for script execution, where emitting an event does nothing.
func (NoEventEmitter) ConvertedServiceEvents ¶ added in v0.30.0
func (NoEventEmitter) ConvertedServiceEvents() flow.ServiceEventList
func (NoEventEmitter) Events ¶
func (NoEventEmitter) Events() flow.EventsList
func (NoEventEmitter) Reset ¶
func (NoEventEmitter) Reset()
func (NoEventEmitter) ServiceEvents ¶
func (NoEventEmitter) ServiceEvents() flow.EventsList
type NoTransactionInfo ¶
type NoTransactionInfo struct { }
Scripts have no associated transaction information.
func (NoTransactionInfo) GetSigningAccounts ¶
func (NoTransactionInfo) GetSigningAccounts() ([]common.Address, error)
func (NoTransactionInfo) IsServiceAccountAuthorizer ¶
func (NoTransactionInfo) IsServiceAccountAuthorizer() bool
func (NoTransactionInfo) LimitAccountStorage ¶
func (NoTransactionInfo) LimitAccountStorage() bool
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
func (NoopMetricsReporter) RuntimeTransactionProgramsCacheHit ¶ added in v0.29.17
func (NoopMetricsReporter) RuntimeTransactionProgramsCacheHit()
RuntimeTransactionProgramsCacheHit is a noop
func (NoopMetricsReporter) RuntimeTransactionProgramsCacheMiss ¶ added in v0.29.17
func (NoopMetricsReporter) RuntimeTransactionProgramsCacheMiss()
RuntimeTransactionProgramsCacheMiss 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 ParseRestrictedAccountInfo ¶
type ParseRestrictedAccountInfo struct {
// contains filtered or unexported fields
}
func (ParseRestrictedAccountInfo) GetAccount ¶
func (ParseRestrictedAccountInfo) GetAccountAvailableBalance ¶
func (info ParseRestrictedAccountInfo) GetAccountAvailableBalance( runtimeAddress common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountInfo) GetAccountBalance ¶
func (info ParseRestrictedAccountInfo) GetAccountBalance( runtimeAddress common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountInfo) GetStorageCapacity ¶
func (info ParseRestrictedAccountInfo) GetStorageCapacity( runtimeAddress common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountInfo) GetStorageUsed ¶
func (info ParseRestrictedAccountInfo) GetStorageUsed( runtimeAddress common.Address, ) ( uint64, error, )
type ParseRestrictedAccountKeyReader ¶ added in v0.28.1
type ParseRestrictedAccountKeyReader struct {
// contains filtered or unexported fields
}
func (ParseRestrictedAccountKeyReader) AccountKeysCount ¶ added in v0.29.0
func (reader ParseRestrictedAccountKeyReader) AccountKeysCount( runtimeAddress common.Address, ) ( uint64, error, )
func (ParseRestrictedAccountKeyReader) GetAccountKey ¶ added in v0.28.1
func (reader ParseRestrictedAccountKeyReader) GetAccountKey( runtimeAddress common.Address, keyIndex int, ) ( *runtime.AccountKey, error, )
type ParseRestrictedAccountKeyUpdater ¶
type ParseRestrictedAccountKeyUpdater struct {
// contains filtered or unexported fields
}
func NewParseRestrictedAccountKeyUpdater ¶
func NewParseRestrictedAccountKeyUpdater( txnState state.NestedTransaction, impl AccountKeyUpdater, ) ParseRestrictedAccountKeyUpdater
func (ParseRestrictedAccountKeyUpdater) AddAccountKey ¶
func (updater ParseRestrictedAccountKeyUpdater) AddAccountKey( runtimeAddress common.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, )
func (ParseRestrictedAccountKeyUpdater) AddEncodedAccountKey ¶
func (updater ParseRestrictedAccountKeyUpdater) AddEncodedAccountKey( runtimeAddress common.Address, publicKey []byte, ) error
func (ParseRestrictedAccountKeyUpdater) RevokeAccountKey ¶
func (updater ParseRestrictedAccountKeyUpdater) RevokeAccountKey( runtimeAddress common.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.NestedTransaction, impl ContractUpdater, ) ParseRestrictedContractUpdater
func (ParseRestrictedContractUpdater) Commit ¶
func (updater ParseRestrictedContractUpdater) Commit() ( ContractUpdates, error, )
func (ParseRestrictedContractUpdater) RemoveAccountContractCode ¶
func (updater ParseRestrictedContractUpdater) RemoveAccountContractCode( location common.AddressLocation, ) error
func (ParseRestrictedContractUpdater) Reset ¶
func (updater ParseRestrictedContractUpdater) Reset()
func (ParseRestrictedContractUpdater) UpdateAccountContractCode ¶
func (updater ParseRestrictedContractUpdater) UpdateAccountContractCode( location common.AddressLocation, code []byte, ) error
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) ConvertedServiceEvents ¶ added in v0.30.0
func (emitter ParseRestrictedEventEmitter) ConvertedServiceEvents() flow.ServiceEventList
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.EventsList
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.EventsList
type ParseRestrictedTransactionInfo ¶
type ParseRestrictedTransactionInfo struct {
// contains filtered or unexported fields
}
func (ParseRestrictedTransactionInfo) GetSigningAccounts ¶
func (info ParseRestrictedTransactionInfo) GetSigningAccounts() ( []common.Address, error, )
func (ParseRestrictedTransactionInfo) IsServiceAccountAuthorizer ¶
func (info ParseRestrictedTransactionInfo) IsServiceAccountAuthorizer() bool
func (ParseRestrictedTransactionInfo) LimitAccountStorage ¶
func (info ParseRestrictedTransactionInfo) LimitAccountStorage() bool
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 ProgramInvalidator ¶ added in v0.29.0
type ProgramInvalidator struct {
DerivedDataInvalidator
}
func (ProgramInvalidator) ShouldInvalidateEntries ¶ added in v0.29.0
func (invalidator ProgramInvalidator) ShouldInvalidateEntries() bool
func (ProgramInvalidator) ShouldInvalidateEntry ¶ added in v0.29.0
func (invalidator ProgramInvalidator) ShouldInvalidateEntry( location common.AddressLocation, program *derived.Program, snapshot *state.ExecutionSnapshot, ) bool
type ProgramLogger ¶
type ProgramLogger struct { ProgramLoggerParams // contains filtered or unexported fields }
func NewProgramLogger ¶
func NewProgramLogger( tracer tracing.TracerSpan, 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 tracing.TracerSpan, meter Meter, metrics MetricsReporter, txnState storage.Transaction, accounts Accounts, ) *Programs
NewPrograms constructs a new ProgramHandler
func (*Programs) DecodeArgument ¶
func (*Programs) GetOrLoadProgram ¶ added in v0.30.0
func (programs *Programs) GetOrLoadProgram( location common.Location, load func() (*interpreter.Program, error), ) (*interpreter.Program, error)
GetOrLoadProgram gets the program from the cache, or loads it (by calling load) if it is not in the cache. When loading a program, this method will be re-entered to load the dependencies of the program.
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.NestedTransaction) *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) 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) 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( id flow.RegisterID, ) ( flow.RegisterValue, 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( id flow.RegisterID, value flow.RegisterValue, ) error
SetValue sets a value in address' storage
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 tracing.TracerSpan, logger *ProgramLogger, runtime *Runtime, ) *SystemContracts
func (*SystemContracts) AccountAvailableBalance ¶
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 ¶
AccountStorageCapacity executes the get storage capacity contract on the service account.
func (*SystemContracts) AccountsStorageCapacity ¶
func (sys *SystemContracts) AccountsStorageCapacity( addresses []flow.Address, payer flow.Address, maxTxFees uint64, ) (cadence.Value, error)
AccountsStorageCapacity gets storage capacity for multiple accounts at once.
func (*SystemContracts) CheckPayerBalanceAndGetMaxTxFees ¶ added in v0.29.0
func (sys *SystemContracts) CheckPayerBalanceAndGetMaxTxFees( payer flow.Address, inclusionEffort uint64, maxExecutionEffort uint64, ) (cadence.Value, error)
CheckPayerBalanceAndGetMaxTxFees executes the verifyPayersBalanceForTransactionExecution on the FlowFees account. It checks whether the given payer has enough balance to cover inclusion fee and max execution fee. It returns (maxTransactionFee, ErrCodeInsufficientPayerBalance) if the payer doesn't have enough balance It returns (maxTransactionFee, nil) if the payer has enough balance
func (*SystemContracts) DeductTransactionFees ¶
func (sys *SystemContracts) DeductTransactionFees( payer flow.Address, inclusionEffort uint64, executionEffort uint64, ) (cadence.Value, error)
DeductTransactionFees executes the fee deduction function on the FlowFees 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 flow.Address, ) (cadence.Value, error)
SetupNewAccount executes the new account setup contract on the service account.
type TransactionInfo ¶
type TransactionInfo interface { TxIndex() uint32 TxID() flow.Identifier TransactionFeesEnabled() bool LimitAccountStorage() bool IsServiceAccountAuthorizer() bool // Cadence's runtime API. Note that the script variant will return // OperationNotSupportedError. GetSigningAccounts() ([]common.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.NestedTransaction, impl TransactionInfo, ) TransactionInfo
func NewTransactionInfo ¶
func NewTransactionInfo( params TransactionInfoParams, tracer tracing.TracerSpan, 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 UUIDGenerator ¶
func NewParseRestrictedUUIDGenerator ¶ added in v0.28.1
func NewParseRestrictedUUIDGenerator( txnState state.NestedTransaction, impl UUIDGenerator, ) UUIDGenerator
type UnsafeRandomGenerator ¶
type UnsafeRandomGenerator interface { // UnsafeRandom returns a random uint64 UnsafeRandom() (uint64, error) }
func NewParseRestrictedUnsafeRandomGenerator ¶ added in v0.28.1
func NewParseRestrictedUnsafeRandomGenerator( txnState state.NestedTransaction, impl UnsafeRandomGenerator, ) UnsafeRandomGenerator
func NewUnsafeRandomGenerator ¶
func NewUnsafeRandomGenerator( tracer tracing.TracerSpan, 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.NestedTransaction, impl ValueStore, ) ValueStore
func NewValueStore ¶
func NewValueStore( tracer tracing.TracerSpan, meter Meter, accounts Accounts, ) ValueStore
Source Files ¶
- account_creator.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
- derived_data_invalidator.go
- env.go
- event_emitter.go
- event_encoder.go
- facade_env.go
- meter.go
- parse_restricted_checker.go
- program_logger.go
- programs.go
- runtime.go
- system_contracts.go
- transaction_info.go
- unsafe_random_generator.go
- uuids.go
- value_store.go