Skip to content

Commit

Permalink
Bring interchain-security into v7 (#857)
Browse files Browse the repository at this point in the history
* add ics

* remove extra codec

* mod

* fix repo

* use `interchaintest` namespace

---------

Co-authored-by: Reece Williams <reecepbcups@gmail.com>
  • Loading branch information
boojamya and Reecepbcups authored Nov 7, 2023
1 parent ad88680 commit 79f1a55
Show file tree
Hide file tree
Showing 18 changed files with 4,174 additions and 100 deletions.
41 changes: 41 additions & 0 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

ccvclient "github.com/cosmos/interchain-security/v3/x/ccv/provider/client"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/internal/blockdb"
"github.com/strangelove-ventures/interchaintest/v7/internal/dockerutil"
Expand Down Expand Up @@ -221,6 +222,25 @@ func (tn *ChainNode) OverwriteGenesisFile(ctx context.Context, content []byte) e
return nil
}

func (tn *ChainNode) privValFileContent(ctx context.Context) ([]byte, error) {
fr := dockerutil.NewFileRetriever(tn.logger(), tn.DockerClient, tn.TestName)
gen, err := fr.SingleFileContent(ctx, tn.VolumeName, "config/priv_validator_key.json")
if err != nil {
return nil, fmt.Errorf("getting priv_validator_key.json content: %w", err)
}

return gen, nil
}

func (tn *ChainNode) overwritePrivValFile(ctx context.Context, content []byte) error {
fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName)
if err := fw.WriteFile(ctx, tn.VolumeName, "config/priv_validator_key.json", content); err != nil {
return fmt.Errorf("overwriting priv_validator_key.json: %w", err)
}

return nil
}

func (tn *ChainNode) copyGentx(ctx context.Context, destVal *ChainNode) error {
nid, err := tn.NodeID(ctx)
if err != nil {
Expand Down Expand Up @@ -1170,6 +1190,27 @@ func (tn *ChainNode) TextProposal(ctx context.Context, keyName string, prop Text
return tn.ExecTx(ctx, keyName, command...)
}

func (tn *ChainNode) ConsumerAdditionProposal(ctx context.Context, keyName string, prop ccvclient.ConsumerAdditionProposalJSON) (string, error) {
propBz, err := json.Marshal(prop)
if err != nil {
return "", err
}

fileName := "proposal_" + dockerutil.RandLowerCaseLetterString(4) + ".json"

fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName)
if err := fw.WriteFile(ctx, tn.VolumeName, fileName, propBz); err != nil {
return "", fmt.Errorf("failure writing proposal json: %w", err)
}

filePath := filepath.Join(tn.HomeDir(), fileName)

return tn.ExecTx(ctx, keyName,
"gov", "submit-legacy-proposal", "consumer-addition", filePath,
"--gas", "auto",
)
}

// ParamChangeProposal submits a param change proposal to the chain, signed by keyName.
func (tn *ChainNode) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (string, error) {
content, err := json.Marshal(prop)
Expand Down
2 changes: 2 additions & 0 deletions chain/cosmos/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibccore "github.com/cosmos/ibc-go/v7/modules/core"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ccvprovider "github.com/cosmos/interchain-security/v3/x/ccv/provider"
ibcwasm "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos/08-wasm-types"
)

Expand Down Expand Up @@ -53,6 +54,7 @@ func DefaultEncoding() testutil.TestEncodingConfig {
ibccore.AppModuleBasic{},
ibctm.AppModuleBasic{},
ibcwasm.AppModuleBasic{},
ccvprovider.AppModuleBasic{},
)
}

Expand Down
Loading

0 comments on commit 79f1a55

Please sign in to comment.