-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat(ipld): bindnode support for all voucher types #713
feat(ipld): bindnode support for all voucher types #713
Conversation
Ok, this took me a long time to understand but as I see it, the end goal here is that, in the case of the retrieval deal proposal, as an example, is now both a CBOR-GEN compatible type AND a bindnode compatible type. The reasoning is:
I've looked at all three PRs now, and my general input is: go forth and implement! |
I will say: shared.SerializedNode is not my favorite name as I read that as "stored in serialized form" which is not true -- it is in fact already deserialzied into a datamodel.Node, unlike cbg.Deferred. I would call it "shared.CborGenIPLDNode" or something like that I think. |
renamed SerializedNode & added additional comments |
Updated to current filecoin-project/go-data-transfer#325 |
daeae33
to
d80f757
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 is looking pretty great. I need to once over again, and I think we should really figure out how to remove deduplication around bindnode embedded schemas between this and go-data-transfer, but otherwise pretty good to go.
I'm fine with merging into the base branch if you want to address any issues in a separate ticket.
Codecov Report
@@ Coverage Diff @@
## feat/datatransfer-v2-integration #713 +/- ##
===================================================================
Coverage ? 58.73%
===================================================================
Files ? 62
Lines ? 5224
Branches ? 0
===================================================================
Hits ? 3068
Misses ? 1815
Partials ? 341 |
655f4f6
to
43e2645
Compare
7765cd2
to
3376176
Compare
79bb329
to
22e0ea4
Compare
b5026b4
to
d07b35b
Compare
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps Update retrievalmarket/types.go Update storagemarket/types.go chore(deps): update to rc candidate chore(dtutils): update for new data transfer configuration interface
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps Update retrievalmarket/types.go Update storagemarket/types.go chore(deps): update to rc candidate chore(dtutils): update for new data transfer configuration interface
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps Update retrievalmarket/types.go Update storagemarket/types.go chore(deps): update to rc candidate chore(dtutils): update for new data transfer configuration interface chore(deps): update to rc4
Voucher refactor integration (#707) * refactor(storagemarket): update storagemarket * refactor(retrievalmarket): use new voucher system refactor for predictability and correctness using new voucher system * chore(deps): update go-data-transfer v2 * style(lint): prep for pr * docs(retrievalmarket): add comments * chore(deps): update go-statemachine * style(imports): fix imports chore(retrievalmarket): remove old types (#712) feat(ipld): bindnode support for all voucher types (#713) * feat(ipld): new data-transfer ipld vouchers + bindnode * feat(ipld): simplify ipldutils API * feat(ipld): use new bindnode registry in go-ipld-prime Ref: ipld/go-ipld-prime#437 feat(deps): update data transfer 61f0756c feat(deps): update data transfer and other deps update to master data transfer with libp2p v0.22.0 plus associated other deps Update retrievalmarket/types.go Update storagemarket/types.go chore(deps): update to rc candidate chore(dtutils): update for new data transfer configuration interface chore(deps): update to rc4
PR against #712 but will be against #707 when that one gets merged.
This depends on a the branch of go-ipld-prime that's in here: ipld/go-ipld-prime#415, which itself builds on ipld/go-ipld-prime#414 (I'll merge them into one soon).
Aim
We want to be able to use
datamodel.Node
vouchers from go-data-transfer, where we're stripping out cbor-gen and it now has a unified go-ipld-prime usage. But we encounter lots of cbor-gen types here that we have to write translation layers to get to if we were to use bindnode or any other go-ipld-primeNode
interface (codegen, basicnode, qp?).This highlights a problem with bindnode - in typical use you end up needing to write a translation layer between two Go types to get to the form your application wants. We found that in graphsync and it's even true in go-ipld-prime itself (as can be seen here: ipld/go-ipld-prime#350 which needs to convert
operationsRaw
toOperation
).Wot?
So 414 and 415 are experiments in exposing extension points in bindnode that give you the ability to convert to and from custom types that don't have a natural translation between Go types and data model kinds. These end up mapping almost exactly to the Go types that have hand-rolled
MarshalCBOR
andUnmarshalCBOR
in the Lotus codebase (a surprising number of them).So now, we get to say how a type translates from a custom Go type to an commonly understood one one (e.g.
Address
->[]byte
), or even a custom Go type to adatamodel.Node
in the case of anAny
. We also get to do this from outside of the type, so we don't need to go digging around in go-state-types, go-address, etc. to add methods to the types we care about—we declare them when we interact with bindnode.The
Any
case (to and fromdatamodel.Node
) lets us even work with cbor-gen'sDeferred
types .. sort of. At least we don't need very heavy modifications to make it work.So this PR includes minimal adjustment of the voucher types, the exception being the
Deferred
forSelector
which we box in a type that can speak with both cbor-gen and bindnode. And we get to use the same types for both cbor-gen and bindnode. It also includes a helper package that improves usability of bindnode for a library like this where you have multiple types you care about—such as allowing the schema to hang off the type itself with aBindnodeSchema()
method.Tests
The main work in this PR are the tests that compare the round-trip serialisation and deserialisation of types through both cbor-gen and bindnode and demonstrate that they are correct and comparable.