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

Dev/v1.11.0 #5777

Merged
merged 9 commits into from
Feb 28, 2023
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
2 changes: 1 addition & 1 deletion app/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
var client *jwtclient.AuthClient
cfg := nd.repo.Config()
if len(cfg.API.VenusAuthURL) > 0 {
client, err = jwtclient.NewAuthClient(cfg.API.VenusAuthURL)
client, err = jwtclient.NewAuthClient(cfg.API.VenusAuthURL, cfg.API.VenusAuthToken)
if err != nil {
return nil, fmt.Errorf("failed to create remote jwt auth client: %w", err)
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var daemonCmd = &cmds.Command{
cmds.BoolOption(ELStdout),
cmds.BoolOption(ULimit, "manage open file limit").WithDefault(true),
cmds.StringOption(AuthServiceURL, "venus auth service URL"),
cmds.StringOption(AuthServiceToken, "venus auth service token"),
cmds.StringsOption(BootstrapPeers, "set the bootstrap peers"),
cmds.BoolOption(IsRelay, "advertise and allow venus network traffic to be relayed through this node"),
cmds.StringOption(ImportSnapshot, "import chain state from a given chain export file or url"),
Expand Down Expand Up @@ -148,6 +149,11 @@ func initRun(req *cmds.Request) error {
}
if authServiceURL, ok := req.Options[AuthServiceURL].(string); ok && len(authServiceURL) > 0 {
cfg.API.VenusAuthURL = authServiceURL
if authServiceToken, ok := req.Options[AuthServiceToken].(string); ok && len(authServiceToken) > 0 {
cfg.API.VenusAuthToken = authServiceToken
} else {
return fmt.Errorf("must also pass token with venus auth service to `--%s`", AuthServiceToken)
}
}

if err := rep.ReplaceConfig(cfg); err != nil {
Expand Down Expand Up @@ -205,6 +211,12 @@ func daemonRun(req *cmds.Request, re cmds.ResponseEmitter) error {
if authURL, ok := req.Options[AuthServiceURL].(string); ok && len(authURL) > 0 {
config.API.VenusAuthURL = authURL
}
if authServiceToken, ok := req.Options[AuthServiceToken].(string); ok && len(authServiceToken) > 0 {
config.API.VenusAuthToken = authServiceToken
}
if len(config.API.VenusAuthURL)+len(config.API.VenusAuthToken) > 0 && len(config.API.VenusAuthToken)*len(config.API.VenusAuthURL) == 0 {
return fmt.Errorf("must set both venus auth service url and token at the same time")
}

if bootPeers, ok := req.Options[BootstrapPeers].([]string); ok && len(bootPeers) > 0 {
config.Bootstrap.Addresses = MergePeers(config.Bootstrap.Addresses, bootPeers)
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const (
// wallet password
Password = "password"

AuthServiceURL = "auth-url"
AuthServiceURL = "auth-url"
AuthServiceToken = "auth-token"

BootstrapPeers = "bootstrap-peers"
)
Expand Down
3 changes: 2 additions & 1 deletion fixtures/networks/network_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package networks

import (
"fmt"
"strings"

"github.com/filecoin-project/venus/pkg/config"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/utils"
)

func GetNetworkFromName(name string) (types.NetworkType, error) {
if name == "2k" {
if name == "2k" || strings.HasPrefix(name, "localnet-") {
return types.Network2k, nil
}
if name == "force" {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/filecoin-project/specs-actors/v8 v8.0.1
github.com/filecoin-project/specs-storage v0.4.1
github.com/filecoin-project/test-vectors/schema v0.0.5
github.com/filecoin-project/venus-auth v1.10.0-rc2
github.com/filecoin-project/venus-auth v1.10.0-rc2.0.20230228032348-a2418f5a8838
github.com/fxamacker/cbor/v2 v2.4.0
github.com/go-errors/errors v1.0.1
github.com/go-kit/kit v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ github.com/filecoin-project/specs-storage v0.4.1/go.mod h1:Z2eK6uMwAOSLjek6+sy0j
github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893 h1:6GCuzxLVHBzlz7y+FkbHh6n0UyoEGWqDwJKQPJoz7bE=
github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg=
github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E=
github.com/filecoin-project/venus-auth v1.10.0-rc2 h1:mC2kRcUmXaL2nPky8iiogFjrygMTUXGXHjvEV9msPgk=
github.com/filecoin-project/venus-auth v1.10.0-rc2/go.mod h1:bJT0owiiQfQq7u8QBpIf22JHNRZdsx9rAr4wMEsg+ds=
github.com/filecoin-project/venus-auth v1.10.0-rc2.0.20230228032348-a2418f5a8838 h1:NbBSFyb5yoKfbtd5jX9JdkJ9vupuS0DM2f/tY7Pi9lo=
github.com/filecoin-project/venus-auth v1.10.0-rc2.0.20230228032348-a2418f5a8838/go.mod h1:5scCRopeVuhwom6QIJaFENmrmL+HrwVElx+qU/oQ3Dw=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ=
github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Config struct {
// nolint
type APIConfig struct {
VenusAuthURL string `json:"venusAuthURL"`
VenusAuthToken string `json:"venusAuthToken"`
APIAddress string `json:"apiAddress"`
AccessControlAllowOrigin []string `json:"accessControlAllowOrigin"`
AccessControlAllowCredentials bool `json:"accessControlAllowCredentials"`
Expand Down
18 changes: 10 additions & 8 deletions venus-devtool/api-gen/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"time"

"github.com/filecoin-project/go-state-types/actors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
datatransfer "github.com/filecoin-project/go-data-transfer"
Expand Down Expand Up @@ -89,6 +91,7 @@ func init() {
panic(err)
}
addExample(constants.TestNetworkVersion)
addExample(actors.Version6)
allocationID := verifreg.AllocationId(0)
addExample(allocationID)
addExample(&allocationID)
Expand Down Expand Up @@ -308,7 +311,7 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
return ExampleValue(method, t.Elem(), nil)
case reflect.Struct:
es := exampleStruct(method, t, parent)
v := reflect.ValueOf(es).Elem().Interface()
v := reflect.ValueOf(es).Interface()
ExampleValues[t] = v
return v
case reflect.Array:
Expand All @@ -322,11 +325,9 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
out.SetMapIndex(reflect.ValueOf(ExampleValue(method, t.Key(), parent)), reflect.ValueOf(ExampleValue(method, t.Elem(), parent)))
return out.Interface()
case reflect.Ptr:
if t.Elem().Kind() == reflect.Struct {
es := exampleStruct(method, t.Elem(), t)
ExampleValues[t] = es
return es
}
out := reflect.New(t.Elem())
out.Elem().Set(reflect.ValueOf(ExampleValue(method, t.Elem(), t)))
return out.Interface()

case reflect.Interface:
if t.Implements(reflect.TypeOf((*error)(nil)).Elem()) {
Expand All @@ -340,15 +341,16 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
}

func exampleStruct(method string, t, parent reflect.Type) interface{} {
ns := reflect.New(t)
ns := reflect.New(t).Elem()
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
if shouldIgnoreField(f, parent) {
continue
}

if strings.Title(f.Name) == f.Name {
ns.Elem().Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
fmt.Println(f.Name)
ns.Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
}
}

Expand Down
Loading