Skip to content

Commit

Permalink
Merge pull request #2197 from cheng762/feature/bump-version-to-1.5.1
Browse files Browse the repository at this point in the history
merge 1.10.18
  • Loading branch information
benbaley authored Nov 16, 2023
2 parents e8864d5 + 76cf461 commit 60cebb2
Show file tree
Hide file tree
Showing 40 changed files with 262 additions and 557 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ clean:

devtools:
env GOBIN= go install golang.org/x/tools/cmd/stringer@latest
env GOBIN= go install github.com/kevinburke/go-bindata/go-bindata@latest
env GOBIN= go install github.com/fjl/gencodec@latest
env GOBIN= go install github.com/golang/protobuf/protoc-gen-go@latest
env GOBIN= go install ./cmd/abigen
Expand Down
3 changes: 2 additions & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"strings"
"time"

"github.com/PlatONnetwork/PlatON-Go/common"
signifyPkg "github.com/PlatONnetwork/PlatON-Go/crypto/signify"
"github.com/PlatONnetwork/PlatON-Go/internal/build"
"github.com/PlatONnetwork/PlatON-Go/params"
Expand Down Expand Up @@ -615,7 +616,7 @@ func ppaUpload(workdir, ppa, sshUser string, files []string) {
var idfile string
if sshkey := getenvBase64("PPA_SSH_KEY"); len(sshkey) > 0 {
idfile = filepath.Join(workdir, "sshkey")
if _, err := os.Stat(idfile); os.IsNotExist(err) {
if !common.FileExist(idfile) {
os.WriteFile(idfile, sshkey, 0600)
}
}
Expand Down
25 changes: 15 additions & 10 deletions cmd/keytool/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ type outputGenerate struct {
AddressEIP55 string
}

var (
privateKeyFlag = cli.StringFlag{
Name: "privatekey",
Usage: "file containing a raw private key to encrypt",
}
lightKDFFlag = cli.BoolFlag{
Name: "lightkdf",
Usage: "use less secure scrypt parameters",
}
)

var commandGenerate = cli.Command{
Name: "generate",
Usage: "generate new keyfile",
Expand All @@ -50,15 +61,9 @@ If you want to encrypt an existing private key, it can be specified by setting
Flags: []cli.Flag{
passphraseFlag,
jsonFlag,
cli.StringFlag{
Name: "privatekey",
Usage: "file containing a raw private key to encrypt",
},
privateKeyFlag,
lightKDFFlag,
utils.AddressHRPFlag,
cli.BoolFlag{
Name: "lightkdf",
Usage: "use less secure scrypt parameters",
},
},
Action: func(ctx *cli.Context) error {
hrp := ctx.String(utils.AddressHRPFlag.Name)
Expand All @@ -79,7 +84,7 @@ If you want to encrypt an existing private key, it can be specified by setting

var privateKey *ecdsa.PrivateKey
var err error
if file := ctx.String("privatekey"); file != "" {
if file := ctx.String(privateKeyFlag.Name); file != "" {
// Load private key from file.
privateKey, err = crypto.LoadECDSA(file)
if err != nil {
Expand Down Expand Up @@ -107,7 +112,7 @@ If you want to encrypt an existing private key, it can be specified by setting
// Encrypt key with passphrase.
passphrase := utils.GetPassPhrase("", true)
scryptN, scryptP := keystore.StandardScryptN, keystore.StandardScryptP
if ctx.Bool("lightkdf") {
if ctx.Bool(lightKDFFlag.Name) {
scryptN, scryptP = keystore.LightScryptN, keystore.LightScryptP
}
keyjson, err := keystore.EncryptKey(key, passphrase, scryptN, scryptP)
Expand Down
17 changes: 10 additions & 7 deletions cmd/keytool/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ package main
import (
"encoding/hex"
"fmt"
"os"

"github.com/PlatONnetwork/PlatON-Go/common"
"os"

"gopkg.in/urfave/cli.v1"

Expand All @@ -36,6 +35,13 @@ type outputInspect struct {
PrivateKey string
}

var (
privateFlag = cli.BoolFlag{
Name: "private",
Usage: "include the private key in the output",
}
)

var commandInspect = cli.Command{
Name: "inspect",
Usage: "inspect a keyfile",
Expand All @@ -48,10 +54,7 @@ make sure to use this feature with great caution!`,
Flags: []cli.Flag{
passphraseFlag,
jsonFlag,
cli.BoolFlag{
Name: "private",
Usage: "include the private key in the output",
},
privateFlag,
utils.AddressHRPFlag,
},
Action: func(ctx *cli.Context) error {
Expand All @@ -76,7 +79,7 @@ make sure to use this feature with great caution!`,
}

// Output all relevant information we can retrieve.
showPrivate := ctx.Bool("private")
showPrivate := ctx.Bool(privateFlag.Name)
out := outputInspect{
Address: key.Address.String(),
PublicKey: hex.EncodeToString(
Expand Down
2 changes: 1 addition & 1 deletion cmd/keytool/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ It is possible to refer to a file containing the message.`,
}

func getMessage(ctx *cli.Context, msgarg int) []byte {
if file := ctx.String("msgfile"); file != "" {
if file := ctx.String(msgfileFlag.Name); file != "" {
if len(ctx.Args()) > msgarg {
utils.Fatalf("Can't use --msgfile and message argument at the same time.")
}
Expand Down
99 changes: 58 additions & 41 deletions cmd/p2psim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,58 @@ import (

var client *simulations.Client

var (
// global command flags
apiFlag = cli.StringFlag{
Name: "api",
Value: "http://localhost:8888",
Usage: "simulation API URL",
EnvVar: "P2PSIM_API_URL",
}

// events subcommand flags
currentFlag = cli.BoolFlag{
Name: "current",
Usage: "get existing nodes and conns first",
}
filterFlag = cli.StringFlag{
Name: "filter",
Value: "",
Usage: "message filter",
}

// node create subcommand flags
nameFlag = cli.StringFlag{
Name: "name",
Value: "",
Usage: "node name",
}
servicesFlag = cli.StringFlag{
Name: "services",
Value: "",
Usage: "node services (comma separated)",
}
keyFlag = cli.StringFlag{
Name: "key",
Value: "",
Usage: "node private key (hex encoded)",
}

// node rpc subcommand flags
subscribeFlag = cli.BoolFlag{
Name: "subscribe",
Usage: "method is a subscription",
}
)

func main() {
app := cli.NewApp()
app.Usage = "devp2p simulation command-line client"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "api",
Value: "http://localhost:8888",
Usage: "simulation API URL",
EnvVar: "P2PSIM_API_URL",
},
apiFlag,
}
app.Before = func(ctx *cli.Context) error {
client = simulations.NewClient(ctx.GlobalString("api"))
client = simulations.NewClient(ctx.GlobalString(apiFlag.Name))
return nil
}
app.Commands = []cli.Command{
Expand All @@ -83,15 +122,8 @@ func main() {
Usage: "stream network events",
Action: streamNetwork,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "current",
Usage: "get existing nodes and conns first",
},
cli.StringFlag{
Name: "filter",
Value: "",
Usage: "message filter",
},
currentFlag,
filterFlag,
},
},
{
Expand Down Expand Up @@ -119,21 +151,9 @@ func main() {
Usage: "create a node",
Action: createNode,
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Value: "",
Usage: "node name",
},
cli.StringFlag{
Name: "services",
Value: "",
Usage: "node services (comma separated)",
},
cli.StringFlag{
Name: "key",
Value: "",
Usage: "node private key (hex encoded)",
},
nameFlag,
servicesFlag,
keyFlag,
},
},
{
Expand Down Expand Up @@ -172,10 +192,7 @@ func main() {
Usage: "call a node RPC method",
Action: rpcNode,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "subscribe",
Usage: "method is a subscription",
},
subscribeFlag,
},
},
},
Expand Down Expand Up @@ -208,8 +225,8 @@ func streamNetwork(ctx *cli.Context) error {
}
events := make(chan *simulations.Event)
sub, err := client.SubscribeNetwork(events, simulations.SubscribeOpts{
Current: ctx.Bool("current"),
Filter: ctx.String("filter"),
Current: ctx.Bool(currentFlag.Name),
Filter: ctx.String(filterFlag.Name),
})
if err != nil {
return err
Expand Down Expand Up @@ -280,16 +297,16 @@ func createNode(ctx *cli.Context) error {
return cli.ShowCommandHelp(ctx, ctx.Command.Name)
}
config := adapters.RandomNodeConfig()
config.Name = ctx.String("name")
if key := ctx.String("key"); key != "" {
config.Name = ctx.String(nameFlag.Name)
if key := ctx.String(keyFlag.Name); key != "" {
privKey, err := crypto.HexToECDSA(key)
if err != nil {
return err
}
config.ID = enode.PubkeyToIDV4(&privKey.PublicKey)
config.PrivateKey = privKey
}
if services := ctx.String("services"); services != "" {
if services := ctx.String(servicesFlag.Name); services != "" {
config.Lifecycles = strings.Split(services, ",")
}
node, err := client.CreateNode(config)
Expand Down Expand Up @@ -390,7 +407,7 @@ func rpcNode(ctx *cli.Context) error {
if err != nil {
return err
}
if ctx.Bool("subscribe") {
if ctx.Bool(subscribeFlag.Name) {
return rpcSubscribe(rpcClient, ctx.App.Writer, method, args[3:]...)
}
var result interface{}
Expand Down
25 changes: 10 additions & 15 deletions cmd/platon/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ var (
Name: "init",
Usage: "Bootstrap and initialize a new genesis block",
ArgsUsage: "<genesisPath>",
Flags: []cli.Flag{
utils.DataDirFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Flags: utils.DatabasePathFlags,
Category: "BLOCKCHAIN COMMANDS",
Description: `
The init command initializes a new genesis block and definition for the network.
This is a destructive action and changes the network in which you will be
Expand All @@ -77,14 +75,13 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
Name: "import-preimages",
Usage: "Import the preimage database from an RLP stream",
ArgsUsage: "<datafile>",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: append([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
},
}, utils.DatabasePathFlags...),
Category: "BLOCKCHAIN COMMANDS",
Description: `
The import-preimages command imports hash preimages from an RLP encoded stream.
The import-preimages command imports hash preimages from an RLP encoded stream.
It's deprecated, please use "geth db import" instead.
`,
}
Expand All @@ -93,11 +90,10 @@ It's deprecated, please use "geth db import" instead.
Name: "export-preimages",
Usage: "Export the preimage database into an RLP stream",
ArgsUsage: "<dumpfile>",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: append([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
},
}, utils.DatabasePathFlags...),
Category: "BLOCKCHAIN COMMANDS",
Description: `
The export-preimages command exports hash preimages to an RLP encoded stream.
Expand All @@ -109,16 +105,15 @@ It's deprecated, please use "geth db export" instead.
Name: "dump",
Usage: "Dump a specific block from storage",
ArgsUsage: "[? <blockHash> | <blockNum>]",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: append([]cli.Flag{
utils.CacheFlag,
utils.IterativeOutputFlag,
utils.ExcludeCodeFlag,
utils.ExcludeStorageFlag,
utils.IncludeIncompletesFlag,
utils.StartKeyFlag,
utils.DumpLimitFlag,
},
}, utils.DatabasePathFlags...),
Category: "BLOCKCHAIN COMMANDS",
Description: `
This command dumps out the state for a given block (or latest, if none provided).
Expand All @@ -145,7 +140,7 @@ func initGenesis(ctx *cli.Context) error {
defer stack.Close()

for _, name := range []string{"chaindata", "lightchaindata"} {
chaindb, err := stack.OpenDatabase(name, 0, 0, "", false)
chaindb, err := stack.OpenDatabaseWithFreezer(name, 0, 0, ctx.GlobalString(utils.AncientFlag.Name), "", false)
if err != nil {
utils.Fatalf("Failed to open database: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/platon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
Usage: "Show configuration values",
ArgsUsage: "",
//Flags: append(append(nodeFlags, rpcFlags...), whisperFlags...),
Flags: append(append(nodeFlags, rpcFlags...)),
Flags: utils.GroupFlags(nodeFlags, rpcFlags),
Category: "MISCELLANEOUS COMMANDS",
Description: `The dumpconfig command shows configuration values.`,
}
Expand Down
Loading

0 comments on commit 60cebb2

Please sign in to comment.