Skip to content

Commit c21293c

Browse files
committed
bloom
1 parent 0fa7859 commit c21293c

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

‎core/types/bloom9.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func LogsBloom(logs state.Logs) *big.Int {
2828
}
2929

3030
for _, b := range data {
31-
bin.Or(bin, common.BigD(bloom9(crypto.Sha3(b[:])).Bytes()))
31+
bin.Or(bin, bloom9(crypto.Sha3(b[:])))
3232
}
3333
}
3434

@@ -38,9 +38,10 @@ func LogsBloom(logs state.Logs) *big.Int {
3838
func bloom9(b []byte) *big.Int {
3939
r := new(big.Int)
4040

41-
for i := 0; i < 16; i += 2 {
41+
for i := 0; i < 6; i += 2 {
4242
t := big.NewInt(1)
43-
b := uint(b[i+1]) + 1024*(uint(b[i])&1)
43+
//b := uint(b[i+1]) + 512*(uint(b[i])&1)
44+
b := (uint(b[i+1]) + (uint(b[i]) << 8)) & 511
4445
r.Or(r, t.Lsh(t, b))
4546
}
4647

‎tests/vm/gh_test.go‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package vm
22

33
import (
44
"bytes"
5+
"fmt"
56
"math/big"
67
"strconv"
78
"testing"
89

910
"github.com/ethereum/go-ethereum/common"
11+
"github.com/ethereum/go-ethereum/core/types"
1012
"github.com/ethereum/go-ethereum/ethdb"
1113
"github.com/ethereum/go-ethereum/logger"
1214
"github.com/ethereum/go-ethereum/state"
@@ -80,6 +82,9 @@ func RunVmTest(p string, t *testing.T) {
8082
helper.CreateFileTests(t, p, &tests)
8183

8284
for name, test := range tests {
85+
if name != "log2_nonEmptyMem" {
86+
continue
87+
}
8388
db, _ := ethdb.NewMemDatabase()
8489
statedb := state.New(common.Hash{}, db)
8590
for addr, account := range test.Pre {
@@ -167,16 +172,16 @@ func RunVmTest(p string, t *testing.T) {
167172
if len(test.Logs) != len(logs) {
168173
t.Errorf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
169174
} else {
170-
/*
171-
fmt.Println("A", test.Logs)
172-
fmt.Println("B", logs)
173-
for i, log := range test.Logs {
174-
genBloom := common.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
175-
if !bytes.Equal(genBloom, common.Hex2Bytes(log.BloomF)) {
176-
t.Errorf("bloom mismatch")
177-
}
178-
}
179-
*/
175+
fmt.Println("A", test.Logs)
176+
fmt.Println("B", logs)
177+
for i, log := range test.Logs {
178+
genBloom := common.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
179+
fmt.Println("A BLOOM", log.BloomF)
180+
fmt.Printf("B BLOOM %x\n", genBloom)
181+
if !bytes.Equal(genBloom, common.Hex2Bytes(log.BloomF)) {
182+
t.Errorf("'%s' bloom mismatch", name)
183+
}
184+
}
180185
}
181186
}
182187
//statedb.Trie().PrintRoot()

‎vm/environment.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ func (self *Log) RlpData() interface{} {
8888
*/
8989

9090
func (self *Log) String() string {
91-
return fmt.Sprintf("[A=%x T=%x D=%x]", self.address, self.topics, self.data)
91+
return fmt.Sprintf("{%x %x %x}", self.address, self.data, self.topics)
9292
}

0 commit comments

Comments
 (0)