filecoin-project / venus

Filecoin Full Node Implementation in Go
https://venus.filecoin.io
Other
2.06k stars 462 forks source link

Make Node init and config consistent and easier throughout testing #1502

Closed shannonwells closed 5 years ago

shannonwells commented 5 years ago

Description

There are a bunch of Node construction helpers which take anywhere from one to 5 params. Two of these params are for offline mode and mock mining, aka alwaysWinningTicket. Offline mode is a Node ConfigOpt, and if any ConfigOpts are passed to some of these helpers and specifically to genNode, the offline flag will override that config.

Proposal is 2 things:

  1. Try to get rid of any flags that override node InitOpts or ConfigOpts; there should be only one way of setting up either one and extra flags may do things surprising to the test writer and result in false positives or negatives in test cases.

  2. Reduce the number of params being passed around to set up a node to two: a text context and A node options struct which takes all the necessary settings to set up a node the way you want. This struct is at minimum node.InitOpts and node.ConfigOpts, but may include other things.

Acceptance criteria

Risks + pitfalls

when investigating this, because we supply a function that sets things like offline mode or addresses, there's currently no way to query what is being set when we pass options to genNode (and hence also to the node instantiator). It means for example it's difficult to know, without the "offlineMode" flag, that the swarm address needs to change from 0.0.0.0 based to 127.0.0.1. It will need some thought.

shannonwells commented 5 years ago

1503 is the right PR for part of this, now merged.