Conversation
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
namesys/publisher.go
Outdated
| if err != nil { | ||
| return ErrInvalidAuthor | ||
| } | ||
| if string(pid) != string(r.Author) { |
There was a problem hiding this comment.
We can remove the string casts here now right
8e934df to
26a8652
Compare
Our code now better validates peer IDs. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
26a8652 to
3edd726
Compare
License: MIT Signed-off-by: Dirk McCormick <dirkmdev@gmail.com>
License: MIT Signed-off-by: Dirk McCormick <dirkmdev@gmail.com>
License: MIT Signed-off-by: Dirk McCormick <dirkmdev@gmail.com>
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Also: * Update the blockstore/blockservice methods to match. * Construct a new temporary offline dag instead of having a GetOfflineLinkService method. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
67fc3da to
e638bc6
Compare
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
e638bc6 to
699b2c4
Compare
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
| ipfsi 2 name resolve /ipns/$PEERID_0 | ||
| ipfsi 1 name resolve /ipns/$PEERID_0; | ||
| ipfsi 2 name resolve /ipns/$PEERID_0; | ||
| true |
There was a problem hiding this comment.
hrm, shouldn't we be testing if they succeeded?
that's why i had the &&.
There was a problem hiding this comment.
the assumption is that name resolve returns 0 if it succeeds.
There was a problem hiding this comment.
Yeah but shouldn't it not succeed? Nothing has been published yet, as far as I know.
There was a problem hiding this comment.
yeah, good point! these are executed for their side-effect of subscribing to the topic.
d503d66 to
2c39138
Compare
Stebalien
left a comment
There was a problem hiding this comment.
Self reviewed because I kind of doubt anyone will have time for a thorough review...
| ctx := notif.RegisterForQueryEvents(req.Context(), events) | ||
|
|
||
| k := string(b58.Decode(req.Arguments()[0])) | ||
| id, err := peer.IDB58Decode(req.Arguments()[0]) |
There was a problem hiding this comment.
This broke a test or two but it's strictly more correct.
There was a problem hiding this comment.
Yeah. I just wonder if anyone was relying on this in practice. One could theoretically use this to find the peers closest to some base58 encoded thing that's not a valid peer ID.
There was a problem hiding this comment.
should probably make sure that this isnt how we do random-walk bootstrapping
There was a problem hiding this comment.
oh wait, this is in a command. Nvm
| return nil, false, err | ||
| } | ||
|
|
||
| offset += bs |
There was a problem hiding this comment.
@whyrusleeping go vet complained. I believe this is the correct fix here but I just wanted to check. Not really related to this PR, just a drive-by fix.
| if err := s.exchange.HasBlock(o); err != nil { | ||
| return nil, errors.New("blockservice is closed") | ||
| // TODO(stebalien): really an error? | ||
| return errors.New("blockservice is closed") |
There was a problem hiding this comment.
@whyrusleeping Should we not just log and continue here?
There was a problem hiding this comment.
unclear. For now lets leave it as is.
There was a problem hiding this comment.
Fair. Reported at #4623 (and the comment has been updated to point to the issue).
| if err := s.exchange.HasBlock(o); err != nil { | ||
| return nil, fmt.Errorf("blockservice is closed (%s)", err) | ||
| // TODO(stebalien): Should this really *return*? | ||
| return fmt.Errorf("blockservice is closed (%s)", err) |
|
|
||
| bs := n.Blocks.Blockstore() | ||
| DAG := dag.NewDAGService(bserv.New(bs, offline.Exchange(bs))) | ||
| getLinks := dag.GetLinksWithDAG(DAG) |
There was a problem hiding this comment.
This is the new way to do offline stuff. We could also use the context trick if we get tired of this dance.
There was a problem hiding this comment.
this is 3 lines instead of 1; ergonomically it's not an improvement...
There was a problem hiding this comment.
Discussion: #4009
So, first, I made implementing LinkService optional. If your NodeGetter (the get side of the DAGService) doesn't implement the LinkService optimizations, it doesn't have to implement the interface.
Next, I tried adding a OfflineNodeGetter method to the NodeGetter interface. However, that really tricky and messy:
- We realized that we'd probably want
Offline*methods on every related service (which would kind of suck). - Things like bitswap sessions (which I wanted to turn into valid
NodeGetters would also have to implement this method). I simply couldn't find a clean way to do this.
So, in #4009, I suggested adding an "offline" flag to the context. I still think that's the best way to go because I keep running into similar cases where I want to try to do something without touching the network but @kevina reasonably objected that it was a bit magical and easy to screw up.
Hence this solution.
I could add a helper function but, really, I kind of want this to be ugly. I'm not happy with this solution at all and don't want this pattern repeated all over the codebase. For one, it makes the LinkService optimization totally useless because we don't reuse the DAG (we construct a new one with the blockstore when we do the GC).
| } | ||
|
|
||
| return gc.GC(ctx, n.Blockstore, n.DAG, n.Pinning, roots) | ||
| return gc.GC(ctx, n.Blockstore, n.Pinning, roots) |
There was a problem hiding this comment.
Now constructs a dag from the blockstore.
| Offset: offset, | ||
| FullPath: fullPath, | ||
| Stat: stat, | ||
| } |
There was a problem hiding this comment.
go vet yelled at me 😨.
| var ParallelBatchCommits = runtime.NumCPU() * 2 | ||
|
|
||
| // Batch is a buffer for batching adds to a dag. | ||
| type Batch struct { |
There was a problem hiding this comment.
Now in go-ipld-format.
| } | ||
|
|
||
| func (s *blockService) AddBlocks(bs []blocks.Block) ([]*cid.Cid, error) { | ||
| func (s *blockService) AddBlocks(bs []blocks.Block) error { |
There was a problem hiding this comment.
are we losing any functionality by dropping the cids from the return type?
There was a problem hiding this comment.
Not really. We can get the CIDs from the blocks so there's no need to return them here. It just complicates the blockservice (and dagservice which is why I removed this).
There was a problem hiding this comment.
Although based on the current implementation we are not losing any functionally here. If AddBlocks is ever enhanced to just add some of the blocks (and not return early on error) it will make it difficult to determine which blocks where added.
There was a problem hiding this comment.
I wouldn't call that an enhancement
There was a problem hiding this comment.
Fair enough. But it is still possible for something to go wrong while adding the blocks, such as running out of space. However, since the underlying BlockStore does not indicate which blocks where added there is no way to get this information. I will make a separate issue for this so we can figure out a proper solution.
| ctx := notif.RegisterForQueryEvents(req.Context(), events) | ||
|
|
||
| k := string(b58.Decode(req.Arguments()[0])) | ||
| id, err := peer.IDB58Decode(req.Arguments()[0]) |
|
|
||
| bs := n.Blocks.Blockstore() | ||
| DAG := dag.NewDAGService(bserv.New(bs, offline.Exchange(bs))) | ||
| getLinks := dag.GetLinksWithDAG(DAG) |
There was a problem hiding this comment.
this is 3 lines instead of 1; ergonomically it's not an improvement...
namesys/publisher.go
Outdated
| return ErrInvalidAuthor | ||
| } | ||
| if string(pid) != string(r.Author) { | ||
| if pid != r.Author { |
|
@Stebalien sharness on OSX is failing. |
|
(well, once someone reviews it) |
magik6k
left a comment
There was a problem hiding this comment.
Github doesn't want to load diff past importer/helpers/dagbuilder.go (which is about half of the changes), I'll try to review the rest somehow.
core/coreapi/key_test.go
Outdated
|
|
||
| if keys[0].Path().String() != "/ipns/Qmfoo" { | ||
| if keys[0].Path().String() != "/ipns/"+testPeerID { | ||
| t.Errorf("expected the key to have path '/ipns/Qmfoo', got '%s'", keys[0].Path().String()) |
There was a problem hiding this comment.
nitpick: this should be
t.Errorf("expected the key to have path '/ipns/%s', got '%s'", testPeerID, keys[0].Path().String())
core/core.go
Outdated
| metrics "gx/ipfs/Qmb1QrSXKwGFWgiGEcyac4s5wakJG4yPvCPk49xZHxr5ux/go-libp2p-metrics" | ||
| cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" | ||
| dht "gx/ipfs/Qmdm5sm2xHCXNaWdxpjhFeStvSNMRhKQkqpBX7aDcqXtfT/go-libp2p-kad-dht" | ||
| node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" |
There was a problem hiding this comment.
With more things in go-ipld-format we may want to change the naming from node to something like ipld - imo node is a bit confusing for some of the things that are now there.
There was a problem hiding this comment.
If we decide to, I'm fine with thin being in another PR, this one is big enough.
There was a problem hiding this comment.
Meh. Might as well do this now. Anyways, go makes this pretty easy :).
|
Looked at the rest of the changes locally, other than the two comments LGTM |
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
fixes #4524 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
|
Please ignore codeclimate. It loves to punish those who refactor for the sins of others. |
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
|
CI failure: #3970. |
magik6k
left a comment
There was a problem hiding this comment.
LGTM - Used this for a while, didn't notice anything strange.
whyrusleeping
left a comment
There was a problem hiding this comment.
Looked through it locally, nothing was immediately objectionable. But it was a pretty massive diff.
|
|
||
| ls = ls.GetOfflineLinkService() | ||
| bsrv := bserv.New(bs, offline.Exchange(bs)) | ||
| ds := dag.NewDAGService(bsrv) |
There was a problem hiding this comment.
This was the way we originally did things back before 721df36. The reason I put it in was not for catching but for the filestore. With the current filestore it is not technically needed, but with a richer more functional filestore it might be again. So that the record is straight I will add a comment outside of the review a little later so its not so easily lost.
There was a problem hiding this comment.
I'm really starting to think we should just be using a context hint. Anyways, all this will need to be reworked when GC changed to operate over a DAG instead of a blockservice.
|
That wasn't a fix, it was a workable hack to allow us to move forward and agree on a fix (that's why I called it out and asked if it was ok for now). |
|
@Stebalien and sorry again I was not on the ball here. That change did not imminently register until you closed my p.r. It would of been very helpful if that change was in a separate p.r. |
Features:
correctly validate DHT records (@dirkmc).Use new DHT record validators.If I'm missing something here, please comment.
To review this PR, please do so commit by commit for your own sanity.
Questions:
GetOfflineLinkServicedid anyways).