Documentation
¶
Index ¶
- Constants
- func GetCosmosAddressFromEVMAddressArg(arg interface{}) (sdk.AccAddress, error)
- func HandleGasError(ctx sdk.Context, contract *vm.Contract, initialGas storetypes.Gas, err *error) func()
- func MustGetABI(f embed.FS, filename string) abi.ABI
- func NewBalanceChangeEntry(acc ethcommon.Address, amt *big.Int, op Operation) balanceChangeEntry
- func ValidateArgsLength(args []interface{}, length int) error
- func ValidateNonPayable(value *big.Int) error
- type Contexter
- type Operation
- type Precompile
- func (p Precompile) AddJournalEntries(stateDB *statedb.StateDB, s snapshot) error
- func (p Precompile) Address() ethcommon.Address
- func (p Precompile) GetABI() abi.ABI
- func (p Precompile) GetMethodIDByName(name string) (methodId []byte, err error)
- func (p Precompile) Prepare(evm *vm.EVM, contract *vm.Contract) (ctx sdk.Context, stateDB *statedb.StateDB, s snapshot, method *abi.Method, ...)
- func (p Precompile) RequiredGas(input []byte) uint64
- func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, sender ethcommon.Address, ...) (bz []byte, err error)
- func (p *Precompile) SetAddress(addr ethcommon.Address)
- func (p *Precompile) SetBalanceChangeEntries(entries ...balanceChangeEntry)
- type PrecompileExecutor
Constants ¶
const (
// ErrNotRunInEvm is raised when a function is not called inside the EVM.
ErrNotRunInEvm = "not run in EVM"
)
const UnknownMethodCallGas uint64 = 3000
Variables ¶
This section is empty.
Functions ¶
func GetCosmosAddressFromEVMAddressArg ¶
func GetCosmosAddressFromEVMAddressArg(arg interface{}) (sdk.AccAddress, error)
func HandleGasError ¶
func HandleGasError(ctx sdk.Context, contract *vm.Contract, initialGas storetypes.Gas, err *error) func()
HandleGasError handles the out of gas panic by resetting the gas meter and returning an error. This is used in order to avoid panics and to allow for the EVM to continue cleanup if the tx or query run out of gas.
func NewBalanceChangeEntry ¶
func ValidateArgsLength ¶
func ValidateNonPayable ¶
Types ¶
type Operation ¶
type Operation int8
Operation is a type that defines if the precompile call produced an addition or subtraction of an account's balance
type Precompile ¶
func NewPrecompile ¶
func NewPrecompile( abi abi.ABI, address ethcommon.Address, executor PrecompileExecutor, ) *Precompile
func (Precompile) AddJournalEntries ¶
func (p Precompile) AddJournalEntries(stateDB *statedb.StateDB, s snapshot) error
AddJournalEntries adds the balanceChange (if corresponds) and precompileCall entries on the stateDB journal This allows to revert the call changes within an evm tx
func (Precompile) Address ¶
func (p Precompile) Address() ethcommon.Address
func (Precompile) GetABI ¶
func (p Precompile) GetABI() abi.ABI
func (Precompile) GetMethodIDByName ¶
func (p Precompile) GetMethodIDByName(name string) (methodId []byte, err error)
func (Precompile) Prepare ¶
func (p Precompile) Prepare( evm *vm.EVM, contract *vm.Contract, ) (ctx sdk.Context, stateDB *statedb.StateDB, s snapshot, method *abi.Method, initialGas storetypes.Gas, args []interface{}, err error, )
Prepare runs the initial setup required to run a transaction or a query. It returns the sdk Context, EVM stateDB, ABI method, initial gas and calling arguments.
func (Precompile) RequiredGas ¶
func (p Precompile) RequiredGas(input []byte) uint64
RequiredGas calculates the base minimum required gas for a transaction or a query.
func (*Precompile) SetAddress ¶
func (p *Precompile) SetAddress(addr ethcommon.Address)
func (*Precompile) SetBalanceChangeEntries ¶
func (p *Precompile) SetBalanceChangeEntries(entries ...balanceChangeEntry)
SetBalanceChangeEntries sets the balanceChange entries as the journalEntries field of the precompile. These entries will be added to the stateDB's journal when calling the AddJournalEntries function
type PrecompileExecutor ¶
type PrecompileExecutor interface {
RequiredGas(input []byte, method *abi.Method) uint64
Execute(
ctx sdk.Context,
evm *vm.EVM,
method *abi.Method,
caller ethcommon.Address,
callingContract vm.ContractRef,
args []interface{},
value *big.Int,
readOnly bool,
isFromDelegateCall bool,
) (ret []byte, err error)
}