filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.83k stars 1.26k forks source link

Load manifest from state-tree #8800

Open Stebalien opened 2 years ago

Stebalien commented 2 years ago

Currently, we load the actor manifest from the bundle (mostly for introspection). However, we should be using the state-tree:

Unfortunately, this is non-trivial:

For now, we'll probably continue importing the bundle.

jennijuju commented 2 years ago

we should just load from the system actor, no?

jennijuju commented 2 years ago

oh nvm that gives you actor cids, not manifest CID. Why would one still want manifest CID if code cids were available ?

Stebalien commented 2 years ago

Ah, no. The issue isn't the actor CIDs or the manifest CIDs. The issue is mapping actor CIDs to actor versions so we can load the state with the correct "introspection" code in:

https://github.com/filecoin-project/lotus/blob/93f3b4923511f5ae3b661c234d09231ee56c4034/chain/actors/builtin/power/power.go#L39-L79

Stebalien commented 2 years ago

So, one solution is to just record the actor-version -> manifest mapping in the binary, which should be fine, honestly.

Stebalien commented 2 years ago

We can easily map the code CID to the actor type by looking at the manifest in the system actor. We should attach a (caching) GetBuiltinActors() map[string]cid.Cid method to the StateManager.

Well... "easily". To do this, we still need to be able to decode the system actor in the first place, which means we need some way to resolve a code CID to an actors version 🙄.