diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-10-20 19:36:29 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-11-13 17:44:04 +0800 |
commit | 445feaeef58bd89a113743dccf6fd5df55cde6fa (patch) | |
tree | 6c692a0989800f005a94bde2d372fcbe1f7630a1 /core/blockchain.go | |
parent | 932d973e36ff0d41a6005b93d2d4ff1b4430fb04 (diff) | |
download | go-tangerine-445feaeef58bd89a113743dccf6fd5df55cde6fa.tar.gz go-tangerine-445feaeef58bd89a113743dccf6fd5df55cde6fa.tar.zst go-tangerine-445feaeef58bd89a113743dccf6fd5df55cde6fa.zip |
core, core/state, trie: EIP158, reprice & skip empty account write
This commit implements EIP158 part 1, 2, 3 & 4
1. If an account is empty it's no longer written to the trie. An empty
account is defined as (balance=0, nonce=0, storage=0, code=0).
2. Delete an empty account if it's touched
3. An empty account is redefined as either non-existent or empty.
4. Zero value calls and zero value suicides no longer consume the 25k
reation costs.
params: moved core/config to params
Signed-off-by: Jeffrey Wilcke <jeffrey@ethereum.org>
Diffstat (limited to 'core/blockchain.go')
-rw-r--r-- | core/blockchain.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 791a8b91d..8b93da60b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -38,6 +38,7 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" @@ -78,7 +79,7 @@ const ( // included in the canonical one where as GetBlockByNumber always represents the // canonical chain. type BlockChain struct { - config *ChainConfig // chain & network configuration + config *params.ChainConfig // chain & network configuration hc *HeaderChain chainDb ethdb.Database @@ -113,7 +114,7 @@ type BlockChain struct { // NewBlockChain returns a fully initialised block chain using information // available in the database. It initialiser the default Ethereum Validator and // Processor. -func NewBlockChain(chainDb ethdb.Database, config *ChainConfig, pow pow.PoW, mux *event.TypeMux) (*BlockChain, error) { +func NewBlockChain(chainDb ethdb.Database, config *params.ChainConfig, pow pow.PoW, mux *event.TypeMux) (*BlockChain, error) { bodyCache, _ := lru.New(bodyCacheLimit) bodyRLPCache, _ := lru.New(bodyCacheLimit) blockCache, _ := lru.New(blockCacheLimit) @@ -924,7 +925,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) { return i, err } // Process block using the parent state as reference point. - receipts, logs, usedGas, err := self.processor.Process(block, self.stateCache, self.config.VmConfig) + receipts, logs, usedGas, err := self.processor.Process(block, self.stateCache, vm.Config{}) if err != nil { reportBlock(block, err) return i, err @@ -936,7 +937,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) { return i, err } // Write state changes to database - _, err = self.stateCache.Commit() + _, err = self.stateCache.Commit(self.config.IsEIP158(block.Number())) if err != nil { return i, err } @@ -1309,4 +1310,4 @@ func (self *BlockChain) GetHeaderByNumber(number uint64) *types.Header { } // Config retrieves the blockchain's chain configuration. -func (self *BlockChain) Config() *ChainConfig { return self.config } +func (self *BlockChain) Config() *params.ChainConfig { return self.config } |