Skip to content

Commit 73c8c83

Browse files
diwufeiwenta0lisimlecode
authored
update spec-actor v5 (#4456)
* upgrade to actor-v5 * upgrade selectMsg for actor v5 * add proof-params srs-inner-product.json * upgrade ffi and go-paramfetch (#4466) * upgrade api (#4468) * update specactors (#4469) * fix test (#4470) * fix v1api not in effect and update calibnet (#4471) * fix v1api not in effect * updata calibnet * Set HyperDrive upgrade epoch (#4473) * Set HyperDrive upgrade epoch * Upgrade acotr v5.0.1 * fix test Co-authored-by: 一页素书 <[email protected]> Co-authored-by: tom <[email protected]> Co-authored-by: simlecode <[email protected]>
1 parent 8ea7419 commit 73c8c83

File tree

271 files changed

+12457
-2053
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+12457
-2053
lines changed

.circleci/config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ jobs:
5353
- run:
5454
name: Install go
5555
command: |
56-
curl -O https://dl.google.com/go/go1.14.4.darwin-amd64.pkg && \
57-
sudo installer -pkg go1.14.4.darwin-amd64.pkg -target /
56+
curl -O https://dl.google.com/go/go1.16.4.darwin-amd64.pkg && \
57+
sudo installer -pkg go1.16.4.darwin-amd64.pkg -target /
5858
- run:
5959
name: Install pkg-config
6060
command: |
@@ -115,7 +115,7 @@ jobs:
115115

116116
deps_linux:
117117
docker:
118-
- image: circleci/golang:1.16.2-stretch
118+
- image: circleci/golang:1.16.4
119119
environment:
120120
GOPROXY: "https://goproxy.io,direct"
121121
working_directory: /go/src/github.com/filecoin-project/venus

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ deps:
88
git submodule update --init
99
go run ./build/*.go smartdeps
1010

11+
lint:
12+
go run ./build/*.go lint
13+
14+
test:
15+
go run ./build/*.go test -timeout=30m
16+
1117
# WARNING THIS BUILDS A GO PLUGIN AND PLUGINS *DO NOT* WORK ON WINDOWS SYSTEMS
1218
iptb:
1319
make -C tools/iptb-plugins all
@@ -23,8 +29,5 @@ gen:
2329
gofmt -s -l -w ./app/client/client_gen.go
2430
goimports -l -w ./app/client/client_gen.go
2531

26-
lint:
27-
go run ./build/*.go lint
28-
29-
test:
30-
go run ./build/*.go test --timeout=30m
32+
gen-asset:
33+
go-bindata -pkg=asset -o ./fixtures/asset/asset.go ./fixtures/_assets/car/ ./fixtures/_assets/proof-params/ ./fixtures/_assets/arch-diagram.monopic

app/client/full.go

+278
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/client/node.go

+31-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,38 @@ package client
22

33
import (
44
"context"
5+
"io/ioutil"
6+
"net/http"
7+
"path"
8+
59
"github.com/filecoin-project/go-jsonrpc"
610
"github.com/multiformats/go-multiaddr"
711
manet "github.com/multiformats/go-multiaddr/net"
8-
"net/http"
12+
13+
"github.com/filecoin-project/venus/app/paths"
914
)
1015

11-
func getVenusClientInfo(api, token string) (string, http.Header, error) {
16+
func getVenusClientInfo(version string) (string, http.Header, error) {
17+
repoPath, err := paths.GetRepoPath("")
18+
if err != nil {
19+
return "", nil, err
20+
}
21+
22+
tokePath := path.Join(repoPath, "token")
23+
rpcPath := path.Join(repoPath, "api")
24+
25+
tokenBytes, err := ioutil.ReadFile(tokePath)
26+
if err != nil {
27+
return "", nil, err
28+
}
29+
rpcBytes, err := ioutil.ReadFile(rpcPath)
30+
if err != nil {
31+
return "", nil, err
32+
}
33+
1234
headers := http.Header{}
13-
headers.Add("Authorization", "Bearer "+token)
14-
apima, err := multiaddr.NewMultiaddr(api)
35+
headers.Add("Authorization", "Bearer "+string(tokenBytes))
36+
apima, err := multiaddr.NewMultiaddr(string(rpcBytes))
1537
if err != nil {
1638
return "", nil, err
1739
}
@@ -21,22 +43,24 @@ func getVenusClientInfo(api, token string) (string, http.Header, error) {
2143
return "", nil, err
2244
}
2345

24-
addr = "ws://" + addr + "/rpc/v0"
46+
addr = "ws://" + addr + "/rpc/" + version
2547
return addr, headers, nil
2648
}
2749

2850
//NewFullNode It is used to construct a full node access client.
2951
//The API can be obtained from ~ /. Venus / API file, read from ~ /. Venus / token in local JWT mode,
3052
//and obtained from Venus auth service in central authorization mode.
31-
func NewFullNode(ctx context.Context, url, token string) (FullNodeStruct, jsonrpc.ClientCloser, error) {
32-
addr, headers, err := getVenusClientInfo(url, token)
53+
func GetFullNodeAPI(ctx context.Context, version string) (FullNodeStruct, jsonrpc.ClientCloser, error) {
54+
addr, headers, err := getVenusClientInfo(version)
3355
if err != nil {
3456
return FullNodeStruct{}, nil, err
3557
}
58+
3659
node := FullNodeStruct{}
3760
closer, err := jsonrpc.NewClient(ctx, addr, "Filecoin", &node, headers)
3861
if err != nil {
3962
return FullNodeStruct{}, nil, err
4063
}
64+
4165
return node, closer, nil
4266
}

app/client/client_gen.go app/client/v0api/full.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
// Code generated by github.com/filecoin-project/tools/gen/api. DO NOT EDIT.
2-
3-
package client
1+
package v0api
42

53
import (
64
"context"
75
"io"
86
"time"
97

8+
"github.com/ipfs/go-cid"
9+
ipld "github.com/ipfs/go-ipld-format"
10+
"github.com/libp2p/go-libp2p-core/metrics"
11+
"github.com/libp2p/go-libp2p-core/peer"
12+
ma "github.com/multiformats/go-multiaddr"
13+
1014
"github.com/filecoin-project/go-address"
1115
"github.com/filecoin-project/go-bitfield"
1216
"github.com/filecoin-project/go-jsonrpc/auth"
@@ -23,15 +27,9 @@ import (
2327
"github.com/filecoin-project/venus/pkg/messagepool"
2428
"github.com/filecoin-project/venus/pkg/net"
2529
"github.com/filecoin-project/venus/pkg/specactors/builtin/miner"
26-
"github.com/filecoin-project/venus/pkg/specactors/builtin/power"
2730
pstate "github.com/filecoin-project/venus/pkg/state"
2831
"github.com/filecoin-project/venus/pkg/types"
2932
"github.com/filecoin-project/venus/pkg/wallet"
30-
"github.com/ipfs/go-cid"
31-
ipld "github.com/ipfs/go-ipld-format"
32-
"github.com/libp2p/go-libp2p-core/metrics"
33-
"github.com/libp2p/go-libp2p-core/peer"
34-
ma "github.com/multiformats/go-multiaddr"
3533
)
3634

3735
type FullNodeStruct struct {
@@ -109,11 +107,13 @@ type IChainInfoStruct struct {
109107
MessageWait func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch, p3 abi.ChainEpoch) (*chain.ChainMessage, error) `perm:"read"`
110108
ProtocolParameters func(p0 context.Context) (*apitypes.ProtocolParams, error) `perm:"read"`
111109
ResolveToKeyAddr func(p0 context.Context, p1 address.Address, p2 *types.TipSet) (address.Address, error) `perm:"read"`
112-
StateGetReceipt func(p0 context.Context, p1 cid.Cid, p2 types.TipSetKey) (*types.MessageReceipt, error) `perm:"read"`
113110
StateNetworkName func(p0 context.Context) (apitypes.NetworkName, error) `perm:"read"`
114111
StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (network.Version, error) `perm:"read"`
115112
StateSearchMsg func(p0 context.Context, p1 cid.Cid) (*apitypes.MsgLookup, error) `perm:"read"`
116-
StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
113+
StateSearchMsgLimited func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
114+
StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64) (*apitypes.MsgLookup, error) `perm:"read"`
115+
StateWaitMsgLimited func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
116+
StateGetReceipt func(p0 context.Context, p1 cid.Cid, p2 types.TipSetKey) (*types.MessageReceipt, error) `perm:"read"`
117117
VerifyEntry func(p0 *types.BeaconEntry, p1 *types.BeaconEntry, p2 abi.ChainEpoch) bool `perm:"read"`
118118
}
119119

@@ -175,7 +175,7 @@ type IMinerStateStruct struct {
175175
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `perm:"read"`
176176
StateMinerInitialPledgeCollateral func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (big.Int, error) `perm:"read"`
177177
StateMinerPartitions func(p0 context.Context, p1 address.Address, p2 uint64, p3 types.TipSetKey) ([]apitypes.Partition, error) `perm:"read"`
178-
StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*power.MinerPower, error) `perm:"read"`
178+
StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*apitypes.MinerPower, error) `perm:"read"`
179179
StateMinerPreCommitDepositForPower func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (big.Int, error) `perm:"read"`
180180
StateMinerProvingDeadline func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*dline.Info, error) `perm:"read"`
181181
StateMinerRecoveries func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `perm:"read"`

app/node/builder.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
225225
offlineMode: b.offlineMode,
226226
repo: b.repo,
227227
}
228+
228229
nd.configModule = config2.NewConfigModule(b.repo)
230+
229231
nd.blockstore, err = blockstore.NewBlockstoreSubmodule(ctx, b.repo)
230232
if err != nil {
231233
return nil, errors.Wrap(err, "failed to build node.blockstore")
@@ -335,7 +337,8 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
335337
if err != nil {
336338
return nil, errors.Wrap(err, "add service failed ")
337339
}
338-
nd.jsonRPCService = apiBuilder.Build()
340+
nd.jsonRPCServiceV1 = apiBuilder.Build("v1")
341+
nd.jsonRPCService = apiBuilder.Build("v0")
339342
return nd, nil
340343
}
341344

app/node/env.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package node
22

33
import (
44
"context"
5+
56
"github.com/filecoin-project/venus/app/submodule/apiface"
7+
"github.com/filecoin-project/venus/app/submodule/apiface/v0api"
68
cmds "github.com/ipfs/go-ipfs-cmds"
79

810
"github.com/filecoin-project/venus/app/submodule/storagenetworking"
@@ -24,7 +26,7 @@ type Env struct {
2426
MingingAPI apiface.IMining
2527
MessagePoolAPI apiface.IMessagePool
2628

27-
MultiSigAPI apiface.IMultiSig
29+
MultiSigAPI v0api.IMultiSig
2830
MarketAPI apiface.IMarket
2931
PaychAPI apiface.IPaychan
3032
}

app/node/node.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88
"os/signal"
99
"syscall"
1010

11+
"github.com/filecoin-project/venus/app/submodule/multisig/v0api"
12+
1113
"github.com/awnumar/memguard"
14+
"github.com/filecoin-project/venus/app/submodule/multisig"
1215

1316
"github.com/filecoin-project/go-jsonrpc"
1417
cmds "github.com/ipfs/go-ipfs-cmds"
@@ -26,7 +29,6 @@ import (
2629
"github.com/filecoin-project/venus/app/submodule/market"
2730
"github.com/filecoin-project/venus/app/submodule/mining"
2831
"github.com/filecoin-project/venus/app/submodule/mpool"
29-
"github.com/filecoin-project/venus/app/submodule/multisig"
3032
network2 "github.com/filecoin-project/venus/app/submodule/network"
3133
"github.com/filecoin-project/venus/app/submodule/paych"
3234
"github.com/filecoin-project/venus/app/submodule/storagenetworking"
@@ -92,7 +94,7 @@ type Node struct {
9294
//
9395
// Jsonrpc
9496
//
95-
jsonRPCService *jsonrpc.RPCServer
97+
jsonRPCService, jsonRPCServiceV1 *jsonrpc.RPCServer
9698

9799
jwtCli jwtauth.IJwtAuthClient
98100
}
@@ -304,6 +306,7 @@ func (node *Node) runRestfulAPI(ctx context.Context, handler *http.ServeMux, roo
304306
//runJsonrpcAPI bind jsonrpc handle
305307
func (node *Node) runJsonrpcAPI(ctx context.Context, handler *http.ServeMux) error { //nolint
306308
handler.Handle("/rpc/v0", node.jsonRPCService)
309+
handler.Handle("/rpc/v1", node.jsonRPCServiceV1)
307310
return nil
308311
}
309312

@@ -325,7 +328,7 @@ func (node *Node) createServerEnv(ctx context.Context) *Env {
325328
MessagePoolAPI: node.mpool.API(),
326329
PaychAPI: node.paychan.API(),
327330
MarketAPI: node.market.API(),
328-
MultiSigAPI: node.multiSig.API(),
331+
MultiSigAPI: &v0api.WrapperV1IMultiSig{IMultiSig: node.multiSig.API(), IMessagePool: node.mpool.API()},
329332
}
330333

331334
return &env

app/node/rpc.go

+64-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
package node
22

33
import (
4+
"reflect"
5+
6+
"github.com/filecoin-project/venus/app/client/v0api"
7+
48
"github.com/filecoin-project/go-jsonrpc"
9+
10+
"golang.org/x/xerrors"
11+
512
"github.com/filecoin-project/venus/app/client"
613
"github.com/filecoin-project/venus/app/client/funcrule"
7-
"golang.org/x/xerrors"
8-
"reflect"
914
)
1015

1116
type RPCService interface {
1217
}
1318

1419
type RPCBuilder struct {
15-
namespace []string
16-
apiStruct []interface{}
20+
namespace []string
21+
v0APIStruct []interface{}
22+
v1APIStruct []interface{}
1723
}
1824

1925
func NewBuilder() *RPCBuilder {
@@ -34,8 +40,10 @@ func (builder *RPCBuilder) AddServices(services ...RPCService) error {
3440
return nil
3541
}
3642
func (builder *RPCBuilder) AddService(service RPCService) error {
43+
methodName := "V0API"
44+
3745
serviceV := reflect.ValueOf(service)
38-
apiMethod := serviceV.MethodByName("API")
46+
apiMethod := serviceV.MethodByName(methodName)
3947
if !apiMethod.IsValid() {
4048
return xerrors.New("expect API function")
4149
}
@@ -50,24 +58,66 @@ func (builder *RPCBuilder) AddService(service RPCService) error {
5058
for i := 0; i < apiLen; i++ {
5159
ele := rv.Index(i)
5260
if ele.IsValid() {
53-
builder.apiStruct = append(builder.apiStruct, apiImpl.Interface())
61+
builder.v0APIStruct = append(builder.v0APIStruct, apiImpl.Interface())
5462
}
5563
}
5664
} else {
57-
builder.apiStruct = append(builder.apiStruct, apiImpl.Interface())
65+
builder.v0APIStruct = append(builder.v0APIStruct, apiImpl.Interface())
66+
}
67+
}
68+
69+
methodName = "API"
70+
serviceV = reflect.ValueOf(service)
71+
apiMethod = serviceV.MethodByName(methodName)
72+
if !apiMethod.IsValid() {
73+
return xerrors.New("expect API function")
74+
}
75+
76+
apiImpls = apiMethod.Call([]reflect.Value{})
77+
78+
for _, apiImpl := range apiImpls {
79+
rt := reflect.TypeOf(apiImpl)
80+
rv := reflect.ValueOf(apiImpl)
81+
if rt.Kind() == reflect.Array {
82+
apiLen := rv.Len()
83+
for i := 0; i < apiLen; i++ {
84+
ele := rv.Index(i)
85+
if ele.IsValid() {
86+
builder.v1APIStruct = append(builder.v1APIStruct, apiImpl.Interface())
87+
}
88+
}
89+
} else {
90+
builder.v1APIStruct = append(builder.v1APIStruct, apiImpl.Interface())
5891
}
5992
}
6093
return nil
6194
}
6295

63-
func (builder *RPCBuilder) Build() *jsonrpc.RPCServer {
64-
server := jsonrpc.NewServer(jsonrpc.WithProxyBind(jsonrpc.PBField))
96+
func (builder *RPCBuilder) Build(version string) *jsonrpc.RPCServer {
97+
serverOptions := make([]jsonrpc.ServerOption, 0)
98+
serverOptions = append(serverOptions, jsonrpc.WithProxyBind(jsonrpc.PBField))
99+
100+
server := jsonrpc.NewServer(serverOptions...)
65101
var fullNode client.FullNodeStruct
66-
for _, apiStruct := range builder.apiStruct {
67-
funcrule.PermissionProxy(apiStruct, &fullNode)
68-
}
69-
for _, nameSpace := range builder.namespace {
70-
server.Register(nameSpace, &fullNode)
102+
var fullNodeV0 v0api.FullNodeStruct
103+
switch version {
104+
case "v0":
105+
for _, apiStruct := range builder.v0APIStruct {
106+
funcrule.PermissionProxy(apiStruct, &fullNodeV0)
107+
}
108+
for _, nameSpace := range builder.namespace {
109+
server.Register(nameSpace, &fullNodeV0)
110+
}
111+
case "v1":
112+
for _, apiStruct := range builder.v1APIStruct {
113+
funcrule.PermissionProxy(apiStruct, &fullNode)
114+
}
115+
for _, nameSpace := range builder.namespace {
116+
server.Register(nameSpace, &fullNode)
117+
}
118+
default:
119+
panic("invalid version: " + version)
71120
}
121+
72122
return server
73123
}

0 commit comments

Comments
 (0)