Skip to content

Commit

Permalink
Merge branch 'main' into chore/libp2p-1
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite authored Mar 1, 2023
2 parents 1aa1c9f + 56ea777 commit b694338
Show file tree
Hide file tree
Showing 133 changed files with 1,648 additions and 1,788 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,4 @@ check_cross_module_imports: ## Lists cross-module imports

.PHONY: send_local_tx
send_local_tx: ## A hardcoded send tx to make LocalNet debugging easier
go run app/client/*.go Account Send 00104055c00bed7c983a48aac7dc6335d7c607a7 00204737d2a165ebe4be3a7d5b0af905b0ea91d8 1000
go run app/client/*.go Account Send --non_interactive 00104055c00bed7c983a48aac7dc6335d7c607a7 00204737d2a165ebe4be3a7d5b0af905b0ea91d8 1000
8 changes: 4 additions & 4 deletions app/client/cli/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ If no changes are desired for the parameter, just enter the current param value
// removing all invalid characters from rawChains argument
rawChains := rawChainCleanupRegex.ReplaceAllString(args[2], "")
chains := strings.Split(rawChains, ",")
serviceURI := args[3]
serviceURL := args[3]

msg := &typesUtil.MessageStake{
PublicKey: pk.PublicKey().Bytes(),
Chains: chains,
Amount: amount,
ServiceUrl: serviceURI,
ServiceUrl: serviceURL,
OutputAddress: pk.Address(),
Signer: pk.Address(),
ActorType: cmdDef.ActorType,
Expand Down Expand Up @@ -201,13 +201,13 @@ func newEditStakeCmd(cmdDef actorCmdDef) *cobra.Command {
// removing all invalid characters from rawChains argument
rawChains := rawChainCleanupRegex.ReplaceAllString(args[2], "")
chains := strings.Split(rawChains, ",")
serviceURI := args[3]
serviceURL := args[3]

msg := &typesUtil.MessageEditStake{
Address: fromAddr,
Chains: chains,
Amount: amount,
ServiceUrl: serviceURI,
ServiceUrl: serviceURL,
Signer: pk.Address(),
ActorType: cmdDef.ActorType,
}
Expand Down
6 changes: 3 additions & 3 deletions app/client/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ func NewDebugCommand() *cobra.Command {
bus := runtimeMgr.GetBus()
modulesRegistry := bus.GetModulesRegistry()

rpcUrl := fmt.Sprintf("http://%s:%s", rpcHost, defaults.DefaultRPCPort)
rpcURL := fmt.Sprintf("http://%s:%s", rpcHost, defaults.DefaultRPCPort)

addressBookProvider := rpcABP.NewRPCAddrBookProvider(
rpcABP.WithP2PConfig(
runtimeMgr.GetConfig().P2P,
),
rpcABP.WithCustomRPCUrl(rpcUrl),
rpcABP.WithCustomRPCURL(rpcURL),
)
modulesRegistry.RegisterModule(addressBookProvider)

currentHeightProvider := rpcCHP.NewRPCCurrentHeightProvider(
rpcCHP.WithCustomRPCUrl(rpcUrl),
rpcCHP.WithCustomRPCURL(rpcURL),
)
modulesRegistry.RegisterModule(currentHeightProvider)

Expand Down
27 changes: 14 additions & 13 deletions app/client/cli/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/pokt-network/pocket/logger"
"github.com/pokt-network/pocket/shared/codec"
"github.com/pokt-network/pocket/shared/converters"
"github.com/pokt-network/pocket/shared/crypto"
utilTypes "github.com/pokt-network/pocket/utility/types"
"path/filepath"
"strconv"
"strings"

"github.com/pokt-network/pocket/logger"
"github.com/pokt-network/pocket/shared/codec"
coreTypes "github.com/pokt-network/pocket/shared/core/types"
"github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/utils"

"github.com/pokt-network/pocket/app/client/keybase"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -363,7 +364,7 @@ func keysExportCommands() []*cobra.Command {

logger.Global.Info().Str("output_file", outputFile).Msg("Exporting private key string to file...")

return converters.WriteOutput(exportString, outputFile)
return utils.WriteOutput(exportString, outputFile)
},
},
}
Expand All @@ -384,7 +385,7 @@ func keysImportCommands() []*cobra.Command {
if len(args) == 1 {
privateKeyString = args[0]
} else if inputFile != "" {
privateKeyBz, err := converters.ReadInput(inputFile)
privateKeyBz, err := utils.ReadInput(inputFile)
privateKeyString = string(privateKeyBz)
if err != nil {
return err
Expand Down Expand Up @@ -578,11 +579,11 @@ func keysSignTxCommands() []*cobra.Command {
}

// Unmarshal Tx from input file
txBz, err := converters.ReadInput(inputFile)
txBz, err := utils.ReadInput(inputFile)
if err != nil {
return err
}
txProto := new(utilTypes.Transaction)
txProto := new(coreTypes.Transaction)
if err := codec.GetCodec().Unmarshal(txBz, txProto); err != nil {
return err
}
Expand All @@ -599,7 +600,7 @@ func keysSignTxCommands() []*cobra.Command {
}

// Add signature to the transaction
sig := new(utilTypes.Signature)
sig := new(coreTypes.Signature)
sig.PublicKey = privKey.PublicKey().Bytes()
sig.Signature = sigBz
txProto.Signature = sig
Expand All @@ -610,7 +611,7 @@ func keysSignTxCommands() []*cobra.Command {
return err
}

if err := converters.WriteOutput(txBz, outputFile); err != nil {
if err := utils.WriteOutput(txBz, outputFile); err != nil {
return err
}

Expand Down Expand Up @@ -650,11 +651,11 @@ func keysSignTxCommands() []*cobra.Command {
}

// Unmarshal Tx from input file
txBz, err := converters.ReadInput(inputFile)
txBz, err := utils.ReadInput(inputFile)
if err != nil {
return err
}
txProto := new(utilTypes.Transaction)
txProto := new(coreTypes.Transaction)
if err := codec.GetCodec().Unmarshal(txBz, txProto); err != nil {
return err
}
Expand Down
11 changes: 6 additions & 5 deletions app/client/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
"github.com/pokt-network/pocket/logger"
"github.com/pokt-network/pocket/rpc"
"github.com/pokt-network/pocket/shared/codec"
"github.com/pokt-network/pocket/shared/converters"
coreTypes "github.com/pokt-network/pocket/shared/core/types"
"github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/utils"
typesUtil "github.com/pokt-network/pocket/utility/types"
"github.com/spf13/cobra"
"golang.org/x/term"
Expand Down Expand Up @@ -89,7 +90,7 @@ func prepareTxBytes(msg typesUtil.Message, pk crypto.PrivateKey) ([]byte, error)
return nil, err
}

tx := &typesUtil.Transaction{
tx := &coreTypes.Transaction{
Msg: anyMsg,
Nonce: fmt.Sprintf("%d", crypto.GetNonce()),
}
Expand All @@ -104,7 +105,7 @@ func prepareTxBytes(msg typesUtil.Message, pk crypto.PrivateKey) ([]byte, error)
return nil, err
}

tx.Signature = &typesUtil.Signature{
tx.Signature = &coreTypes.Signature{
Signature: signature,
PublicKey: pk.PublicKey().Bytes(),
}
Expand Down Expand Up @@ -155,13 +156,13 @@ func readPassphraseMessage(currPwd, prompt string) string {
}

func validateStakeAmount(amount string) error {
am, err := converters.StringToBigInt(amount)
am, err := utils.StringToBigInt(amount)
if err != nil {
return err
}

sr := big.NewInt(stakingRecommendationAmount)
if converters.BigIntLessThan(am, sr) {
if utils.BigIntLessThan(am, sr) {
fmt.Printf("The amount you are staking for is below the recommendation of %d POKT, would you still like to continue? y|n\n", sr.Div(sr, oneMillion).Int64())
if !confirmation(pwd) {
return fmt.Errorf("aborted")
Expand Down
4 changes: 4 additions & 0 deletions app/client/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.19] - 2023-02-28

- Renamed the package names for some basic helpers

## [0.0.0.18] - 2023-02-28

- Implement SLIP-0010 HD child key derivation with the keybase
Expand Down
4 changes: 2 additions & 2 deletions app/client/keybase/debug/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package debug

import (
"fmt"
"github.com/pokt-network/pocket/shared/converters"
"os"
"path/filepath"
r "runtime"
Expand All @@ -12,6 +11,7 @@ import (
"github.com/pokt-network/pocket/runtime"
cryptoPocket "github.com/pokt-network/pocket/shared/crypto"
pocketk8s "github.com/pokt-network/pocket/shared/k8s"
"github.com/pokt-network/pocket/shared/utils"
"gopkg.in/yaml.v2"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -133,7 +133,7 @@ func fetchValidatorPrivateKeysFromFile() (map[string]string, error) {
_, current, _, _ := r.Caller(0)
//nolint:gocritic // Use path to find private-keys yaml file from being called in any location in the repo
yamlFile := filepath.Join(current, privateKeysYamlFile)
if exists, err := converters.FileExists(yamlFile); !exists || err != nil {
if exists, err := utils.FileExists(yamlFile); !exists || err != nil {
return nil, fmt.Errorf("unable to find YAML file: %s", yamlFile)
}

Expand Down
4 changes: 2 additions & 2 deletions app/client/keybase/keybase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/hex"
"testing"

"github.com/pokt-network/pocket/runtime/test_artifacts/keygenerator"
"github.com/pokt-network/pocket/runtime/test_artifacts/keygen"
"github.com/pokt-network/pocket/shared/crypto"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -441,7 +441,7 @@ func initDB(t *testing.T) Keybase {
func createTestKeys(t *testing.T, n int) []crypto.PrivateKey {
pks := make([]crypto.PrivateKey, 0)
for i := 0; i < n; i++ {
privKeyString, _, _ := keygenerator.GetInstance().Next()
privKeyString, _, _ := keygen.GetInstance().Next()
privKey, err := crypto.NewPrivateKey(privKeyString)
require.NoError(t, err)
pks = append(pks, privKey)
Expand Down
7 changes: 3 additions & 4 deletions app/client/keybase/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/pokt-network/pocket/shared/crypto/slip"
"strings"

"github.com/pokt-network/pocket/shared/converters"

"github.com/dgraph-io/badger/v3"
"github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/crypto/slip"
"github.com/pokt-network/pocket/shared/utils"
)

const (
Expand All @@ -32,7 +31,7 @@ type badgerKeybase struct {

// NewKeybase creates/Opens the DB at the specified path creating the path if it doesn't exist
func NewKeybase(path string) (Keybase, error) {
pathExists, err := converters.DirExists(path) // Creates path if it doesn't exist
pathExists, err := utils.DirExists(path) // Creates path if it doesn't exist
if err != nil || !pathExists {
return nil, err
}
Expand Down
30 changes: 11 additions & 19 deletions build/config/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -4040,7 +4040,7 @@
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"chains": null,
"generic_param": "node1.consensus:8080",
"service_url": "node1.consensus:8080",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4051,7 +4051,7 @@
"address": "00204737d2a165ebe4be3a7d5b0af905b0ea91d8",
"public_key": "eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"chains": null,
"generic_param": "node2.consensus:8080",
"service_url": "node2.consensus:8080",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4062,7 +4062,7 @@
"address": "00304d0101847b37fd62e7bebfbdddecdbb7133e",
"public_key": "1041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"chains": null,
"generic_param": "node3.consensus:8080",
"service_url": "node3.consensus:8080",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4073,7 +4073,7 @@
"address": "00404a570febd061274f72b50d0a37f611dfe339",
"public_key": "d6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"chains": null,
"generic_param": "node4.consensus:8080",
"service_url": "node4.consensus:8080",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4085,10 +4085,7 @@
{
"address": "88a792b7aca673620132ef01f50e62caa58eca83",
"public_key": "5f78658599943dc3e623539ce0b3c9fe4e192034a1e3fef308bc9f96915754e0",
"chains": [
"0001"
],
"generic_param": "1000000",
"chains": ["0001"],
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4100,10 +4097,8 @@
{
"address": "43d9ea9d9ad9c58bb96ec41340f83cb2cabb6496",
"public_key": "16cd0a304c38d76271f74dd3c90325144425d904ef1b9a6fbab9b201d75a998b",
"chains": [
"0001"
],
"generic_param": "node1.consensus:8080",
"chains": ["0001"],
"service_url": "node1.consensus:8080",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4115,10 +4110,8 @@
{
"address": "9ba047197ec043665ad3f81278ab1f5d3eaf6b8b",
"public_key": "68efd26af01692fcd77dc135ca1de69ede464e8243e6832bd6c37f282db8c9cb",
"chains": [
"0001"
],
"generic_param": "node1.consensus:8080",
"chains": ["0001"],
"service_url": "node1.consensus:8080",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4130,7 +4123,7 @@
"blocks_per_session": 4,
"app_minimum_stake": "15000000000",
"app_max_chains": 15,
"app_baseline_stake_rate": 100,
"app_session_tokens_multiplier": 100,
"app_unstaking_blocks": 2016,
"app_minimum_pause_blocks": 4,
"app_max_pause_blocks": 672,
Expand Down Expand Up @@ -4184,8 +4177,7 @@
"blocks_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_baseline_stake_rate_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_staking_adjustment_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_session_tokens_multiplier_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
Expand Down
5 changes: 5 additions & 0 deletions build/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.19] - 2023-02-28

- Renamed `generic_param` to `service_url` in the config files
- Renamed a few governance parameters to make self explanatory

## [0.0.0.18] - 2023-02-21

- Rename ServiceNode Actor Type Name to Servicer
Expand Down
Loading

0 comments on commit b694338

Please sign in to comment.