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

fix: market: Reuse the market PubSub in index provider #8443

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

masih
Copy link
Member

@masih masih commented Apr 6, 2022

Related Issues

N/A

Proposed Changes

  • The markets process instantiates its own PubSub instance with all validators, peer scoring, etc. set up. Use that instance to join the indexing topic, otherwise the default topic instantiated by index-provider internally (via go-legs) has no validators.

  • Fixes the construction of PubSub via dependency injection mechanism in markets by binding its dependencies: bootstrap peers, drand related config.

Looks like DI for PubSub in markets is broken since it seems it was never used in markets before; waiting for confirmation that we indeed want validators for the gossipsub used by provider engine before spending time on fixing it.

Additional Info

N/A

Checklist

Before you mark the PR ready for review, please make sure that:

  • All commits have a clear commit message.
  • The PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, test
    • area: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps
  • This PR has tests for new functionality or change in behaviour
  • If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io or Discussion Tutorials.
  • CI is green

@masih masih requested a review from a team as a code owner April 6, 2022 12:54
@masih masih requested review from magik6k, vyzo and willscott April 6, 2022 12:54
node/modules/storageminer_idxprov.go Outdated Show resolved Hide resolved
Comment on lines +47 to +50
// Join the indexer topic using the market's pubsub instance. Otherwise, the provider
// engine would create its own instance of pubsub down the line in go-legs, which has
// no validators by default.
t, err := ps.Join(cfg.TopicName)
Copy link
Contributor

Choose a reason for hiding this comment

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

why should the market process be subscribed to the topic? it shouldn't be receiving or interested in any messages on this topic - it only produced the messages and we don't want it to relay or receive them.

Copy link
Member Author

@masih masih Apr 6, 2022

Choose a reason for hiding this comment

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

To publish we also need a topic instance; at least go-legs publisher needs it. Is there a way to publish to a topic without joining it?

Also, the changes here are equivelant to what legs publisher does internally if topic is not set.

Subscribing to a topic (i.e. t.Subscribe) is another explicit call. .Join does not mean subscription I don't think.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, you can publish without subscribing.

Copy link
Contributor

@vyzo vyzo Apr 6, 2022

Choose a reason for hiding this comment

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

but we normally do it by calling publish directly, without a topic.

Copy link
Contributor

Choose a reason for hiding this comment

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

and thats totally ok, getting the topic to publish is the caconical way since topic handles were added.

@masih masih changed the title fix: market: Reuse the market process PubSub instance in index provider engine fix: market: Reuse the market PubSub instance in index provider and set remaining config Apr 6, 2022
@masih masih changed the title fix: market: Reuse the market PubSub instance in index provider and set remaining config fix: market: Reuse the market PubSub in index provider and set all options Apr 6, 2022
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

this looks fine to me, but i am not versed in the details to give a meaningful approval.

@willscott
Copy link
Contributor

I think this will change markets to use the standard pubsub setup / validator, while it currently only has the one built in within legs.
This may mean pubsub messages begin to pass through the markets process, which I'm not sure we want

@masih masih force-pushed the masih/idxprov-reuse-pubsub branch from 82351d8 to cc2f805 Compare April 6, 2022 15:15
@masih masih changed the title fix: market: Reuse the market PubSub in index provider and set all options fix: market: Reuse the market PubSub in index provider Apr 6, 2022
Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Should be better

Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Actually this makes tests really unhappy:

    ensemble.go:647: 
        	Error Trace:	ensemble.go:647
        	            				ensemble_presets.go:22
        	            				deals_512mb_test.go:29
        	Error:      	Received unexpected error:
        	            	starting node:
        	            	    github.com/filecoin-project/lotus/node.New
        	            	        /home/circleci/project/node/builder.go:373
        	            	  - could not build arguments for function "github.com/filecoin-project/lotus/node/modules".HandleDeals
        	            	    	/home/circleci/project/node/modules/storageminer.go:305:
        	            	    failed to build storagemarket.StorageProvider:
        	            	    could not build arguments for function "reflect".makeFuncStub
        	            	    	/usr/local/go/src/reflect/asm_amd64.s:14:
        	            	    failed to build provider.Interface:
        	            	    could not build arguments for function "reflect".makeFuncStub
        	            	    	/usr/local/go/src/reflect/asm_amd64.s:14:
        	            	    failed to build *pubsub.PubSub:
        	            	    missing dependencies for function "reflect".makeFuncStub
        	            	    	/usr/local/go/src/reflect/asm_amd64.s:14:
        	            	    missing types:
        	            	    	- dtypes.BootstrapPeers (did you mean to Provide it?)
        	            	    	- dtypes.DrandBootstrap (did you mean to Provide it?)
        	            	    	- dtypes.DrandSchedule (did you mean to Provide it?)

