aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 791a8b91d..bbcff3b92 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)
@@ -633,17 +634,19 @@ func (self *BlockChain) Rollback(chain []common.Hash) {
}
// SetReceiptsData computes all the non-consensus fields of the receipts
-func SetReceiptsData(block *types.Block, receipts types.Receipts) {
+func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts types.Receipts) {
+ signer := types.MakeSigner(config, block.Number())
+
transactions, logIndex := block.Transactions(), uint(0)
for j := 0; j < len(receipts); j++ {
// The transaction hash can be retrieved from the transaction itself
receipts[j].TxHash = transactions[j].Hash()
+ tx, _ := transactions[j].AsMessage(signer)
// The contract address can be derived from the transaction itself
- if MessageCreatesContract(transactions[j]) {
- from, _ := transactions[j].From()
- receipts[j].ContractAddress = crypto.CreateAddress(from, transactions[j].Nonce())
+ if MessageCreatesContract(tx) {
+ receipts[j].ContractAddress = crypto.CreateAddress(tx.From(), tx.Nonce())
}
// The used gas can be calculated based on previous receipts
if j == 0 {
@@ -665,6 +668,7 @@ func SetReceiptsData(block *types.Block, receipts types.Receipts) {
// InsertReceiptChain attempts to complete an already existing header chain with
// transaction and receipt data.
+// XXX should this be moved to the test?
func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []types.Receipts) (int, error) {
self.wg.Add(1)
defer self.wg.Done()
@@ -704,7 +708,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
continue
}
// Compute all the non-consensus fields of the receipts
- SetReceiptsData(block, receipts)
+ SetReceiptsData(self.config, block, receipts)
// Write all the data out into the database
if err := WriteBody(self.chainDb, block.Hash(), block.NumberU64(), block.Body()); err != nil {
errs[index] = fmt.Errorf("failed to write block body: %v", err)
@@ -924,7 +928,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 +940,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 +1313,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 }