Merge pull request #1231 from filecoin-project/feat/update-msig-refs

actors: Drop refs to multisig_actor.go
This commit is contained in:
Łukasz Magiera 2020-02-06 21:01:43 +01:00 committed by GitHub
commit 3aa521600a
10 changed files with 50 additions and 168 deletions

View File

@ -1,128 +0,0 @@
package actors
import (
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
)
type MultiSigActor struct{}
type MultiSigActorState = samsig.MultiSigActorState
type MultiSigTransaction = samsig.MultiSigTransaction
type TxnID = samsig.TxnID
type musigMethods struct {
MultiSigConstructor uint64
Propose uint64
Approve uint64
Cancel uint64
ClearCompleted uint64
AddSigner uint64
RemoveSigner uint64
SwapSigner uint64
ChangeRequirement uint64
}
var MultiSigMethods = musigMethods{1, 2, 3, 4, 5, 6, 7, 8, 9}
type MultiSigConstructorParams = samsig.ConstructorParams
type MultiSigProposeParams = samsig.ProposeParams
type MultiSigTxID = samsig.TxnIDParams
type MultiSigAddSignerParam = samsig.AddSignerParams
type MultiSigRemoveSignerParam = samsig.RemoveSignerParams
type MultiSigSwapSignerParams = samsig.SwapSignerParams
type MultiSigChangeReqParams = samsig.ChangeNumApprovalsThresholdParams
/*
func (msa MultiSigActor) Exports() []interface{} {
return []interface{}{
1: msa.MultiSigConstructor,
2: msa.Propose,
3: msa.Approve,
4: msa.Cancel,
//5: msa.ClearCompleted,
6: msa.AddSigner,
7: msa.RemoveSigner,
8: msa.SwapSigner,
9: msa.ChangeRequirement,
}
}
func (MultiSigActor) MultiSigConstructor(act *types.Actor, vmctx types.VMContext,
params *MultiSigConstructorParams) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).Constructor(shim, params)
})
}
func (msa MultiSigActor) Propose(act *types.Actor, vmctx types.VMContext,
params *MultiSigProposeParams) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).Propose(shim, params)
})
}
func (msa MultiSigActor) Approve(act *types.Actor, vmctx types.VMContext,
params *MultiSigTxID) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).Approve(shim, params)
})
}
func (msa MultiSigActor) Cancel(act *types.Actor, vmctx types.VMContext,
params *MultiSigTxID) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).Cancel(shim, params)
})
}
func (msa MultiSigActor) AddSigner(act *types.Actor, vmctx types.VMContext,
params *MultiSigAddSignerParam) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).AddSigner(shim, params)
})
}
func (msa MultiSigActor) RemoveSigner(act *types.Actor, vmctx types.VMContext,
params *MultiSigRemoveSignerParam) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).RemoveSigner(shim, params)
})
}
func (msa MultiSigActor) SwapSigner(act *types.Actor, vmctx types.VMContext,
params *MultiSigSwapSignerParams) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).SwapSigner(shim, params)
})
}
func (msa MultiSigActor) ChangeRequirement(act *types.Actor, vmctx types.VMContext,
params *MultiSigChangeReqParams) ([]byte, ActorError) {
shim := &runtimeShim{vmctx: vmctx}
return shim.shimCall(func() interface{} {
return (&samsig.MultiSigActor{}).ChangeNumApprovalsThreshold(shim, params)
})
}
*/

View File

