From 40c1b601aa375228aed6682212d6255d0a12d4f4 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sun, 13 Aug 2023 22:05:51 -0500 Subject: [PATCH 1/6] Faster block times (3s) + test --- app/upgrades/v17/upgrades.go | 20 ++++++++++++++++- cmd/junod/cmd/root.go | 5 +++-- interchaintest/chain_upgrade_test.go | 23 ++++++++++++++++++++ interchaintest/helpers/mint.go | 32 ++++++++++++++++++++++++++++ interchaintest/helpers/slashing.go | 32 ++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 interchaintest/helpers/mint.go create mode 100644 interchaintest/helpers/slashing.go diff --git a/app/upgrades/v17/upgrades.go b/app/upgrades/v17/upgrades.go index 154b65029..498f0b1a9 100644 --- a/app/upgrades/v17/upgrades.go +++ b/app/upgrades/v17/upgrades.go @@ -14,7 +14,7 @@ import ( func CreateV17UpgradeHandler( mm *module.Manager, cfg module.Configurator, - _ *keepers.AppKeepers, + keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { logger := ctx.Logger().With("upgrade", UpgradeName) @@ -30,6 +30,24 @@ func CreateV17UpgradeHandler( } logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap)) + // x/Mint + // Double blocks per year (from 6 seconds to 3 = 2x blocks per year) + mintParams := keepers.MintKeeper.GetParams(ctx) + mintParams.BlocksPerYear *= 2 + if err = keepers.MintKeeper.SetParams(ctx, mintParams); err != nil { + return nil, err + } + logger.Info(fmt.Sprintf("updated minted blocks per year logic to %v", mintParams)) + + // x/Slashing + // Double slashing window due to double blocks per year + slashingParams := keepers.SlashingKeeper.GetParams(ctx) + slashingParams.SignedBlocksWindow *= 2 + if err := keepers.SlashingKeeper.SetParams(ctx, slashingParams); err != nil { + return nil, err + } + logger.Info(fmt.Sprintf("updated slashing params to %v", slashingParams)) + return versionMap, err } } diff --git a/cmd/junod/cmd/root.go b/cmd/junod/cmd/root.go index ccb66a6a8..bb33eae45 100644 --- a/cmd/junod/cmd/root.go +++ b/cmd/junod/cmd/root.go @@ -5,6 +5,7 @@ import ( "io" "os" "path/filepath" + "time" wasm "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -110,8 +111,8 @@ func initTendermintConfig() *tmcfg.Config { // cfg.P2P.MaxNumInboundPeers = 100 // cfg.P2P.MaxNumOutboundPeers = 40 - // 2 seconds + 1 second tendermint = 3 second blocks (v15 upgrade) - // cfg.Consensus.TimeoutCommit = 2 * time.Second + // 2 seconds + 1 second tendermint = 3 second blocks + cfg.Consensus.TimeoutCommit = 2 * time.Second return cfg } diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index 663ca8ea6..ee0e005a9 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + helpers "github.com/CosmosContracts/juno/tests/interchaintest/helpers" cosmosproto "github.com/cosmos/gogoproto/proto" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v7" @@ -39,6 +40,7 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, initialVersion, upgradeBran t.Log(chainName, initialVersion, upgradeBranchVersion, upgradeRepo, upgradeName) numVals, numNodes := 4, 4 + // TODO: use PR 788's impl of 'CreateChain' to modify the x/mint genesis to match mainnet. chains := CreateThisBranchChain(t, numVals, numNodes) chain := chains[0].(*cosmos.CosmosChain) @@ -61,8 +63,29 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, initialVersion, upgradeBran ValidatorVoting(t, ctx, chain, proposalID, height, haltHeight) + preUpgradeChecks(t, ctx, chain) + UpgradeNodes(t, ctx, chain, client, haltHeight, upgradeRepo, upgradeBranchVersion) + postUpgradeChecks(t, ctx, chain) + +} + +func preUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { + mp := helpers.GetMintParams(t, ctx, chain) + // mainnet it is 5048093, but we are just ensuring the upgrade applies correctly from default. + require.Equal(t, mp.BlocksPerYear, uint64(6311520)) + + sp := helpers.GetSlashingParams(t, ctx, chain) + require.Equal(t, sp.SignedBlocksWindow, uint64(100)) +} + +func postUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { + mp := helpers.GetMintParams(t, ctx, chain) + require.Equal(t, mp.BlocksPerYear, uint64(6311520*2)) // double default + + sp := helpers.GetSlashingParams(t, ctx, chain) + require.Equal(t, sp.SignedBlocksWindow, uint64(100*2)) } func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, client *client.Client, haltHeight uint64, upgradeRepo, upgradeBranchVersion string) { diff --git a/interchaintest/helpers/mint.go b/interchaintest/helpers/mint.go new file mode 100644 index 000000000..8d763ac9f --- /dev/null +++ b/interchaintest/helpers/mint.go @@ -0,0 +1,32 @@ +package helpers + +import ( + "context" + "encoding/json" + "testing" + + minttypes "github.com/CosmosContracts/juno/v17/x/mint/types" + "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" + "github.com/stretchr/testify/require" +) + +func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) minttypes.Params { + cmd := []string{ + "junod", "query", "mint", "params", + "--node", chain.GetRPCAddress(), + "--chain-id", chain.Config().ChainID, + "--output", "json", + } + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + debugOutput(t, string(stdout)) + + results := minttypes.QueryParamsResponse{} + err = json.Unmarshal(stdout, &results) + require.NoError(t, err) + + t.Log(results) + + return results.Params +} diff --git a/interchaintest/helpers/slashing.go b/interchaintest/helpers/slashing.go new file mode 100644 index 000000000..e6daf7e18 --- /dev/null +++ b/interchaintest/helpers/slashing.go @@ -0,0 +1,32 @@ +package helpers + +import ( + "context" + "encoding/json" + "testing" + + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" + "github.com/stretchr/testify/require" +) + +func GetSlashingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) slashingtypes.Params { + cmd := []string{ + "junod", "query", "slashing", "params", + "--node", chain.GetRPCAddress(), + "--chain-id", chain.Config().ChainID, + "--output", "json", + } + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + debugOutput(t, string(stdout)) + + results := slashingtypes.QueryParamsResponse{} + err = json.Unmarshal(stdout, &results) + require.NoError(t, err) + + t.Log(results) + + return results.Params +} From e6fd2fbcc29883e4bbd31239eaa96b75a059f2ce Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sun, 13 Aug 2023 22:16:17 -0500 Subject: [PATCH 2/6] Fix query pointer ref --- interchaintest/helpers/mint.go | 4 ++-- interchaintest/helpers/slashing.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interchaintest/helpers/mint.go b/interchaintest/helpers/mint.go index 8d763ac9f..f6ca8ca25 100644 --- a/interchaintest/helpers/mint.go +++ b/interchaintest/helpers/mint.go @@ -22,8 +22,8 @@ func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) debugOutput(t, string(stdout)) - results := minttypes.QueryParamsResponse{} - err = json.Unmarshal(stdout, &results) + results := &minttypes.QueryParamsResponse{} + err = json.Unmarshal(stdout, results) require.NoError(t, err) t.Log(results) diff --git a/interchaintest/helpers/slashing.go b/interchaintest/helpers/slashing.go index e6daf7e18..81ea6157c 100644 --- a/interchaintest/helpers/slashing.go +++ b/interchaintest/helpers/slashing.go @@ -22,8 +22,8 @@ func GetSlashingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosCh debugOutput(t, string(stdout)) - results := slashingtypes.QueryParamsResponse{} - err = json.Unmarshal(stdout, &results) + results := &slashingtypes.QueryParamsResponse{} + err = json.Unmarshal(stdout, results) require.NoError(t, err) t.Log(results) From 092c6c724848265cb4ccaa7425e560a806df629c Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sun, 13 Aug 2023 22:30:06 -0500 Subject: [PATCH 3/6] Pull out Param types (since no `params` are shown in the queries anymore --- interchaintest/chain_upgrade_test.go | 4 ++-- interchaintest/helpers/mint.go | 15 +++++++++++---- interchaintest/helpers/slashing.go | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index ee0e005a9..acb6e51ac 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -82,10 +82,10 @@ func preUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosCha func postUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { mp := helpers.GetMintParams(t, ctx, chain) - require.Equal(t, mp.BlocksPerYear, uint64(6311520*2)) // double default + require.Equal(t, mp.BlocksPerYear, uint64(12623040)) // double default sp := helpers.GetSlashingParams(t, ctx, chain) - require.Equal(t, sp.SignedBlocksWindow, uint64(100*2)) + require.Equal(t, sp.SignedBlocksWindow, uint64(200)) } func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, client *client.Client, haltHeight uint64, upgradeRepo, upgradeBranchVersion string) { diff --git a/interchaintest/helpers/mint.go b/interchaintest/helpers/mint.go index f6ca8ca25..eee56d843 100644 --- a/interchaintest/helpers/mint.go +++ b/interchaintest/helpers/mint.go @@ -5,12 +5,19 @@ import ( "encoding/json" "testing" - minttypes "github.com/CosmosContracts/juno/v17/x/mint/types" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/stretchr/testify/require" ) -func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) minttypes.Params { +// minttypes.Params +type MintParams struct { + // type of coin to mint + MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` + // expected blocks per year + BlocksPerYear uint64 `protobuf:"varint,2,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` +} + +func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) MintParams { cmd := []string{ "junod", "query", "mint", "params", "--node", chain.GetRPCAddress(), @@ -22,11 +29,11 @@ func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) debugOutput(t, string(stdout)) - results := &minttypes.QueryParamsResponse{} + results := &MintParams{} err = json.Unmarshal(stdout, results) require.NoError(t, err) t.Log(results) - return results.Params + return *results } diff --git a/interchaintest/helpers/slashing.go b/interchaintest/helpers/slashing.go index 81ea6157c..7007dcff8 100644 --- a/interchaintest/helpers/slashing.go +++ b/interchaintest/helpers/slashing.go @@ -4,13 +4,22 @@ import ( "context" "encoding/json" "testing" + "time" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/stretchr/testify/require" ) -func GetSlashingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) slashingtypes.Params { +type SlashingParams struct { + SignedBlocksWindow int64 `protobuf:"varint,1,opt,name=signed_blocks_window,json=signedBlocksWindow,proto3" json:"signed_blocks_window,omitempty"` + MinSignedPerWindow sdk.Dec `protobuf:"bytes,2,opt,name=min_signed_per_window,json=minSignedPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_signed_per_window"` + DowntimeJailDuration time.Duration `protobuf:"bytes,3,opt,name=downtime_jail_duration,json=downtimeJailDuration,proto3,stdduration" json:"downtime_jail_duration"` + SlashFractionDoubleSign sdk.Dec `protobuf:"bytes,4,opt,name=slash_fraction_double_sign,json=slashFractionDoubleSign,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction_double_sign"` + SlashFractionDowntime sdk.Dec `protobuf:"bytes,5,opt,name=slash_fraction_downtime,json=slashFractionDowntime,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction_downtime"` +} + +func GetSlashingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) SlashingParams { cmd := []string{ "junod", "query", "slashing", "params", "--node", chain.GetRPCAddress(), @@ -22,11 +31,11 @@ func GetSlashingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosCh debugOutput(t, string(stdout)) - results := &slashingtypes.QueryParamsResponse{} + results := &SlashingParams{} err = json.Unmarshal(stdout, results) require.NoError(t, err) t.Log(results) - return results.Params + return *results } From 752dbffde9aa95caafca5a2efc85e68f3031eedb Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sun, 13 Aug 2023 22:43:17 -0500 Subject: [PATCH 4/6] Change uint64 to string --- interchaintest/chain_upgrade_test.go | 8 ++++---- interchaintest/helpers/mint.go | 2 +- interchaintest/helpers/slashing.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index acb6e51ac..26273c671 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -74,18 +74,18 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, initialVersion, upgradeBran func preUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { mp := helpers.GetMintParams(t, ctx, chain) // mainnet it is 5048093, but we are just ensuring the upgrade applies correctly from default. - require.Equal(t, mp.BlocksPerYear, uint64(6311520)) + require.Equal(t, mp.BlocksPerYear, "6311520") sp := helpers.GetSlashingParams(t, ctx, chain) - require.Equal(t, sp.SignedBlocksWindow, uint64(100)) + require.Equal(t, sp.SignedBlocksWindow, "100") } func postUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { mp := helpers.GetMintParams(t, ctx, chain) - require.Equal(t, mp.BlocksPerYear, uint64(12623040)) // double default + require.Equal(t, mp.BlocksPerYear, "12623040") // double default sp := helpers.GetSlashingParams(t, ctx, chain) - require.Equal(t, sp.SignedBlocksWindow, uint64(200)) + require.Equal(t, sp.SignedBlocksWindow, "200") } func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, client *client.Client, haltHeight uint64, upgradeRepo, upgradeBranchVersion string) { diff --git a/interchaintest/helpers/mint.go b/interchaintest/helpers/mint.go index eee56d843..3b154bc32 100644 --- a/interchaintest/helpers/mint.go +++ b/interchaintest/helpers/mint.go @@ -14,7 +14,7 @@ type MintParams struct { // type of coin to mint MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` // expected blocks per year - BlocksPerYear uint64 `protobuf:"varint,2,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` + BlocksPerYear string `protobuf:"varint,2,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` } func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) MintParams { diff --git a/interchaintest/helpers/slashing.go b/interchaintest/helpers/slashing.go index 7007dcff8..46dfc46b5 100644 --- a/interchaintest/helpers/slashing.go +++ b/interchaintest/helpers/slashing.go @@ -12,7 +12,7 @@ import ( ) type SlashingParams struct { - SignedBlocksWindow int64 `protobuf:"varint,1,opt,name=signed_blocks_window,json=signedBlocksWindow,proto3" json:"signed_blocks_window,omitempty"` + SignedBlocksWindow string `protobuf:"varint,1,opt,name=signed_blocks_window,json=signedBlocksWindow,proto3" json:"signed_blocks_window,omitempty"` MinSignedPerWindow sdk.Dec `protobuf:"bytes,2,opt,name=min_signed_per_window,json=minSignedPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_signed_per_window"` DowntimeJailDuration time.Duration `protobuf:"bytes,3,opt,name=downtime_jail_duration,json=downtimeJailDuration,proto3,stdduration" json:"downtime_jail_duration"` SlashFractionDoubleSign sdk.Dec `protobuf:"bytes,4,opt,name=slash_fraction_double_sign,json=slashFractionDoubleSign,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction_double_sign"` From 2fd7d52ee7cd95c19eea4eb68a8de94a7f5aee89 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sun, 13 Aug 2023 23:06:33 -0500 Subject: [PATCH 5/6] Move 3s block time check to go test --- app/upgrades/v17/upgrade_test.go | 22 +++++++++++++++ interchaintest/chain_upgrade_test.go | 23 ---------------- interchaintest/helpers/mint.go | 39 -------------------------- interchaintest/helpers/slashing.go | 41 ---------------------------- 4 files changed, 22 insertions(+), 103 deletions(-) delete mode 100644 interchaintest/helpers/mint.go delete mode 100644 interchaintest/helpers/slashing.go diff --git a/app/upgrades/v17/upgrade_test.go b/app/upgrades/v17/upgrade_test.go index e02c2e4b8..dded4c49a 100644 --- a/app/upgrades/v17/upgrade_test.go +++ b/app/upgrades/v17/upgrade_test.go @@ -25,6 +25,28 @@ func TestKeeperTestSuite(t *testing.T) { func (s *UpgradeTestSuite) TestUpgrade() { s.Setup() + preUpgradeChecks(s) + upgradeHeight := int64(5) s.ConfirmUpgradeSucceeded(v17.UpgradeName, upgradeHeight) + + postUpgradeChecks(s) +} + +func preUpgradeChecks(s *UpgradeTestSuite) { + mp := s.App.AppKeepers.MintKeeper.GetParams(s.Ctx) + s.Require().Equal(mp.BlocksPerYear, uint64(6311520)) + + sp := s.App.AppKeepers.SlashingKeeper.GetParams(s.Ctx) + s.Require().Equal(sp.SignedBlocksWindow, int64(100)) +} + +func postUpgradeChecks(s *UpgradeTestSuite) { + // Ensure the mint params have doubled + mp := s.App.AppKeepers.MintKeeper.GetParams(s.Ctx) + s.Require().Equal(mp.BlocksPerYear, uint64(6311520*2)) + + // Ensure the slashing params have doubled + sp := s.App.AppKeepers.SlashingKeeper.GetParams(s.Ctx) + s.Require().Equal(sp.SignedBlocksWindow, int64(100*2)) } diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index 26273c671..c55aee897 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - helpers "github.com/CosmosContracts/juno/tests/interchaintest/helpers" cosmosproto "github.com/cosmos/gogoproto/proto" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v7" @@ -63,29 +62,7 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, initialVersion, upgradeBran ValidatorVoting(t, ctx, chain, proposalID, height, haltHeight) - preUpgradeChecks(t, ctx, chain) - UpgradeNodes(t, ctx, chain, client, haltHeight, upgradeRepo, upgradeBranchVersion) - - postUpgradeChecks(t, ctx, chain) - -} - -func preUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { - mp := helpers.GetMintParams(t, ctx, chain) - // mainnet it is 5048093, but we are just ensuring the upgrade applies correctly from default. - require.Equal(t, mp.BlocksPerYear, "6311520") - - sp := helpers.GetSlashingParams(t, ctx, chain) - require.Equal(t, sp.SignedBlocksWindow, "100") -} - -func postUpgradeChecks(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) { - mp := helpers.GetMintParams(t, ctx, chain) - require.Equal(t, mp.BlocksPerYear, "12623040") // double default - - sp := helpers.GetSlashingParams(t, ctx, chain) - require.Equal(t, sp.SignedBlocksWindow, "200") } func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, client *client.Client, haltHeight uint64, upgradeRepo, upgradeBranchVersion string) { diff --git a/interchaintest/helpers/mint.go b/interchaintest/helpers/mint.go deleted file mode 100644 index 3b154bc32..000000000 --- a/interchaintest/helpers/mint.go +++ /dev/null @@ -1,39 +0,0 @@ -package helpers - -import ( - "context" - "encoding/json" - "testing" - - "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" - "github.com/stretchr/testify/require" -) - -// minttypes.Params -type MintParams struct { - // type of coin to mint - MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` - // expected blocks per year - BlocksPerYear string `protobuf:"varint,2,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` -} - -func GetMintParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) MintParams { - cmd := []string{ - "junod", "query", "mint", "params", - "--node", chain.GetRPCAddress(), - "--chain-id", chain.Config().ChainID, - "--output", "json", - } - stdout, _, err := chain.Exec(ctx, cmd, nil) - require.NoError(t, err) - - debugOutput(t, string(stdout)) - - results := &MintParams{} - err = json.Unmarshal(stdout, results) - require.NoError(t, err) - - t.Log(results) - - return *results -} diff --git a/interchaintest/helpers/slashing.go b/interchaintest/helpers/slashing.go deleted file mode 100644 index 46dfc46b5..000000000 --- a/interchaintest/helpers/slashing.go +++ /dev/null @@ -1,41 +0,0 @@ -package helpers - -import ( - "context" - "encoding/json" - "testing" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" - "github.com/stretchr/testify/require" -) - -type SlashingParams struct { - SignedBlocksWindow string `protobuf:"varint,1,opt,name=signed_blocks_window,json=signedBlocksWindow,proto3" json:"signed_blocks_window,omitempty"` - MinSignedPerWindow sdk.Dec `protobuf:"bytes,2,opt,name=min_signed_per_window,json=minSignedPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_signed_per_window"` - DowntimeJailDuration time.Duration `protobuf:"bytes,3,opt,name=downtime_jail_duration,json=downtimeJailDuration,proto3,stdduration" json:"downtime_jail_duration"` - SlashFractionDoubleSign sdk.Dec `protobuf:"bytes,4,opt,name=slash_fraction_double_sign,json=slashFractionDoubleSign,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction_double_sign"` - SlashFractionDowntime sdk.Dec `protobuf:"bytes,5,opt,name=slash_fraction_downtime,json=slashFractionDowntime,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction_downtime"` -} - -func GetSlashingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain) SlashingParams { - cmd := []string{ - "junod", "query", "slashing", "params", - "--node", chain.GetRPCAddress(), - "--chain-id", chain.Config().ChainID, - "--output", "json", - } - stdout, _, err := chain.Exec(ctx, cmd, nil) - require.NoError(t, err) - - debugOutput(t, string(stdout)) - - results := &SlashingParams{} - err = json.Unmarshal(stdout, results) - require.NoError(t, err) - - t.Log(results) - - return *results -} From 7e3a7ed35b598ffeba19829b82338c58712cbebf Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sun, 13 Aug 2023 23:52:21 -0500 Subject: [PATCH 6/6] Forced faster block times config --- cmd/junod/cmd/root.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/junod/cmd/root.go b/cmd/junod/cmd/root.go index bb33eae45..9e71d0e27 100644 --- a/cmd/junod/cmd/root.go +++ b/cmd/junod/cmd/root.go @@ -90,8 +90,14 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { return err } + // 2 seconds + 1 second tendermint = 3 second blocks + timeoutCommit := 2 * time.Second + customAppTemplate, customAppConfig := initAppConfig() - customTMConfig := initTendermintConfig() + customTMConfig := initTendermintConfig(timeoutCommit) + + // Force faster block times + os.Setenv("JUNOD_CONSENSUS_TIMEOUT_COMMIT", cast.ToString(timeoutCommit)) return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) }, @@ -104,15 +110,15 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { // initTendermintConfig helps to override default Tendermint Config values. // return tmcfg.DefaultConfig if no custom configuration is required for the application. -func initTendermintConfig() *tmcfg.Config { +func initTendermintConfig(timeoutCommit time.Duration) *tmcfg.Config { cfg := tmcfg.DefaultConfig() // these values put a higher strain on node memory // cfg.P2P.MaxNumInboundPeers = 100 // cfg.P2P.MaxNumOutboundPeers = 40 - // 2 seconds + 1 second tendermint = 3 second blocks - cfg.Consensus.TimeoutCommit = 2 * time.Second + // While this is set, it only applies to new configs. + cfg.Consensus.TimeoutCommit = timeoutCommit return cfg }