aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-20 17:53:11 +0800
committerobscuren <geffobscura@gmail.com>2014-10-20 17:53:11 +0800
commit097ba56df59293f9225a8ecdc9e1c43a5ad891bb (patch)
tree2aba3bb53afd2ff8738c2e71526454917707b7ed
parent33ca8d7b8f3d4db4b01890e39fa806766fbe8f84 (diff)
downloadgo-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.tar
go-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.tar.gz
go-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.tar.bz2
go-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.tar.lz
go-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.tar.xz
go-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.tar.zst
go-tangerine-097ba56df59293f9225a8ecdc9e1c43a5ad891bb.zip
Renamed block_chain to chain_manager
-rw-r--r--block_pool.go16
-rw-r--r--ethchain/block_manager_test.go36
-rw-r--r--ethchain/chain_manager.go (renamed from ethchain/block_chain.go)44
-rw-r--r--ethchain/chain_manager_test.go (renamed from ethchain/block_chain_test.go)0
-rw-r--r--ethchain/filter.go8
-rw-r--r--ethchain/state_manager.go16
-rw-r--r--ethchain/transaction_pool.go2
-rw-r--r--ethereum.go6
-rw-r--r--ethminer/miner.go12
-rw-r--r--ethpipe/js_pipe.go6
-rw-r--r--ethpipe/pipe.go4
-rw-r--r--peer.go29
-rw-r--r--tests/vm/gh_test.go9
-rw-r--r--vm/vm_debug.go2
14 files changed, 77 insertions, 113 deletions
diff --git a/block_pool.go b/block_pool.go
index 6ad2f5269..b2cade6ad 100644
--- a/block_pool.go
+++ b/block_pool.go
@@ -66,11 +66,11 @@ func (self *BlockPool) HasLatestHash() bool {
self.mut.Lock()
defer self.mut.Unlock()
- return self.pool[string(self.eth.BlockChain().CurrentBlock.Hash())] != nil
+ return self.pool[string(self.eth.ChainManager().CurrentBlock.Hash())] != nil
}
func (self *BlockPool) HasCommonHash(hash []byte) bool {
- return self.eth.BlockChain().GetBlock(hash) != nil
+ return self.eth.ChainManager().GetBlock(hash) != nil
}
func (self *BlockPool) Blocks() (blocks ethchain.Blocks) {
@@ -137,7 +137,7 @@ func (self *BlockPool) addBlock(b *ethchain.Block, peer *Peer, newBlock bool) {
hash := string(b.Hash())
- if self.pool[hash] == nil && !self.eth.BlockChain().HasBlock(b.Hash()) {
+ if self.pool[hash] == nil && !self.eth.ChainManager().HasBlock(b.Hash()) {
poollogger.Infof("Got unrequested block (%x...)\n", hash[0:4])
self.hashes = append(self.hashes, b.Hash())
@@ -145,10 +145,10 @@ func (self *BlockPool) addBlock(b *ethchain.Block, peer *Peer, newBlock bool) {
// The following is only performed on an unrequested new block
if newBlock {
- fmt.Println("1.", !self.eth.BlockChain().HasBlock(b.PrevHash), ethutil.Bytes2Hex(b.Hash()[0:4]), ethutil.Bytes2Hex(b.PrevHash[0:4]))
+ fmt.Println("1.", !self.eth.ChainManager().HasBlock(b.PrevHash), ethutil.Bytes2Hex(b.Hash()[0:4]), ethutil.Bytes2Hex(b.PrevHash[0:4]))
fmt.Println("2.", self.pool[string(b.PrevHash)] == nil)
fmt.Println("3.", !self.fetchingHashes)
- if !self.eth.BlockChain().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil && !self.fetchingHashes {
+ if !self.eth.ChainManager().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil && !self.fetchingHashes {
poollogger.Infof("Unknown chain, requesting (%x...)\n", b.PrevHash[0:4])
peer.QueueMessage(ethwire.NewMessage(ethwire.MsgGetBlockHashesTy, []interface{}{b.Hash(), uint32(256)}))
}
@@ -265,7 +265,7 @@ out:
ethchain.BlockBy(ethchain.Number).Sort(blocks)
if len(blocks) > 0 {
- if !self.eth.BlockChain().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil && !self.fetchingHashes {
+ if !self.eth.ChainManager().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil && !self.fetchingHashes {
}
}
}
@@ -287,14 +287,14 @@ out:
// Find common block
for i, block := range blocks {
- if self.eth.BlockChain().HasBlock(block.PrevHash) {
+ if self.eth.ChainManager().HasBlock(block.PrevHash) {
blocks = blocks[i:]
break
}
}
if len(blocks) > 0 {
- if self.eth.BlockChain().HasBlock(blocks[0].PrevHash) {
+ if self.eth.ChainManager().HasBlock(blocks[0].PrevHash) {
for i, block := range blocks[1:] {
// NOTE: The Ith element in this loop refers to the previous block in
// outer "blocks"
diff --git a/ethchain/block_manager_test.go b/ethchain/block_manager_test.go
deleted file mode 100644
index 3a1e5f510..000000000
--- a/ethchain/block_manager_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package ethchain
-
-/*
-import (
- _ "fmt"
- "github.com/ethereum/eth-go/ethdb"
- "github.com/ethereum/eth-go/ethutil"
- "math/big"
- "testing"
-)
-
-func TestVm(t *testing.T) {
- InitFees()
- ethutil.ReadConfig("")
-
- db, _ := ethdb.NewMemDatabase()
- ethutil.Config.Db = db
- bm := NewStateManager(nil)
-
- block := bm.bc.genesisBlock
- bm.Prepare(block.State(), block.State())
- script := Compile([]string{
- "PUSH",
- "1",
- "PUSH",
- "2",
- })
- tx := NewTransaction(ContractAddr, big.NewInt(200000000), script)
- addr := tx.Hash()[12:]
- bm.ApplyTransactions(block, []*Transaction{tx})
-
- tx2 := NewTransaction(addr, big.NewInt(1e17), nil)
- tx2.Sign([]byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
- bm.ApplyTransactions(block, []*Transaction{tx2})
-}
-*/
diff --git a/ethchain/block_chain.go b/ethchain/chain_manager.go
index a5dcec438..227b02c0a 100644
--- a/ethchain/block_chain.go
+++ b/ethchain/chain_manager.go
@@ -11,7 +11,7 @@ import (
var chainlogger = ethlog.NewLogger("CHAIN")
-type BlockChain struct {
+type ChainManager struct {
Ethereum EthManager
// The famous, the fabulous Mister GENESIIIIIIS (block)
genesisBlock *Block
@@ -24,8 +24,8 @@ type BlockChain struct {
LastBlockHash []byte
}
-func NewBlockChain(ethereum EthManager) *BlockChain {
- bc := &BlockChain{}
+func NewChainManager(ethereum EthManager) *ChainManager {
+ bc := &ChainManager{}
bc.genesisBlock = NewBlockFromBytes(ethutil.Encode(Genesis))
bc.Ethereum = ethereum
@@ -34,11 +34,11 @@ func NewBlockChain(ethereum EthManager) *BlockChain {
return bc
}
-func (bc *BlockChain) Genesis() *Block {
+func (bc *ChainManager) Genesis() *Block {
return bc.genesisBlock
}
-func (bc *BlockChain) NewBlock(coinbase []byte) *Block {
+func (bc *ChainManager) NewBlock(coinbase []byte) *Block {
var root interface{}
hash := ZeroHash256
@@ -81,7 +81,7 @@ func CalcDifficulty(block, parent *Block) *big.Int {
return diff
}
-func (bc *BlockChain) Reset() {
+func (bc *ChainManager) Reset() {
AddTestNetFunds(bc.genesisBlock)
bc.genesisBlock.state.Trie.Sync()
@@ -97,13 +97,13 @@ func (bc *BlockChain) Reset() {
bc.TD = ethutil.BigD(ethutil.Config.Db.LastKnownTD())
}
-func (bc *BlockChain) HasBlock(hash []byte) bool {
+func (bc *ChainManager) HasBlock(hash []byte) bool {
data, _ := ethutil.Config.Db.Get(hash)
return len(data) != 0
}
// TODO: At one point we might want to save a block by prevHash in the db to optimise this...
-func (bc *BlockChain) HasBlockWithPrevHash(hash []byte) bool {
+func (bc *ChainManager) HasBlockWithPrevHash(hash []byte) bool {
block := bc.CurrentBlock
for ; block != nil; block = bc.GetBlock(block.PrevHash) {
@@ -114,7 +114,7 @@ func (bc *BlockChain) HasBlockWithPrevHash(hash []byte) bool {
return false
}
-func (bc *BlockChain) CalculateBlockTD(block *Block) *big.Int {
+func (bc *ChainManager) CalculateBlockTD(block *Block) *big.Int {
blockDiff := new(big.Int)
for _, uncle := range block.Uncles {
@@ -125,11 +125,11 @@ func (bc *BlockChain) CalculateBlockTD(block *Block) *big.Int {
return blockDiff
}
-func (bc *BlockChain) GenesisBlock() *Block {
+func (bc *ChainManager) GenesisBlock() *Block {
return bc.genesisBlock
}
-func (self *BlockChain) GetChainHashesFromHash(hash []byte, max uint64) (chain [][]byte) {
+func (self *ChainManager) GetChainHashesFromHash(hash []byte, max uint64) (chain [][]byte) {
block := self.GetBlock(hash)
if block == nil {
return
@@ -167,7 +167,7 @@ func AddTestNetFunds(block *Block) {
}
}
-func (bc *BlockChain) setLastBlock() {
+func (bc *ChainManager) setLastBlock() {
data, _ := ethutil.Config.Db.Get([]byte("LastBlock"))
if len(data) != 0 {
// Prep genesis
@@ -187,13 +187,13 @@ func (bc *BlockChain) setLastBlock() {
chainlogger.Infof("Last block (#%d) %x\n", bc.LastBlockNumber, bc.CurrentBlock.Hash())
}
-func (bc *BlockChain) SetTotalDifficulty(td *big.Int) {
+func (bc *ChainManager) SetTotalDifficulty(td *big.Int) {
ethutil.Config.Db.Put([]byte("LTD"), td.Bytes())
bc.TD = td
}
// Add a block to the chain and record addition information
-func (bc *BlockChain) Add(block *Block) {
+func (bc *ChainManager) Add(block *Block) {
bc.writeBlockInfo(block)
// Prepare the genesis block
@@ -205,7 +205,7 @@ func (bc *BlockChain) Add(block *Block) {
ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock)
}
-func (self *BlockChain) CalcTotalDiff(block *Block) (*big.Int, error) {
+func (self *ChainManager) CalcTotalDiff(block *Block) (*big.Int, error) {
parent := self.GetBlock(block.PrevHash)
if parent == nil {
return nil, fmt.Errorf("Unable to calculate total diff without known parent %x", block.PrevHash)
@@ -225,7 +225,7 @@ func (self *BlockChain) CalcTotalDiff(block *Block) (*big.Int, error) {
return td, nil
}
-func (bc *BlockChain) GetBlock(hash []byte) *Block {
+func (bc *ChainManager) GetBlock(hash []byte) *Block {
data, _ := ethutil.Config.Db.Get(hash)
if len(data) == 0 {
return nil
@@ -234,7 +234,7 @@ func (bc *BlockChain) GetBlock(hash []byte) *Block {
return NewBlockFromBytes(data)
}
-func (self *BlockChain) GetBlockByNumber(num uint64) *Block {
+func (self *ChainManager) GetBlockByNumber(num uint64) *Block {
block := self.CurrentBlock
for ; block != nil; block = self.GetBlock(block.PrevHash) {
if block.Number.Uint64() == num {
@@ -249,7 +249,7 @@ func (self *BlockChain) GetBlockByNumber(num uint64) *Block {
return block
}
-func (self *BlockChain) GetBlockBack(num uint64) *Block {
+func (self *ChainManager) GetBlockBack(num uint64) *Block {
block := self.CurrentBlock
for ; num != 0 && block != nil; num-- {
@@ -259,7 +259,7 @@ func (self *BlockChain) GetBlockBack(num uint64) *Block {
return block
}
-func (bc *BlockChain) BlockInfoByHash(hash []byte) BlockInfo {
+func (bc *ChainManager) BlockInfoByHash(hash []byte) BlockInfo {
bi := BlockInfo{}
data, _ := ethutil.Config.Db.Get(append(hash, []byte("Info")...))
bi.RlpDecode(data)
@@ -267,7 +267,7 @@ func (bc *BlockChain) BlockInfoByHash(hash []byte) BlockInfo {
return bi
}
-func (bc *BlockChain) BlockInfo(block *Block) BlockInfo {
+func (bc *ChainManager) BlockInfo(block *Block) BlockInfo {
bi := BlockInfo{}
data, _ := ethutil.Config.Db.Get(append(block.Hash(), []byte("Info")...))
bi.RlpDecode(data)
@@ -276,7 +276,7 @@ func (bc *BlockChain) BlockInfo(block *Block) BlockInfo {
}
// Unexported method for writing extra non-essential block info to the db
-func (bc *BlockChain) writeBlockInfo(block *Block) {
+func (bc *ChainManager) writeBlockInfo(block *Block) {
bc.LastBlockNumber++
bi := BlockInfo{Number: bc.LastBlockNumber, Hash: block.Hash(), Parent: block.PrevHash, TD: bc.TD}
@@ -284,7 +284,7 @@ func (bc *BlockChain) writeBlockInfo(block *Block) {
ethutil.Config.Db.Put(append(block.Hash(), []byte("Info")...), bi.RlpEncode())
}
-func (bc *BlockChain) Stop() {
+func (bc *ChainManager) Stop() {
if bc.CurrentBlock != nil {
chainlogger.Infoln("Stopped")
}
diff --git a/ethchain/block_chain_test.go b/ethchain/chain_manager_test.go
index 3603fd8a7..3603fd8a7 100644
--- a/ethchain/block_chain_test.go
+++ b/ethchain/chain_manager_test.go
diff --git a/ethchain/filter.go b/ethchain/filter.go
index 90f2512ab..4e8df7d5f 100644
--- a/ethchain/filter.go
+++ b/ethchain/filter.go
@@ -76,16 +76,16 @@ func (self *Filter) SetSkip(skip int) {
func (self *Filter) Find() []*ethstate.Message {
var earliestBlockNo uint64 = uint64(self.earliest)
if self.earliest == -1 {
- earliestBlockNo = self.eth.BlockChain().CurrentBlock.Number.Uint64()
+ earliestBlockNo = self.eth.ChainManager().CurrentBlock.Number.Uint64()
}
var latestBlockNo uint64 = uint64(self.latest)
if self.latest == -1 {
- latestBlockNo = self.eth.BlockChain().CurrentBlock.Number.Uint64()
+ latestBlockNo = self.eth.ChainManager().CurrentBlock.Number.Uint64()
}
var (
messages []*ethstate.Message
- block = self.eth.BlockChain().GetBlockByNumber(latestBlockNo)
+ block = self.eth.ChainManager().GetBlockByNumber(latestBlockNo)
quit bool
)
for i := 0; !quit && block != nil; i++ {
@@ -111,7 +111,7 @@ func (self *Filter) Find() []*ethstate.Message {
messages = append(messages, self.FilterMessages(msgs)...)
}
- block = self.eth.BlockChain().GetBlock(block.PrevHash)
+ block = self.eth.ChainManager().GetBlock(block.PrevHash)
}
skip := int(math.Min(float64(len(messages)), float64(self.skip)))
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index b71cbe8a1..ed513c9dc 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -33,7 +33,7 @@ type Peer interface {
type EthManager interface {
StateManager() *StateManager
- BlockChain() *BlockChain
+ ChainManager() *ChainManager
TxPool() *TxPool
Broadcast(msgType ethwire.MsgType, data []interface{})
PeerCount() int
@@ -50,7 +50,7 @@ type StateManager struct {
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
// Canonical block chain
- bc *BlockChain
+ bc *ChainManager
// non-persistent key/value memory storage
mem map[string]*big.Int
// Proof of work used for validating
@@ -79,10 +79,10 @@ func NewStateManager(ethereum EthManager) *StateManager {
mem: make(map[string]*big.Int),
Pow: &EasyPow{},
eth: ethereum,
- bc: ethereum.BlockChain(),
+ bc: ethereum.ChainManager(),
}
- sm.transState = ethereum.BlockChain().CurrentBlock.State().Copy()
- sm.miningState = ethereum.BlockChain().CurrentBlock.State().Copy()
+ sm.transState = ethereum.ChainManager().CurrentBlock.State().Copy()
+ sm.miningState = ethereum.ChainManager().CurrentBlock.State().Copy()
return sm
}
@@ -113,7 +113,7 @@ func (self *StateManager) updateThread() {
}
func (sm *StateManager) CurrentState() *ethstate.State {
- return sm.eth.BlockChain().CurrentBlock.State()
+ return sm.eth.ChainManager().CurrentBlock.State()
}
func (sm *StateManager) TransState() *ethstate.State {
@@ -125,12 +125,12 @@ func (sm *StateManager) MiningState() *ethstate.State {
}
func (sm *StateManager) NewMiningState() *ethstate.State {
- sm.miningState = sm.eth.BlockChain().CurrentBlock.State().Copy()
+ sm.miningState = sm.eth.ChainManager().CurrentBlock.State().Copy()
return sm.miningState
}
-func (sm *StateManager) BlockChain() *BlockChain {
+func (sm *StateManager) ChainManager() *ChainManager {
return sm.bc
}
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go
index 0676af3a3..ff3184582 100644
--- a/ethchain/transaction_pool.go
+++ b/ethchain/transaction_pool.go
@@ -96,7 +96,7 @@ func (pool *TxPool) addTransaction(tx *Transaction) {
func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
// Get the last block so we can retrieve the sender and receiver from
// the merkle trie
- block := pool.Ethereum.BlockChain().CurrentBlock
+ block := pool.Ethereum.ChainManager().CurrentBlock
// Something has gone horribly wrong if this happens
if block == nil {
return fmt.Errorf("[TXPL] No last block on the block chain")
diff --git a/ethereum.go b/ethereum.go
index e5f73d507..bb8d6db73 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -55,7 +55,7 @@ type Ethereum struct {
// for later including in the blocks
txPool *ethchain.TxPool
// The canonical chain
- blockChain *ethchain.BlockChain
+ blockChain *ethchain.ChainManager
// The block pool
blockPool *BlockPool
// Eventer
@@ -129,7 +129,7 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager
ethereum.blockPool = NewBlockPool(ethereum)
ethereum.txPool = ethchain.NewTxPool(ethereum)
- ethereum.blockChain = ethchain.NewBlockChain(ethereum)
+ ethereum.blockChain = ethchain.NewChainManager(ethereum)
ethereum.stateManager = ethchain.NewStateManager(ethereum)
// Start the tx pool
@@ -146,7 +146,7 @@ func (s *Ethereum) ClientIdentity() ethwire.ClientIdentity {
return s.clientIdentity
}
-func (s *Ethereum) BlockChain() *ethchain.BlockChain {
+func (s *Ethereum) ChainManager() *ethchain.ChainManager {
return s.blockChain
}
diff --git a/ethminer/miner.go b/ethminer/miner.go
index ffc49f096..69f6e4bf6 100644
--- a/ethminer/miner.go
+++ b/ethminer/miner.go
@@ -61,7 +61,7 @@ func (miner *Miner) Start() {
// Insert initial TXs in our little miner 'pool'
miner.txs = miner.ethereum.TxPool().Flush()
- miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase)
+ miner.block = miner.ethereum.ChainManager().NewBlock(miner.coinbase)
mux := miner.ethereum.EventMux()
miner.events = mux.Subscribe(ethchain.NewBlockEvent{}, ethchain.TxEvent{})
@@ -95,7 +95,7 @@ func (miner *Miner) listener() {
case ethchain.NewBlockEvent:
block := event.Block
//logger.Infoln("Got new block via Reactor")
- if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 {
+ if bytes.Compare(miner.ethereum.ChainManager().CurrentBlock.Hash(), block.Hash()) == 0 {
// TODO: Perhaps continue mining to get some uncle rewards
//logger.Infoln("New top block found resetting state")
@@ -115,10 +115,10 @@ func (miner *Miner) listener() {
miner.txs = newtxs
// Setup a fresh state to mine on
- //miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs)
+ //miner.block = miner.ethereum.ChainManager().NewBlock(miner.coinbase, miner.txs)
} else {
- if bytes.Compare(block.PrevHash, miner.ethereum.BlockChain().CurrentBlock.PrevHash) == 0 {
+ if bytes.Compare(block.PrevHash, miner.ethereum.ChainManager().CurrentBlock.PrevHash) == 0 {
logger.Infoln("Adding uncle block")
miner.uncles = append(miner.uncles, block)
}
@@ -163,7 +163,7 @@ func (miner *Miner) stopMining() {
func (self *Miner) mineNewBlock() {
stateManager := self.ethereum.StateManager()
- self.block = self.ethereum.BlockChain().NewBlock(self.coinbase)
+ self.block = self.ethereum.ChainManager().NewBlock(self.coinbase)
// Apply uncles
if len(self.uncles) > 0 {
@@ -175,7 +175,7 @@ func (self *Miner) mineNewBlock() {
// Accumulate all valid transactions and apply them to the new state
// Error may be ignored. It's not important during mining
- parent := self.ethereum.BlockChain().GetBlock(self.block.PrevHash)
+ parent := self.ethereum.ChainManager().GetBlock(self.block.PrevHash)
coinbase := self.block.State().GetOrNewStateObject(self.block.Coinbase)
coinbase.SetGasPool(self.block.CalcGasLimit(parent))
receipts, txs, unhandledTxs, err := stateManager.ProcessTransactions(coinbase, self.block.State(), self.block, self.block, self.txs)
diff --git a/ethpipe/js_pipe.go b/ethpipe/js_pipe.go
index 24a553dad..873373b75 100644
--- a/ethpipe/js_pipe.go
+++ b/ethpipe/js_pipe.go
@@ -21,17 +21,17 @@ func NewJSPipe(eth ethchain.EthManager) *JSPipe {
func (self *JSPipe) BlockByHash(strHash string) *JSBlock {
hash := ethutil.Hex2Bytes(strHash)
- block := self.obj.BlockChain().GetBlock(hash)
+ block := self.obj.ChainManager().GetBlock(hash)
return NewJSBlock(block)
}
func (self *JSPipe) BlockByNumber(num int32) *JSBlock {
if num == -1 {
- return NewJSBlock(self.obj.BlockChain().CurrentBlock)
+ return NewJSBlock(self.obj.ChainManager().CurrentBlock)
}
- return NewJSBlock(self.obj.BlockChain().GetBlockByNumber(uint64(num)))
+ return NewJSBlock(self.obj.ChainManager().GetBlockByNumber(uint64(num)))
}
func (self *JSPipe) Block(v interface{}) *JSBlock {
diff --git a/ethpipe/pipe.go b/ethpipe/pipe.go
index 5e5ff7000..50507143c 100644
--- a/ethpipe/pipe.go
+++ b/ethpipe/pipe.go
@@ -21,7 +21,7 @@ type VmVars struct {
type Pipe struct {
obj ethchain.EthManager
stateManager *ethchain.StateManager
- blockChain *ethchain.BlockChain
+ blockChain *ethchain.ChainManager
world *World
Vm VmVars
@@ -31,7 +31,7 @@ func New(obj ethchain.EthManager) *Pipe {
pipe := &Pipe{
obj: obj,
stateManager: obj.StateManager(),
- blockChain: obj.BlockChain(),
+ blockChain: obj.ChainManager(),
}
pipe.world = NewWorld(pipe)
diff --git a/peer.go b/peer.go
index 52eb20cfc..0eb2eb299 100644
--- a/peer.go
+++ b/peer.go
@@ -476,7 +476,7 @@ func (p *Peer) HandleInbound() {
hash := msg.Data.Get(0).Bytes()
amount := msg.Data.Get(1).Uint()
- hashes := p.ethereum.BlockChain().GetChainHashesFromHash(hash, amount)
+ hashes := p.ethereum.ChainManager().GetChainHashesFromHash(hash, amount)
p.QueueMessage(ethwire.NewMessage(ethwire.MsgBlockHashesTy, ethutil.ByteSliceToInterface(hashes)))
@@ -487,7 +487,7 @@ func (p *Peer) HandleInbound() {
for i := 0; i < max; i++ {
hash := msg.Data.Get(i).Bytes()
- block := p.ethereum.BlockChain().GetBlock(hash)
+ block := p.ethereum.ChainManager().GetBlock(hash)
if block != nil {
blocks = append(blocks, block.Value().Raw())
}
@@ -674,9 +674,9 @@ func (self *Peer) pushStatus() {
msg := ethwire.NewMessage(ethwire.MsgStatusTy, []interface{}{
//uint32(ProtocolVersion),
uint32(NetVersion),
- self.ethereum.BlockChain().TD,
- self.ethereum.BlockChain().CurrentBlock.Hash(),
- self.ethereum.BlockChain().Genesis().Hash(),
+ self.ethereum.ChainManager().TD,
+ self.ethereum.ChainManager().CurrentBlock.Hash(),
+ self.ethereum.ChainManager().Genesis().Hash(),
})
self.QueueMessage(msg)
@@ -693,7 +693,7 @@ func (self *Peer) handleStatus(msg *ethwire.Msg) {
genesis = c.Get(3).Bytes()
)
- if bytes.Compare(self.ethereum.BlockChain().Genesis().Hash(), genesis) != 0 {
+ if bytes.Compare(self.ethereum.ChainManager().Genesis().Hash(), genesis) != 0 {
ethlogger.Warnf("Invalid genisis hash %x. Disabling [eth]\n", genesis)
return
}
@@ -728,7 +728,7 @@ func (self *Peer) handleStatus(msg *ethwire.Msg) {
func (p *Peer) pushHandshake() error {
pubkey := p.ethereum.KeyManager().PublicKey()
msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{
- P2PVersion, []byte(p.version), []interface{}{"eth", ProtocolVersion}, p.port, pubkey[1:],
+ P2PVersion, []byte(p.version), []interface{}{[]interface{}{"eth", ProtocolVersion}}, p.port, pubkey[1:],
})
p.QueueMessage(msg)
@@ -749,6 +749,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
// Check correctness of p2p protocol version
if p2pVersion != P2PVersion {
+ fmt.Println(p)
peerlogger.Debugf("Invalid P2P version. Require protocol %d, received %d\n", P2PVersion, p2pVersion)
p.Stop()
return
@@ -807,16 +808,16 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
p.ethereum.eventMux.Post(PeerListEvent{p.ethereum.Peers()})
p.protocolCaps = caps
- capsIt := caps.NewIterator()
+
+ it := caps.NewIterator()
var capsStrs []string
- for capsIt.Next() {
- cap := capsIt.Value().Str()
+ for it.Next() {
+ cap := it.Value().Get(0).Str()
+ ver := it.Value().Get(1).Uint()
switch cap {
case "eth":
- capsIt.Next()
- version := capsIt.Value().Uint()
- if version != ProtocolVersion {
- ethlogger.Warnf("Invalid protocol version %d. Disabling [eth]\n", version)
+ if ver != ProtocolVersion {
+ ethlogger.Warnf("Invalid protocol version %d. Disabling [eth]\n", ver)
continue
}
p.pushStatus()
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go
index 466fae9c7..f27cc7af3 100644
--- a/tests/vm/gh_test.go
+++ b/tests/vm/gh_test.go
@@ -44,6 +44,9 @@ func RunVmTest(p string, t *testing.T) {
helper.CreateFileTests(t, p, &tests)
for name, test := range tests {
+ if name != "CallRecursiveBomb" {
+ continue
+ }
state := ethstate.New(helper.NewTrie())
for addr, account := range test.Pre {
obj := StateObjectFromAccount(addr, account)
@@ -56,11 +59,6 @@ func RunVmTest(p string, t *testing.T) {
if err != nil {
helper.Log.Infoln(err)
}
- /*
- if err != nil {
- t.Errorf("%s's execution failed. %v\n", name, err)
- }
- */
rexp := helper.FromHex(test.Out)
if bytes.Compare(rexp, ret) != 0 {
@@ -94,6 +92,7 @@ func TestVMArithmetic(t *testing.T) {
}
func TestVMSystemOperation(t *testing.T) {
+ helper.Logger.SetLogLevel(5)
const fn = "../files/vmtests/vmSystemOperationsTest.json"
RunVmTest(fn, t)
}
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 785e699c7..8773df087 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -97,7 +97,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
return closure.Return(nil), nil
}
- vmlogger.Debugf("(%s) %x gas: %v (d) %x\n", self.Fn, closure.Address(), closure.Gas, closure.Args)
+ vmlogger.Debugf("(%d) %x gas: %v (d) %x\n", self.depth, closure.Address(), closure.Gas, closure.Args)
for {
prevStep = step