Fix compilation, small improvements

This commit is contained in:
Paweł Bylica 2019-10-03 12:09:22 +02:00
parent 2f4a259c56
commit 77aea4f0d9
No known key found for this signature in database
GPG key ID: 7A0C037434FE77EF

View file

@ -17,40 +17,36 @@
package runtime
import (
"math/big"
"testing"
"flag"
"fmt"
"io/ioutil"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
)
var (
codefile string
input string
expected string
)
var testVMConfig = func() vm.Config {
vmconfig := vm.Config{}
var flagsParsed = func() bool {
flag.StringVar(&codefile, "codefile", "", "EVM code to run")
flag.StringVar(&input, "input", "", "input calldata")
flag.StringVar(&expected, "expected", "", "expected return data")
flag.Parse()
// don't actually need this vmconfig, but we need to parse custom command args in some way like this
return vmconfig
return true
}()
func BenchmarkEvmCode(b *testing.B) {
state, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase()))
state, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
address := common.HexToAddress("0x0a")
var (
@ -78,7 +74,6 @@ func BenchmarkEvmCode(b *testing.B) {
codebytes = common.Hex2Bytes(codehexstr)
state.SetCode(address, codebytes)
evmChainConfig := &params.ChainConfig{
ChainID: big.NewInt(1),
@ -90,13 +85,15 @@ func BenchmarkEvmCode(b *testing.B) {
EIP158Block: new(big.Int),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
};
}
startGas := uint64(100000000) // 100 million
inputBytes := common.Hex2Bytes(input)
config := &Config{ChainConfig: evmChainConfig, State: state, EVMConfig: vm.Config{}, GasLimit: startGas}
b.ResetTimer()
for i := 0; i < b.N; i++ {
ret, gasLeft, err = Call(address, common.Hex2Bytes(input), &Config{ChainConfig: evmChainConfig, State: state, EVMConfig: testVMConfig, GasLimit: startGas})
ret, gasLeft, err = Call(address, inputBytes, config)
}
b.StopTimer()
//Check if it is correct