Skip to content

Commit

Permalink
Merge pull request #8642 from filecoin-project/feat/nv16-bundles
Browse files Browse the repository at this point in the history
[nv16] dynamic loading of builtin actor bundles
  • Loading branch information
vyzo authored May 12, 2022
2 parents f0867a9 + 68b280b commit 8a8fb56
Show file tree
Hide file tree
Showing 23 changed files with 395 additions and 288 deletions.
7 changes: 0 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ commands:
- run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev
- run: git submodule sync
- run: git submodule update --init
- fetch_builtin_actors
download-params:
steps:
- restore_cache:
Expand Down Expand Up @@ -84,12 +83,6 @@ commands:
name: fetch all tags
command: |
git fetch --all
fetch_builtin_actors:
steps:
- run:
name: fetch builtin actor bundles
command: |
build/builtin-actors/fetch-bundles.sh
packer_build:
description: "Run a packer build"
parameters:
Expand Down
7 changes: 0 additions & 7 deletions .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ commands:
- run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev
- run: git submodule sync
- run: git submodule update --init
- fetch_builtin_actors
download-params:
steps:
- restore_cache:
Expand Down Expand Up @@ -84,12 +83,6 @@ commands:
name: fetch all tags
command: |
git fetch --all
fetch_builtin_actors:
steps:
- run:
name: fetch builtin actor bundles
command: |
build/builtin-actors/fetch-bundles.sh
packer_build:
description: "Run a packer build"
parameters:
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ build/.update-modules:

# end git modules

# builtin actor bundles
builtin-actor-bundles:
./build/builtin-actors/fetch-bundles.sh

BUILD_DEPS+=builtin-actor-bundles

.PHONY: builtin-actor-bundles

## MAIN BINARIES

CLEAN+=build/.update-modules
Expand All @@ -79,15 +71,19 @@ debug: GOFLAGS+=-tags=debug
debug: build-devnets

2k: GOFLAGS+=-tags=2k
2k: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=devnet
2k: build-devnets

calibnet: GOFLAGS+=-tags=calibnet
calibnet: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=calibrationnet
calibnet: build-devnets

butterflynet: GOFLAGS+=-tags=butterflynet
butterflynet: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=butterflynet
butterflynet: build-devnets

interopnet: GOFLAGS+=-tags=interopnet
interopnet: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=caterpillarnet
interopnet: build-devnets

lotus: $(BUILD_DEPS)
Expand Down
3 changes: 0 additions & 3 deletions build/builtin-actors/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions build/builtin-actors/bundles.env

This file was deleted.

85 changes: 0 additions & 85 deletions build/builtin-actors/fetch-bundles.sh

This file was deleted.

27 changes: 27 additions & 0 deletions build/builtin_actors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package build

import (
"bytes"

"github.com/filecoin-project/lotus/chain/actors"

"github.com/BurntSushi/toml"
)

var BuiltinActorReleases map[actors.Version]string

func init() {
BuiltinActorReleases = make(map[actors.Version]string)

spec := BundleSpec{}

r := bytes.NewReader(BuiltinActorBundles)
_, err := toml.DecodeReader(r, &spec)
if err != nil {
panic(err)
}

for _, b := range spec.Bundles {
BuiltinActorReleases[b.Version] = b.Release
}
}
22 changes: 0 additions & 22 deletions build/builtin_actors_2k.go

This file was deleted.

22 changes: 0 additions & 22 deletions build/builtin_actors_butterfly.go

This file was deleted.

22 changes: 0 additions & 22 deletions build/builtin_actors_calibnet.go

This file was deleted.

22 changes: 0 additions & 22 deletions build/builtin_actors_interop.go

This file was deleted.

22 changes: 0 additions & 22 deletions build/builtin_actors_mainnet.go

This file was deleted.

21 changes: 21 additions & 0 deletions build/bundle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package build

import (
_ "embed"

"github.com/filecoin-project/lotus/chain/actors"
)

var NetworkBundle string

//go:embed bundles.toml
var BuiltinActorBundles []byte

type BundleSpec struct {
Bundles []Bundle
}

type Bundle struct {
Version actors.Version
Release string
}
3 changes: 3 additions & 0 deletions build/bundles.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[bundles]]
version = 8
release = "b71c2ec785aec23d"
9 changes: 0 additions & 9 deletions chain/actors/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,3 @@ func LoadBundle(ctx context.Context, bs blockstore.Blockstore, av Version, data

return nil
}

func LoadManifestFromBundle(ctx context.Context, bs blockstore.Blockstore, av Version, data []byte) error {
if err := LoadBundle(ctx, bs, av, data); err != nil {
return err
}

cborStore := cbor.NewCborStore(bs)
return LoadManifests(ctx, cborStore)
}
13 changes: 6 additions & 7 deletions cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ package cli

import (
"context"
"fmt"

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/node/bundle"
)

func init() {
// preload manifest so that we have the correct code CID inventory for cli since that doesn't
// go through CI
if len(build.BuiltinActorsV8Bundle()) > 0 {
bs := blockstore.NewMemory()
// TODO loading the bundle in every cli invocation adds some latency; we should figure out a way
// to load actor CIDs without incurring this hit.
bs := blockstore.NewMemory()

if err := actors.LoadManifestFromBundle(context.TODO(), bs, actors.Version8, build.BuiltinActorsV8Bundle()); err != nil {
panic(fmt.Errorf("error loading actor manifest: %w", err))
}
if err := bundle.FetchAndLoadBundles(context.Background(), bs, build.BuiltinActorReleases); err != nil {
panic(err)
}
}
Loading

0 comments on commit 8a8fb56

Please # to comment.