diff options
author | Martin Holst Swende <martin@swende.se> | 2018-10-04 23:15:37 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-10-04 23:15:37 +0800 |
commit | 89a32451aeb418db3fd5d9c427a0c29fddb1e85b (patch) | |
tree | 24df0d470d52030635712364a947bc7a8293d366 /core/vm/runtime | |
parent | 8c63d0d2e44128c6a0f12fb9db8f0a32528b4a7d (diff) | |
download | dexon-89a32451aeb418db3fd5d9c427a0c29fddb1e85b.tar.gz dexon-89a32451aeb418db3fd5d9c427a0c29fddb1e85b.tar.zst dexon-89a32451aeb418db3fd5d9c427a0c29fddb1e85b.zip |
core/vm: faster create/create2 (#17806)
* core/vm/runtim: benchmark create/create2
* core/vm: do less hashing in CREATE2
* core/vm: avoid storing jumpdest analysis for initcode
* core/vm: avoid unneccesary lookups, remove unused fields
* core/vm: go formatting tests
* core/vm: save jumpdest analysis locally
* core/vm: use common.Hash instead of nil, fix review comments
* core/vm: removed type destinations
* core/vm: correct check for empty hash
* eth: more elegant api_tracer
* core/vm: address review concerns
Diffstat (limited to 'core/vm/runtime')
-rw-r--r-- | core/vm/runtime/runtime_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index ef664bda3..bac06e524 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -26,6 +26,7 @@ import ( "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" ) func TestDefaults(t *testing.T) { @@ -148,3 +149,57 @@ func BenchmarkCall(b *testing.B) { } } } +func benchmarkEVM_Create(bench *testing.B, code string) { + var ( + statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) + sender = common.BytesToAddress([]byte("sender")) + receiver = common.BytesToAddress([]byte("receiver")) + ) + + statedb.CreateAccount(sender) + statedb.SetCode(receiver, common.FromHex(code)) + runtimeConfig := Config{ + Origin: sender, + State: statedb, + GasLimit: 10000000, + Difficulty: big.NewInt(0x200000), + Time: new(big.Int).SetUint64(0), + Coinbase: common.Address{}, + BlockNumber: new(big.Int).SetUint64(1), + ChainConfig: ¶ms.ChainConfig{ + ChainID: big.NewInt(1), + HomesteadBlock: new(big.Int), + ByzantiumBlock: new(big.Int), + ConstantinopleBlock: new(big.Int), + DAOForkBlock: new(big.Int), + DAOForkSupport: false, + EIP150Block: new(big.Int), + EIP155Block: new(big.Int), + EIP158Block: new(big.Int), + }, + EVMConfig: vm.Config{}, + } + // Warm up the intpools and stuff + bench.ResetTimer() + for i := 0; i < bench.N; i++ { + Call(receiver, []byte{}, &runtimeConfig) + } + bench.StopTimer() +} + +func BenchmarkEVM_CREATE_500(bench *testing.B) { + // initcode size 500K, repeatedly calls CREATE and then modifies the mem contents + benchmarkEVM_Create(bench, "5b6207a120600080f0600152600056") +} +func BenchmarkEVM_CREATE2_500(bench *testing.B) { + // initcode size 500K, repeatedly calls CREATE2 and then modifies the mem contents + benchmarkEVM_Create(bench, "5b586207a120600080f5600152600056") +} +func BenchmarkEVM_CREATE_1200(bench *testing.B) { + // initcode size 1200K, repeatedly calls CREATE and then modifies the mem contents + benchmarkEVM_Create(bench, "5b62124f80600080f0600152600056") +} +func BenchmarkEVM_CREATE2_1200(bench *testing.B) { + // initcode size 1200K, repeatedly calls CREATE2 and then modifies the mem contents + benchmarkEVM_Create(bench, "5b5862124f80600080f5600152600056") +} |