@ -3,6 +3,8 @@ package actors_test
import (
"testing"
"github.com/filecoin-project/specs-actors/actors/builtin"
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/stretchr/testify/assert"
cbg "github.com/whyrusleeping/cbor-gen"
@ -26,7 +28,7 @@ func TestMultiSigCreate(t *testing.T) {
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.MultisigCodeCid,
&actors.MultiSigConstructorParams{
&samsig.ConstructorParams{
Signers: []address.Address{creatorAddr, sig1Addr, sig2Addr},
NumApprovalsThreshold: 2,
})
@ -53,7 +55,7 @@ func TestMultiSigOps(t *testing.T) {
HarnessAddr(&outsideAddr, 100000),
HarnessActor(&multSigAddr, &creatorAddr, actors.MultisigCodeCid,
func() cbg.CBORMarshaler {
return &actors.MultiSigConstructorParams{
return &samsig.ConstructorParams{
Signers: []address.Address{creatorAddr, sig1Addr, sig2Addr},
NumApprovalsThreshold: 2,
}
@ -73,22 +75,22 @@ func TestMultiSigOps(t *testing.T) {
{
// Transfer funds outside of multsig
const sendVal = 1000
ret, _ := h.Invoke(t, creatorAddr, multSigAddr, actors.MultiSigMethods.Propose,
&actors.MultiSigProposeParams{
ret, _ := h.Invoke(t, creatorAddr, multSigAddr, uint64(builtin.MethodsMultisig.Propose),
&samsig.ProposeParams{
To: outsideAddr,
Value: big.NewInt(sendVal),
})
ApplyOK(t, ret)
var txIDParam actors.MultiSigTxID
var txIDParam samsig.TxnIDParams
err := cbor.DecodeInto(ret.Return, &txIDParam.ID)
assert.NoError(t, err, "decoding txid")
ret, _ = h.Invoke(t, outsideAddr, multSigAddr, actors.MultiSigMethods.Approve,
ret, _ = h.Invoke(t, outsideAddr, multSigAddr, uint64(builtin.MethodsMultisig.Approve),
&txIDParam)
assert.Equal(t, uint8(18), ret.ExitCode, "outsideAddr should not approve")
h.AssertBalanceChange(t, multSigAddr, 0)
ret2, _ := h.Invoke(t, sig1Addr, multSigAddr, actors.MultiSigMethods.Approve,
ret2, _ := h.Invoke(t, sig1Addr, multSigAddr, uint64(builtin.MethodsMultisig.Approve),
&txIDParam)
ApplyOK(t, ret2)

View File

@ -22,7 +22,7 @@ type Message struct {
GasPrice BigInt
GasLimit BigInt
Method uint64
Method uint64 // TODO: decide
Params []byte
}

View File

@ -10,7 +10,9 @@ import (
vaddress "github.com/filecoin-project/chain-validation/pkg/state/address"
vtypes "github.com/filecoin-project/chain-validation/pkg/state/types"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
)
@ -83,14 +85,14 @@ var methods = []uint64{
vchain.StorageMinerGetPeerID: actors.MAMethods.GetPeerID,
vchain.StorageMinerGetSectorSize: actors.MAMethods.GetSectorSize,
vchain.MultiSigConstructor: actors.MultiSigMethods.MultiSigConstructor,
vchain.MultiSigPropose: actors.MultiSigMethods.Propose,
vchain.MultiSigApprove: actors.MultiSigMethods.Approve,
vchain.MultiSigCancel: actors.MultiSigMethods.Cancel,
vchain.MultiSigClearCompleted: actors.MultiSigMethods.ClearCompleted,
vchain.MultiSigAddSigner: actors.MultiSigMethods.AddSigner,
vchain.MultiSigRemoveSigner: actors.MultiSigMethods.RemoveSigner,
vchain.MultiSigSwapSigner: actors.MultiSigMethods.SwapSigner,
vchain.MultiSigChangeRequirement: actors.MultiSigMethods.ChangeRequirement,
vchain.MultiSigConstructor: uint64(builtin.MethodsMultisig.Constructor),
vchain.MultiSigPropose: uint64(builtin.MethodsMultisig.Propose),
vchain.MultiSigApprove: uint64(builtin.MethodsMultisig.Approve),
vchain.MultiSigCancel: uint64(builtin.MethodsMultisig.Cancel),
vchain.MultiSigClearCompleted: uint64(builtin.MethodsMultisig.ClearCompleted),
vchain.MultiSigAddSigner: uint64(builtin.MethodsMultisig.AddSigner),
vchain.MultiSigRemoveSigner: uint64(builtin.MethodsMultisig.RemoveSigner),
vchain.MultiSigSwapSigner: uint64(builtin.MethodsMultisig.SwapSigner),
vchain.MultiSigChangeRequirement: uint64(builtin.MethodsMultisig.ChangeNumApprovalsThreshold),
// More to follow...
}

View File

@ -10,6 +10,10 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/sigs"
)

View File

@ -12,17 +12,20 @@ import (
"text/tabwriter"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/apibstore"
actors "github.com/filecoin-project/lotus/chain/actors"
types "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/apibstore"
actors "github.com/filecoin-project/lotus/chain/actors"
types "github.com/filecoin-project/lotus/chain/types"
)
var multisigCmd = &cli.Command{
@ -90,7 +93,7 @@ var msigCreateCmd = &cli.Command{
}
// Set up constructor parameters for multisig
msigParams := &actors.MultiSigConstructorParams{
msigParams := &samsig.ConstructorParams{
Signers: addrs,
NumApprovalsThreshold: required,
}
@ -183,7 +186,7 @@ var msigInspectCmd = &cli.Command{
return err
}
var mstate actors.MultiSigActorState
var mstate samsig.MultiSigActorState
if err := mstate.UnmarshalCBOR(bytes.NewReader(obj)); err != nil {
return err
}
@ -223,7 +226,7 @@ var msigInspectCmd = &cli.Command{
},
}
func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (map[int64]*actors.MultiSigTransaction, error) {
func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (map[int64]*samsig.MultiSigTransaction, error) {
bs := apibstore.NewAPIBlockstore(lapi)
cst := cbor.NewCborStore(bs)
@ -232,10 +235,10 @@ func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (
return nil, err
}
txs := make(map[int64]*actors.MultiSigTransaction)
txs := make(map[int64]*samsig.MultiSigTransaction)
err = nd.ForEach(ctx, func(k string, val interface{}) error {
d := val.(*cbg.Deferred)
var tx actors.MultiSigTransaction
var tx samsig.MultiSigTransaction
if err := tx.UnmarshalCBOR(bytes.NewReader(d.Raw)); err != nil {
return err
}
@ -252,7 +255,7 @@ func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (
return txs, nil
}
func state(tx *actors.MultiSigTransaction) string {
func state(tx *samsig.MultiSigTransaction) string {
/* // TODO(why): I strongly disagree with not having these... but i need to move forward
if tx.Complete {
return "done"
@ -315,7 +318,7 @@ var msigProposeCmd = &cli.Command{
params = p
}
enc, err := actors.SerializeParams(&actors.MultiSigProposeParams{
enc, err := actors.SerializeParams(&samsig.ProposeParams{
To: dest,
Value: abi.TokenAmount(types.BigInt(value)),
Method: abi.MethodNum(method),
@ -344,7 +347,7 @@ var msigProposeCmd = &cli.Command{
To: msig,
From: from,
Value: types.NewInt(0),
Method: actors.MultiSigMethods.Propose,
Method: uint64(builtin.MethodsMultisig.Propose),
Params: enc,
GasLimit: types.NewInt(100000),
GasPrice: types.NewInt(1),
@ -403,8 +406,8 @@ var msigApproveCmd = &cli.Command{
return err
}
enc, err := actors.SerializeParams(&actors.MultiSigTxID{
ID: actors.TxnID(txid),
enc, err := actors.SerializeParams(&samsig.TxnIDParams{
ID: samsig.TxnID(txid),
})
if err != nil {
return err
@ -429,7 +432,7 @@ var msigApproveCmd = &cli.Command{
To: msig,
From: from,
Value: types.NewInt(0),
Method: actors.MultiSigMethods.Approve,
Method: uint64(builtin.MethodsMultisig.Approve),
Params: enc,
GasLimit: types.NewInt(100000),
GasPrice: types.NewInt(1),

View File

@ -1,15 +1,12 @@
package main
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"encoding/json"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
@ -20,6 +17,7 @@ import (
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
"github.com/filecoin-project/lotus/genesis"

2
go.mod
View File

@ -21,7 +21,7 @@ require (
github.com/filecoin-project/go-paramfetch v0.0.1
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb62
github.com/filecoin-project/go-statestore v0.1.0
github.com/filecoin-project/specs-actors v0.0.0-20200204204849-b1474eeb2fb5
github.com/filecoin-project/specs-actors v0.0.0-20200206185502-20fc70907293
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/gorilla/mux v1.7.3

4
go.sum
View File

@ -123,8 +123,8 @@ github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb6
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb62/go.mod h1:jNGVCDihkMFnraYVLH1xl4ceZQVxx/u4dOORrTKeRi0=
github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIiWBRilQjQ+5IiwdQ=
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
github.com/filecoin-project/specs-actors v0.0.0-20200204204849-b1474eeb2fb5 h1:rDyP5UTPFxdfS7D5I0XLdaQZZoNGYTic1X9ptKmRSlM=
github.com/filecoin-project/specs-actors v0.0.0-20200204204849-b1474eeb2fb5/go.mod h1:9vrrnLVhF2Zz6R3VBI7lKxQYRvPpsc1FTUyNqCvuYME=
github.com/filecoin-project/specs-actors v0.0.0-20200206185502-20fc70907293 h1:k/xtj90OknHTVOJikJ9mnf81UN2BaflS3R83OUg3BJM=
github.com/filecoin-project/specs-actors v0.0.0-20200206185502-20fc70907293/go.mod h1:gx4vDpIVf3AfF23iyVn9PNQhKy7wGQDrhxNyCHDzG8I=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0=

View File

@ -7,6 +7,7 @@ import (
"strconv"
"github.com/filecoin-project/go-amt-ipld/v2"
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
@ -416,7 +417,7 @@ func (a *StateAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Add
ts = a.Chain.GetHeaviestTipSet()
}
var st actors.MultiSigActorState
var st samsig.MultiSigActorState
act, err := a.StateManager.LoadActorState(ctx, addr, &st, ts)
if err != nil {
return types.EmptyInt, xerrors.Errorf("failed to load multisig actor state: %w", err)