From 69c1f2c2a760fcb1c4229bff06719c73aa8cce31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 12 Feb 2018 11:54:14 +0200 Subject: core: force import known but rolled back blocks --- core/blockchain.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/blockchain.go b/core/blockchain.go index 8d141fddb..e498dedef 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1070,8 +1070,12 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty } switch { case err == ErrKnownBlock: - stats.ignored++ - continue + // Block and state both already known. However if the current block is below + // this number we did a rollback and we should reimport it nonetheless. + if bc.CurrentBlock().NumberU64() >= block.NumberU64() { + stats.ignored++ + continue + } case err == consensus.ErrFutureBlock: // Allow up to MaxFuture second in the future blocks. If this limit is exceeded -- cgit v1.2.3 From b007412db165e22640eb4cef6cb41013f54ddd32 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 13 Feb 2018 14:12:55 +0100 Subject: core: soften up state memory force-commit log messages (#16080) Talk about "state" instead of "trie timing", "trie memory" and remove the overzealous warning when the limit is just reached. Since the time limit is always reached on slow machines, move the message to info level so users don't freak out about internal details. --- core/blockchain.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/blockchain.go b/core/blockchain.go index e498dedef..4ae0e4f4e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -926,13 +926,9 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. if chosen < lastWrite+triesInMemory { switch { case size >= 2*limit: - log.Error("Trie memory critical, forcing to disk", "size", size, "limit", limit, "optimum", float64(chosen-lastWrite)/triesInMemory) + log.Warn("State memory usage too high, committing", "size", size, "limit", limit, "optimum", float64(chosen-lastWrite)/triesInMemory) case bc.gcproc >= 2*bc.cacheConfig.TrieTimeLimit: - log.Error("Trie timing critical, forcing to disk", "time", bc.gcproc, "allowance", bc.cacheConfig.TrieTimeLimit, "optimum", float64(chosen-lastWrite)/triesInMemory) - case size > limit: - log.Warn("Trie memory at dangerous levels", "size", size, "limit", limit, "optimum", float64(chosen-lastWrite)/triesInMemory) - case bc.gcproc > bc.cacheConfig.TrieTimeLimit: - log.Warn("Trie timing at dangerous levels", "time", bc.gcproc, "limit", bc.cacheConfig.TrieTimeLimit, "optimum", float64(chosen-lastWrite)/triesInMemory) + log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", bc.cacheConfig.TrieTimeLimit, "optimum", float64(chosen-lastWrite)/triesInMemory) } } // If optimum or critical limits reached, write to disk -- cgit v1.2.3 From a5c0bbb4f4c321c355637ef57fff807857128c6b Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 14 Feb 2018 13:49:11 +0100 Subject: all: update license information (#16089) --- core/vm/contracts_test.go | 16 ++++++++++++++++ core/vm/instructions_test.go | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'core') diff --git a/core/vm/contracts_test.go b/core/vm/contracts_test.go index 513651835..96083337c 100644 --- a/core/vm/contracts_test.go +++ b/core/vm/contracts_test.go @@ -1,3 +1,19 @@ +// Copyright 2017 The go-ethereum Authors +// 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 . + package vm import ( diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index 18644989c..180433ea8 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -1,3 +1,19 @@ +// Copyright 2017 The go-ethereum Authors +// 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 . + package vm import ( -- cgit v1.2.3 From ff225db813b6d56ecd35db301bc582ca04e42b27 Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Wed, 14 Feb 2018 14:41:05 +0100 Subject: core/vm: remove unused hashing (#16075) --- core/vm/interpreter.go | 7 ------- 1 file changed, 7 deletions(-) (limited to 'core') diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 482e67a3a..82a6d3de6 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -20,9 +20,7 @@ import ( "fmt" "sync/atomic" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" ) @@ -123,11 +121,6 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er return nil, nil } - codehash := contract.CodeHash // codehash is used when doing jump dest caching - if codehash == (common.Hash{}) { - codehash = crypto.Keccak256Hash(contract.Code) - } - var ( op OpCode // current opcode mem = NewMemory() // bound memory -- cgit v1.2.3 From dc7ca52b3b7c84e8371ea0c1acde327149df6c50 Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Wed, 14 Feb 2018 21:02:51 +0100 Subject: core: handle ignored error (#16065) - according to implementation of `IntrinsicGas` we can continue execution since problem will be detected later. However, early return is future-proof for changes. --- core/state_transition.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core') diff --git a/core/state_transition.go b/core/state_transition.go index 390473fff..b19bc12e4 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -215,6 +215,9 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo // Pay intrinsic gas gas, err := IntrinsicGas(st.data, contractCreation, homestead) + if err != nil { + return nil, 0, false, err + } if err = st.useGas(gas); err != nil { return nil, 0, false, err } -- cgit v1.2.3