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

feat: ethereum filters over indexed events #9646

Merged
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6f51ec2
update builtin-actors v10 bundle to http://filecoin-project/builtin-a…
raulk Nov 15, 2022
5249a35
update ffi to filecoin-project/filecoin-ffi#332.
raulk Nov 15, 2022
476a933
fix Event schema + cbor-gen.
raulk Nov 15, 2022
7cc2c5c
fix types in Eth API.
raulk Nov 15, 2022
f434133
cli: evm/invoke-evm-actor: print events.
raulk Nov 15, 2022
28ec43c
Merge branch 'feat/nv18-events' into raulk/events-integrate-fvm
raulk Nov 15, 2022
43e2a2b
fix merge error.
raulk Nov 15, 2022
f22762d
create EVM utilities in itest framework.
raulk Nov 15, 2022
4313917
Merge branch 'feat/nv18-fevm' into raulk/events-integrate-fvm
raulk Nov 15, 2022
907c201
add a FEVM events itest.
raulk Nov 15, 2022
0e8dd9e
Add historic event indexing
iand Nov 14, 2022
0d9c474
Implement EthGetLogs
iand Nov 15, 2022
32839f6
Initialise event index in di
iand Nov 15, 2022
bf1fcf8
Check actor event database schema version
iand Nov 15, 2022
e2ddc97
Fix lint error
iand Nov 15, 2022
73655ed
Fix for event entry key type is now a string
iand Nov 15, 2022
48ea469
go mod tidy
iand Nov 15, 2022
c31662d
make gen
iand Nov 15, 2022
ade75af
Update filecoin-ffi to https://github.com/filecoin-project/filecoin-f…
iand Nov 15, 2022
1035711
Add basic itests for ethereum filter api
iand Nov 15, 2022
7ef9973
make gen
iand Nov 15, 2022
98210ec
Add lint directive
iand Nov 15, 2022
bcdfc17
Fix TestEthNewFilterCatchAll
iand Nov 15, 2022
2803552
Merge branch 'feat/nv18-events' into feat/nv18-events-historic
raulk Nov 16, 2022
0376b7b
More assertions in TestEthNewFilterCatchAll
iand Nov 16, 2022
b5f95b7
Fix invalid address flake in TestEthNewFilterCatchAll
iand Nov 16, 2022
d5177a3
Add TestEthGetLogsAll itest
iand Nov 16, 2022
41bf2a0
Load actor to resolve address
iand Nov 16, 2022
8134d2f
Parse block heights as hex
iand Nov 16, 2022
314fb31
Fix signature of EthSubscribe
iand Nov 16, 2022
5a1f8d8
Return eth blocks not tipsets in subscriptions
iand Nov 16, 2022
7c2dcc8
Eth JSON-RPC API: add aliases for new methods.
raulk Nov 16, 2022
32385a9
Eth JSON-RPC API: return logs in eth_getTransactionReceipt.
raulk Nov 16, 2022
1ab39a4
simplify by moving receipt constructor logic to API.
raulk Nov 16, 2022
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
15 changes: 10 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,6 @@ workflows:
- gofmt
- gen-check
- docs-check
- test:
name: test-itest-actor_events
suite: itest-actor_events
target: "./itests/actor_events_test.go"

- test:
name: test-itest-api
suite: itest-api
Expand Down Expand Up @@ -916,6 +911,16 @@ workflows:
suite: itest-dup_mpool_messages
target: "./itests/dup_mpool_messages_test.go"

- test:
name: test-itest-eth_filter
suite: itest-eth_filter
target: "./itests/eth_filter_test.go"

- test:
name: test-itest-fevm_events
suite: itest-fevm_events
target: "./itests/fevm_events_test.go"

