handler

package
v0.37.14-migration-mai... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockHashListCapacity            = 256
	BlockStoreLatestBlockKey         = "LatestBlock"
	BlockStoreLatestBlockProposalKey = "LatestBlockProposal"
)
View Source
const RandomSourceTypeValueFieldName = "value"
View Source
const ValidationResultTypeIsValidFieldName = "isValid"

Variables

This section is empty.

Functions

func MakeCOAAddress added in v0.33.30

func MakeCOAAddress(index uint64) types.Address

func MakePrecompileAddress added in v0.33.30

func MakePrecompileAddress(index uint64) types.Address

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

func (*Account) Address

func (a *Account) Address() types.Address

Address returns the address associated with the account

func (*Account) Balance

func (a *Account) Balance() types.Balance

Balance returns the balance of this account

Note: we don't meter any extra computation given reading data from the storage already translates into computation

func (*Account) Call

func (a *Account) Call(to types.Address, data types.Data, gaslimit types.GasLimit, balance types.Balance) *types.ResultSummary

Call calls a smart contract function with the given data it would limit the gas used according to the limit provided given it doesn't goes beyond what Flow transaction allows. the balance would be deducted from the OFA account and would be transferred to the target address

func (*Account) Code added in v0.33.30

func (a *Account) Code() types.Code

Code returns the code of this account

Note: we don't meter any extra computation given reading data from the storage already translates into computation

func (*Account) CodeHash added in v0.33.30

func (a *Account) CodeHash() []byte

CodeHash returns the code hash of this account

Note: we don't meter any extra computation given reading data from the storage already translates into computation

func (*Account) Deploy

func (a *Account) Deploy(code types.Code, gaslimit types.GasLimit, balance types.Balance) *types.ResultSummary

Deploy deploys a contract to the EVM environment the new deployed contract would be at the returned address contained in the result summary as data and the contract data is not controlled by the caller accounts

func (*Account) Deposit

func (a *Account) Deposit(v *types.FLOWTokenVault)

Deposit deposits the token from the given vault into the flow evm main vault and update the account balance with the new amount

func (*Account) Nonce added in v0.33.30

func (a *Account) Nonce() uint64

Nonce returns the nonce of this account

Note: we don't meter any extra computation given reading data from the storage already translates into computation

func (*Account) Transfer

func (a *Account) Transfer(to types.Address, balance types.Balance)

Transfer transfers tokens between accounts

func (*Account) Withdraw

func (a *Account) Withdraw(b types.Balance) *types.FLOWTokenVault

Withdraw deducts the balance from the account and withdraw and return flow token from the Flex main vault.

type AddressAllocator

type AddressAllocator struct {
}

func NewAddressAllocator

func NewAddressAllocator() *AddressAllocator

NewAddressAllocator constructs a new statefull address allocator

func (*AddressAllocator) AllocateCOAAddress added in v0.33.30

func (aa *AddressAllocator) AllocateCOAAddress(uuid uint64) types.Address

AllocateCOAAddress allocates an address for COA

func (*AddressAllocator) AllocatePrecompileAddress added in v0.33.30

func (aa *AddressAllocator) AllocatePrecompileAddress(index uint64) types.Address

func (*AddressAllocator) COAFactoryAddress added in v0.33.30

func (aa *AddressAllocator) COAFactoryAddress() types.Address

func (*AddressAllocator) NativeTokenBridgeAddress added in v0.33.30

func (aa *AddressAllocator) NativeTokenBridgeAddress() types.Address

type BlockHashList added in v0.36.3

type BlockHashList struct {
	// contains filtered or unexported fields
}

BlockHashList stores the last `capacity` number of block hashes

Under the hood it breaks the list of hashes into smaller fixed size buckets to minimize the number of bytes read and written during set/get operations.

func NewBlockHashList added in v0.36.3

func NewBlockHashList(
	backend types.Backend,
	rootAddress flow.Address,
	capacity int,
) (*BlockHashList, error)

NewBlockHashList creates a block hash list It tries to load the metadata from the backend and if not exist it creates one

func (*BlockHashList) BlockHashByHeight added in v0.36.3

func (bhl *BlockHashList) BlockHashByHeight(height uint64) (found bool, bh gethCommon.Hash, err error)

BlockHashByIndex returns the block hash by block height

func (*BlockHashList) IsEmpty added in v0.36.3

func (bhl *BlockHashList) IsEmpty() bool

IsEmpty returns true if the list is empty

func (*BlockHashList) LastAddedBlockHash added in v0.36.3

func (bhl *BlockHashList) LastAddedBlockHash() (gethCommon.Hash, error)

LastAddedBlockHash returns the last block hash added to the list for empty list it returns empty hash value

func (*BlockHashList) MaxAvailableHeight added in v0.36.3

