diff --git a/api/api_full.go b/api/api_full.go index 8ec713b8a..d4299887b 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -26,8 +26,6 @@ import ( type FullNode interface { Common - // TODO: TipSetKeys - // MethodGroup: Chain // The Chain method group contains methods for interacting with the // blockchain, but that do not require any form of state computation. @@ -162,7 +160,7 @@ type FullNode interface { WalletNew(context.Context, crypto.SigType) (address.Address, error) // WalletHas indicates whether the given address is in the wallet. WalletHas(context.Context, address.Address) (bool, error) - // WalletHas indicates whether the given address is in the wallet. + // WalletList lists all the addresses in the wallet. WalletList(context.Context) ([]address.Address, error) // WalletBalance returns the balance of the given address at the current head of the chain. WalletBalance(context.Context, address.Address) (types.BigInt, error) @@ -314,9 +312,9 @@ type FullNode interface { // MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) // MsigGetAvailableBalance creates a multisig wallet - // It takes the following params: , , , - // , - MsigCreate(context.Context, uint64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) + // It takes the following params: , , + //, , + MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) // MsigPropose proposes a multisig message // It takes the following params: , , , // , , @@ -326,10 +324,9 @@ type FullNode interface { // , , MsigApprove(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) // MsigCancel cancels a previously-proposed multisig message - // It takes the following params: , , , , , + // It takes the following params: , , , , // , , - // TODO: You can't cancel someone else's proposed message, so "src" and "proposer" here are redundant - MsigCancel(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) + MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) MarketEnsureAvailable(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) // MarketFreeBalance @@ -393,8 +390,8 @@ type DealInfo struct { type MsgLookup struct { Receipt types.MessageReceipt ReturnDec interface{} - // TODO: This should probably a tipsetkey? - TipSet *types.TipSet + TipSet types.TipSetKey + Height abi.ChainEpoch } type BlockMessages struct { diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index c0b4d9e6b..3ae4b2e90 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -162,10 +162,10 @@ type FullNodeStruct struct { StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (*verifreg.DataCap, error) `perm:"read"` MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"` - MsigCreate func(context.Context, uint64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"` + MsigCreate func(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"` MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"` MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"` - MsigCancel func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"` + MsigCancel func(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"` MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"` @@ -708,8 +708,8 @@ func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address. return c.Internal.MsigGetAvailableBalance(ctx, a, tsk) } -func (c *FullNodeStruct) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) { - return c.Internal.MsigCreate(ctx, req, addrs, val, src, gp) +func (c *FullNodeStruct) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) { + return c.Internal.MsigCreate(ctx, req, addrs, duration, val, src, gp) } func (c *FullNodeStruct) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { @@ -720,8 +720,8 @@ func (c *FullNodeStruct) MsigApprove(ctx context.Context, msig address.Address, return c.Internal.MsigApprove(ctx, msig, txID, proposer, to, amt, src, method, params) } -func (c *FullNodeStruct) MsigCancel(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { - return c.Internal.MsigCancel(ctx, msig, txID, proposer, to, amt, src, method, params) +func (c *FullNodeStruct) MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { + return c.Internal.MsigCancel(ctx, msig, txID, to, amt, src, method, params) } func (c *FullNodeStruct) MarketEnsureAvailable(ctx context.Context, addr, wallet address.Address, amt types.BigInt) (cid.Cid, error) { diff --git a/build/version.go b/build/version.go index b5d48eac7..6af1fb673 100644 --- a/build/version.go +++ b/build/version.go @@ -53,7 +53,7 @@ func (ve Version) EqMajorMinor(v2 Version) bool { } // APIVersion is a semver version of the rpc api exposed -var APIVersion Version = newVer(0, 5, 0) +var APIVersion Version = newVer(0, 7, 0) //nolint:varcheck,deadcode const ( diff --git a/chain/events/events_height.go b/chain/events/events_height.go index fc94d6262..24d758a31 100644 --- a/chain/events/events_height.go +++ b/chain/events/events_height.go @@ -93,7 +93,6 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error { if hnd.called { return nil } - hnd.called = true triggerH := h - abi.ChainEpoch(hnd.confidence) @@ -108,6 +107,7 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error { e.lk.Unlock() err = handle(ctx, incTs, h) e.lk.Lock() + hnd.called = true span.End() if err != nil { diff --git a/chain/sync.go b/chain/sync.go index b704789b1..a00767b73 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -349,6 +349,10 @@ func zipTipSetAndMessages(bs cbor.IpldStore, ts *types.TipSet, allbmsgs []*types fts := &store.FullTipSet{} for bi, b := range ts.Blocks() { + if msgc := len(bmi[bi]) + len(smi[bi]); msgc > build.BlockMessageLimit { + return nil, fmt.Errorf("block %q has too many messages (%d)", b.Cid(), msgc) + } + var smsgs []*types.SignedMessage var smsgCids []cbg.CBORMarshaler for _, m := range smi[bi] { @@ -365,10 +369,6 @@ func zipTipSetAndMessages(bs cbor.IpldStore, ts *types.TipSet, allbmsgs []*types bmsgCids = append(bmsgCids, &c) } - if msgc := len(bmsgCids) + len(smsgCids); msgc > build.BlockMessageLimit { - return nil, fmt.Errorf("block %q has too many messages (%d)", b.Cid(), msgc) - } - mrcid, err := computeMsgMeta(bs, bmsgCids, smsgCids) if err != nil { return nil, err diff --git a/cli/client.go b/cli/client.go index f80ed99ec..414c04cd8 100644 --- a/cli/client.go +++ b/cli/client.go @@ -91,6 +91,11 @@ var clientImportCmd = &cli.Command{ } defer closer() ctx := ReqContext(cctx) + + if cctx.NArg() != 1 { + return xerrors.New("expected input path as the only arg") + } + absPath, err := filepath.Abs(cctx.Args().First()) if err != nil { return err diff --git a/cli/multisig.go b/cli/multisig.go index 543e4ac10..8230ee140 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -6,6 +6,7 @@ import ( "encoding/binary" "encoding/hex" "fmt" + "github.com/filecoin-project/specs-actors/actors/abi" "os" "sort" "strconv" @@ -57,6 +58,11 @@ var msigCreateCmd = &cli.Command{ Usage: "initial funds to give to multisig", Value: "0", }, + &cli.StringFlag{ + Name: "duration", + Usage: "length of the period over which funds unlock", + Value: "0", + }, &cli.StringFlag{ Name: "from", Usage: "account to send the create message from", @@ -114,9 +120,11 @@ var msigCreateCmd = &cli.Command{ required = uint64(len(addrs)) } + d := abi.ChainEpoch(cctx.Uint64("duration")) + gp := types.NewInt(1) - msgCid, err := api.MsigCreate(ctx, required, addrs, intVal, sendAddr, gp) + msgCid, err := api.MsigCreate(ctx, required, addrs, d, intVal, sendAddr, gp) if err != nil { return err } diff --git a/cli/state.go b/cli/state.go index 03fa51a3e..89cf3eff0 100644 --- a/cli/state.go +++ b/cli/state.go @@ -337,7 +337,11 @@ var stateReplaySetCmd = &cli.Command{ return xerrors.Errorf("finding message in chain: %w", err) } - ts, err = fapi.ChainGetTipSet(ctx, r.TipSet.Parents()) + childTs, err := fapi.ChainGetTipSet(ctx, r.TipSet) + if err != nil { + return xerrors.Errorf("loading tipset: %w", err) + } + ts, err = fapi.ChainGetTipSet(ctx, childTs.Parents()) } if err != nil { return err diff --git a/node/impl/full/multisig.go b/node/impl/full/multisig.go index 2a0c9c031..7d6d9e86c 100644 --- a/node/impl/full/multisig.go +++ b/node/impl/full/multisig.go @@ -26,7 +26,7 @@ type MsigAPI struct { MpoolAPI MpoolAPI } -func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) { +func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) { lenAddrs := uint64(len(addrs)) @@ -50,6 +50,7 @@ func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Ad msigParams := &samsig.ConstructorParams{ Signers: addrs, NumApprovalsThreshold: req, + UnlockDuration: duration, } enc, actErr := actors.SerializeParams(msigParams) @@ -138,8 +139,8 @@ func (a *MsigAPI) MsigApprove(ctx context.Context, msig address.Address, txID ui return a.msigApproveOrCancel(ctx, api.MsigApprove, msig, txID, proposer, to, amt, src, method, params) } -func (a *MsigAPI) MsigCancel(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { - return a.msigApproveOrCancel(ctx, api.MsigCancel, msig, txID, proposer, to, amt, src, method, params) +func (a *MsigAPI) MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { + return a.msigApproveOrCancel(ctx, api.MsigCancel, msig, txID, src, to, amt, src, method, params) } func (a *MsigAPI) msigApproveOrCancel(ctx context.Context, operation api.MsigProposeResponse, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) { diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 21b478c66..36c634c70 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -387,7 +387,8 @@ func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uin return &api.MsgLookup{ Receipt: *recpt, ReturnDec: returndec, - TipSet: ts, + TipSet: ts.Key(), + Height: ts.Height(), }, nil } @@ -400,7 +401,8 @@ func (a *StateAPI) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLoo if ts != nil { return &api.MsgLookup{ Receipt: *recpt, - TipSet: ts, + TipSet: ts.Key(), + Height: ts.Height(), }, nil } else { return nil, nil diff --git a/storage/adapter_storage_miner.go b/storage/adapter_storage_miner.go index 266ee3849..eaaa7a75c 100644 --- a/storage/adapter_storage_miner.go +++ b/storage/adapter_storage_miner.go @@ -93,8 +93,8 @@ func (s SealingAPIAdapter) StateWaitMsg(ctx context.Context, mcid cid.Cid) (seal Return: wmsg.Receipt.Return, GasUsed: wmsg.Receipt.GasUsed, }, - TipSetTok: wmsg.TipSet.Key().Bytes(), - Height: wmsg.TipSet.Height(), + TipSetTok: wmsg.TipSet.Bytes(), + Height: wmsg.Height, }, nil }