2017-04-14 08:29:00 +00:00
|
|
|
// Copyright 2016 The go-ethereum Authors
|
2016-12-06 01:16:03 +00:00
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package vm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/big"
|
|
|
|
|
2022-11-30 01:31:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
|
2022-05-26 16:20:34 +00:00
|
|
|
"github.com/ledgerwatch/erigon/params"
|
|
|
|
|
2020-05-25 11:12:25 +00:00
|
|
|
"github.com/holiman/uint256"
|
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
2016-12-06 01:16:03 +00:00
|
|
|
)
|
|
|
|
|
2018-09-13 09:48:15 +00:00
|
|
|
// CallContext provides a basic interface for the EVM calling conventions. The EVM
|
2016-12-06 01:16:03 +00:00
|
|
|
// depends on this context being implemented for doing subcalls and initialising new EVM contracts.
|
|
|
|
type CallContext interface {
|
|
|
|
// Call another contract
|
2017-01-05 10:52:10 +00:00
|
|
|
Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
|
2016-12-06 01:16:03 +00:00
|
|
|
// Take another's contract code and execute within our own context
|
2017-01-05 10:52:10 +00:00
|
|
|
CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
|
2016-12-06 01:16:03 +00:00
|
|
|
// Same as CallCode except sender and value is propagated from parent to child scope
|
2017-01-05 10:52:10 +00:00
|
|
|
DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
|
2016-12-06 01:16:03 +00:00
|
|
|
// Create a new contract
|
2017-01-05 10:52:10 +00:00
|
|
|
Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
|
2016-12-06 01:16:03 +00:00
|
|
|
}
|
2021-12-06 14:58:53 +00:00
|
|
|
|
|
|
|
type VMInterface interface {
|
2022-11-30 01:31:13 +00:00
|
|
|
Reset(txCtx evmtypes.TxContext, ibs evmtypes.IntraBlockState)
|
2021-12-06 14:58:53 +00:00
|
|
|
Create(caller ContractRef, code []byte, gas uint64, value *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
|
|
|
|
Call(caller ContractRef, addr common.Address, input []byte, gas uint64, value *uint256.Int, bailout bool) (ret []byte, leftOverGas uint64, err error)
|
|
|
|
Config() Config
|
2022-01-14 19:06:35 +00:00
|
|
|
ChainConfig() *params.ChainConfig
|
2022-05-26 16:20:34 +00:00
|
|
|
ChainRules() *params.Rules
|
2022-11-30 01:31:13 +00:00
|
|
|
Context() evmtypes.BlockContext
|
|
|
|
IntraBlockState() evmtypes.IntraBlockState
|
|
|
|
TxContext() evmtypes.TxContext
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|