Skip to content

Commit

Permalink
Merge branch 'main' into rollkit-celestia-example
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba authored May 15, 2024
2 parents d7431af + 2fe399e commit 7666463
Show file tree
Hide file tree
Showing 19 changed files with 162 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
open-pull-requests-limit: 10
labels:
- dependencies
- dependencies
- package-ecosystem: github-actions
directory: "/"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
contents: read
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.4.0
- uses: amannn/action-semantic-pull-request@v5.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ docker-mac-nuke: ## macOS only. Try docker-reset first. Kills and restarts Docke
gen: ## Run code generators
go generate ./...

.PHONY: mod-tidy
mod-tidy: ## Run mod tidy
go mod tidy
cd local-interchain && go mod tidy

.PHONY: proto-gen
proto-gen: ## Generate code from protos
@echo "Generating Protobuf files"
Expand Down
11 changes: 11 additions & 0 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type ChainNode struct {
GrpcConn *grpc.ClientConn
TestName string
Image ibc.DockerImage
preStartNode func(*ChainNode)

// Additional processes that need to be run on a per-validator basis.
Sidecars SidecarProcesses
Expand Down Expand Up @@ -97,6 +98,12 @@ func NewChainNode(log *zap.Logger, validator bool, chain *CosmosChain, dockerCli
return tn
}

// WithPreStartNode sets the preStartNode function for the ChainNode
func (tn *ChainNode) WithPreStartNode(preStartNode func(*ChainNode)) *ChainNode {
tn.preStartNode = preStartNode
return tn
}

// ChainNodes is a collection of ChainNode
type ChainNodes []*ChainNode

Expand Down Expand Up @@ -1186,6 +1193,10 @@ func (tn *ChainNode) StartContainer(ctx context.Context) error {
}
}

if tn.preStartNode != nil {
tn.preStartNode(tn)
}

if err := tn.containerLifecycle.StartContainer(ctx); err != nil {
return err
}
Expand Down
19 changes: 19 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type CosmosChain struct {
Provider *CosmosChain
Consumers []*CosmosChain

// preStartNodes is able to mutate the node containers before
// they are all started
preStartNodes func(*CosmosChain)

// Additional processes that need to be run on a per-chain basis.
Sidecars SidecarProcesses

Expand Down Expand Up @@ -119,6 +123,12 @@ func NewCosmosChain(testName string, chainConfig ibc.ChainConfig, numValidators
}
}

// WithPreStartNodes sets the preStartNodes function.
func (c *CosmosChain) WithPreStartNodes(preStartNodes func(*CosmosChain)) {
c.preStartNodes = preStartNodes
}


// GetCodec returns the codec for the chain.
func (c *CosmosChain) GetCodec() *codec.ProtoCodec {
return c.cdc
Expand Down Expand Up @@ -539,6 +549,11 @@ func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contr
return c.getFullNode().ExecuteContract(ctx, keyName, contractAddress, message, extraExecTxArgs...)
}

// MigrateContract performs contract migration
func (c *CosmosChain) MigrateContract(ctx context.Context, keyName string, contractAddress string, codeID string, message string, extraExecTxArgs ...string) (res *types.TxResponse, err error) {
return c.getFullNode().MigrateContract(ctx, keyName, contractAddress, codeID, message, extraExecTxArgs...)
}

// QueryContract performs a smart query, taking in a query struct and returning a error with the response struct populated.
func (c *CosmosChain) QueryContract(ctx context.Context, contractAddress string, query any, response any) error {
return c.getFullNode().QueryContract(ctx, contractAddress, query, response)
Expand Down Expand Up @@ -900,6 +915,10 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene
return err
}

if c.preStartNodes != nil {
c.preStartNodes(c)
}

