Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #72 from consensus-shipyard/adlrocha/load-ipc-bundle
Browse files Browse the repository at this point in the history
BundleOverride with `ipc-actors` type for automatic loading
  • Loading branch information
adlrocha authored Feb 16, 2023
2 parents 505664a + 1856a5b commit 2073a1f
Show file tree
Hide file tree
Showing 47 changed files with 508 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,4 +617,4 @@ workflows:
name: mir-consensus-tests
suite: consensus
go-test-flags: "-tags=spacenet -timeout 60m -run TestMirConsensus"
target: "./itests/mir_test.go"
target: "./itests/mir_test.go"
4 changes: 4 additions & 0 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"time"

"github.com/consensus-shipyard/go-ipc-types/subnetactor"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
blocks "github.com/ipfs/go-libipfs/blocks"
Expand Down Expand Up @@ -858,6 +859,9 @@ type FullNode interface {

RaftState(ctx context.Context) (*RaftStateData, error) //perm:read
RaftLeader(ctx context.Context) (peer.ID, error) //perm:read

// IPC-specific methods
IpcAddSubnetActor(ctx context.Context, wallet address.Address, params subnetactor.ConstructParams) (address.Address, error) //perm:write
}

// reverse interface to the client, called after EthSubscribe
Expand Down
7 changes: 4 additions & 3 deletions api/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"
"unicode"

"github.com/consensus-shipyard/go-ipc-types/subnetactor"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-graphsync"
Expand Down Expand Up @@ -401,6 +402,8 @@ func init() {
FromBlock: pstring("2301220"),
Address: []ethtypes.EthAddress{ethaddr},
})

addExample(subnetactor.ConsensusType(0))
}

func GetAPIType(name, pkg string) (i interface{}, t reflect.Type, permStruct []reflect.Type) {
Expand Down
34 changes: 26 additions & 8 deletions api/mocks/mock_full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 24 additions & 8 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions api/v0api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions api/v0api/v0mocks/mock_full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
57 changes: 54 additions & 3 deletions build/builtin_actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
//go:embed actors/*.tar.zst
var embeddedBuiltinActorReleases embed.FS

const IPCCarPath = "actors/ipc-actors.car"

//go:embed actors/ipc-actors.car
var ipcActorsFs embed.FS

func init() {
if BundleOverrides == nil {
BundleOverrides = make(map[actorstypes.Version]string)
Expand Down Expand Up @@ -61,9 +66,30 @@ func loadManifests(netw string) error {
var newMetadata []*BuiltinActorsMetadata
// First, prefer overrides.
for av, path := range BundleOverrides {
root, actorCids, err := readBundleManifestFromFile(path)
if err != nil {
return err
var (
root cid.Cid
actorCids map[string]cid.Cid
err error
)
// if the version bundle is to be overridden by the ipc-actors bundle
if IsIPCActorOverride(path) {
fi, err := ipcActorsFs.Open(IPCCarPath)
if err != nil {
return xerrors.Errorf("couldn't open ipc-actors.car: %w", err)
}

root, actorCids, err = readBundleManifest(fi)
if err != nil {
return err
}
fi.Close() //nolint

} else {
// else we use a path override
root, actorCids, err = readBundleManifestFromFile(path)
if err != nil {
return err
}
}
newMetadata = append(newMetadata, &BuiltinActorsMetadata{
Network: netw,
Expand Down Expand Up @@ -264,3 +290,28 @@ func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool)
return car, true
}
}

// GetIPCActorsBundle gets the specific bundle including ipc actors from the embedded car file.
func GetIPCActorsBundle(ctx context.Context, bs blockstore.Blockstore) (cid.Cid, error) {
f, err := ipcActorsFs.Open(IPCCarPath)
if err != nil {
return cid.Undef, xerrors.Errorf("error opening ipc-actors bundle: %w", err)
}
defer f.Close() //nolint

hdr, err := car.LoadCar(ctx, bs, f)
if err != nil {
return cid.Undef, xerrors.Errorf("error loading builtin actors bundle: %w", err)
}

if len(hdr.Roots) != 1 {
return cid.Undef, xerrors.Errorf("expected one root when loading actors bundle, got %d", len(hdr.Roots))
}
return hdr.Roots[0], nil
}

// IsIPCActorOverride checks if the override should point to the ipc-actors or
// some other generic path.
func IsIPCActorOverride(path string) bool {
return path == "ipc-actors"
}
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/gateway.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
4 changes: 3 additions & 1 deletion build/params_spacenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
)

var NetworkBundle = "devnet"
var BundleOverrides map[actorstypes.Version]string
var BundleOverrides = map[actorstypes.Version]string{
actorstypes.Version10: "ipc-actors",
}
var ActorDebugging = false

// FIXME: The following will be used to address this issue:
Expand Down
2 changes: 1 addition & 1 deletion chain/gen/genesis/f02_reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package genesis
import (
"context"

ipctypes "github.com/consensus-shipyard/go-ipc-types/types"
ipctypes "github.com/consensus-shipyard/go-ipc-types/sdk"
cbor "github.com/ipfs/go-ipld-cbor"
"golang.org/x/xerrors"

Expand Down
Loading

0 comments on commit 2073a1f

Please sign in to comment.