-
Notifications
You must be signed in to change notification settings - Fork 462
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(actor): update go-hamt-ipld library to latest #3411
Conversation
2854b12
to
31ca841
Compare
@@ -169,6 +169,9 @@ func MakeGenesisFunc(opts ...GenOption) GenesisInitFunc { | |||
if err = s.Commit(scid, a.Head); err != nil { | |||
return nil, err | |||
} | |||
if err := st.SetActor(ctx, addr, a); err != nil { |
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.
Of particular note: I do not understand how this was working before -- the head gets committed, which updates the actor, but it isn't rewritten to the hamt -- it makes me think this was only working cause of in some memory caching? Not sure!
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.
Presumably the problem is that the actor's Head is not getting updated in the state tree without this line. If this is the case, is line 160 still necessary? If so, we need a comment explaining why we're setting the actor twice.
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.
Thanks. I don't like the deps on personal repos, but this didn't make the situation any worse, and we can address it later.
@@ -177,7 +177,7 @@ func (pb *Actor) CreateChannel(vmctx exec.VMContext, target address.Address, eol | |||
|
|||
err := withPayerChannels(ctx, storage, payerAddress, func(byChannelID exec.Lookup) error { | |||
// check to see if payment channel is duplicate | |||
_, err := byChannelID.Find(ctx, channelID.KeyString()) | |||
err := byChannelID.Find(ctx, channelID.KeyString(), &PaymentChannel{}) |
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.
In storagemarket.go
you used nil
for an unwanted out parameter. Do something consistent (nil seems fine if supported).
@hannahhoward your editor seems to be inserting unnecessary package aliases. I'd appreciate you figuring out how to avoid that. |
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 good. I have a couple question that may prompt minor modifications.
@@ -169,6 +169,9 @@ func MakeGenesisFunc(opts ...GenOption) GenesisInitFunc { | |||
if err = s.Commit(scid, a.Head); err != nil { | |||
return nil, err | |||
} | |||
if err := st.SetActor(ctx, addr, a); err != nil { |
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.
Presumably the problem is that the actor's Head is not getting updated in the state tree without this line. If this is the case, is line 160 still necessary? If so, we need a comment explaining why we're setting the actor twice.
return &act, nil | ||
} | ||
|
||
func hackTransferObject(from, to interface{}) 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.
🎉
nd, err = cbor.Decode(bytes, types.DefaultHashFunction, -1) | ||
} else if raw, ok := v.([]byte); ok { | ||
nd, err = cbor.Decode(raw, types.DefaultHashFunction, -1) | ||
} else if cm, ok := v.(cbg.CBORMarshaler); ok { |
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 putting CBORMarshaler
s into storage? Is this new functionality? If so, and we aren't yet using it, we should wait to introduce this until it is exercised by code (and 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.
so a CBORMarshaler just means an object that conforms to that interface, meaning it has methods to fast path it's own serialization / deserialization -- this covers all hamt nodes, and in fact, they need to be fastpathed to encode properly. WrapObject won't work here because of the cbg.Deferred object. The actual solution is that go-ipld-cbor should check for fast path in its own calls to marshal/unmarshal, which there is an unmerged PR for: ipfs/go-ipld-cbor#64 . Absent that getting merged, this is neccesary for a couple direct calls to storage.Put
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.
^^ @acruikshank
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.
will add a comment to that effect.
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.
@hannahhoward I will defer to whatever AC & AN suggest here. My feedback is primarily nits: combine if err :=
, no unnecessary import renames, and a slight preference for select
over else if
in vm/storage.go
.
Updates to the latest go-hamt-ipld library, which supports fast CBOR decode/encode and also supports alternate bitwidths on HAMT. This does not actually alter the bitwidth for the HAMT fanout -- that will be a future PR
hamt behavior was relying on actors being in memory
@anorth Hey so I finally tracked this down to not my editor but goimports, which does autoimporting, and specifically, this issue: golang/go#28428 & https://go-review.googlesource.com/c/tools/+/152000 They actually chose to add this feature and I honestly understand their reasoning -- the thought is even if the underlying package name is correct, if there's a mismatch with the filename there's no way to determine that it is without digging into the underlying source code of the file, so having the rename allows the imports of the file to be validated just by looking at the file itself. Though also I am curious if I am the only one who uses goimports and if others have had the same issue. Anyway, I only say this cause goimports is a pretty standard go tool, though I guess I am the only one who uses it on this project. But I'll turn it off and just do manual imports. |
- remove unneccesary imports - delete set line - add comment
31ca841
to
beb73c9
Compare
Codecov Report
@@ Coverage Diff @@
## master #3411 +/- ##
========================================
- Coverage 48% 26% -23%
========================================
Files 230 230
Lines 14362 14296 -66
========================================
- Hits 6959 3765 -3194
- Misses 6375 9900 +3525
+ Partials 1028 631 -397 |
Goals
Update Actor code to the latest go-hamt-ipld library, which supports fast CBOR decode/encode and also supports alternate bitwidths on HAMT.
Implementation
will be a future PR.
For discussion
I've changed a couple methods that didn't have a lot of individual test coverage to begin with -- should that be added to get this merged?
See comment on lines below for the MakeGenisisFunc function -- I don't understand how this didn't fail the waiter_test in plumbing/msg before?