It would seem that markets don't have a pubsub instance by default, so it should be constructed in the indexer (and maybe there's a bug where it's constructed there multiple times?).

@masih
Copy link
Member Author

masih commented Apr 6, 2022

It would seem that markets don't have a pubsub instance by default, so it should be constructed in the indexer (and maybe there's a bug where it's constructed there multiple times?).

The DI for PubSub in markets is broken: it is there but never actually instantiated because before this PR nothing in markets injected it.

The issue is that DI for PubSub in markets uses the same functionality as daemon injection to construct PubSub, which needs bootstrap-specific setting that don't make sense in markets?

@magik6k
Copy link
Contributor

magik6k commented Apr 6, 2022

it is there but never actually instantiated because before this PR nothing in markets injected it.

Which is expected, and that should mean that it's fine to just use create pubsub in go-legs (but it also seems like we somehow have multiple pubsub instances somehow?)

masih added 2 commits April 6, 2022 19:39
The markets process instantiates its own `PubSub` instance with all
validators, peer scoring, etc. set up. Use that instane to join the
indexing topic, otherwise the default topic instantiated by
index-provider internally (via go-legs) has no validators.
Bind drand and bootstrap peers config so that `PubSub` instantiated by
`ConfigCommon` has all the dependencies it needs when `PubSub` instance
is needed in markets. In ths case, the instance is needed by the index
provider engine to announce new indexing advertisements.
@masih masih force-pushed the masih/idxprov-reuse-pubsub branch from cc2f805 to f369d99 Compare April 6, 2022 19:04
@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #8443 (f369d99) into master (f378c6d) will increase coverage by 6.03%.
The diff coverage is 58.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8443      +/-   ##
==========================================
+ Coverage   34.56%   40.60%   +6.03%     
==========================================
  Files         681      686       +5     
  Lines       75174    75415     +241     
==========================================
+ Hits        25984    30619    +4635     
+ Misses      44340    39483    -4857     
- Partials     4850     5313     +463     
Impacted Files Coverage Δ
node/modules/storageminer_idxprov.go 58.69% <50.00%> (-2.42%) ⬇️
node/builder_miner.go 95.17% <100.00%> (+0.10%) ⬆️
chain/events/message_cache.go 87.50% <0.00%> (-12.50%) ⬇️
itests/kit/blockminer.go 70.10% <0.00%> (-0.55%) ⬇️
miner/miner.go 57.04% <0.00%> (-0.33%) ⬇️
chain/types/blockheader.go 55.55% <0.00%> (ø)
journal/mockjournal/journal.go 71.42% <0.00%> (ø)
markets/dagstore/mocks/mock_lotus_accessor.go 80.48% <0.00%> (ø)
chain/actors/builtin/paych/mock/mock.go 71.42% <0.00%> (ø)
chain/vectors/gen/main.go 2.36% <0.00%> (ø)
... and 160 more

Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Looks like this should work

@magik6k magik6k merged commit 9f98d0a into master Apr 6, 2022
@magik6k magik6k deleted the masih/idxprov-reuse-pubsub branch April 6, 2022 21:51
jennijuju added a commit that referenced this pull request Apr 7, 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.

4 participants