Skip to content

Commit 5251de7

Browse files
committed
address comments
1 parent c98ca60 commit 5251de7

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# UNRELEASED
44

5+
- Event APIs (`GetActorEventsRaw`, `SubscribeActorEventsRaw`, `eth_getLogs`, `eth_newFilter`, etc.) will now return an error when a request matches more than `MaxFilterResults` (default: 10,000) rather than silently truncating the results. Also apply an internal event matcher for `eth_getLogs` (etc.) to avoid builtin actor events on database query so as not to include them in `MaxFilterResults` calculation. ([filecoin-project/lotus#12671](https://github.com/filecoin-project/lotus/pull/12671))
6+
57
# UNRELEASED v1.31.0
68

79
See https://github.com/filecoin-project/lotus/blob/release/v1.31.0/CHANGELOG.md

chain/index/events.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/filecoin-project/lotus/chain/types"
2323
)
2424

25-
var ErrMaxResultsReached = xerrors.New("max results limit reached, results truncated")
25+
var ErrMaxResultsReached = fmt.Errorf("filter matches too many events, try a more restricted filter")
2626

2727
const maxLookBackForWait = 120 // one hour of tipsets
2828

chain/index/events_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ func TestGetEventsForFilterWithRawCodec(t *testing.T) {
404404

405405
// Define codec constants (replace with actual multicodec values)
406406
var (
407-
codecRaw = uint64(multicodec.Raw)
408-
codecCBOR = uint64(multicodec.Cbor)
407+
codecRaw = multicodec.Raw
408+
codecCBOR = multicodec.Cbor
409409
)
410410

411411
// Create events with different codecs
@@ -528,8 +528,8 @@ func TestMaxFilterResults(t *testing.T) {
528528

529529
// Define codec constants (replace with actual multicodec values)
530530
var (
531-
codecRaw = uint64(multicodec.Raw)
532-
codecCBOR = uint64(multicodec.Cbor)
531+
codecRaw = multicodec.Raw
532+
codecCBOR = multicodec.Cbor
533533
)
534534

535535
// Create events with different codecs
@@ -687,7 +687,7 @@ func fakeEvent(emitter abi.ActorID, indexed []kv, unindexed []kv) *types.Event {
687687
return ev
688688
}
689689

690-
func fakeEventWithCodec(emitter abi.ActorID, indexed []kv, codec uint64) *types.Event {
690+
func fakeEventWithCodec(emitter abi.ActorID, indexed []kv, codec multicodec.Code) *types.Event {
691691
ev := &types.Event{
692692
Emitter: emitter,
693693
}
@@ -696,7 +696,7 @@ func fakeEventWithCodec(emitter abi.ActorID, indexed []kv, codec uint64) *types.
696696
ev.Entries = append(ev.Entries, types.EventEntry{
697697
Flags: 0x01,
698698
Key: in.k,
699-
Codec: codec,
699+
Codec: uint64(codec),
700700
Value: in.v,
701701
})
702702
}

chain/index/interface.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66

77
"github.com/ipfs/go-cid"
8+
"github.com/multiformats/go-multicodec"
89

910
"github.com/filecoin-project/go-address"
1011
"github.com/filecoin-project/go-state-types/abi"
@@ -48,7 +49,7 @@ type EventFilter struct {
4849
KeysWithCodec map[string][]types.ActorEventBlock // map of key names to a list of alternate values that may match
4950
MaxResults int // maximum number of results to collect, 0 is unlimited
5051

51-
Codec uint64 // optional codec filter, only used if KeysWithCodec is not set
52+
Codec multicodec.Code // optional codec filter, only used if KeysWithCodec is not set
5253
}
5354

5455
type Indexer interface {

node/impl/full/eth.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -1775,19 +1775,13 @@ func (e *EthEventHandler) ethGetEventsForFilter(ctx context.Context, filterSpec
17751775
return nil, xerrors.New("cannot ask for events for a tipset at or greater than head")
17761776
}
17771777

1778-
var codec uint64
1779-
// if no keys are specified, we can use the codec filter to make sure we only get `raw` encoded events
1780-
if len(pf.keys) == 0 {
1781-
codec = uint64(multicodec.Raw)
1782-
}
1783-
17841778
ef := &index.EventFilter{
17851779
MinHeight: pf.minHeight,
17861780
MaxHeight: pf.maxHeight,
17871781
TipsetCid: pf.tipsetCid,
17881782
Addresses: pf.addresses,
17891783
KeysWithCodec: pf.keys,
1790-
Codec: codec,
1784+
Codec: multicodec.Raw,
17911785
MaxResults: e.EventFilterManager.MaxFilterResults,
17921786
}
17931787

0 commit comments

Comments
 (0)