Add the ipfs dag api object in Blockstore#356
Conversation
Codecov Report
@@ Coverage Diff @@
## master #356 +/- ##
==========================================
- Coverage 61.81% 61.78% -0.03%
==========================================
Files 262 262
Lines 22920 22920
==========================================
- Hits 14167 14161 -6
+ Misses 7259 7257 -2
- Partials 1494 1502 +8
|
ipfs/mock.go
Outdated
| // DagOnlyMock provides an empty APIProvider that only mocks the DAG portion of | ||
| // the ipfs api object. This is much lighter than the full IPFS node and should | ||
| // be favored for CI testing | ||
| func DagOnlyMock() APIProvider { | ||
| mockAPI := dagOnlyMock{mdutils.Mock()} | ||
| return func() (coreiface.CoreAPI, io.Closer, error) { | ||
| return mockAPI, mockAPI, nil | ||
| } | ||
| } | ||
|
|
||
| var _ coreiface.CoreAPI = dagOnlyMock{} | ||
|
|
||
| type dagOnlyMock struct { | ||
| format.DAGService | ||
| } | ||
|
|
||
| func (dom dagOnlyMock) Dag() coreiface.APIDagService { return dom } | ||
|
|
||
| func (dagOnlyMock) Unixfs() coreiface.UnixfsAPI { return nil } | ||
| func (dagOnlyMock) Block() coreiface.BlockAPI { return nil } | ||
| func (dagOnlyMock) Name() coreiface.NameAPI { return nil } | ||
| func (dagOnlyMock) Key() coreiface.KeyAPI { return nil } | ||
| func (dagOnlyMock) Pin() coreiface.PinAPI { return nil } | ||
| func (dagOnlyMock) Object() coreiface.ObjectAPI { return nil } | ||
| func (dagOnlyMock) Dht() coreiface.DhtAPI { return nil } | ||
| func (dagOnlyMock) Swarm() coreiface.SwarmAPI { return nil } | ||
| func (dagOnlyMock) PubSub() coreiface.PubSubAPI { return nil } | ||
| func (dagOnlyMock) ResolvePath(context.Context, path.Path) (path.Resolved, error) { return nil, nil } | ||
| func (dagOnlyMock) ResolveNode(context.Context, path.Path) (format.Node, error) { return nil, nil } | ||
| func (dagOnlyMock) WithOptions(...options.ApiOption) (coreiface.CoreAPI, error) { return nil, nil } | ||
| func (dagOnlyMock) Close() error { return nil } | ||
| func (dagOnlyMock) Pinning() format.NodeAdder { return nil } |
There was a problem hiding this comment.
I'm not the biggest fan of these nil mocks, but it does give us a lot flexibility in the future by not modifying APIProvider, which returns the full iface.CoreAPI. If we need the full ipfs API for whatever reason, then we can still use the normal Mock. If we don't, then we can use the much lighter dagOnlyMock
There was a problem hiding this comment.
tbc, I'm not attached to this solution, and am very open to other ideas for passing in a dag only mock.
There was a problem hiding this comment.
It's probably better to actually just pass around the DAG / the absolutely necessary API surface in these cases as well (like @Wondertan did in #352) but I think having different mocks for different purposes might still be useful. Especially as unit-tests most likely will rarely really need the whole CoreAPI object.
I'm OK with this. Would like to hear what @Wondertan thinks about this too.
There was a problem hiding this comment.
Agree with @liamsi, we can simply deprecate full core API usage. We won't need anything form it except for the DAG.
There was a problem hiding this comment.
So I don't see any need for dagOnlyMock
There was a problem hiding this comment.
alrighty, the api object has been kicked from the island 1bddff2
node/node_test.go
Outdated
| ipfs.Mock(), | ||
| ipfs.DagOnlyMock(), |
There was a problem hiding this comment.
The full mock node was part of the reason why TestNodeSetPrivValIPC kept failing in the CI (passes locally). TBH, I'm still not 100% sure why, as this test was passing in #352, and the mocked IPFS api obejct was only moved to the blockstore. 🤷♂️
| indexerService *txindex.IndexerService | ||
| prometheusSrv *http.Server | ||
|
|
||
| ipfsAPI ipface.CoreAPI |
There was a problem hiding this comment.
removed this for now, as we weren't using it anywhere. We can easily add it back in if needed.
test-output2.txt
Outdated
| ok github.com/lazyledger/lazyledger-core/types (cached) | ||
| ? github.com/lazyledger/lazyledger-core/types/consts [no test files] | ||
| ok github.com/lazyledger/lazyledger-core/types/time (cached) | ||
| ? github.com/lazyledger/lazyledger-core/version [no test files] |
There was a problem hiding this comment.
This was probably checkedin by accident only?
There was a problem hiding this comment.
whoops. Thanks for catching this! removed c11b9fe
Wondertan
left a comment
There was a problem hiding this comment.
Overall good but my concerns are:
- Encapsulating DAG in the Blockstore
- Keep relying on CoreAPI
store/store.go
Outdated
|
|
||
| // IpfsAPI returns the ipfs api object of the BlockStore. Fullfills the | ||
| // state.BlockStore interface. | ||
| func (bs *BlockStore) IpfsDagAPI() format.DAGService { |
There was a problem hiding this comment.
What about only DAG() or IpfsDAG()? Api seems redundant to me here
Also, the comment does not correspond to the name
There was a problem hiding this comment.
removed the entire method 8a4026c because we were no longer using it after fixing #356 (comment)
store/store.go
Outdated
| "strconv" | ||
|
|
||
| "github.com/gogo/protobuf/proto" | ||
| format "github.com/ipfs/go-ipld-format" |
There was a problem hiding this comment.
Let's use ipld alias for go-ipld-format everywhere. I also did that in the previous PR
There was a problem hiding this comment.
changed here b2469cc
left it as format in the consensus and light packages as they use our own ipld package
There was a problem hiding this comment.
Yep, I am going to propose the rename of ipld package soon. We should change its name as it does not explain what it has inside
ipfs/mock.go
Outdated
| // DagOnlyMock provides an empty APIProvider that only mocks the DAG portion of | ||
| // the ipfs api object. This is much lighter than the full IPFS node and should | ||
| // be favored for CI testing | ||
| func DagOnlyMock() APIProvider { | ||
| mockAPI := dagOnlyMock{mdutils.Mock()} | ||
| return func() (coreiface.CoreAPI, io.Closer, error) { | ||
| return mockAPI, mockAPI, nil | ||
| } | ||
| } | ||
|
|
||
| var _ coreiface.CoreAPI = dagOnlyMock{} | ||
|
|
||
| type dagOnlyMock struct { | ||
| format.DAGService | ||
| } | ||
|
|
||
| func (dom dagOnlyMock) Dag() coreiface.APIDagService { return dom } | ||
|
|
||
| func (dagOnlyMock) Unixfs() coreiface.UnixfsAPI { return nil } | ||
| func (dagOnlyMock) Block() coreiface.BlockAPI { return nil } | ||
| func (dagOnlyMock) Name() coreiface.NameAPI { return nil } | ||
| func (dagOnlyMock) Key() coreiface.KeyAPI { return nil } | ||
| func (dagOnlyMock) Pin() coreiface.PinAPI { return nil } | ||
| func (dagOnlyMock) Object() coreiface.ObjectAPI { return nil } | ||
| func (dagOnlyMock) Dht() coreiface.DhtAPI { return nil } | ||
| func (dagOnlyMock) Swarm() coreiface.SwarmAPI { return nil } | ||
| func (dagOnlyMock) PubSub() coreiface.PubSubAPI { return nil } | ||
| func (dagOnlyMock) ResolvePath(context.Context, path.Path) (path.Resolved, error) { return nil, nil } | ||
| func (dagOnlyMock) ResolveNode(context.Context, path.Path) (format.Node, error) { return nil, nil } | ||
| func (dagOnlyMock) WithOptions(...options.ApiOption) (coreiface.CoreAPI, error) { return nil, nil } | ||
| func (dagOnlyMock) Close() error { return nil } | ||
| func (dagOnlyMock) Pinning() format.NodeAdder { return nil } |
There was a problem hiding this comment.
Agree with @liamsi, we can simply deprecate full core API usage. We won't need anything form it except for the DAG.
ipfs/mock.go
Outdated
| // DagOnlyMock provides an empty APIProvider that only mocks the DAG portion of | ||
| // the ipfs api object. This is much lighter than the full IPFS node and should | ||
| // be favored for CI testing | ||
| func DagOnlyMock() APIProvider { | ||
| mockAPI := dagOnlyMock{mdutils.Mock()} | ||
| return func() (coreiface.CoreAPI, io.Closer, error) { | ||
| return mockAPI, mockAPI, nil | ||
| } | ||
| } | ||
|
|
||
| var _ coreiface.CoreAPI = dagOnlyMock{} | ||
|
|
||
| type dagOnlyMock struct { | ||
| format.DAGService | ||
| } | ||
|
|
||
| func (dom dagOnlyMock) Dag() coreiface.APIDagService { return dom } | ||
|
|
||
| func (dagOnlyMock) Unixfs() coreiface.UnixfsAPI { return nil } | ||
| func (dagOnlyMock) Block() coreiface.BlockAPI { return nil } | ||
| func (dagOnlyMock) Name() coreiface.NameAPI { return nil } | ||
| func (dagOnlyMock) Key() coreiface.KeyAPI { return nil } | ||
| func (dagOnlyMock) Pin() coreiface.PinAPI { return nil } | ||
| func (dagOnlyMock) Object() coreiface.ObjectAPI { return nil } | ||
| func (dagOnlyMock) Dht() coreiface.DhtAPI { return nil } | ||
| func (dagOnlyMock) Swarm() coreiface.SwarmAPI { return nil } | ||
| func (dagOnlyMock) PubSub() coreiface.PubSubAPI { return nil } | ||
| func (dagOnlyMock) ResolvePath(context.Context, path.Path) (path.Resolved, error) { return nil, nil } | ||
| func (dagOnlyMock) ResolveNode(context.Context, path.Path) (format.Node, error) { return nil, nil } | ||
| func (dagOnlyMock) WithOptions(...options.ApiOption) (coreiface.CoreAPI, error) { return nil, nil } | ||
| func (dagOnlyMock) Close() error { return nil } | ||
| func (dagOnlyMock) Pinning() format.NodeAdder { return nil } |
There was a problem hiding this comment.
So I don't see any need for dagOnlyMock
| // store blocks and commits | ||
| blockStore sm.BlockStore | ||
|
|
||
| dag format.DAGService |
There was a problem hiding this comment.
Pls, keep DAGService in the State how it was. DAGService handles networking as well and making State rely on dag service provided by blockstore is architecturally not a good idea.
There was a problem hiding this comment.
Conceptually, I argue that we should change "move the ipfs dag api object to Blockstore" to "use the ipfs dag api object in Blockstore"
There was a problem hiding this comment.
that is now true, yes.
|
|
||
| // APIProvider allows customizable IPFS core APIs. | ||
| type APIProvider func() (coreiface.CoreAPI, io.Closer, error) | ||
| type APIProvider func() (coreiface.APIDagService, io.Closer, error) |
There was a problem hiding this comment.
👍🏻
This should make the IPFS resource usage footprint in tests very low!
liamsi
left a comment
There was a problem hiding this comment.
You guys rock 🚀 Great work and thanks for the thorough review as well @Wondertan.
|
The further we go, the more we disassemble the IPFS blob. I start to like this approach as it appears to be more natural than just going straight into breaking it. |
… of embedded ipfs objects This reverts commit 40acb17.
* Revert "Remove the PartSetHeader from VoteSetMaj23, VoteSetBits, and state.State (#479)" This reverts commit 3ba47c2. * Revert "Stop Signing over the `PartSetHeader` for Votes and remove it from the `Header` (#457)" This reverts commit 818be04. * Revert "Decouple PartSetHeader from BlockID (#441)" This reverts commit 9d4265d. * Revert "Save and load block data using IPFS (#374)" This reverts commit 8da1644. * fix merge error * Revert "Add the ipfs dag api object in Blockstore (#356)" and get rid of embedded ipfs objects This reverts commit 40acb17. * remove ipfs node provider from new node * stop init ipfs repos * remove IPFS node config * clean up remaining ipfs stuff
Description
This PR adds the ipfs object to the
Blockstorestruct, along with adding a method to get the IPFS dag api object to theBlockStoreinterface. It also removes it from theStateandNodeobjects. It does not do anything new with the ipfs api object.Piggy backing on the work of #352, this PR introduces
DagOnlyMock. In this case, it was needed to getTestNodeSetPrivValIPCto pass.There are also a few timeout increases in a meager attempt to decrease CI flakiness.
Closes: #355