-
Notifications
You must be signed in to change notification settings - Fork 267
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
Use IPLD Dag instead of CoreAPI #352
Conversation
Codecov Report
@@ Coverage Diff @@
## ismail/light-mvp #352 +/- ##
===================================================
Coverage ? 61.85%
===================================================
Files ? 262
Lines ? 22930
Branches ? 0
===================================================
Hits ? 14184
Misses ? 7251
Partials ? 1495 |
p2p/ipld/read.go
Outdated
total /= 2 | ||
if leaf < total { | ||
root = lnks[0].Cid | ||
} else { | ||
root, leaf = lnks[1].Cid, leaf-total | ||
} |
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.
mind adding some documentation somewhere? doesn't have to be anything too elaborate, but I think some simple guidance would make a big difference. Particularly for readers who are not familiar with our plugin.
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.
Sure. Also, that’s no the final form of the PR. I think I will close ot and rewrite afresh basing on the master, but that requires #323 to be merged first.
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.
merged :-)
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 added some documentation now, hope it will help understand the logic
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.
Cool! Just saw that after reviewing.
Use of Dag Sessions(optimization)
I think I understand this now. Although it's not clear to me how it works under the hood. But it makes sense intuitively.
This comment has been minimized.
This comment has been minimized.
96460c9
to
2b648fe
Compare
2b648fe
to
e87e122
Compare
@liamsi, @evan-forbes, I decided not to close this PR and instead extend it with the requested changes for CoreAPI removal |
In follow-up PR I will go even further and will propose our custom interface for network DataAvailavility which works over DAG |
08e51ea
to
631ab19
Compare
631ab19
to
0d0ab65
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.
This looks great! Left some suggestions and questions.
@@ -9,6 +9,7 @@ import ( | |||
"testing" | |||
"time" | |||
|
|||
mdutils "github.com/ipfs/go-merkledag/test" |
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.
Can we use another alias? mdutils sounds like markdown utils. Suggestion: dagutils? dagtest?
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.
That's a default package name.
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 won't change that as that's actually temporary thing
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.
Later in block propagation PR instead of just Mock I will use Mock with Mock networking
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 I won't spend time for this renaming
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.
That's a default package name.
But what does that even mean? Is the package aliased like this in other contexts?
p2p/ipld/read.go
Outdated
// GetLeafData fetches and returns the raw leaf. | ||
// It walks down the IPLD NMT tree until it finds the requested one. | ||
func GetLeaf(ctx context.Context, dag format.NodeGetter, root cid.Cid, leaf, total uint32) (format.Node, error) { | ||
// request the node | ||
nd, err := dag.Get(ctx, root) |
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 new GetLeaf
is much simpler! I like it a lot 👍
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.
@liamsi do we need to update ADR002 with this slight api change?
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, it would be good if the ADR would match the implementation's APIs.
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 think so, but also I am going to propose an elegant PR soon. If it's get accepted, updating this will make more sense
(from CI)
This is why the race detector hack was there btw. |
@liamsi, I guessed that removing Mock IPFS will decrease the number of goroutines to remove the hack. WIll try something else to fix that |
t.Run(fmt.Sprintf("%s size %d", tc.name, tc.squareSize), func(t *testing.T) { | ||
// if we're using the race detector, skip some large tests due to time and | ||
// concurrency constraints | ||
if racedetector.IsActive() && tc.squareSize > 8 { |
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.
To save you some time and to unblock this PR: we can either revert the changes regarding the racedetector, or, we simply skip all tests with a squareSize > 8
.
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.
two 👍 from me! all of these refactors and optimizations are really adding up! ✨
@liamsi, @evan-forbes, after looking deeply into the reasons why the issue above happens, I conclude that we have a goroutine leak that we should fix. With that hack, we just solely ignored the issue, so I don't think taking the hack back makes sense. We must limit the amount of spawned: go sc.retrieveShare(rootCid, true, row, col, dag) |
I would like to handle this myself as part of this PR, but I am really tired to do that today and it is midnight my time |
we don't have to merge this tonight. I'll try limiting the goroutines on a separate branch and see what happens |
Ok, but I already pushed temporary hack to unblock this |
While it makes perfect sense to limit that number of go-routines spawned in that method, it's not a go-routine leak. Also note that the error only kicks in when the race-detector is active and the code works fine even with larger blocks without the race detector though. I think, we can skip that test for now for larger blocks with a note that we should limit the number of go-routines spawned (I'll open an issue). If possible, let's merge this and handle the issue in a separate PR. |
That's true! Goruitne leak is when goroutine hangs out infinitely without returning, e.g. not calling cancel() for context will introduce one. My original intuition was that spawning tonnes of routines are like leaking something. Obviously, it's wrong, affects performance, and should be avoided. Idk how to call that properly btw. |
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.
Awesome work! 👍🏼 🚀
by moving the `codecov.yml` file from .github the root folder. --- #### PR checklist - [x] Tests written/updated - [x] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [x] Updated relevant documentation (`docs/` or `spec/`) and code comments (cherry picked from commit c906604) Co-authored-by: Lasaro <lasaro@informal.systems>
The PR's main goal is to facilitate everything related to IPFS usage by:
DAS timings before 2 above optimizations:
DAS timings after optimizations:
NOTE: Heights in the run with optimization was not DASed before, so light-client didn't have common data before.