Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/fix api permission #4626

Merged
merged 5 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ jobs:
fingerprints:
- "1e:73:c5:15:75:e0:e4:98:54:3c:2b:9e:e8:94:14:2e"
- checkout
- clone_lotus
- update_submodules
# Save the Git SHA of the rust-fil-proofs submodule so that we can use it when creating a cache key
- generate_rust_submodules_checksums
Expand All @@ -199,6 +200,9 @@ jobs:
cmd: "lint"
- go_build:
cmd: "build"
- go_build:
cmd: "gen-api"
- check_file_change
# place the filecoin binary in PATH for IPTB
- go_build:
cmd: "install"
Expand Down Expand Up @@ -749,6 +753,21 @@ commands:
name: fetch all tags
command: |
git fetch --all
clone_lotus:
steps:
- run:
name: Clone lotus
command: |
mkdir -p ${GOPATH}/pkg/mod/github.com/filecoin-project
cd ${GOPATH}/pkg/mod/github.com/filecoin-project
git clone -b v1.12.0 https://github.com/filecoin-project/lotus.git
check_file_change:
steps:
- run:
name: Check api file change
command: |
cd /go/src/github.com/filecoin-project/venus
bash ./scripts/check_api_file_change.sh
go_build:
parameters:
cmd:
Expand Down
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
export CGO_CFLAGS_ALLOW=-D__BLST_PORTABLE__
export CGO_CFLAGS=-D__BLST_PORTABLE__