- test:
name: test-itest-fevm
suite: itest-fevm
Expand Down
32 changes: 15 additions & 17 deletions api/eth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ type EthFilterSpec struct {
type EthAddressList []EthAddress

func (e *EthAddressList) UnmarshalJSON(b []byte) error {
if bytes.Equal(b, []byte{'n', 'u', 'l', 'l'}) {
return nil
}
if len(b) > 0 && b[0] == '[' {
var addrs []EthAddress
err := json.Unmarshal(b, &addrs)
Expand Down Expand Up @@ -542,34 +545,29 @@ func (e *EthHashList) UnmarshalJSON(b []byte) error {
return nil
}

// FilterResult represents the response from executing a filter: a list of bloack hashes, a list of transaction hashes
// FilterResult represents the response from executing a filter: a list of block hashes, a list of transaction hashes
// or a list of logs
// This is a union type. Only one field will be populated.
// The JSON encoding must produce an array of the populated field.
type EthFilterResult struct {
// List of block hashes. Only populated when the filter has been installed via EthNewBlockFilter
NewBlockHashes []EthHash

// List of transaction hashes. Only populated when the filter has been installed via EthNewPendingTransactionFilter
NewTransactionHashes []EthHash

// List of event logs. Only populated when the filter has been installed via EthNewFilter
NewLogs []EthLog
Results []interface{}
}

func (h EthFilterResult) MarshalJSON() ([]byte, error) {
if h.NewBlockHashes != nil {
return json.Marshal(h.NewBlockHashes)
}
if h.NewTransactionHashes != nil {
return json.Marshal(h.NewTransactionHashes)
}
if h.NewLogs != nil {
return json.Marshal(h.NewLogs)
if h.Results != nil {
return json.Marshal(h.Results)
}
return []byte{'[', ']'}, nil
}

func (h *EthFilterResult) UnmarshalJSON(b []byte) error {
if bytes.Equal(b, []byte{'n', 'u', 'l', 'l'}) {
return nil
}
err := json.Unmarshal(b, &h.Results)
return err
}

// EthLog represents the results of an event filter execution.
type EthLog struct {
// Address is the address of the actor that produced the event log.
Expand Down
34 changes: 24 additions & 10 deletions api/eth_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,33 @@ func TestEthFilterResultMarshalJSON(t *testing.T) {

{
res: EthFilterResult{
NewBlockHashes: []EthHash{hash1, hash2},
Results: []any{hash1, hash2},
},
want: `["0x013dbb9442ca9667baccc6230fcd5c1c4b2d4d2870f4bd20681d4d47cfd15184","0xab8653edf9f51785664a643b47605a7ba3d917b5339a0724e7642c114d0e4738"]`,
},

{
res: EthFilterResult{
NewTransactionHashes: []EthHash{hash1, hash2},
Results: []any{hash1, hash2},
},
want: `["0x013dbb9442ca9667baccc6230fcd5c1c4b2d4d2870f4bd20681d4d47cfd15184","0xab8653edf9f51785664a643b47605a7ba3d917b5339a0724e7642c114d0e4738"]`,
},

{
res: EthFilterResult{
NewLogs: []EthLog{log},
Results: []any{log},
},
want: `[` + string(logjson) + `]`,
},
}

for _, tc := range testcases {
data, err := json.Marshal(tc.res)
require.NoError(t, err)
require.Equal(t, tc.want, string(data))
tc := tc
t.Run("", func(t *testing.T) {
data, err := json.Marshal(tc.res)
require.NoError(t, err)
require.Equal(t, tc.want, string(data))
})
}
}

Expand Down Expand Up @@ -325,12 +328,23 @@ func TestEthAddressListUnmarshalJSON(t *testing.T) {
input: `"0xd4c5fb16488Aa48081296299d54b0c648C9333dA"`,
want: EthAddressList{addr1},
},
{
input: `[]`,
want: EthAddressList{},
},
{
input: `null`,
want: EthAddressList(nil),
},
}
for _, tc := range testcases {
var got EthAddressList
err := json.Unmarshal([]byte(tc.input), &got)
require.NoError(t, err)
require.Equal(t, tc.want, got)
tc := tc
t.Run("", func(t *testing.T) {
var got EthAddressList
err := json.Unmarshal([]byte(tc.input), &got)
require.NoError(t, err)
require.Equal(t, tc.want, got)
})
}
}

Expand Down
Binary file modified build/actors/v10.tar.zst
Binary file not shown.
Loading