aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-11-14 01:12:12 +0800
committerobscuren <geffobscura@gmail.com>2014-11-14 01:12:12 +0800
commit20d518ee959f1621a5accf1f3432282a6c0d6c3c (patch)
treec1c9dcd1e2ced349d11edeca7d2ef179b092fc9b
parent60cdb1148c404218846fd39331690658168f4e04 (diff)
downloadgo-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar
go-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.gz
go-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.bz2
go-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.lz
go-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.xz
go-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.zst
go-tangerine-20d518ee959f1621a5accf1f3432282a6c0d6c3c.zip
Numerous fixes for consensus.
* Removed (buged) C++ specific gas specification for LOG* * Fixed LOG* where mstart went after msize *
-rw-r--r--chain/block_manager.go8
-rw-r--r--chain/chain_manager.go8
-rw-r--r--chain/filter.go2
-rw-r--r--chain/receipt.go1
-rw-r--r--chain/state_transition.go25
-rw-r--r--ethereum.go6
-rw-r--r--peer.go2
-rw-r--r--vm/vm_debug.go10
8 files changed, 48 insertions, 14 deletions
diff --git a/chain/block_manager.go b/chain/block_manager.go
index a1c75fd93..730a44e7b 100644
--- a/chain/block_manager.go
+++ b/chain/block_manager.go
@@ -161,7 +161,6 @@ done:
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
bloom := ethutil.LeftPadBytes(LogsBloom(state.Logs()).Bytes(), 64)
receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, bloom, state.Logs()}
- fmt.Println(receipt)
// Notify all subscribers
go self.eth.EventMux().Post(TxPostEvent{tx})
@@ -215,7 +214,6 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
if err != nil {
return
}
- //block.SetReceipts(receipts)
txSha := DeriveSha(block.transactions)
if bytes.Compare(txSha, block.TxSha) != 0 {
@@ -240,8 +238,10 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
return
}
- if bytes.Compare(CreateBloom(block), block.LogsBloom) != 0 {
- err = errors.New("Unable to replicate block's bloom")
+ block.SetReceipts(receipts)
+ rbloom := CreateBloom(block)
+ if bytes.Compare(rbloom, block.LogsBloom) != 0 {
+ err = fmt.Errorf("unable to replicate block's bloom: %x", rbloom)
return
}
diff --git a/chain/chain_manager.go b/chain/chain_manager.go
index 710d96bef..df390a4c0 100644
--- a/chain/chain_manager.go
+++ b/chain/chain_manager.go
@@ -206,7 +206,7 @@ func (bc *ChainManager) add(block *Block) {
ethutil.Config.Db.Put(block.Hash(), encodedBlock)
ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock)
- chainlogger.Infof("Imported block #%d (%x...)\n", block.Number, block.Hash()[0:4])
+ //chainlogger.Infof("Imported block #%d (%x...)\n", block.Number, block.Hash()[0:4])
}
func (self *ChainManager) CalcTotalDiff(block *Block) (*big.Int, error) {
@@ -333,6 +333,12 @@ func (self *ChainManager) InsertChain(chain *BlockChain) {
self.Ethereum.EventMux().Post(NewBlockEvent{link.block})
self.Ethereum.EventMux().Post(link.messages)
}
+
+ b, e := chain.Front(), chain.Back()
+ if b != nil && e != nil {
+ front, back := b.Value.(*link).block, e.Value.(*link).block
+ chainlogger.Infof("Imported %d blocks. #%v (%x) / %#v (%x)", chain.Len(), front.Number, front.Hash()[0:4], back.Number, back.Hash()[0:4])
+ }
}
func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) {
diff --git a/chain/filter.go b/chain/filter.go
index 71e32c32f..3c0b02d4f 100644
--- a/chain/filter.go
+++ b/chain/filter.go
@@ -2,7 +2,6 @@ package chain
import (
"bytes"
- "fmt"
"math"
"math/big"
@@ -102,7 +101,6 @@ func (self *Filter) Find() []*state.Message {
// Use bloom filtering to see if this block is interesting given the
// current parameters
if self.bloomFilter(block) {
- fmt.Println("block", block.Number, "has something interesting")
// Get the messages of the block
msgs, err := self.eth.BlockManager().GetMessages(block)
if err != nil {
diff --git a/chain/receipt.go b/chain/receipt.go
index 742271fa3..c2e6f53a5 100644
--- a/chain/receipt.go
+++ b/chain/receipt.go
@@ -35,7 +35,6 @@ func (self *Receipt) RlpValueDecode(decoder *ethutil.Value) {
}
func (self *Receipt) RlpData() interface{} {
- fmt.Println(self.logs.RlpData())
return []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs.RlpData()}
}
diff --git a/chain/state_transition.go b/chain/state_transition.go
index c208a9188..afe044299 100644
--- a/chain/state_transition.go
+++ b/chain/state_transition.go
@@ -231,6 +231,31 @@ func (self *StateTransition) TransitionState() (err error) {
}
}
+ /*
+ * XXX The following _should_ replace the above transaction
+ * execution (also for regular calls. Will replace / test next
+ * phase
+ */
+ /*
+ // Execute transaction
+ if tx.CreatesContract() {
+ self.rec = MakeContract(tx, self.state)
+ }
+
+ address := self.Receiver().Address()
+ evm := vm.New(NewEnv(state, self.tx, self.block), vm.DebugVmTy)
+ exe := NewExecution(evm, address, self.tx.Data, self.gas, self.gas.Price, self.tx.Value)
+ ret, err := msg.Exec(address, self.Sender())
+ if err != nil {
+ statelogger.Debugln(err)
+ } else {
+ if tx.CreatesContract() {
+ self.Receiver().Code = ret
+ }
+ msg.Output = ret
+ }
+ */
+
// Add default LOG. Default = big(sender.addr) + 1
//addr := ethutil.BigD(receiver.Address())
//self.state.AddLog(&state.Log{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes(), [][]byte{sender.Address()}, nil})
diff --git a/ethereum.go b/ethereum.go
index a919c3191..ce8a92b58 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -233,7 +233,7 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
if s.peers.Len() < s.MaxPeers {
var alreadyConnected bool
- ahost, _, _ := net.SplitHostPort(addr)
+ ahost, aport, _ := net.SplitHostPort(addr)
var chost string
ips, err := net.LookupIP(ahost)
@@ -273,9 +273,9 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
if p.conn == nil {
return
}
- phost, _, _ := net.SplitHostPort(p.conn.RemoteAddr().String())
+ phost, pport, _ := net.SplitHostPort(p.conn.RemoteAddr().String())
- if phost == chost {
+ if phost == chost && pport == aport {
alreadyConnected = true
//loggerger.Debugf("Peer %s already added.\n", chost)
return
diff --git a/peer.go b/peer.go
index 45865ea66..6fef24ac0 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 = 40
+ ProtocolVersion = 41
// Current P2P version
P2PVersion = 2
// Ethereum network version
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 290eddda4..37ad7620e 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -169,6 +169,8 @@ 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)
@@ -732,12 +734,16 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
case LOG0, LOG1, LOG2, LOG3, LOG4:
n := int(op - LOG0)
topics := make([][]byte, n)
- mSize, mStart := stack.Pop().Int64(), stack.Pop().Int64()
+ mStart, mSize := stack.Pop().Int64(), stack.Pop().Int64()
data := mem.Geti(mStart, mSize)
for i := 0; i < n; i++ {
topics[i] = stack.Pop().Bytes()
}
- self.env.AddLog(&state.Log{closure.Address(), topics, data})
+
+ log := &state.Log{closure.Address(), topics, data}
+ self.env.AddLog(log)
+
+ self.Printf(" => %v", log)
case MLOAD:
offset := stack.Pop()
val := ethutil.BigD(mem.Get(offset.Int64(), 32))