Documentation ¶
Index ¶
- Variables
- func AddOne64th(n uint64) uint64
- func GetDefaultSigner() types.Signer
- func GetSigner(cfg *Config) types.Signer
- type BlockView
- func (bl *BlockView) BatchRunTransactions(txs []*gethTypes.Transaction) ([]*types.Result, error)
- func (bl *BlockView) DirectCall(call *types.DirectCall) (res *types.Result, err error)
- func (bl *BlockView) DryRunTransaction(tx *gethTypes.Transaction, from gethCommon.Address) (*types.Result, error)
- func (bl *BlockView) RunTransaction(tx *gethTypes.Transaction) (result *types.Result, err error)
- type CallTracker
- func (ct *CallTracker) CaptureRequiredGas(address types.Address, input []byte, output uint64)
- func (ct *CallTracker) CaptureRun(address types.Address, input []byte, output []byte, err error)
- func (ct *CallTracker) CapturedCalls() ([]byte, error)
- func (ct *CallTracker) IsCalled() bool
- func (ct *CallTracker) RegisterPrecompiledContract(pc types.PrecompiledContract) types.PrecompiledContract
- func (ct *CallTracker) Reset()
- type Config
- type Emulator
- type Option
- func WithBlockNumber(blockNumber *big.Int) Option
- func WithBlockTime(time uint64) Option
- func WithBlockTotalGasUsedSoFar(gasUsed uint64) Option
- func WithBlockTxCountSoFar(txCount uint) Option
- func WithChainID(chainID *big.Int) Option
- func WithCoinbase(coinbase gethCommon.Address) Option
- func WithDirectCallBaseGasUsage(gas uint64) Option
- func WithExtraPrecompiledContracts(precompiledContracts []types.PrecompiledContract) Option
- func WithGasLimit(gasLimit uint64) Option
- func WithGasPrice(gasPrice *big.Int) Option
- func WithGetBlockHashFunction(getHash gethVM.GetHashFunc) Option
- func WithOrigin(origin gethCommon.Address) Option
- func WithRandom(rand *gethCommon.Hash) Option
- func WithTransactionTracer(tracer *tracers.Tracer) Option
- type ReadOnlyBlockView
- func (bv *ReadOnlyBlockView) BalanceOf(address types.Address) (*big.Int, error)
- func (bv *ReadOnlyBlockView) CodeHashOf(address types.Address) ([]byte, error)
- func (bv *ReadOnlyBlockView) CodeOf(address types.Address) (types.Code, error)
- func (bv *ReadOnlyBlockView) NonceOf(address types.Address) (uint64, error)
- type WrappedPrecompiledContract
Constants ¶
This section is empty.
Variables ¶
var DefaultChainConfig = &gethParams.ChainConfig{ ChainID: types.FlowEVMPreviewNetChainID, HomesteadBlock: bigZero, DAOForkBlock: bigZero, DAOForkSupport: false, EIP150Block: bigZero, EIP155Block: bigZero, EIP158Block: bigZero, ByzantiumBlock: bigZero, ConstantinopleBlock: bigZero, PetersburgBlock: bigZero, IstanbulBlock: bigZero, BerlinBlock: bigZero, LondonBlock: bigZero, MuirGlacierBlock: bigZero, ShanghaiTime: &zero, CancunTime: &zero, PragueTime: nil, VerkleTime: nil, }
DefaultChainConfig is the default chain config used by the emulator considers majority of EVM upgrades (e.g. Cancun update) are already applied This has been done through setting the height of these changes to zero nad setting the time for some other changes to zero For the future changes of EVM, we need to update the EVM go mod version and set a proper height for the specific release based on the Flow EVM heights so it could gets activated at a desired time.
Functions ¶
func AddOne64th ¶ added in v0.35.17
func GetDefaultSigner ¶
GetDefaultSigner returns a signer which is compatible with the default config
Types ¶
type BlockView ¶
type BlockView struct {
// contains filtered or unexported fields
}
BlockView allows mutation of the evm state as part of a block current version only accepts only a single interaction per block view.
func (*BlockView) BatchRunTransactions ¶ added in v0.33.30
BatchRunTransactions runs a batch of EVM transactions
func (*BlockView) DirectCall ¶
DirectCall executes a direct call
func (*BlockView) DryRunTransaction ¶ added in v0.33.30
func (bl *BlockView) DryRunTransaction( tx *gethTypes.Transaction, from gethCommon.Address, ) (*types.Result, error)
DryRunTransaction runs an unsigned transaction without persisting the state
func (*BlockView) RunTransaction ¶
RunTransaction runs an evm transaction
type CallTracker ¶ added in v0.36.3
type CallTracker struct {
// contains filtered or unexported fields
}
CallTracker captures precompiled calls
func NewCallTracker ¶ added in v0.36.3
func NewCallTracker() *CallTracker
NewCallTracker constructs a new CallTracker
func (*CallTracker) CaptureRequiredGas ¶ added in v0.36.3
func (ct *CallTracker) CaptureRequiredGas(address types.Address, input []byte, output uint64)
CaptureRequiredGas captures a required gas call
func (*CallTracker) CaptureRun ¶ added in v0.36.3
CaptureRun captures a run calls
func (*CallTracker) CapturedCalls ¶ added in v0.36.3
func (ct *CallTracker) CapturedCalls() ([]byte, error)
Encoded
func (*CallTracker) IsCalled ¶ added in v0.36.3
func (ct *CallTracker) IsCalled() bool
IsCalled returns true if any calls has been captured
func (*CallTracker) RegisterPrecompiledContract ¶ added in v0.36.3
func (ct *CallTracker) RegisterPrecompiledContract(pc types.PrecompiledContract) types.PrecompiledContract
RegisterPrecompiledContract registers a precompiled contract for tracking
type Config ¶
type Config struct { // Chain Config ChainConfig *gethParams.ChainConfig // EVM config EVMConfig gethVM.Config // block context BlockContext *gethVM.BlockContext // transaction context TxContext *gethVM.TxContext // base unit of gas for direct calls DirectCallBaseGasUsage uint64 // captures extra precompiled calls PCTracker *CallTracker // BlockTxCount captures the total number of // transactions included in this block so far BlockTxCountSoFar uint // BlockTotalGasSoFar captures the total // amount of gas used so far BlockTotalGasUsedSoFar uint64 }
Config aggregates all the configuration (chain, evm, block, tx, ...) needed during executing a transaction.
func (*Config) ChainRules ¶ added in v0.33.30
func (c *Config) ChainRules() gethParams.Rules
ChainRules returns the chain rules
type Emulator ¶
type Emulator struct {
// contains filtered or unexported fields
}
Emulator wraps an EVM runtime where evm transactions and direct calls are accepted.
func NewEmulator ¶
NewEmulator constructs a new EVM Emulator
func (*Emulator) NewBlockView ¶
NewBlockView constructs a new block view (mutable)
func (*Emulator) NewReadOnlyBlockView ¶
func (em *Emulator) NewReadOnlyBlockView(ctx types.BlockContext) (types.ReadOnlyBlockView, error)
NewReadOnlyBlockView constructs a new read-only block view
type Option ¶
func WithBlockNumber ¶
WithBlockNumber sets the block height in the block context
func WithBlockTime ¶
WithBlockTime sets the block time in the block context
func WithBlockTotalGasUsedSoFar ¶ added in v0.36.4
WithBlockTotalGasSoFar sets the total amount of gas used for this block so far
func WithBlockTxCountSoFar ¶ added in v0.36.4
WithBlockTxCountSoFar sets the total number of transactions included in the current block so far
func WithChainID ¶ added in v0.33.30
WithChainID sets the evm chain ID
func WithCoinbase ¶
func WithCoinbase(coinbase gethCommon.Address) Option
WithCoinbase sets the coinbase of the block where the fees are collected in
func WithDirectCallBaseGasUsage ¶
WithDirectCallBaseGasUsage sets the base direct call gas usage
func WithExtraPrecompiledContracts ¶ added in v0.35.17
func WithExtraPrecompiledContracts(precompiledContracts []types.PrecompiledContract) Option
WithExtraPrecompiledContracts appends the precompiled contract list with extra precompiled contracts
func WithGasLimit ¶
WithGasLimit sets the gas limit of the transaction
func WithGasPrice ¶
WithGasPrice sets the gas price for the transaction (usually the one sets by the sender)
func WithGetBlockHashFunction ¶
func WithGetBlockHashFunction(getHash gethVM.GetHashFunc) Option
WithGetBlockHashFunction sets the functionality to look up block hash by height
func WithOrigin ¶
func WithOrigin(origin gethCommon.Address) Option
WithOrigin sets the origin of the transaction (signer)
func WithRandom ¶ added in v0.33.30
func WithRandom(rand *gethCommon.Hash) Option
WithRandom sets the block context random field
func WithTransactionTracer ¶ added in v0.33.30
WithTransactionTracer sets a transaction tracer
type ReadOnlyBlockView ¶
type ReadOnlyBlockView struct {
// contains filtered or unexported fields
}
ReadOnlyBlockView provides a read only view of a block could be used for multiple queries against a block
func (*ReadOnlyBlockView) CodeHashOf ¶ added in v0.33.30
func (bv *ReadOnlyBlockView) CodeHashOf(address types.Address) ([]byte, error)
CodeHashOf returns the code hash of the given address
type WrappedPrecompiledContract ¶ added in v0.36.3
type WrappedPrecompiledContract struct {
// contains filtered or unexported fields
}
func (*WrappedPrecompiledContract) Address ¶ added in v0.36.3
func (wpc *WrappedPrecompiledContract) Address() types.Address
func (*WrappedPrecompiledContract) RequiredGas ¶ added in v0.36.3
func (wpc *WrappedPrecompiledContract) RequiredGas(input []byte) uint64