-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
mega update #4610
mega update #4610
Conversation
License: MIT Signed-off-by: Steven Allen <[email protected]>
License: MIT Signed-off-by: Steven Allen <[email protected]>
namesys/publisher.go
Outdated
if err != nil { | ||
return ErrInvalidAuthor | ||
} | ||
if string(pid) != string(r.Author) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
26a8652
to
3edd726
Compare
License: MIT Signed-off-by: Dirk McCormick <[email protected]>
License: MIT Signed-off-by: Dirk McCormick <[email protected]>
License: MIT Signed-off-by: Dirk McCormick <[email protected]>
License: MIT Signed-off-by: Dirk McCormick <[email protected]>
License: MIT Signed-off-by: Steven Allen <[email protected]>
License: MIT Signed-off-by: Steven Allen <[email protected]>
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 <[email protected]>
License: MIT Signed-off-by: Steven Allen <[email protected]>
67fc3da
to
e638bc6
Compare
License: MIT Signed-off-by: Steven Allen <[email protected]>
e638bc6
to
699b2c4
Compare
License: MIT Signed-off-by: Steven Allen <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vyzo does this change make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrm, shouldn't we be testing if they succeeded?
that's why i had the &&
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the assumption is that name resolve returns 0 if it succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but shouldn't it not succeed? Nothing has been published yet, as far as I know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, good point! these are executed for their side-effect of subscribing to the topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So yes, change makes sense.
d503d66
to
2c39138
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self reviewed because I kind of doubt anyone will have time for a thorough review...
@@ -69,9 +69,13 @@ var queryDhtCmd = &cmds.Command{ | |||
events := make(chan *notif.QueryEvent) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke a test or two but it's strictly more correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like faulty tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably make sure that this isnt how we do random-walk bootstrapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait, this is in a command. Nvm
@@ -330,7 +330,6 @@ func (dm *DagModifier) modifyDag(n node.Node, offset uint64, data io.Reader) (*c | |||
return nil, false, err | |||
} | |||
|
|||
offset += bs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
blockservice/blockservice.go
Outdated
} | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whyrusleeping Should we not just log and continue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unclear. For now lets leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair. Reported at #4623 (and the comment has been updated to point to the issue).
blockservice/blockservice.go
Outdated
for _, o := range toput { | ||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same?
|
||
bs := n.Blocks.Blockstore() | ||
DAG := dag.NewDAGService(bserv.New(bs, offline.Exchange(bs))) | ||
getLinks := dag.GetLinksWithDAG(DAG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is 3 lines instead of 1; ergonomically it's not an improvement...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
NodeGetter
s 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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough.
@@ -154,7 +154,7 @@ func GarbageCollectAsync(n *core.IpfsNode, ctx context.Context) <-chan gc.Result | |||
return out | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now constructs a dag from the blockstore.
Offset: offset, | ||
FullPath: fullPath, | ||
Stat: stat, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we losing any functionality by dropping the cids from the return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call that an enhancement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -69,9 +69,13 @@ var queryDhtCmd = &cmds.Command{ | |||
events := make(chan *notif.QueryEvent) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like faulty tests!
|
||
bs := n.Blocks.Blockstore() | ||
DAG := dag.NewDAGService(bserv.New(bs, offline.Exchange(bs))) | ||
getLinks := dag.GetLinksWithDAG(DAG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is 3 lines instead of 1; ergonomically it's not an improvement...
namesys/publisher.go
Outdated
@@ -322,7 +322,7 @@ func ValidateIpnsRecord(r *record.ValidationRecord) error { | |||
if err != nil { | |||
return ErrInvalidAuthor | |||
} | |||
if string(pid) != string(r.Author) { | |||
if pid != r.Author { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clown shoes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😕
@Stebalien sharness on OSX is failing. |
(well, once someone reviews it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -31,7 +31,7 @@ func TestListSelf(t *testing.T) { | |||
t.Errorf("expected the key to be called 'self', got '%s'", keys[0].Name()) | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
License: MIT Signed-off-by: Steven Allen <[email protected]>
fixes #4524 License: MIT Signed-off-by: Steven Allen <[email protected]>
Please ignore codeclimate. It loves to punish those who refactor for the sins of others. |
License: MIT Signed-off-by: Steven Allen <[email protected]>
CI failure: #3970. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Used this for a while, didn't notice anything strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked through it locally, nothing was immediately objectionable. But it was a pretty massive diff.
...to match the recent mass rename in #4610. License: MIT Signed-off-by: Steven Allen <[email protected]>
|
||
elock := log.EventBegin(ctx, "GC.lockWait") | ||
unlocker := bs.GCLock() | ||
elock.Done() | ||
elock = log.EventBegin(ctx, "GC.locked") | ||
emark := log.EventBegin(ctx, "GC.mark") | ||
|
||
ls = ls.GetOfflineLinkService() | ||
bsrv := bserv.New(bs, offline.Exchange(bs)) | ||
ds := dag.NewDAGService(bsrv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
...to match the recent mass rename in ipfs#4610. License: MIT Signed-off-by: Steven Allen <[email protected]>
mega update This commit was moved from ipfs/kubo@b386088
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:
GetOfflineLinkService
did anyways).