Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BP: v3-ics <- #565] SDK v47 features from Juno #640

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import (
"bytes"
"context"
<<<<<<< HEAD

Check failure on line 6 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / test-cosmos-examples

expected 'STRING', found '<<'

Check failure on line 6 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 6 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / test-ibc-examples

expected 'STRING', found '<<'

Check failure on line 6 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / test-conformance

expected 'STRING', found '<<'

Check failure on line 6 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / unit-tests

expected 'STRING', found '<<'

Check failure on line 6 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / unit-tests

expected 'STRING', found '<<'
=======

Check failure on line 7 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
"crypto/sha256"
"encoding/hex"
>>>>>>> 220ce33 (SDK v47 features from Juno (#565))

Check failure on line 10 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
"encoding/json"
"fmt"
"io"
Expand All @@ -16,13 +21,20 @@
"github.com/cosmos/cosmos-sdk/types"
authTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types"
<<<<<<< HEAD
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
chanTypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types"
ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ccvconsumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types"
ccvclient "github.com/cosmos/interchain-security/x/ccv/provider/client"
ccvprovidertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
=======
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
cosmosproto "github.com/cosmos/gogoproto/proto"
chanTypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
>>>>>>> 220ce33 (SDK v47 features from Juno (#565))

Check failure on line 37 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

illegal character U+0023 '#' (typecheck)
dockertypes "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client"
Expand Down Expand Up @@ -318,6 +330,7 @@
return c.txProposal(txHash)
}

<<<<<<< HEAD

Check failure on line 333 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

expected declaration, found '<<' (typecheck)
// ParamChangeProposal submits a param-change governance proposal to the chain.
func (c *CosmosChain) ParamChangeProposal(ctx context.Context, keyName, fileLocation string) (tx TxProposal, _ error) {
dat, err := os.ReadFile(fileLocation)
Expand All @@ -334,10 +347,44 @@
txHash, err := c.getFullNode().ParamChangeProposal(ctx, keyName, paramChange)
if err != nil {
return tx, fmt.Errorf("failed to submit param-change proposal: %w", err)
=======
// SubmitProposal submits a gov v1 proposal to the chain.
func (c *CosmosChain) SubmitProposal(ctx context.Context, keyName string, prop TxProposalv1) (tx TxProposal, _ error) {
txHash, err := c.getFullNode().SubmitProposal(ctx, keyName, prop)
if err != nil {
return tx, fmt.Errorf("failed to submit gov v1 proposal: %w", err)
>>>>>>> 220ce33 (SDK v47 features from Juno (#565))

Check failure on line 356 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

illegal character U+0023 '#' (typecheck)
}
return c.txProposal(txHash)
}

<<<<<<< HEAD
=======
// Build a gov v1 proposal type.
func (c *CosmosChain) BuildProposal(messages []cosmosproto.Message, title, summary, metadata, depositStr string) (TxProposalv1, error) {
var propType TxProposalv1
rawMsgs := make([]json.RawMessage, len(messages))

Check failure on line 366 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

expected declaration, found rawMsgs (typecheck)

for i, msg := range messages {
msg, err := c.Config().EncodingConfig.Codec.MarshalInterfaceJSON(msg)
if err != nil {
return propType, err
}
rawMsgs[i] = msg
}

propType = TxProposalv1{
Messages: rawMsgs,
Metadata: metadata,
Deposit: depositStr,
Title: title,
Summary: summary,
}

return propType, nil
}

>>>>>>> 220ce33 (SDK v47 features from Juno (#565))

Check failure on line 387 in chain/cosmos/cosmos_chain.go

View workflow job for this annotation

GitHub Actions / lint

illegal character U+0023 '#' (typecheck)
// TextProposal submits a text governance proposal to the chain.
func (c *CosmosChain) TextProposal(ctx context.Context, keyName string, prop TextProposal) (tx TxProposal, _ error) {
txHash, err := c.getFullNode().TextProposal(ctx, keyName, prop)
Expand Down
29 changes: 28 additions & 1 deletion chain/cosmos/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@
import (
"encoding/json"
"fmt"
"strconv"
"strings"

"github.com/icza/dyno"
"github.com/strangelove-ventures/interchaintest/v3/ibc"
)

func ModifyGenesisProposalTime(votingPeriod string, maxDepositPeriod string) func(ibc.ChainConfig, []byte) ([]byte, error) {
type GenesisKV struct {
Key string `json:"key"`
Value interface{} `json:"value"`
}

func ModifyGenesis(genesisKV []GenesisKV) func(ibc.ChainConfig, []byte) ([]byte, error) {
return func(chainConfig ibc.ChainConfig, genbz []byte) ([]byte, error) {
g := make(map[string]interface{})
if err := json.Unmarshal(genbz, &g); err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err)
}
<<<<<<< HEAD

Check failure on line 24 in chain/cosmos/genesis.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '<<' (typecheck)
if err := dyno.Set(g, votingPeriod, "app_state", "gov", "voting_params", "voting_period"); err != nil {
return nil, fmt.Errorf("failed to set voting period in genesis json: %w", err)
}
Expand All @@ -22,7 +30,26 @@
}
if err := dyno.Set(g, chainConfig.Denom, "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil {
return nil, fmt.Errorf("failed to set voting period in genesis json: %w", err)
=======

Check failure on line 33 in chain/cosmos/genesis.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '==' (typecheck)

for idx, values := range genesisKV {
splitPath := strings.Split(values.Key, ".")

path := make([]interface{}, len(splitPath))
for i, component := range splitPath {
if v, err := strconv.Atoi(component); err == nil {
path[i] = v
} else {
path[i] = component
}
}

if err := dyno.Set(g, values.Value, path...); err != nil {
return nil, fmt.Errorf("failed to set value (index:%d) in genesis json: %w", idx, err)
}
>>>>>>> 220ce33 (SDK v47 features from Juno (#565))
}

out, err := json.Marshal(g)
if err != nil {
return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err)
Expand Down
18 changes: 17 additions & 1 deletion examples/cosmos/chain_param_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,30 @@ func CosmosChainParamChangeTest(t *testing.T, name, version string) {
numVals := 1
numFullNodes := 1

// SDK v45 params for Juno genesis
shortVoteGenesis := []cosmos.GenesisKV{
{
Key: "app_state.gov.voting_params.voting_period",
Value: votingPeriod,
},
{
Key: "app_state.gov.deposit_params.max_deposit_period",
Value: maxDepositPeriod,
},
{
Key: "app_state.gov.deposit_params.min_deposit.0.denom",
Value: "ujuno",
},
}

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: name,
ChainName: name,
Version: version,
ChainConfig: ibc.ChainConfig{
Denom: "ujuno",
ModifyGenesis: cosmos.ModifyGenesisProposalTime(votingPeriod, maxDepositPeriod),
ModifyGenesis: cosmos.ModifyGenesis(shortVoteGenesis),
},
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
Expand Down
18 changes: 17 additions & 1 deletion examples/cosmos/chain_upgrade_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,29 @@ func CosmosChainUpgradeIBCTest(t *testing.T, chainName, initialVersion, upgradeV

t.Parallel()

// SDK v45 params for Juno genesis
shortVoteGenesis := []cosmos.GenesisKV{
{
Key: "app_state.gov.voting_params.voting_period",
Value: votingPeriod,
},
{
Key: "app_state.gov.deposit_params.max_deposit_period",
Value: maxDepositPeriod,
},
{
Key: "app_state.gov.deposit_params.min_deposit.0.denom",
Value: "ujuno",
},
}

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: chainName,
ChainName: chainName,
Version: initialVersion,
ChainConfig: ibc.ChainConfig{
ModifyGenesis: cosmos.ModifyGenesisProposalTime(votingPeriod, maxDepositPeriod),
ModifyGenesis: cosmos.ModifyGenesis(shortVoteGenesis),
},
},
{
Expand Down
Loading