Centralize some params in builtin
This commit is contained in:
parent
dd65e57d4b
commit
be9d23b329
@ -18,6 +18,9 @@ import (
|
||||
smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
||||
)
|
||||
|
||||
var SystemActorAddr = builtin0.SystemActorAddr
|
||||
var BurntFundsActorAddr = builtin0.BurntFundsActorAddr
|
||||
|
||||
// TODO: Why does actors have 2 different versions of this?
|
||||
type SectorInfo = proof0.SectorInfo
|
||||
type PoStProof = proof0.PoStProof
|
||||
@ -66,3 +69,20 @@ func ActorNameByCode(c cid.Cid) string {
|
||||
func IsBuiltinActor(c cid.Cid) bool {
|
||||
return builtin0.IsBuiltinActor(c) || builtin2.IsBuiltinActor(c)
|
||||
}
|
||||
|
||||
func IsAccountActor(c cid.Cid) bool {
|
||||
return c == builtin0.AccountActorCodeID || c == builtin2.AccountActorCodeID
|
||||
}
|
||||
|
||||
func IsStorageMinerActor(c cid.Cid) bool {
|
||||
return c == builtin0.StorageMinerActorCodeID || c == builtin2.StorageMinerActorCodeID
|
||||
}
|
||||
|
||||
func IsMultisigActor(c cid.Cid) bool {
|
||||
return c == builtin0.MultisigActorCodeID || c == builtin2.MultisigActorCodeID
|
||||
|
||||
}
|
||||
|
||||
func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
return c == builtin0.PaymentChannelActorCodeID || c == builtin2.PaymentChannelActorCodeID
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
|
||||
@ -858,7 +860,7 @@ func (sm *StateManager) setupGenesisActors(ctx context.Context) error {
|
||||
|
||||
totalsByEpoch := make(map[abi.ChainEpoch]abi.TokenAmount)
|
||||
err = sTree.ForEach(func(kaddr address.Address, act *types.Actor) error {
|
||||
if act.IsMultisigActor() {
|
||||
if builtin.IsMultisigActor(act.Code) {
|
||||
s, err := multisig.Load(sm.cs.Store(ctx), act)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -890,7 +892,7 @@ func (sm *StateManager) setupGenesisActors(ctx context.Context) error {
|
||||
totalsByEpoch[ud] = ib
|
||||
}
|
||||
|
||||
} else if act.IsAccountActor() {
|
||||
} else if builtin.IsAccountActor(act.Code) {
|
||||
// should exclude burnt funds actor and "remainder account actor"
|
||||
// should only ever be "faucet" accounts in testnets
|
||||
if kaddr == builtin0.BurntFundsActorAddr {
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||
@ -1080,7 +1082,7 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock
|
||||
return xerrors.Errorf("failed to get actor: %w", err)
|
||||
}
|
||||
|
||||
if !act.IsAccountActor() {
|
||||
if !builtin.IsAccountActor(act.Code) {
|
||||
return xerrors.New("Sender must be an account actor")
|
||||
}
|
||||
nonces[m.From] = act.Nonce
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
)
|
||||
|
||||
var ErrActorNotFound = errors.New("actor not found")
|
||||
@ -17,19 +15,3 @@ type Actor struct {
|
||||
Nonce uint64
|
||||
Balance BigInt
|
||||
}
|
||||
|
||||
func (a *Actor) IsAccountActor() bool {
|
||||
return a.Code == builtin0.AccountActorCodeID
|
||||
}
|
||||
|
||||
func (a *Actor) IsStorageMinerActor() bool {
|
||||
return a.Code == builtin0.StorageMinerActorCodeID
|
||||
}
|
||||
|
||||
func (a *Actor) IsMultisigActor() bool {
|
||||
return a.Code == builtin0.MultisigActorCodeID
|
||||
}
|
||||
|
||||
func (a *Actor) IsPaymentChannelActor() bool {
|
||||
return a.Code == builtin0.PaymentChannelActorCodeID
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
@ -210,7 +212,7 @@ func DecodeParams(b []byte, out interface{}) error {
|
||||
}
|
||||
|
||||
func DumpActorState(act *types.Actor, b []byte) (interface{}, error) {
|
||||
if act.IsAccountActor() { // Account code special case
|
||||
if builtin.IsAccountActor(act.Code) { // Account code special case
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
block "github.com/ipfs/go-block-format"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
@ -23,7 +25,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
@ -396,7 +397,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
||||
}
|
||||
|
||||
// this should never happen, but is currently still exercised by some tests
|
||||
if !fromActor.IsAccountActor() {
|
||||
if !builtin.IsAccountActor(fromActor.Code) {
|
||||
gasOutputs := ZeroGasOutputs()
|
||||
gasOutputs.MinerPenalty = minerPenaltyAmount
|
||||
return &ApplyRet{
|
||||
|
@ -9,6 +9,10 @@ import (
|
||||
"strconv"
|
||||
"text/tabwriter"
|
||||
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
@ -20,7 +24,6 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
|
||||
@ -356,7 +359,7 @@ var msigProposeCmd = &cli.Command{
|
||||
return fmt.Errorf("failed to look up multisig %s: %w", msig, err)
|
||||
}
|
||||
|
||||
if !act.IsMultisigActor() {
|
||||
if !builtin.IsMultisigActor(act.Code) {
|
||||
return fmt.Errorf("actor %s is not a multisig actor", msig)
|
||||
}
|
||||
|
||||
@ -1029,7 +1032,7 @@ var msigLockProposeCmd = &cli.Command{
|
||||
return actErr
|
||||
}
|
||||
|
||||
msgCid, err := api.MsigPropose(ctx, msig, msig, big.Zero(), from, uint64(builtin.MethodsMultisig.LockBalance), params)
|
||||
msgCid, err := api.MsigPropose(ctx, msig, msig, big.Zero(), from, uint64(builtin2.MethodsMultisig.LockBalance), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1126,7 +1129,7 @@ var msigLockApproveCmd = &cli.Command{
|
||||
return actErr
|
||||
}
|
||||
|
||||
msgCid, err := api.MsigApprove(ctx, msig, txid, prop, msig, big.Zero(), from, uint64(builtin.MethodsMultisig.LockBalance), params)
|
||||
msgCid, err := api.MsigApprove(ctx, msig, txid, prop, msig, big.Zero(), from, uint64(builtin2.MethodsMultisig.LockBalance), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1218,7 +1221,7 @@ var msigLockCancelCmd = &cli.Command{
|
||||
return actErr
|
||||
}
|
||||
|
||||
msgCid, err := api.MsigCancel(ctx, msig, txid, msig, big.Zero(), from, uint64(builtin.MethodsMultisig.LockBalance), params)
|
||||
msgCid, err := api.MsigCancel(ctx, msig, txid, msig, big.Zero(), from, uint64(builtin2.MethodsMultisig.LockBalance), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -28,7 +30,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/apibstore"
|
||||
|
@ -12,7 +12,9 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
@ -375,14 +377,14 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu
|
||||
continue
|
||||
}
|
||||
|
||||
if !a.IsStorageMinerActor() {
|
||||
if !builtin.IsStorageMinerActor(a.Code) {
|
||||
continue
|
||||
}
|
||||
|
||||
var messageMethod string
|
||||
|
||||
switch m.Method {
|
||||
case builtin.MethodsMiner.ProveCommitSector:
|
||||
case builtin0.MethodsMiner.ProveCommitSector:
|
||||
if !r.proveCommitEnabled {
|
||||
continue
|
||||
}
|
||||
@ -429,7 +431,7 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu
|
||||
}
|
||||
|
||||
refundValue = collateral
|
||||
case builtin.MethodsMiner.PreCommitSector:
|
||||
case builtin0.MethodsMiner.PreCommitSector:
|
||||
if !r.preCommitEnabled {
|
||||
continue
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
lotusbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"
|
||||
|
||||
@ -97,7 +97,7 @@ var chainBalanceCmd = &cli.Command{
|
||||
Type: string(act.Code.Hash()[2:]),
|
||||
}
|
||||
|
||||
if act.IsStorageMinerActor() {
|
||||
if builtin.IsStorageMinerActor(act.Code) {
|
||||
pow, err := api.StateMinerPower(ctx, addr, tsk)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to get power: %w", err)
|
||||
@ -198,7 +198,7 @@ var chainBalanceStateCmd = &cli.Command{
|
||||
PreCommits: types.FIL(big.NewInt(0)),
|
||||
}
|
||||
|
||||
if minerInfo && act.IsStorageMinerActor() {
|
||||
if minerInfo && builtin.IsStorageMinerActor(act.Code) {
|
||||
pow, _, _, err := stmgr.GetPowerRaw(ctx, sm, sroot, addr)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to get power: %w", err)
|
||||
@ -322,7 +322,7 @@ var chainPledgeCmd = &cli.Command{
|
||||
}
|
||||
|
||||
var (
|
||||
powerSmoothed lotusbuiltin.FilterEstimate
|
||||
powerSmoothed builtin.FilterEstimate
|
||||
pledgeCollateral abi.TokenAmount
|
||||
)
|
||||
if act, err := state.GetActor(power.Address); err != nil {
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"os"
|
||||
"sort"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/ipfs/go-datastore"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
@ -95,14 +97,14 @@ var genesisVerifyCmd = &cli.Command{
|
||||
|
||||
if err := stree.ForEach(func(addr address.Address, act *types.Actor) error {
|
||||
switch {
|
||||
case act.IsStorageMinerActor():
|
||||
case builtin.IsStorageMinerActor(act.Code):
|
||||
_, err := miner.Load(store, act)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("miner actor: %w", err)
|
||||
}
|
||||
// TODO: actually verify something here?
|
||||
kminers[addr] = minerInfo{}
|
||||
case act.IsMultisigActor():
|
||||
case builtin.IsMultisigActor(act.Code):
|
||||
st, err := multisig.Load(store, act)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("multisig actor: %w", err)
|
||||
@ -123,7 +125,7 @@ var genesisVerifyCmd = &cli.Command{
|
||||
Threshold: threshold,
|
||||
}
|
||||
msigAddrs = append(msigAddrs, addr)
|
||||
case act.IsAccountActor():
|
||||
case builtin.IsAccountActor(act.Code):
|
||||
st, err := account.Load(store, act)
|
||||
if err != nil {
|
||||
// TODO: magik6k: this _used_ to log instead of failing, why?
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
)
|
||||
@ -122,7 +123,7 @@ var mpoolStatsCmd = &cli.Command{
|
||||
return false, err
|
||||
}
|
||||
|
||||
ism := act.IsStorageMinerActor()
|
||||
ism := builtin.IsStorageMinerActor(act.Code)
|
||||
mcache[addr] = ism
|
||||
return ism, nil
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"math/rand"
|
||||
"sort"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -182,7 +184,7 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message,
|
||||
return res.MsgRct.GasUsed, nil
|
||||
}
|
||||
|
||||
if !act.IsPaymentChannelActor() {
|
||||
if !builtin.IsPaymentChannelActor(act.Code) {
|
||||
return res.MsgRct.GasUsed, nil
|
||||
}
|
||||
if msgIn.Method != builtin0.MethodsPaych.Collect {
|
||||
|
Loading…
Reference in New Issue
Block a user