feat: refactor: actor bundling system (#8838)
1. Include the builtin-actors in the lotus source tree.
2. Embed the bundle on build instead of downloading at runtime.
3. Avoid reading the bundle whenever possible by including bundle
metadata (the bundle CID, the actor CIDs, etc.).
4. Remove everything related to dependency injection.
1. We're no longer downloading the bundle, so doing anything ahead
of time doesn't really help.
2. We register the manifests on init because, unfortunately, they're
global.
3. We explicitly load the current actors bundle in the genesis
state-tree method.
4. For testing, we just change the in-use bundle with a bit of a
hack. It's not great, but using dependency injection doesn't make
any sense either because, again, the manifest information is
global.
5. Remove the bundle.toml file. Bundles may be overridden by
specifying an override path in the parameters file, or an
environment variable.
fixes #8701
2022-06-13 17:15:00 +00:00
|
|
|
package build_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2023-11-14 00:06:11 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-11-14 00:06:11 +00:00
|
|
|
|
2022-09-06 15:49:29 +00:00
|
|
|
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
2022-12-13 23:02:34 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/manifest"
|
2023-11-14 00:06:11 +00:00
|
|
|
|
feat: refactor: actor bundling system (#8838)
1. Include the builtin-actors in the lotus source tree.
2. Embed the bundle on build instead of downloading at runtime.
3. Avoid reading the bundle whenever possible by including bundle
metadata (the bundle CID, the actor CIDs, etc.).
4. Remove everything related to dependency injection.
1. We're no longer downloading the bundle, so doing anything ahead
of time doesn't really help.
2. We register the manifests on init because, unfortunately, they're
global.
3. We explicitly load the current actors bundle in the genesis
state-tree method.
4. For testing, we just change the in-use bundle with a bit of a
hack. It's not great, but using dependency injection doesn't make
any sense either because, again, the manifest information is
global.
5. Remove the bundle.toml file. Bundles may be overridden by
specifying an override path in the parameters file, or an
environment variable.
fixes #8701
2022-06-13 17:15:00 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Test that the embedded metadata is correct.
|
|
|
|
func TestEmbeddedMetadata(t *testing.T) {
|
|
|
|
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-02-08 16:14:31 +00:00
|
|
|
for i, v1 := range metadata {
|
|
|
|
v2 := build.EmbeddedBuiltinActorsMetadata[i]
|
|
|
|
require.Equal(t, v1.Network, v2.Network)
|
|
|
|
require.Equal(t, v1.Version, v2.Version)
|
|
|
|
require.Equal(t, v1.ManifestCid, v2.ManifestCid)
|
|
|
|
require.Equal(t, v1.Actors, v2.Actors)
|
|
|
|
}
|
feat: refactor: actor bundling system (#8838)
1. Include the builtin-actors in the lotus source tree.
2. Embed the bundle on build instead of downloading at runtime.
3. Avoid reading the bundle whenever possible by including bundle
metadata (the bundle CID, the actor CIDs, etc.).
4. Remove everything related to dependency injection.
1. We're no longer downloading the bundle, so doing anything ahead
of time doesn't really help.
2. We register the manifests on init because, unfortunately, they're
global.
3. We explicitly load the current actors bundle in the genesis
state-tree method.
4. For testing, we just change the in-use bundle with a bit of a
hack. It's not great, but using dependency injection doesn't make
any sense either because, again, the manifest information is
global.
5. Remove the bundle.toml file. Bundles may be overridden by
specifying an override path in the parameters file, or an
environment variable.
fixes #8701
2022-06-13 17:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test that we're registering the manifest correctly.
|
|
|
|
func TestRegistration(t *testing.T) {
|
2022-11-16 15:09:48 +00:00
|
|
|
for _, av := range []actorstypes.Version{actorstypes.Version8, actorstypes.Version9} {
|
|
|
|
manifestCid, found := actors.GetManifest(av)
|
feat: refactor: actor bundling system (#8838)
1. Include the builtin-actors in the lotus source tree.
2. Embed the bundle on build instead of downloading at runtime.
3. Avoid reading the bundle whenever possible by including bundle
metadata (the bundle CID, the actor CIDs, etc.).
4. Remove everything related to dependency injection.
1. We're no longer downloading the bundle, so doing anything ahead
of time doesn't really help.
2. We register the manifests on init because, unfortunately, they're
global.
3. We explicitly load the current actors bundle in the genesis
state-tree method.
4. For testing, we just change the in-use bundle with a bit of a
hack. It's not great, but using dependency injection doesn't make
any sense either because, again, the manifest information is
global.
5. Remove the bundle.toml file. Bundles may be overridden by
specifying an override path in the parameters file, or an
environment variable.
fixes #8701
2022-06-13 17:15:00 +00:00
|
|
|
require.True(t, found)
|
2022-11-16 15:09:48 +00:00
|
|
|
require.True(t, manifestCid.Defined())
|
|
|
|
|
2022-12-13 23:02:34 +00:00
|
|
|
for _, key := range manifest.GetBuiltinActorsKeys(av) {
|
2022-11-16 15:09:48 +00:00
|
|
|
actorCid, found := actors.GetActorCodeID(av, key)
|
|
|
|
require.True(t, found)
|
|
|
|
name, version, found := actors.GetActorMetaByCode(actorCid)
|
|
|
|
require.True(t, found)
|
|
|
|
require.Equal(t, av, version)
|
|
|
|
require.Equal(t, key, name)
|
|
|
|
}
|
feat: refactor: actor bundling system (#8838)
1. Include the builtin-actors in the lotus source tree.
2. Embed the bundle on build instead of downloading at runtime.
3. Avoid reading the bundle whenever possible by including bundle
metadata (the bundle CID, the actor CIDs, etc.).
4. Remove everything related to dependency injection.
1. We're no longer downloading the bundle, so doing anything ahead
of time doesn't really help.
2. We register the manifests on init because, unfortunately, they're
global.
3. We explicitly load the current actors bundle in the genesis
state-tree method.
4. For testing, we just change the in-use bundle with a bit of a
hack. It's not great, but using dependency injection doesn't make
any sense either because, again, the manifest information is
global.
5. Remove the bundle.toml file. Bundles may be overridden by
specifying an override path in the parameters file, or an
environment variable.
fixes #8701
2022-06-13 17:15:00 +00:00
|
|
|
}
|
|
|
|
}
|