Skip to content

Commit

Permalink
Merge pull request #8521 from filecoin-project/fix/itests-nv16
Browse files Browse the repository at this point in the history
[nv16] improve itest situation and preload manifests in cli
  • Loading branch information
arajasek authored Apr 21, 2022
2 parents b60d795 + 270f962 commit a7dc3f5
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 30 deletions.
2 changes: 1 addition & 1 deletion build/builtin-actors/bundles.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
actors7_release=""
actors8_release=a9635268e3b359bd
actors8_release=5921189441f18b88
10 changes: 9 additions & 1 deletion chain/actors/builtin/multisig/message.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ func (m message{{.v}}) Create(
return nil, actErr
}

{{if (le .v 7)}}
actorCodeID := builtin{{.v}}.MultisigActorCodeID
{{else}}
actorCodeID, ok := actors.GetActorCodeID(actors.Version{{.v}}, "multisig")
if !ok {
return nil, xerrors.Errorf("error getting actor multisig code id for actor version %d", {{.v}})
}
{{end}}
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init{{.v}}.ExecParams{
CodeCID: builtin{{.v}}.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message0.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ func (m message0) Create(
return nil, actErr
}

actorCodeID := builtin0.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init0.ExecParams{
CodeCID: builtin0.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message2.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func (m message2) Create(
return nil, actErr
}

actorCodeID := builtin2.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init2.ExecParams{
CodeCID: builtin2.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message3.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func (m message3) Create(
return nil, actErr
}

actorCodeID := builtin3.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init3.ExecParams{
CodeCID: builtin3.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message4.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func (m message4) Create(
return nil, actErr
}

actorCodeID := builtin4.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init4.ExecParams{
CodeCID: builtin4.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message5.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func (m message5) Create(
return nil, actErr
}

actorCodeID := builtin5.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init5.ExecParams{
CodeCID: builtin5.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message6.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func (m message6) Create(
return nil, actErr
}

actorCodeID := builtin6.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init6.ExecParams{
CodeCID: builtin6.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
4 changes: 3 additions & 1 deletion chain/actors/builtin/multisig/message7.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ func (m message7) Create(
return nil, actErr
}

actorCodeID := builtin7.MultisigActorCodeID

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init7.ExecParams{
CodeCID: builtin7.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
7 changes: 6 additions & 1 deletion chain/actors/builtin/multisig/message8.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ func (m message8) Create(
return nil, actErr
}

actorCodeID, ok := actors.GetActorCodeID(actors.Version8, "multisig")
if !ok {
return nil, xerrors.Errorf("error getting actor multisig code id for actor version %d", 8)
}

// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init8.ExecParams{
CodeCID: builtin8.MultisigActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: enc,
}

Expand Down
22 changes: 13 additions & 9 deletions chain/actors/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ var manifests map[Version]*manifest.Manifest
var actorMeta map[cid.Cid]actorEntry

var (
loadOnce sync.Once
loadError error

manifestMx sync.Mutex
manifestMx sync.RWMutex
)

type actorEntry struct {
Expand All @@ -44,17 +41,18 @@ func AddManifest(av Version, manifestCid cid.Cid) {
}

func GetManifest(av Version) (cid.Cid, bool) {
manifestMx.Lock()
defer manifestMx.Unlock()
manifestMx.RLock()
defer manifestMx.RUnlock()

c, ok := manifestCids[av]
return c, ok
}

func LoadManifests(ctx context.Context, store cbor.IpldStore) error {
// tests may invoke this concurrently, so we wrap it in a sync.Once
loadOnce.Do(func() { loadError = loadManifests(ctx, store) })
return loadError
manifestMx.Lock()
defer manifestMx.Unlock()

return loadManifests(ctx, store)
}

func loadManifests(ctx context.Context, store cbor.IpldStore) error {
Expand Down Expand Up @@ -87,6 +85,9 @@ func loadManifests(ctx context.Context, store cbor.IpldStore) error {
}

func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
manifestMx.RLock()
defer manifestMx.RUnlock()

mf, ok := manifests[av]
if ok {
return mf.Get(name)
Expand All @@ -96,6 +97,9 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
}

func GetActorMetaByCode(c cid.Cid) (string, Version, bool) {
manifestMx.RLock()
defer manifestMx.RUnlock()

entry, ok := actorMeta[c]
if !ok {
return "", -1, false
Expand Down
1 change: 0 additions & 1 deletion chain/vm/fvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ type FVM struct {
}

func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) {
log.Info("using the FVM, this is experimental!")
circToReport := opts.FilVested
// For v14 (and earlier), we perform the FilVested portion of the calculation, and let the FVM dynamically do the rest
// v15 and after, the circ supply is always constant per epoch, so we calculate the base and report it at creation
Expand Down
22 changes: 22 additions & 0 deletions cli/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cli

import (
"context"
"fmt"

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

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()

if err := actors.LoadManifestFromBundle(context.TODO(), bs, actors.Version8, build.BuiltinActorsV8Bundle()); err != nil {
panic(fmt.Errorf("error loading actor manifest: %w", err))
}
}
}
12 changes: 2 additions & 10 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,8 @@ func (n *Ensemble) Start() *Ensemble {
// this is a miner created after genesis, so it won't have a preseal.
// we need to create it on chain.

// we get the proof type for the requested sector size, for
// the current network version.
// nv, err := m.FullNode.FullNode.StateNetworkVersion(ctx, types.EmptyTSK)
// require.NoError(n.t, err)

// TODO this doesn't currently work with the FVM -- we need to specify policy somehow
// proofType, err := miner.WindowPoStProofTypeFromSectorSize(m.options.sectorSize)
// require.NoError(n.t, err)
// so do this instead, which works:
proofType := abi.RegisteredPoStProof_StackedDrgWindow64GiBV1
proofType, err := miner.WindowPoStProofTypeFromSectorSize(m.options.sectorSize)
require.NoError(n.t, err)

params, aerr := actors.SerializeParams(&power3.CreateMinerParams{
Owner: m.OwnerKey.Address,
Expand Down

0 comments on commit a7dc3f5

Please sign in to comment.