aboutsummaryrefslogtreecommitdiffstats
path: root/chain
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 /chain
parent60cdb1148c404218846fd39331690658168f4e04 (diff)
downloaddexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar
dexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.gz
dexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.bz2
dexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.lz
dexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.xz
dexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.tar.zst
dexon-20d518ee959f1621a5accf1f3432282a6c0d6c3c.zip
Numerous fixes for consensus.
* Removed (buged) C++ specific gas specification for LOG* * Fixed LOG* where mstart went after msize *
Diffstat (limited to 'chain')
-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
5 files changed, 36 insertions, 8 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})