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

Ethereum actor events API fixes #9639

Merged

Conversation

iand
Copy link
Contributor

@iand iand commented Nov 14, 2022

Some fixes from original event api PR (#9623) that was merged earlier.

  • Rename modules.EthEvent function to EthEventAPI
  • Change event emitter type to abi.ActorID
  • Ensure event matching is performed on f4 addresses by converting actor id to f4 at match time

@iand iand requested a review from a team as a code owner November 14, 2022 16:04
@iand iand changed the title Feat/nv18 events prfixes Ethereum actor events API fixes Nov 14, 2022
@iand
Copy link
Contributor Author

iand commented Nov 14, 2022

Fixing a bug in tests, don't merge yet

@iand
Copy link
Contributor Author

iand commented Nov 14, 2022

Fixed the test bug, this is ready for review

Comment on lines 89 to 103
idAddr, err := address.NewIDAddress(uint64(ev.Emitter))
if err != nil {
return xerrors.Errorf("convert emitter to id address: %w", err)
}
addr, err = ra.LookupRobustAddress(ctx, idAddr, te.rctTs)
if err != nil {
return xerrors.Errorf("lookup robust address: %w", err)
}

// if robust address is not f4 then we won't match against it so bail early
if addr.Protocol() != address.Delegated {
continue
}

addressLookups[ev.Emitter] = addr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the logic in this component should stay agnostic of addressing assumptions. After all, this is a general facility to stream matching events. How about we move the matching logic to the filter, making the user supply a func(emitter actor.ID, want address.Address) (bool, error) at origin? I'm afraid that only the upstream component will know how to perform a match that's semantically valid for its use case.

@@ -51,6 +52,7 @@ func EthEvent(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecycle
if cfg.EnableRealTimeFilterAPI {
ee.EventFilterManager = &filter.EventFilterManager{
ChainStore: cs,
RobustAddresser: sm,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to a predicate as per above; that way we keep the f4 assumption away from the deeper event subscription facilities.

@iand
Copy link
Contributor Author

iand commented Nov 15, 2022

@raulk PTAL

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this simpler/cleaner than having a predicate? I'm happy either way, but would love to know the reasoning.

@@ -50,7 +53,25 @@ func EthEvent(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecycle

if cfg.EnableRealTimeFilterAPI {
ee.EventFilterManager = &filter.EventFilterManager{
ChainStore: cs,
ChainStore: cs,
AddressResolver: func(ctx context.Context, emitter abi.ActorID, ts *types.TipSet) (address.Address, bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep a TODO somewhere that we expect to focus optimization efforts here.

}

// if robust address is not f4 then we won't match against it so bail early
if addr.Protocol() != address.Delegated {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to check that the namespace of the delegated address is the EAM.

@raulk raulk merged commit 273ac51 into filecoin-project:feat/nv18-events Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants