-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Network upgrade support #3781
Network upgrade support #3781
Conversation
This patch starts adding support for network upgrades. * It adds an actors abstraction layer for loading abstract (cross-version) actors. * It starts switching over to a shared deadline type. * It adds an abstraction for ADTs (hamt/amt). * It removes the callback-based API in the StateManager (difficult to abstract across actor versions). * It _does not_ actually add support for actors v2. We can do that in a followup patch but that should be relatively easy. This patch is heavily WIP and does not compile. Feel free to push changes directly to this branch. Notes: * State tree access now needs a network version, because the HAMT type will change. * I haven't figured out a nice way to abstract over changes to the _message_ types. However, many of them will be type aliased to actors v0 in actors v2 so we can likely continue using the v0 versions (or use the v2 versions everywhere). I've been renaming imports to `v0*` to make it clear that we're importing types from a _specific_ actors version. TODO: * Consider merging incremental improvements? We'd have to get this compiling again first but we could merge in the new abstractions, and slowly switch over. * Finish migrating to the new abstractions. * Remove all actor state types from the public API. See `miner.State.Info()` for the planned approach here. * Fix the tests. This is likely going to be a massive pain.
chain/actors/builtin/builtin.go
Outdated
// Converts a network version into a specs-actors version. | ||
func VersionForNetwork(version network.Version) Version { | ||
switch version { | ||
case network.Version0, network.Version1: |
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.
Yes. Network version != actor version. Also, actor version is going to go from 0 (well, 0.9) to 2. That's going to be rather strange..
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.
If it will just be used as a unique key, maybe use a string "v2" instead?
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.
We're now encoding this inside the state tree itself.
@magik6k what version do we actually want in the state tree. We could use:
- Network version (seems like overkill).
- Actors version (what we're using here).
- A specific "state tree" version (for the HAMT). That seems like the best approach, honestly.
Thoughts?
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.
A specific state tree version sounds like what we want here
@@ -47,6 +47,7 @@ func NewInvoker() *Invoker { | |||
} | |||
|
|||
// add builtInCode using: register(cid, singleton) | |||
// NETUPGRADE: register code IDs for v2, etc. |
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 plan here is to register code IDs for both v1 and v2 actors, at the same time. As far as I know, this should "just work".
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.
Correct, though ideally we'd at least specify minimum / maximum epoch at which a given code CID can be used
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.
Looking good from here
chain/actors/builtin/builtin.go
Outdated
// Converts a network version into a specs-actors version. | ||
func VersionForNetwork(version network.Version) Version { | ||
switch version { | ||
case network.Version0, network.Version1: |
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.
If it will just be used as a unique key, maybe use a string "v2" instead?
Yes, definitely want non-consensus breaking changes in before, so the PR with the actual consensus upgrade is as small/easy to review as possible |
2373b19
to
cc99ecd
Compare
cc99ecd
to
1dc69e3
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.
I think this is good to merge. The biggest thing kicked down the road is probably genesis setup stuff (along with lots of tests explicitly using v0 actors). I think that's fine for now.
Some of the "just use v0 actors it'll be fine" needs to be scrutinised, but we can do a second pass when we actually introduce v1 actors.
@@ -300,7 +290,11 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp | |||
return cid.Cid{}, cid.Cid{}, err | |||
} | |||
|
|||
rectarr := adt.MakeEmptyArray(sm.cs.Store(ctx)) | |||
// XXX: Is the height correct? Or should it be epoch-1? |
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 matching how the VM GetNtwkVersion works, so most likely correct
(differently something to manually verify when we test the fork)
case act.IsAccountActor(): | ||
st, err := account.Load(store, act) | ||
if err != nil { | ||
// TODO: magik6k: this _used_ to log instead of failing, why? |
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 @whyrusleeping question
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.
Looks good, also works, ship it!
This patch starts adding support for network upgrades.
This patch is heavily WIP and does not compile. Feel free to push changes directly to this branch.
Notes:
State tree access now needs a network version, because the HAMT type will change.The state-tree now includes a version.v0*
to make it clear that we're importing types from a specific actors version.TODO:
Consider merging incremental improvements? We'd have to get this compiling again first but we could merge in the new abstractions, and slowly switch over.miner.State.Info()
for the planned approach here.