Numerous fixes for consensus.

* Removed (buged) C++ specific gas specification for LOG*
* Fixed LOG* where mstart went after msize
*
This commit is contained in:
obscuren
2014-11-13 18:12:12 +01:00
parent 60cdb1148c
commit 20d518ee95
8 changed files with 48 additions and 14 deletions

View File

@@ -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
}

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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()}
}

View File

@@ -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})