func (bhl *BlockHashList) MaxAvailableHeight() uint64

MaxAvailableHeight returns the max available height in the list

func (*BlockHashList) MinAvailableHeight added in v0.36.3

func (bhl *BlockHashList) MinAvailableHeight() uint64

MinAvailableHeight returns the min available height in the list

func (*BlockHashList) Push added in v0.36.3

func (bhl *BlockHashList) Push(height uint64, bh gethCommon.Hash) error

Push pushes a block hash for the next height to the list. If the list has reached to the capacity, it overwrites the oldest element.

type BlockStore

type BlockStore struct {
	// contains filtered or unexported fields
}

func NewBlockStore

func NewBlockStore(
	chainID flow.ChainID,
	backend types.Backend,
	rootAddress flow.Address,
) *BlockStore

NewBlockStore constructs a new block store

func (*BlockStore) BlockHash

func (bs *BlockStore) BlockHash(height uint64) (gethCommon.Hash, error)

BlockHash returns the block hash for the last x blocks

func (*BlockStore) BlockProposal

func (bs *BlockStore) BlockProposal() (*types.BlockProposal, error)

BlockProposal returns the block proposal to be updated by the handler

func (*BlockStore) CommitBlockProposal

func (bs *BlockStore) CommitBlockProposal(bp *types.BlockProposal) error

CommitBlockProposal commits the block proposal to the chain

func (*BlockStore) LatestBlock

func (bs *BlockStore) LatestBlock() (*types.Block, error)

LatestBlock returns the latest executed block

func (*BlockStore) UpdateBlockProposal added in v0.36.2

func (bs *BlockStore) UpdateBlockProposal(bp *types.BlockProposal) error

UpdateBlockProposal updates the block proposal

type ContractHandler

type ContractHandler struct {
	// contains filtered or unexported fields
}

ContractHandler is responsible for triggering calls to emulator, metering, event emission and updating the block

func NewContractHandler

func NewContractHandler(
	flowChainID flow.ChainID,
	evmContractAddress flow.Address,
	flowTokenAddress common.Address,
	randomBeaconAddress flow.Address,
	blockStore types.BlockStore,
	addressAllocator types.AddressAllocator,
	backend types.Backend,
	emulator types.Emulator,
	tracer debug.EVMTracer,
) *ContractHandler

NewContractHandler constructs a new ContractHandler

func (*ContractHandler) AccountByAddress

func (h *ContractHandler) AccountByAddress(addr types.Address, isAuthorized bool) types.Account

AccountByAddress returns the account for the given address, if isAuthorized is set, account is controlled by the FVM (COAs)

func (*ContractHandler) BatchRun added in v0.33.30

func (h *ContractHandler) BatchRun(rlpEncodedTxs [][]byte, gasFeeCollector types.Address) []*types.ResultSummary

BatchRun tries to run batch of rlp-encoded transactions collects the gas fees and pay it to the coinbase address provided. All transactions provided in the batch are included in a single block, except for invalid transactions

func (*ContractHandler) CommitBlockProposal added in v0.36.2

func (h *ContractHandler) CommitBlockProposal()

CommitBlockProposal commits the block proposal and add a new block to the EVM blockchain

func (*ContractHandler) DeployCOA added in v0.33.30

func (h *ContractHandler) DeployCOA(uuid uint64) types.Address

DeployCOA deploys a cadence-owned-account and returns the address

func (*ContractHandler) DryRun added in v0.33.30

func (h *ContractHandler) DryRun(
	rlpEncodedTx []byte,
	from types.Address,
) *types.ResultSummary

DryRun simulates execution of the provided RLP-encoded and unsigned transaction.

func (*ContractHandler) EVMContractAddress added in v0.33.30

func (h *ContractHandler) EVMContractAddress() common.Address

EVMContractAddress returns the address where EVM contract is deployed

func (*ContractHandler) FlowTokenAddress

func (h *ContractHandler) FlowTokenAddress() common.Address

FlowTokenAddress returns the address where the FlowToken contract is deployed

func (*ContractHandler) GenerateResourceUUID added in v0.33.30

func (h *ContractHandler) GenerateResourceUUID() uint64

func (*ContractHandler) LastExecutedBlock

func (h *ContractHandler) LastExecutedBlock() *types.Block

LastExecutedBlock returns the last executed block

func (*ContractHandler) Run

func (h *ContractHandler) Run(rlpEncodedTx []byte, gasFeeCollector types.Address) *types.ResultSummary

Run tries to run an rlp-encoded evm transaction collects the gas fees and pay it to the gasFeeCollector address provided.

func (*ContractHandler) RunOrPanic added in v0.33.30

func (h *ContractHandler) RunOrPanic(rlpEncodedTx []byte, gasFeeCollector types.Address)

RunOrPanic runs an rlp-encoded evm transaction and

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL