diff --git a/Makefile b/Makefile index 6d46f90be..5c350dfda 100644 --- a/Makefile +++ b/Makefile @@ -260,6 +260,8 @@ acc_balance_total_supply: ## Query the total supply of the network # (PNF was selected ambigously) to make sure their public keys are populated. # TODO_TECHDEBT: One of the accounts involved in this command always errors # so we need to understand why and fix it. + + .PHONY: acc_initialize_pubkeys acc_initialize_pubkeys: ## Make sure the account keeper has public keys for all available accounts $(eval ADDRESSES=$(shell make -s ignite_acc_list | grep pokt | awk '{printf "%s ", $$2}' | sed 's/.$$//')) @@ -268,8 +270,10 @@ acc_initialize_pubkeys: ## Make sure the account keeper has public keys for all poktrolld tx bank send \ $(addr) $(PNF_ADDRESS) 1000upokt \ --yes \ + --gas=auto \ + --gas-prices=0.000000001upokt \ --home=$(POKTROLLD_HOME) \ - --node $(POCKET_NODE);) + --node=$(POCKET_NODE);) ###################### ### Ignite Helpers ### diff --git a/api/poktroll/application/tx.pulsar.go b/api/poktroll/application/tx.pulsar.go index 58fc70aa6..0fd937521 100644 --- a/api/poktroll/application/tx.pulsar.go +++ b/api/poktroll/application/tx.pulsar.go @@ -5,11 +5,11 @@ import ( _ "cosmossdk.io/api/amino" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - shared "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/cmd/poktrolld/cmd/commands.go b/cmd/poktrolld/cmd/commands.go index 7792e07f7..b30a296c6 100644 --- a/cmd/poktrolld/cmd/commands.go +++ b/cmd/poktrolld/cmd/commands.go @@ -114,6 +114,9 @@ func txCommand() *cobra.Command { authcmd.GetDecodeCommand(), authcmd.GetSimulateCmd(), ) + + // TODO_TECHDEBT: doesn't seem changing flags here has any effect (as commands use `flags.AddTxFlagsToCmd(cmd)`) + // consider moving to `clientconfig.DefaultClientConfigTemplate` and `initClientConfig()` on newer cosmos-sdk versions (currently at v0.50.9) cmd.PersistentFlags().String(flags.FlagChainID, DefaultChainID, "The network chain ID") return cmd diff --git a/cmd/poktrolld/cmd/config.go b/cmd/poktrolld/cmd/config.go index ae9520a41..138075e84 100644 --- a/cmd/poktrolld/cmd/config.go +++ b/cmd/poktrolld/cmd/config.go @@ -1,10 +1,12 @@ package cmd import ( + "strings" "sync" "time" cmtcfg "github.com/cometbft/cometbft/config" + clientconfig "github.com/cosmos/cosmos-sdk/client/config" serverconfig "github.com/cosmos/cosmos-sdk/server/config" sdk "github.com/cosmos/cosmos-sdk/types" @@ -176,3 +178,65 @@ func customPoktrollAppConfigTemplate() string { cardinality-level = "{{ .Poktroll.Telemetry.CardinalityLevel }}" ` } + +// initClientConfig helps to override default client config (client.toml) template and configs. +// Allows to dynamically create client.toml file with custom values. +// TODO_TECHDEBT: make use of this with `clientconfig.DefaultClientConfigTemplate` on newer cosmos-sdk versions (currently at v0.50.9) +func initClientConfig() (string, interface{}) { + type GasConfig struct { + GasAdjustment float64 `mapstructure:"gas-adjustment"` + Gas string `mapstructure:"gas"` + } + + type CustomClientConfig struct { + clientconfig.ClientConfig `mapstructure:",squash"` + + GasConfig GasConfig `mapstructure:"gas"` + } + + // Default configuration from cosmos-sdk + clientCfg := clientconfig.DefaultConfig() + // clientCfg.ChainID = "" TODO_MAINNET: set mainnet chain-id + + // Now we set the custom config default values. + customClientConfig := CustomClientConfig{ + ClientConfig: *clientCfg, + GasConfig: GasConfig{ + GasAdjustment: 1.5, // default is 1. + Gas: "auto", // default is 200000 + }, + } + + // According to cosmos-sdk documentation, the template is exported via clientconfig.DefaultClientConfigTemplate, + // however as of 0.50.9 - it is not, so we're copying their template. + // TODO_TECHDEBT: switch to `clientconfig.DefaultClientConfigTemplate` on newer cosmos-sdk versions. + defaultConfigTemplate := `# This is a TOML config file. + # For more information, see https://github.com/toml-lang/toml + + ############################################################################### + ### Client Configuration ### + ############################################################################### + + # The network chain ID + chain-id = "{{ .ChainID }}" + # The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) + keyring-backend = "{{ .KeyringBackend }}" + # CLI output format (text|json) + output = "{{ .Output }}" + # : to CometBFT RPC interface for this chain + node = "{{ .Node }}" + # Transaction broadcasting mode (sync|async) + broadcast-mode = "{{ .BroadcastMode }}" + ` + + // Adding our custom config template + customClientConfigTemplate := defaultConfigTemplate + strings.TrimSpace(` + # This is default the gas adjustment factor used in tx commands. + # It can be overwritten by the --gas-adjustment flag in each tx command. + gas-adjustment = {{ .GasConfig.GasAdjustment }} + # Gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically + gas = "{{ .GasConfig.Gas }}" + `) + + return customClientConfigTemplate, customClientConfig +} diff --git a/cmd/poktrolld/cmd/root.go b/cmd/poktrolld/cmd/root.go index 86fd01f81..a9466e2ba 100644 --- a/cmd/poktrolld/cmd/root.go +++ b/cmd/poktrolld/cmd/root.go @@ -77,6 +77,7 @@ func NewRootCmd() *cobra.Command { return err } + // TODO_TECHDEBT: switch to `config.CreateClientConfig` on newer cosmos-sdk versions. Make use of `initClientConfig()` clientCtx, err = config.ReadFromClientConfig(clientCtx) if err != nil { return err @@ -99,10 +100,6 @@ func NewRootCmd() *cobra.Command { return err } - if err = client.SetCmdClientContextHandler(clientCtx, cmd); err != nil { - return err - } - customAppTemplate, customAppConfig := initAppConfig() customCMTConfig := initCometBFTConfig() diff --git a/config.yml b/config.yml index 0554fcf5d..a58be9ec3 100644 --- a/config.yml +++ b/config.yml @@ -88,7 +88,7 @@ validators: # DEV_NOTE: Ignite does not carry over all defaults, so we are going to match `minimum-gas-prices` with `cmd/config.go`. # See the enhancement request here: https://github.com/ignite/cli/issues/4340 # TODO_BETA(@okdas, #794): turn on `minimum-gas-prices` back - # minimum-gas-prices: 0.000000001upokt + minimum-gas-prices: 0.000000001upokt telemetry: enabled: true poktroll: diff --git a/e2e/tests/0_settlement.feature b/e2e/tests/0_settlement.feature index a6595eb37..4153c0471 100644 --- a/e2e/tests/0_settlement.feature +++ b/e2e/tests/0_settlement.feature @@ -21,8 +21,8 @@ Feature: Tokenomics Namespace And the "proof" module parameters are set as follows | name | value | type | | proof_request_probability | 0.25 | float | - | proof_requirement_threshold | 839 | coin | - | proof_missing_penalty | 320 | coin | + | proof_requirement_threshold | 839000000 | coin | + | proof_missing_penalty | 320000000 | coin | | proof_submission_fee | 1000000 | coin | And all "proof" module params should be updated And the "shared" module parameters are set as follows @@ -55,9 +55,9 @@ Feature: Tokenomics Namespace # to make sure a proof is not required. And the "proof" module parameters are set as follows | name | value | type | - | proof_request_probability | 0 | float | - | proof_requirement_threshold | 421 | coin | - | proof_missing_penalty | 320 | coin | + | proof_request_probability | 0.25 | float | + | proof_requirement_threshold | 20000000 | coin | + | proof_missing_penalty | 320000000 | coin | | proof_submission_fee | 1000000 | coin | And all "proof" module params should be updated And the "shared" module parameters are set as follows diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 2c152c232..01ce58566 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -191,6 +191,8 @@ func (s *suite) TheUserSendsUpoktFromAccountToAccount(amount int64, accName1, ac fmt.Sprintf("%dupokt", amount), keyRingFlag, chainIdFlag, + "--gas=auto", + "--gas-prices=0.000001upokt", "-y", } res, err := s.pocketd.RunCommandOnHost("", args...) @@ -300,6 +302,7 @@ func (s *suite) TheUserStakesAWithUpoktForServiceFromTheAccount(actorType string accName, keyRingFlag, chainIdFlag, + "--fees=1upokt", "-y", } res, err := s.pocketd.RunCommandOnHost("", args...) diff --git a/e2e/tests/send.feature b/e2e/tests/send.feature index ae1eb60d3..47cb779c4 100644 --- a/e2e/tests/send.feature +++ b/e2e/tests/send.feature @@ -9,5 +9,5 @@ Feature: Send Namespace And the user should be able to see standard output containing "code: 0" And the pocketd binary should exit without error And the user should wait for "5" seconds - And the account balance of "app1" should be "1000" uPOKT "less" than before + And the account balance of "app1" should be "1001" uPOKT "less" than before And the account balance of "app2" should be "1000" uPOKT "more" than before diff --git a/e2e/tests/session.feature b/e2e/tests/session.feature index df5f3f66a..c06951cfa 100644 --- a/e2e/tests/session.feature +++ b/e2e/tests/session.feature @@ -2,14 +2,14 @@ Feature: Session Namespace Scenario: Supplier completes claim/proof lifecycle for a valid session Given the user has the pocketd binary installed - # Set proof_requirement_threshold to 209 < num_relays (5) * compute_units_per_relay (1) * compute_units_to_tokens_multiplier (42) + # Set proof_requirement_threshold to 209000000 < num_relays (5) * compute_units_per_relay (1) * compute_units_to_tokens_multiplier (42) # to make sure a proof is required. And the "proof" module parameters are set as follows - | name | value | type | - | proof_request_probability | 0.25 | float | - | proof_requirement_threshold | 209 | coin | - | proof_missing_penalty | 320 | coin | - | proof_submission_fee | 1000000 | coin | + | name | value | type | + | proof_request_probability | 0.25 | float | + | proof_requirement_threshold | 20000000 | coin | + | proof_missing_penalty | 320000000 | coin | + | proof_submission_fee | 1000000 | coin | And all "proof" module params should be updated And the "shared" module parameters are set as follows | compute_units_to_tokens_multiplier | 42 | int64 | diff --git a/e2e/tests/stake_supplier_steps_test.go b/e2e/tests/stake_supplier_steps_test.go index 96aa53538..d57507abb 100644 --- a/e2e/tests/stake_supplier_steps_test.go +++ b/e2e/tests/stake_supplier_steps_test.go @@ -29,18 +29,21 @@ func (s *suite) TheUnbondingPeriodParamIsSuccessfullySetToSessionsOfBlocks( grantee, "user", ) - // NB: If new parameters are added to the shared module, they - // MUST be included here; otherwise, this step will fail. + // Get current params first + currentParams := s.queryAllModuleParams(paramModuleName) + currentSharedParams := currentParams.Params + + // Only update the specific parameters we care about sharedParams := sharedtypes.Params{ NumBlocksPerSession: uint64(numBlocksPerSession), - GracePeriodEndOffsetBlocks: 0, - ClaimWindowOpenOffsetBlocks: 0, - ClaimWindowCloseOffsetBlocks: 1, - ProofWindowOpenOffsetBlocks: 0, - ProofWindowCloseOffsetBlocks: 1, + GracePeriodEndOffsetBlocks: currentSharedParams.GracePeriodEndOffsetBlocks, + ClaimWindowOpenOffsetBlocks: currentSharedParams.ClaimWindowOpenOffsetBlocks, + ClaimWindowCloseOffsetBlocks: currentSharedParams.ClaimWindowCloseOffsetBlocks, + ProofWindowOpenOffsetBlocks: currentSharedParams.ProofWindowOpenOffsetBlocks, + ProofWindowCloseOffsetBlocks: currentSharedParams.ProofWindowCloseOffsetBlocks, SupplierUnbondingPeriodSessions: uint64(unbondingPeriodSessions), ApplicationUnbondingPeriodSessions: uint64(unbondingPeriodSessions), - ComputeUnitsToTokensMultiplier: sharedtypes.DefaultComputeUnitsToTokensMultiplier, + ComputeUnitsToTokensMultiplier: currentSharedParams.ComputeUnitsToTokensMultiplier, } // Convert params struct to the map type expected by @@ -77,3 +80,21 @@ func paramsAnyMapFromParamsStruct(paramStruct any) paramsAnyMap { } return paramsMap } + +// queryAllModuleParams queries all parameters for the given module and returns them +// as a QueryParamsResponse. +func (s *suite) queryAllModuleParams(moduleName string) *sharedtypes.QueryParamsResponse { + argsAndFlags := []string{ + "query", + moduleName, + "params", + "--output=json", + } + + res, err := s.pocketd.RunCommandOnHostWithRetry("", numQueryRetries, argsAndFlags...) + require.NoError(s, err) + + var paramsRes sharedtypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), ¶msRes) + return ¶msRes +} diff --git a/localnet/poktrolld/config/app.toml b/localnet/poktrolld/config/app.toml index d5135735e..dc2618620 100644 --- a/localnet/poktrolld/config/app.toml +++ b/localnet/poktrolld/config/app.toml @@ -6,7 +6,7 @@ iavl-disable-fastnode = false index-events = [] inter-block-cache = true min-retain-blocks = 0 -minimum-gas-prices = "0upokt" +minimum-gas-prices = "0.000000001upokt" pruning = "nothing" pruning-interval = "0" pruning-keep-recent = "0" diff --git a/localnet/poktrolld/config/client.toml b/localnet/poktrolld/config/client.toml index 57ac25034..554936fff 100644 --- a/localnet/poktrolld/config/client.toml +++ b/localnet/poktrolld/config/client.toml @@ -1,5 +1,7 @@ broadcast-mode = "sync" chain-id = "poktroll" +gas = "auto" +gas-prices = "0.000000001upokt" keyring-backend = "test" node = "tcp://localhost:26657" output = "text"