Merge branch 'master' into feature-generate-multi-bls

pull/191/head
Sebastian Johnsson 5 years ago
commit bc2fb963cd
  1. 13
      Makefile
  2. 2
      cmd/subcommands/root.go
  3. 30
      cmd/subcommands/transfer.go
  4. 35
      cmd/subcommands/validator.go
  5. 5
      pkg/common/numeric.go
  6. 228
      pkg/rpc/methods.go

@ -9,9 +9,9 @@ ldflags := -X main.version=v${version} -X main.commit=${commit}
ldflags += -X main.builtAt=${built_at} -X main.builtBy=${built_by}
cli := ./dist/hmy
upload-path-darwin := 's3://pub.harmony.one/release/darwin-x86_64/mainnet/hmy'
upload-path-darwin-version := 's3://pub.harmony.one/release/darwin-x86_64/mainnet/hmy_version'
upload-path-linux := 's3://pub.harmony.one/release/linux-x86_64/mainnet/hmy'
upload-path-linux-version := 's3://pub.harmony.one/release/linux-x86_64/mainnet/hmy_version'
uname := $(shell uname)
env := GO111MODULE=on
@ -45,14 +45,21 @@ test-rpc:
# Notice assumes you have correct uploading credentials
upload-darwin:all
ifeq (${uname}, Darwin)
aws --profile upload s3 cp ./hmy ${upload-path-darwin}
./hmy version &> ./hmy_version
aws --profile upload s3 cp ./hmy_version ${upload-path-darwin-version}
else
@echo "Wrong operating system for target upload"
endif
# Only the linux build will upload the CLI version
upload-linux:static
ifeq (${uname}, Linux)
aws --profile upload s3 cp ./hmy ${upload-path-linux}
./hmy version &> ./hmy_version
aws --profile upload s3 cp ./hmy_version ${upload-path-linux-version}
else
@echo "Wrong operating system for target upload"
endif
.PHONY:clean run-tests upload-darwin upload-linux

@ -159,7 +159,7 @@ var (
VersionWrapDump = ""
cookbook = color.GreenString("hmy cookbook")
versionLink = "https://harmony.one/hmycli_ver"
versionFormat = regexp.MustCompile("v[0-9]+-[0-9]{6}")
versionFormat = regexp.MustCompile("v[0-9]+-[a-z0-9]{6}")
)
// Execute kicks off the hmy CLI

