Skip to content

Commit

Permalink
fix: make compatible actor
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Jul 21, 2022
1 parent bd8be91 commit 7308f16
Show file tree
Hide file tree
Showing 19 changed files with 392 additions and 601 deletions.
8 changes: 3 additions & 5 deletions pkg/gen/genesis/f00_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (

"github.com/filecoin-project/go-state-types/manifest"

"github.com/filecoin-project/venus/venus-shared/actors/builtin"

"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/system"
Expand Down Expand Up @@ -53,9 +51,9 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi
return nil, err
}

actcid, err := builtin.GetSystemActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.SystemKey)
if !found {
return nil, fmt.Errorf("failed to get system actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
7 changes: 3 additions & 4 deletions pkg/gen/genesis/f01_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/filecoin-project/go-state-types/big"

"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"

cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
Expand Down Expand Up @@ -174,9 +173,9 @@ func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, i
return 0, nil, nil, err
}

actcid, err := builtin.GetInitActorCodeID(av)
if err != nil {
return 0, nil, nil, err
actcid, found := actors.GetActorCodeID(av, actors.InitKey)
if !found {
return 0, nil, nil, fmt.Errorf("failed to get init actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/genesis/f02_reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package genesis

import (
"context"
"fmt"

"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/reward"
"github.com/filecoin-project/venus/venus-shared/types"

Expand All @@ -29,9 +29,9 @@ func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int
return nil, err
}

actcid, err := builtin.GetRewardActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.RewardKey)
if !found {
return nil, fmt.Errorf("failed to get reward actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/genesis/f03_cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package genesis

import (
"context"
"fmt"

"github.com/filecoin-project/go-state-types/big"
cbor "github.com/ipfs/go-ipld-cbor"

"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/cron"

bstore "github.com/filecoin-project/venus/pkg/util/blockstoreutil"
Expand All @@ -27,9 +27,9 @@ func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version
return nil, err
}

actcid, err := builtin.GetCronActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.CronKey)
if !found {
return nil, fmt.Errorf("failed to get cron actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/genesis/f04_power.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package genesis

import (
"context"
"fmt"

"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/power"

"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"

cbor "github.com/ipfs/go-ipld-cbor"

Expand All @@ -29,9 +29,9 @@ func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors
return nil, err
}

actcid, err := builtin.GetPowerActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.PowerKey)
if !found {
return nil, fmt.Errorf("failed to get power actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/genesis/f05_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package genesis

import (
"context"
"fmt"

"github.com/filecoin-project/go-state-types/big"
cbor "github.com/ipfs/go-ipld-cbor"

"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/market"

bstore "github.com/filecoin-project/venus/pkg/util/blockstoreutil"
Expand All @@ -27,9 +27,9 @@ func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actor
return nil, err
}

actcid, err := builtin.GetMarketActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.MarketKey)
if !found {
return nil, fmt.Errorf("failed to get market actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/genesis/f06_vreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package genesis

import (
"context"
"fmt"

"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/verifreg"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -42,9 +42,9 @@ func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av ac
return nil, err
}

actcid, err := builtin.GetVerifregActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.VerifregKey)
if !found {
return nil, fmt.Errorf("failed to get verifreg actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down
12 changes: 6 additions & 6 deletions pkg/gen/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ func makeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version
return nil, err
}

actcid, err := builtin.GetAccountActorCodeID(av)
if err != nil {
return nil, err
actcid, found := actors.GetActorCodeID(av, actors.AccountKey)
if !found {
return nil, fmt.Errorf("failed to get account actor code ID for actors version %d", av)
}

act := &types.Actor{
Expand Down Expand Up @@ -467,9 +467,9 @@ func createMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *tree.
return err
}

actcid, err := builtin.GetMultisigActorCodeID(av)
if err != nil {
return err
actcid, found := actors.GetActorCodeID(av, actors.MultisigKey)
if !found {
return fmt.Errorf("failed to get multisig actor code ID for actors version %d", av)
}

err = state.SetActor(ctx, ida, &types.Actor{
Expand Down
6 changes: 3 additions & 3 deletions pkg/vm/vmcontext/invocation_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ func (ctx *invocationContext) resolveTarget(target address.Address) (*types.Acto
if err != nil {
panic(err)
}
actorCode, err := builtin.GetAccountActorCodeID(ver)
if err != nil {
panic(err)
actorCode, found := actors.GetActorCodeID(ver, actors.AccountKey)
if !found {
panic(fmt.Errorf("failed to get account actor code ID for actors version %d", ver))
}
ctx.CreateActor(actorCode, targetIDAddr)

Expand Down
Loading

0 comments on commit 7308f16

Please sign in to comment.