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

mega update #4610

Merged
merged 25 commits into from
Jan 30, 2018
Merged

mega update #4610

merged 25 commits into from
Jan 30, 2018

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Jan 25, 2018

Features:

If I'm missing something here, please comment.

To review this PR, please do so commit by commit for your own sanity.


Questions:

  • Are we happy with the fix for [RFC] Add an offline hint to contexts #4009 (offline dag)? Currently, I just take a blockservice instead and construct an offline dagservice on the fly (which is what GetOfflineLinkService did anyways).

License: MIT
Signed-off-by: Steven Allen <[email protected]>
License: MIT
Signed-off-by: Steven Allen <[email protected]>
@ghost ghost assigned Stebalien Jan 25, 2018
@ghost ghost added the status/in-progress In progress label Jan 25, 2018
if err != nil {
return ErrInvalidAuthor
}
if string(pid) != string(r.Author) {
Copy link
Contributor

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

Our code now better validates peer IDs.

License: MIT
Signed-off-by: Steven Allen <[email protected]>
dirkmc and others added 8 commits January 25, 2018 15:13
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]>
@Stebalien Stebalien force-pushed the gx/update-1m7019 branch 2 times, most recently from 67fc3da to e638bc6 Compare January 25, 2018 23:18
License: MIT
Signed-off-by: Steven Allen <[email protected]>
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
Copy link
Member Author

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?

Copy link
Contributor

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 &&.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

@Stebalien Stebalien left a 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])
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds like faulty tests!

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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
Copy link
Member Author

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.

}

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")
Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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).

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)
Copy link
Member Author

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)
Copy link
Member Author

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.

Copy link
Contributor

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...

Copy link
Member Author

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:

  1. We realized that we'd probably want Offline* methods on every related service (which would kind of suck).
  2. 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).

Copy link
Contributor

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)
Copy link
Member Author

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,
}
Copy link
Member Author

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 {
Copy link
Member Author

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 {
Copy link
Contributor

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?

Copy link
Member Author

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).

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor

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])
Copy link
Contributor

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)
Copy link
Contributor

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...

@@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

clown shoes!

Copy link
Member Author

Choose a reason for hiding this comment

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

😕

@whyrusleeping
Copy link
Member

@Stebalien sharness on OSX is failing.

@Stebalien Stebalien removed the status/in-progress In progress label Jan 29, 2018
@Stebalien
Copy link
Member Author

(well, once someone reviews it)

Copy link
Member

@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.

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.

@@ -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())
Copy link
Member

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"
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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 :).

@magik6k
Copy link
Member

magik6k commented Jan 29, 2018

Looked at the rest of the changes locally, other than the two comments LGTM

@Stebalien Stebalien added status/in-progress In progress and removed RFM labels Jan 29, 2018
License: MIT
Signed-off-by: Steven Allen <[email protected]>
fixes #4524

License: MIT
Signed-off-by: Steven Allen <[email protected]>
@Stebalien
Copy link
Member Author

Please ignore codeclimate. It loves to punish those who refactor for the sins of others.

License: MIT
Signed-off-by: Steven Allen <[email protected]>
@Stebalien Stebalien added RFM and removed status/in-progress In progress labels Jan 29, 2018
@Stebalien
Copy link
Member Author

CI failure: #3970.

Copy link
Member

@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.

LGTM - Used this for a while, didn't notice anything strange.

Copy link
Member

@whyrusleeping whyrusleeping left a 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.

@whyrusleeping whyrusleeping merged commit b386088 into master Jan 30, 2018
@whyrusleeping whyrusleeping deleted the gx/update-1m7019 branch January 30, 2018 19:12
Stebalien added a commit that referenced this pull request Jan 30, 2018
...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)
Copy link
Contributor

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.

Copy link
Member Author

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.

@kevina
Copy link
Contributor

kevina commented Jan 31, 2018

This was merged before I had a chance to really review it, sorry I was not more on the ball here but I am not happy with the fix for #4009, I'll add my comment to #4009 where it will have a better chance of being seen.

@Stebalien
Copy link
Member Author

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).

@kevina
Copy link
Contributor

kevina commented Jan 31, 2018

@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.

AFDudley pushed a commit to vulcanize/go-ipfs that referenced this pull request Mar 22, 2018
...to match the recent mass rename in ipfs#4610.

License: MIT
Signed-off-by: Steven Allen <[email protected]>
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect Bandwidth
6 participants