diff --git a/venus-devtool/api-gen/proxygen.go b/venus-devtool/api-gen/proxygen.go index a458432516..a5d05e3b00 100644 --- a/venus-devtool/api-gen/proxygen.go +++ b/venus-devtool/api-gen/proxygen.go @@ -12,15 +12,11 @@ import ( "os" "path" "path/filepath" - "regexp" - "strconv" "strings" "text/template" "unicode" - "github.com/filecoin-project/go-jsonrpc/auth" _ "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/venus/app/client/funcrule" "golang.org/x/xerrors" ) @@ -36,49 +32,12 @@ var ( VenusV1ApiFile = path.Join(VenusAPIPath, "chain/v1", GenAPIFileName) ) -// Rule[perm:read,ignore:true] -var rulePattern = `Rule\[(?P.*)\]` - type ruleKey = string const ( - rkPerm ruleKey = "perm" - rkIgnore ruleKey = "ignore" + rkPerm ruleKey = "perm" ) -var defaultPerm = []string{"perm", "read"} -var regRule, _ = regexp.Compile(rulePattern) - -func parseRule(comment string) (*funcrule.Rule, map[string][]string) { - rule := new(funcrule.Rule) - match := regRule.FindStringSubmatch(comment) - tags := map[string][]string{} - if len(match) == 2 { - pairs := strings.Split(match[1], ",") - for _, v := range pairs { - pair := strings.Split(v, ":") - if len(pair) != 2 { - continue - } - switch pair[0] { - case rkPerm: - tags[rkPerm] = pair - rule.Perm = auth.Permission(pair[1]) - case rkIgnore: - ig, err := strconv.ParseBool(pair[1]) - if err != nil { - panic("the rule tag is invalid format") - } - rule.Ignore = ig - } - } - } else { - rule.Perm = "read" - tags[rkPerm] = defaultPerm - } - return rule, tags -} - type methodMeta struct { node ast.Node ftype *ast.FuncType @@ -372,13 +331,11 @@ func methodMetaFromInterface(rootPath string, pkg, outpkg string) (*meta, error) // try to parse tag info if len(filteredComments) > 0 { - cmt := filteredComments[0].List[len(filteredComments[0].List)-1].Text - rule, tags := parseRule(cmt) - info.Methods[mname].Tags[rkPerm] = tags[rkPerm] - // remove ignore method - if rule.Ignore { - ignoreMethods[ifname] = append(ignoreMethods[ifname], mname) - } + lastComment := filteredComments[len(filteredComments)-1] + // eg. cmt = `//perm:read` + cmt := lastComment.List[len(lastComment.List)-1].Text + cmt = strings.Replace(cmt, "//", "", 1) + info.Methods[mname].Tags[rkPerm] = strings.Split(cmt, ":") } } } diff --git a/venus-devtool/compatible/actors/main.go b/venus-devtool/compatible/actors/main.go index c72c351f76..8ae1746842 100644 --- a/venus-devtool/compatible/actors/main.go +++ b/venus-devtool/compatible/actors/main.go @@ -6,6 +6,7 @@ import ( "log" "os" "path/filepath" + "regexp" "strings" "github.com/urfave/cli/v2" @@ -145,18 +146,35 @@ var replicaCmd = &cli.Command{ return fmt.Errorf("find chain/actors: %w", err) } + reg := regexp.MustCompile(`v[0-9]+.go`) + files, err := listFilesInDir(srcDir, func(path string, d fs.DirEntry) bool { if d.IsDir() { return true } + // need adt.go diff_adt.go + if strings.Contains(path, "adt.go") { + return false + } + + // skip test file if strings.HasSuffix(path, "test.go") { return true } - // diff.go diff_deadlines.go version.go params.go utils.go util.go - if !strings.Contains(path, "diff") && !strings.HasSuffix(path, "version.go") && - !strings.HasSuffix(path, "params.go") && !strings.Contains(path, "util") { + if strings.HasSuffix(path, "main.go") || strings.Contains(path, "template") || + strings.Contains(path, "message") { + return true + } + + dir := filepath.Dir(path) + arr := strings.Split(dir, "/") + if strings.HasSuffix(path, fmt.Sprintf("%s.go", arr[len(arr)-1])) { + return true + } + + if reg.MatchString(d.Name()) { return true } diff --git a/venus-shared/actors/adt/adt.go b/venus-shared/actors/adt/adt.go index 084471bb8f..6cebb1e0e6 100644 --- a/venus-shared/actors/adt/adt.go +++ b/venus-shared/actors/adt/adt.go @@ -1,3 +1,5 @@ +// FETCHED FROM LOTUS: adt/adt.go + package adt import ( diff --git a/venus-shared/actors/adt/store.go b/venus-shared/actors/adt/store.go index 8dd9841a15..04b71797da 100644 --- a/venus-shared/actors/adt/store.go +++ b/venus-shared/actors/adt/store.go @@ -1,3 +1,5 @@ +// FETCHED FROM LOTUS: adt/store.go + package adt import ( diff --git a/venus-shared/actors/aerrors/error.go b/venus-shared/actors/aerrors/error.go index 12f802c8fc..df5f23a817 100644 --- a/venus-shared/actors/aerrors/error.go +++ b/venus-shared/actors/aerrors/error.go @@ -1,3 +1,5 @@ +// FETCHED FROM LOTUS: aerrors/error.go + package aerrors import ( diff --git a/venus-shared/actors/aerrors/wrap.go b/venus-shared/actors/aerrors/wrap.go index 0552829f91..4193628428 100644 --- a/venus-shared/actors/aerrors/wrap.go +++ b/venus-shared/actors/aerrors/wrap.go @@ -1,3 +1,5 @@ +// FETCHED FROM LOTUS: aerrors/wrap.go + package aerrors import ( diff --git a/venus-shared/actors/builtin/README.md b/venus-shared/actors/builtin/README.md new file mode 100644 index 0000000000..b47dd68fed --- /dev/null +++ b/venus-shared/actors/builtin/README.md @@ -0,0 +1,31 @@ +// FETCHED FROM LOTUS: builtin/README.md + +# Actors + +This package contains shims for abstracting over different actor versions. + +## Design + +Shims in this package follow a few common design principles. + +### Structure Agnostic + +Shims interfaces defined in this package should (ideally) not change even if the +structure of the underlying data changes. For example: + +* All shims store an internal "store" object. That way, state can be moved into + a separate object without needing to add a store to the function signature. +* All functions must return an error, even if unused for now. + +### Minimal + +These interfaces should be expanded only as necessary to reduce maintenance burden. + +### Queries, not field assessors. + +When possible, functions should query the state instead of simply acting as +field assessors. These queries are more likely to remain stable across +specs-actor upgrades than specific state fields. + +Note: there is a trade-off here. Avoid implementing _complicated_ query logic +inside these shims, as it will need to be replicated in every shim. diff --git a/venus-shared/api/chain/v0/blockstore.go b/venus-shared/api/chain/v0/blockstore.go index adca654f68..511e14852d 100644 --- a/venus-shared/api/chain/v0/blockstore.go +++ b/venus-shared/api/chain/v0/blockstore.go @@ -9,12 +9,8 @@ import ( ) type IBlockStore interface { - // Rule[perm:read] - ChainReadObj(ctx context.Context, ocid cid.Cid) ([]byte, error) - // Rule[perm:admin] - ChainDeleteObj(ctx context.Context, obj cid.Cid) error - // Rule[perm:read] - ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) - // Rule[perm:read] - ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (chain2.ObjStat, error) + ChainReadObj(ctx context.Context, cid cid.Cid) ([]byte, error) //perm:read + ChainDeleteObj(ctx context.Context, obj cid.Cid) error //perm:admin + ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) //perm:read + ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (chain2.ObjStat, error) //perm:read } diff --git a/venus-shared/api/chain/v0/chain.go b/venus-shared/api/chain/v0/chain.go index 4cc4e6b20d..25b0c16677 100644 --- a/venus-shared/api/chain/v0/chain.go +++ b/venus-shared/api/chain/v0/chain.go @@ -27,154 +27,85 @@ type IChain interface { } type IAccount interface { - // Rule[perm:read] - StateAccountKey(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) + StateAccountKey(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) //perm:read } type IActor interface { - // Rule[perm:read] - StateGetActor(ctx context.Context, actor address.Address, tsk chain.TipSetKey) (*chain.Actor, error) - // Rule[perm:read] - ListActor(ctx context.Context) (map[address.Address]*chain.Actor, error) + StateGetActor(ctx context.Context, actor address.Address, tsk chain.TipSetKey) (*chain.Actor, error) //perm:read + ListActor(ctx context.Context) (map[address.Address]*chain.Actor, error) //perm:read } type IBeacon interface { - // Rule[perm:read] - BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*chain.BeaconEntry, error) + BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*chain.BeaconEntry, error) //perm:read } type IChainInfo interface { - // Rule[perm:read] - BlockTime(ctx context.Context) time.Duration - // Rule[perm:read] - ChainList(ctx context.Context, tsKey chain.TipSetKey, count int) ([]chain.TipSetKey, error) - // Rule[perm:read] - ChainHead(ctx context.Context) (*chain.TipSet, error) - // Rule[perm:admin] - ChainSetHead(ctx context.Context, key chain.TipSetKey) error - // Rule[perm:read] - ChainGetTipSet(ctx context.Context, key chain.TipSetKey) (*chain.TipSet, error) - // Rule[perm:read] - ChainGetTipSetByHeight(ctx context.Context, height abi.ChainEpoch, tsk chain.TipSetKey) (*chain.TipSet, error) - // Rule[perm:read] - ChainGetRandomnessFromBeacon(ctx context.Context, key chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) - // Rule[perm:read] - ChainGetRandomnessFromTickets(ctx context.Context, tsk chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) - // Rule[perm:read] - ChainGetBlock(ctx context.Context, id cid.Cid) (*chain.BlockHeader, error) - // Rule[perm:read] - ChainGetMessage(ctx context.Context, msgID cid.Cid) (*chain.Message, error) - // Rule[perm:read] - ChainGetBlockMessages(ctx context.Context, bid cid.Cid) (*chain2.BlockMessages, error) - // Rule[perm:read] - ChainGetMessagesInTipset(ctx context.Context, key chain.TipSetKey) ([]chain2.Message, error) - // Rule[perm:read] - ChainGetReceipts(ctx context.Context, id cid.Cid) ([]chain.MessageReceipt, error) - // Rule[perm:read] - ChainGetParentMessages(ctx context.Context, bcid cid.Cid) ([]chain2.Message, error) - // Rule[perm:read] - ChainGetParentReceipts(ctx context.Context, bcid cid.Cid) ([]*chain.MessageReceipt, error) - //Rule[perm:read] - StateVerifiedRegistryRootKey(ctx context.Context, tsk chain.TipSetKey) (address.Address, error) - // Rule[perm:read] - StateVerifierStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) - // Rule[perm:read] - ChainNotify(ctx context.Context) (<-chan []*chain2.HeadChange, error) - // Rule[perm:read] - GetFullBlock(ctx context.Context, id cid.Cid) (*chain.FullBlock, error) - // Rule[perm:read] - GetActor(ctx context.Context, addr address.Address) (*chain.Actor, error) - // Rule[perm:read] - GetParentStateRootActor(ctx context.Context, ts *chain.TipSet, addr address.Address) (*chain.Actor, error) - // Rule[perm:read] - GetEntry(ctx context.Context, height abi.ChainEpoch, round uint64) (*chain.BeaconEntry, error) - // Rule[perm:read] - MessageWait(ctx context.Context, msgCid cid.Cid, confidence, lookback abi.ChainEpoch) (*chain2.ChainMessage, error) - // Rule[perm:read] - ProtocolParameters(ctx context.Context) (*chain2.ProtocolParams, error) - // Rule[perm:read] - ResolveToKeyAddr(ctx context.Context, addr address.Address, ts *chain.TipSet) (address.Address, error) - // Rule[perm:read] - StateNetworkName(ctx context.Context) (chain2.NetworkName, error) - // Rule[perm:read] - StateGetReceipt(ctx context.Context, msg cid.Cid, from chain.TipSetKey) (*chain.MessageReceipt, error) - // Rule[perm:read] - StateSearchMsg(ctx context.Context, msg cid.Cid) (*chain2.MsgLookup, error) - // Rule[perm:read] - StateSearchMsgLimited(ctx context.Context, cid cid.Cid, limit abi.ChainEpoch) (*chain2.MsgLookup, error) - // Rule[perm:read] - StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*chain2.MsgLookup, error) - // Rule[perm:read] - StateWaitMsgLimited(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch) (*chain2.MsgLookup, error) - // Rule[perm:read] - StateNetworkVersion(ctx context.Context, tsk chain.TipSetKey) (network.Version, error) - // Rule[perm:read] - VerifyEntry(parent, child *chain.BeaconEntry, height abi.ChainEpoch) bool - // Rule[perm:read] - ChainExport(context.Context, abi.ChainEpoch, bool, chain.TipSetKey) (<-chan []byte, error) - // Rule[perm:read] - ChainGetPath(ctx context.Context, from chain.TipSetKey, to chain.TipSetKey) ([]*chain2.HeadChange, error) + BlockTime(ctx context.Context) time.Duration //perm:read + ChainList(ctx context.Context, tsKey chain.TipSetKey, count int) ([]chain.TipSetKey, error) //perm:read + ChainHead(ctx context.Context) (*chain.TipSet, error) //perm:read + ChainSetHead(ctx context.Context, key chain.TipSetKey) error //perm:admin + ChainGetTipSet(ctx context.Context, key chain.TipSetKey) (*chain.TipSet, error) //perm:read + ChainGetTipSetByHeight(ctx context.Context, height abi.ChainEpoch, tsk chain.TipSetKey) (*chain.TipSet, error) //perm:read + ChainGetRandomnessFromBeacon(ctx context.Context, key chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read + ChainGetRandomnessFromTickets(ctx context.Context, tsk chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read + ChainGetBlock(ctx context.Context, id cid.Cid) (*chain.BlockHeader, error) //perm:read + ChainGetMessage(ctx context.Context, msgID cid.Cid) (*chain.Message, error) //perm:read + ChainGetBlockMessages(ctx context.Context, bid cid.Cid) (*chain2.BlockMessages, error) //perm:read + ChainGetMessagesInTipset(ctx context.Context, key chain.TipSetKey) ([]chain2.Message, error) //perm:read + ChainGetReceipts(ctx context.Context, id cid.Cid) ([]chain.MessageReceipt, error) //perm:read + ChainGetParentMessages(ctx context.Context, bcid cid.Cid) ([]chain2.Message, error) //perm:read + ChainGetParentReceipts(ctx context.Context, bcid cid.Cid) ([]*chain.MessageReceipt, error) //perm:read + StateVerifiedRegistryRootKey(ctx context.Context, tsk chain.TipSetKey) (address.Address, error) //perm:read + StateVerifierStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) //perm:read + ChainNotify(ctx context.Context) (<-chan []*chain2.HeadChange, error) //perm:read + GetFullBlock(ctx context.Context, id cid.Cid) (*chain.FullBlock, error) //perm:read + GetActor(ctx context.Context, addr address.Address) (*chain.Actor, error) //perm:read + GetParentStateRootActor(ctx context.Context, ts *chain.TipSet, addr address.Address) (*chain.Actor, error) //perm:read + GetEntry(ctx context.Context, height abi.ChainEpoch, round uint64) (*chain.BeaconEntry, error) //perm:read + MessageWait(ctx context.Context, msgCid cid.Cid, confidence, lookback abi.ChainEpoch) (*chain2.ChainMessage, error) //perm:read + ProtocolParameters(ctx context.Context) (*chain2.ProtocolParams, error) //perm:read + ResolveToKeyAddr(ctx context.Context, addr address.Address, ts *chain.TipSet) (address.Address, error) //perm:read + StateNetworkName(ctx context.Context) (chain2.NetworkName, error) //perm:read + StateGetReceipt(ctx context.Context, msg cid.Cid, from chain.TipSetKey) (*chain.MessageReceipt, error) //perm:read + StateSearchMsg(ctx context.Context, msg cid.Cid) (*chain2.MsgLookup, error) //perm:read + StateSearchMsgLimited(ctx context.Context, cid cid.Cid, limit abi.ChainEpoch) (*chain2.MsgLookup, error) //perm:read + StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*chain2.MsgLookup, error) //perm:read + StateWaitMsgLimited(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch) (*chain2.MsgLookup, error) //perm:read + StateNetworkVersion(ctx context.Context, tsk chain.TipSetKey) (network.Version, error) //perm:read + VerifyEntry(parent, child *chain.BeaconEntry, height abi.ChainEpoch) bool //perm:read + ChainExport(context.Context, abi.ChainEpoch, bool, chain.TipSetKey) (<-chan []byte, error) //perm:read + ChainGetPath(ctx context.Context, from chain.TipSetKey, to chain.TipSetKey) ([]*chain2.HeadChange, error) //perm:read } type IMinerState interface { - // Rule[perm:read] - StateMinerSectorAllocated(ctx context.Context, maddr address.Address, s abi.SectorNumber, tsk chain.TipSetKey) (bool, error) - // Rule[perm:read] - StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) - // Rule[perm:read] - StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorOnChainInfo, error) - // Rule[perm:read] - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorLocation, error) - // Rule[perm:read] - StateMinerSectorSize(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (abi.SectorSize, error) - // Rule[perm:read] - StateMinerInfo(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (miner.MinerInfo, error) - // Rule[perm:read] - StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (address.Address, error) - // Rule[perm:read] - StateMinerRecoveries(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) - // Rule[perm:read] - StateMinerFaults(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) - // Rule[perm:read] - StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (*dline.Info, error) - // Rule[perm:read] - StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tsk chain.TipSetKey) ([]chain2.Partition, error) - // Rule[perm:read] - StateMinerDeadlines(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]chain2.Deadline, error) - // Rule[perm:read] - StateMinerSectors(ctx context.Context, maddr address.Address, sectorNos *bitfield.BitField, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) - // Rule[perm:read] - StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tsk chain.TipSetKey) (*chain2.MarketDeal, error) - // Rule[perm:read] - StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - StateVMCirculatingSupplyInternal(ctx context.Context, tsk chain.TipSetKey) (chain.CirculatingSupply, error) - // Rule[perm:read] - StateCirculatingSupply(ctx context.Context, tsk chain.TipSetKey) (abi.TokenAmount, error) - // Rule[perm:read] - StateMarketDeals(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketDeal, error) - // Rule[perm:read] - StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) - // Rule[perm:read] - StateLookupID(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) - // Rule[perm:read] - StateListMiners(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) - // Rule[perm:read] - StateListActors(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) - // Rule[perm:read] - StateMinerPower(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*chain2.MinerPower, error) - // Rule[perm:read] - StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorExpiration, error) - // Rule[perm:read] - StateMinerSectorCount(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MinerSectors, error) - // Rule[perm:read] - StateMarketBalance(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MarketBalance, error) - // Rule[perm:read] - StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk chain.TipSetKey) (chain2.DealCollateralBounds, error) - // Rule[perm:read] - StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) + StateMinerSectorAllocated(ctx context.Context, maddr address.Address, s abi.SectorNumber, tsk chain.TipSetKey) (bool, error) //perm:read + StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) //perm:read + StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorLocation, error) //perm:read + StateMinerSectorSize(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (abi.SectorSize, error) //perm:read + StateMinerInfo(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (miner.MinerInfo, error) //perm:read + StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (address.Address, error) //perm:read + StateMinerRecoveries(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) //perm:read + StateMinerFaults(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) //perm:read + StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (*dline.Info, error) //perm:read + StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tsk chain.TipSetKey) ([]chain2.Partition, error) //perm:read + StateMinerDeadlines(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]chain2.Deadline, error) //perm:read + StateMinerSectors(ctx context.Context, maddr address.Address, sectorNos *bitfield.BitField, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) //perm:read + StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tsk chain.TipSetKey) (*chain2.MarketDeal, error) //perm:read + StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) //perm:read + StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) //perm:read + StateVMCirculatingSupplyInternal(ctx context.Context, tsk chain.TipSetKey) (chain.CirculatingSupply, error) //perm:read + StateCirculatingSupply(ctx context.Context, tsk chain.TipSetKey) (abi.TokenAmount, error) //perm:read + StateMarketDeals(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketDeal, error) //perm:read + StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) //perm:read + StateLookupID(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) //perm:read + StateListMiners(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) //perm:read + StateListActors(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) //perm:read + StateMinerPower(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*chain2.MinerPower, error) //perm:read + StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (big.Int, error) //perm:read + StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorExpiration, error) //perm:read + StateMinerSectorCount(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MinerSectors, error) //perm:read + StateMarketBalance(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MarketBalance, error) //perm:read + StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk chain.TipSetKey) (chain2.DealCollateralBounds, error) //perm:read + StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) //perm:read } diff --git a/venus-shared/api/chain/v0/discovery.go b/venus-shared/api/chain/v0/discovery.go deleted file mode 100644 index 2fd1fe7bcd..0000000000 --- a/venus-shared/api/chain/v0/discovery.go +++ /dev/null @@ -1,4 +0,0 @@ -package v0 - -type IDiscovery interface { -} diff --git a/venus-shared/api/chain/v0/fullnode.go b/venus-shared/api/chain/v0/fullnode.go index a33a5cff18..99e896b1e7 100644 --- a/venus-shared/api/chain/v0/fullnode.go +++ b/venus-shared/api/chain/v0/fullnode.go @@ -1,16 +1,3 @@ -/* -in api interface, you can add comment tags to the function -Note: -Rule[perm:admin,ignore:true] -perm: read,write,sign,admin -jwt token permission check -ignore: bool -the func in the api whether needs to be added to the client for external exposure - -TODO: -1. Support global FUNC injection - -*/ package v0 //go:generate go run github.com/golang/mock/mockgen@v1.6.0 -destination=./mock/full.go -package=mock . FullNode @@ -19,7 +6,6 @@ package v0 type FullNode interface { IBlockStore IChain - IDiscovery IMarket IMining IMessagePool diff --git a/venus-shared/api/chain/v0/jwtauth.go b/venus-shared/api/chain/v0/jwtauth.go index a32f7dd0f5..ef3f0c9bb8 100644 --- a/venus-shared/api/chain/v0/jwtauth.go +++ b/venus-shared/api/chain/v0/jwtauth.go @@ -7,8 +7,6 @@ import ( ) type IJwtAuthAPI interface { - // Rule[perm:read] - Verify(ctx context.Context, host, token string) ([]auth.Permission, error) - // Rule[perm:admin] - AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) + Verify(ctx context.Context, host, token string) ([]auth.Permission, error) //perm:read + AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) //perm:admin } diff --git a/venus-shared/api/chain/v0/market.go b/venus-shared/api/chain/v0/market.go index 36d80dec11..81c6eb75fb 100644 --- a/venus-shared/api/chain/v0/market.go +++ b/venus-shared/api/chain/v0/market.go @@ -8,6 +8,5 @@ import ( ) type IMarket interface { - // Rule[perm:read] - StateMarketParticipants(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketBalance, error) //perm:admin + StateMarketParticipants(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketBalance, error) //perm:read } diff --git a/venus-shared/api/chain/v0/mining.go b/venus-shared/api/chain/v0/mining.go index df8442f1a4..99da702aa6 100644 --- a/venus-shared/api/chain/v0/mining.go +++ b/venus-shared/api/chain/v0/mining.go @@ -11,8 +11,6 @@ import ( ) type IMining interface { - // Rule[perm:read] - MinerGetBaseInfo(ctx context.Context, maddr address.Address, round abi.ChainEpoch, tsk chain.TipSetKey) (*chain2.MiningBaseInfo, error) - // Rule[perm:write] - MinerCreateBlock(ctx context.Context, bt *chain2.BlockTemplate) (*chain.BlockMsg, error) + MinerGetBaseInfo(ctx context.Context, maddr address.Address, round abi.ChainEpoch, tsk chain.TipSetKey) (*chain2.MiningBaseInfo, error) //perm:read + MinerCreateBlock(ctx context.Context, bt *chain2.BlockTemplate) (*chain.BlockMsg, error) //perm:write } diff --git a/venus-shared/api/chain/v0/mpool.go b/venus-shared/api/chain/v0/mpool.go index b3b481c42c..eb867dcc3f 100644 --- a/venus-shared/api/chain/v0/mpool.go +++ b/venus-shared/api/chain/v0/mpool.go @@ -13,48 +13,26 @@ import ( ) type IMessagePool interface { - // Rule[perm:admin] - MpoolDeleteByAdress(ctx context.Context, addr address.Address) error - // Rule[perm:admin] - MpoolPublishByAddr(context.Context, address.Address) error - // Rule[perm:admin] - MpoolPublishMessage(ctx context.Context, smsg *chain.SignedMessage) error - // Rule[perm:write] - MpoolPush(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) - // Rule[perm:read] - MpoolGetConfig(context.Context) (*messagepool.MpoolConfig, error) - // Rule[perm:admin] - MpoolSetConfig(ctx context.Context, cfg *messagepool.MpoolConfig) error - // Rule[perm:read] - MpoolSelect(context.Context, chain.TipSetKey, float64) ([]*chain.SignedMessage, error) - // Rule[perm:read] - MpoolSelects(context.Context, chain.TipSetKey, []float64) ([][]*chain.SignedMessage, error) - // Rule[perm:read] - MpoolPending(ctx context.Context, tsk chain.TipSetKey) ([]*chain.SignedMessage, error) - // Rule[perm:write] - MpoolClear(ctx context.Context, local bool) error - // Rule[perm:write] - MpoolPushUntrusted(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) - // Rule[perm:sign] - MpoolPushMessage(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec) (*chain.SignedMessage, error) - // Rule[perm:write] - MpoolBatchPush(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) - // Rule[perm:write] - MpoolBatchPushUntrusted(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) - // Rule[perm:sign] - MpoolBatchPushMessage(ctx context.Context, msgs []*chain.Message, spec *chain2.MessageSendSpec) ([]*chain.SignedMessage, error) - // Rule[perm:read] - MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) - // Rule[perm:read] - MpoolSub(ctx context.Context) (<-chan messagepool.MpoolUpdate, error) - // Rule[perm:read] - GasEstimateMessageGas(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec, tsk chain.TipSetKey) (*chain.Message, error) - // Rule[perm:read] - GasBatchEstimateMessageGas(ctx context.Context, estimateMessages []*chain2.EstimateMessage, fromNonce uint64, tsk chain.TipSetKey) ([]*chain2.EstimateResult, error) - // Rule[perm:read] - GasEstimateFeeCap(ctx context.Context, msg *chain.Message, maxqueueblks int64, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - GasEstimateGasLimit(ctx context.Context, msgIn *chain.Message, tsk chain.TipSetKey) (int64, error) + MpoolDeleteByAdress(ctx context.Context, addr address.Address) error //perm:admin + MpoolPublishByAddr(context.Context, address.Address) error //perm:admin + MpoolPublishMessage(ctx context.Context, smsg *chain.SignedMessage) error //perm:admin + MpoolPush(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) //perm:write + MpoolGetConfig(context.Context) (*messagepool.MpoolConfig, error) //perm:read + MpoolSetConfig(ctx context.Context, cfg *messagepool.MpoolConfig) error //perm:admin + MpoolSelect(context.Context, chain.TipSetKey, float64) ([]*chain.SignedMessage, error) //perm:read + MpoolSelects(context.Context, chain.TipSetKey, []float64) ([][]*chain.SignedMessage, error) //perm:read + MpoolPending(ctx context.Context, tsk chain.TipSetKey) ([]*chain.SignedMessage, error) //perm:read + MpoolClear(ctx context.Context, local bool) error //perm:write + MpoolPushUntrusted(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) //perm:write + MpoolPushMessage(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec) (*chain.SignedMessage, error) //perm:sign + MpoolBatchPush(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) //perm:write + MpoolBatchPushUntrusted(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) //perm:write + MpoolBatchPushMessage(ctx context.Context, msgs []*chain.Message, spec *chain2.MessageSendSpec) ([]*chain.SignedMessage, error) //perm:sign + MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) //perm:read + MpoolSub(ctx context.Context) (<-chan messagepool.MpoolUpdate, error) //perm:read + GasEstimateMessageGas(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec, tsk chain.TipSetKey) (*chain.Message, error) //perm:read + GasBatchEstimateMessageGas(ctx context.Context, estimateMessages []*chain2.EstimateMessage, fromNonce uint64, tsk chain.TipSetKey) ([]*chain2.EstimateResult, error) //perm:read + GasEstimateFeeCap(ctx context.Context, msg *chain.Message, maxqueueblks int64, tsk chain.TipSetKey) (big.Int, error) //perm:read + GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk chain.TipSetKey) (big.Int, error) //perm:read + GasEstimateGasLimit(ctx context.Context, msgIn *chain.Message, tsk chain.TipSetKey) (int64, error) //perm:read } diff --git a/venus-shared/api/chain/v0/multisig.go b/venus-shared/api/chain/v0/multisig.go index 2673c422bc..fbb98798a3 100644 --- a/venus-shared/api/chain/v0/multisig.go +++ b/venus-shared/api/chain/v0/multisig.go @@ -15,30 +15,17 @@ type IMultiSig interface { // MsigCreate creates a multisig wallet // It takes the following params: , , //, , - // Rule[perm:sign] - MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, chain.BigInt, address.Address, chain.BigInt) (cid.Cid, error) - // Rule[perm:sign] - MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) - // Rule[perm:sign] - MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (cid.Cid, error) - // Rule[perm:sign] - MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) - // Rule[perm:sign] - MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) - // Rule[perm:sign] - MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) - // Rule[perm:sign] - MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) - // Rule[perm:sign] - MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) - // Rule[perm:sign] - MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) - // Rule[perm:sign] - MsigApproveTxnHash(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) - // Rule[perm:sign] - MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) - // Rule[perm:sign] - MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error) - // Rule[perm:read] - MsigGetVested(ctx context.Context, addr address.Address, start chain.TipSetKey, end chain.TipSetKey) (chain.BigInt, error) + MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, chain.BigInt, address.Address, chain.BigInt) (cid.Cid, error) //perm:sign + MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) //perm:sign + MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (cid.Cid, error) //perm:sign + MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) //perm:sign + MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) //perm:sign + MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) //perm:sign + MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) //perm:sign + MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) //perm:sign + MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) //perm:sign + MsigApproveTxnHash(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) //perm:sign + MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) //perm:sign + MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error) //perm:sign + MsigGetVested(ctx context.Context, addr address.Address, start chain.TipSetKey, end chain.TipSetKey) (chain.BigInt, error) //perm:read } diff --git a/venus-shared/api/chain/v0/network.go b/venus-shared/api/chain/v0/network.go index fd00a5d835..0c1bffb4ab 100644 --- a/venus-shared/api/chain/v0/network.go +++ b/venus-shared/api/chain/v0/network.go @@ -13,24 +13,14 @@ import ( ) type INetwork interface { - // Rule[perm:admin] - NetworkGetBandwidthStats(ctx context.Context) metrics.Stats - // Rule[perm:admin] - NetworkGetPeerAddresses(ctx context.Context) []ma.Multiaddr - // Rule[perm:admin] - NetworkGetPeerID(ctx context.Context) peer.ID - // Rule[perm:read] - NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo - // Rule[perm:read] - NetworkGetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error) - // Rule[perm:read] - NetworkFindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error) - // Rule[perm:read] - NetworkConnect(ctx context.Context, addrs []string) (<-chan net.ConnectionResult, error) - // Rule[perm:read] - NetworkPeers(ctx context.Context, verbose, latency, streams bool) (*net.SwarmConnInfos, error) - // Rule[perm:read] - Version(context.Context) (chain2.Version, error) - // Rule[perm:read] - NetAddrsListen(context.Context) (peer.AddrInfo, error) + NetworkGetBandwidthStats(ctx context.Context) metrics.Stats //perm:admin + NetworkGetPeerAddresses(ctx context.Context) []ma.Multiaddr //perm:admin + NetworkGetPeerID(ctx context.Context) peer.ID //perm:admin + NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo //perm:read + NetworkGetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error) //perm:read + NetworkFindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error) //perm:read + NetworkConnect(ctx context.Context, addrs []string) (<-chan net.ConnectionResult, error) //perm:read + NetworkPeers(ctx context.Context, verbose, latency, streams bool) (*net.SwarmConnInfos, error) //perm:read + Version(context.Context) (chain2.Version, error) //perm:read + NetAddrsListen(context.Context) (peer.AddrInfo, error) //perm:read } diff --git a/venus-shared/api/chain/v0/paych.go b/venus-shared/api/chain/v0/paych.go index b738725cee..062ca411c9 100644 --- a/venus-shared/api/chain/v0/paych.go +++ b/venus-shared/api/chain/v0/paych.go @@ -16,68 +16,55 @@ type IPaychan interface { // @from: the payment channel sender // @to: the payment channel recipient // @amt: the deposits funds in the payment channel - // Rule[perm:sign] - PaychGet(ctx context.Context, from, to address.Address, amt big.Int) (*paych.ChannelInfo, error) + PaychGet(ctx context.Context, from, to address.Address, amt big.Int) (*paych.ChannelInfo, error) //perm:sign // PaychAvailableFunds get the status of an outbound payment channel // @pch: payment channel address - // Rule[perm:sign] - PaychAvailableFunds(ctx context.Context, ch address.Address) (*chain2.ChannelAvailableFunds, error) + PaychAvailableFunds(ctx context.Context, ch address.Address) (*chain2.ChannelAvailableFunds, error) //perm:sign // PaychAvailableFundsByFromTo get the status of an outbound payment channel // @from: the payment channel sender // @to: he payment channel recipient - // Rule[perm:sign] - PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*chain2.ChannelAvailableFunds, error) + PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*chain2.ChannelAvailableFunds, error) //perm:sign // PaychGetWaitReady waits until the create channel / add funds message with the sentinel // @sentinel: given message CID arrives. // @ch: the returned channel address can safely be used against the Manager methods. - // Rule[perm:sign] - PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error) + PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error) //perm:sign // PaychAllocateLane Allocate late creates a lane within a payment channel so that calls to // CreatePaymentVoucher will automatically make vouchers only for the difference in total - // Rule[perm:sign] - PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error) + PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error) //perm:sign // PaychNewPayment aggregate vouchers into a new lane // @from: the payment channel sender // @to: the payment channel recipient // @vouchers: the outstanding (non-redeemed) vouchers - // Rule[perm:sign] - PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []paych.VoucherSpec) (*paych.PaymentInfo, error) + PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []paych.VoucherSpec) (*paych.PaymentInfo, error) //perm:sign // PaychList list the addresses of all channels that have been created - // Rule[perm:read] - PaychList(ctx context.Context) ([]address.Address, error) + PaychList(ctx context.Context) ([]address.Address, error) //perm:read // PaychStatus get the payment channel status // @pch: payment channel address - // Rule[perm:read] - PaychStatus(ctx context.Context, pch address.Address) (*paych.Status, error) + PaychStatus(ctx context.Context, pch address.Address) (*paych.Status, error) //perm:read // PaychSettle update payment channel status to settle // After a settlement period (currently 12 hours) either party to the payment channel can call collect on chain // @pch: payment channel address - // Rule[perm:sign] - PaychSettle(ctx context.Context, addr address.Address) (cid.Cid, error) + PaychSettle(ctx context.Context, addr address.Address) (cid.Cid, error) //perm:sign // PaychCollect update payment channel status to collect // Collect sends the value of submitted vouchers to the channel recipient (the provider), // and refunds the remaining channel balance to the channel creator (the client). // @pch: payment channel address - // Rule[perm:sign] - PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) + PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) //perm:sign // PaychVoucherCheckValid checks if the given voucher is valid (is or could become spendable at some point). // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). // @pch: payment channel address // @sv: voucher - // Rule[perm:read] - PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error + PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error //perm:read // PaychVoucherCheckSpendable checks if the given voucher is currently spendable // @pch: payment channel address // @sv: voucher - // Rule[perm:read] - PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) + PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) //perm:read // PaychVoucherAdd adds a voucher for an inbound channel. // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). - // Rule[perm:write] - PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) + PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) //perm:write // PaychVoucherCreate creates a new signed voucher on the given payment channel // with the given lane and amount. The value passed in is exactly the value // that will be used to create the voucher, so if previous vouchers exist, the @@ -85,15 +72,12 @@ type IPaychan interface { // the two. // If there are insufficient funds in the channel to create the voucher, // returns a nil voucher and the shortfall. - // Rule[perm:sign] - PaychVoucherCreate(ctx context.Context, pch address.Address, amt big.Int, lane uint64) (*paych.VoucherCreateResult, error) + PaychVoucherCreate(ctx context.Context, pch address.Address, amt big.Int, lane uint64) (*paych.VoucherCreateResult, error) //perm:sign // PaychVoucherList list vouchers in payment channel // @pch: payment channel address - // Rule[perm:write] - PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) + PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) //perm:write // PaychVoucherSubmit Submit voucher to chain to update payment channel state // @pch: payment channel address // @sv: voucher in payment channel - // Rule[perm:sign] - PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) + PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) //perm:sign } diff --git a/venus-shared/api/chain/v0/proxy_gen.go b/venus-shared/api/chain/v0/proxy_gen.go index ad37fd695d..d067bc9699 100644 --- a/venus-shared/api/chain/v0/proxy_gen.go +++ b/venus-shared/api/chain/v0/proxy_gen.go @@ -29,7 +29,6 @@ import ( type FullNodeStruct struct { IBlockStoreStruct IChainStruct - IDiscoveryStruct IMarketStruct IMiningStruct IMessagePoolStruct @@ -327,9 +326,6 @@ func (s *IChainInfoStruct) VerifyEntry(p0 *chain.BeaconEntry, p1 *chain.BeaconEn return s.Internal.VerifyEntry(p0, p1, p2) } -type IDiscoveryStruct struct { -} - type IJwtAuthAPIStruct struct { Internal struct { AuthNew func(p0 context.Context, p1 []auth.Permission) ([]byte, error) `perm:"admin"` diff --git a/venus-shared/api/chain/v0/syncer.go b/venus-shared/api/chain/v0/syncer.go index 413db069b2..439b7f043b 100644 --- a/venus-shared/api/chain/v0/syncer.go +++ b/venus-shared/api/chain/v0/syncer.go @@ -10,20 +10,12 @@ import ( ) type ISyncer interface { - // Rule[perm:write] - ChainSyncHandleNewTipSet(ctx context.Context, ci *chain.ChainInfo) error - // Rule[perm:admin] - SetConcurrent(ctx context.Context, concurrent int64) error - // Rule[perm:read] - SyncerTracker(ctx context.Context) *chain2.TargetTracker - // Rule[perm:read] - Concurrent(ctx context.Context) int64 - // Rule[perm:read] - ChainTipSetWeight(ctx context.Context, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:write] - SyncSubmitBlock(ctx context.Context, blk *chain.BlockMsg) error - // Rule[perm:read] - StateCall(ctx context.Context, msg *chain.Message, tsk chain.TipSetKey) (*chain2.InvocResult, error) - // Rule[perm:read] - SyncState(ctx context.Context) (*chain2.SyncState, error) + ChainSyncHandleNewTipSet(ctx context.Context, ci *chain.ChainInfo) error //perm:write + SetConcurrent(ctx context.Context, concurrent int64) error //perm:admin + SyncerTracker(ctx context.Context) *chain2.TargetTracker //perm:read + Concurrent(ctx context.Context) int64 //perm:read + ChainTipSetWeight(ctx context.Context, tsk chain.TipSetKey) (big.Int, error) //perm:read + SyncSubmitBlock(ctx context.Context, blk *chain.BlockMsg) error //perm:write + StateCall(ctx context.Context, msg *chain.Message, tsk chain.TipSetKey) (*chain2.InvocResult, error) //perm:read + SyncState(ctx context.Context) (*chain2.SyncState, error) //perm:read } diff --git a/venus-shared/api/chain/v0/wallet.go b/venus-shared/api/chain/v0/wallet.go index 1f78fb5c20..bed48a5e50 100644 --- a/venus-shared/api/chain/v0/wallet.go +++ b/venus-shared/api/chain/v0/wallet.go @@ -12,34 +12,19 @@ import ( ) type IWallet interface { - // Rule[perm:sign] - WalletSign(ctx context.Context, k address.Address, msg []byte, meta wallet.MsgMeta) (*crypto.Signature, error) - // Rule[perm:admin] - WalletExport(addr address.Address, password string) (*wallet.KeyInfo, error) - // Rule[perm:admin] - WalletImport(key *wallet.KeyInfo) (address.Address, error) - // Rule[perm:write] - WalletHas(ctx context.Context, addr address.Address) (bool, error) - // Rule[perm:write] - WalletNewAddress(protocol address.Protocol) (address.Address, error) - // Rule[perm:read] - WalletBalance(ctx context.Context, addr address.Address) (abi.TokenAmount, error) //not exists in remote - // Rule[perm:write] - WalletDefaultAddress(ctx context.Context) (address.Address, error) //not exists in remote - // Rule[perm:admin] - WalletAddresses(ctx context.Context) []address.Address - // Rule[perm:write] - WalletSetDefault(ctx context.Context, addr address.Address) error //not exists in remote - // Rule[perm:sign] - WalletSignMessage(ctx context.Context, k address.Address, msg *chain.Message) (*chain.SignedMessage, error) - // Rule[perm:admin] - LockWallet(ctx context.Context) error - // Rule[perm:admin] - UnLockWallet(ctx context.Context, password []byte) error - // Rule[perm:admin] - SetPassword(Context context.Context, password []byte) error - // Rule[perm:admin] - HasPassword(Context context.Context) bool - // Rule[perm:admin] - WalletState(Context context.Context) int + WalletSign(ctx context.Context, k address.Address, msg []byte, meta wallet.MsgMeta) (*crypto.Signature, error) //perm:sign + WalletExport(addr address.Address, password string) (*wallet.KeyInfo, error) //perm:admin + WalletImport(key *wallet.KeyInfo) (address.Address, error) //perm:admin + WalletHas(ctx context.Context, addr address.Address) (bool, error) //perm:write + WalletNewAddress(protocol address.Protocol) (address.Address, error) //perm:write + WalletBalance(ctx context.Context, addr address.Address) (abi.TokenAmount, error) //perm:read + WalletDefaultAddress(ctx context.Context) (address.Address, error) //perm:write + WalletAddresses(ctx context.Context) []address.Address //perm:admin + WalletSetDefault(ctx context.Context, addr address.Address) error //perm:write + WalletSignMessage(ctx context.Context, k address.Address, msg *chain.Message) (*chain.SignedMessage, error) //perm:sign + LockWallet(ctx context.Context) error //perm:admin + UnLockWallet(ctx context.Context, password []byte) error //perm:admin + SetPassword(Context context.Context, password []byte) error //perm:admin + HasPassword(Context context.Context) bool //perm:admin + WalletState(Context context.Context) int //perm:admin } diff --git a/venus-shared/api/chain/v1/blockstore.go b/venus-shared/api/chain/v1/blockstore.go index 041de41c31..c96e3d04b0 100644 --- a/venus-shared/api/chain/v1/blockstore.go +++ b/venus-shared/api/chain/v1/blockstore.go @@ -9,12 +9,8 @@ import ( ) type IBlockStore interface { - // Rule[perm:read] - ChainReadObj(ctx context.Context, ocid cid.Cid) ([]byte, error) - // Rule[perm:admin] - ChainDeleteObj(ctx context.Context, obj cid.Cid) error - // Rule[perm:read] - ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) - // Rule[perm:read] - ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (chain2.ObjStat, error) + ChainReadObj(ctx context.Context, cid cid.Cid) ([]byte, error) //perm:read + ChainDeleteObj(ctx context.Context, obj cid.Cid) error //perm:admin + ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) //perm:read + ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (chain2.ObjStat, error) //perm:read } diff --git a/venus-shared/api/chain/v1/chain.go b/venus-shared/api/chain/v1/chain.go index d2a159c81a..18629b99c7 100644 --- a/venus-shared/api/chain/v1/chain.go +++ b/venus-shared/api/chain/v1/chain.go @@ -27,81 +27,48 @@ type IChain interface { } type IAccount interface { - // Rule[perm:read] - StateAccountKey(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) + StateAccountKey(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) //perm:read } type IActor interface { - // Rule[perm:read] - StateGetActor(ctx context.Context, actor address.Address, tsk chain.TipSetKey) (*chain.Actor, error) - // Rule[perm:read] - ListActor(ctx context.Context) (map[address.Address]*chain.Actor, error) + StateGetActor(ctx context.Context, actor address.Address, tsk chain.TipSetKey) (*chain.Actor, error) //perm:read + ListActor(ctx context.Context) (map[address.Address]*chain.Actor, error) //perm:read } type IBeacon interface { - // Rule[perm:read] - BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*chain.BeaconEntry, error) + BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*chain.BeaconEntry, error) //perm:read } type IChainInfo interface { - // Rule[perm:read] - BlockTime(ctx context.Context) time.Duration - // Rule[perm:read] - ChainList(ctx context.Context, tsKey chain.TipSetKey, count int) ([]chain.TipSetKey, error) - // Rule[perm:read] - ChainHead(ctx context.Context) (*chain.TipSet, error) - // Rule[perm:admin] - ChainSetHead(ctx context.Context, key chain.TipSetKey) error - // Rule[perm:read] - ChainGetTipSet(ctx context.Context, key chain.TipSetKey) (*chain.TipSet, error) - // Rule[perm:read] - ChainGetTipSetByHeight(ctx context.Context, height abi.ChainEpoch, tsk chain.TipSetKey) (*chain.TipSet, error) - // Rule[perm:read] - ChainGetTipSetAfterHeight(ctx context.Context, height abi.ChainEpoch, tsk chain.TipSetKey) (*chain.TipSet, error) - // Rule[perm:read] - ChainGetRandomnessFromBeacon(ctx context.Context, key chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) - // Rule[perm:read] - ChainGetRandomnessFromTickets(ctx context.Context, tsk chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) - // Rule[perm:read] - StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk chain.TipSetKey) (abi.Randomness, error) - // Rule[perm:read] - StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk chain.TipSetKey) (abi.Randomness, error) - // Rule[perm:read] - ChainGetBlock(ctx context.Context, id cid.Cid) (*chain.BlockHeader, error) - // Rule[perm:read] - ChainGetMessage(ctx context.Context, msgID cid.Cid) (*chain.Message, error) - // Rule[perm:read] - ChainGetBlockMessages(ctx context.Context, bid cid.Cid) (*chain2.BlockMessages, error) - // Rule[perm:read] - ChainGetMessagesInTipset(ctx context.Context, key chain.TipSetKey) ([]chain2.Message, error) - // Rule[perm:read] - ChainGetReceipts(ctx context.Context, id cid.Cid) ([]chain.MessageReceipt, error) - // Rule[perm:read] - ChainGetParentMessages(ctx context.Context, bcid cid.Cid) ([]chain2.Message, error) - // Rule[perm:read] - ChainGetParentReceipts(ctx context.Context, bcid cid.Cid) ([]*chain.MessageReceipt, error) - // Rule[perm:read] - StateVerifiedRegistryRootKey(ctx context.Context, tsk chain.TipSetKey) (address.Address, error) - // Rule[perm:read] - StateVerifierStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) - // Rule[perm:read] - ChainNotify(ctx context.Context) (<-chan []*chain2.HeadChange, error) - // Rule[perm:read] - GetFullBlock(ctx context.Context, id cid.Cid) (*chain.FullBlock, error) - // Rule[perm:read] - GetActor(ctx context.Context, addr address.Address) (*chain.Actor, error) - // Rule[perm:read] - GetParentStateRootActor(ctx context.Context, ts *chain.TipSet, addr address.Address) (*chain.Actor, error) - // Rule[perm:read] - GetEntry(ctx context.Context, height abi.ChainEpoch, round uint64) (*chain.BeaconEntry, error) - // Rule[perm:read] - MessageWait(ctx context.Context, msgCid cid.Cid, confidence, lookback abi.ChainEpoch) (*chain2.ChainMessage, error) - // Rule[perm:read] - ProtocolParameters(ctx context.Context) (*chain2.ProtocolParams, error) - // Rule[perm:read] - ResolveToKeyAddr(ctx context.Context, addr address.Address, ts *chain.TipSet) (address.Address, error) - // Rule[perm:read] - StateNetworkName(ctx context.Context) (chain2.NetworkName, error) + BlockTime(ctx context.Context) time.Duration //perm:read + ChainList(ctx context.Context, tsKey chain.TipSetKey, count int) ([]chain.TipSetKey, error) //perm:read + ChainHead(ctx context.Context) (*chain.TipSet, error) //perm:read + ChainSetHead(ctx context.Context, key chain.TipSetKey) error //perm:admin + ChainGetTipSet(ctx context.Context, key chain.TipSetKey) (*chain.TipSet, error) //perm:read + ChainGetTipSetByHeight(ctx context.Context, height abi.ChainEpoch, tsk chain.TipSetKey) (*chain.TipSet, error) //perm:read + ChainGetTipSetAfterHeight(ctx context.Context, height abi.ChainEpoch, tsk chain.TipSetKey) (*chain.TipSet, error) //perm:read + ChainGetRandomnessFromBeacon(ctx context.Context, key chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read + ChainGetRandomnessFromTickets(ctx context.Context, tsk chain.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read + StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk chain.TipSetKey) (abi.Randomness, error) //perm:read + StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk chain.TipSetKey) (abi.Randomness, error) //perm:read + ChainGetBlock(ctx context.Context, id cid.Cid) (*chain.BlockHeader, error) //perm:read + ChainGetMessage(ctx context.Context, msgID cid.Cid) (*chain.Message, error) //perm:read + ChainGetBlockMessages(ctx context.Context, bid cid.Cid) (*chain2.BlockMessages, error) //perm:read + ChainGetMessagesInTipset(ctx context.Context, key chain.TipSetKey) ([]chain2.Message, error) //perm:read + ChainGetReceipts(ctx context.Context, id cid.Cid) ([]chain.MessageReceipt, error) //perm:read + ChainGetParentMessages(ctx context.Context, bcid cid.Cid) ([]chain2.Message, error) //perm:read + ChainGetParentReceipts(ctx context.Context, bcid cid.Cid) ([]*chain.MessageReceipt, error) //perm:read + StateVerifiedRegistryRootKey(ctx context.Context, tsk chain.TipSetKey) (address.Address, error) //perm:read + StateVerifierStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) //perm:read + ChainNotify(ctx context.Context) (<-chan []*chain2.HeadChange, error) //perm:read + GetFullBlock(ctx context.Context, id cid.Cid) (*chain.FullBlock, error) //perm:read + GetActor(ctx context.Context, addr address.Address) (*chain.Actor, error) //perm:read + GetParentStateRootActor(ctx context.Context, ts *chain.TipSet, addr address.Address) (*chain.Actor, error) //perm:read + GetEntry(ctx context.Context, height abi.ChainEpoch, round uint64) (*chain.BeaconEntry, error) //perm:read + MessageWait(ctx context.Context, msgCid cid.Cid, confidence, lookback abi.ChainEpoch) (*chain2.ChainMessage, error) //perm:read + ProtocolParameters(ctx context.Context) (*chain2.ProtocolParams, error) //perm:read + ResolveToKeyAddr(ctx context.Context, addr address.Address, ts *chain.TipSet) (address.Address, error) //perm:read + StateNetworkName(ctx context.Context) (chain2.NetworkName, error) //perm:read // StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed // // NOTE: If a replacing message is found on chain, this method will return @@ -118,8 +85,7 @@ type IChainInfo interface { // A replacing message is a message with a different CID, any of Gas values, and // different signature, but with all other parameters matching (source/destination, // nonce, params, etc.) - // Rule[perm:read] - StateSearchMsg(ctx context.Context, from chain.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*chain2.MsgLookup, error) + StateSearchMsg(ctx context.Context, from chain.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*chain2.MsgLookup, error) //perm:read // StateWaitMsg looks back up to limit epochs in the chain for a message. // If not found, it blocks until the message arrives on chain, and gets to the // indicated confidence depth. @@ -138,77 +104,42 @@ type IChainInfo interface { // A replacing message is a message with a different CID, any of Gas values, and // different signature, but with all other parameters matching (source/destination, // nonce, params, etc.) - // Rule[perm:read] - StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*chain2.MsgLookup, error) - // Rule[perm:read] - StateNetworkVersion(ctx context.Context, tsk chain.TipSetKey) (network.Version, error) - // Rule[perm:read] - VerifyEntry(parent, child *chain.BeaconEntry, height abi.ChainEpoch) bool - // Rule[perm:read] - ChainExport(context.Context, abi.ChainEpoch, bool, chain.TipSetKey) (<-chan []byte, error) - // Rule[perm:read] - ChainGetPath(ctx context.Context, from chain.TipSetKey, to chain.TipSetKey) ([]*chain2.HeadChange, error) + StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*chain2.MsgLookup, error) //perm:read + StateNetworkVersion(ctx context.Context, tsk chain.TipSetKey) (network.Version, error) //perm:read + VerifyEntry(parent, child *chain.BeaconEntry, height abi.ChainEpoch) bool //perm:read + ChainExport(context.Context, abi.ChainEpoch, bool, chain.TipSetKey) (<-chan []byte, error) //perm:read + ChainGetPath(ctx context.Context, from chain.TipSetKey, to chain.TipSetKey) ([]*chain2.HeadChange, error) //perm:read } type IMinerState interface { - // Rule[perm:read] - StateMinerSectorAllocated(ctx context.Context, maddr address.Address, s abi.SectorNumber, tsk chain.TipSetKey) (bool, error) - // Rule[perm:read] - StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) - // Rule[perm:read] - StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorOnChainInfo, error) - // Rule[perm:read] - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorLocation, error) - // Rule[perm:read] - StateMinerSectorSize(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (abi.SectorSize, error) - // Rule[perm:read] - StateMinerInfo(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (miner.MinerInfo, error) - // Rule[perm:read] - StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (address.Address, error) - // Rule[perm:read] - StateMinerRecoveries(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) - // Rule[perm:read] - StateMinerFaults(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) - // Rule[perm:read] - StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (*dline.Info, error) - // Rule[perm:read] - StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tsk chain.TipSetKey) ([]chain2.Partition, error) - // Rule[perm:read] - StateMinerDeadlines(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]chain2.Deadline, error) - // Rule[perm:read] - StateMinerSectors(ctx context.Context, maddr address.Address, sectorNos *bitfield.BitField, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) - // Rule[perm:read] - StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tsk chain.TipSetKey) (*chain2.MarketDeal, error) - // Rule[perm:read] - StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - StateVMCirculatingSupplyInternal(ctx context.Context, tsk chain.TipSetKey) (chain.CirculatingSupply, error) - // Rule[perm:read] - StateCirculatingSupply(ctx context.Context, tsk chain.TipSetKey) (abi.TokenAmount, error) - // Rule[perm:read] - StateMarketDeals(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketDeal, error) - // Rule[perm:read] - StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) - // Rule[perm:read] - StateLookupID(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) - // Rule[perm:read] - StateListMiners(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) - // Rule[perm:read] - StateListActors(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) - // Rule[perm:read] - StateMinerPower(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*chain2.MinerPower, error) - // Rule[perm:read] - StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorExpiration, error) - // Rule[perm:read] - StateMinerSectorCount(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MinerSectors, error) - // Rule[perm:read] - StateMarketBalance(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MarketBalance, error) - // Rule[perm:read] - StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk chain.TipSetKey) (chain2.DealCollateralBounds, error) - // Rule[perm:read] - StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) + StateMinerSectorAllocated(ctx context.Context, maddr address.Address, s abi.SectorNumber, tsk chain.TipSetKey) (bool, error) //perm:read + StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) //perm:read + StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorLocation, error) //perm:read + StateMinerSectorSize(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (abi.SectorSize, error) //perm:read + StateMinerInfo(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (miner.MinerInfo, error) //perm:read + StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (address.Address, error) //perm:read + StateMinerRecoveries(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) //perm:read + StateMinerFaults(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (bitfield.BitField, error) //perm:read + StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (*dline.Info, error) //perm:read + StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tsk chain.TipSetKey) ([]chain2.Partition, error) //perm:read + StateMinerDeadlines(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]chain2.Deadline, error) //perm:read + StateMinerSectors(ctx context.Context, maddr address.Address, sectorNos *bitfield.BitField, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) //perm:read + StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tsk chain.TipSetKey) (*chain2.MarketDeal, error) //perm:read + StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) //perm:read + StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk chain.TipSetKey) (big.Int, error) //perm:read + StateVMCirculatingSupplyInternal(ctx context.Context, tsk chain.TipSetKey) (chain.CirculatingSupply, error) //perm:read + StateCirculatingSupply(ctx context.Context, tsk chain.TipSetKey) (abi.TokenAmount, error) //perm:read + StateMarketDeals(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketDeal, error) //perm:read + StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) ([]*miner.SectorOnChainInfo, error) //perm:read + StateLookupID(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (address.Address, error) //perm:read + StateListMiners(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) //perm:read + StateListActors(ctx context.Context, tsk chain.TipSetKey) ([]address.Address, error) //perm:read + StateMinerPower(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*chain2.MinerPower, error) //perm:read + StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk chain.TipSetKey) (big.Int, error) //perm:read + StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk chain.TipSetKey) (*miner.SectorExpiration, error) //perm:read + StateMinerSectorCount(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MinerSectors, error) //perm:read + StateMarketBalance(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (chain2.MarketBalance, error) //perm:read + StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk chain.TipSetKey) (chain2.DealCollateralBounds, error) //perm:read + StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk chain.TipSetKey) (*abi.StoragePower, error) //perm:read } diff --git a/venus-shared/api/chain/v1/fullnode.go b/venus-shared/api/chain/v1/fullnode.go index 25b7743348..aad482dd0a 100644 --- a/venus-shared/api/chain/v1/fullnode.go +++ b/venus-shared/api/chain/v1/fullnode.go @@ -1,16 +1,3 @@ -/* -in api interface, you can add comment tags to the function -Note: -Rule[perm:admin,ignore:true] -perm: read,write,sign,admin -jwt token permission check -ignore: bool -the func in the api whether needs to be added to the client for external exposure - -TODO: -1. Support global FUNC injection - -*/ package v1 //go:generate go run github.com/golang/mock/mockgen@v1.6.0 -destination=./mock/full.go -package=mock . FullNode diff --git a/venus-shared/api/chain/v1/jwtauth.go b/venus-shared/api/chain/v1/jwtauth.go index d2c24ca86f..5b412252a1 100644 --- a/venus-shared/api/chain/v1/jwtauth.go +++ b/venus-shared/api/chain/v1/jwtauth.go @@ -7,8 +7,6 @@ import ( ) type IJwtAuthAPI interface { - // Rule[perm:read] - Verify(ctx context.Context, host, token string) ([]auth.Permission, error) - // Rule[perm:admin] - AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) + Verify(ctx context.Context, host, token string) ([]auth.Permission, error) //perm:read + AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) //perm:admin } diff --git a/venus-shared/api/chain/v1/market.go b/venus-shared/api/chain/v1/market.go index fc0119d888..c6c3e0cee3 100644 --- a/venus-shared/api/chain/v1/market.go +++ b/venus-shared/api/chain/v1/market.go @@ -8,6 +8,5 @@ import ( ) type IMarket interface { - // Rule[perm:read] - StateMarketParticipants(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketBalance, error) //perm:admin + StateMarketParticipants(ctx context.Context, tsk chain.TipSetKey) (map[string]chain2.MarketBalance, error) //perm:read } diff --git a/venus-shared/api/chain/v1/mining.go b/venus-shared/api/chain/v1/mining.go index abbebb9da9..d881a2d4a2 100644 --- a/venus-shared/api/chain/v1/mining.go +++ b/venus-shared/api/chain/v1/mining.go @@ -11,8 +11,6 @@ import ( ) type IMining interface { - // Rule[perm:read] - MinerGetBaseInfo(ctx context.Context, maddr address.Address, round abi.ChainEpoch, tsk chain.TipSetKey) (*chain2.MiningBaseInfo, error) - // Rule[perm:write] - MinerCreateBlock(ctx context.Context, bt *chain2.BlockTemplate) (*chain.BlockMsg, error) + MinerGetBaseInfo(ctx context.Context, maddr address.Address, round abi.ChainEpoch, tsk chain.TipSetKey) (*chain2.MiningBaseInfo, error) //perm:read + MinerCreateBlock(ctx context.Context, bt *chain2.BlockTemplate) (*chain.BlockMsg, error) //perm:write } diff --git a/venus-shared/api/chain/v1/mpool.go b/venus-shared/api/chain/v1/mpool.go index 0d16538217..584239f18f 100644 --- a/venus-shared/api/chain/v1/mpool.go +++ b/venus-shared/api/chain/v1/mpool.go @@ -13,57 +13,32 @@ import ( ) type IMessagePool interface { - // Rule[perm:admin] - MpoolDeleteByAdress(ctx context.Context, addr address.Address) error - // Rule[perm:write] - MpoolPublishByAddr(context.Context, address.Address) error - // Rule[perm:write] - MpoolPublishMessage(ctx context.Context, smsg *chain.SignedMessage) error - // Rule[perm:write] - MpoolPush(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) - // Rule[perm:read] - MpoolGetConfig(context.Context) (*messagepool.MpoolConfig, error) - // Rule[perm:admin] - MpoolSetConfig(ctx context.Context, cfg *messagepool.MpoolConfig) error - // Rule[perm:read] - MpoolSelect(context.Context, chain.TipSetKey, float64) ([]*chain.SignedMessage, error) - // Rule[perm:read] - MpoolSelects(context.Context, chain.TipSetKey, []float64) ([][]*chain.SignedMessage, error) - // Rule[perm:read] - MpoolPending(ctx context.Context, tsk chain.TipSetKey) ([]*chain.SignedMessage, error) - // Rule[perm:write] - MpoolClear(ctx context.Context, local bool) error - // Rule[perm:write] - MpoolPushUntrusted(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) - // Rule[perm:sign] - MpoolPushMessage(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec) (*chain.SignedMessage, error) - // Rule[perm:write] - MpoolBatchPush(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) - // Rule[perm:write] - MpoolBatchPushUntrusted(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) - // Rule[perm:sign] - MpoolBatchPushMessage(ctx context.Context, msgs []*chain.Message, spec *chain2.MessageSendSpec) ([]*chain.SignedMessage, error) - // Rule[perm:read] - MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) - // Rule[perm:read] - MpoolSub(ctx context.Context) (<-chan messagepool.MpoolUpdate, error) - // Rule[perm:read] - GasEstimateMessageGas(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec, tsk chain.TipSetKey) (*chain.Message, error) - // Rule[perm:read] - GasBatchEstimateMessageGas(ctx context.Context, estimateMessages []*chain2.EstimateMessage, fromNonce uint64, tsk chain.TipSetKey) ([]*chain2.EstimateResult, error) - // Rule[perm:read] - GasEstimateFeeCap(ctx context.Context, msg *chain.Message, maxqueueblks int64, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:read] - GasEstimateGasLimit(ctx context.Context, msgIn *chain.Message, tsk chain.TipSetKey) (int64, error) + MpoolDeleteByAdress(ctx context.Context, addr address.Address) error //perm:admin + MpoolPublishByAddr(context.Context, address.Address) error //perm:write + MpoolPublishMessage(ctx context.Context, smsg *chain.SignedMessage) error //perm:write + MpoolPush(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) //perm:write + MpoolGetConfig(context.Context) (*messagepool.MpoolConfig, error) //perm:read + MpoolSetConfig(ctx context.Context, cfg *messagepool.MpoolConfig) error //perm:admin + MpoolSelect(context.Context, chain.TipSetKey, float64) ([]*chain.SignedMessage, error) //perm:read + MpoolSelects(context.Context, chain.TipSetKey, []float64) ([][]*chain.SignedMessage, error) //perm:read + MpoolPending(ctx context.Context, tsk chain.TipSetKey) ([]*chain.SignedMessage, error) //perm:read + MpoolClear(ctx context.Context, local bool) error //perm:write + MpoolPushUntrusted(ctx context.Context, smsg *chain.SignedMessage) (cid.Cid, error) //perm:write + MpoolPushMessage(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec) (*chain.SignedMessage, error) //perm:sign + MpoolBatchPush(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) //perm:write + MpoolBatchPushUntrusted(ctx context.Context, smsgs []*chain.SignedMessage) ([]cid.Cid, error) //perm:write + MpoolBatchPushMessage(ctx context.Context, msgs []*chain.Message, spec *chain2.MessageSendSpec) ([]*chain.SignedMessage, error) //perm:sign + MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) //perm:read + MpoolSub(ctx context.Context) (<-chan messagepool.MpoolUpdate, error) //perm:read + GasEstimateMessageGas(ctx context.Context, msg *chain.Message, spec *chain2.MessageSendSpec, tsk chain.TipSetKey) (*chain.Message, error) //perm:read + GasBatchEstimateMessageGas(ctx context.Context, estimateMessages []*chain2.EstimateMessage, fromNonce uint64, tsk chain.TipSetKey) ([]*chain2.EstimateResult, error) //perm:read + GasEstimateFeeCap(ctx context.Context, msg *chain.Message, maxqueueblks int64, tsk chain.TipSetKey) (big.Int, error) //perm:read + GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk chain.TipSetKey) (big.Int, error) //perm:read + GasEstimateGasLimit(ctx context.Context, msgIn *chain.Message, tsk chain.TipSetKey) (int64, error) //perm:read // MpoolCheckMessages performs logical checks on a batch of messages - // Rule[perm:read] - MpoolCheckMessages(ctx context.Context, protos []*messagepool.MessagePrototype) ([][]messagepool.MessageCheckStatus, error) + MpoolCheckMessages(ctx context.Context, protos []*messagepool.MessagePrototype) ([][]messagepool.MessageCheckStatus, error) //perm:read // MpoolCheckPendingMessages performs logical checks for all pending messages from a given address - // Rule[perm:read] - MpoolCheckPendingMessages(ctx context.Context, addr address.Address) ([][]messagepool.MessageCheckStatus, error) + MpoolCheckPendingMessages(ctx context.Context, addr address.Address) ([][]messagepool.MessageCheckStatus, error) //perm:read // MpoolCheckReplaceMessages performs logical checks on pending messages with replacement - // Rule[perm:read] - MpoolCheckReplaceMessages(ctx context.Context, msg []*chain.Message) ([][]messagepool.MessageCheckStatus, error) + MpoolCheckReplaceMessages(ctx context.Context, msg []*chain.Message) ([][]messagepool.MessageCheckStatus, error) //perm:read } diff --git a/venus-shared/api/chain/v1/multisig.go b/venus-shared/api/chain/v1/multisig.go index 41b8a6f198..e72eac71fb 100644 --- a/venus-shared/api/chain/v1/multisig.go +++ b/venus-shared/api/chain/v1/multisig.go @@ -11,30 +11,17 @@ import ( ) type IMultiSig interface { - // Rule[perm:sign] - MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val chain.BigInt, src address.Address, gp chain.BigInt) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigApproveTxnHash(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (*messagepool.MessagePrototype, error) - // Rule[perm:sign] - MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (*messagepool.MessagePrototype, error) - // Rule[perm:read] - MsigGetVested(ctx context.Context, addr address.Address, start chain.TipSetKey, end chain.TipSetKey) (chain.BigInt, error) + MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val chain.BigInt, src address.Address, gp chain.BigInt) (*messagepool.MessagePrototype, error) //perm:sign + MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (*messagepool.MessagePrototype, error) //perm:sign + MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (*messagepool.MessagePrototype, error) //perm:sign + MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (*messagepool.MessagePrototype, error) //perm:sign + MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (*messagepool.MessagePrototype, error) //perm:sign + MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (*messagepool.MessagePrototype, error) //perm:sign + MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (*messagepool.MessagePrototype, error) //perm:sign + MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (*messagepool.MessagePrototype, error) //perm:sign + MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (*messagepool.MessagePrototype, error) //perm:sign + MsigApproveTxnHash(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (*messagepool.MessagePrototype, error) //perm:sign + MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt chain.BigInt, src address.Address, method uint64, params []byte) (*messagepool.MessagePrototype, error) //perm:sign + MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (*messagepool.MessagePrototype, error) //perm:sign + MsigGetVested(ctx context.Context, addr address.Address, start chain.TipSetKey, end chain.TipSetKey) (chain.BigInt, error) //perm:read } diff --git a/venus-shared/api/chain/v1/network.go b/venus-shared/api/chain/v1/network.go index 5935fc53de..1b1d291491 100644 --- a/venus-shared/api/chain/v1/network.go +++ b/venus-shared/api/chain/v1/network.go @@ -13,24 +13,14 @@ import ( ) type INetwork interface { - // Rule[perm:admin] - NetworkGetBandwidthStats(ctx context.Context) metrics.Stats - // Rule[perm:admin] - NetworkGetPeerAddresses(ctx context.Context) []ma.Multiaddr - // Rule[perm:admin] - NetworkGetPeerID(ctx context.Context) peer.ID - // Rule[perm:read] - NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo - // Rule[perm:read] - NetworkGetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error) - // Rule[perm:read] - NetworkFindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error) - // Rule[perm:read] - NetworkConnect(ctx context.Context, addrs []string) (<-chan net.ConnectionResult, error) - // Rule[perm:read] - NetworkPeers(ctx context.Context, verbose, latency, streams bool) (*net.SwarmConnInfos, error) - // Rule[perm:read] - Version(context.Context) (chain2.Version, error) - // Rule[perm:read] - NetAddrsListen(context.Context) (peer.AddrInfo, error) + NetworkGetBandwidthStats(ctx context.Context) metrics.Stats //perm:admin + NetworkGetPeerAddresses(ctx context.Context) []ma.Multiaddr //perm:admin + NetworkGetPeerID(ctx context.Context) peer.ID //perm:admin + NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo //perm:read + NetworkGetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error) //perm:read + NetworkFindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error) //perm:read + NetworkConnect(ctx context.Context, addrs []string) (<-chan net.ConnectionResult, error) //perm:read + NetworkPeers(ctx context.Context, verbose, latency, streams bool) (*net.SwarmConnInfos, error) //perm:read + Version(context.Context) (chain2.Version, error) //perm:read + NetAddrsListen(context.Context) (peer.AddrInfo, error) //perm:read } diff --git a/venus-shared/api/chain/v1/paych.go b/venus-shared/api/chain/v1/paych.go index c02d557f06..f726bcc1b5 100644 --- a/venus-shared/api/chain/v1/paych.go +++ b/venus-shared/api/chain/v1/paych.go @@ -16,68 +16,55 @@ type IPaychan interface { // @from: the payment channel sender // @to: the payment channel recipient // @amt: the deposits funds in the payment channel - // Rule[perm:sign] - PaychGet(ctx context.Context, from, to address.Address, amt big.Int) (*paych.ChannelInfo, error) + PaychGet(ctx context.Context, from, to address.Address, amt big.Int) (*paych.ChannelInfo, error) //perm:sign // PaychAvailableFunds get the status of an outbound payment channel // @pch: payment channel address - // Rule[perm:sign] - PaychAvailableFunds(ctx context.Context, ch address.Address) (*chain2.ChannelAvailableFunds, error) + PaychAvailableFunds(ctx context.Context, ch address.Address) (*chain2.ChannelAvailableFunds, error) //perm:sign // PaychAvailableFundsByFromTo get the status of an outbound payment channel // @from: the payment channel sender // @to: he payment channel recipient - // Rule[perm:sign] - PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*chain2.ChannelAvailableFunds, error) + PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*chain2.ChannelAvailableFunds, error) //perm:sign // PaychGetWaitReady waits until the create channel / add funds message with the sentinel // @sentinel: given message CID arrives. // @ch: the returned channel address can safely be used against the Manager methods. - // Rule[perm:sign] - PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error) + PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error) //perm:sign // PaychAllocateLane Allocate late creates a lane within a payment channel so that calls to // CreatePaymentVoucher will automatically make vouchers only for the difference in total - // Rule[perm:sign] - PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error) + PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error) //perm:sign // PaychNewPayment aggregate vouchers into a new lane // @from: the payment channel sender // @to: the payment channel recipient // @vouchers: the outstanding (non-redeemed) vouchers - // Rule[perm:sign] - PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []paych.VoucherSpec) (*paych.PaymentInfo, error) + PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []paych.VoucherSpec) (*paych.PaymentInfo, error) //perm:sign // PaychList list the addresses of all channels that have been created - // Rule[perm:read] - PaychList(ctx context.Context) ([]address.Address, error) + PaychList(ctx context.Context) ([]address.Address, error) //perm:read // PaychStatus get the payment channel status // @pch: payment channel address - // Rule[perm:read] - PaychStatus(ctx context.Context, pch address.Address) (*paych.Status, error) + PaychStatus(ctx context.Context, pch address.Address) (*paych.Status, error) //perm:read // PaychSettle update payment channel status to settle // After a settlement period (currently 12 hours) either party to the payment channel can call collect on chain // @pch: payment channel address - // Rule[perm:sign] - PaychSettle(ctx context.Context, addr address.Address) (cid.Cid, error) + PaychSettle(ctx context.Context, addr address.Address) (cid.Cid, error) //perm:sign // PaychCollect update payment channel status to collect // Collect sends the value of submitted vouchers to the channel recipient (the provider), // and refunds the remaining channel balance to the channel creator (the client). // @pch: payment channel address - // Rule[perm:sign] - PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) + PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) //perm:sign // PaychVoucherCheckValid checks if the given voucher is valid (is or could become spendable at some point). // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). // @pch: payment channel address // @sv: voucher - // Rule[perm:read] - PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error + PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error //perm:read // PaychVoucherCheckSpendable checks if the given voucher is currently spendable // @pch: payment channel address // @sv: voucher - // Rule[perm:read] - PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) + PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) //perm:read // PaychVoucherAdd adds a voucher for an inbound channel. // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). - // Rule[perm:write] - PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) + PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) //perm:write // PaychVoucherCreate creates a new signed voucher on the given payment channel // with the given lane and amount. The value passed in is exactly the value // that will be used to create the voucher, so if previous vouchers exist, the @@ -85,15 +72,12 @@ type IPaychan interface { // the two. // If there are insufficient funds in the channel to create the voucher, // returns a nil voucher and the shortfall. - // Rule[perm:sign] - PaychVoucherCreate(ctx context.Context, pch address.Address, amt big.Int, lane uint64) (*paych.VoucherCreateResult, error) + PaychVoucherCreate(ctx context.Context, pch address.Address, amt big.Int, lane uint64) (*paych.VoucherCreateResult, error) //perm:sign // PaychVoucherList list vouchers in payment channel // @pch: payment channel address - // Rule[perm:write] - PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) + PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) //perm:write // PaychVoucherSubmit Submit voucher to chain to update payment channel state // @pch: payment channel address // @sv: voucher in payment channel - // Rule[perm:sign] - PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) + PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) //perm:sign } diff --git a/venus-shared/api/chain/v1/syncer.go b/venus-shared/api/chain/v1/syncer.go index 7d9a434fbb..560e4ededa 100644 --- a/venus-shared/api/chain/v1/syncer.go +++ b/venus-shared/api/chain/v1/syncer.go @@ -10,20 +10,12 @@ import ( ) type ISyncer interface { - // Rule[perm:write] - ChainSyncHandleNewTipSet(ctx context.Context, ci *chain.ChainInfo) error - // Rule[perm:admin] - SetConcurrent(ctx context.Context, concurrent int64) error - // Rule[perm:read] - SyncerTracker(ctx context.Context) *chain2.TargetTracker - // Rule[perm:read] - Concurrent(ctx context.Context) int64 - // Rule[perm:read] - ChainTipSetWeight(ctx context.Context, tsk chain.TipSetKey) (big.Int, error) - // Rule[perm:write] - SyncSubmitBlock(ctx context.Context, blk *chain.BlockMsg) error - // Rule[perm:read] - StateCall(ctx context.Context, msg *chain.Message, tsk chain.TipSetKey) (*chain2.InvocResult, error) - // Rule[perm:read] - SyncState(ctx context.Context) (*chain2.SyncState, error) + ChainSyncHandleNewTipSet(ctx context.Context, ci *chain.ChainInfo) error //perm:write + SetConcurrent(ctx context.Context, concurrent int64) error //perm:admin + SyncerTracker(ctx context.Context) *chain2.TargetTracker //perm:read + Concurrent(ctx context.Context) int64 //perm:read + ChainTipSetWeight(ctx context.Context, tsk chain.TipSetKey) (big.Int, error) //perm:read + SyncSubmitBlock(ctx context.Context, blk *chain.BlockMsg) error //perm:write + StateCall(ctx context.Context, msg *chain.Message, tsk chain.TipSetKey) (*chain2.InvocResult, error) //perm:read + SyncState(ctx context.Context) (*chain2.SyncState, error) //perm:read } diff --git a/venus-shared/api/chain/v1/wallet.go b/venus-shared/api/chain/v1/wallet.go index 8c24d740a4..42c1c5dd6e 100644 --- a/venus-shared/api/chain/v1/wallet.go +++ b/venus-shared/api/chain/v1/wallet.go @@ -12,34 +12,19 @@ import ( ) type IWallet interface { - // Rule[perm:sign] - WalletSign(ctx context.Context, k address.Address, msg []byte, meta wallet.MsgMeta) (*crypto.Signature, error) - // Rule[perm:admin] - WalletExport(addr address.Address, password string) (*wallet.KeyInfo, error) - // Rule[perm:admin] - WalletImport(key *wallet.KeyInfo) (address.Address, error) - // Rule[perm:write] - WalletHas(ctx context.Context, addr address.Address) (bool, error) - // Rule[perm:write] - WalletNewAddress(protocol address.Protocol) (address.Address, error) - // Rule[perm:read] - WalletBalance(ctx context.Context, addr address.Address) (abi.TokenAmount, error) //not exists in remote - // Rule[perm:write] - WalletDefaultAddress(ctx context.Context) (address.Address, error) //not exists in remote - // Rule[perm:admin] - WalletAddresses(ctx context.Context) []address.Address - // Rule[perm:write] - WalletSetDefault(ctx context.Context, addr address.Address) error //not exists in remote - // Rule[perm:sign] - WalletSignMessage(ctx context.Context, k address.Address, msg *chain.Message) (*chain.SignedMessage, error) - // Rule[perm:admin] - LockWallet(ctx context.Context) error - // Rule[perm:admin] - UnLockWallet(ctx context.Context, password []byte) error - // Rule[perm:admin] - SetPassword(Context context.Context, password []byte) error - // Rule[perm:admin] - HasPassword(Context context.Context) bool - // Rule[perm:admin] - WalletState(Context context.Context) int + WalletSign(ctx context.Context, k address.Address, msg []byte, meta wallet.MsgMeta) (*crypto.Signature, error) //perm:sign + WalletExport(addr address.Address, password string) (*wallet.KeyInfo, error) //perm:admin + WalletImport(key *wallet.KeyInfo) (address.Address, error) //perm:admin + WalletHas(ctx context.Context, addr address.Address) (bool, error) //perm:write + WalletNewAddress(protocol address.Protocol) (address.Address, error) //perm:write + WalletBalance(ctx context.Context, addr address.Address) (abi.TokenAmount, error) //perm:read + WalletDefaultAddress(ctx context.Context) (address.Address, error) //perm:write + WalletAddresses(ctx context.Context) []address.Address //perm:admin + WalletSetDefault(ctx context.Context, addr address.Address) error //perm:write + WalletSignMessage(ctx context.Context, k address.Address, msg *chain.Message) (*chain.SignedMessage, error) //perm:sign + LockWallet(ctx context.Context) error //perm:admin + UnLockWallet(ctx context.Context, password []byte) error //perm:admin + SetPassword(Context context.Context, password []byte) error //perm:admin + HasPassword(Context context.Context) bool //perm:admin + WalletState(Context context.Context) int //perm:admin } diff --git a/venus-shared/api/proxy_util.go b/venus-shared/api/proxy_util.go new file mode 100644 index 0000000000..ba94a9e5dc --- /dev/null +++ b/venus-shared/api/proxy_util.go @@ -0,0 +1,30 @@ +package api + +import "reflect" + +var _internalField = "Internal" + +// GetInternalStructs extracts all pointers to 'Internal' sub-structs from the provided pointer to a proxy struct +func GetInternalStructs(in interface{}) []interface{} { + return getInternalStructs(reflect.ValueOf(in).Elem()) +} + +func getInternalStructs(rv reflect.Value) []interface{} { + var out []interface{} + + internal := rv.FieldByName(_internalField) + ii := internal.Addr().Interface() + out = append(out, ii) + + for i := 0; i < rv.NumField(); i++ { + if rv.Type().Field(i).Name == _internalField { + continue + } + + sub := getInternalStructs(rv.Field(i)) + + out = append(out, sub...) + } + + return out +} diff --git a/venus-shared/api/proxy_util_test.go b/venus-shared/api/proxy_util_test.go new file mode 100644 index 0000000000..3cbc466b6a --- /dev/null +++ b/venus-shared/api/proxy_util_test.go @@ -0,0 +1,62 @@ +package api + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +type StrA struct { + StrB + + Internal struct { + A int + } +} + +type StrB struct { + Internal struct { + B int + } +} + +type StrC struct { + Internal struct { + Internal struct { + C int + } + } +} + +func TestGetInternalStructs(t *testing.T) { + var proxy StrA + + sts := GetInternalStructs(&proxy) + require.Len(t, sts, 2) + + sa := sts[0].(*struct{ A int }) + sa.A = 3 + sb := sts[1].(*struct{ B int }) + sb.B = 4 + + require.Equal(t, 3, proxy.Internal.A) + require.Equal(t, 4, proxy.StrB.Internal.B) +} + +func TestNestedInternalStructs(t *testing.T) { + var proxy StrC + + // check that only the top-level internal struct gets picked up + + sts := GetInternalStructs(&proxy) + require.Len(t, sts, 1) + + sa := sts[0].(*struct { + Internal struct { + C int + } + }) + sa.Internal.C = 5 + + require.Equal(t, 5, proxy.Internal.Internal.C) +}