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

[Indexer] Add index storage interfaces and base in-memory implementation #34

Merged
merged 80 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
644089d
add first index storage interface draft
Jan 25, 2024
1d27c05
update index interface
Jan 25, 2024
a5e783c
update interfaces
Jan 29, 2024
af39518
add bloom methods
Jan 29, 2024
ad74e37
update range bloom api
Jan 29, 2024
e9b5c71
update bloom type
Jan 29, 2024
4c74da8
update index methods
Jan 29, 2024
8cbed54
add errors
Jan 29, 2024
9db7532
add errors
Jan 29, 2024
f56e984
fix typo
Jan 29, 2024
cc510c1
add locks
Jan 29, 2024
373e142
add basic test suite
Jan 29, 2024
d3cdbf7
add block mock
Jan 29, 2024
838b74c
mod tidy
Jan 29, 2024
d2aec38
add base block test suite
Jan 29, 2024
a90373c
update deps
Jan 29, 2024
05c6c5c
comment expected behaviour of indexers
Jan 29, 2024
b96979a
add new error
Jan 29, 2024
1643ac5
add more test suite
Jan 29, 2024
6848596
add mocks for block
Jan 29, 2024
4d4610d
update behaviour
Jan 29, 2024
93aca83
update tests
Jan 29, 2024
a0f2d57
update receipt type
Jan 29, 2024
752b8d3
add receipt test suite
Jan 29, 2024
c3ceb8e
add receipt mock
Jan 29, 2024
80f34d7
add transaction test suite
Jan 29, 2024
00734c5
add tx mock
Jan 29, 2024
cbfb2fa
fix storage bug
Jan 29, 2024
3b0cd01
update range type
Jan 29, 2024
b53a816
fix tests
Jan 29, 2024
2175eec
fix tests
Jan 29, 2024
77130e5
fix tests
Jan 29, 2024
54e8bae
fix tests
Jan 29, 2024
fa25954
update deps
Jan 30, 2024
ff16811
change receipt getter to block height
Jan 30, 2024
2105329
update change in receipt indexer api
Jan 30, 2024
e19e278
update tests
Jan 30, 2024
032a58b
fix typo
Jan 30, 2024
ec2fa84
fix storage type
Jan 30, 2024
4a6c9fe
define provider interface
Jan 30, 2024
b2d7ec6
add storage and stream provider dummy code
Jan 30, 2024
39d11d5
add get storage naive impl
Jan 30, 2024
eb263e1
update comment
Jan 30, 2024
c1ea686
change bloom to return map of heights
Jan 30, 2024
cc4358c
update provider
Jan 30, 2024
824bd84
change bloom slice type
Jan 30, 2024
da7eb8c
update storage provider to enable block id search
Jan 30, 2024
e66a0c6
add wip filter impl
Jan 30, 2024
44b2e1b
change provider log chan type
Jan 30, 2024
b58ac15
add filter match
Jan 30, 2024
6455a00
add todo
Jan 30, 2024
9c3e7e1
implement filters
Jan 31, 2024
ffcf6cf
delete providers
Jan 31, 2024
deea612
add generate for storage mocks
Jan 31, 2024
07abe91
add generated mocks
Jan 31, 2024
c09f2a3
add mockery
Jan 31, 2024
2b4a1a7
add mocks and single ID test
Jan 31, 2024
bd96346
add more table tests
Jan 31, 2024
c7d4aa7
added id tests
Jan 31, 2024
d0729de
add bloom mocks
Jan 31, 2024
12347bd
change bloom getter to return bloom and heights as two slices
Jan 31, 2024
a51ad7c
update tests with bloom api change
Jan 31, 2024
872bcc9
update filters with bloom change
Jan 31, 2024
58a2649
add block type and decoder
Feb 1, 2024
963d3f3
add block decode test
Feb 1, 2024
18c98ff
add transaction and receipt decoders
Feb 1, 2024
6b74bcd
fix block decoding
Feb 1, 2024
315183b
adding transaction tests
Feb 1, 2024
6abf5ed
fix tx decoder
Feb 2, 2024
7ad0c75
add test for decoder
Feb 2, 2024
9ed0a0d
Merge pull request #36 from onflow/gregor/index/indexer-dec
franklywatson Feb 5, 2024
5a272bb
Revert "[Indexer] Decoding of event values"
sideninja Feb 6, 2024
f1ab42b
Merge pull request #40 from onflow/revert-36-gregor/index/indexer-dec
sideninja Feb 27, 2024
26113d1
Revert "[Indexer] Decoding of event values"
sideninja Feb 27, 2024
58b9ca1
Merge pull request #86 from onflow/revert-40-revert-36-gregor/index/i…
sideninja Feb 27, 2024
82fd232
update start end range
Feb 27, 2024
54bb7db
only receiver
Feb 27, 2024
1f57041
only receiver
Feb 27, 2024
500cb9f
Merge pull request #33 from onflow/gregor/index/storage-filter
sideninja Feb 27, 2024
bca3c6a
Merge branch 'main' into gregor/index/storage-index
sideninja Feb 27, 2024
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
72 changes: 50 additions & 22 deletions services/logs/filter_test.go
Original file line number Diff line number Diff line change
@@ -32,15 +32,15 @@ var receipts = []*gethTypes.Receipt{
Logs: []*gethTypes.Log{
{
Address: common.BytesToAddress([]byte{0x22}),
Topics: []common.Hash{common.HexToHash("alfa"), common.HexToHash("bravo")},
Topics: []common.Hash{common.HexToHash("aa"), common.HexToHash("bb")},
},
{
Address: common.BytesToAddress([]byte{0x22}),
Topics: []common.Hash{common.HexToHash("charlie"), common.HexToHash("delta")},
Topics: []common.Hash{common.HexToHash("cc"), common.HexToHash("dd")},
},
{
Address: common.BytesToAddress([]byte{0x33}),
Topics: []common.Hash{common.HexToHash("echo"), common.HexToHash("foxtrot")},
Topics: []common.Hash{common.HexToHash("ee"), common.HexToHash("ff")},
},
},
}, {
@@ -49,11 +49,11 @@ var receipts = []*gethTypes.Receipt{
Logs: []*gethTypes.Log{
{
Address: common.BytesToAddress([]byte{0x22}),
Topics: []common.Hash{common.HexToHash("charlie"), common.HexToHash("hotel")},
Topics: []common.Hash{common.HexToHash("cc"), common.HexToHash("11")},
},
{
Address: common.BytesToAddress([]byte{0x55}),
Topics: []common.Hash{common.HexToHash("alfa"), common.HexToHash("hotel")},
Topics: []common.Hash{common.HexToHash("aa"), common.HexToHash("11")},
},
},
}, {
@@ -66,11 +66,11 @@ var receipts = []*gethTypes.Receipt{
Logs: []*gethTypes.Log{
{
Address: common.BytesToAddress([]byte{0x66}),
Topics: []common.Hash{common.HexToHash("alfa"), common.HexToHash("bravo"), common.HexToHash("india")},
Topics: []common.Hash{common.HexToHash("aa"), common.HexToHash("bb"), common.HexToHash("22")},
},
{
Address: common.BytesToAddress([]byte{0x22}),
Topics: []common.Hash{common.HexToHash("alfa")},
Topics: []common.Hash{common.HexToHash("aa")},
},
},
}, {
@@ -79,7 +79,7 @@ var receipts = []*gethTypes.Receipt{
Logs: []*gethTypes.Log{
{
Address: common.BytesToAddress([]byte{0x88}),
Topics: []common.Hash{common.HexToHash("juliet"), common.HexToHash("kilo"), common.HexToHash("lima")},
Topics: []common.Hash{common.HexToHash("33"), common.HexToHash("44"), common.HexToHash("55")},
},
},
},
@@ -121,20 +121,48 @@ func TestIDFilter(t *testing.T) {
blockStorage := blockStorage()
receiptStorage := receiptStorage()

t.Run("single topic, single address", func(t *testing.T) {
id, _ := blocks[0].Hash()
log := receipts[0].Logs[0]
criteria := FilterCriteria{
Addresses: []common.Address{log.Address},
Topics: [][]common.Hash{{log.Topics[0]}},
}
filter := NewIDFilter(id, criteria, blockStorage, receiptStorage)
logs, err := filter.Match()

require.NoError(t, err)
require.Len(t, logs, 1)
require.Equal(t, logs[0], log)
})
// both topics no address
// only address
// multiple addresses

tests := []struct {
desc string
id common.Hash
expectLogs []*gethTypes.Log
criteria FilterCriteria
}{{
desc: "single topic, single address match single log",
id: mustHash(blocks[0]),
criteria: FilterCriteria{
Addresses: []common.Address{receipts[0].Logs[0].Address},
Topics: [][]common.Hash{{receipts[0].Logs[0].Topics[0]}},
},
expectLogs: []*gethTypes.Log{receipts[0].Logs[0]},
}, {
desc: "single topic match single log",
id: mustHash(blocks[0]),
criteria: FilterCriteria{
Topics: [][]common.Hash{{receipts[0].Logs[0].Topics[0]}},
},
expectLogs: []*gethTypes.Log{receipts[0].Logs[0]},
}, {
desc: "invalid topic match no logs",
id: mustHash(blocks[0]),
criteria: FilterCriteria{
Topics: [][]common.Hash{{common.HexToHash("123")}},
},
expectLogs: []*gethTypes.Log{},
}}

for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
filter := NewIDFilter(tt.id, tt.criteria, blockStorage, receiptStorage)
logs, err := filter.Match()

require.NoError(t, err)
require.Equal(t, tt.expectLogs, logs)
})
}
}

func TestRangeFilter(t *testing.T) {