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 main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2023-02-17 19:17:30 +00:00
|
|
|
"strconv"
|
2023-02-16 17:33:47 +00:00
|
|
|
"strings"
|
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
|
|
|
"text/template"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
)
|
|
|
|
|
2024-05-09 02:15:35 +00:00
|
|
|
var tmpl = template.Must(template.New("actor-metadata").Parse(`
|
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
|
|
|
// WARNING: This file has automatically been generated
|
|
|
|
|
|
|
|
package build
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
)
|
|
|
|
|
|
|
|
var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMetadata{
|
|
|
|
{{- range . }} {
|
|
|
|
Network: {{printf "%q" .Network}},
|
|
|
|
Version: {{.Version}},
|
2023-02-07 02:23:23 +00:00
|
|
|
{{if .BundleGitTag}} BundleGitTag: {{printf "%q" .BundleGitTag}}, {{end}}
|
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
|
|
|
ManifestCid: MustParseCid({{printf "%q" .ManifestCid}}),
|
|
|
|
Actors: map[string]cid.Cid {
|
|
|
|
{{- range $name, $cid := .Actors }}
|
|
|
|
{{printf "%q" $name}}: MustParseCid({{printf "%q" $cid}}),
|
|
|
|
{{- end }}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{{- end -}}
|
|
|
|
}
|
|
|
|
`))
|
|
|
|
|
2023-02-16 17:33:47 +00:00
|
|
|
func splitOverride(override string) (string, string) {
|
|
|
|
x := strings.Split(override, "=")
|
|
|
|
return x[0], x[1]
|
|
|
|
}
|
|
|
|
|
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
|
|
|
func main() {
|
2023-02-17 19:17:30 +00:00
|
|
|
// read metadata from the embedded bundle, includes all info except git tags
|
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
|
|
|
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2023-02-17 19:17:30 +00:00
|
|
|
// IF args have been provided, extract git tag info from them, otherwise
|
|
|
|
// rely on previously embedded metadata for git tags.
|
2023-02-16 17:33:47 +00:00
|
|
|
if len(os.Args) > 1 {
|
2023-02-17 19:17:30 +00:00
|
|
|
// see ./build/actors/pack.sh
|
|
|
|
// (optional) expected args are:
|
|
|
|
// $(GOCC) run ./gen/bundle $(VERSION) $(RELEASE) $(RELEASE_OVERRIDES)
|
|
|
|
// overrides are in the format network_name=override
|
|
|
|
gitTag := os.Args[2]
|
|
|
|
packedActorsVersion, err := strconv.Atoi(os.Args[1][1:])
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2023-02-16 21:01:45 +00:00
|
|
|
overrides := map[string]string{}
|
|
|
|
for _, override := range os.Args[3:] {
|
|
|
|
k, v := splitOverride(override)
|
|
|
|
overrides[k] = v
|
|
|
|
}
|
2023-02-16 17:33:47 +00:00
|
|
|
for _, m := range metadata {
|
2023-02-17 19:17:30 +00:00
|
|
|
if int(m.Version) == packedActorsVersion {
|
2023-02-16 21:01:45 +00:00
|
|
|
override, ok := overrides[m.Network]
|
|
|
|
if ok {
|
|
|
|
m.BundleGitTag = override
|
|
|
|
} else {
|
2023-02-17 19:17:30 +00:00
|
|
|
m.BundleGitTag = gitTag
|
2023-02-16 21:01:45 +00:00
|
|
|
}
|
2023-02-17 19:17:30 +00:00
|
|
|
} else {
|
|
|
|
m.BundleGitTag = getOldGitTagFromEmbeddedMetadata(m)
|
2023-02-16 17:33:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-07 02:23:23 +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
|
|
|
fi, err := os.Create("./build/builtin_actors_gen.go")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer fi.Close() //nolint
|
|
|
|
|
|
|
|
err = tmpl.Execute(fi, metadata)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2023-02-17 19:17:30 +00:00
|
|
|
|
|
|
|
func getOldGitTagFromEmbeddedMetadata(m *build.BuiltinActorsMetadata) string {
|
|
|
|
for _, v := range build.EmbeddedBuiltinActorsMetadata {
|
|
|
|
// if we agree on the manifestCid for the previously embedded metadata, use the previously set tag
|
|
|
|
if m.Version == v.Version && m.Network == v.Network && m.ManifestCid == v.ManifestCid {
|
|
|
|
return m.BundleGitTag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|