2021-12-06 14:58:53 +00:00
|
|
|
package vm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-01-18 10:20:35 +00:00
|
|
|
|
2021-12-06 14:58:53 +00:00
|
|
|
"github.com/holiman/uint256"
|
2023-01-13 18:12:18 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/chain"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
|
2022-11-30 01:31:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
|
2021-12-06 14:58:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/params"
|
|
|
|
)
|
|
|
|
|
|
|
|
const CairoNotImplemented = "the method is currently not implemented for cvm: %s"
|
|
|
|
|
|
|
|
type CVMAdapter struct {
|
|
|
|
Cvm *CVM
|
|
|
|
}
|
|
|
|
|
2022-11-30 01:31:13 +00:00
|
|
|
func (c *CVMAdapter) Reset(txCtx evmtypes.TxContext, ibs evmtypes.IntraBlockState) {
|
2022-01-18 10:20:35 +00:00
|
|
|
c.Cvm.intraBlockState = ibs
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (c *CVMAdapter) Create(caller ContractRef, code []byte, gas uint64, value *uint256.Int) (ret []byte, contractAddr libcommon.Address, leftOverGas uint64, err error) {
|
2021-12-06 14:58:53 +00:00
|
|
|
leftOverGas = 0
|
|
|
|
|
2022-01-18 10:20:35 +00:00
|
|
|
ret, contractAddr, err = c.Cvm.Create(caller, code)
|
2021-12-06 14:58:53 +00:00
|
|
|
|
|
|
|
return ret, contractAddr, leftOverGas, err
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (cvm *CVMAdapter) Call(caller ContractRef, addr libcommon.Address, input []byte, gas uint64, value *uint256.Int, bailout bool) (ret []byte, leftOverGas uint64, err error) {
|
2021-12-06 14:58:53 +00:00
|
|
|
return nil, 0, fmt.Errorf(CairoNotImplemented, "Call")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cvm *CVMAdapter) Config() Config {
|
|
|
|
return cvm.Cvm.Config()
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (cvm *CVMAdapter) ChainConfig() *chain.Config {
|
2022-12-10 22:55:31 +00:00
|
|
|
return params.AllProtocolChanges
|
2022-01-14 19:06:35 +00:00
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (cvm *CVMAdapter) ChainRules() *chain.Rules {
|
|
|
|
return &chain.Rules{}
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 01:31:13 +00:00
|
|
|
func (cvm *CVMAdapter) Context() evmtypes.BlockContext {
|
|
|
|
return evmtypes.BlockContext{}
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 01:31:13 +00:00
|
|
|
func (cvm *CVMAdapter) IntraBlockState() evmtypes.IntraBlockState {
|
2021-12-06 14:58:53 +00:00
|
|
|
return cvm.Cvm.IntraBlockState()
|
|
|
|
}
|
|
|
|
|
2022-11-30 01:31:13 +00:00
|
|
|
func (cvm *CVMAdapter) TxContext() evmtypes.TxContext {
|
|
|
|
return evmtypes.TxContext{}
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|