Documentation ¶
Index ¶
- Constants
- Variables
- func BalanceConversionToUFix64ProneToRoundingError(bal Balance) bool
- func BalanceToBigInt(bal Balance) *big.Int
- func BalancesAreEqual(bal1, bal2 Balance) bool
- func COAOwnershipProofSignatureCountFromEncoded(data []byte) (int, error)
- func ConvertBalanceToUFix64(bal Balance) (value cadence.UFix64, roundedOff bool, err error)
- func EVMChainIDFromFlowChainID(flowChainID flow.ChainID) *big.Int
- func ErrorFromCode(errorCode ErrorCode) error
- func GenesisBlockHash(chainID flow.ChainID) gethCommon.Hash
- func GenesisTimestamp(flowChainID flow.ChainID) uint64
- func IsABackendError(err error) bool
- func IsACOAAddress(addr Address) bool
- func IsAFatalError(err error) bool
- func IsAInsufficientTotalSupplyError(err error) bool
- func IsAStateError(err error) bool
- func IsAUnauthorizedMethodCallError(err error) bool
- func IsAnExtendedPrecompileAddress(addr Address) bool
- func IsWithdrawBalanceRoundingError(err error) bool
- func MakeBigIntInFlow(amount uint64) *big.Int
- func OneFlow() *big.Int
- func SliceToChecksumLength(input []byte) [ChecksumLength]byte
- func UnsafeCastOfBalanceToFloat64(bal Balance) float64
- type Account
- type Address
- type AddressAllocator
- type AggregatedPrecompiledCalls
- type Backend
- type BackendError
- type BackendStorage
- type BackendStorageSnapshot
- type Balance
- func AddBalance(bal1 Balance, bal2 Balance) (Balance, error)
- func CopyBalance(inp Balance) Balance
- func MakeABalanceInFlow(amount uint64) Balance
- func NewBalance(inp *big.Int) Balance
- func NewBalanceFromUFix64(inp cadence.UFix64) Balance
- func OneFlowBalance() Balance
- func SubBalance(bal1 Balance, bal2 Balance) (Balance, error)
- type BaseView
- type Block
- type BlockContext
- type BlockProposal
- type BlockProposalV0
- type BlockSnapshot
- type BlockSnapshotProvider
- type BlockStore
- type BlockV0
- type BlockView
- type COAOwnershipProof
- type COAOwnershipProofInContext
- type Code
- type ContractHandler
- type Data
- type DirectCall
- func DirectCallFromEncoded(encoded []byte) (*DirectCall, error)
- func NewContractCall(caller Address, to Address, data Data, gasLimit uint64, value *big.Int, ...) *DirectCall
- func NewDeployCall(caller Address, code Code, gasLimit uint64, value *big.Int, nonce uint64) *DirectCall
- func NewDeployCallWithTargetAddress(caller Address, to Address, code Code, gasLimit uint64, value *big.Int, ...) *DirectCall
- func NewDepositCall(bridge Address, address Address, amount *big.Int, nonce uint64) *DirectCall
- func NewTransferCall(from Address, to Address, amount *big.Int, nonce uint64) *DirectCall
- func NewWithdrawCall(bridge Address, address Address, amount *big.Int, nonce uint64) *DirectCall
- type Emulator
- type ErrorCode
- type FLOWTokenVault
- type FatalError
- type FlowAddress
- type GasLimit
- type HotView
- type KeyIndices
- type LightLog
- type LightReceipt
- type PrecompiledCalls
- type PrecompiledContract
- type PublicPath
- type ReadOnlyBlockView
- type ReadOnlyView
- type ReplayResultCollector
- type Result
- func (res *Result) DeployedContractAddressString() string
- func (res *Result) ErrorMsg() string
- func (res *Result) Failed() bool
- func (res *Result) Invalid() bool
- func (res *Result) LightReceipt() *LightReceipt
- func (res *Result) RLPEncodedLogs() ([]byte, error)
- func (res *Result) Receipt() *gethTypes.Receipt
- func (res *Result) ResultSummary() *ResultSummary
- func (res *Result) SetValidationError(err error)
- func (res *Result) StateChangeChecksum() [ChecksumLength]byte
- func (res *Result) Successful() bool
- func (res *Result) VMErrorString() string
- type ResultSummary
- type RunCall
- type Signature
- type Signatures
- type SignedData
- type SlotAddress
- type SlotEntry
- type StateDB
- type StateError
- type Status
- type StorageProvider
- type TransactionHashes
Constants ¶
const ( // tx type 255 is used for direct calls from COAs DirectCallTxType = byte(255) UnknownCallSubType = byte(0) DepositCallSubType = byte(1) WithdrawCallSubType = byte(2) TransferCallSubType = byte(3) DeployCallSubType = byte(4) ContractCallSubType = byte(5) // Note that these gas values might need to change if we // change the transaction (e.g. add access list), // then it has to be updated to use Intrinsic function // to calculate the minimum gas needed to run the transaction. IntrinsicFeeForTokenTransfer = gethParams.TxGas // 21_000 is the minimum for a transaction + max gas allowed for receive/fallback methods DefaultGasLimitForTokenTransfer = IntrinsicFeeForTokenTransfer + 2_300 // the value is set to the gas limit for transfer to facilitate transfers // to smart contract addresses. DepositCallGasLimit = DefaultGasLimitForTokenTransfer WithdrawCallGasLimit = DefaultGasLimitForTokenTransfer )
const ( AggregatedPrecompiledCallsEncodingByteSize int = 1 AggregatedPrecompiledCallsEncodingVersion uint8 = 2 // current version )
const AddressLength = gethCommon.AddressLength
AddressLength holds the number of bytes used for each EVM address
const COAAddressTemplate = "A.%v.EVM.CadenceOwnedAccountCreated"
const CadenceOwnedAccountCreatedTypeAddressFieldName = "address"
const ChecksumLength = 4
ChecksumLength captures number of bytes a checksum uses
const FlowEVMSpecialAddressPrefixLen = 12
FlowEVMSpecialAddressPrefixLen captures the number of prefix bytes with constant values for special accounts (extended precompiles and COAs).
The prefix length should insure a high-enough level of security against finding a pre-image using the hash function used for EVM addresses generation (Keccak256). This is required to avoid finding an EVM address that is also a valid FlowEVM address. The target (minimal) security in this case is the security level provided by EVM addresses. Since EVM addresses are 160-bits long, they offer only 80 bits of security (collision resistance offers the lowest level). A pre-image resistance of 80 bits requires the prefix to be at least 80-bits long (i.e 10 bytes). When used as a prefix in EVM addresses (20-bytes long), a prefix length of 12 bytes leaves a variable part of 8 bytes (64 bits).
const InvalidTransactionGasCost = 1_000
InvalidTransactionGasCost is a gas cost we charge when a transaction or call fails at validation step. in typical evm environment this doesn't exist given if a transaction is invalid it won't be included and no fees can be charged for users even though the validation has used some resources, in our case given we charge the fees on flow transaction and we are doing on chain validation we can/should charge the user for the validation fee.
Variables ¶
var ( // Using leading zeros for prefix helps with the storage compactness. // // Prefix for the built-in EVM precompiles FlowEVMNativePrecompileAddressPrefix = [FlowEVMSpecialAddressPrefixLen]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // Prefix for the extended precompiles FlowEVMExtendedPrecompileAddressPrefix = [FlowEVMSpecialAddressPrefixLen]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} // Prefix for the COA addresses FlowEVMCOAAddressPrefix = [FlowEVMSpecialAddressPrefixLen]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2} // Coinbase address CoinbaseAddress = Address{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0} )
var ( AttoScale = 18 UFixedScale = fixedpoint.Fix64Scale UFixedToAttoConversionScale = AttoScale - UFixedScale UFixToAttoConversionMultiplier = new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(UFixedToAttoConversionScale)), nil) OneFlowInUFix64 = cadence.UFix64(uint64(math.Pow(10, float64(UFixedScale)))) EmptyBalance = Balance(new(big.Int)) )
var ( FlowEVMPreviewNetChainID = big.NewInt(646) FlowEVMTestNetChainID = big.NewInt(545) FlowEVMMainNetChainID = big.NewInt(747) FlowEVMPreviewNetChainIDInUInt64 = FlowEVMPreviewNetChainID.Uint64() FlowEVMTestNetChainIDInUInt64 = FlowEVMTestNetChainID.Uint64() FlowEVMMainNetChainIDInUInt64 = FlowEVMMainNetChainID.Uint64() )
var ( // DefaultBlockLevelGasLimit is the default value for the block gas limit // currently set to maximum and we don't consider any limit // given number of included EVM transactions are naturally // limited by the Flow block production limits. DefaultBlockLevelGasLimit = uint64(math.MaxUint64) // DefaultBaseFee is the default base fee value for the block // is set to zero but can be updated by the config DefaultBaseFee = big.NewInt(0) // DefaultDirectCallBaseGasUsage holds the minimum gas // charge for direct calls DefaultDirectCallBaseGasUsage = uint64(21_000) // DefaultDirectCallGasPrice captures the default // gas price for the direct call. // its set to zero currently given that we charge // computation but we don't need to refund to any // coinbase account. DefaultDirectCallGasPrice = uint64(0) // anything block number above 0 works here BlockNumberForEVMRules = big.NewInt(1) )
var ( // ErrInvalidBalance is returned when an invalid amount is provided for transfer or balance change (e.g. negative) ErrInvalidBalance = errors.New("invalid amount for transfer or balance change") // ErrInsufficientComputation is returned when not enough computation is // left in the context of flow transaction to execute the evm operation. ErrInsufficientComputation = errors.New("insufficient computation") ErrUnauthorizedMethodCall = errors.New("unauthorized method call") // ErrWithdrawBalanceRounding is returned when withdraw call has a balance that could // result in rounding error, i.e. the balance contains fractions smaller than 10^8 Flow (smallest unit allowed to transfer). ErrWithdrawBalanceRounding = errors.New("withdraw failed! the balance is susceptible to the rounding error") // ErrUnexpectedEmptyResult is returned when a result is expected to be returned by the emulator // but nil has been returned. This should never happen and is a safety error. ErrUnexpectedEmptyResult = errors.New("unexpected empty result has been returned") // ErrInsufficientTotalSupply is returned when flow token // withdraw request is received but not enough balance is on EVM native token vault // this should never happen but its a safety measure to protect Flow against EVM issues. ErrInsufficientTotalSupply = NewFatalError(errors.New("insufficient total supply")) // ErrNotImplemented is a fatal error when something is called that is not implemented ErrNotImplemented = NewFatalError(errors.New("a functionality is called that is not implemented")) )
var AddressBytesCadenceType = cadence.NewConstantSizedArrayType(AddressLength, cadence.UInt8Type)
var AddressBytesSemaType = sema.ByteArrayType
var EmptyAddress = Address(gethCommon.Address{})
EmptyAddress is an empty evm address
var FlowAddressCadenceType = cadence.AddressType
var FlowAddressSemaType = sema.TheAddressType
var KeyIndicesCadenceType = cadence.NewVariableSizedArrayType(cadence.UInt64Type)
var KeyIndicesSemaType = &sema.VariableSizedType{Type: sema.UInt64Type}
var PublicPathCadenceType = cadence.PathType
var PublicPathSemaType = sema.PathType
var SignatureCadenceType = cadence.NewVariableSizedArrayType(cadence.UInt8Type)
var SignaturesCadenceType = cadence.NewVariableSizedArrayType(SignatureCadenceType)
var SignaturesSemaType = sema.ByteArrayArrayType
var SignedDataCadenceType = cadence.NewVariableSizedArrayType(cadence.UInt8Type)
var SignedDataSemaType = sema.ByteArrayType
var TestNetGenesisHash = gethCommon.Hash{
60, 220, 118, 103, 27, 85, 73, 205,
46, 2, 83, 105, 179, 240, 255, 14,
55, 21, 42, 211, 55, 87, 177, 115,
118, 144, 125, 37, 146, 116, 168, 229,
}
when testnet was launched the block structure didn't have the preRandao filed so the hash of the event was different from hashing the genesis block struct.
Functions ¶
func BalanceConversionToUFix64ProneToRoundingError ¶ added in v0.37.1
BalanceConversionToUFix64ProneToRoundingError returns true if casting to UFix64 could result in rounding error
func BalanceToBigInt ¶ added in v0.33.30
BalanceToBigInt convert balance into big int
func BalancesAreEqual ¶ added in v0.36.2
BalancesAreEqual returns true if balances are equal
func COAOwnershipProofSignatureCountFromEncoded ¶ added in v0.33.30
func ConvertBalanceToUFix64 ¶ added in v0.33.30
ConvertBalanceToUFix64 casts the balance into a UFix64,
Warning! The smallest unit of Flow token that a FlowVault (Cadence) could store is 1e10^-8, so transferring smaller values (or values with smalls fractions) could result in loss in conversion. The rounded flag should be used to prevent loss of assets.
func EVMChainIDFromFlowChainID ¶ added in v0.33.30
func ErrorFromCode ¶ added in v0.33.30
func GenesisBlockHash ¶ added in v0.33.30
func GenesisBlockHash(chainID flow.ChainID) gethCommon.Hash
GenesisBlockHash returns the genesis block hash in the EVM environment
func GenesisTimestamp ¶ added in v0.37.1
GenesisTimestamp returns the block time stamp for EVM genesis block
func IsABackendError ¶ added in v0.33.30
IsABackendError returns true if the error or any underlying errors is a backend error
func IsACOAAddress ¶ added in v0.33.30
IsACOAAddress returns true if the address is a COA address
This test insures `addr` has been generated as a COA address with high probability. Brute forcing an EVM address `addr` to pass the `IsACOAAddress` test is as hard as the bit-length of `FlowEVMCOAAddressPrefix` (here 96 bits). Although this is lower than the protocol-wide security level in Flow (128 bits), it remains higher than the EVM addresses security (80 bits when considering collision attacks)
func IsAFatalError ¶
IsAFatalError returns true if the error or underlying error is of fatal type.
func IsAInsufficientTotalSupplyError ¶
IsAInsufficientTotalSupplyError returns true if the error type is InsufficientTotalSupplyError
func IsAStateError ¶
IsAStateError returns true if the error or any underlying errors is a state error
func IsAUnauthorizedMethodCallError ¶ added in v0.36.4
IsAUnauthorizedMethodCallError returns true if the error type is UnauthorizedMethodCallError
func IsAnExtendedPrecompileAddress ¶ added in v0.33.30
IsAnExtendedPrecompileAddress returns true if the address is a extended precompile address
func IsWithdrawBalanceRoundingError ¶ added in v0.33.30
IsWithdrawBalanceRoundingError returns true if the error type is ErrWithdrawBalanceRounding
func MakeBigIntInFlow ¶ added in v0.37.1
MakeBigIntInFlow makes big int containing `amount` of Flow
func SliceToChecksumLength ¶ added in v0.37.22
func SliceToChecksumLength(input []byte) [ChecksumLength]byte
SliceToChecksumLength cuts the first 4 bytes of the input and convert it into checksum
func UnsafeCastOfBalanceToFloat64 ¶ added in v0.36.3
UnsafeCastOfBalanceToFloat64 tries to cast the balance into a float64,
Warning! this method is only provided for logging and metric reporting purposes, using float64 for any actual computation result in non-determinism.
Types ¶
type Account ¶
type Account interface { // Address returns the address of this account Address() Address // Balance returns the balance of this account Balance() Balance // Code returns the code of this account Code() Code // CodeHash returns the code hash of this account CodeHash() []byte // Nonce returns the nonce of this account Nonce() uint64 // Deposit deposits the token from the given vault into this account Deposit(*FLOWTokenVault) // Withdraw withdraws the balance from account and // return it as a FlowTokenVault // works only for COAs Withdraw(Balance) *FLOWTokenVault // Transfer is a utility method on top of call for transferring tokens to another account Transfer(to Address, balance Balance) // Deploy deploys a contract to the environment // the new deployed contract would be at the returned // result address and the contract data is not controlled by the COA // works only for COAs Deploy(Code, GasLimit, Balance) *ResultSummary // Call calls a smart contract function with the given data. // The gas usage is limited by the given gas limit, // and the Flow transaction's computation limit. // The fees are deducted from the COA // and are transferred to the target address. // if no data is provided it would behave as transferring tokens to the // target address // works only for COAs Call(Address, Data, GasLimit, Balance) *ResultSummary }
Account is an EVM account, currently three types of accounts are supported on Flow EVM, externally owned accounts (EOAs), smart contract accounts and cadence owned accounts Cadence-owned-account (COA) is a new type of account in the environment, that instead of being managed by public key, it is managed by a resource owned by a Flow account.
In other words, the FVM account who owns the FOA resource can bridge native tokens to and from the account associated with the COA, deploy contracts to the environment, or call methods on contracts without the need to sign a transaction.
type Address ¶
type Address gethCommon.Address
Address is an EVM-compatible address
func COAAddressFromFlowCOACreatedEvent ¶ added in v0.33.30
func NewAddress ¶
func NewAddress(addr gethCommon.Address) Address
NewAddress constructs a new Address
func NewAddressFromBytes ¶
NewAddressFromBytes constructs a new address from bytes
func NewAddressFromString ¶
NewAddressFromString constructs a new address from an string
func (Address) String ¶ added in v0.33.30
String returns the hex encoding of the address it returns empty string if address is empty
func (Address) ToCadenceValue ¶ added in v0.33.30
func (Address) ToCommon ¶
func (fa Address) ToCommon() gethCommon.Address
ToCommon returns the geth address
type AddressAllocator ¶
type AddressAllocator interface { // AllocateAddress allocates an address to be used by a COA resource AllocateCOAAddress(uuid uint64) Address // COAFactoryAddress returns the address for the COA factory COAFactoryAddress() Address // NativeTokenBridgeAddress returns the address for the native token bridge // used for deposit and withdraw calls NativeTokenBridgeAddress() Address // AllocateAddress allocates an address by index to be used by a precompile contract AllocatePrecompileAddress(index uint64) Address }
AddressAllocator allocates addresses, used by the handler
type AggregatedPrecompiledCalls ¶ added in v0.35.17
type AggregatedPrecompiledCalls []PrecompiledCalls
AggregatedPrecompiledCalls aggregates a list of precompiled calls the list should be sorted by the address
func AggregatedPrecompileCallsFromEncoded ¶ added in v0.35.17
func AggregatedPrecompileCallsFromEncoded(encoded []byte) (AggregatedPrecompiledCalls, error)
AggregatedPrecompileCallsFromEncoded constructs an AggregatedPrecompileCalls from encoded data
func (AggregatedPrecompiledCalls) Encode ¶ added in v0.35.17
func (apc AggregatedPrecompiledCalls) Encode() ([]byte, error)
Encode encodes the aggregated precompile calls using rlp encoding if there is no underlying call, we encode to empty bytes to save space on transaction results (common case) TODO: In the future versions of the encoding we might skip encoding the inputs given it just takes space and not needed during execution time
func (AggregatedPrecompiledCalls) IsEmpty ¶ added in v0.35.17
func (apc AggregatedPrecompiledCalls) IsEmpty() bool
IsEmpty returns true if all of the underlying precompiled calls are empty
type Backend ¶
type Backend interface { BackendStorage environment.Meter environment.EventEmitter environment.BlockInfo environment.RandomGenerator environment.ContractFunctionInvoker environment.UUIDGenerator environment.Tracer environment.EVMMetricsReporter environment.LoggerProvider }
Backend provides a subset of the FVM environment functionality Any error returned by a Backend is expected to be a `FatalError` or a `BackendError`.
type BackendError ¶ added in v0.33.30
type BackendError struct {
// contains filtered or unexported fields
}
BackendError is a non-fatal error wraps errors returned from the backend
func NewBackendError ¶ added in v0.33.30
func NewBackendError(rootCause error) BackendError
NewBackendError returns a new BackendError
func (BackendError) Error ¶ added in v0.33.30
func (err BackendError) Error() string
func (BackendError) Unwrap ¶ added in v0.33.30
func (err BackendError) Unwrap() error
Unwrap unwraps the underlying evm error
type BackendStorage ¶ added in v0.37.22
type BackendStorage interface { environment.ValueStore }
BackendStorage provides an interface for storage of registers
type BackendStorageSnapshot ¶
BackendStorageSnapshot provides a read only view of registers
type Balance ¶
Balance represents the balance of an address in the evm environment (Flow EVM), balances are kept in atto-flow (1e-18 flow); the smallest denomination of FLOW token (similar to how Wei is used to store Eth) But A Cadence FLOW Vault uses a Cadence.UFix64 to store values in Flow, which means 1e-8 is the smallest value that can be stored on the vault. The balance here considers the highest precision (atto-flow) but utility function has been provided for conversion from/to UFix64 to prevent accidental conversion errors and dealing with rounding errors.
func AddBalance ¶ added in v0.33.30
AddBalance balance 2 to balance 1 and returns the result as a new balance
func CopyBalance ¶ added in v0.33.30
CopyBalance creates a copy of the balance
func MakeABalanceInFlow ¶ added in v0.33.30
MakeABalanceInFlow makes a balance object that has `amount` Flow Token in it
func NewBalance ¶ added in v0.33.30
NewBalance constructs a new balance from an atto-flow value
func NewBalanceFromUFix64 ¶ added in v0.33.30
NewBalanceFromUFix64 constructs a new balance from flow value (how its stored in Cadence Flow)
func OneFlowBalance ¶ added in v0.33.30
func OneFlowBalance() Balance
OneFlowBalance creates a new balance including one flow
type BaseView ¶
type BaseView interface { ReadOnlyView // Creates a new account CreateAccount( addr gethCommon.Address, balance *uint256.Int, nonce uint64, code []byte, codeHash gethCommon.Hash, ) error // UpdateAccount updates a account UpdateAccount( addr gethCommon.Address, balance *uint256.Int, nonce uint64, code []byte, codeHash gethCommon.Hash, ) error // DeleteAccount deletes an account DeleteAccount(addr gethCommon.Address) error // UpdateSlot updates the value for the given slot in the main storage UpdateSlot( slot SlotAddress, value gethCommon.Hash, ) error // Commit commits the changes Commit() error }
BaseView is a low-level mutable view of the state baseview is usually updated at the commit calls to the higher level view
type Block ¶
type Block struct { // the hash of the parent block ParentBlockHash gethCommon.Hash // Height returns the height of this block Height uint64 // Timestamp is a Unix timestamp in seconds at which the block was created // Note that this value must be provided from the FVM Block Timestamp uint64 // holds the total amount of the native token deposited in the evm side. (in attoflow) TotalSupply *big.Int // ReceiptRoot returns the root hash of the receipts emitted in this block // Note that this value won't be unique to each block, for example for the // case of empty trie of receipts or a single receipt with no logs and failed state // the same receipt root would be reported for block. ReceiptRoot gethCommon.Hash // TransactionHashRoot returns the root hash of the transaction hashes // included in this block. // Note that despite similar functionality this is a bit different than TransactionRoot // provided by Ethereum. TransactionRoot constructs a Merkle proof with leafs holding // encoded transactions as values. But TransactionHashRoot uses transaction hash // values as node values. Proofs are still compatible but might require an extra hashing step. TransactionHashRoot gethCommon.Hash // TotalGasUsed stores gas used by all transactions included in the block. TotalGasUsed uint64 // PrevRandao is the value returned for block.prevrandao opcode PrevRandao gethCommon.Hash }
Block represents a evm block. It captures block info such as height and state
func GenesisBlock ¶
GenesisBlock returns the genesis block in the EVM environment
func NewBlock ¶
func NewBlock( parentBlockHash gethCommon.Hash, height uint64, timestamp uint64, totalSupply *big.Int, prevRandao gethCommon.Hash, ) *Block
NewBlock constructs a new block
func NewBlockFromBytes ¶
NewBlockFromBytes constructs a new block from encoded data
type BlockContext ¶
type BlockContext struct { ChainID *big.Int BlockNumber uint64 BlockTimestamp uint64 DirectCallBaseGasUsage uint64 DirectCallGasPrice uint64 TxCountSoFar uint TotalGasUsedSoFar uint64 GasFeeCollector Address GetHashFunc func(n uint64) gethCommon.Hash Random gethCommon.Hash Tracer *tracers.Tracer // a set of extra precompiled contracts to be injected ExtraPrecompiledContracts []PrecompiledContract }
BlockContext holds the context needed for the emulator operations
func NewDefaultBlockContext ¶
func NewDefaultBlockContext(BlockNumber uint64) BlockContext
NewDefaultBlockContext returns a new default block context
type BlockProposal ¶ added in v0.36.2
type BlockProposal struct { Block // Receipts keeps a order list of light receipts generated during block execution Receipts []LightReceipt // TxHashes keeps transaction hashes included in this block proposal TxHashes TransactionHashes }
BlockProposal is a EVM block proposal holding all the interim data of block before commitment
func NewBlockProposal ¶ added in v0.36.2
func NewBlockProposal( parentBlockHash gethCommon.Hash, height uint64, timestamp uint64, totalSupply *big.Int, prevRandao gethCommon.Hash, ) *BlockProposal
func NewBlockProposalFromBytes ¶ added in v0.36.2
func NewBlockProposalFromBytes(encoded []byte) (*BlockProposal, error)
NewBlockProposalFromBytes constructs a new block proposal from encoded data
func (*BlockProposal) AppendTransaction ¶ added in v0.36.2
func (b *BlockProposal) AppendTransaction(res *Result)
AppendTransaction appends a transaction hash to the list of transaction hashes of the block and also update the receipts
func (*BlockProposal) PopulateReceiptRoot ¶ added in v0.36.2
func (b *BlockProposal) PopulateReceiptRoot()
PopulateReceiptRoot sets the receiptRoot
func (*BlockProposal) PopulateRoots ¶ added in v0.36.2
func (b *BlockProposal) PopulateRoots()
PopulateRoots populates receiptRoot and transactionHashRoot
func (*BlockProposal) PopulateTransactionHashRoot ¶ added in v0.36.2
func (b *BlockProposal) PopulateTransactionHashRoot()
PopulateTransactionHashRoot sets the transactionHashRoot
func (*BlockProposal) ToBytes ¶ added in v0.36.2
func (b *BlockProposal) ToBytes() ([]byte, error)
ToBytes encodes the block proposal into bytes
type BlockProposalV0 ¶ added in v0.37.5
type BlockProposalV0 struct { BlockV0 Receipts []LightReceipt TxHashes TransactionHashes }
type BlockSnapshot ¶
type BlockSnapshot interface { // BlockContext constructs and returns the block context for the block // // Warning! the block hash provider on this one has to return empty // for the current block to stay compatible with how on-chain EVM // behaves. so if we are on block 10, and we query for the block hash on block // 10 it should return empty hash. BlockContext() (BlockContext, error) }
BlockSnapshot provides access to the block information at specific block height
type BlockSnapshotProvider ¶
type BlockSnapshotProvider interface { // GetSnapshotAt returns a readonly snapshot of block given evm block height GetSnapshotAt(evmBlockHeight uint64) (BlockSnapshot, error) }
type BlockStore ¶
type BlockStore interface { // LatestBlock returns the latest appended block LatestBlock() (*Block, error) // BlockHash returns the hash of the block at the given height BlockHash(height uint64) (gethCommon.Hash, error) // BlockProposal returns the active block proposal BlockProposal() (*BlockProposal, error) // UpdateBlockProposal replaces the current block proposal with the ones passed UpdateBlockProposal(*BlockProposal) error // CommitBlockProposal commits the block proposal and update the chain of blocks CommitBlockProposal(*BlockProposal) error }
BlockStore stores the chain of blocks
type BlockV0 ¶ added in v0.37.5
type BlockV0 struct { ParentBlockHash gethCommon.Hash Height uint64 Timestamp uint64 TotalSupply *big.Int ReceiptRoot gethCommon.Hash TransactionHashRoot gethCommon.Hash TotalGasUsed uint64 }
before adding PrevRandao to the block
type BlockView ¶
type BlockView interface { // DirectCall executes a direct call DirectCall(call *DirectCall) (*Result, error) // RunTransaction executes an evm transaction RunTransaction(tx *gethTypes.Transaction) (*Result, error) // DryRunTransaction executes unsigned transaction but does not persist the state changes, // since transaction is not signed, from address is used as the signer. DryRunTransaction(tx *gethTypes.Transaction, from gethCommon.Address) (*Result, error) // BatchRunTransactions executes a batch of evm transactions producing // a slice of execution Result where each result corresponds to each // item in the txs slice. BatchRunTransactions(txs []*gethTypes.Transaction) ([]*Result, error) }
BlockView facilitates execution of a transaction or a direct evm call in the context of a block Any error returned by any of the methods (e.g. stateDB errors) if non-fatal stops the outer flow transaction if fatal stops the node. EVM validation errors and EVM execution errors are part of the returned result and should be handled separately.
type COAOwnershipProof ¶ added in v0.33.30
type COAOwnershipProof struct { KeyIndices KeyIndices Address FlowAddress CapabilityPath PublicPath Signatures Signatures }
COAOwnershipProof is a proof that a flow account controls a COA resource. To do so, the flow account (Address is address of this account) provides signatures (with proper total weights) over an arbitrary data input set by proof requester. KeyIndices captures, which account keys has been used for signatures. Beside signatures, it provides the CapabilityPath where the resource EVMAddress capability is stored.
func COAOwnershipProofFromEncoded ¶ added in v0.33.30
func COAOwnershipProofFromEncoded(data []byte) (*COAOwnershipProof, error)
func (*COAOwnershipProof) Encode ¶ added in v0.33.30
func (p *COAOwnershipProof) Encode() ([]byte, error)
type COAOwnershipProofInContext ¶ added in v0.33.30
type COAOwnershipProofInContext struct { COAOwnershipProof SignedData SignedData EVMAddress Address }
COAOwnershipProofInContext contains all the data needed to verify a COAOwnership proof. The proof is verified by checking the signatures over the input signed data (SignedData), then loading the resource capability from the provided path in the proof, and at last checking if the EVMAddress of the resource matches the provided one.
func NewCOAOwnershipProofInContext ¶ added in v0.33.30
func NewCOAOwnershipProofInContext(sd []byte, addr Address, encodedProof []byte) (*COAOwnershipProofInContext, error)
func (*COAOwnershipProofInContext) ToCadenceValues ¶ added in v0.33.30
func (proof *COAOwnershipProofInContext) ToCadenceValues() []cadence.Value
type ContractHandler ¶
type ContractHandler interface { // DeployCOA deploys a Cadence owned account and return the address DeployCOA(uuid uint64) Address // AccountByAddress returns an account by address // if isAuthorized is set, it allows for functionality like `call`, `deploy` // should only be set for the cadence owned accounts only. AccountByAddress(address Address, isAuthorized bool) Account // LastExecutedBlock returns information about the last executed block LastExecutedBlock() *Block // Run runs a transaction in the evm environment, // collects the gas fees, and transfers it to the gasFeeCollector account Run(tx []byte, gasFeeCollector Address) *ResultSummary // DryRun simulates execution of the provided RLP-encoded and unsigned transaction. // Because the transaction is unsigned the from address is required, since // from address is normally derived from the transaction signature. // The function should not have any persisted changes made to the state. DryRun(tx []byte, from Address) *ResultSummary // BatchRun runs transaction batch in the evm environment, // collect all the gas fees and transfers the gas fees to the gasFeeCollector account. BatchRun(txs [][]byte, gasFeeCollector Address) []*ResultSummary // FlowTokenAddress returns the address where FLOW token is deployed FlowTokenAddress() common.Address // EVMContractAddress returns the address where EVM is deployed EVMContractAddress() common.Address // GenerateResourceUUID generates a new UUID for a resource GenerateResourceUUID() uint64 // Constructs and commits a new block from the block proposal CommitBlockProposal() }
ContractHandler handles operations on the evm environment
type DirectCall ¶
type DirectCall struct { Type byte SubType byte From Address To Address Data []byte Value *big.Int GasLimit uint64 Nonce uint64 }
DirectCall captures all the data related to a direct call to evm direct calls are similar to transactions but they don't have signatures and don't need sequence number checks Note that while we don't check the nonce, it impacts hash calculation and also impacts the address of resulting contract when deployed through direct calls. Users don't have the worry about the nonce, handler sets it to the right value.
func DirectCallFromEncoded ¶ added in v0.33.30
func DirectCallFromEncoded(encoded []byte) (*DirectCall, error)
DirectCallFromEncoded constructs a DirectCall from encoded data
func NewContractCall ¶
func NewContractCall( caller Address, to Address, data Data, gasLimit uint64, value *big.Int, nonce uint64, ) *DirectCall
NewContractCall constructs a new contract call
func NewDeployCall ¶
func NewDeployCall( caller Address, code Code, gasLimit uint64, value *big.Int, nonce uint64, ) *DirectCall
NewDeployCall constructs a new deploy direct call
func NewDeployCallWithTargetAddress ¶ added in v0.33.30
func NewDeployCallWithTargetAddress( caller Address, to Address, code Code, gasLimit uint64, value *big.Int, nonce uint64, ) *DirectCall
NewDeployCallWithTargetAddress constructs a new deployment call for the given target address
Warning! This subtype should only be used internally for deploying contracts at given addresses (e.g. COA account init setup) should not be used for other means.
func NewDepositCall ¶
NewDepositCall constructs a new deposit direct call
func NewTransferCall ¶
func NewWithdrawCall ¶
NewDepositCall constructs a new withdraw direct call
func (*DirectCall) EmptyToField ¶ added in v0.33.30
func (dc *DirectCall) EmptyToField() bool
EmptyToField returns true if `to` field contains an empty address
func (*DirectCall) Encode ¶
func (dc *DirectCall) Encode() ([]byte, error)
Encode encodes the direct call it also adds the type as the very first byte, similar to how evm encodes types.
func (*DirectCall) Hash ¶
func (dc *DirectCall) Hash() gethCommon.Hash
Hash computes the hash of a direct call
func (*DirectCall) Message ¶
func (dc *DirectCall) Message() *gethCore.Message
Message constructs a core.Message from the direct call
func (*DirectCall) Transaction ¶ added in v0.33.30
func (dc *DirectCall) Transaction() *gethTypes.Transaction
Transaction constructs a geth.Transaction from the direct call
type Emulator ¶
type Emulator interface { // constructs a new block view NewReadOnlyBlockView(ctx BlockContext) (ReadOnlyBlockView, error) // constructs a new block NewBlockView(ctx BlockContext) (BlockView, error) }
Emulator emulates an evm-compatible chain
type ErrorCode ¶ added in v0.33.30
type ErrorCode uint16
const ( ErrCodeNoError ErrorCode = 0 // covers all other validation codes that doesn't have an specific code ValidationErrCodeMisc ErrorCode = 100 // general execution error returned for cases that don't have an specific code ExecutionErrCodeMisc ErrorCode = 400 )
internal error codes
const ( // the nonce of the tx is lower than the expected ValidationErrCodeNonceTooLow ErrorCode = iota + 201 // the nonce of the tx is higher than the expected ValidationErrCodeNonceTooHigh // tx sender account has reached to the maximum nonce ValidationErrCodeNonceMax // not enough gas is available on the block to include this transaction ValidationErrCodeGasLimitReached // the transaction sender doesn't have enough funds for transfer(topmost call only). ValidationErrCodeInsufficientFundsForTransfer // creation transaction provides the init code bigger than init code size limit. ValidationErrCodeMaxInitCodeSizeExceeded // the total cost of executing a transaction is higher than the balance of the user's account. ValidationErrCodeInsufficientFunds // overflow detected when calculating the gas usage ValidationErrCodeGasUintOverflow // the transaction is specified to use less gas than required to start the invocation. ValidationErrCodeIntrinsicGas // the transaction is not supported in the current network configuration. ValidationErrCodeTxTypeNotSupported // tip was set to higher than the total fee cap ValidationErrCodeTipAboveFeeCap // an extremely big numbers is set for the tip field ValidationErrCodeTipVeryHigh // an extremely big numbers is set for the fee cap field ValidationErrCodeFeeCapVeryHigh // the transaction fee cap is less than the base fee of the block ValidationErrCodeFeeCapTooLow // the sender of a transaction is a contract ValidationErrCodeSenderNoEOA // the transaction fee cap is less than the blob gas fee of the block. ValidationErrCodeBlobFeeCapTooLow )
geth evm core errors (reserved range: [201-300) )
const ( // execution ran out of gas ExecutionErrCodeOutOfGas ErrorCode = iota + 301 // contract creation code storage out of gas ExecutionErrCodeCodeStoreOutOfGas // max call depth exceeded ExecutionErrCodeDepth // insufficient balance for transfer ExecutionErrCodeInsufficientBalance // contract address collision" ExecutionErrCodeContractAddressCollision // execution reverted ExecutionErrCodeExecutionReverted // max initcode size exceeded ExecutionErrCodeMaxInitCodeSizeExceeded // max code size exceeded ExecutionErrCodeMaxCodeSizeExceeded // invalid jump destination ExecutionErrCodeInvalidJump // write protection ExecutionErrCodeWriteProtection // return data out of bounds ExecutionErrCodeReturnDataOutOfBounds // gas uint64 overflow ExecutionErrCodeGasUintOverflow // invalid code: must not begin with 0xef ExecutionErrCodeInvalidCode // nonce uint64 overflow ExecutionErrCodeNonceUintOverflow )
evm execution errors (reserved range: [301-400) )
func ExecutionErrorCode ¶ added in v0.33.30
func ValidationErrorCode ¶ added in v0.33.30
type FLOWTokenVault ¶
type FLOWTokenVault struct {
// contains filtered or unexported fields
}
FLOWTokenVault holds a balance of flow token
func NewFlowTokenVault ¶
func NewFlowTokenVault(balance Balance) *FLOWTokenVault
func (*FLOWTokenVault) Balance ¶
func (t *FLOWTokenVault) Balance() Balance
func (*FLOWTokenVault) Deposit ¶
func (t *FLOWTokenVault) Deposit(inp *FLOWTokenVault) error
func (*FLOWTokenVault) Withdraw ¶
func (t *FLOWTokenVault) Withdraw(b Balance) (*FLOWTokenVault, error)
type FatalError ¶
type FatalError struct {
// contains filtered or unexported fields
}
FatalError is used for any error that is not user related and something unusual has happened. Usually we stop the node when this happens given it might have a non-deterministic root.
func NewFatalError ¶
func NewFatalError(rootCause error) FatalError
NewFatalError returns a new FatalError
func (FatalError) Error ¶
func (err FatalError) Error() string
func (FatalError) Unwrap ¶
func (err FatalError) Unwrap() error
Unwrap unwraps the underlying fatal error
type FlowAddress ¶ added in v0.33.30
func (FlowAddress) ToCadenceValue ¶ added in v0.33.30
func (addr FlowAddress) ToCadenceValue() cadence.Address
type GasLimit ¶
type GasLimit uint64
GasLimit sets the limit for the total gas used by a transaction
type HotView ¶
type HotView interface { ReadOnlyView // CreateAccount creates a new account CreateAccount(gethCommon.Address) error // CreateContract is used whenever a contract is created. This may be preceded // by CreateAccount, but that is not required if it already existed in the // state due to funds sent beforehand. CreateContract(gethCommon.Address) // SelfDestruct set the flag for destruction of the account after execution SelfDestruct(gethCommon.Address) error // SubBalance subtracts the amount from the balance the given address SubBalance(gethCommon.Address, *uint256.Int) error // AddBalance adds the amount to the balance of the given address AddBalance(gethCommon.Address, *uint256.Int) error // SetNonce sets the nonce for the given address SetNonce(gethCommon.Address, uint64) error // SetCode sets the code for the given address SetCode(gethCommon.Address, []byte) error // SetState sets a value for the given slot in the main storage SetState(SlotAddress, gethCommon.Hash) error // SetTransientState sets a value for the given slot in the transient storage SetTransientState(SlotAddress, gethCommon.Hash) // AddRefund adds the amount to the total (gas) refund AddRefund(uint64) error // SubRefund subtracts the amount from the total (gas) refund SubRefund(uint64) error // AddAddressToAccessList adds an address to the per-transaction access list AddAddressToAccessList(addr gethCommon.Address) (addressAdded bool) // AddSlotToAccessList adds a slot to the per-transaction access list AddSlotToAccessList(SlotAddress) (addressAdded, slotAdded bool) // AddLog append a log to the log collection AddLog(*gethTypes.Log) // AddPreimage adds a preimage to the list of preimages (input -> hash mapping) AddPreimage(gethCommon.Hash, []byte) }
HotView captures a high-level mutable view of the state
type KeyIndices ¶ added in v0.33.30
type KeyIndices []uint64
func (KeyIndices) Count ¶ added in v0.33.30
func (ki KeyIndices) Count() int
func (KeyIndices) ToCadenceValue ¶ added in v0.33.30
func (ki KeyIndices) ToCadenceValue() cadence.Array
type LightLog ¶ added in v0.36.2
type LightLog struct { // address of the contract that generated the event Address gethCommon.Address // list of topics provided by the contract. Topics []gethCommon.Hash // supplied by the contract, usually ABI-encoded Data []byte }
LightLog captures only consensus fields of an EVM log used by the LightReceipt
type LightReceipt ¶ added in v0.36.2
LightReceipt captures only the consensus fields of a receipt, making storage of receipts for the purpose of trie building more storage efficient.
Note that we don't store Bloom as we can reconstruct it later. We don't have PostState and we use a uint8 for status as there is currently only acts as boolean. Data shows that using the light receipt results in 60% storage reduction for block proposals and the extra overheads are manageable.
func (*LightReceipt) ToReceipt ¶ added in v0.36.2
func (lr *LightReceipt) ToReceipt() *gethTypes.Receipt
ToReceipt constructs a Receipt from the LightReceipt Warning, this only populates the consensus fields and if you want the full data, use the receipt from the result.
type PrecompiledCalls ¶ added in v0.35.17
PrecompiledCalls captures all the calls to a precompiled contract
func (*PrecompiledCalls) IsEmpty ¶ added in v0.35.17
func (pc *PrecompiledCalls) IsEmpty() bool
IsEmpty returns true if no requiredGas or run calls is captured
type PrecompiledContract ¶ added in v0.35.17
type PrecompiledContract interface { // PrecompiledContract provides an interface for // calling requiredGas and run gethVM.PrecompiledContract // Address returns the address where the precompile is deployed Address() Address }
PrecompiledContract wraps gethVM precompiles with functionality to return where the contract is deployed
type PublicPath ¶ added in v0.33.30
type PublicPath string
func (PublicPath) ToCadenceValue ¶ added in v0.33.30
func (p PublicPath) ToCadenceValue() cadence.Path
type ReadOnlyBlockView ¶
type ReadOnlyBlockView interface { // BalanceOf returns the balance of this address BalanceOf(address Address) (*big.Int, error) // NonceOf returns the nonce of this address NonceOf(address Address) (uint64, error) // CodeOf returns the code for this address CodeOf(address Address) (Code, error) // CodeHashOf returns the code hash for this address CodeHashOf(address Address) ([]byte, error) }
ReadOnlyBlockView provides a read only view of a block
type ReadOnlyView ¶
type ReadOnlyView interface { // Exist returns true if the address exist in the state Exist(gethCommon.Address) (bool, error) // IsCreated returns true if address has been created in this tx IsCreated(gethCommon.Address) bool // IsNewContract returns true if address is a new contract // either is a new account or it had balance but no code before IsNewContract(addr gethCommon.Address) bool // HasSelfDestructed returns true if an address has self destructed // it also returns the balance of address before selfdestruction call HasSelfDestructed(gethCommon.Address) (bool, *uint256.Int) // GetBalance returns the balance of an address GetBalance(gethCommon.Address) (*uint256.Int, error) // GetNonce returns the nonce of an address GetNonce(gethCommon.Address) (uint64, error) // GetCode returns the code of an address GetCode(gethCommon.Address) ([]byte, error) // GetCodeHash returns the code hash of an address GetCodeHash(gethCommon.Address) (gethCommon.Hash, error) // GetCodeSize returns the code size of an address GetCodeSize(gethCommon.Address) (int, error) // GetState returns values for an slot in the main storage GetState(SlotAddress) (gethCommon.Hash, error) // GetStorageRoot returns some sort of root for the given address. // Warning! Since StateDB doesn't construct a Merkel tree under the hood, // the behavior of this endpoint is as follow: // - if an account doesn't exist it returns common.Hash{} // - if account is EOA it returns gethCommon.EmptyRootHash // - else it returns a unique hash value as the root but this returned GetStorageRoot(gethCommon.Address) (gethCommon.Hash, error) // GetTransientState returns values for an slot transient storage GetTransientState(SlotAddress) gethCommon.Hash // GetRefund returns the total amount of (gas) refund GetRefund() uint64 // AddressInAccessList checks if an address is in the access list AddressInAccessList(gethCommon.Address) bool // SlotInAccessList checks if a slot is in the access list SlotInAccessList(SlotAddress) (addressOk bool, slotOk bool) }
ReadOnlyView provides a readonly view of the state
type ReplayResultCollector ¶
type ReplayResultCollector interface { // StorageRegisterUpdates returns the set of register changes // (only the EVM-related registers) StorageRegisterUpdates() map[flow.RegisterID]flow.RegisterValue }
ReplayResultCollector collects results of replay a block
type Result ¶
type Result struct { // captures error returned during validation step (pre-checks) ValidationError error // captures error returned by the EVM VMError error // type of transaction defined by the evm package // see DirectCallTxType as extra type we added type for direct calls. TxType uint8 // total gas consumed during execution GasConsumed uint64 // total gas used by the block after this tx execution CumulativeGasUsed uint64 // total gas refunds after transaction execution GasRefund uint64 // the address where the contract is deployed (if any) DeployedContractAddress *Address // returned data from a function call ReturnedData []byte // EVM logs (events that are emitted by evm) Logs []*gethTypes.Log // TX hash holds the cached value of tx hash TxHash gethCommon.Hash // transaction block inclusion index Index uint16 // PrecompiledCalls captures an encoded list of calls to the precompile // during the execution of transaction PrecompiledCalls []byte // StateChangeCommitment captures a commitment over the state change (delta) StateChangeCommitment []byte }
Result captures the result of an interaction to the emulator it could be the output of a direct call or output of running an evm transaction. Its more comprehensive than typical evm receipt, usually the receipt generation requires some extra calculation (e.g. Deployed contract address) but we take a different approach here and include more data so that it requires less work for anyone who tracks and consume results.
func NewInvalidResult ¶ added in v0.33.30
func NewInvalidResult(tx *gethTypes.Transaction, err error) *Result
NewInvalidResult creates a new result that hold transaction validation error as well as the defined gas cost for validation.
func (*Result) DeployedContractAddressString ¶ added in v0.37.22
DeployedContractAddressString returns an string of the deployed address it returns an empty string if the deployed address is nil
func (*Result) ErrorMsg ¶ added in v0.37.22
ErrorMsg returns the error message, if any VM or Validation error both error would never happen at the same time but if it happens the priority is by validation error
func (*Result) Failed ¶
Failed returns true if transaction has been executed but VM has returned some error
func (*Result) LightReceipt ¶ added in v0.36.2
func (res *Result) LightReceipt() *LightReceipt
LightReceipt constructs a light receipt from the result that is used for storing in block proposal.
func (*Result) RLPEncodedLogs ¶ added in v0.37.22
RLPEncodedLogs returns the rlp encoding of the logs
func (*Result) Receipt ¶
Receipt constructs an EVM-style receipt can be used by json-rpc and other integration to be returned.
This is method is also used to construct block receipt root hash which requires the return receipt satisfy RLP encoding and cover these fields Type (txType), PostState or Status, CumulativeGasUsed, Logs and Logs Bloom and for each log, Address, Topics, Data (consensus fields) During execution we also do fill in BlockNumber, TxIndex, Index (event index)
func (*Result) ResultSummary ¶ added in v0.33.30
func (res *Result) ResultSummary() *ResultSummary
ResultSummary constructs a result summary
func (*Result) SetValidationError ¶ added in v0.33.30
SetValidationError sets the validation error and also sets the gas used to the fixed invalid gas usage
func (*Result) StateChangeChecksum ¶ added in v0.37.22
func (res *Result) StateChangeChecksum() [ChecksumLength]byte
StateChangeChecksum constructs a checksum based on the state change commitment on the result
func (*Result) Successful ¶ added in v0.33.30
Successful returns true if transaction has been executed without any errors
func (*Result) VMErrorString ¶ added in v0.33.30
returns the VM error as an string, if no error it returns an empty string
type ResultSummary ¶ added in v0.33.30
type ResultSummary struct { Status Status ErrorCode ErrorCode ErrorMessage string GasConsumed uint64 GasRefund uint64 DeployedContractAddress *Address ReturnedData Data }
ResultSummary summarizes the outcome of a EVM call or tx run
type RunCall ¶ added in v0.35.17
RunCall captures a call to the Run method of a precompiled contract
type Signature ¶ added in v0.33.30
type Signature []byte
func (Signature) ToCadenceValue ¶ added in v0.33.30
type Signatures ¶ added in v0.33.30
type Signatures []Signature
func (Signatures) Count ¶ added in v0.33.30
func (ss Signatures) Count() int
func (Signatures) ToCadenceValue ¶ added in v0.33.30
func (ss Signatures) ToCadenceValue() cadence.Array
type SignedData ¶ added in v0.33.30
type SignedData []byte
func (SignedData) ToCadenceValue ¶ added in v0.33.30
func (sd SignedData) ToCadenceValue() cadence.Array
type SlotAddress ¶
type SlotAddress struct { Address gethCommon.Address Key gethCommon.Hash }
SlotAddress captures an address to a storage slot
type SlotEntry ¶
type SlotEntry struct { Address gethCommon.Address Key gethCommon.Hash Value gethCommon.Hash }
SlotEntry captures an address to a storage slot and the value stored in it
func SlotEntryFromEncoded ¶
SlotEntryFromEncoded constructs an slot entry from the encoded data
type StateDB ¶
type StateDB interface { gethVM.StateDB // Commit commits the changes and // returns a commitment over changes // setting `finalize` flag // calls a subsequent call to Finalize // deferring finalization and calling it once at the end // improves efficiency of batch operations. Commit(finalize bool) (hash.Hash, error) // Finalize flushes all the changes // to the permanent storage Finalize() error // Logs collects and prepares logs Logs( blockNumber uint64, txHash gethCommon.Hash, txIndex uint, ) []*gethTypes.Log // Preimages returns a map of preimages Preimages() map[gethCommon.Hash][]byte // Reset resets uncommitted changes and transient artifacts such as error, logs, // preimages, access lists, ... // The method is often called between execution of different transactions Reset() // Error returns any error that has been cached so far by the state. Error() error }
StateDB acts as the main interface to the EVM runtime
type StateError ¶
type StateError struct {
// contains filtered or unexported fields
}
StateError is a non-fatal error, returned when a state operation has failed (e.g. reaching storage interaction limit)
func NewStateError ¶
func NewStateError(rootCause error) StateError
NewStateError returns a new StateError
func (StateError) Error ¶
func (err StateError) Error() string
func (StateError) Unwrap ¶
func (err StateError) Unwrap() error
Unwrap unwraps the underlying evm error
type Status ¶ added in v0.33.30
type Status uint8
Status captures the status of an interaction to the emulator
var ( StatusUnknown Status = 0 // StatusInvalid shows that the transaction was not a valid // transaction and rejected to be executed and included in any block. StatusInvalid Status = 1 // StatusFailed shows that the transaction has been executed, // but the output of the execution was an error // for this case a block is formed and receipts are available StatusFailed Status = 2 // StatusSuccessful shows that the transaction has been executed and the execution has returned success // for this case a block is formed and receipts are available StatusSuccessful Status = 3 )
type StorageProvider ¶
type StorageProvider interface { // GetSnapshotAt returns a readonly snapshot of storage // at specific block (start state of the block before executing transactions) GetSnapshotAt(evmBlockHeight uint64) (BackendStorageSnapshot, error) }
StorageProvider provides access to storage at specific time point in history of the EVM chain
type TransactionHashes ¶ added in v0.36.2
type TransactionHashes []gethCommon.Hash
func (TransactionHashes) EncodeIndex ¶ added in v0.36.2
func (t TransactionHashes) EncodeIndex(index int, buffer *bytes.Buffer)
func (TransactionHashes) Len ¶ added in v0.36.2
func (t TransactionHashes) Len() int
func (TransactionHashes) RootHash ¶ added in v0.36.2
func (t TransactionHashes) RootHash() gethCommon.Hash