handler

package
v0.33.19 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FlexLatestBlockKey = "LatestBlock"

Functions

This section is empty.

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 bridged account

func (*Account) Balance

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

Balance returns the balance of this bridged account

TODO: we might need to meter computation for read only operations as well currently the storage limits is enforced

func (*Account) Call

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

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) Deploy

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

Deploy deploys a contract to the EVM environment the new deployed contract would be at the returned address 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) 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 {
	// contains filtered or unexported fields
}

func NewAddressAllocator

func NewAddressAllocator(led atree.Ledger, flexAddress flow.Address) (*AddressAllocator, error)

NewAddressAllocator constructs a new statefull address allocator

func (*AddressAllocator) AllocateAddress

func (aa *AddressAllocator) AllocateAddress() (types.Address, error)

AllocateAddress allocates an address

type BlockStore

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

func NewBlockStore

func NewBlockStore(led atree.Ledger, flexAddress flow.Address) (*BlockStore, error)

NewBlockStore constructs a new block store

func (*BlockStore) BlockHash

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

BlockHash returns the block hash for the last x blocks

TODO: implement this properly to keep the last 256 block hashes and connect use it inside the handler to pass as a config to the emulator

func (*BlockStore) BlockProposal

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

BlockProposal returns the block proposal to be updated by the handler

func (*BlockStore) CommitBlockProposal

func (bs *BlockStore) CommitBlockProposal() 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) ResetBlockProposal

func (bs *BlockStore) ResetBlockProposal() error

ResetBlockProposal resets 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

TODO and Warning: currently database keeps a copy of roothash, and if after commiting the changes by the evm we want to revert in this code we need to reset that or we should always do all the checks and return before calling the emulator, after that should be only event emissions and computation usage updates. thats another reason we first check the computation limit before using. in the future we might benefit from a view style of access to db passed as a param to the emulator.

func NewContractHandler

func NewContractHandler(
	flowTokenAddress common.Address,
	blockstore types.BlockStore,
	addressAllocator types.AddressAllocator,
	backend types.Backend,
	emulator types.Emulator,
) *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 (bridged accounts)

func (*ContractHandler) AllocateAddress

func (h *ContractHandler) AllocateAddress() types.Address

AllocateAddress allocates an address to be used by the bridged accounts

func (*ContractHandler) FlowTokenAddress

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

func (*ContractHandler) LastExecutedBlock

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

LastExecutedBlock returns the last executed block

func (*ContractHandler) Run

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

Run runs an rlpencoded evm transaction and collects the gas fees and pay it to the coinbase address provided.

Jump to

Keyboard shortcuts

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