diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-03 00:22:33 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-03 00:22:33 +0800 |
commit | cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376 (patch) | |
tree | 5bb3fa719fd1388573201b8baa92b90e790f720a | |
parent | 5ebae82eeb3f5ecdffb96f9d692523d0b0d4f759 (diff) | |
download | go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.tar go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.tar.gz go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.tar.bz2 go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.tar.lz go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.tar.xz go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.tar.zst go-tangerine-cb4d168ecc9f6c2ecdb1a8f3308f8f3eb9f02376.zip |
Updated LOG to match proper gas in all cases
-rw-r--r-- | block_pool.go | 26 | ||||
-rw-r--r-- | chain/chain_manager.go | 5 | ||||
-rw-r--r-- | chain/dagger.go | 14 | ||||
-rw-r--r-- | peer.go | 2 | ||||
-rw-r--r-- | vm/types.go | 8 | ||||
-rw-r--r-- | vm/vm_debug.go | 5 |
6 files changed, 17 insertions, 43 deletions
diff --git a/block_pool.go b/block_pool.go index 69c7a54de..2cc705514 100644 --- a/block_pool.go +++ b/block_pool.go @@ -336,32 +336,6 @@ out: self.Remove(block.Hash()) } } - - /* - // Test and import - bchain := chain.NewChain(blocks) - _, err := chainManager.TestChain(bchain) - if err != nil && !chain.IsTDError(err) { - poollogger.Debugln(err) - - self.Reset() - - if self.peer != nil && self.peer.conn != nil { - poollogger.Debugf("Punishing peer for supplying bad chain (%v)\n", self.peer.conn.RemoteAddr()) - } - - // This peer gave us bad hashes and made us fetch a bad chain, therefor he shall be punished. - self.eth.BlacklistPeer(self.peer) - self.peer.StopWithReason(DiscBadPeer) - self.td = ethutil.Big0 - self.peer = nil - } else { - chainManager.InsertChain(bchain) - for _, block := range blocks { - self.Remove(block.Hash()) - } - } - */ } } } diff --git a/chain/chain_manager.go b/chain/chain_manager.go index 45af61e48..b71510833 100644 --- a/chain/chain_manager.go +++ b/chain/chain_manager.go @@ -321,7 +321,6 @@ func NewChain(blocks Blocks) *BlockChain { return chain } -// This function assumes you've done your checking. No checking is done at this stage anymore func (self *ChainManager) InsertChain(chain Blocks) error { for _, block := range chain { td, messages, err := self.Ethereum.BlockManager().Process(block) @@ -330,7 +329,9 @@ func (self *ChainManager) InsertChain(chain Blocks) error { continue } - chainlogger.Infof("block process failed %v (%x)\n", block.Number, block.Hash()[:4]) + chainlogger.Infof("block #%v process failed (%x)\n", block.Number, block.Hash()[:4]) + chainlogger.Infoln(block) + chainlogger.Infoln(err) return err } diff --git a/chain/dagger.go b/chain/dagger.go index 2cf70e091..a0ccaeeca 100644 --- a/chain/dagger.go +++ b/chain/dagger.go @@ -81,13 +81,17 @@ func (pow *EasyPow) Verify(hash []byte, diff *big.Int, nonce []byte) bool { d := append(hash, nonce...) sha.Write(d) - v := ethutil.BigPow(2, 256) - ret := new(big.Int).Div(v, diff) + verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff) + res := ethutil.U256(ethutil.BigD(sha.Sum(nil))) - res := new(big.Int) - res.SetBytes(sha.Sum(nil)) + /* + fmt.Printf("hash w/o nonce %x\n", hash) + fmt.Printf("2**256 / %v = %v\n", diff, verification) + fmt.Printf("%v <= %v\n", res, verification) + fmt.Printf("vlen: %d rlen: %d\n", len(verification.Bytes()), len(res.Bytes())) + */ - return res.Cmp(ret) == -1 + return res.Cmp(verification) <= 0 } func (pow *EasyPow) SetHash(hash *big.Int) { @@ -24,7 +24,7 @@ const ( // The size of the output buffer for writing messages outputBufferSize = 50 // Current protocol version - ProtocolVersion = 45 + ProtocolVersion = 46 // Current P2P version P2PVersion = 2 // Ethereum network version diff --git a/vm/types.go b/vm/types.go index 0b20fb655..530dbf400 100644 --- a/vm/types.go +++ b/vm/types.go @@ -163,8 +163,8 @@ const ( // 0xf0 range - closures CREATE OpCode = 0xf0 + iota CALL - RETURN CALLCODE + RETURN // 0x70 range - other SUICIDE = 0xff @@ -309,12 +309,6 @@ var opCodeToString = map[OpCode]string{ SWAP15: "SWAP15", SWAP16: "SWAP16", - LOG0: "LOG0", - LOG1: "LOG1", - LOG2: "LOG2", - LOG3: "LOG3", - LOG4: "LOG4", - // 0xf0 range CREATE: "CREATE", CALL: "CALL", diff --git a/vm/vm_debug.go b/vm/vm_debug.go index ea94987d1..dbab8fbcb 100644 --- a/vm/vm_debug.go +++ b/vm/vm_debug.go @@ -165,10 +165,11 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { n := int(op - LOG0) require(n + 2) - mSize, mStart := stack.Peekn() gas.Set(GasLog) addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog)) - addStepGasUsage(new(big.Int).Add(mSize, mStart)) + + mSize, _ := stack.Peekn() + addStepGasUsage(mSize) case EXP: require(2) |