forked from cerc-io/plugeth
Numerous fixes for consensus.
* Removed (buged) C++ specific gas specification for LOG* * Fixed LOG* where mstart went after msize *
This commit is contained in:
parent
60cdb1148c
commit
20d518ee95
@ -161,7 +161,6 @@ done:
|
|||||||
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
|
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
|
||||||
bloom := ethutil.LeftPadBytes(LogsBloom(state.Logs()).Bytes(), 64)
|
bloom := ethutil.LeftPadBytes(LogsBloom(state.Logs()).Bytes(), 64)
|
||||||
receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, bloom, state.Logs()}
|
receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, bloom, state.Logs()}
|
||||||
fmt.Println(receipt)
|
|
||||||
|
|
||||||
// Notify all subscribers
|
// Notify all subscribers
|
||||||
go self.eth.EventMux().Post(TxPostEvent{tx})
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//block.SetReceipts(receipts)
|
|
||||||
|
|
||||||
txSha := DeriveSha(block.transactions)
|
txSha := DeriveSha(block.transactions)
|
||||||
if bytes.Compare(txSha, block.TxSha) != 0 {
|
if bytes.Compare(txSha, block.TxSha) != 0 {
|
||||||
@ -240,8 +238,10 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if bytes.Compare(CreateBloom(block), block.LogsBloom) != 0 {
|
block.SetReceipts(receipts)
|
||||||
err = errors.New("Unable to replicate block's bloom")
|
rbloom := CreateBloom(block)
|
||||||
|
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
|
||||||
|
err = fmt.Errorf("unable to replicate block's bloom: %x", rbloom)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ func (bc *ChainManager) add(block *Block) {
|
|||||||
ethutil.Config.Db.Put(block.Hash(), encodedBlock)
|
ethutil.Config.Db.Put(block.Hash(), encodedBlock)
|
||||||
ethutil.Config.Db.Put([]byte("LastBlock"), 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) {
|
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(NewBlockEvent{link.block})
|
||||||
self.Ethereum.EventMux().Post(link.messages)
|
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) {
|
func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) {
|
||||||
|
@ -2,7 +2,6 @@ package chain
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
@ -102,7 +101,6 @@ func (self *Filter) Find() []*state.Message {
|
|||||||
// Use bloom filtering to see if this block is interesting given the
|
// Use bloom filtering to see if this block is interesting given the
|
||||||
// current parameters
|
// current parameters
|
||||||
if self.bloomFilter(block) {
|
if self.bloomFilter(block) {
|
||||||
fmt.Println("block", block.Number, "has something interesting")
|
|
||||||
// Get the messages of the block
|
// Get the messages of the block
|
||||||
msgs, err := self.eth.BlockManager().GetMessages(block)
|
msgs, err := self.eth.BlockManager().GetMessages(block)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -35,7 +35,6 @@ func (self *Receipt) RlpValueDecode(decoder *ethutil.Value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Receipt) RlpData() interface{} {
|
func (self *Receipt) RlpData() interface{} {
|
||||||
fmt.Println(self.logs.RlpData())
|
|
||||||
return []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs.RlpData()}
|
return []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs.RlpData()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
// Add default LOG. Default = big(sender.addr) + 1
|
||||||
//addr := ethutil.BigD(receiver.Address())
|
//addr := ethutil.BigD(receiver.Address())
|
||||||
//self.state.AddLog(&state.Log{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes(), [][]byte{sender.Address()}, nil})
|
//self.state.AddLog(&state.Log{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes(), [][]byte{sender.Address()}, nil})
|
||||||
|
@ -233,7 +233,7 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
|
|||||||
if s.peers.Len() < s.MaxPeers {
|
if s.peers.Len() < s.MaxPeers {
|
||||||
var alreadyConnected bool
|
var alreadyConnected bool
|
||||||
|
|
||||||
ahost, _, _ := net.SplitHostPort(addr)
|
ahost, aport, _ := net.SplitHostPort(addr)
|
||||||
var chost string
|
var chost string
|
||||||
|
|
||||||
ips, err := net.LookupIP(ahost)
|
ips, err := net.LookupIP(ahost)
|
||||||
@ -273,9 +273,9 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
|
|||||||
if p.conn == nil {
|
if p.conn == nil {
|
||||||
return
|
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
|
alreadyConnected = true
|
||||||
//loggerger.Debugf("Peer %s already added.\n", chost)
|
//loggerger.Debugf("Peer %s already added.\n", chost)
|
||||||
return
|
return
|
||||||
|
2
peer.go
2
peer.go
@ -24,7 +24,7 @@ const (
|
|||||||
// The size of the output buffer for writing messages
|
// The size of the output buffer for writing messages
|
||||||
outputBufferSize = 50
|
outputBufferSize = 50
|
||||||
// Current protocol version
|
// Current protocol version
|
||||||
ProtocolVersion = 40
|
ProtocolVersion = 41
|
||||||
// Current P2P version
|
// Current P2P version
|
||||||
P2PVersion = 2
|
P2PVersion = 2
|
||||||
// Ethereum network version
|
// Ethereum network version
|
||||||
|
@ -169,6 +169,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
gas.Set(GasLog)
|
gas.Set(GasLog)
|
||||||
addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog))
|
addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog))
|
||||||
addStepGasUsage(new(big.Int).Add(mSize, mStart))
|
addStepGasUsage(new(big.Int).Add(mSize, mStart))
|
||||||
|
// BUG in C++
|
||||||
|
//gas.Set(ethutil.Big1)
|
||||||
// Gas only
|
// Gas only
|
||||||
case STOP:
|
case STOP:
|
||||||
gas.Set(ethutil.Big0)
|
gas.Set(ethutil.Big0)
|
||||||
@ -732,12 +734,16 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
case LOG0, LOG1, LOG2, LOG3, LOG4:
|
case LOG0, LOG1, LOG2, LOG3, LOG4:
|
||||||
n := int(op - LOG0)
|
n := int(op - LOG0)
|
||||||
topics := make([][]byte, n)
|
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)
|
data := mem.Geti(mStart, mSize)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
topics[i] = stack.Pop().Bytes()
|
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:
|
case MLOAD:
|
||||||
offset := stack.Pop()
|
offset := stack.Pop()
|
||||||
val := ethutil.BigD(mem.Get(offset.Int64(), 32))
|
val := ethutil.BigD(mem.Get(offset.Int64(), 32))
|
||||||
|
Loading…
Reference in New Issue
Block a user