aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block_pool.go2
-rw-r--r--chain/block_manager.go13
-rw-r--r--chain/bloom9.go1
-rw-r--r--peer.go2
-rw-r--r--vm/execution.go2
-rw-r--r--vm/stack.go28
-rw-r--r--vm/vm_debug.go15
7 files changed, 34 insertions, 29 deletions
diff --git a/block_pool.go b/block_pool.go
index f89ee71df..a1c3fc096 100644
--- a/block_pool.go
+++ b/block_pool.go
@@ -200,7 +200,7 @@ func (self *BlockPool) DistributeHashes() {
} else if lastFetchFailed || item.peer == nil {
// Find a suitable, available peer
eachPeer(self.eth.peers, func(p *Peer, v *list.Element) {
- if peer == nil && len(dist[p]) < amount/peerLen {
+ if peer == nil && len(dist[p]) < amount/peerLen && p.statusKnown {
peer = p
}
})
diff --git a/chain/block_manager.go b/chain/block_manager.go
index 730a44e7b..d39f188d4 100644
--- a/chain/block_manager.go
+++ b/chain/block_manager.go
@@ -217,13 +217,13 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
txSha := DeriveSha(block.transactions)
if bytes.Compare(txSha, block.TxSha) != 0 {
- err = fmt.Errorf("Error validating transaction sha. Received %x, got %x", block.TxSha, txSha)
+ err = fmt.Errorf("Error validating transaction root. Received %x, got %x", block.TxSha, txSha)
return
}
receiptSha := DeriveSha(receipts)
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
- err = fmt.Errorf("Error validating receipt sha. Received %x, got %x", block.ReceiptSha, receiptSha)
+ err = fmt.Errorf("Error validating receipt root. Received %x, got %x", block.ReceiptSha, receiptSha)
return
}
@@ -238,7 +238,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
return
}
- block.SetReceipts(receipts)
+ block.receipts = receipts
rbloom := CreateBloom(block)
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
err = fmt.Errorf("unable to replicate block's bloom: %x", rbloom)
@@ -260,12 +260,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
messages := state.Manifest().Messages
state.Manifest().Reset()
- /*
- sm.eth.ChainManager().SetTotalDifficulty(td)
- sm.eth.ChainManager().add(block)
- sm.eth.EventMux().Post(NewBlockEvent{block})
- sm.eth.EventMux().Post(messages)
- */
+ chainlogger.Infof("Processed block #%d (%x...)\n", block.Number, block.Hash()[0:4])
sm.transState = state.Copy()
diff --git a/chain/bloom9.go b/chain/bloom9.go
index 4c029b56b..bf270127e 100644
--- a/chain/bloom9.go
+++ b/chain/bloom9.go
@@ -10,7 +10,6 @@ import (
func CreateBloom(block *Block) []byte {
bin := new(big.Int)
- bin.Or(bin, bloom9(crypto.Sha3(block.Coinbase)))
for _, receipt := range block.Receipts() {
bin.Or(bin, LogsBloom(receipt.logs))
}
diff --git a/peer.go b/peer.go
index 6fef24ac0..b54978854 100644
--- a/peer.go
+++ b/peer.go
@@ -24,7 +24,7 @@ const (
// The size of the output buffer for writing messages
outputBufferSize = 50
// Current protocol version
- ProtocolVersion = 41
+ ProtocolVersion = 42
// Current P2P version
P2PVersion = 2
// Ethereum network version
diff --git a/vm/execution.go b/vm/execution.go
index 401157808..c23164f82 100644
--- a/vm/execution.go
+++ b/vm/execution.go
@@ -34,11 +34,13 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error)
func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte, err error) {
env := self.vm.Env()
+ vmlogger.Debugf("pre state %x\n", env.State().Root())
snapshot := env.State().Copy()
defer func() {
if IsDepthErr(err) || IsOOGErr(err) {
env.State().Set(snapshot)
}
+ vmlogger.Debugf("post state %x\n", env.State().Root())
}()
msg := env.State().Manifest().AddMessage(&state.Message{
diff --git a/vm/stack.go b/vm/stack.go
index 69ded6562..2eca60ad1 100644
--- a/vm/stack.go
+++ b/vm/stack.go
@@ -107,20 +107,26 @@ type Memory struct {
store []byte
}
+func NewMemory() *Memory {
+ return &Memory{nil}
+}
+
func (m *Memory) Set(offset, size int64, value []byte) {
- totSize := offset + size
- lenSize := int64(len(m.store) - 1)
- if totSize > lenSize {
- // Calculate the diff between the sizes
- diff := totSize - lenSize
- if diff > 0 {
- // Create a new empty slice and append it
- newSlice := make([]byte, diff-1)
- // Resize slice
- m.store = append(m.store, newSlice...)
+ if len(value) > 0 {
+ totSize := offset + size
+ lenSize := int64(len(m.store) - 1)
+ if totSize > lenSize {
+ // Calculate the diff between the sizes
+ diff := totSize - lenSize
+ if diff > 0 {
+ // Create a new empty slice and append it
+ newSlice := make([]byte, diff-1)
+ // Resize slice
+ m.store = append(m.store, newSlice...)
+ }
}
+ copy(m.store[offset:offset+size], value)
}
- copy(m.store[offset:offset+size], value)
}
func (m *Memory) Resize(size uint64) {
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 37ad7620e..ae5a20175 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -61,7 +61,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
op OpCode
destinations = analyseJumpDests(closure.Code)
- mem = &Memory{}
+ mem = NewMemory()
stack = NewStack()
pc = big.NewInt(0)
step = 0
@@ -169,8 +169,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
gas.Set(GasLog)
addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog))
addStepGasUsage(new(big.Int).Add(mSize, mStart))
- // BUG in C++
- //gas.Set(ethutil.Big1)
// Gas only
case STOP:
gas.Set(ethutil.Big0)
@@ -263,11 +261,14 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
memGasUsage.Div(memGasUsage, u256(32))
addStepGasUsage(memGasUsage)
+
+ mem.Resize(newMemSize.Uint64())
}
+
}
self.Printf("(pc) %-3d -o- %-14s", pc, op.String())
- self.Printf(" (g) %-3v (%v)", gas, closure.Gas)
+ self.Printf(" (m) %-4d (s) %-4d (g) %-3v (%v)", mem.Len(), stack.Len(), gas, closure.Gas)
if !closure.UseGas(gas) {
self.Endl()
@@ -279,8 +280,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
return closure.Return(nil), OOG(gas, tmp)
}
- mem.Resize(newMemSize.Uint64())
-
switch op {
// 0x20 range
case ADD:
@@ -622,6 +621,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
code := closure.Args[cOff : cOff+l]
mem.Set(mOff, l, code)
+
+ self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, code[cOff:cOff+l])
case CODESIZE, EXTCODESIZE:
var code []byte
if op == EXTCODESIZE {
@@ -663,6 +664,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
codeCopy := code[cOff : cOff+l]
mem.Set(mOff, l, codeCopy)
+
+ self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, code[cOff:cOff+l])
case GASPRICE:
stack.Push(closure.Price)