Skip to content

Commit

Permalink
Merge pull request #6353 from filecoin-project/fix/sync-in-progress-e…
Browse files Browse the repository at this point in the history
…vents

fix(events): check for sync-in-progress
  • Loading branch information
simlecode authored Jun 13, 2024
2 parents cb12a73 + df9cf88 commit f390c95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/submodule/eth/eth_event_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var _ v1.IETHEvent = (*ethEventAPI)(nil)

func newEthEventAPI(ctx context.Context, em *EthSubModule) (*ethEventAPI, error) {
chainAPI := em.chainModule.API()
bsstore := em.chainModule.ChainReader.Blockstore()
cfg := em.cfg.FevmConfig
ee := &ethEventAPI{
em: em,
Expand Down Expand Up @@ -70,7 +69,7 @@ func newEthEventAPI(ctx context.Context, em *EthSubModule) (*ethEventAPI, error)

ee.EventFilterManager = &filter.EventFilterManager{
MessageStore: ee.em.chainModule.MessageStore,
ChainStore: bsstore,
ChainStore: ee.em.chainModule.ChainReader,
EventIndex: eventIndex, // will be nil unless EnableHistoricFilterAPI is true
AddressResolver: func(ctx context.Context, emitter abi.ActorID, ts *types.TipSet) (address.Address, bool) {
// we only want to match using f4 addresses
Expand Down
9 changes: 6 additions & 3 deletions pkg/events/filter/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
blockadt "github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/venus/pkg/chain"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/blockstore"
"github.com/filecoin-project/venus/venus-shared/types"
cbor "github.com/ipfs/go-ipld-cbor"
)
Expand Down Expand Up @@ -303,7 +302,7 @@ func (e *executedMessage) Events() []*types.Event {

type EventFilterManager struct {
MessageStore *chain.MessageStore
ChainStore blockstore.Blockstore
ChainStore *chain.Store
AddressResolver func(ctx context.Context, emitter abi.ActorID, ts *types.TipSet) (address.Address, bool)
MaxFilterResults int
EventIndex *EventIndex
Expand Down Expand Up @@ -378,6 +377,10 @@ func (m *EventFilterManager) Revert(ctx context.Context, from, to *types.TipSet)
func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight abi.ChainEpoch, tipsetCid cid.Cid, addresses []address.Address,
keysWithCodec map[string][]types.ActorEventBlock, excludeReverted bool) (EventFilter, error) {
m.mu.Lock()
if m.currentHeight == 0 {
// sync in progress, we haven't had an Apply
m.currentHeight = m.ChainStore.GetHead().Height()
}
currentHeight := m.currentHeight
m.mu.Unlock()

Expand Down Expand Up @@ -433,7 +436,7 @@ func (m *EventFilterManager) loadExecutedMessages(ctx context.Context, msgTS, rc
return nil, xerrors.Errorf("read messages: %w", err)
}

st := adt.WrapStore(ctx, cbor.NewCborStore(m.ChainStore))
st := adt.WrapStore(ctx, cbor.NewCborStore(m.ChainStore.Blockstore()))

arr, err := blockadt.AsArray(st, rctTS.Blocks()[0].ParentMessageReceipts)
if err != nil {
Expand Down

0 comments on commit f390c95

Please sign in to comment.