aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-16 04:11:05 +0800
committerobscuren <geffobscura@gmail.com>2014-09-16 04:11:05 +0800
commit399256b38403f2e95312250d49fca3cada8956b8 (patch)
tree25ee8bb6334377fb18a39463c8bd85ea7878f641 /ethchain
parent33a0dec8a157b9687ca6038f4deb011f3f1f7bdc (diff)
downloadgo-tangerine-399256b38403f2e95312250d49fca3cada8956b8.tar
go-tangerine-399256b38403f2e95312250d49fca3cada8956b8.tar.gz
go-tangerine-399256b38403f2e95312250d49fca3cada8956b8.tar.bz2
go-tangerine-399256b38403f2e95312250d49fca3cada8956b8.tar.lz
go-tangerine-399256b38403f2e95312250d49fca3cada8956b8.tar.xz
go-tangerine-399256b38403f2e95312250d49fca3cada8956b8.tar.zst
go-tangerine-399256b38403f2e95312250d49fca3cada8956b8.zip
VM execution fixes
Refactoring caused executing issues
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/block_chain.go8
-rw-r--r--ethchain/state_manager.go19
2 files changed, 16 insertions, 11 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go
index 5d0d652df..1e29f1188 100644
--- a/ethchain/block_chain.go
+++ b/ethchain/block_chain.go
@@ -148,6 +148,9 @@ func AddTestNetFunds(block *Block) {
}
func (bc *BlockChain) setLastBlock() {
+ // Prep genesis
+ AddTestNetFunds(bc.genesisBlock)
+
data, _ := ethutil.Config.Db.Get([]byte("LastBlock"))
if len(data) != 0 {
block := NewBlockFromBytes(data)
@@ -155,12 +158,7 @@ func (bc *BlockChain) setLastBlock() {
bc.LastBlockHash = block.Hash()
bc.LastBlockNumber = block.Number.Uint64()
- if bc.LastBlockNumber == 0 {
- bc.genesisBlock = block
- }
} else {
- AddTestNetFunds(bc.genesisBlock)
-
bc.genesisBlock.state.Trie.Sync()
// Prepare the genesis block
bc.Add(bc.genesisBlock)
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 1ccaa560f..b0ea754f4 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -5,6 +5,7 @@ import (
"container/list"
"fmt"
"math/big"
+ "os"
"sync"
"time"
@@ -154,6 +155,10 @@ done:
if i < len(block.Receipts()) {
original := block.Receipts()[i]
if !original.Cmp(receipt) {
+ if ethutil.Config.Diff {
+ os.Exit(1)
+ }
+
return nil, nil, nil, fmt.Errorf("err diff #%d (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", i+1, original.CumulativeGasUsed, original.PostState[0:4], receipt.CumulativeGasUsed, receipt.PostState[0:4], receipt.Tx.Hash())
}
}
@@ -307,14 +312,16 @@ func (sm *StateManager) ValidateBlock(block *Block) error {
// Check each uncle's previous hash. In order for it to be valid
// is if it has the same block hash as the current
- previousBlock := sm.bc.GetBlock(block.PrevHash)
- for _, uncle := range block.Uncles {
- if bytes.Compare(uncle.PrevHash, previousBlock.PrevHash) != 0 {
- return ValidationError("Mismatch uncle's previous hash. Expected %x, got %x", previousBlock.PrevHash, uncle.PrevHash)
+ parent := sm.bc.GetBlock(block.PrevHash)
+ /*
+ for _, uncle := range block.Uncles {
+ if bytes.Compare(uncle.PrevHash,parent.PrevHash) != 0 {
+ return ValidationError("Mismatch uncle's previous hash. Expected %x, got %x",parent.PrevHash, uncle.PrevHash)
+ }
}
- }
+ */
- diff := block.Time - previousBlock.Time
+ diff := block.Time - parent.Time
if diff < 0 {
return ValidationError("Block timestamp less then prev block %v (%v - %v)", diff, block.Time, sm.bc.CurrentBlock.Time)
}