if c.cfg.PreGenesis != nil {
err := c.cfg.PreGenesis(chainCfg)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions chain/cosmos/ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi

chainNodes := c.Nodes()

if c.preStartNodes != nil {
c.preStartNodes(c)
}

for _, cn := range chainNodes {
if err := cn.OverwriteGenesisFile(ctx, genbz); err != nil {
return err
Expand Down
23 changes: 23 additions & 0 deletions chain/cosmos/module_cosmwasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path"
"path/filepath"

"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
)
Expand Down Expand Up @@ -160,6 +161,28 @@ func (tn *ChainNode) QueryContract(ctx context.Context, contractAddress string,
return err
}

// MigrateContract performs contract migration
func (tn *ChainNode) MigrateContract(ctx context.Context, keyName string, contractAddress string, codeID string, message string, extraExecTxArgs ...string) (res *types.TxResponse, err error) {
cmd := []string{"wasm", "migrate", contractAddress, codeID, message}
cmd = append(cmd, extraExecTxArgs...)

txHash, err := tn.ExecTx(ctx, keyName, cmd...)
if err != nil {
return &types.TxResponse{}, err
}

txResp, err := tn.GetTransaction(tn.CliContext(), txHash)
if err != nil {
return &types.TxResponse{}, fmt.Errorf("failed to get transaction %s: %w", txHash, err)
}

if txResp.Code != 0 {
return txResp, fmt.Errorf("error in transaction (code: %d): %s", txResp.Code, txResp.RawLog)
}

return txResp, nil
}

// StoreClientContract takes a file path to a client smart contract and stores it on-chain. Returns the contracts code id.
func (tn *ChainNode) StoreClientContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) {
content, err := os.ReadFile(fileName)
Expand Down
4 changes: 2 additions & 2 deletions chainfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func initBuiltinChainConfig(log *zap.Logger) (map[string]ibc.ChainConfig, error)
var dat []byte
var err error

// checks if IBCTEST_CONFIGURED_CHAINS environment variable is set with a path,
// checks if ICTEST_CONFIGURED_CHAINS environment variable is set with a path,
// otherwise, ./configuredChains.yaml gets embedded and used.
val := os.Getenv("IBCTEST_CONFIGURED_CHAINS")
val := os.Getenv("ICTEST_CONFIGURED_CHAINS")

if val != "" {
dat, err = os.ReadFile(val)
Expand Down
2 changes: 1 addition & 1 deletion configuredChains.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## NOTICE: This file gets embedded into interchaintest binary.
## Set the environment variable: IBCTEST_CONFIGURED_CHAINS to a path
## Set the environment variable: ICTEST_CONFIGURED_CHAINS to a path
## to use custom versions of this file

agoric:
Expand Down
4 changes: 2 additions & 2 deletions dockerutil/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ const (
// using DockerSetup are retained or deleted following a test failure.
//
// The value is false by default, but can be initialized to true by setting the
// environment variable IBCTEST_SKIP_FAILURE_CLEANUP to a non-empty value.
// environment variable ICTEST_SKIP_FAILURE_CLEANUP to a non-empty value.
// Alternatively, importers of the dockerutil package may set the variable to true.
// Because dockerutil is an internal package, the public API for setting this value
// is interchaintest.KeepDockerVolumesOnFailure(bool).
var KeepVolumesOnFailure = os.Getenv("IBCTEST_SKIP_FAILURE_CLEANUP") != ""
var KeepVolumesOnFailure = os.Getenv("ICTEST_SKIP_FAILURE_CLEANUP") != ""

// DockerSetup returns a new Docker Client and the ID of a configured network, associated with t.
//
Expand Down
4 changes: 2 additions & 2 deletions docs/retainingDataOnFailedTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ By default, failed tests will clean up any temporary directories they created.
Sometimes when debugging a failed test, it can be more helpful to leave the directory behind
for further manual inspection.

Setting the environment variable `IBCTEST_SKIP_FAILURE_CLEANUP` to any non-empty value
Setting the environment variable `ICTEST_SKIP_FAILURE_CLEANUP` to any non-empty value
will cause the test to skip deletion of the temporary directories.
Any tests that fail and skip cleanup will log a message like
`Not removing temporary directory for test at: /tmp/...`.
Expand All @@ -14,4 +14,4 @@ Test authors must use
instead of `(*testing.T).Cleanup` to opt in to this behavior.

By default, Docker volumes associated with tests are cleaned up at the end of each test run.
That same `IBCTEST_SKIP_FAILURE_CLEANUP` controls whether the volumes associated with failed tests are pruned.
That same `ICTEST_SKIP_FAILURE_CLEANUP` controls whether the volumes associated with failed tests are pruned.
8 changes: 8 additions & 0 deletions examples/ibc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Interchain Accounts

* [interchain_accounts demo](https://gist.github.com/Reecepbcups/8ec46ad83f6c9c1a152c10ab25774335)
* [ibc-go](https://github.com/cosmos/ibc-go/blob/main/e2e/tests/interchain_accounts/base_test.go)
* [relayer](https://github.com/cosmos/relayer/blob/v2.5.2/interchaintest/interchain_accounts_test.go)
* [ICA channel close](https://github.com/cosmos/relayer/blob/v2.5.2/interchaintest/ica_channel_close_test.go)

Interchain Queries

Expand All @@ -21,3 +23,9 @@ IBC Client Update
IBC Transfers (ICS-20)

* [ibc-go](https://github.com/cosmos/ibc-go/blob/main/e2e/tests/transfer/base_test.go)

IBC Fee Middleware (ICS-29)

* [go relayer](https://github.com/cosmos/relayer/blob/v2.5.2/interchaintest/fee_middleware_test.go)


2 changes: 1 addition & 1 deletion examples/ibc/wasm/wasm_icq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
// the ICQ module is required to be present in order to receive interchain queries.
func TestInterchainQueriesWASM(t *testing.T) {
//TODO (1): force relayer to use specific versions of the chains configured in the file.
//os.Setenv("IBCTEST_CONFIGURED_CHAINS", "./icq_wasm_configured_chains.yaml")
//os.Setenv("ICTEST_CONFIGURED_CHAINS", "./icq_wasm_configured_chains.yaml")

//TODO (2): use Juno as sender "ghcr.io/strangelove-ventures/heighliner/juno:v10.1.0"
//and Strangelove's icqd (or another chain with ICQ module present) as receiver.
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ require (
github.com/StirlingMarketingGroup/go-namecase v1.0.0
github.com/atotto/clipboard v0.1.4
github.com/avast/retry-go/v4 v4.5.1
github.com/cometbft/cometbft v0.38.6
github.com/cometbft/cometbft v0.38.7
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.2.0
github.com/cosmos/ibc-go/v8 v8.2.1
github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.1
github.com/docker/docker v24.0.9+incompatible
github.com/docker/go-connections v0.5.0
github.com/ethereum/go-ethereum v1.13.15
github.com/ethereum/go-ethereum v1.14.0
github.com/gdamore/tcell/v2 v2.7.4
github.com/google/go-cmp v0.6.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand All @@ -42,7 +42,7 @@ require (
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2
github.com/mr-tron/base58 v1.2.0
github.com/pelletier/go-toml v1.9.5
github.com/pelletier/go-toml/v2 v2.2.0
github.com/pelletier/go-toml/v2 v2.2.2
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
Expand All @@ -56,7 +56,7 @@ require (
golang.org/x/tools v0.20.0
google.golang.org/grpc v1.63.2
gopkg.in/yaml.v3 v3.0.1
modernc.org/sqlite v1.29.5
modernc.org/sqlite v1.29.9
)

require (
Expand Down Expand Up @@ -154,7 +154,7 @@ require (
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.3 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.3 // indirect
Expand All @@ -175,7 +175,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
Expand Down Expand Up @@ -263,9 +263,9 @@ require (
gotest.tools/v3 v3.5.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.41.0 // indirect
modernc.org/libc v1.49.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
nhooyr.io/websocket v1.8.7 // indirect
Expand Down
Loading

0 comments on commit 7666463

Please sign in to comment.