Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e3: union limit #7156

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 4 additions & 59 deletions cmd/rpcdaemon/commands/eth_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func applyFiltersV3(tx kv.TemporalTx, begin, end uint64, crit filters.FilterCrit
if out == nil {
out = addrBitmap
} else {
out = iter.Intersect[uint64](out, addrBitmap)
out = iter.Intersect[uint64](out, addrBitmap, -1)
}
}
if out == nil {
Expand Down Expand Up @@ -551,14 +551,14 @@ func getTopicsBitmapV3(tx kv.TemporalTx, topics [][]common.Hash, from, to uint64
if err != nil {
return nil, err
}
topicsUnion = iter.Union[uint64](topicsUnion, it, order.Asc)
topicsUnion = iter.Union[uint64](topicsUnion, it, order.Asc, -1)
}

if res == nil {
res = topicsUnion
continue
}
res = iter.Intersect[uint64](res, topicsUnion)
res = iter.Intersect[uint64](res, topicsUnion, -1)
}
return res, nil
}
Expand All @@ -569,66 +569,11 @@ func getAddrsBitmapV3(tx kv.TemporalTx, addrs []common.Address, from, to uint64)
if err != nil {
return nil, err
}
res = iter.Union[uint64](res, it, order.Asc)
res = iter.Union[uint64](res, it, order.Asc, -1)
}
return res, nil
}

/*
func getTopicsBitmapV3(tx kv.TemporalTx, topics [][]common.Hash, from, to uint64) (*roaring64.Bitmap, error) {
var result *roaring64.Bitmap
for _, sub := range topics {
bitmapForORing := bitmapdb.NewBitmap64()
defer bitmapdb.ReturnToPool64(bitmapForORing)

for _, topic := range sub {
it, err := tx.IndexRange(temporal.LogTopicIdx, topic.Bytes(), from, to, true, -1)
if err != nil {
return nil, err
}
bm, err := it.(bitmapdb.ToBitmap).ToBitmap()
if err != nil {
return nil, err
}
bitmapForORing.Or(bm)
}

if bitmapForORing.GetCardinality() == 0 {
continue
}
if result == nil {
result = bitmapForORing.Clone()
continue
}
result = roaring64.And(bitmapForORing, result)
}
return result, nil
}

func getAddrsBitmapV3(tx kv.TemporalTx, addrs []common.Address, from, to uint64) (*roaring64.Bitmap, error) {
if len(addrs) == 0 {
return nil, nil
}
rx := make([]*roaring64.Bitmap, len(addrs))
defer func() {
for _, bm := range rx {
bitmapdb.ReturnToPool64(bm)
}
}()
for idx, addr := range addrs {
it, err := tx.IndexRange(temporal.LogAddrIdx, addr[:], from, to, true, -1)
if err != nil {
return nil, err
}
rx[idx], err = it.(bitmapdb.ToBitmap).ToBitmap()
if err != nil {
return nil, err
}
}
return roaring64.FastOr(rx...), nil
}
*/

// GetTransactionReceipt implements eth_getTransactionReceipt. Returns the receipt of a transaction given the transaction's hash.
func (api *APIImpl) GetTransactionReceipt(ctx context.Context, txnHash common.Hash) (map[string]interface{}, error) {
tx, err := api.db.BeginRo(ctx)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/otterscan_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (api *OtterscanAPIImpl) searchTransactionsBeforeV3(tx kv.TemporalTx, ctx co
if err != nil {
return nil, err
}
txNums := iter.Union[uint64](itFrom, itTo, order.Desc)
txNums := iter.Union[uint64](itFrom, itTo, order.Desc, -1)
txNumsIter := MapDescendTxNum2BlockNum(tx, txNums)

exec := txnExecutor(tx, chainConfig, api.engine(), api._blockReader, nil)
Expand Down
8 changes: 4 additions & 4 deletions cmd/rpcdaemon/commands/trace_filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func traceFilterBitmapsV3(tx kv.TemporalTx, req TraceFilterRequest, from, to uin
if errors.Is(err, ethdb.ErrKeyNotFound) {
continue
}
allBlocks = iter.Union[uint64](allBlocks, it, order.Asc)
allBlocks = iter.Union[uint64](allBlocks, it, order.Asc, -1)
fromAddresses[*addr] = struct{}{}
}
}
Expand All @@ -305,18 +305,18 @@ func traceFilterBitmapsV3(tx kv.TemporalTx, req TraceFilterRequest, from, to uin
if errors.Is(err, ethdb.ErrKeyNotFound) {
continue
}
blocksTo = iter.Union[uint64](blocksTo, it, order.Asc)
blocksTo = iter.Union[uint64](blocksTo, it, order.Asc, -1)
toAddresses[*addr] = struct{}{}
}
}

switch req.Mode {
case TraceFilterModeIntersection:
allBlocks = iter.Intersect[uint64](allBlocks, blocksTo)
allBlocks = iter.Intersect[uint64](allBlocks, blocksTo, -1)
case TraceFilterModeUnion:
fallthrough
default:
allBlocks = iter.Union[uint64](allBlocks, blocksTo, order.Asc)
allBlocks = iter.Union[uint64](allBlocks, blocksTo, order.Asc, -1)
}

// Special case - if no addresses specified, take all traces
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.18

require (
github.com/ledgerwatch/erigon-lib v0.0.0-20230322051001-ef07abc3e379
github.com/ledgerwatch/erigon-lib v0.0.0-20230322063357-c394d9bb48a7
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3
github.com/ledgerwatch/log/v3 v3.7.0
github.com/ledgerwatch/secp256k1 v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20230322051001-ef07abc3e379 h1:DVA8+IrSvyGkBlTWZitT0bOEFLlwlbsIuIQsluzjWIg=
github.com/ledgerwatch/erigon-lib v0.0.0-20230322051001-ef07abc3e379/go.mod h1:I+1Oys00tH9C8Ow1u5atjh3XasMPE4VoAG5lq8Bi1Zs=
github.com/ledgerwatch/erigon-lib v0.0.0-20230322063357-c394d9bb48a7 h1:Sj0xGrrw9uNPjkdbBMYR2tc9hBBsjtnzmGWv9AadNAc=
github.com/ledgerwatch/erigon-lib v0.0.0-20230322063357-c394d9bb48a7/go.mod h1:I+1Oys00tH9C8Ow1u5atjh3XasMPE4VoAG5lq8Bi1Zs=
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3 h1:tfzawK1gIIgRjVZeANXOr0Ziu+kqCIBuKMe0TXfl5Aw=
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.7.0 h1:aFPEZdwZx4jzA3+/Pf8wNDN5tCI0cIolq/kfvgcM+og=
Expand Down