diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-05 19:32:47 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-05 19:32:47 +0800 |
commit | d80f8bda940a8ae8f6dab1502a46054c06cee5cc (patch) | |
tree | 3397c3d58bcef44840de4098c23d5ef93056a7f3 /core | |
parent | 3cf0477c21376b16492cb0b8705b9c7b951e2fb8 (diff) | |
download | dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.gz dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.zst dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.zip |
Fixed issue in VM where LOG didn't pop anything of the stack
Diffstat (limited to 'core')
-rw-r--r-- | core/block_manager.go | 13 | ||||
-rw-r--r-- | core/types/bloom9.go | 12 | ||||
-rw-r--r-- | core/types/receipt.go | 13 |
3 files changed, 24 insertions, 14 deletions
diff --git a/core/block_manager.go b/core/block_manager.go index 909f26a1b..4c1cea35a 100644 --- a/core/block_manager.go +++ b/core/block_manager.go @@ -236,6 +236,12 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I return } + rbloom := types.CreateBloom(receipts) + if bytes.Compare(rbloom, block.LogsBloom) != 0 { + err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom) + return + } + txSha := types.DeriveSha(block.Transactions()) if bytes.Compare(txSha, block.TxSha) != 0 { err = fmt.Errorf("validating transaction root. received=%x got=%x", block.TxSha, txSha) @@ -252,13 +258,6 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I return } - //block.receipts = receipts // although this isn't necessary it be in the future - rbloom := types.CreateBloom(receipts) - if bytes.Compare(rbloom, block.LogsBloom) != 0 { - err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom) - return - } - state.Update(ethutil.Big0) if !block.State().Cmp(state) { diff --git a/core/types/bloom9.go b/core/types/bloom9.go index d04656b0d..c1841e553 100644 --- a/core/types/bloom9.go +++ b/core/types/bloom9.go @@ -20,18 +20,16 @@ func CreateBloom(receipts Receipts) []byte { func LogsBloom(logs state.Logs) *big.Int { bin := new(big.Int) for _, log := range logs { - data := [][]byte{log.Address()} - for _, topic := range log.Topics() { - data = append(data, topic) + data := make([][]byte, len(log.Topics())+1) + data[0] = log.Address() + + for i, topic := range log.Topics() { + data[i+1] = topic } for _, b := range data { bin.Or(bin, ethutil.BigD(bloom9(crypto.Sha3(b)).Bytes())) } - - //if log.Data != nil { - // data = append(data, log.Data) - //} } return bin diff --git a/core/types/receipt.go b/core/types/receipt.go index 25fa8fb07..bac64e41d 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -64,5 +64,18 @@ func (self *Receipt) String() string { type Receipts []*Receipt +func (self Receipts) RlpData() interface{} { + data := make([]interface{}, len(self)) + for i, receipt := range self { + data[i] = receipt.RlpData() + } + + return data +} + +func (self Receipts) RlpEncode() []byte { + return ethutil.Encode(self.RlpData()) +} + func (self Receipts) Len() int { return len(self) } func (self Receipts) GetRlp(i int) []byte { return ethutil.Rlp(self[i]) } |