-
Notifications
You must be signed in to change notification settings - Fork 464
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
update and use upstream deps #1270
Conversation
843d7d7
to
325b445
Compare
@@ -72,7 +72,7 @@ type Actor struct{} | |||
|
|||
// State is the storage market's storage. | |||
type State struct { | |||
Miners cid.Cid | |||
Miners cid.Cid `refmt:",omitempty"` |
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 real design question here. I'm really quite unhappy with this "omitempty" dance but want to get some opinions before I try pushing for a change in refmt.
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 can this ever be 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.
no, this should never be nil. At worst, its the cid of the empty HAMT
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.
@phritz @whyrusleeping This value is nil when it's initialized. Nil signals that there's currently no block in storage for the Cid. It could be implemented differently if we really want to avoid nils.
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 for doing this
- yes we should fix refmt, current state is just going to cause bugs and confusion
- can you please send an email to filevcoin-dev highlighting the cid changes?
api/actor.go
Outdated
@@ -12,11 +12,11 @@ import ( | |||
type ActorView struct { | |||
ActorType string `json:"actorType"` | |||
Address string `json:"address"` | |||
Code *cid.Cid `json:"code"` | |||
Code cid.Cid `json:"code"` |
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.
pretty sure code can be 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.
no. Code can't be 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.
@whyrusleeping @Stebalien yes it can: https://github.com/filecoin-project/go-filecoin/blob/34875d0636c784fe6fa29d745f0484e228f580bd/consensus/processor.go#L340. Recall we added actor upgrades to handle sends to predictable but uninitialized addresses.
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.
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 waiting on decisions in refmt, currently. For now, we could also just use *cid.Cid
here and sidestep the issue (it's just a little annoying to deal with both cid.Cid
and *cid.Cid
).
Nit: We should add a test case that covers 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.
Ah. Actually, ActorView is just for the user. As far as I can tell, it's never turned into an IPLD object. However, I can make it omitempty anyways (can't hurt).
commands/client.go
Outdated
@@ -72,9 +72,9 @@ var clientImportDataCmd = &cmds.Command{ | |||
|
|||
re.Emit(out.Cid()) // nolint: errcheck | |||
}, | |||
Type: cid.Cid{}, | |||
Type: cid.Undef, |
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.
why do we do 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.
My bad.
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.
(fixed)
@@ -72,7 +72,7 @@ type Actor struct{} | |||
|
|||
// State is the storage market's storage. | |||
type State struct { | |||
Miners cid.Cid | |||
Miners cid.Cid `refmt:",omitempty"` |
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 can this ever be nil?
325b445
to
ac4d215
Compare
Rebased. If I don't keep this up-to-date, it'll be really painful. |
Refmt issue here: polydawn/refmt#42 |
ac4d215
to
4ce6fd8
Compare
So, it turns out I was technically incorrect:
refmt will decode |
Status: This is blocked on polydawn/refmt#42. Instead of waiting on that, I'd like to propose two alternatives:
Thoughts? |
f0c5e65
to
e15bb7b
Compare
e15bb7b
to
9b6f48c
Compare
Updates:
fixes #643
Cids by value or by pointer: In the past, we always passed around
*cid.Cid
(a pointer to a struct). In go-ipfs, we now pass aroundcid.Cid
(effectively a newtype around a string). This:==
However, it introduces a tricky edge-case: nil CIDs. To handle this, we use
cid.Undef
(orcid.Cid{}
) and have defined amyCid.Defined()
method to tell if the CID is valid or not.Unfortunately, this has lead to a rather annoying edge-case concerning refmt and ipld-cbor: refmt provides no way to decode
null
ascid.Cid{}
or encodecid.Cid{}
asnull
. The current workaround (in this patch) is to:refmt:",omitempty"
.null
where a CID is.The alternatives are:
*cid.Cid
in structs where the CID is nullable.Please carefully look over this PR, it contains quite a few changes. I've broken it up into logical commits (sticking all gx updates in the first once) so it should be reviewable.
Please also tell me if there are any changes made to upstream libraries in forks that I may be unaware of. I believe ipfs/go-ipld-cbor is now on-par with filecoin-project/go-ipld-cbor but I may be wrong.