all:
go run ./build/*.go build

deps:
git submodule update --init
go run ./build/*.go smartdeps

lint:
go run ./build/*.go lint

test:
go run ./build/*.go test -timeout=30m

# WARNING THIS BUILDS A GO PLUGIN AND PLUGINS *DO NOT* WORK ON WINDOWS SYSTEMS
iptb:
make -C tools/iptb-plugins all

clean:
rm ./venus

rm -rf ./extern/filecoin-ffi
rm -rf ./extern/test-vectors

gen-api:
go run ./tools/gen/api/proxygen.go
gofmt -s -l -w ./app/client/full.go
gofmt -s -l -w ./app/client/v0api/full.go

compare-api:
go run ./tools/gen/api/proxygen.go compare

gen-asset:
go-bindata -pkg=asset -o ./fixtures/asset/asset.go ./fixtures/_assets/car/ ./fixtures/_assets/proof-params/ ./fixtures/_assets/arch-diagram.monopic


### shared module ###
cborgen:
cd venus-devtool && go run ./cborgen/*.go

Expand Down
33 changes: 0 additions & 33 deletions Makefile.bak

This file was deleted.

5 changes: 3 additions & 2 deletions app/client/apiface/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package apiface

import (
"context"
"io"

"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
"io"
)

type IDagService interface {
Expand All @@ -14,6 +15,6 @@ type IDagService interface {
DAGGetFileSize(ctx context.Context, c cid.Cid) (uint64, error)
// Rule[perm:read]
DAGCat(ctx context.Context, c cid.Cid) (io.Reader, error)
// Rule[perm:read]
// Rule[perm:write]
DAGImportData(ctx context.Context, data io.Reader) (ipld.Node, error)
}
2 changes: 1 addition & 1 deletion app/client/apiface/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type IBlockStore interface {
// Rule[perm:read]
ChainReadObj(ctx context.Context, ocid cid.Cid) ([]byte, error)
// Rule[perm:read]
// Rule[perm:admin]
ChainDeleteObj(ctx context.Context, obj cid.Cid) error
// Rule[perm:read]
ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error)
Expand Down
2 changes: 1 addition & 1 deletion app/client/apiface/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type IChainInfo interface {
ChainList(ctx context.Context, tsKey types.TipSetKey, count int) ([]types.TipSetKey, error)
// Rule[perm:read]
ChainHead(ctx context.Context) (*types.TipSet, error)
// Rule[perm:read]
// Rule[perm:admin]
ChainSetHead(ctx context.Context, key types.TipSetKey) error
// Rule[perm:read]
ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error)
Expand Down
2 changes: 1 addition & 1 deletion app/client/apiface/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package apiface
import "context"

type IConfig interface {
// Rule[perm:read]
// Rule[perm:admin]
ConfigSet(ctx context.Context, dottedPath string, paramJSON string) error
// Rule[perm:read]
ConfigGet(ctx context.Context, dottedPath string) (interface{}, error)
Expand Down
3 changes: 2 additions & 1 deletion app/client/apiface/jwtauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package apiface

import (
"context"

"github.com/filecoin-project/go-jsonrpc/auth"
)

type IJwtAuthAPI interface {
// Rule[perm:read]
Verify(ctx context.Context, host, token string) ([]auth.Permission, error)
// Rule[perm:read]
// Rule[perm:admin]
AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error)
}
3 changes: 2 additions & 1 deletion app/client/apiface/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiface

import (
"context"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/venus/app/submodule/apitypes"
Expand All @@ -11,6 +12,6 @@ import (
type IMining interface {
// Rule[perm:read]
MinerGetBaseInfo(ctx context.Context, maddr address.Address, round abi.ChainEpoch, tsk types.TipSetKey) (*apitypes.MiningBaseInfo, error)
// Rule[perm:read]
// Rule[perm:write]
MinerCreateBlock(ctx context.Context, bt *apitypes.BlockTemplate) (*types.BlockMsg, error)
}
22 changes: 11 additions & 11 deletions app/client/apiface/mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ import (
)

type IMessagePool interface {
// Rule[perm:read]
// Rule[perm:admin]
MpoolDeleteByAdress(ctx context.Context, addr address.Address) error
// Rule[perm:read]
// Rule[perm:write]
MpoolPublishByAddr(context.Context, address.Address) error
// Rule[perm:read]
// Rule[perm:write]
MpoolPublishMessage(ctx context.Context, smsg *types.SignedMessage) error
// Rule[perm:read]
// Rule[perm:write]
MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error)
// Rule[perm:read]
MpoolGetConfig(context.Context) (*messagepool.MpoolConfig, error)
// Rule[perm:read]
// Rule[perm:admin]
MpoolSetConfig(ctx context.Context, cfg *messagepool.MpoolConfig) error
// Rule[perm:read]
MpoolSelect(context.Context, types.TipSetKey, float64) ([]*types.SignedMessage, error)
// Rule[perm:read]
MpoolSelects(context.Context, types.TipSetKey, []float64) ([][]*types.SignedMessage, error)
// Rule[perm:read]
MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error)
// Rule[perm:read]
// Rule[perm:write]
MpoolClear(ctx context.Context, local bool) error
// Rule[perm:read]
// Rule[perm:write]
MpoolPushUntrusted(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error)
// Rule[perm:read]
// Rule[perm:sign]
MpoolPushMessage(ctx context.Context, msg *types.UnsignedMessage, spec *types.MessageSendSpec) (*types.SignedMessage, error)
// Rule[perm:read]
// Rule[perm:write]
MpoolBatchPush(ctx context.Context, smsgs []*types.SignedMessage) ([]cid.Cid, error)
// Rule[perm:read]
// Rule[perm:write]
MpoolBatchPushUntrusted(ctx context.Context, smsgs []*types.SignedMessage) ([]cid.Cid, error)
// Rule[perm:read]
// Rule[perm:sign]
MpoolBatchPushMessage(ctx context.Context, msgs []*types.UnsignedMessage, spec *types.MessageSendSpec) ([]*types.SignedMessage, error)
// Rule[perm:read]
MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error)
Expand Down
24 changes: 12 additions & 12 deletions app/client/apiface/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ import (
)

type IMultiSig interface {
// Rule[perm:read]
// Rule[perm:sign]
MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigApproveTxnHash(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigCancel(ctx context.Context, msig address.Address, txID uint64, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
// Rule[perm:sign]
MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (*apitypes.MessagePrototype, error)
// Rule[perm:read]
MsigGetVested(ctx context.Context, addr address.Address, start types.TipSetKey, end types.TipSetKey) (types.BigInt, error)
Expand Down
1 change: 1 addition & 0 deletions app/client/apiface/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiface

import (
"context"

"github.com/filecoin-project/venus/app/submodule/apitypes"

"github.com/filecoin-project/venus/pkg/net"
Expand Down
25 changes: 13 additions & 12 deletions app/client/apiface/paych.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiface

import (
"context"

"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/venus/app/submodule/apitypes"
"github.com/filecoin-project/venus/pkg/paychmgr"
Expand All @@ -18,31 +19,31 @@ type IPaychan interface {
// @from: the payment channel sender
// @to: the payment channel recipient
// @amt: the deposits funds in the payment channel
// Rule[perm:read]
// Rule[perm:sign]
PaychGet(ctx context.Context, from, to address.Address, amt big.Int) (*apitypes.ChannelInfo, error)
// PaychAvailableFunds get the status of an outbound payment channel
// @pch: payment channel address
// Rule[perm:read]
// Rule[perm:sign]
PaychAvailableFunds(ctx context.Context, ch address.Address) (*paychmgr.ChannelAvailableFunds, error)
// PaychAvailableFundsByFromTo get the status of an outbound payment channel
// @from: the payment channel sender
// @to: he payment channel recipient
// Rule[perm:read]
// Rule[perm:sign]
PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*paychmgr.ChannelAvailableFunds, error)
// 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:read]
// Rule[perm:sign]
PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error)
// 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:read]
// Rule[perm:sign]
PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error)
// 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:read]
// Rule[perm:sign]
PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []apitypes.VoucherSpec) (*apitypes.PaymentInfo, error)
// PaychList list the addresses of all channels that have been created
// Rule[perm:read]
Expand All @@ -54,13 +55,13 @@ type IPaychan interface {
// 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:read]
// Rule[perm:sign]
PaychSettle(ctx context.Context, addr address.Address) (cid.Cid, error)
// 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:read]
// Rule[perm:sign]
PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error)

// PaychVoucherCheckValid checks if the given voucher is valid (is or could become spendable at some point).
Expand All @@ -78,7 +79,7 @@ type IPaychan interface {
// 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:read]
// Rule[perm:write]
PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error)
// 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
Expand All @@ -87,15 +88,15 @@ 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:read]
// Rule[perm:sign]
PaychVoucherCreate(ctx context.Context, pch address.Address, amt big.Int, lane uint64) (*paychmgr.VoucherCreateResult, error)
// PaychVoucherList list vouchers in payment channel
// @pch: payment channel address
// Rule[perm:read]
// Rule[perm:write]
PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error)
// PaychVoucherSubmit Submit voucher to chain to update payment channel state
// @pch: payment channel address
// @sv: voucher in payment channel
// Rule[perm:read]
// Rule[perm:sign]
PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error)
}
Loading