@ -2,14 +2,15 @@ package cmd
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"strconv"
"strings"
"time"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
c "github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/harmony-one/go-sdk/pkg/store"
@ -18,7 +19,6 @@ import (
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/core"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -126,13 +126,19 @@ func handlerForTransaction(txLog *transactionLog) error {
if handlerForError(txLog, err) != nil {
return err
}
amt, err := c.NewDecFromString(amount)
if handlerForError(txLog, err) != nil {
return err
amt, err := common.NewDecFromString(amount)
if err != nil {
amtErr := fmt.Errorf("amount %w", err)
handlerForError(txLog, amtErr)
return amtErr
}
gPrice, err := c.NewDecFromString(gasPrice)
if handlerForError(txLog, err) != nil {
return err
gPrice, err := common.NewDecFromString(gasPrice)
if err != nil {
gasErr := fmt.Errorf("gas-price %w", err)
handlerForError(txLog, gasErr)
return gasErr
}
var gLimit uint64
@ -142,6 +148,11 @@ func handlerForTransaction(txLog *transactionLog) error {
return err
}
} else {
if strings.HasPrefix(gasLimit, "-") {
limitErr := errors.New(fmt.Sprintf("gas-limit can not be negative: %s", gasLimit))
handlerForError(txLog, limitErr)
return limitErr
}
tempLimit, e := strconv.ParseInt(gasLimit, 10, 64)
if handlerForError(txLog, e) != nil {
return e
@ -258,6 +269,9 @@ func opts(ctlr *transaction.Controller) {
func getNonceFromInput(addr, inputNonce string, messenger rpc.T) (uint64, error) {
if inputNonce != "" {
if strings.HasPrefix(inputNonce, "-") {
return 0, errors.New(fmt.Sprintf("nonce can not be negative: %s", inputNonce))
}
nonce, err := strconv.ParseUint(inputNonce, 10, 64)
if err != nil {
return 0, err

@ -2,8 +2,10 @@ package cmd
import (
"fmt"
"strconv"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -41,7 +43,20 @@ var (
PreRunE: validateAddress,
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
return request(rpc.Method.GetValidatorInformation, []interface{}{addr.address})
e := request(rpc.Method.GetValidatorInformation, []interface{}{addr.address})
if e != nil {
return fmt.Errorf("validator address not found: %s", addr.address)
}
return e
},
}, {
Use: "information-by-block-number",
Short: "original creation record of a validator by block number",
Args: cobra.ExactArgs(2),
PreRunE: validateAddress,
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
return request(rpc.Method.GetValidatorInformationByBlockNumber, []interface{}{addr.address, args[1]})
},
}, {
Use: "all-information",
@ -49,7 +64,23 @@ var (
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
return request(rpc.Method.GetAllValidatorInformation, []interface{}{args[0]})
page, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
return errors.Wrapf(err, "the page argument must be integer, supplied %v", args[0])
}
return request(rpc.Method.GetAllValidatorInformation, []interface{}{page})
},
}, {
Use: "all-information-by-block-number",
Short: "all validators information by block number",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
page, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
return errors.Wrapf(err, "the page argument must be integer, supplied %v", args[0])
}
return request(rpc.Method.GetAllValidatorInformationByBlockNumber, []interface{}{page, args[1]})
},
},
}

@ -1,6 +1,8 @@
package common
import (
"errors"
"fmt"
"math/big"
"regexp"
"strconv"
@ -32,6 +34,9 @@ func Pow(base numeric.Dec, exp int) numeric.Dec {
}
func NewDecFromString(i string) (numeric.Dec, error) {
if strings.HasPrefix(i, "-") {
return numeric.ZeroDec(), errors.New(fmt.Sprintf("can not be negative: %s", i))
}
if pattern.FindString(i) != "" {
tokens := strings.Split(i, "e")
a, _ := numeric.NewDecFromStr(tokens[0])

@ -12,122 +12,126 @@ type method = string
type errorCode int
type rpcEnumList struct {
GetShardingStructure method
GetBlockByHash method
GetBlockByNumber method
GetBlockTransactionCountByHash method
GetBlockTransactionCountByNumber method
GetCode method
GetTransactionByBlockHashAndIndex method
GetTransactionByBlockNumberAndIndex method
GetTransactionByHash method
GetStakingTransactionByHash method
GetTransactionReceipt method
Syncing method
PeerCount method
GetBalance method
GetStorageAt method
GetTransactionCount method
SendTransaction method
SendRawTransaction method
Subscribe method
GetPastLogs method
GetWork method
GetProof method
GetFilterChanges method
NewPendingTransactionFilter method
NewBlockFilter method
NewFilter method
Call method
EstimateGas method
GasPrice method
BlockNumber method
UnSubscribe method
NetVersion method
ProtocolVersion method
GetNodeMetadata method
GetLatestBlockHeader method
SendRawStakingTransaction method
GetElectedValidatorAddresses method
GetAllValidatorAddresses method
GetValidatorInformation method
GetAllValidatorInformation method
GetDelegationsByDelegator method
GetDelegationsByValidator method
GetCurrentTransactionErrorSink method
GetValidatorMetrics method
GetMedianRawStakeSnapshot method
GetCurrentStakingErrorSink method
GetTransactionsHistory method
GetPendingTxnsInPool method
GetPendingCrosslinks method
GetPendingCXReceipts method
GetCurrentUtilityMetrics method
ResendCX method
GetSuperCommmittees method
GetCurrentBadBlocks method
GetShardID method
GetLastCrossLinks method
GetShardingStructure method
GetBlockByHash method
GetBlockByNumber method
GetBlockTransactionCountByHash method
GetBlockTransactionCountByNumber method
GetCode method
GetTransactionByBlockHashAndIndex method
GetTransactionByBlockNumberAndIndex method
GetTransactionByHash method
GetStakingTransactionByHash method
GetTransactionReceipt method
Syncing method
PeerCount method
GetBalance method
GetStorageAt method
GetTransactionCount method
SendTransaction method
SendRawTransaction method
Subscribe method
GetPastLogs method
GetWork method
GetProof method
GetFilterChanges method
NewPendingTransactionFilter method
NewBlockFilter method
NewFilter method
Call method
EstimateGas method
GasPrice method
BlockNumber method
UnSubscribe method
NetVersion method
ProtocolVersion method
GetNodeMetadata method
GetLatestBlockHeader method
SendRawStakingTransaction method
GetElectedValidatorAddresses method
GetAllValidatorAddresses method
GetValidatorInformation method
GetAllValidatorInformation method
GetValidatorInformationByBlockNumber method
GetAllValidatorInformationByBlockNumber method
GetDelegationsByDelegator method
GetDelegationsByValidator method
GetCurrentTransactionErrorSink method
GetValidatorMetrics method
GetMedianRawStakeSnapshot method
GetCurrentStakingErrorSink method
GetTransactionsHistory method
GetPendingTxnsInPool method
GetPendingCrosslinks method
GetPendingCXReceipts method
GetCurrentUtilityMetrics method
ResendCX method
GetSuperCommmittees method
GetCurrentBadBlocks method
GetShardID method
GetLastCrossLinks method
}
// Method is a list of known RPC methods
var Method = rpcEnumList{
GetShardingStructure: "hmy_getShardingStructure",
GetNodeMetadata: "hmy_getNodeMetadata",
GetLatestBlockHeader: "hmy_latestHeader",
GetBlockByHash: "hmy_getBlockByHash",
GetBlockByNumber: "hmy_getBlockByNumber",
GetBlockTransactionCountByHash: "hmy_getBlockTransactionCountByHash",
GetBlockTransactionCountByNumber: "hmy_getBlockTransactionCountByNumber",
GetCode: "hmy_getCode",
GetTransactionByBlockHashAndIndex: "hmy_getTransactionByBlockHashAndIndex",
GetTransactionByBlockNumberAndIndex: "hmy_getTransactionByBlockNumberAndIndex",
GetTransactionByHash: "hmy_getTransactionByHash",
GetStakingTransactionByHash: "hmy_getStakingTransactionByHash",
GetTransactionReceipt: "hmy_getTransactionReceipt",
Syncing: "hmy_syncing",
PeerCount: "net_peerCount",
GetBalance: "hmy_getBalance",
GetStorageAt: "hmy_getStorageAt",
GetTransactionCount: "hmy_getTransactionCount",
SendTransaction: "hmy_sendTransaction",
SendRawTransaction: "hmy_sendRawTransaction",
Subscribe: "hmy_subscribe",
GetPastLogs: "hmy_getLogs",
GetWork: "hmy_getWork",
GetProof: "hmy_getProof",
GetFilterChanges: "hmy_getFilterChanges",
NewPendingTransactionFilter: "hmy_newPendingTransactionFilter",
NewBlockFilter: "hmy_newBlockFilter",
NewFilter: "hmy_newFilter",
Call: "hmy_call",
EstimateGas: "hmy_estimateGas",
GasPrice: "hmy_gasPrice",
BlockNumber: "hmy_blockNumber",
UnSubscribe: "hmy_unsubscribe",
NetVersion: "net_version",
ProtocolVersion: "hmy_protocolVersion",
SendRawStakingTransaction: "hmy_sendRawStakingTransaction",
GetElectedValidatorAddresses: "hmy_getElectedValidatorAddresses",
GetAllValidatorAddresses: "hmy_getAllValidatorAddresses",
GetValidatorInformation: "hmy_getValidatorInformation",
GetAllValidatorInformation: "hmy_getAllValidatorInformation",
GetDelegationsByDelegator: "hmy_getDelegationsByDelegator",
GetDelegationsByValidator: "hmy_getDelegationsByValidator",
GetCurrentTransactionErrorSink: "hmy_getCurrentTransactionErrorSink",
GetValidatorMetrics: "hmy_getValidatorMetrics",
GetMedianRawStakeSnapshot: "hmy_getMedianRawStakeSnapshot",
GetCurrentStakingErrorSink: "hmy_getCurrentStakingErrorSink",
GetTransactionsHistory: "hmy_getTransactionsHistory",
GetPendingTxnsInPool: "hmy_pendingTransactions",
GetPendingCrosslinks: "hmy_getPendingCrossLinks",
GetPendingCXReceipts: "hmy_getPendingCXReceipts",
GetCurrentUtilityMetrics: "hmy_getCurrentUtilityMetrics",
ResendCX: "hmy_resendCx",
GetSuperCommmittees: "hmy_getSuperCommittees",
GetCurrentBadBlocks: "hmy_getCurrentBadBlocks",
GetShardID: "hmy_getShardID",
GetLastCrossLinks: "hmy_getLastCrossLinks",
GetShardingStructure: "hmy_getShardingStructure",
GetNodeMetadata: "hmy_getNodeMetadata",
GetLatestBlockHeader: "hmy_latestHeader",
GetBlockByHash: "hmy_getBlockByHash",
GetBlockByNumber: "hmy_getBlockByNumber",
GetBlockTransactionCountByHash: "hmy_getBlockTransactionCountByHash",
GetBlockTransactionCountByNumber: "hmy_getBlockTransactionCountByNumber",
GetCode: "hmy_getCode",
GetTransactionByBlockHashAndIndex: "hmy_getTransactionByBlockHashAndIndex",
GetTransactionByBlockNumberAndIndex: "hmy_getTransactionByBlockNumberAndIndex",
GetTransactionByHash: "hmy_getTransactionByHash",
GetStakingTransactionByHash: "hmy_getStakingTransactionByHash",
GetTransactionReceipt: "hmy_getTransactionReceipt",
Syncing: "hmy_syncing",
PeerCount: "net_peerCount",
GetBalance: "hmy_getBalance",
GetStorageAt: "hmy_getStorageAt",
GetTransactionCount: "hmy_getTransactionCount",
SendTransaction: "hmy_sendTransaction",
SendRawTransaction: "hmy_sendRawTransaction",
Subscribe: "hmy_subscribe",
GetPastLogs: "hmy_getLogs",
GetWork: "hmy_getWork",
GetProof: "hmy_getProof",
GetFilterChanges: "hmy_getFilterChanges",
NewPendingTransactionFilter: "hmy_newPendingTransactionFilter",
NewBlockFilter: "hmy_newBlockFilter",
NewFilter: "hmy_newFilter",
Call: "hmy_call",
EstimateGas: "hmy_estimateGas",
GasPrice: "hmy_gasPrice",
BlockNumber: "hmy_blockNumber",
UnSubscribe: "hmy_unsubscribe",
NetVersion: "net_version",
ProtocolVersion: "hmy_protocolVersion",
SendRawStakingTransaction: "hmy_sendRawStakingTransaction",
GetElectedValidatorAddresses: "hmy_getElectedValidatorAddresses",
GetAllValidatorAddresses: "hmy_getAllValidatorAddresses",
GetValidatorInformation: "hmy_getValidatorInformation",
GetAllValidatorInformation: "hmy_getAllValidatorInformation",
GetValidatorInformationByBlockNumber: "hmy_getValidatorInformationByBlockNumber",
GetAllValidatorInformationByBlockNumber: "hmy_getAllValidatorInformationByBlockNumber",
GetDelegationsByDelegator: "hmy_getDelegationsByDelegator",
GetDelegationsByValidator: "hmy_getDelegationsByValidator",
GetCurrentTransactionErrorSink: "hmy_getCurrentTransactionErrorSink",
GetValidatorMetrics: "hmy_getValidatorMetrics",
GetMedianRawStakeSnapshot: "hmy_getMedianRawStakeSnapshot",
GetCurrentStakingErrorSink: "hmy_getCurrentStakingErrorSink",
GetTransactionsHistory: "hmy_getTransactionsHistory",
GetPendingTxnsInPool: "hmy_pendingTransactions",
GetPendingCrosslinks: "hmy_getPendingCrossLinks",
GetPendingCXReceipts: "hmy_getPendingCXReceipts",
GetCurrentUtilityMetrics: "hmy_getCurrentUtilityMetrics",
ResendCX: "hmy_resendCx",
GetSuperCommmittees: "hmy_getSuperCommittees",
GetCurrentBadBlocks: "hmy_getCurrentBadBlocks",
GetShardID: "hmy_getShardID",
GetLastCrossLinks: "hmy_getLastCrossLinks",
}
// TODO Use Reflection here to avoid typing out the cases

Loading…
Cancel
Save