diff --git a/.codespellrc b/.codespellrc index e393c29a7..f2350b52f 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,4 @@ [codespell] -skip = *.pulsar.go,*.pb.go,*.pb.gw.go,*.json,*.git,*.bin,*.sum,*.mod,query_test.go +skip = *.pulsar.go,*.pb.go,*.pb.gw.go,*.json,*.git,*.bin,*.sum,*.mod,query_test.go,*.sol ignore-words-list = usera,pres,crate -count = quiet-level = 3 \ No newline at end of file diff --git a/.github/workflows/chores.yml b/.github/workflows/chores.yml deleted file mode 100644 index 83c577016..000000000 --- a/.github/workflows/chores.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: chores - -on: - pull_request: - -jobs: - link-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 - - typos: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run codespell - continue-on-error: true - run: | - # .codespellrc is used - sudo apt-get install codespell -y - codespell -w --config .codespellrc - exit $? - - pr-title-format: - name: Lint PR Title - permissions: - pull-requests: read - statuses: write - contents: read - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..bd9acccf4 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,61 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '59 23 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages. + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ✏️ If the Autobuild fails above, remove it and uncomment the following lines + # and modify them (or add more) to build your code. + + #- run: | + # make install + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2a4ca6a4b..8f35b408e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,41 +1,54 @@ -name: golangci-lint +# Lint the entire golang project. This workflow relies on the +# '.golangci.yml' file for its configuration settings. +name: Lint on: + push: + tags: + - v* + branches: + - master + - main pull_request: +permissions: + contents: read + +env: + GO_VERSION: 1.22 + jobs: + clippy-lint: + defaults: + run: + working-directory: local-interchain/rust/localic-std + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install stable with clippy and rustfmt + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt, clippy + - name: Install clippy + run: rustup component add clippy + - name: Update + run: cargo update + - name: Run clippy + run: make lint + golangci: - name: lint + name: golangci-lint runs-on: ubuntu-latest steps: - uses: actions/setup-go@v5 with: - go-version: '1.21' - cache: false + go-version: ${{ env.GO_VERSION }} + - uses: actions/checkout@v4 + - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.54 - only-new-issues: true - args: --timeout=10m - - clippy-lint: - defaults: - run: - working-directory: local-interchain/rust/localic-std - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install stable with clippy and rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt, clippy - - name: Install clippy - run: rustup component add clippy - - name: Update - run: cargo update - - name: Run clippy - run: make lint - + version: v1.57.2 + args: --timeout 15m \ No newline at end of file diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml new file mode 100644 index 000000000..3daf692b8 --- /dev/null +++ b/.github/workflows/markdown-link-check.yml @@ -0,0 +1,11 @@ +name: Markdown Link Check + +on: + pull_request: + +jobs: + link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70a261d78..40440e00e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: types: [created] env: - GO_VERSION: 1.21 + GO_VERSION: 1.21 jobs: release-static-binary: @@ -18,7 +18,7 @@ jobs: - name: Setup go ${{ env.GO_VERSION }} uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version: ${{ env.GO_VERSION }} # NOTE: make install must not be statically linked to the MakeFileInstallDirectory - run: cd local-interchain && go mod tidy && IGNORE_STATIC_LINK=true make install diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 000000000..96ef19cc4 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,24 @@ +name: Spell Check + +on: + pull_request: + +jobs: + spellcheck: + name: Run codespell + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install codespell + run: pip install codespell + + - name: Run codespell + run: codespell \ No newline at end of file diff --git a/.github/workflows/title-format.yml b/.github/workflows/title-format.yml new file mode 100644 index 000000000..b5e7d1a95 --- /dev/null +++ b/.github/workflows/title-format.yml @@ -0,0 +1,20 @@ +name: "Lint PR Title" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..2b13f2610 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,69 @@ +run: + timeout: 10m + tests: true + +# These linter checks can be modified on a per project basis. +# Simply remove them from the enable list to disable them. +linters: + disable-all: true + enable: + - asciicheck + - bidichk + - bodyclose + - decorder + - dupl + - dupword + - errcheck + - errchkjson + - errname + - exhaustive + - exportloopref + - forbidigo + - gci + - goconst + - gocritic + - godot + - gofumpt + - gosec + - gosimple + - gosmopolitan + - govet + - grouper + - ineffassign + - loggercheck + - misspell + - nilerr + - nilnil + - noctx + - staticcheck + - stylecheck + - testifylint + - thelper + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - wastedassign + - whitespace + +linters-settings: + gci: + custom-order: true + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - blank # blank imports + - dot # dot imports + - prefix(cosmossdk.io) + - prefix(github.com/cosmos) + - prefix(github.com/cosmos/cosmos-sdk) + - prefix(github.com/cometbft/cometbft) + - prefix(github.com/strangelove-ventures/interchaintest) + gosec: + excludes: + - G404 # disables checks on insecure random number source + +issues: + max-issues-per-linter: 0 \ No newline at end of file diff --git a/blockdb/collect_test.go b/blockdb/collect_test.go index 2a6159aae..f5106c8dd 100644 --- a/blockdb/collect_test.go +++ b/blockdb/collect_test.go @@ -59,7 +59,7 @@ func TestCollector_Collect(t *testing.T) { savedHeights = append(savedHeights, int(height)) savedTxs = append(savedTxs, txs) } - atomic.SwapInt64(¤tHeight, int64(height)) + atomic.SwapInt64(¤tHeight, height) return nil }) diff --git a/blockdb/messages_view_test.go b/blockdb/messages_view_test.go index 442c563a7..2b23a0a8d 100644 --- a/blockdb/messages_view_test.go +++ b/blockdb/messages_view_test.go @@ -9,8 +9,6 @@ import ( "path/filepath" "testing" - "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/relayer" @@ -18,6 +16,10 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" + + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/types" ) func TestMessagesView(t *testing.T) { diff --git a/blockdb/query_test.go b/blockdb/query_test.go index d4c5d705c..5268ee7c5 100644 --- a/blockdb/query_test.go +++ b/blockdb/query_test.go @@ -2,20 +2,19 @@ package blockdb import ( "context" - _ "embed" "encoding/json" "strings" "testing" "time" "github.com/stretchr/testify/require" -) -var ( - //go:embed testdata/sample_txs.json - txsFixture []byte + _ "embed" ) +//go:embed testdata/sample_txs.json +var txsFixture []byte + func TestQuery_CurrentSchemaVersion(t *testing.T) { t.Parallel() diff --git a/blockdb/sql.go b/blockdb/sql.go index 75f4288c4..459ce9ada 100644 --- a/blockdb/sql.go +++ b/blockdb/sql.go @@ -17,7 +17,7 @@ import ( // Pass :memory: as databasePath for in-memory database. func ConnectDB(ctx context.Context, databasePath string) (*sql.DB, error) { if databasePath != ":memory:" { - if err := os.MkdirAll(filepath.Dir(databasePath), 0755); err != nil { + if err := os.MkdirAll(filepath.Dir(databasePath), 0o755); err != nil { return nil, err } } diff --git a/blockdb/tui/presenter/cosmos_message.go b/blockdb/tui/presenter/cosmos_message.go index 1f29a9a21..4da9cfb32 100644 --- a/blockdb/tui/presenter/cosmos_message.go +++ b/blockdb/tui/presenter/cosmos_message.go @@ -17,7 +17,7 @@ func (msg CosmosMessage) Height() string { return strconv.FormatInt(msg.Result.H // Index is the message's ordered position within the tx. func (msg CosmosMessage) Index() string { return strconv.Itoa(msg.Result.Index) } -// Type is a URI for the proto definition, e.g. /ibc.core.client.v1.MsgCreateClient +// Type is a URI for the proto definition, e.g. /ibc.core.client.v1.MsgCreateClient. func (msg CosmosMessage) Type() string { return msg.Result.Type } func (msg CosmosMessage) ClientChain() string { return msg.Result.ClientChainID.String } diff --git a/blockdb/tui/style.go b/blockdb/tui/style.go index 9a8a4eee1..9fd3f0c0a 100644 --- a/blockdb/tui/style.go +++ b/blockdb/tui/style.go @@ -8,6 +8,4 @@ const ( errorTextColor = tcell.ColorRed ) -var ( - textStyle = tcell.Style{}.Foreground(textColor) -) +var textStyle = tcell.Style{}.Foreground(textColor) diff --git a/chain/cosmos/08-wasm-types/client_state.go b/chain/cosmos/08-wasm-types/client_state.go index f607d6f80..bc5e91291 100644 --- a/chain/cosmos/08-wasm-types/client_state.go +++ b/chain/cosmos/08-wasm-types/client_state.go @@ -2,10 +2,12 @@ package types import ( storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck "github.com/cosmos/ibc-go/v8/modules/core/exported" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" ) var _ exported.ClientState = (*ClientState)(nil) @@ -86,9 +88,8 @@ func (c ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec return true } -// UpdateStateOnMisbehaviour should perform appropriate state changes on a client state given that misbehaviour has been detected and verified +// UpdateStateOnMisbehaviour should perform appropriate state changes on a client state given that misbehaviour has been detected and verified. func (c ClientState) UpdateStateOnMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) { - } func (c ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height { diff --git a/chain/cosmos/08-wasm-types/codec.go b/chain/cosmos/08-wasm-types/codec.go index 324016496..be73b5693 100644 --- a/chain/cosmos/08-wasm-types/codec.go +++ b/chain/cosmos/08-wasm-types/codec.go @@ -1,11 +1,11 @@ package types import ( + "github.com/cosmos/ibc-go/v8/modules/core/exported" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - - "github.com/cosmos/ibc-go/v8/modules/core/exported" ) // RegisterInterfaces registers the tendermint concrete client-related diff --git a/chain/cosmos/08-wasm-types/module.go b/chain/cosmos/08-wasm-types/module.go index 013890c0e..11b8aa32e 100644 --- a/chain/cosmos/08-wasm-types/module.go +++ b/chain/cosmos/08-wasm-types/module.go @@ -3,14 +3,14 @@ package types import ( "encoding/json" + // grpc "github.com/cosmos/gogoproto/grpc". + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" - - //grpc "github.com/cosmos/gogoproto/grpc" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" ) var _ module.AppModuleBasic = AppModuleBasic{} diff --git a/chain/cosmos/08-wasm-types/msgs.go b/chain/cosmos/08-wasm-types/msgs.go index efe7da1b3..bbe13ef1c 100644 --- a/chain/cosmos/08-wasm-types/msgs.go +++ b/chain/cosmos/08-wasm-types/msgs.go @@ -16,12 +16,12 @@ func NewMsgStoreCode(signer string, code []byte) *MsgStoreCode { } } -// ValidateBasic implements sdk.Msg +// ValidateBasic implements sdk.Msg. func (m MsgStoreCode) ValidateBasic() error { return nil } -// GetSigners implements sdk.Msg +// GetSigners implements sdk.Msg. func (m MsgStoreCode) GetSigners() []sdk.AccAddress { signer, err := sdk.AccAddressFromBech32(m.Signer) if err != nil { diff --git a/chain/cosmos/account_retriever.go b/chain/cosmos/account_retriever.go index 66b9f66cf..a814e5932 100644 --- a/chain/cosmos/account_retriever.go +++ b/chain/cosmos/account_retriever.go @@ -3,7 +3,6 @@ package cosmos import ( "context" "fmt" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "strconv" grpc "google.golang.org/grpc" @@ -12,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) var ( diff --git a/chain/cosmos/address.go b/chain/cosmos/address.go index 121c021bb..fdb18359b 100644 --- a/chain/cosmos/address.go +++ b/chain/cosmos/address.go @@ -2,10 +2,10 @@ package cosmos import ( "errors" - "github.com/cosmos/cosmos-sdk/types/bech32" "strings" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/bech32" ) // AccAddressFromBech32 creates an AccAddress from a Bech32 string. diff --git a/chain/cosmos/broadcaster.go b/chain/cosmos/broadcaster.go index c30f19f2e..7dd7a8027 100644 --- a/chain/cosmos/broadcaster.go +++ b/chain/cosmos/broadcaster.go @@ -8,6 +8,9 @@ import ( "testing" "time" + "github.com/strangelove-ventures/interchaintest/v8/dockerutil" + "github.com/strangelove-ventures/interchaintest/v8/testutil" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -15,8 +18,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" - "github.com/strangelove-ventures/interchaintest/v8/testutil" ) type ClientContextOpt func(clientContext client.Context) client.Context @@ -216,13 +217,11 @@ func BroadcastTx(ctx context.Context, broadcaster *Broadcaster, broadcastingUser err = testutil.WaitForCondition(time.Second*30, time.Second*5, func() (bool, error) { var err error txBytes, err = broadcaster.GetTxResponseBytes(ctx, broadcastingUser) - if err != nil { return false, nil } return true, nil }) - if err != nil { return sdk.TxResponse{}, err } diff --git a/chain/cosmos/chain_node.go b/chain/cosmos/chain_node.go index 912c2a7fe..4db0c25a5 100644 --- a/chain/cosmos/chain_node.go +++ b/chain/cosmos/chain_node.go @@ -18,23 +18,13 @@ import ( "time" "github.com/avast/retry-go/v4" - tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/p2p" - rpcclient "github.com/cometbft/cometbft/rpc/client" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - coretypes "github.com/cometbft/cometbft/rpc/core/types" - libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" volumetypes "github.com/docker/docker/api/types/volume" dockerclient "github.com/docker/docker/client" "github.com/docker/go-connections/nat" + "github.com/strangelove-ventures/interchaintest/v8/blockdb" + "github.com/strangelove-ventures/interchaintest/v8/dockerutil" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" "golang.org/x/mod/semver" "golang.org/x/sync/errgroup" @@ -43,13 +33,25 @@ import ( icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" - "github.com/strangelove-ventures/interchaintest/v8/blockdb" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" - "github.com/strangelove-ventures/interchaintest/v8/ibc" - "github.com/strangelove-ventures/interchaintest/v8/testutil" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + tmjson "github.com/cometbft/cometbft/libs/json" + "github.com/cometbft/cometbft/p2p" + rpcclient "github.com/cometbft/cometbft/rpc/client" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" + coretypes "github.com/cometbft/cometbft/rpc/core/types" + libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" ) -// ChainNode represents a node in the test network that is being created +// ChainNode represents a node in the test network that is being created. type ChainNode struct { VolumeName string Index int @@ -101,13 +103,13 @@ func NewChainNode(log *zap.Logger, validator bool, chain *CosmosChain, dockerCli return tn } -// WithPreStartNode sets the preStartNode function for the ChainNode +// 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 +// ChainNodes is a collection of ChainNode. type ChainNodes []*ChainNode const ( @@ -122,17 +124,15 @@ const ( cometMockRawPort = "22331" ) -var ( - sentryPorts = nat.PortMap{ - nat.Port(p2pPort): {}, - nat.Port(rpcPort): {}, - nat.Port(grpcPort): {}, - nat.Port(apiPort): {}, - nat.Port(privValPort): {}, - } -) +var sentryPorts = nat.PortMap{ + nat.Port(p2pPort): {}, + nat.Port(rpcPort): {}, + nat.Port(grpcPort): {}, + nat.Port(apiPort): {}, + nat.Port(privValPort): {}, +} -// NewClient creates and assigns a new Tendermint RPC client to the ChainNode +// NewClient creates and assigns a new Tendermint RPC client to the ChainNode. func (tn *ChainNode) NewClient(addr string) error { httpClient, err := libclient.DefaultHTTPClient(addr) if err != nil { @@ -201,7 +201,7 @@ func (tn *ChainNode) NewSidecarProcess( return nil } -// CliContext creates a new Cosmos SDK client context +// CliContext creates a new Cosmos SDK client context. func (tn *ChainNode) CliContext() client.Context { cfg := tn.Chain.Config() return client.Context{ @@ -217,7 +217,7 @@ func (tn *ChainNode) CliContext() client.Context { } } -// Name of the test node container +// Name of the test node container. func (tn *ChainNode) Name() string { return fmt.Sprintf("%s-%s-%d-%s", tn.Chain.Config().ChainID, tn.NodeType(), tn.Index, dockerutil.SanitizeContainerName(tn.TestName)) } @@ -234,12 +234,12 @@ func (tn *ChainNode) ContainerID() string { return tn.containerLifecycle.ContainerID() } -// hostname of the test node container +// hostname of the test node container. func (tn *ChainNode) HostName() string { return dockerutil.CondenseHostName(tn.Name()) } -// hostname of the comet mock container +// hostname of the comet mock container. func (tn *ChainNode) HostnameCometMock() string { return tn.cometHostname } @@ -312,7 +312,7 @@ type PrivValidatorKeyFile struct { PrivKey PrivValidatorKey `json:"priv_key"` } -// Bind returns the home folder bind point for running the node +// Bind returns the home folder bind point for running the node. func (tn *ChainNode) Bind() []string { return []string{fmt.Sprintf("%s:%s", tn.VolumeName, tn.HomeDir())} } @@ -398,7 +398,7 @@ func (tn *ChainNode) SetTestConfig(ctx context.Context) error { ) } -// SetPeers modifies the config persistent_peers for a node +// SetPeers modifies the config persistent_peers for a node. func (tn *ChainNode) SetPeers(ctx context.Context, peers string) error { c := make(testutil.Toml) p2p := make(testutil.Toml) @@ -507,7 +507,7 @@ func (tn *ChainNode) FindTxs(ctx context.Context, height int64) ([]blockdb.Tx, e // with the chain node binary. func (tn *ChainNode) TxCommand(keyName string, command ...string) []string { command = append([]string{"tx"}, command...) - var gasPriceFound, gasAdjustmentFound, gasFound, feesFound = false, false, false, false + gasPriceFound, gasAdjustmentFound, gasFound, feesFound := false, false, false, false for i := 0; i < len(command); i++ { if command[i] == "--gas-prices" { gasPriceFound = true @@ -673,7 +673,7 @@ func CondenseMoniker(m string) string { return m[:keepLen] + "..." + m[len(m)-keepLen:] + suffix } -// InitHomeFolder initializes a home folder for the given node +// InitHomeFolder initializes a home folder for the given node. func (tn *ChainNode) InitHomeFolder(ctx context.Context) error { tn.lock.Lock() defer tn.lock.Unlock() @@ -687,7 +687,7 @@ func (tn *ChainNode) InitHomeFolder(ctx context.Context) error { // WriteFile accepts file contents in a byte slice and writes the contents to // the docker filesystem. relPath describes the location of the file in the -// docker volume relative to the home directory +// docker volume relative to the home directory. func (tn *ChainNode) WriteFile(ctx context.Context, content []byte, relPath string) error { fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName) return fw.WriteFile(ctx, tn.VolumeName, relPath, content) @@ -695,7 +695,7 @@ func (tn *ChainNode) WriteFile(ctx context.Context, content []byte, relPath stri // CopyFile adds a file from the host filesystem to the docker filesystem // relPath describes the location of the file in the docker volume relative to -// the home directory +// the home directory. func (tn *ChainNode) CopyFile(ctx context.Context, srcPath, dstPath string) error { content, err := os.ReadFile(srcPath) if err != nil { @@ -715,7 +715,7 @@ func (tn *ChainNode) ReadFile(ctx context.Context, relPath string) ([]byte, erro return gen, nil } -// CreateKey creates a key in the keyring backend test for the given node +// CreateKey creates a key in the keyring backend test for the given node. func (tn *ChainNode) CreateKey(ctx context.Context, name string) error { tn.lock.Lock() defer tn.lock.Unlock() @@ -768,7 +768,7 @@ func (tn *ChainNode) ICSVersion(ctx context.Context) string { return "" } -// AddGenesisAccount adds a genesis account for each key +// AddGenesisAccount adds a genesis account for each key. func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, genesisAmount []sdk.Coin) error { amount := "" for i, coin := range genesisAmount { @@ -802,7 +802,7 @@ func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, gene return err } -// Gentx generates the gentx for a given node +// Gentx generates the gentx for a given node. func (tn *ChainNode) Gentx(ctx context.Context, name string, genesisSelfDelegation sdk.Coin) error { tn.lock.Lock() defer tn.lock.Unlock() @@ -823,7 +823,7 @@ func (tn *ChainNode) Gentx(ctx context.Context, name string, genesisSelfDelegati return err } -// CollectGentxs runs collect gentxs on the node's home folders +// CollectGentxs runs collect gentxs on the node's home folders. func (tn *ChainNode) CollectGentxs(ctx context.Context) error { command := []string{tn.Chain.Config().Bin} if tn.IsAboveSDK47(ctx) { @@ -986,7 +986,6 @@ func (tn *ChainNode) GetBuildInformation(ctx context.Context) *BinaryBuildInform Replacement: r, ReplacementVersion: rV, } - } else { // Ex: "github.com/aaa/bbb@v0.0.0-20191008050251-8e49817e8af4" parent, version := getRepoAndVersion(dep) @@ -1015,7 +1014,7 @@ func (tn *ChainNode) GetBuildInformation(ctx context.Context) *BinaryBuildInform } } -// QueryClientContractCode performs a query with the contract codeHash as the input and code as the output +// QueryClientContractCode performs a query with the contract codeHash as the input and code as the output. func (tn *ChainNode) QueryClientContractCode(ctx context.Context, codeHash string, response any) error { stdout, _, err := tn.ExecQuery(ctx, "ibc-wasm", "code", codeHash) if err != nil { @@ -1288,7 +1287,7 @@ func (tn *ChainNode) RemoveContainer(ctx context.Context) error { return tn.containerLifecycle.RemoveContainer(ctx) } -// InitValidatorFiles creates the node files and signs a genesis transaction +// InitValidatorFiles creates the node files and signs a genesis transaction. func (tn *ChainNode) InitValidatorGenTx( ctx context.Context, chainType *ibc.ChainConfig, @@ -1337,7 +1336,8 @@ func (tn *ChainNode) NodeID(ctx context.Context) (string, error) { // KeyBech32 retrieves the named key's address in bech32 format from the node. // bech is the bech32 prefix (acc|val|cons). If empty, defaults to the account key (same as "acc"). func (tn *ChainNode) KeyBech32(ctx context.Context, name string, bech string) (string, error) { - command := []string{tn.Chain.Config().Bin, "keys", "show", "--address", name, + command := []string{ + tn.Chain.Config().Bin, "keys", "show", "--address", name, "--home", tn.HomeDir(), "--keyring-backend", keyring.BackendTest, } @@ -1359,7 +1359,7 @@ func (tn *ChainNode) AccountKeyBech32(ctx context.Context, name string) (string, return tn.KeyBech32(ctx, name, "") } -// PeerString returns the string for connecting the nodes passed in +// PeerString returns the string for connecting the nodes passed in. func (nodes ChainNodes) PeerString(ctx context.Context) string { addrs := make([]string, len(nodes)) for i, n := range nodes { @@ -1381,7 +1381,7 @@ func (nodes ChainNodes) PeerString(ctx context.Context) string { return strings.Join(addrs, ",") } -// LogGenesisHashes logs the genesis hashes for the various nodes +// LogGenesisHashes logs the genesis hashes for the various nodes. func (nodes ChainNodes) LogGenesisHashes(ctx context.Context) error { for _, n := range nodes { gen, err := n.GenesisFileContent(ctx) @@ -1487,7 +1487,7 @@ func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, from } // GetHostAddress returns the host-accessible url for a port in the container. -// This is useful for finding the url & random host port for ports exposed via ChainConfig.ExposeAdditionalPorts +// This is useful for finding the url & random host port for ports exposed via ChainConfig.ExposeAdditionalPorts. func (tn *ChainNode) GetHostAddress(ctx context.Context, portID string) (string, error) { ports, err := tn.containerLifecycle.GetHostPorts(ctx, portID) if err != nil { diff --git a/chain/cosmos/codec.go b/chain/cosmos/codec.go index b297d2729..d7065270d 100644 --- a/chain/cosmos/codec.go +++ b/chain/cosmos/codec.go @@ -1,7 +1,16 @@ package cosmos import ( + ibcwasm "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos/08-wasm-types" + "cosmossdk.io/x/upgrade" + + "github.com/cosmos/ibc-go/modules/capability" + transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibccore "github.com/cosmos/ibc-go/v8/modules/core" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ccvprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,13 +29,6 @@ import ( paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/cosmos/ibc-go/modules/capability" - - transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer" - ibccore "github.com/cosmos/ibc-go/v8/modules/core" - ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - ccvprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider" - ibcwasm "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos/08-wasm-types" ) func DefaultEncoding() testutil.TestEncodingConfig { diff --git a/chain/cosmos/cosmos_chain.go b/chain/cosmos/cosmos_chain.go index c493806ce..0d88ea1b2 100644 --- a/chain/cosmos/cosmos_chain.go +++ b/chain/cosmos/cosmos_chain.go @@ -13,20 +13,6 @@ import ( "strings" "sync" - sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck - chanTypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" dockertypes "github.com/docker/docker/api/types" volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" @@ -38,6 +24,23 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" "golang.org/x/sync/errgroup" + + sdkmath "cosmossdk.io/math" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck + chanTypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" ) // CosmosChain is a local docker testnet for a Cosmos SDK chain. @@ -72,7 +75,8 @@ func NewCosmosHeighlinerChainConfig(name string, gasPrices string, gasAdjustment float64, trustingPeriod string, - noHostMount bool) ibc.ChainConfig { + noHostMount bool, +) ibc.ChainConfig { return ibc.ChainConfig{ Type: "cosmos", Name: name, @@ -172,7 +176,7 @@ func (c *CosmosChain) AddFullNodes(ctx context.Context, configFileOverrides map[ for configFile, modifiedConfig := range configFileOverrides { modifiedToml, ok := modifiedConfig.(testutil.Toml) if !ok { - return fmt.Errorf("Provided toml override for file %s is of type (%T). Expected (DecodedToml)", configFile, modifiedConfig) + return fmt.Errorf("provided toml override for file %s is of type (%T). Expected (DecodedToml)", configFile, modifiedConfig) } if err := testutil.ModifyTomlConfigFile( ctx, @@ -195,12 +199,12 @@ func (c *CosmosChain) AddFullNodes(ctx context.Context, configFileOverrides map[ return eg.Wait() } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) Config() ibc.ChainConfig { return c.cfg } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error { if err := c.initializeSidecars(ctx, testName, cli, networkID); err != nil { return err @@ -221,7 +225,7 @@ func (c *CosmosChain) Exec(ctx context.Context, cmd []string, env []string) (std return c.getFullNode().Exec(ctx, cmd, env) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) GetRPCAddress() string { if c.Config().UsesCometMock() { return fmt.Sprintf("http://%s:22331", c.getFullNode().HostnameCometMock()) @@ -230,12 +234,12 @@ func (c *CosmosChain) GetRPCAddress() string { return fmt.Sprintf("http://%s:26657", c.getFullNode().HostName()) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) GetAPIAddress() string { return fmt.Sprintf("http://%s:1317", c.getFullNode().HostName()) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) GetGRPCAddress() string { return fmt.Sprintf("%s:9090", c.getFullNode().HostName()) } @@ -269,17 +273,17 @@ func (c *CosmosChain) HomeDir() string { return c.getFullNode().HomeDir() } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) CreateKey(ctx context.Context, keyName string) error { return c.getFullNode().CreateKey(ctx, keyName) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) RecoverKey(ctx context.Context, keyName, mnemonic string) error { return c.getFullNode().RecoverKey(ctx, keyName, mnemonic) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) GetAddress(ctx context.Context, keyName string) ([]byte, error) { b32Addr, err := c.getFullNode().AccountKeyBech32(ctx, keyName) if err != nil { @@ -291,7 +295,7 @@ func (c *CosmosChain) GetAddress(ctx context.Context, keyName string) ([]byte, e // BuildWallet will return a Cosmos wallet // If mnemonic != "", it will restore using that mnemonic -// If mnemonic == "", it will create a new key +// If mnemonic == "", it will create a new key. func (c *CosmosChain) BuildWallet(ctx context.Context, keyName string, mnemonic string) (ibc.Wallet, error) { if mnemonic != "" { if err := c.RecoverKey(ctx, keyName, mnemonic); err != nil { @@ -339,17 +343,17 @@ func (c *CosmosChain) BuildRelayerWallet(ctx context.Context, keyName string) (i return NewWallet(keyName, addrBytes, mnemonic, c.cfg), nil } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error { return c.getFullNode().BankSend(ctx, keyName, amount) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) SendFundsWithNote(ctx context.Context, keyName string, amount ibc.WalletAmount, note string) (string, error) { return c.getFullNode().BankSendWithNote(ctx, keyName, amount, note) } -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) SendIBCTransfer( ctx context.Context, channelID string, @@ -432,7 +436,7 @@ func (c *CosmosChain) SendICATx(ctx context.Context, keyName, connectionID strin return node.SendICATx(ctx, keyName, connectionID, registry, msgs, icaTxMemo, encoding) } -// PushNewWasmClientProposal submits a new wasm client governance proposal to the chain +// PushNewWasmClientProposal submits a new wasm client governance proposal to the chain. func (c *CosmosChain) PushNewWasmClientProposal(ctx context.Context, keyName string, fileName string, prop TxProposalv1) (TxProposal, string, error) { tx := TxProposal{} content, err := os.ReadFile(fileName) @@ -553,7 +557,7 @@ func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contr return c.getFullNode().ExecuteContract(ctx, keyName, contractAddress, message, extraExecTxArgs...) } -// MigrateContract performs contract migration +// 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...) } @@ -573,13 +577,13 @@ func (c *CosmosChain) StoreClientContract(ctx context.Context, keyName string, f return c.getFullNode().StoreClientContract(ctx, keyName, fileName, extraExecTxArgs...) } -// QueryClientContractCode performs a query with the contract codeHash as the input and code as the output +// QueryClientContractCode performs a query with the contract codeHash as the input and code as the output. func (c *CosmosChain) QueryClientContractCode(ctx context.Context, codeHash string, response any) error { return c.getFullNode().QueryClientContractCode(ctx, codeHash, response) } // ExportState exports the chain state at specific height. -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) ExportState(ctx context.Context, height int64) (string, error) { return c.getFullNode().ExportState(ctx, height) } @@ -737,7 +741,7 @@ func (c *CosmosChain) NewSidecarProcess( return nil } -// creates the test node objects required for bootstrapping tests +// creates the test node objects required for bootstrapping tests. func (c *CosmosChain) initializeChainNodes( ctx context.Context, testName string, @@ -809,7 +813,6 @@ func (c *CosmosChain) initializeSidecars( } return nil }) - } if err := eg.Wait(); err != nil { return err @@ -837,7 +840,7 @@ type ValidatorWithIntPower struct { PubKeyBase64 string } -// Bootstraps the chain and starts it from genesis +// Bootstraps the chain and starts it from genesis. func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { if c.cfg.InterchainSecurityConfig.ConsumerCopyProviderKey != nil && c.Provider == nil { return fmt.Errorf("don't set ConsumerCopyProviderKey if it's not a consumer chain") @@ -875,7 +878,7 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene for configFile, modifiedConfig := range configFileOverrides { modifiedToml, ok := modifiedConfig.(testutil.Toml) if !ok { - return fmt.Errorf("Provided toml override for file %s is of type (%T). Expected (DecodedToml)", configFile, modifiedConfig) + return fmt.Errorf("provided toml override for file %s is of type (%T). Expected (DecodedToml)", configFile, modifiedConfig) } if err := testutil.ModifyTomlConfigFile( ctx, @@ -907,7 +910,7 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene for configFile, modifiedConfig := range configFileOverrides { modifiedToml, ok := modifiedConfig.(testutil.Toml) if !ok { - return fmt.Errorf("Provided toml override for file %s is of type (%T). Expected (DecodedToml)", configFile, modifiedConfig) + return fmt.Errorf("provided toml override for file %s is of type (%T). Expected (DecodedToml)", configFile, modifiedConfig) } if err := testutil.ModifyTomlConfigFile( ctx, @@ -964,7 +967,6 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene } for _, wallet := range additionalGenesisWallets { - if err := validator0.AddGenesisAccount(ctx, wallet.Address, []types.Coin{{Denom: wallet.Denom, Amount: wallet.Amount}}); err != nil { return err } @@ -998,7 +1000,7 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene zap.String("chain", exportGenesisChain), zap.String("path", exportGenesis), ) - _ = os.WriteFile(exportGenesis, genbz, 0600) + _ = os.WriteFile(exportGenesis, genbz, 0o600) } chainNodes := c.Nodes() @@ -1069,12 +1071,12 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene return testutil.WaitForBlocks(ctx, 2, c.getFullNode()) } -// Height implements ibc.Chain +// Height implements ibc.Chain. func (c *CosmosChain) Height(ctx context.Context) (int64, error) { return c.getFullNode().Height(ctx) } -// Acknowledgements implements ibc.Chain, returning all acknowledgments in block at height +// Acknowledgements implements ibc.Chain, returning all acknowledgments in block at height. func (c *CosmosChain) Acknowledgements(ctx context.Context, height int64) ([]ibc.PacketAcknowledgement, error) { var acks []*chanTypes.MsgAcknowledgement err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.getFullNode().Client, height, func(msg types.Msg) bool { @@ -1107,7 +1109,7 @@ func (c *CosmosChain) Acknowledgements(ctx context.Context, height int64) ([]ibc return ibcAcks, nil } -// Timeouts implements ibc.Chain, returning all timeouts in block at height +// Timeouts implements ibc.Chain, returning all timeouts in block at height. func (c *CosmosChain) Timeouts(ctx context.Context, height int64) ([]ibc.PacketTimeout, error) { var timeouts []*chanTypes.MsgTimeout err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.getFullNode().Client, height, func(msg types.Msg) bool { @@ -1147,7 +1149,7 @@ func (c *CosmosChain) FindTxs(ctx context.Context, height int64) ([]blockdb.Tx, return fn.FindTxs(ctx, height) } -// StopAllNodes stops and removes all long running containers (validators and full nodes) +// StopAllNodes stops and removes all long running containers (validators and full nodes). func (c *CosmosChain) StopAllNodes(ctx context.Context) error { var eg errgroup.Group for _, n := range c.Nodes() { @@ -1264,7 +1266,7 @@ func (c *CosmosChain) VoteOnProposalAllValidators(ctx context.Context, proposalI } // GetTimeoutHeight returns a timeout height of 1000 blocks above the current block height. -// This function should be used when the timeout is never expected to be reached +// This function should be used when the timeout is never expected to be reached. func (c *CosmosChain) GetTimeoutHeight(ctx context.Context) (clienttypes.Height, error) { height, err := c.Height(ctx) if err != nil { diff --git a/chain/cosmos/ics.go b/chain/cosmos/ics.go index c6743dbf9..beb0e9ead 100644 --- a/chain/cosmos/ics.go +++ b/chain/cosmos/ics.go @@ -11,11 +11,6 @@ import ( "strings" "time" - sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck - ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" "github.com/icza/dyno" "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" @@ -26,6 +21,13 @@ import ( "golang.org/x/mod/semver" "golang.org/x/sync/errgroup" + sdkmath "cosmossdk.io/math" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck + ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" + + "github.com/cosmos/cosmos-sdk/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingttypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -100,7 +102,7 @@ func (c *CosmosChain) FlushPendingICSPackets(ctx context.Context, r ibc.Relayer, return r.Flush(ctx, eRep, ibcPath, ICSChannel) } -// Bootstraps the provider chain and starts it from genesis +// Bootstraps the provider chain and starts it from genesis. func (c *CosmosChain) StartProvider(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { if c.cfg.InterchainSecurityConfig.ConsumerCopyProviderKey != nil { return fmt.Errorf("don't set ConsumerCopyProviderKey in the provider chain") @@ -205,7 +207,7 @@ func (c *CosmosChain) StartProvider(testName string, ctx context.Context, additi return nil } -// Bootstraps the consumer chain and starts it from genesis +// Bootstraps the consumer chain and starts it from genesis. func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { chainCfg := c.Config() @@ -358,7 +360,7 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi zap.String("chain", exportGenesisChain), zap.String("path", exportGenesis), ) - _ = os.WriteFile(exportGenesis, genbz, 0600) + _ = os.WriteFile(exportGenesis, genbz, 0o600) } chainNodes := c.Nodes() diff --git a/chain/cosmos/module_auth.go b/chain/cosmos/module_auth.go index c847025eb..30b5d5875 100644 --- a/chain/cosmos/module_auth.go +++ b/chain/cosmos/module_auth.go @@ -4,13 +4,12 @@ import ( "context" "fmt" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" ) -// AuthQueryAccount performs a query to get the account details of the specified address +// AuthQueryAccount performs a query to get the account details of the specified address. func (c *CosmosChain) AuthQueryAccount(ctx context.Context, addr string) (*cdctypes.Any, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).Account(ctx, &authtypes.QueryAccountRequest{ Address: addr, @@ -18,13 +17,13 @@ func (c *CosmosChain) AuthQueryAccount(ctx context.Context, addr string) (*cdcty return res.Account, err } -// AuthQueryParams performs a query to get the auth module parameters +// AuthQueryParams performs a query to get the auth module parameters. func (c *CosmosChain) AuthQueryParams(ctx context.Context) (*authtypes.Params, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).Params(ctx, &authtypes.QueryParamsRequest{}) return &res.Params, err } -// AuthQueryModuleAccounts performs a query to get the account details of all the chain modules +// AuthQueryModuleAccounts performs a query to get the account details of all the chain modules. func (c *CosmosChain) AuthQueryModuleAccounts(ctx context.Context) ([]authtypes.ModuleAccount, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).ModuleAccounts(ctx, &authtypes.QueryModuleAccountsRequest{}) @@ -42,7 +41,7 @@ func (c *CosmosChain) AuthQueryModuleAccounts(ctx context.Context) ([]authtypes. return maccs, err } -// AuthGetModuleAccount performs a query to get the account details of the specified chain module +// AuthGetModuleAccount performs a query to get the account details of the specified chain module. func (c *CosmosChain) AuthQueryModuleAccount(ctx context.Context, moduleName string) (authtypes.ModuleAccount, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).ModuleAccountByName(ctx, &authtypes.QueryModuleAccountByNameRequest{ Name: moduleName, @@ -57,7 +56,7 @@ func (c *CosmosChain) AuthQueryModuleAccount(ctx context.Context, moduleName str return modAcc, err } -// GetModuleAddress performs a query to get the address of the specified chain module +// GetModuleAddress performs a query to get the address of the specified chain module. func (c *CosmosChain) AuthQueryModuleAddress(ctx context.Context, moduleName string) (string, error) { queryRes, err := c.AuthQueryModuleAccount(ctx, moduleName) if err != nil { @@ -66,13 +65,13 @@ func (c *CosmosChain) AuthQueryModuleAddress(ctx context.Context, moduleName str return queryRes.BaseAccount.Address, nil } -// Deprecated: use AuthQueryModuleAddress instead +// Deprecated: use AuthQueryModuleAddress instead. func (c *CosmosChain) GetModuleAddress(ctx context.Context, moduleName string) (string, error) { return c.AuthQueryModuleAddress(ctx, moduleName) } // GetGovernanceAddress performs a query to get the address of the chain's x/gov module -// Deprecated: use AuthQueryModuleAddress(ctx, "gov") instead +// Deprecated: use AuthQueryModuleAddress(ctx, "gov") instead. func (c *CosmosChain) GetGovernanceAddress(ctx context.Context) (string, error) { return c.GetModuleAddress(ctx, "gov") } @@ -82,7 +81,7 @@ func (c *CosmosChain) AuthQueryBech32Prefix(ctx context.Context) (string, error) return res.Bech32Prefix, err } -// AddressBytesToString converts a byte array address to a string +// AddressBytesToString converts a byte array address to a string. func (c *CosmosChain) AuthAddressBytesToString(ctx context.Context, addrBz []byte) (string, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).AddressBytesToString(ctx, &authtypes.AddressBytesToStringRequest{ AddressBytes: addrBz, @@ -90,7 +89,7 @@ func (c *CosmosChain) AuthAddressBytesToString(ctx context.Context, addrBz []byt return res.AddressString, err } -// AddressStringToBytes converts a string address to a byte array +// AddressStringToBytes converts a string address to a byte array. func (c *CosmosChain) AuthAddressStringToBytes(ctx context.Context, addr string) ([]byte, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).AddressStringToBytes(ctx, &authtypes.AddressStringToBytesRequest{ AddressString: addr, @@ -98,7 +97,7 @@ func (c *CosmosChain) AuthAddressStringToBytes(ctx context.Context, addr string) return res.AddressBytes, err } -// AccountInfo queries the account information of the given address +// AccountInfo queries the account information of the given address. func (c *CosmosChain) AuthQueryAccountInfo(ctx context.Context, addr string) (*authtypes.BaseAccount, error) { res, err := authtypes.NewQueryClient(c.GetNode().GrpcConn).AccountInfo(ctx, &authtypes.QueryAccountInfoRequest{ Address: addr, diff --git a/chain/cosmos/module_authz.go b/chain/cosmos/module_authz.go index ad5ac5e76..de7e17f43 100644 --- a/chain/cosmos/module_authz.go +++ b/chain/cosmos/module_authz.go @@ -6,14 +6,14 @@ import ( "path" "strings" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" - "github.com/strangelove-ventures/interchaintest/v8/ibc" ) // AuthzGrant grants a message as a permission to an account. func (tn *ChainNode) AuthzGrant(ctx context.Context, granter ibc.Wallet, grantee, authType string, extraFlags ...string) (*sdk.TxResponse, error) { - allowed := "send|generic|delegate|unbond|redelegate" if !strings.Contains(allowed, authType) { return nil, fmt.Errorf("invalid auth type: %s allowed: %s", authType, allowed) diff --git a/chain/cosmos/module_bank.go b/chain/cosmos/module_bank.go index 5f54071ce..eb2d3fba9 100644 --- a/chain/cosmos/module_bank.go +++ b/chain/cosmos/module_bank.go @@ -4,12 +4,12 @@ import ( "context" "fmt" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/strangelove-ventures/interchaintest/v8/ibc" ) // BankSend sends tokens from one account to another. @@ -27,7 +27,7 @@ func (tn *ChainNode) BankSendWithNote(ctx context.Context, keyName string, amoun fmt.Sprintf("%s%s", amount.Amount.String(), amount.Denom), "--note", note) } -// Deprecated: use BankSend instead +// Deprecated: use BankSend instead. func (tn *ChainNode) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error { return tn.BankSend(ctx, keyName, amount) } @@ -42,24 +42,24 @@ func (tn *ChainNode) BankMultiSend(ctx context.Context, keyName string, addresse } // GetBalance fetches the current balance for a specific account address and denom. -// Implements Chain interface +// Implements Chain interface. func (c *CosmosChain) GetBalance(ctx context.Context, address string, denom string) (sdkmath.Int, error) { return c.BankQueryBalance(ctx, address, denom) } -// BankGetBalance is an alias for GetBalance +// BankGetBalance is an alias for GetBalance. func (c *CosmosChain) BankQueryBalance(ctx context.Context, address string, denom string) (sdkmath.Int, error) { res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).Balance(ctx, &banktypes.QueryBalanceRequest{Address: address, Denom: denom}) return res.Balance.Amount, err } -// AllBalances fetches an account address's balance for all denoms it holds +// AllBalances fetches an account address's balance for all denoms it holds. func (c *CosmosChain) BankQueryAllBalances(ctx context.Context, address string) (types.Coins, error) { res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).AllBalances(ctx, &banktypes.QueryAllBalancesRequest{Address: address}) return res.GetBalances(), err } -// BankDenomMetadata fetches the metadata of a specific coin denomination +// BankDenomMetadata fetches the metadata of a specific coin denomination. func (c *CosmosChain) BankQueryDenomMetadata(ctx context.Context, denom string) (*banktypes.Metadata, error) { res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).DenomMetadata(ctx, &banktypes.QueryDenomMetadataRequest{Denom: denom}) return &res.Metadata, err diff --git a/chain/cosmos/module_cosmwasm.go b/chain/cosmos/module_cosmwasm.go index 4940471ec..43ae64a0c 100644 --- a/chain/cosmos/module_cosmwasm.go +++ b/chain/cosmos/module_cosmwasm.go @@ -10,9 +10,10 @@ import ( "path" "path/filepath" + "github.com/strangelove-ventures/interchaintest/v8/testutil" + "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/strangelove-ventures/interchaintest/v8/testutil" ) type InstantiateContractAttribute struct { @@ -161,7 +162,7 @@ func (tn *ChainNode) QueryContract(ctx context.Context, contractAddress string, return err } -// MigrateContract performs contract migration +// 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...) diff --git a/chain/cosmos/module_distribution.go b/chain/cosmos/module_distribution.go index 29acc0de2..b2ef55099 100644 --- a/chain/cosmos/module_distribution.go +++ b/chain/cosmos/module_distribution.go @@ -53,7 +53,7 @@ func (tn *ChainNode) DistributionWithdrawValidatorRewards(ctx context.Context, k return err } -// DistributionCommission returns the validator's commission +// DistributionCommission returns the validator's commission. func (c *CosmosChain) DistributionQueryCommission(ctx context.Context, valAddr string) (*distrtypes.ValidatorAccumulatedCommission, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). ValidatorCommission(ctx, &distrtypes.QueryValidatorCommissionRequest{ @@ -62,42 +62,42 @@ func (c *CosmosChain) DistributionQueryCommission(ctx context.Context, valAddr s return &res.Commission, err } -// DistributionCommunityPool returns the community pool +// DistributionCommunityPool returns the community pool. func (c *CosmosChain) DistributionQueryCommunityPool(ctx context.Context) (*sdk.DecCoins, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). CommunityPool(ctx, &distrtypes.QueryCommunityPoolRequest{}) return &res.Pool, err } -// DistributionDelegationTotalRewards returns the delegator's total rewards +// DistributionDelegationTotalRewards returns the delegator's total rewards. func (c *CosmosChain) DistributionQueryDelegationTotalRewards(ctx context.Context, delegatorAddr string) (*distrtypes.QueryDelegationTotalRewardsResponse, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). DelegationTotalRewards(ctx, &distrtypes.QueryDelegationTotalRewardsRequest{DelegatorAddress: delegatorAddr}) return res, err } -// DistributionDelegatorValidators returns the delegator's validators +// DistributionDelegatorValidators returns the delegator's validators. func (c *CosmosChain) DistributionQueryDelegatorValidators(ctx context.Context, delegatorAddr string) (*distrtypes.QueryDelegatorValidatorsResponse, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). DelegatorValidators(ctx, &distrtypes.QueryDelegatorValidatorsRequest{DelegatorAddress: delegatorAddr}) return res, err } -// DistributionDelegatorWithdrawAddress returns the delegator's withdraw address +// DistributionDelegatorWithdrawAddress returns the delegator's withdraw address. func (c *CosmosChain) DistributionQueryDelegatorWithdrawAddress(ctx context.Context, delegatorAddr string) (string, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). DelegatorWithdrawAddress(ctx, &distrtypes.QueryDelegatorWithdrawAddressRequest{DelegatorAddress: delegatorAddr}) return res.WithdrawAddress, err } -// DistributionParams returns the distribution params +// DistributionParams returns the distribution params. func (c *CosmosChain) DistributionQueryParams(ctx context.Context) (*distrtypes.Params, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). Params(ctx, &distrtypes.QueryParamsRequest{}) return &res.Params, err } -// DistributionRewards returns the delegator's rewards +// DistributionRewards returns the delegator's rewards. func (c *CosmosChain) DistributionQueryRewards(ctx context.Context, delegatorAddr, valAddr string) (sdk.DecCoins, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). DelegationRewards(ctx, &distrtypes.QueryDelegationRewardsRequest{ @@ -107,21 +107,21 @@ func (c *CosmosChain) DistributionQueryRewards(ctx context.Context, delegatorAdd return res.Rewards, err } -// DistributionValidatorSlashes returns the validator's slashes +// DistributionValidatorSlashes returns the validator's slashes. func (c *CosmosChain) DistributionQueryValidatorSlashes(ctx context.Context, valAddr string) ([]distrtypes.ValidatorSlashEvent, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). ValidatorSlashes(ctx, &distrtypes.QueryValidatorSlashesRequest{ValidatorAddress: valAddr}) return res.Slashes, err } -// DistributionValidatorDistributionInfo returns the validator's distribution info +// DistributionValidatorDistributionInfo returns the validator's distribution info. func (c *CosmosChain) DistributionQueryValidatorDistributionInfo(ctx context.Context, valAddr string) (*distrtypes.QueryValidatorDistributionInfoResponse, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). ValidatorDistributionInfo(ctx, &distrtypes.QueryValidatorDistributionInfoRequest{ValidatorAddress: valAddr}) return res, err } -// DistributionValidatorOutstandingRewards returns the validator's outstanding rewards +// DistributionValidatorOutstandingRewards returns the validator's outstanding rewards. func (c *CosmosChain) DistributionQueryValidatorOutstandingRewards(ctx context.Context, valAddr string) (*distrtypes.ValidatorOutstandingRewards, error) { res, err := distrtypes.NewQueryClient(c.GetNode().GrpcConn). ValidatorOutstandingRewards(ctx, &distrtypes.QueryValidatorOutstandingRewardsRequest{ValidatorAddress: valAddr}) diff --git a/chain/cosmos/module_gov.go b/chain/cosmos/module_gov.go index d9fac35c1..7c38d6e89 100644 --- a/chain/cosmos/module_gov.go +++ b/chain/cosmos/module_gov.go @@ -9,12 +9,13 @@ import ( "path/filepath" "strconv" + "github.com/strangelove-ventures/interchaintest/v8/dockerutil" + upgradetypes "cosmossdk.io/x/upgrade/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" - - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" ) // VoteOnProposal submits a vote for the specified proposal. diff --git a/chain/cosmos/module_slashing.go b/chain/cosmos/module_slashing.go index 3f5c98439..a4cb16179 100644 --- a/chain/cosmos/module_slashing.go +++ b/chain/cosmos/module_slashing.go @@ -14,7 +14,7 @@ func (tn *ChainNode) SlashingUnJail(ctx context.Context, keyName string) error { return err } -// SlashingGetParams returns slashing params +// SlashingGetParams returns slashing params. func (c *CosmosChain) SlashingQueryParams(ctx context.Context) (*slashingtypes.Params, error) { res, err := slashingtypes.NewQueryClient(c.GetNode().GrpcConn). Params(ctx, &slashingtypes.QueryParamsRequest{}) @@ -24,7 +24,7 @@ func (c *CosmosChain) SlashingQueryParams(ctx context.Context) (*slashingtypes.P return &res.Params, nil } -// SlashingSigningInfo returns signing info for a validator +// SlashingSigningInfo returns signing info for a validator. func (c *CosmosChain) SlashingQuerySigningInfo(ctx context.Context, consAddress string) (*slashingtypes.ValidatorSigningInfo, error) { res, err := slashingtypes.NewQueryClient(c.GetNode().GrpcConn). SigningInfo(ctx, &slashingtypes.QuerySigningInfoRequest{ConsAddress: consAddress}) @@ -34,7 +34,7 @@ func (c *CosmosChain) SlashingQuerySigningInfo(ctx context.Context, consAddress return &res.ValSigningInfo, nil } -// SlashingSigningInfos returns all signing infos +// SlashingSigningInfos returns all signing infos. func (c *CosmosChain) SlashingQuerySigningInfos(ctx context.Context) ([]slashingtypes.ValidatorSigningInfo, error) { res, err := slashingtypes.NewQueryClient(c.GetNode().GrpcConn). SigningInfos(ctx, &slashingtypes.QuerySigningInfosRequest{}) diff --git a/chain/cosmos/module_tokenfactory.go b/chain/cosmos/module_tokenfactory.go index 3e5bf5a41..76f16a7bd 100644 --- a/chain/cosmos/module_tokenfactory.go +++ b/chain/cosmos/module_tokenfactory.go @@ -99,7 +99,7 @@ func (c *CosmosChain) TokenFactoryQueryAdmin(ctx context.Context, fullDenom stri return res, nil } -// Deprecated: use TokenFactoryQueryAdmin instead +// Deprecated: use TokenFactoryQueryAdmin instead. func TokenFactoryGetAdmin(c *CosmosChain, ctx context.Context, fullDenom string) (*QueryDenomAuthorityMetadataResponse, error) { return c.TokenFactoryQueryAdmin(ctx, fullDenom) } diff --git a/chain/cosmos/module_upgrade.go b/chain/cosmos/module_upgrade.go index f0b0d071b..93a97e4c7 100644 --- a/chain/cosmos/module_upgrade.go +++ b/chain/cosmos/module_upgrade.go @@ -49,10 +49,9 @@ func (c *CosmosChain) UpgradeQueryAppliedPlan(ctx context.Context, name string) Name: name, }) return res, err - } -// UpgradeQueryAuthority returns the account with authority to conduct upgrades +// UpgradeQueryAuthority returns the account with authority to conduct upgrades. func (c *CosmosChain) UpgradeQueryAuthority(ctx context.Context) (string, error) { res, err := upgradetypes.NewQueryClient(c.GetNode().GrpcConn).Authority(ctx, &upgradetypes.QueryAuthorityRequest{}) return res.Address, err diff --git a/chain/cosmos/module_vesting.go b/chain/cosmos/module_vesting.go index 4e318a47f..b0b62963f 100644 --- a/chain/cosmos/module_vesting.go +++ b/chain/cosmos/module_vesting.go @@ -6,8 +6,9 @@ import ( "fmt" "path" - vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli" "github.com/strangelove-ventures/interchaintest/v8/dockerutil" + + vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli" ) // VestingCreateAccount creates a new vesting account funded with an allocation of tokens. The account can either be a delayed or continuous vesting account, which is determined by the '--delayed' flag. diff --git a/chain/cosmos/node_test.go b/chain/cosmos/node_test.go index e3223dbaf..8eebb9f57 100644 --- a/chain/cosmos/node_test.go +++ b/chain/cosmos/node_test.go @@ -4,9 +4,10 @@ import ( "strings" "testing" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/stretchr/testify/require" + + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestCondenseMoniker_MiddleDetail(t *testing.T) { diff --git a/chain/cosmos/osmosis.go b/chain/cosmos/osmosis.go index ab81c5f99..c6ecbb77f 100644 --- a/chain/cosmos/osmosis.go +++ b/chain/cosmos/osmosis.go @@ -10,7 +10,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/dockerutil" ) -// OsmosisPoolParams defines parameters for creating an osmosis gamm liquidity pool +// OsmosisPoolParams defines parameters for creating an osmosis gamm liquidity pool. type OsmosisPoolParams struct { Weights string `json:"weights"` InitialDeposit string `json:"initial-deposit"` diff --git a/chain/cosmos/poll.go b/chain/cosmos/poll.go index 04f642d9b..39b34d965 100644 --- a/chain/cosmos/poll.go +++ b/chain/cosmos/poll.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "github.com/strangelove-ventures/interchaintest/v8/testutil" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - "github.com/strangelove-ventures/interchaintest/v8/ibc" - "github.com/strangelove-ventures/interchaintest/v8/testutil" ) // PollForProposalStatus attempts to find a proposal with matching ID and status using gov v1. @@ -82,7 +82,7 @@ func PollForMessage[T any](ctx context.Context, chain *CosmosChain, registry cod return bp.DoPoll(ctx, startHeight, maxHeight) } -// PollForBalance polls until the balance matches +// PollForBalance polls until the balance matches. func PollForBalance(ctx context.Context, chain *CosmosChain, deltaBlocks int64, balance ibc.WalletAmount) error { h, err := chain.Height(ctx) if err != nil { diff --git a/chain/cosmos/query.go b/chain/cosmos/query.go index d710d453c..c33a955dc 100644 --- a/chain/cosmos/query.go +++ b/chain/cosmos/query.go @@ -4,9 +4,10 @@ import ( "context" "fmt" - tmtypes "github.com/cometbft/cometbft/rpc/core/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + + tmtypes "github.com/cometbft/cometbft/rpc/core/types" ) type blockClient interface { diff --git a/chain/cosmos/sidecar.go b/chain/cosmos/sidecar.go index 9927e6ec0..7c6978d37 100644 --- a/chain/cosmos/sidecar.go +++ b/chain/cosmos/sidecar.go @@ -7,10 +7,9 @@ import ( dockerclient "github.com/docker/docker/client" "github.com/docker/go-connections/nat" - "go.uber.org/zap" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" + "go.uber.org/zap" ) type SidecarProcesses []*SidecarProcess @@ -150,7 +149,7 @@ func (s *SidecarProcess) GetHostPorts(ctx context.Context, portIDs ...string) ([ // WriteFile accepts file contents in a byte slice and writes the contents to // the docker filesystem. relPath describes the location of the file in the -// docker volume relative to the home directory +// docker volume relative to the home directory. func (s *SidecarProcess) WriteFile(ctx context.Context, content []byte, relPath string) error { fw := dockerutil.NewFileWriter(s.logger(), s.DockerClient, s.TestName) return fw.WriteFile(ctx, s.VolumeName, relPath, content) @@ -158,7 +157,7 @@ func (s *SidecarProcess) WriteFile(ctx context.Context, content []byte, relPath // CopyFile adds a file from the host filesystem to the docker filesystem // relPath describes the location of the file in the docker volume relative to -// the home directory +// the home directory. func (s *SidecarProcess) CopyFile(ctx context.Context, srcPath, dstPath string) error { content, err := os.ReadFile(srcPath) if err != nil { diff --git a/chain/cosmos/types.go b/chain/cosmos/types.go index 22350bcc7..af29e1a68 100644 --- a/chain/cosmos/types.go +++ b/chain/cosmos/types.go @@ -12,7 +12,7 @@ const ( ProposalVoteAbstain = "abstain" ) -// TxProposalv1 contains chain proposal transaction detail for gov module v1 (sdk v0.46.0+) +// TxProposalv1 contains chain proposal transaction detail for gov module v1 (sdk v0.46.0+). type TxProposalv1 struct { Messages []json.RawMessage `json:"messages"` Metadata string `json:"metadata"` diff --git a/chain/cosmos/wallet.go b/chain/cosmos/wallet.go index 2ee27bc08..da2efade9 100644 --- a/chain/cosmos/wallet.go +++ b/chain/cosmos/wallet.go @@ -1,12 +1,15 @@ package cosmos import ( - "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v8/ibc" + + "github.com/cosmos/cosmos-sdk/types" ) -var _ ibc.Wallet = &CosmosWallet{} -var _ User = &CosmosWallet{} +var ( + _ ibc.Wallet = &CosmosWallet{} + _ User = &CosmosWallet{} +) type CosmosWallet struct { mnemonic string @@ -28,17 +31,17 @@ func (w *CosmosWallet) KeyName() string { return w.keyName } -// Get formatted address, passing in a prefix +// Get formatted address, passing in a prefix. func (w *CosmosWallet) FormattedAddress() string { return types.MustBech32ifyAddressBytes(w.chainCfg.Bech32Prefix, w.address) } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *CosmosWallet) Mnemonic() string { return w.mnemonic } -// Get Address with chain's prefix +// Get Address with chain's prefix. func (w *CosmosWallet) Address() []byte { return w.address } diff --git a/chain/cosmos/wasm/wasm.go b/chain/cosmos/wasm/wasm.go index 46886314a..5d5e01c53 100644 --- a/chain/cosmos/wasm/wasm.go +++ b/chain/cosmos/wasm/wasm.go @@ -2,10 +2,10 @@ package wasm import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - "github.com/cosmos/cosmos-sdk/types/module/testutil" - - // simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + // simappparams "github.com/cosmos/cosmos-sdk/simapp/params". "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" + + "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func WasmEncoding() *testutil.TestEncodingConfig { diff --git a/chain/ethereum/ethererum_chain.go b/chain/ethereum/ethererum_chain.go index 010bd0068..30599baf4 100644 --- a/chain/ethereum/ethererum_chain.go +++ b/chain/ethereum/ethererum_chain.go @@ -6,21 +6,20 @@ import ( "io" "time" - sdkmath "cosmossdk.io/math" - dockertypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/volume" dockerclient "github.com/docker/docker/client" "github.com/docker/go-connections/nat" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/ethclient" "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" + sdkmath "cosmossdk.io/math" ) const ( diff --git a/chain/ethereum/foundry/anvil_chain.go b/chain/ethereum/foundry/anvil_chain.go index d42b8c7ef..0f230e7ec 100644 --- a/chain/ethereum/foundry/anvil_chain.go +++ b/chain/ethereum/foundry/anvil_chain.go @@ -37,7 +37,8 @@ func (c *AnvilChain) KeystoreDir() string { } func (c *AnvilChain) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { - cmd := []string{c.Config().Bin, + cmd := []string{ + c.Config().Bin, "--host", "0.0.0.0", // Anyone can call "--no-cors", "--gas-price", c.Config().GasPrices, @@ -127,7 +128,7 @@ func (c *AnvilChain) RecoverKey(ctx context.Context, keyName, mnemonic string) e return nil } -// Get address of account, cast to a string to use +// Get address of account, cast to a string to use. func (c *AnvilChain) GetAddress(ctx context.Context, keyName string) ([]byte, error) { account, ok := c.keystoreMap[keyName] if !ok { diff --git a/chain/ethereum/foundry/forge.go b/chain/ethereum/foundry/forge.go index a37084e83..c9a38e7df 100644 --- a/chain/ethereum/foundry/forge.go +++ b/chain/ethereum/foundry/forge.go @@ -21,7 +21,7 @@ type ForgeScriptOpts struct { RawOptions []string // optional, appends additional options to command } -// Add private-key or keystore to cmd +// Add private-key or keystore to cmd. func (c *AnvilChain) AddKey(cmd []string, keyName string) []string { account, ok := c.keystoreMap[keyName] if !ok { @@ -34,7 +34,7 @@ func (c *AnvilChain) AddKey(cmd []string, keyName string) []string { return cmd } -// Add signature function to cmd, if present +// Add signature function to cmd, if present. func AddSignature(cmd []string, signature string) []string { if signature != "" { cmd = append(cmd, "--sig", signature) @@ -46,7 +46,7 @@ func GetConfigFilePath(configFile, localContractRootDir, solidityContractDir str return filepath.Join(localContractRootDir, solidityContractDir, configFile) } -// ReadAndAppendConfigFile, returns the cmd, configFileBz +// ReadAndAppendConfigFile, returns the cmd, configFileBz. func ReadAndAppendConfigFile(cmd []string, configFile, localContractRootDir, solidityContractDir string) ([]string, []byte, error) { // if config file is present, read the file and add it to cmd, after running, overwrite the results if configFile != "" { @@ -61,11 +61,11 @@ func ReadAndAppendConfigFile(cmd []string, configFile, localContractRootDir, sol return cmd, nil, nil } -// WriteConfigFile - if config file is present, we need to overwrite what forge changed +// WriteConfigFile - if config file is present, we need to overwrite what forge changed. func WriteConfigFile(configFile string, localContractRootDir string, solidityContractDir string, configFileBz []byte) error { if configFile != "" { configFilePath := GetConfigFilePath(configFile, localContractRootDir, solidityContractDir) - err := os.WriteFile(configFilePath, configFileBz, 0644) + err := os.WriteFile(configFilePath, configFileBz, 0o644) if err != nil { return err } diff --git a/chain/ethereum/geth/default_configs.go b/chain/ethereum/geth/default_configs.go index a38235c8f..e114d6f2f 100644 --- a/chain/ethereum/geth/default_configs.go +++ b/chain/ethereum/geth/default_configs.go @@ -31,7 +31,7 @@ func DefaultEthereumGethChainConfig( "--verbosity", "4", // Level = debug "--networkid", "15", "--rpc.txfeecap", "50.0", // 50 eth - "--rpc.gascap", "30000000", //30M + "--rpc.gascap", "30000000", // 30M "--gpo.percentile", "150", // default 60 "--gpo.ignoreprice", "1000000000", // 1gwei, default 2 "--dev.gaslimit", "30000000", // 30M, default 11.5M @@ -58,7 +58,7 @@ func DefaultBscChainConfig( { Repository: "ghcr.io/bnb-chain/bsc", Version: "1.2.13", // same version as other sim tests - //Version: "1.4.13", // this version does not work in dev mode (1.3.x+) + // Version: "1.4.13", // this version does not work in dev mode (1.3.x+) UidGid: "1000:1000", }, }, @@ -69,7 +69,7 @@ func DefaultBscChainConfig( "--verbosity", "4", // Level = debug "--networkid", "15", "--rpc.txfeecap", "50.0", // 50 eth - "--rpc.gascap", "30000000", //30M + "--rpc.gascap", "30000000", // 30M "--gpo.percentile", "150", // default 60 "--gpo.ignoreprice", "1000000000", // 1gwei, default 2 "--dev.gaslimit", "30000000", // 30M, default 11.5M diff --git a/chain/ethereum/geth/geth_chain.go b/chain/ethereum/geth/geth_chain.go index cf9538870..1307ca044 100644 --- a/chain/ethereum/geth/geth_chain.go +++ b/chain/ethereum/geth/geth_chain.go @@ -8,14 +8,14 @@ import ( "sync" "time" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/docker/docker/api/types/mount" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/strangelove-ventures/interchaintest/v8/chain/ethereum" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" + + "github.com/cosmos/cosmos-sdk/crypto/hd" ) var _ ibc.Chain = &GethChain{} @@ -40,7 +40,8 @@ func NewGethChain(testName string, chainConfig ibc.ChainConfig, log *zap.Logger) } func (c *GethChain) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { - cmd := []string{c.Config().Bin, + cmd := []string{ + c.Config().Bin, "--dev", "--datadir", c.HomeDir(), "-http", "--http.addr", "0.0.0.0", "--http.port", "8545", "--allow-insecure-unlock", "--http.api", "eth,net,web3,miner,personal,txpool,debug", "--http.corsdomain", "*", "-nodiscover", "--http.vhosts=*", "--miner.gasprice", c.Config().GasPrices, @@ -52,13 +53,13 @@ func (c *GethChain) Start(testName string, ctx context.Context, additionalGenesi return c.EthereumChain.Start(ctx, cmd, []mount.Mount{}) } -// JavaScriptExec() - Execute web3 code via geth's attach command +// JavaScriptExec() - Execute web3 code via geth's attach command. func (c *GethChain) JavaScriptExec(ctx context.Context, jsCmd string) (stdout, stderr []byte, err error) { cmd := []string{c.Config().Bin, "--exec", jsCmd, "--datadir", c.HomeDir(), "attach"} return c.Exec(ctx, cmd, nil) } -// JavaScriptExecTx() - Execute a tx via web3, function ensures account is unlocked and blocks multiple txs +// JavaScriptExecTx() - Execute a tx via web3, function ensures account is unlocked and blocks multiple txs. func (c *GethChain) JavaScriptExecTx(ctx context.Context, account *NodeWallet, jsCmd string) (stdout, stderr []byte, err error) { if err := c.UnlockAccount(ctx, account); err != nil { return nil, nil, err @@ -88,7 +89,8 @@ func (c *GethChain) CreateKey(ctx context.Context, keyName string) error { EOF -`, c.HomeDir())} +`, c.HomeDir()), + } _, _, err := c.Exec(ctx, cmd, nil) if err != nil { return err @@ -128,7 +130,7 @@ func (c *GethChain) RecoverKey(ctx context.Context, keyName, mnemonic string) er return nil } -// Get address of account, cast to a string to use +// Get address of account, cast to a string to use. func (c *GethChain) GetAddress(ctx context.Context, keyName string) ([]byte, error) { account, found := c.keynameToAccountMap[keyName] if !found { @@ -200,7 +202,7 @@ func (c *GethChain) SendFundsWithNote(ctx context.Context, keyName string, amoun } // DeployContract creates a new contract on-chain, returning the contract address -// Constructor params are appended to the byteCode +// Constructor params are appended to the byteCode. func (c *GethChain) DeployContract(ctx context.Context, keyName string, abi []byte, byteCode []byte) (string, error) { account, found := c.keynameToAccountMap[keyName] if !found { diff --git a/chain/ethereum/wallet.go b/chain/ethereum/wallet.go index 86e6688a7..0993065b8 100644 --- a/chain/ethereum/wallet.go +++ b/chain/ethereum/wallet.go @@ -25,17 +25,17 @@ func (w *EthereumWallet) KeyName() string { return w.keyName } -// Get formatted address, passing in a prefix +// Get formatted address, passing in a prefix. func (w *EthereumWallet) FormattedAddress() string { return hexutil.Encode(w.address) } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *EthereumWallet) Mnemonic() string { return w.mnemonic } -// Get Address with chain's prefix +// Get Address with chain's prefix. func (w *EthereumWallet) Address() []byte { return w.address } diff --git a/chain/internal/tendermint/events_test.go b/chain/internal/tendermint/events_test.go index 558723165..4a7643c4a 100644 --- a/chain/internal/tendermint/events_test.go +++ b/chain/internal/tendermint/events_test.go @@ -3,8 +3,9 @@ package tendermint import ( "testing" - abcitypes "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/require" + + abcitypes "github.com/cometbft/cometbft/abci/types" ) func TestAttributeValue(t *testing.T) { diff --git a/chain/internal/tendermint/tendermint_node.go b/chain/internal/tendermint/tendermint_node.go index ab9ff578f..6b0aeb2de 100644 --- a/chain/internal/tendermint/tendermint_node.go +++ b/chain/internal/tendermint/tendermint_node.go @@ -9,11 +9,6 @@ import ( "time" "github.com/avast/retry-go/v4" - tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/p2p" - rpcclient "github.com/cometbft/cometbft/rpc/client" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" volumetypes "github.com/docker/docker/api/types/volume" dockerclient "github.com/docker/docker/client" "github.com/docker/go-connections/nat" @@ -22,9 +17,15 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" + + tmjson "github.com/cometbft/cometbft/libs/json" + "github.com/cometbft/cometbft/p2p" + rpcclient "github.com/cometbft/cometbft/rpc/client" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" + libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" ) -// TendermintNode represents a node in the test network that is being created +// TendermintNode represents a node in the test network that is being created. type TendermintNode struct { Log *zap.Logger @@ -50,8 +51,10 @@ func NewTendermintNode( testName string, image ibc.DockerImage, ) (*TendermintNode, error) { - tn := &TendermintNode{Log: log, Index: i, Chain: c, - DockerClient: dockerClient, NetworkID: networkID, TestName: testName, Image: image} + tn := &TendermintNode{ + Log: log, Index: i, Chain: c, + DockerClient: dockerClient, NetworkID: networkID, TestName: testName, Image: image, + } tn.containerLifecycle = dockerutil.NewContainerLifecycle(log, dockerClient, tn.Name()) @@ -81,11 +84,11 @@ func NewTendermintNode( return tn, nil } -// TendermintNodes is a collection of TendermintNode +// TendermintNodes is a collection of TendermintNode. type TendermintNodes []*TendermintNode const ( - // BlockTimeSeconds (in seconds) is approx time to create a block + // BlockTimeSeconds (in seconds) is approx time to create a block. BlockTimeSeconds = 2 p2pPort = "26656/tcp" @@ -95,17 +98,15 @@ const ( privValPort = "1234/tcp" ) -var ( - sentryPorts = nat.PortMap{ - nat.Port(p2pPort): {}, - nat.Port(rpcPort): {}, - nat.Port(grpcPort): {}, - nat.Port(apiPort): {}, - nat.Port(privValPort): {}, - } -) +var sentryPorts = nat.PortMap{ + nat.Port(p2pPort): {}, + nat.Port(rpcPort): {}, + nat.Port(grpcPort): {}, + nat.Port(apiPort): {}, + nat.Port(privValPort): {}, +} -// NewClient creates and assigns a new Tendermint RPC client to the TendermintNode +// NewClient creates and assigns a new Tendermint RPC client to the TendermintNode. func (tn *TendermintNode) NewClient(addr string) error { httpClient, err := libclient.DefaultHTTPClient(addr) if err != nil { @@ -122,7 +123,7 @@ func (tn *TendermintNode) NewClient(addr string) error { return nil } -// Name is the hostname of the test node container +// Name is the hostname of the test node container. func (tn *TendermintNode) Name() string { return fmt.Sprintf("node-%d-%s-%s", tn.Index, tn.Chain.Config().ChainID, dockerutil.SanitizeContainerName(tn.TestName)) } @@ -171,7 +172,7 @@ type PrivValidatorKeyFile struct { PrivKey PrivValidatorKey `json:"priv_key"` } -// Bind returns the home folder bind point for running the node +// Bind returns the home folder bind point for running the node. func (tn *TendermintNode) Bind() []string { return []string{fmt.Sprintf("%s:%s", tn.VolumeName, tn.HomeDir())} } @@ -180,7 +181,7 @@ func (tn *TendermintNode) HomeDir() string { return path.Join("/var/tendermint", tn.Chain.Config().Name) } -// SetConfigAndPeers modifies the config for a validator node to start a chain +// SetConfigAndPeers modifies the config for a validator node to start a chain. func (tn *TendermintNode) SetConfigAndPeers(ctx context.Context, peers string) error { c := make(testutil.Toml) @@ -233,7 +234,7 @@ func (tn *TendermintNode) SetConfigAndPeers(ctx context.Context, peers string) e // Tenderment deprecate snake_case in config for hyphen-case in v0.34.1 // https://github.com/cometbft/cometbft/blob/main/CHANGELOG.md#v0341 func (tn *TendermintNode) GetConfigSeparator() (string, error) { - var sep = "_" + sep := "_" currentTnVersion, err := version.NewVersion(tn.Image.Version[1:]) if err != nil { @@ -258,9 +259,10 @@ func (tn *TendermintNode) Height(ctx context.Context) (int64, error) { return stat.SyncInfo.LatestBlockHeight, nil } -// InitHomeFolder initializes a home folder for the given node +// InitHomeFolder initializes a home folder for the given node. func (tn *TendermintNode) InitHomeFolder(ctx context.Context, mode string) error { - command := []string{tn.Chain.Config().Bin, "init", mode, + command := []string{ + tn.Chain.Config().Bin, "init", mode, "--home", tn.HomeDir(), } _, _, err := tn.Exec(ctx, command, tn.Chain.Config().Env) @@ -311,7 +313,7 @@ func (tn *TendermintNode) StartContainer(ctx context.Context) error { }, retry.Context(ctx), retry.DelayType(retry.BackOffDelay)) } -// InitValidatorFiles creates the node files and signs a genesis transaction +// InitValidatorFiles creates the node files and signs a genesis transaction. func (tn *TendermintNode) InitValidatorFiles(ctx context.Context) error { return tn.InitHomeFolder(ctx, "validator") } @@ -320,7 +322,7 @@ func (tn *TendermintNode) InitFullNodeFiles(ctx context.Context) error { return tn.InitHomeFolder(ctx, "full") } -// NodeID returns the node of a given node +// NodeID returns the node of a given node. func (tn *TendermintNode) NodeID(ctx context.Context) (string, error) { // This used to call p2p.LoadNodeKey against the file on the host, // but because we are transitioning to operating on Docker volumes, @@ -338,7 +340,7 @@ func (tn *TendermintNode) NodeID(ctx context.Context) (string, error) { return string(nk.ID()), nil } -// PeerString returns the string for connecting the nodes passed in +// PeerString returns the string for connecting the nodes passed in. func (tn TendermintNodes) PeerString(ctx context.Context, node *TendermintNode) string { addrs := make([]string, len(tn)) for i, n := range tn { @@ -360,7 +362,7 @@ func (tn TendermintNodes) PeerString(ctx context.Context, node *TendermintNode) return strings.Join(addrs, ",") } -// LogGenesisHashes logs the genesis hashes for the various nodes +// LogGenesisHashes logs the genesis hashes for the various nodes. func (tn TendermintNodes) LogGenesisHashes(ctx context.Context) error { for _, n := range tn { gen, err := n.GenesisFileContent(ctx) diff --git a/chain/penumbra/penumbra_app_node.go b/chain/penumbra/penumbra_app_node.go index 7f61ed81d..9a6e033c7 100644 --- a/chain/penumbra/penumbra_app_node.go +++ b/chain/penumbra/penumbra_app_node.go @@ -53,8 +53,10 @@ func NewPenumbraAppNode( networkID string, image ibc.DockerImage, ) (*PenumbraAppNode, error) { - pn := &PenumbraAppNode{log: log, Index: index, Chain: chain, - DockerClient: dockerClient, NetworkID: networkID, TestName: testName, Image: image} + pn := &PenumbraAppNode{ + log: log, Index: index, Chain: chain, + DockerClient: dockerClient, NetworkID: networkID, TestName: testName, Image: image, + } pn.containerLifecycle = dockerutil.NewContainerLifecycle(log, dockerClient, pn.Name()) @@ -301,7 +303,7 @@ func (p *PenumbraAppNode) GetAddress(ctx context.Context, keyName string) ([]byt } // GetBalance attempts to query the token balances for a specified key name via an instance of pcli. -// TODO we need to change the func sig to take a denom then filter out the target denom bal from stdout +// TODO we need to change the func sig to take a denom then filter out the target denom bal from stdout. func (p *PenumbraAppNode) GetBalance(ctx context.Context, keyName string) (int64, error) { keyPath := filepath.Join(p.HomeDir(), "keys", keyName) cmd := []string{"pcli", "--home", keyPath, "view", "balance"} @@ -398,7 +400,8 @@ func (p *PenumbraAppNode) SendIBCTransfer(ctx context.Context, channelID, keyNam parts := strings.Split(channelID, "-") chanNum := parts[1] - cmd := []string{"pcli", "--home", keyPath, "tx", "withdraw", + cmd := []string{ + "pcli", "--home", keyPath, "tx", "withdraw", "--to", amount.Address, "--channel", chanNum, "--timeout-height", fmt.Sprintf("0-%d", opts.Timeout.Height), diff --git a/chain/penumbra/penumbra_chain.go b/chain/penumbra/penumbra_chain.go index dc8ba12c7..3f59f46c2 100644 --- a/chain/penumbra/penumbra_chain.go +++ b/chain/penumbra/penumbra_chain.go @@ -10,13 +10,7 @@ import ( "strings" "sync" - "cosmossdk.io/math" "github.com/BurntSushi/toml" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v8/chain/internal/tendermint" @@ -25,6 +19,14 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" "golang.org/x/sync/errgroup" + + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" ) type PenumbraChain struct { @@ -130,7 +132,7 @@ func (c *PenumbraChain) GetGRPCAddress() string { return fmt.Sprintf("%s:9090", c.getFullNode().TendermintNode.HostName()) } -// Implements Chain interface +// Implements Chain interface. func (c *PenumbraChain) GetHostPeerAddress() string { panic("NOT IMPLEMENTED") } @@ -235,7 +237,7 @@ func (c *PenumbraChain) SendFunds(ctx context.Context, keyName string, amount ib } // SendFundsWithNote will initiate a local transfer from the account associated with the specified keyName, -// amount, token denom, and recipient are specified in the amount and attach a note/memo +// amount, token denom, and recipient are specified in the amount and attach a note/memo. func (c *PenumbraChain) SendFundsWithNote(ctx context.Context, keyName string, amount ibc.WalletAmount, note string) (string, error) { panic("Penumbrachain: SendFundsWithNote unimplemented") } diff --git a/chain/penumbra/penumbra_client_node.go b/chain/penumbra/penumbra_client_node.go index 8e210166d..70e618993 100644 --- a/chain/penumbra/penumbra_client_node.go +++ b/chain/penumbra/penumbra_client_node.go @@ -10,14 +10,7 @@ import ( "strings" "time" - "cosmossdk.io/math" "github.com/BurntSushi/toml" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - transactionv1 "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/core/transaction/v1" - - //nolint:staticcheck - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/go-connections/nat" @@ -26,6 +19,7 @@ import ( pool "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/core/component/shielded_pool/v1" keys "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/core/keys/v1" num "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/core/num/v1" + transactionv1 "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/core/transaction/v1" custody "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/custody/v1" view "github.com/strangelove-ventures/interchaintest/v8/chain/penumbra/view/v1" "github.com/strangelove-ventures/interchaintest/v8/dockerutil" @@ -34,6 +28,12 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + + "cosmossdk.io/math" + + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + //nolint:staticcheck + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ) // PenumbraClientNode represents an instance of pclientd. @@ -263,7 +263,7 @@ func (p *PenumbraClientNode) SendFunds(ctx context.Context, amount ibc.WalletAmo // SendIBCTransfer sends an IBC transfer from the current PenumbraClientNode to a specified destination address on a specified channel. // The function validates the address string on the current PenumbraClientNode instance. If the address string is empty, it returns an error. -// It translates the amount to a big integer and creates an `ibcv1.Ics20Withdrawal` with the amount, denom, destination address, return address, timeout height, timeout timestamp +// It translates the amount to a big integer and creates an `ibcv1.Ics20Withdrawal` with the amount, denom, destination address, return address, timeout height, timeout timestamp. func (p *PenumbraClientNode) SendIBCTransfer( ctx context.Context, channelID string, diff --git a/chain/penumbra/penumbra_client_node_test.go b/chain/penumbra/penumbra_client_node_test.go index c18f2f1c5..f9d899dfc 100644 --- a/chain/penumbra/penumbra_client_node_test.go +++ b/chain/penumbra/penumbra_client_node_test.go @@ -4,9 +4,10 @@ import ( "math/big" "testing" - "cosmossdk.io/math" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/stretchr/testify/require" + + "cosmossdk.io/math" ) // TestBigIntDecoding tests the decoding of big integers. @@ -30,7 +31,7 @@ func TestBigIntDecoding(t *testing.T) { // Scenario 2: options has nil timeout value - return default timeout values // Scenario 3: both timeout values equal non-zero values - use specified timeout values // Scenario 4: only nanoseconds equals non-zero value - use specified value for timestamp and zero for height -// Scenario 5: only height equals non-zero value - use specified value for height and zero for timestamp +// Scenario 5: only height equals non-zero value - use specified value for height and zero for timestamp. func TestIbcTransferTimeout(t *testing.T) { defaultHeight, defaultTimestamp := defaultTransferTimeouts() zero := uint64(0) diff --git a/chain/penumbra/wallet.go b/chain/penumbra/wallet.go index 41cbc88af..8f4403890 100644 --- a/chain/penumbra/wallet.go +++ b/chain/penumbra/wallet.go @@ -14,7 +14,7 @@ type PenumbraWallet struct { chainCfg ibc.ChainConfig } -// NewWallet creates a new instance of PenumbraWallet with the provided parameters +// NewWallet creates a new instance of PenumbraWallet with the provided parameters. func NewWallet(keyname string, address []byte, mnemonic string, chainCfg ibc.ChainConfig) *PenumbraWallet { return &PenumbraWallet{ mnemonic: mnemonic, diff --git a/chain/polkadot/keys.go b/chain/polkadot/keys.go index 18489ff4c..57fbed896 100644 --- a/chain/polkadot/keys.go +++ b/chain/polkadot/keys.go @@ -5,10 +5,9 @@ import ( "encoding/hex" "fmt" - "github.com/decred/dcrd/dcrec/secp256k1/v2" - schnorrkel "github.com/ChainSafe/go-schnorrkel/1" "github.com/StirlingMarketingGroup/go-namecase" + "github.com/decred/dcrd/dcrec/secp256k1/v2" p2pCrypto "github.com/libp2p/go-libp2p/core/crypto" "golang.org/x/crypto/blake2b" ) @@ -18,7 +17,7 @@ const ( ss58Secp256k1Prefix = "Secp256k1HDKD" ) -var DEV_SEED, _ = hex.DecodeString("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e") +var DevSeed, _ = hex.DecodeString("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e") func DeriveEd25519FromName(name string) (*p2pCrypto.Ed25519PrivateKey, error) { chainCode := make([]byte, 32) @@ -33,7 +32,7 @@ func DeriveEd25519FromName(name string) (*p2pCrypto.Ed25519PrivateKey, error) { toHash := []byte{byte(len(ss58Ed25519Prefix) << 2)} toHash = append(toHash, []byte(ss58Ed25519Prefix)...) - toHash = append(toHash, DEV_SEED...) + toHash = append(toHash, DevSeed...) toHash = append(toHash, chainCode...) if _, err := hasher.Write(toHash); err != nil { @@ -60,7 +59,7 @@ func DeriveEd25519FromName(name string) (*p2pCrypto.Ed25519PrivateKey, error) { func DeriveSr25519FromName(path []string) (*schnorrkel.MiniSecretKey, error) { var miniSecretSeed [32]byte - _ = copy(miniSecretSeed[:], DEV_SEED[:32]) + _ = copy(miniSecretSeed[:], DevSeed[:32]) miniSecret, err := schnorrkel.NewMiniSecretKeyFromRaw(miniSecretSeed) if err != nil { return nil, fmt.Errorf("error getting mini secret from seed: %w", err) @@ -92,7 +91,7 @@ func DeriveSecp256k1FromName(name string) (*secp256k1.PrivateKey, error) { toHash := []byte{byte(len(ss58Secp256k1Prefix) << 2)} toHash = append(toHash, []byte(ss58Secp256k1Prefix)...) - toHash = append(toHash, DEV_SEED...) + toHash = append(toHash, DevSeed...) toHash = append(toHash, chainCode...) if _, err := hasher.Write(toHash); err != nil { diff --git a/chain/polkadot/parachain_node.go b/chain/polkadot/parachain_node.go index 43bdbebea..c5b809d47 100644 --- a/chain/polkadot/parachain_node.go +++ b/chain/polkadot/parachain_node.go @@ -8,9 +8,7 @@ import ( "path/filepath" "strings" - "cosmossdk.io/math" "github.com/avast/retry-go/v4" - sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/docker/docker/client" "github.com/icza/dyno" p2pcrypto "github.com/libp2p/go-libp2p/core/crypto" @@ -19,9 +17,13 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" "go.uber.org/zap" + + "cosmossdk.io/math" + + sdktypes "github.com/cosmos/cosmos-sdk/types" ) -// Increase parachain wallet amount due to their additional precision +// Increase parachain wallet amount due to their additional precision. const parachainScaling = int64(1_000) // ParachainNode defines the properties required for running a polkadot parachain node. @@ -78,7 +80,7 @@ func (pn *ParachainNode) ParachainChainSpecFileName() string { } // ParachainChainSpecFilePathFull returns the full path to the chain spec file -// within the parachain container +// within the parachain container. func (pn *ParachainNode) ParachainChainSpecFilePathFull() string { return filepath.Join(pn.NodeHome(), pn.ParachainChainSpecFileName()) } @@ -117,7 +119,7 @@ type GetParachainIDResponse struct { ParachainID int `json:"para_id"` } -// GenerateDefaultChainSpec runs build-spec to get the default chain spec into something malleable +// GenerateDefaultChainSpec runs build-spec to get the default chain spec into something malleable. func (pn *ParachainNode) GenerateDefaultChainSpec(ctx context.Context) ([]byte, error) { cmd := []string{ pn.Bin, @@ -132,7 +134,7 @@ func (pn *ParachainNode) GenerateDefaultChainSpec(ctx context.Context) ([]byte, } // GenerateParachainGenesisFile creates the default chain spec, modifies it and returns it. -// The modified chain spec is then written to each Parachain node +// The modified chain spec is then written to each Parachain node. func (pn *ParachainNode) GenerateParachainGenesisFile(ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) ([]byte, error) { defaultChainSpec, err := pn.GenerateDefaultChainSpec(ctx) if err != nil { @@ -309,7 +311,7 @@ func (pn *ParachainNode) GetBalance(ctx context.Context, address string, denom s return GetBalance(pn.api, address) } -// GetIbcBalance returns the Coins type of ibc coins in account +// GetIbcBalance returns the Coins type of ibc coins in account. func (pn *ParachainNode) GetIbcBalance(ctx context.Context, address string, denom uint64) (sdktypes.Coin, error) { res, err := pn.api.RPC.IBC.QueryBalanceWithAddress(ctx, address, denom) if err != nil { @@ -369,7 +371,7 @@ func (pn *ParachainNode) SendIbcFunds( return nil } -// MintFunds mints an asset for a user on parachain, keyName must be the owner of the asset +// MintFunds mints an asset for a user on parachain, keyName must be the owner of the asset. func (pn *ParachainNode) MintFunds( keyName string, amount ibc.WalletAmount, diff --git a/chain/polkadot/polkadot_chain.go b/chain/polkadot/polkadot_chain.go index 6c71c3b39..ce88f0535 100644 --- a/chain/polkadot/polkadot_chain.go +++ b/chain/polkadot/polkadot_chain.go @@ -9,11 +9,8 @@ import ( "io" "strings" - "cosmossdk.io/math" "github.com/99designs/keyring" "github.com/StirlingMarketingGroup/go-namecase" - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/go-bip39" "github.com/docker/docker/api/types" volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" @@ -27,9 +24,15 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "go.uber.org/zap" "golang.org/x/sync/errgroup" + + "cosmossdk.io/math" + + "github.com/cosmos/go-bip39" + + sdktypes "github.com/cosmos/cosmos-sdk/types" ) -// Increase polkadot wallet amount due to their additional precision +// Increase polkadot wallet amount due to their additional precision. const polkadotScaling = int64(1_000) // PolkadotChain implements the ibc.Chain interface for substrate chains. @@ -74,8 +77,10 @@ type ParachainConfig struct { } // IndexedName is a slice of the substrate dev key names used for key derivation. -var IndexedName = []string{"alice", "bob", "charlie", "dave", "ferdie"} -var IndexedUri = []string{"//Alice", "//Bob", "//Charlie", "//Dave", "//Ferdie"} +var ( + IndexedName = []string{"alice", "bob", "charlie", "dave", "ferdie"} + IndexedUri = []string{"//Alice", "//Bob", "//Charlie", "//Dave", "//Ferdie"} +) // NewPolkadotChain returns an uninitialized PolkadotChain, which implements the ibc.Chain interface. func NewPolkadotChain(log *zap.Logger, testName string, chainConfig ibc.ChainConfig, numRelayChainNodes int, parachains []ParachainConfig) *PolkadotChain { @@ -510,7 +515,7 @@ func (c *PolkadotChain) Start(testName string, ctx context.Context, additionalGe if err := fw.WriteFile(ctx, n.VolumeName, n.RawRelayChainSpecFilePathRelative(), rawChainSpecBytes); err != nil { return fmt.Errorf("error writing raw chain spec: %w", err) } - //fmt.Print(string(rawChainSpecBytes)) + // fmt.Print(string(rawChainSpecBytes)) c.logger().Info("Creating container", zap.String("name", n.Name())) if err := n.CreateNodeContainer(ctx); err != nil { return err @@ -542,7 +547,7 @@ func (c *PolkadotChain) GetRPCAddress() string { if len(c.ParachainNodes) > 0 && len(c.ParachainNodes[0]) > 0 { parachainHostName = c.ParachainNodes[0][0].HostName() - //return fmt.Sprintf("%s:%s", c.ParachainNodes[0][0].HostName(), strings.Split(rpcPort, "/")[0]) + // return fmt.Sprintf("%s:%s", c.ParachainNodes[0][0].HostName(), strings.Split(rpcPort, "/")[0]) } else { parachainHostName = c.RelayChainNodes[0].HostName() } @@ -550,7 +555,7 @@ func (c *PolkadotChain) GetRPCAddress() string { parachainUrl := fmt.Sprintf("http://%s:%s", parachainHostName, port) relaychainUrl := fmt.Sprintf("http://%s:%s", relaychainHostName, port) return fmt.Sprintf("%s,%s", parachainUrl, relaychainUrl) - //return fmt.Sprintf("%s:%s", c.RelayChainNodes[0].HostName(), strings.Split(rpcPort, "/")[0]) + // return fmt.Sprintf("%s:%s", c.RelayChainNodes[0].HostName(), strings.Split(rpcPort, "/")[0]) } // GetGRPCAddress retrieves the grpc address that can be reached by other containers in the docker network. @@ -562,7 +567,7 @@ func (c *PolkadotChain) GetGRPCAddress() string { return fmt.Sprintf("%s:%s", c.RelayChainNodes[0].HostName(), strings.Split(wsPort, "/")[0]) } -// Implements Chain interface +// Implements Chain interface. func (c *PolkadotChain) GetHostPeerAddress() string { panic("NOT IMPLEMENTED") } @@ -720,7 +725,7 @@ func (c *PolkadotChain) GetPublicKey(keyName string) ([]byte, error) { // BuildWallet will return a Polkadot wallet // If mnemonic != "", it will restore using that mnemonic -// If mnemonic == "", it will create a new key +// If mnemonic == "", it will create a new key. func (c *PolkadotChain) BuildWallet(ctx context.Context, keyName string, mnemonic string) (ibc.Wallet, error) { if mnemonic != "" { if err := c.RecoverKey(ctx, keyName, mnemonic); err != nil { @@ -799,7 +804,7 @@ func (c *PolkadotChain) GetBalance(ctx context.Context, address string, denom st return c.ParachainNodes[0][0].GetBalance(ctx, address, denom) } -// AccountInfo contains information of an account +// AccountInfo contains information of an account. type AccountInfo struct { Nonce gstypes.U32 Consumers gstypes.U32 @@ -831,7 +836,7 @@ func (c *PolkadotChain) Timeouts(ctx context.Context, height int64) ([]ibc.Packe panic("[Timeouts] not implemented yet") } -// GetKeyringPair returns the keyring pair from the keyring using keyName +// GetKeyringPair returns the keyring pair from the keyring using keyName. func (c *PolkadotChain) GetKeyringPair(keyName string) (signature.KeyringPair, error) { kp := signature.KeyringPair{} krItem, err := c.keyring.Get(keyName) @@ -847,17 +852,17 @@ func (c *PolkadotChain) GetKeyringPair(keyName string) (signature.KeyringPair, e return kp, nil } -// FindTxs implements blockdb.BlockSaver (Not implemented yet for polkadot, but we don't want to exit) +// FindTxs implements blockdb.BlockSaver (Not implemented yet for polkadot, but we don't want to exit). func (c *PolkadotChain) FindTxs(ctx context.Context, height int64) ([]blockdb.Tx, error) { return []blockdb.Tx{}, nil } -// GetIbcBalance returns the Coins type of ibc coins in account +// GetIbcBalance returns the Coins type of ibc coins in account. func (c *PolkadotChain) GetIbcBalance(ctx context.Context, address string, denom uint64) (sdktypes.Coin, error) { return c.ParachainNodes[0][0].GetIbcBalance(ctx, address, denom) } -// MintFunds mints an asset for a user on parachain, keyName must be the owner of the asset +// MintFunds mints an asset for a user on parachain, keyName must be the owner of the asset. func (c *PolkadotChain) MintFunds(keyName string, amount ibc.WalletAmount) error { return c.ParachainNodes[0][0].MintFunds(keyName, amount) } diff --git a/chain/polkadot/query.go b/chain/polkadot/query.go index 8b0ca27db..1ab1933ee 100644 --- a/chain/polkadot/query.go +++ b/chain/polkadot/query.go @@ -1,12 +1,13 @@ package polkadot import ( - "cosmossdk.io/math" gsrpc "github.com/misko9/go-substrate-rpc-client/v4" gstypes "github.com/misko9/go-substrate-rpc-client/v4/types" + + "cosmossdk.io/math" ) -// GetBalance fetches the current balance for a specific account address using the SubstrateAPI +// GetBalance fetches the current balance for a specific account address using the SubstrateAPI. func GetBalance(api *gsrpc.SubstrateAPI, address string) (math.Int, error) { meta, err := api.RPC.State.GetMetadataLatest() if err != nil { diff --git a/chain/polkadot/relay_chain_node.go b/chain/polkadot/relay_chain_node.go index 27a440938..5450347f5 100644 --- a/chain/polkadot/relay_chain_node.go +++ b/chain/polkadot/relay_chain_node.go @@ -8,19 +8,18 @@ import ( "strings" "time" - "cosmossdk.io/math" "github.com/avast/retry-go/v4" + "github.com/decred/dcrd/dcrec/secp256k1/v2" "github.com/docker/docker/client" "github.com/docker/go-connections/nat" - gsrpc "github.com/misko9/go-substrate-rpc-client/v4" - p2pCrypto "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" - "go.uber.org/zap" - - "github.com/decred/dcrd/dcrec/secp256k1/v2" + gsrpc "github.com/misko9/go-substrate-rpc-client/v4" "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" + "go.uber.org/zap" + + "cosmossdk.io/math" ) // RelayChainNode defines the properties required for running a polkadot relay chain node. @@ -51,7 +50,7 @@ type RelayChainNodes []*RelayChainNode const ( wsPort = "27451/tcp" - //rpcPort = "27452/tcp" + // rpcPort = "27452/tcp". nodePort = "27452/tcp" rpcPort = "9933/tcp" prometheusPort = "27453/tcp" diff --git a/chain/polkadot/ss58.go b/chain/polkadot/ss58.go index 0abcb3e87..83c77d808 100644 --- a/chain/polkadot/ss58.go +++ b/chain/polkadot/ss58.go @@ -61,7 +61,7 @@ func DecodeAddressSS58(address string) ([]byte, error) { } bss := ss58AddrDecoded[0 : len(ss58AddrDecoded)-checksumLength] checksum, _ := blake2b.New(64, []byte{}) - w := append(checksumPrefix[:], bss[:]...) + w := append(checksumPrefix, bss...) _, err = checksum.Write(w) if err != nil { return nil, err diff --git a/chain/polkadot/tx.go b/chain/polkadot/tx.go index b4afce48c..0df44fe9c 100644 --- a/chain/polkadot/tx.go +++ b/chain/polkadot/tx.go @@ -11,7 +11,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" ) -// SendFundsTx sends funds to a wallet using the SubstrateAPI +// SendFundsTx sends funds to a wallet using the SubstrateAPI. func SendFundsTx(api *gsrpc.SubstrateAPI, senderKeypair signature.KeyringPair, amount ibc.WalletAmount) (gstypes.Hash, error) { hash := gstypes.Hash{} meta, err := api.RPC.State.GetMetadataLatest() @@ -37,7 +37,7 @@ func SendFundsTx(api *gsrpc.SubstrateAPI, senderKeypair signature.KeyringPair, a return CreateSignSubmitExt(api, meta, senderKeypair, call) } -// Turns on sending and receiving ibc transfers +// Turns on sending and receiving ibc transfers. func EnableIbc(api *gsrpc.SubstrateAPI, senderKeypair signature.KeyringPair) (gstypes.Hash, error) { hash := gstypes.Hash{} meta, err := api.RPC.State.GetMetadataLatest() @@ -58,7 +58,7 @@ func EnableIbc(api *gsrpc.SubstrateAPI, senderKeypair signature.KeyringPair) (gs return CreateSignSubmitExt(api, meta, senderKeypair, sc) } -// SendIbcFundsTx sends funds to a wallet using the SubstrateAPI +// SendIbcFundsTx sends funds to a wallet using the SubstrateAPI. func SendIbcFundsTx( api *gsrpc.SubstrateAPI, senderKeypair signature.KeyringPair, @@ -96,7 +96,7 @@ func SendIbcFundsTx( return CreateSignSubmitExt(api, meta, senderKeypair, call) } -// MintFunds mints an asset for a user on parachain, keyName must be the owner of the asset +// MintFunds mints an asset for a user on parachain, keyName must be the owner of the asset. func MintFundsTx( api *gsrpc.SubstrateAPI, senderKeypair signature.KeyringPair, @@ -134,7 +134,7 @@ func MintFundsTx( return CreateSignSubmitExt(api, meta, senderKeypair, call) } -// Common tx function to create an extrinsic and sign/submit it +// Common tx function to create an extrinsic and sign/submit it. func CreateSignSubmitExt( api *gsrpc.SubstrateAPI, meta *gstypes.Metadata, diff --git a/chain/polkadot/wallet.go b/chain/polkadot/wallet.go index 82ac58d12..9d58c9e28 100644 --- a/chain/polkadot/wallet.go +++ b/chain/polkadot/wallet.go @@ -30,13 +30,13 @@ func (w *PolkadotWallet) FormattedAddress() string { return string(w.address) } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *PolkadotWallet) Mnemonic() string { return w.mnemonic } // Get Address -// TODO Change to SS58 +// TODO Change to SS58. func (w *PolkadotWallet) Address() []byte { return w.address } diff --git a/chain/thorchain/account_retriever.go b/chain/thorchain/account_retriever.go index 7805a2c7b..ac587c3ba 100644 --- a/chain/thorchain/account_retriever.go +++ b/chain/thorchain/account_retriever.go @@ -5,14 +5,13 @@ import ( "fmt" "strconv" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - grpc "google.golang.org/grpc" "google.golang.org/grpc/metadata" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) var ( diff --git a/chain/thorchain/address.go b/chain/thorchain/address.go index 0021ddc85..61fa9b175 100644 --- a/chain/thorchain/address.go +++ b/chain/thorchain/address.go @@ -4,9 +4,8 @@ import ( "errors" "strings" - "github.com/cosmos/cosmos-sdk/types/bech32" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/bech32" ) // AccAddressFromBech32 creates an AccAddress from a Bech32 string. diff --git a/chain/thorchain/api_query.go b/chain/thorchain/api_query.go index 559243664..d442e5528 100644 --- a/chain/thorchain/api_query.go +++ b/chain/thorchain/api_query.go @@ -12,9 +12,9 @@ import ( "strconv" "strings" - sdkmath "cosmossdk.io/math" - "github.com/strangelove-ventures/interchaintest/v8/chain/thorchain/common" + + sdkmath "cosmossdk.io/math" ) func (c *Thorchain) ApiGetBalances(addr string) (common.Coins, error) { diff --git a/chain/thorchain/broadcaster.go b/chain/thorchain/broadcaster.go index f4b37b474..6dc22a1e3 100644 --- a/chain/thorchain/broadcaster.go +++ b/chain/thorchain/broadcaster.go @@ -8,6 +8,9 @@ import ( "testing" "time" + "github.com/strangelove-ventures/interchaintest/v8/dockerutil" + "github.com/strangelove-ventures/interchaintest/v8/testutil" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -15,8 +18,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" - "github.com/strangelove-ventures/interchaintest/v8/testutil" ) type ClientContextOpt func(clientContext client.Context) client.Context @@ -216,13 +217,11 @@ func BroadcastTx(ctx context.Context, broadcaster *Broadcaster, broadcastingUser err = testutil.WaitForCondition(time.Second*30, time.Second*5, func() (bool, error) { var err error txBytes, err = broadcaster.GetTxResponseBytes(ctx, broadcastingUser) - if err != nil { return false, nil } return true, nil }) - if err != nil { return sdk.TxResponse{}, err } diff --git a/chain/thorchain/codec.go b/chain/thorchain/codec.go index 7c1194638..819956536 100644 --- a/chain/thorchain/codec.go +++ b/chain/thorchain/codec.go @@ -2,6 +2,12 @@ package thorchain import ( "cosmossdk.io/x/upgrade" + + "github.com/cosmos/ibc-go/modules/capability" + transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibccore "github.com/cosmos/ibc-go/v8/modules/core" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,11 +22,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/cosmos/ibc-go/modules/capability" - - transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer" - ibccore "github.com/cosmos/ibc-go/v8/modules/core" - ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ) func DefaultEncoding() testutil.TestEncodingConfig { diff --git a/chain/thorchain/common/chain.go b/chain/thorchain/common/chain.go index b721b8531..ddb4c9ae9 100644 --- a/chain/thorchain/common/chain.go +++ b/chain/thorchain/common/chain.go @@ -22,10 +22,10 @@ const ( type Chain string -// Chains represent a slice of Chain +// Chains represent a slice of Chain. type Chains []Chain -// Valid validates chain format, should consist only of uppercase letters +// Valid validates chain format, should consist only of uppercase letters. func (c Chain) Valid() error { if len(c) < 3 { return errors.New("chain id len is less than 3") @@ -41,7 +41,7 @@ func (c Chain) Valid() error { return nil } -// NewChain create a new Chain and default the siging_algo to Secp256k1 +// NewChain create a new Chain and default the siging_algo to Secp256k1. func NewChain(chainID string) (Chain, error) { chain := Chain(strings.ToUpper(chainID)) if err := chain.Valid(); err != nil { @@ -50,13 +50,13 @@ func NewChain(chainID string) (Chain, error) { return chain, nil } -// String implement fmt.Stringer +// String implement fmt.Stringer. func (c Chain) String() string { // convert it to upper case again just in case someone created a ticker via Chain("rune") return strings.ToUpper(string(c)) } -// GetGasAsset chain's base asset +// GetGasAsset chain's base asset. func (c Chain) GetGasAsset() Asset { switch c { case THORChain: diff --git a/chain/thorchain/module_bank.go b/chain/thorchain/module_bank.go index ef540809b..5d3446f12 100644 --- a/chain/thorchain/module_bank.go +++ b/chain/thorchain/module_bank.go @@ -3,26 +3,26 @@ package thorchain import ( "context" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/strangelove-ventures/interchaintest/v8/ibc" ) -// Deprecated: use BankSend instead +// Deprecated: use BankSend instead. func (tn *ChainNode) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error { return tn.BankSend(ctx, keyName, amount) } // GetBalance fetches the current balance for a specific account address and denom. -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) GetBalance(ctx context.Context, address string, denom string) (sdkmath.Int, error) { return c.BankQueryBalance(ctx, address, denom) } -// BankGetBalance is an alias for GetBalance +// BankGetBalance is an alias for GetBalance. func (c *Thorchain) BankQueryBalance(ctx context.Context, address string, denom string) (sdkmath.Int, error) { res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).Balance(ctx, &banktypes.QueryBalanceRequest{Address: address, Denom: denom}) if err != nil { @@ -31,7 +31,7 @@ func (c *Thorchain) BankQueryBalance(ctx context.Context, address string, denom return res.Balance.Amount, nil } -// AllBalances fetches an account address's balance for all denoms it holds +// AllBalances fetches an account address's balance for all denoms it holds. func (c *Thorchain) BankQueryAllBalances(ctx context.Context, address string) (types.Coins, error) { res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).AllBalances(ctx, &banktypes.QueryAllBalancesRequest{Address: address}) if err != nil { @@ -40,7 +40,7 @@ func (c *Thorchain) BankQueryAllBalances(ctx context.Context, address string) (t return res.GetBalances(), nil } -// BankDenomMetadata fetches the metadata of a specific coin denomination +// BankDenomMetadata fetches the metadata of a specific coin denomination. func (c *Thorchain) BankQueryDenomMetadata(ctx context.Context, denom string) (*banktypes.Metadata, error) { res, err := banktypes.NewQueryClient(c.GetNode().GrpcConn).DenomMetadata(ctx, &banktypes.QueryDenomMetadataRequest{Denom: denom}) if err != nil { diff --git a/chain/thorchain/module_thorchain.go b/chain/thorchain/module_thorchain.go index ad4240c34..ad0705738 100644 --- a/chain/thorchain/module_thorchain.go +++ b/chain/thorchain/module_thorchain.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "cosmossdk.io/math" - "github.com/strangelove-ventures/interchaintest/v8/ibc" + + "cosmossdk.io/math" ) // BankSend sends tokens from one account to another. diff --git a/chain/thorchain/poll.go b/chain/thorchain/poll.go index 2b813da9b..74a5e1232 100644 --- a/chain/thorchain/poll.go +++ b/chain/thorchain/poll.go @@ -5,10 +5,10 @@ import ( "errors" "fmt" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) // PollForMessage searches every transaction for a message. Must pass a coded registry capable of decoding the cosmos transaction. @@ -44,7 +44,7 @@ func PollForMessage[T any](ctx context.Context, chain *Thorchain, registry codec return bp.DoPoll(ctx, startHeight, maxHeight) } -// PollForBalance polls until the balance matches +// PollForBalance polls until the balance matches. func PollForBalance(ctx context.Context, chain *Thorchain, deltaBlocks int64, balance ibc.WalletAmount) error { h, err := chain.Height(ctx) if err != nil { diff --git a/chain/thorchain/query.go b/chain/thorchain/query.go index dcb453114..6263de0d3 100644 --- a/chain/thorchain/query.go +++ b/chain/thorchain/query.go @@ -4,9 +4,10 @@ import ( "context" "fmt" - tmtypes "github.com/cometbft/cometbft/rpc/core/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + + tmtypes "github.com/cometbft/cometbft/rpc/core/types" ) type blockClient interface { diff --git a/chain/thorchain/sidecar.go b/chain/thorchain/sidecar.go index d4a691248..c59bc1b22 100644 --- a/chain/thorchain/sidecar.go +++ b/chain/thorchain/sidecar.go @@ -7,10 +7,9 @@ import ( dockerclient "github.com/docker/docker/client" "github.com/docker/go-connections/nat" - "go.uber.org/zap" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" + "go.uber.org/zap" ) type SidecarProcesses []*SidecarProcess @@ -158,7 +157,7 @@ func (s *SidecarProcess) GetHostPorts(ctx context.Context, portIDs ...string) ([ // WriteFile accepts file contents in a byte slice and writes the contents to // the docker filesystem. relPath describes the location of the file in the -// docker volume relative to the home directory +// docker volume relative to the home directory. func (s *SidecarProcess) WriteFile(ctx context.Context, content []byte, relPath string) error { fw := dockerutil.NewFileWriter(s.logger(), s.DockerClient, s.TestName) return fw.WriteFile(ctx, s.VolumeName, relPath, content) @@ -166,7 +165,7 @@ func (s *SidecarProcess) WriteFile(ctx context.Context, content []byte, relPath // CopyFile adds a file from the host filesystem to the docker filesystem // relPath describes the location of the file in the docker volume relative to -// the home directory +// the home directory. func (s *SidecarProcess) CopyFile(ctx context.Context, srcPath, dstPath string) error { content, err := os.ReadFile(srcPath) if err != nil { diff --git a/chain/thorchain/thorchain.go b/chain/thorchain/thorchain.go index 078b6a4a3..b00d933e8 100644 --- a/chain/thorchain/thorchain.go +++ b/chain/thorchain/thorchain.go @@ -14,15 +14,6 @@ import ( "strings" "sync" - sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck - chanTypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" dockertypes "github.com/docker/docker/api/types" volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" @@ -32,6 +23,18 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" "golang.org/x/sync/errgroup" + + sdkmath "cosmossdk.io/math" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck + chanTypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/types" ) type Thorchain struct { @@ -190,12 +193,12 @@ func (c *Thorchain) AddFullNodes(ctx context.Context, configFileOverrides map[st return eg.Wait() } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) Config() ibc.ChainConfig { return c.cfg } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error { if err := c.initializeSidecars(ctx, testName, cli, networkID); err != nil { return err @@ -216,7 +219,7 @@ func (c *Thorchain) Exec(ctx context.Context, cmd []string, env []string) (stdou return c.getFullNode().Exec(ctx, cmd, env) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) GetRPCAddress() string { if c.Config().UsesCometMock() { return fmt.Sprintf("http://%s:22331", c.getFullNode().HostnameCometMock()) @@ -225,13 +228,13 @@ func (c *Thorchain) GetRPCAddress() string { return fmt.Sprintf("http://%s:26657", c.getFullNode().HostName()) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) GetAPIAddress() string { return fmt.Sprintf("http://%s:1317", "127.0.0.1") - //return fmt.Sprintf("http://%s:1317", c.getFullNode().HostName()) + // return fmt.Sprintf("http://%s:1317", c.getFullNode().HostName()) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) GetGRPCAddress() string { return fmt.Sprintf("%s:9090", c.getFullNode().HostName()) } @@ -265,17 +268,17 @@ func (c *Thorchain) HomeDir() string { return c.getFullNode().HomeDir() } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) CreateKey(ctx context.Context, keyName string) error { return c.getFullNode().CreateKey(ctx, keyName) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) RecoverKey(ctx context.Context, keyName, mnemonic string) error { return c.getFullNode().RecoverKey(ctx, keyName, mnemonic) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) GetAddress(ctx context.Context, keyName string) ([]byte, error) { b32Addr, err := c.getFullNode().AccountKeyBech32(ctx, keyName) if err != nil { @@ -287,7 +290,7 @@ func (c *Thorchain) GetAddress(ctx context.Context, keyName string) ([]byte, err // BuildWallet will return a Cosmos wallet // If mnemonic != "", it will restore using that mnemonic -// If mnemonic == "", it will create a new key +// If mnemonic == "", it will create a new key. func (c *Thorchain) BuildWallet(ctx context.Context, keyName string, mnemonic string) (ibc.Wallet, error) { if mnemonic != "" { c.log.Info("BuildWallet recovering key", zap.String("key_name", keyName)) @@ -339,17 +342,17 @@ func (c *Thorchain) BuildRelayerWallet(ctx context.Context, keyName string) (ibc return NewWallet(keyName, addrBytes, mnemonic, c.cfg), nil } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error { return c.getFullNode().BankSend(ctx, keyName, amount) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) SendFundsWithNote(ctx context.Context, keyName string, amount ibc.WalletAmount, note string) (string, error) { return c.getFullNode().BankSendWithNote(ctx, keyName, amount, note) } -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) SendIBCTransfer( ctx context.Context, channelID string, @@ -425,7 +428,7 @@ func (c *Thorchain) QueryBankMetadata(ctx context.Context, denom string) (*BankM } // ExportState exports the chain state at specific height. -// Implements Chain interface +// Implements Chain interface. func (c *Thorchain) ExportState(ctx context.Context, height int64) (string, error) { return c.getFullNode().ExportState(ctx, height) } @@ -576,7 +579,7 @@ func (c *Thorchain) NewSidecarProcess( return nil } -// creates the test node objects required for bootstrapping tests +// creates the test node objects required for bootstrapping tests. func (c *Thorchain) initializeChainNodes( ctx context.Context, testName string, @@ -653,7 +656,6 @@ func (c *Thorchain) initializeSidecars( } return nil }) - } if err := eg.Wait(); err != nil { return err @@ -781,7 +783,7 @@ func (c *Thorchain) prepNodes(ctx context.Context, genesisAmounts [][]types.Coin return eg.Wait() } -// Bootstraps the chain and starts it from genesis +// Bootstraps the chain and starts it from genesis. func (c *Thorchain) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { c.log.Info("Starting", zap.String("chain", c.Config().Name)) chainCfg := c.Config() @@ -861,7 +863,7 @@ func (c *Thorchain) Start(testName string, ctx context.Context, additionalGenesi if len(activeVals) > chainCfg.Genesis.MaxVals { c.log.Warn("Not enough validators to meet 2/3 bond threshold, increase GenesisConfig.MaxVals to reach consensus", zap.Int("required", len(activeVals)), zap.Int("max", chainCfg.Genesis.MaxVals)) - //return fmt.Errorf("too many validators required to meet bond threshold: %d, max allowed: %d: increase this limit to proceed", len(activeVals), chainCfg.Genesis.MaxVals) + // return fmt.Errorf("too many validators required to meet bond threshold: %d, max allowed: %d: increase this limit to proceed", len(activeVals), chainCfg.Genesis.MaxVals) c.NumValidators = chainCfg.Genesis.MaxVals } else { c.NumValidators = len(activeVals) @@ -979,7 +981,7 @@ func (c *Thorchain) Start(testName string, ctx context.Context, additionalGenesi zap.String("chain", exportGenesisChain), zap.String("path", exportGenesis), ) - _ = os.WriteFile(exportGenesis, genBz, 0600) + _ = os.WriteFile(exportGenesis, genBz, 0o600) } chainNodes := c.Nodes() @@ -1050,12 +1052,12 @@ func (c *Thorchain) Start(testName string, ctx context.Context, additionalGenesi return testutil.WaitForBlocks(ctx, 2, c.getFullNode()) } -// Height implements ibc.Chain +// Height implements ibc.Chain. func (c *Thorchain) Height(ctx context.Context) (int64, error) { return c.getFullNode().Height(ctx) } -// Acknowledgements implements ibc.Chain, returning all acknowledgments in block at height +// Acknowledgements implements ibc.Chain, returning all acknowledgments in block at height. func (c *Thorchain) Acknowledgements(ctx context.Context, height int64) ([]ibc.PacketAcknowledgement, error) { var acks []*chanTypes.MsgAcknowledgement err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.getFullNode().Client, height, func(msg types.Msg) bool { @@ -1088,7 +1090,7 @@ func (c *Thorchain) Acknowledgements(ctx context.Context, height int64) ([]ibc.P return ibcAcks, nil } -// Timeouts implements ibc.Chain, returning all timeouts in block at height +// Timeouts implements ibc.Chain, returning all timeouts in block at height. func (c *Thorchain) Timeouts(ctx context.Context, height int64) ([]ibc.PacketTimeout, error) { var timeouts []*chanTypes.MsgTimeout err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.getFullNode().Client, height, func(msg types.Msg) bool { @@ -1128,7 +1130,7 @@ func (c *Thorchain) FindTxs(ctx context.Context, height int64) ([]blockdb.Tx, er return fn.FindTxs(ctx, height) } -// StopAllNodes stops and removes all long running containers (validators and full nodes) +// StopAllNodes stops and removes all long running containers (validators and full nodes). func (c *Thorchain) StopAllNodes(ctx context.Context) error { var eg errgroup.Group for _, n := range c.Nodes() { @@ -1240,7 +1242,7 @@ func (c *Thorchain) StartAllValSidecars(ctx context.Context) error { } // GetTimeoutHeight returns a timeout height of 1000 blocks above the current block height. -// This function should be used when the timeout is never expected to be reached +// This function should be used when the timeout is never expected to be reached. func (c *Thorchain) GetTimeoutHeight(ctx context.Context) (clienttypes.Height, error) { height, err := c.Height(ctx) if err != nil { diff --git a/chain/thorchain/thornode.go b/chain/thorchain/thornode.go index 1e764e747..e3a968560 100644 --- a/chain/thorchain/thornode.go +++ b/chain/thorchain/thornode.go @@ -17,32 +17,33 @@ import ( "time" "github.com/avast/retry-go/v4" - tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/p2p" - rpcclient "github.com/cometbft/cometbft/rpc/client" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - coretypes "github.com/cometbft/cometbft/rpc/core/types" - libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" - sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" volumetypes "github.com/docker/docker/api/types/volume" dockerclient "github.com/docker/docker/client" "github.com/docker/go-connections/nat" "github.com/icza/dyno" + "github.com/strangelove-ventures/interchaintest/v8/blockdb" + "github.com/strangelove-ventures/interchaintest/v8/dockerutil" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" "golang.org/x/mod/semver" "golang.org/x/sync/errgroup" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "github.com/strangelove-ventures/interchaintest/v8/blockdb" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" - "github.com/strangelove-ventures/interchaintest/v8/ibc" - "github.com/strangelove-ventures/interchaintest/v8/testutil" + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + tmjson "github.com/cometbft/cometbft/libs/json" + "github.com/cometbft/cometbft/p2p" + rpcclient "github.com/cometbft/cometbft/rpc/client" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" + coretypes "github.com/cometbft/cometbft/rpc/core/types" + libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" ) type ChainNode struct { @@ -98,13 +99,13 @@ func NewChainNode(log *zap.Logger, validator bool, chain *Thorchain, dockerClien return tn } -// WithPreStartNode sets the preStartNode function for the ChainNode +// 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 +// ChainNodes is a collection of ChainNode. type ChainNodes []*ChainNode const ( @@ -119,17 +120,15 @@ const ( cometMockRawPort = "22331" ) -var ( - sentryPorts = nat.PortMap{ - nat.Port(p2pPort): {}, - nat.Port(rpcPort): {}, - nat.Port(grpcPort): {}, - nat.Port(apiPort): {}, - nat.Port(privValPort): {}, - } -) +var sentryPorts = nat.PortMap{ + nat.Port(p2pPort): {}, + nat.Port(rpcPort): {}, + nat.Port(grpcPort): {}, + nat.Port(apiPort): {}, + nat.Port(privValPort): {}, +} -// NewClient creates and assigns a new Tendermint RPC client to the ChainNode +// NewClient creates and assigns a new Tendermint RPC client to the ChainNode. func (tn *ChainNode) NewClient(addr string) error { httpClient, err := libclient.DefaultHTTPClient(addr) if err != nil { @@ -198,7 +197,7 @@ func (tn *ChainNode) NewSidecarProcess( return nil } -// CliContext creates a new Cosmos SDK client context +// CliContext creates a new Cosmos SDK client context. func (tn *ChainNode) CliContext() client.Context { cfg := tn.Chain.Config() return client.Context{ @@ -214,7 +213,7 @@ func (tn *ChainNode) CliContext() client.Context { } } -// Name of the test node container +// Name of the test node container. func (tn *ChainNode) Name() string { return fmt.Sprintf("%s-%s-%d-%s", tn.Chain.Config().ChainID, tn.NodeType(), tn.Index, dockerutil.SanitizeContainerName(tn.TestName)) } @@ -231,12 +230,12 @@ func (tn *ChainNode) ContainerID() string { return tn.containerLifecycle.ContainerID() } -// hostname of the test node container +// hostname of the test node container. func (tn *ChainNode) HostName() string { return dockerutil.CondenseHostName(tn.Name()) } -// hostname of the comet mock container +// hostname of the comet mock container. func (tn *ChainNode) HostnameCometMock() string { return tn.cometHostname } @@ -288,7 +287,7 @@ type PrivValidatorKeyFile struct { PrivKey PrivValidatorKey `json:"priv_key"` } -// Bind returns the home folder bind point for running the node +// Bind returns the home folder bind point for running the node. func (tn *ChainNode) Bind() []string { return []string{fmt.Sprintf("%s:%s", tn.VolumeName, tn.HomeDir())} } @@ -375,7 +374,7 @@ func (tn *ChainNode) SetTestConfig(ctx context.Context) error { ) } -// SetPeers modifies the config persistent_peers for a node +// SetPeers modifies the config persistent_peers for a node. func (tn *ChainNode) SetPeers(ctx context.Context, peers string) error { c := make(testutil.Toml) p2p := make(testutil.Toml) @@ -485,7 +484,7 @@ func (tn *ChainNode) FindTxs(ctx context.Context, height int64) ([]blockdb.Tx, e // with the chain node binary. func (tn *ChainNode) TxCommand(keyName string, command ...string) []string { command = append([]string{"tx"}, command...) - var gasPriceFound, gasAdjustmentFound, feesFound = false, false, false + gasPriceFound, gasAdjustmentFound, feesFound := false, false, false for i := 0; i < len(command); i++ { if command[i] == "--gas-prices" { gasPriceFound = true @@ -663,7 +662,7 @@ func CondenseMoniker(m string) string { return m[:keepLen] + "..." + m[len(m)-keepLen:] + suffix } -// InitHomeFolder initializes a home folder for the given node +// InitHomeFolder initializes a home folder for the given node. func (tn *ChainNode) InitHomeFolder(ctx context.Context) error { tn.lock.Lock() defer tn.lock.Unlock() @@ -677,7 +676,7 @@ func (tn *ChainNode) InitHomeFolder(ctx context.Context) error { // WriteFile accepts file contents in a byte slice and writes the contents to // the docker filesystem. relPath describes the location of the file in the -// docker volume relative to the home directory +// docker volume relative to the home directory. func (tn *ChainNode) WriteFile(ctx context.Context, content []byte, relPath string) error { fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName) return fw.WriteFile(ctx, tn.VolumeName, relPath, content) @@ -685,7 +684,7 @@ func (tn *ChainNode) WriteFile(ctx context.Context, content []byte, relPath stri // CopyFile adds a file from the host filesystem to the docker filesystem // relPath describes the location of the file in the docker volume relative to -// the home directory +// the home directory. func (tn *ChainNode) CopyFile(ctx context.Context, srcPath, dstPath string) error { content, err := os.ReadFile(srcPath) if err != nil { @@ -705,7 +704,7 @@ func (tn *ChainNode) ReadFile(ctx context.Context, relPath string) ([]byte, erro return gen, nil } -// CreateKey creates a key in the keyring backend test for the given node +// CreateKey creates a key in the keyring backend test for the given node. func (tn *ChainNode) CreateKey(ctx context.Context, name string) error { tn.lock.Lock() defer tn.lock.Unlock() @@ -782,7 +781,7 @@ func (tn *ChainNode) ICSVersion(ctx context.Context) string { return "" } -// AddGenesisAccount adds a genesis account for each key +// AddGenesisAccount adds a genesis account for each key. func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, genesisAmount []sdk.Coin) error { amount := "" for i, coin := range genesisAmount { @@ -817,7 +816,8 @@ func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, gene } func (tn *ChainNode) Version(ctx context.Context) (string, error) { - command := []string{tn.Chain.Config().Bin, "query", "thorchain", "version", "--output", "json", + command := []string{ + tn.Chain.Config().Bin, "query", "thorchain", "version", "--output", "json", "--home", tn.HomeDir(), } @@ -835,7 +835,8 @@ func (tn *ChainNode) Version(ctx context.Context) (string, error) { } func (tn *ChainNode) GetValidatorConsPubKey(ctx context.Context) (string, error) { - command := []string{tn.Chain.Config().Bin, "tendermint", "show-validator", + command := []string{ + tn.Chain.Config().Bin, "tendermint", "show-validator", "--home", tn.HomeDir(), } @@ -1236,7 +1237,6 @@ func (tn *ChainNode) GetBuildInformation(ctx context.Context) *BinaryBuildInform Replacement: r, ReplacementVersion: rV, } - } else { // Ex: "github.com/aaa/bbb@v0.0.0-20191008050251-8e49817e8af4" parent, version := getRepoAndVersion(dep) @@ -1534,14 +1534,14 @@ func (tn *ChainNode) RemoveContainer(ctx context.Context) error { return tn.containerLifecycle.RemoveContainer(ctx) } -// InitValidatorFiles creates the node files and signs a genesis transaction +// InitValidatorFiles creates the node files and signs a genesis transaction. func (tn *ChainNode) InitValidatorGenTx( ctx context.Context, chainType *ibc.ChainConfig, genesisAmounts []sdk.Coin, genesisSelfDelegation sdk.Coin, ) error { - //if err := tn.CreateKey(ctx, valKey); err != nil { + // if err := tn.CreateKey(ctx, valKey); err != nil { // return err //} // Thorchain will only start with 1 validator @@ -1557,7 +1557,7 @@ func (tn *ChainNode) InitValidatorGenTx( return err } return nil - //return tn.Gentx(ctx, valKey, genesisSelfDelegation) + // return tn.Gentx(ctx, valKey, genesisSelfDelegation) } func (tn *ChainNode) InitFullNodeFiles(ctx context.Context) error { @@ -1610,7 +1610,7 @@ func (tn *ChainNode) AccountKeyBech32(ctx context.Context, name string) (string, return tn.KeyBech32(ctx, name, "") } -// PeerString returns the string for connecting the nodes passed in +// PeerString returns the string for connecting the nodes passed in. func (nodes ChainNodes) PeerString(ctx context.Context) string { addrs := make([]string, len(nodes)) for i, n := range nodes { @@ -1644,7 +1644,7 @@ func (nodes ChainNodes) SidecarBifrostPeers() string { return strings.Join(addrs, ",") } -// LogGenesisHashes logs the genesis hashes for the various nodes +// LogGenesisHashes logs the genesis hashes for the various nodes. func (nodes ChainNodes) LogGenesisHashes(ctx context.Context) error { for _, n := range nodes { gen, err := n.GenesisFileContent(ctx) @@ -1701,7 +1701,7 @@ func (tn *ChainNode) QueryICA(ctx context.Context, connectionID, address string) } // GetHostAddress returns the host-accessible url for a port in the container. -// This is useful for finding the url & random host port for ports exposed via ChainConfig.ExposeAdditionalPorts +// This is useful for finding the url & random host port for ports exposed via ChainConfig.ExposeAdditionalPorts. func (tn *ChainNode) GetHostAddress(ctx context.Context, portID string) (string, error) { ports, err := tn.containerLifecycle.GetHostPorts(ctx, portID) if err != nil { diff --git a/chain/thorchain/types.go b/chain/thorchain/types.go index 243f13855..33d9be164 100644 --- a/chain/thorchain/types.go +++ b/chain/thorchain/types.go @@ -85,7 +85,7 @@ type DenomAuthorityMetadata struct { // thorchain openapi types -// InboundAddress struct for InboundAddress +// InboundAddress struct for InboundAddress. type InboundAddress struct { Chain *string `json:"chain,omitempty"` PubKey *string `json:"pub_key,omitempty"` @@ -111,7 +111,7 @@ type InboundAddress struct { DustThreshold *string `json:"dust_threshold,omitempty"` } -// LiquidityProvider struct for LiquidityProvider +// LiquidityProvider struct for LiquidityProvider. type LiquidityProvider struct { Asset string `json:"asset"` RuneAddress *string `json:"rune_address,omitempty"` @@ -131,7 +131,7 @@ type LiquidityProvider struct { LuviGrowthPct *string `json:"luvi_growth_pct,omitempty"` } -// Saver struct for Saver +// Saver struct for Saver. type Saver struct { Asset string `json:"asset"` AssetAddress string `json:"asset_address"` @@ -143,7 +143,7 @@ type Saver struct { GrowthPct string `json:"growth_pct"` } -// Pool struct for Pool +// Pool struct for Pool. type Pool struct { Asset string `json:"asset"` ShortCode *string `json:"short_code,omitempty"` @@ -185,7 +185,7 @@ type Pool struct { DerivedDepthBps string `json:"derived_depth_bps"` } -// QuoteFees struct for QuoteFees +// QuoteFees struct for QuoteFees. type QuoteFees struct { // the target asset used for all fees Asset string `json:"asset"` @@ -203,7 +203,7 @@ type QuoteFees struct { TotalBps int64 `json:"total_bps"` } -// QuoteSwapResponse struct for QuoteSwapResponse +// QuoteSwapResponse struct for QuoteSwapResponse. type QuoteSwapResponse struct { // the inbound address for the transaction on the source chain InboundAddress *string `json:"inbound_address,omitempty"` @@ -246,7 +246,7 @@ type QuoteSwapResponse struct { TotalSwapSeconds *int64 `json:"total_swap_seconds,omitempty"` } -// QuoteSaverDepositResponse struct for QuoteSaverDepositResponse +// QuoteSaverDepositResponse struct for QuoteSaverDepositResponse. type QuoteSaverDepositResponse struct { // the inbound address for the transaction on the source chain InboundAddress string `json:"inbound_address"` @@ -283,7 +283,7 @@ type QuoteSaverDepositResponse struct { ExpectedAmountDeposit string `json:"expected_amount_deposit"` } -// InboundObservedStage struct for InboundObservedStage +// InboundObservedStage struct for InboundObservedStage. type InboundObservedStage struct { // returns true if any nodes have observed the transaction (to be deprecated in favour of counts) Started *bool `json:"started,omitempty"` @@ -295,7 +295,7 @@ type InboundObservedStage struct { Completed bool `json:"completed"` } -// InboundConfirmationCountedStage struct for InboundConfirmationCountedStage +// InboundConfirmationCountedStage struct for InboundConfirmationCountedStage. type InboundConfirmationCountedStage struct { // the THORChain block height when confirmation counting began CountingStartHeight *int64 `json:"counting_start_height,omitempty"` @@ -311,13 +311,13 @@ type InboundConfirmationCountedStage struct { Completed bool `json:"completed"` } -// InboundFinalisedStage struct for InboundFinalisedStage +// InboundFinalisedStage struct for InboundFinalisedStage. type InboundFinalisedStage struct { // returns true if the inbound transaction has been finalised (THORChain agreeing it exists) Completed bool `json:"completed"` } -// StreamingStatus struct for StreamingStatus +// StreamingStatus struct for StreamingStatus. type StreamingStatus struct { // how often each swap is made, in blocks Interval int64 `json:"interval"` @@ -327,20 +327,20 @@ type StreamingStatus struct { Count int64 `json:"count"` } -// SwapStatus struct for SwapStatus +// SwapStatus struct for SwapStatus. type SwapStatus struct { // true when awaiting a swap Pending bool `json:"pending"` Streaming *StreamingStatus `json:"streaming,omitempty"` } -// SwapFinalisedStage struct for SwapFinalisedStage +// SwapFinalisedStage struct for SwapFinalisedStage. type SwapFinalisedStage struct { // (to be deprecated in favor of swap_status) returns true if an inbound transaction's swap (successful or refunded) is no longer pending Completed bool `json:"completed"` } -// OutboundDelayStage struct for OutboundDelayStage +// OutboundDelayStage struct for OutboundDelayStage. type OutboundDelayStage struct { // the number of remaining THORChain blocks the outbound will be delayed RemainingDelayBlocks *int64 `json:"remaining_delay_blocks,omitempty"` @@ -350,7 +350,7 @@ type OutboundDelayStage struct { Completed bool `json:"completed"` } -// OutboundSignedStage struct for OutboundSignedStage +// OutboundSignedStage struct for OutboundSignedStage. type OutboundSignedStage struct { // THORChain height for which the external outbound is scheduled ScheduledOutboundHeight *int64 `json:"scheduled_outbound_height,omitempty"` @@ -360,7 +360,7 @@ type OutboundSignedStage struct { Completed bool `json:"completed"` } -// TxStagesResponse struct for TxStagesResponse +// TxStagesResponse struct for TxStagesResponse. type TxStagesResponse struct { InboundObserved InboundObservedStage `json:"inbound_observed"` InboundConfirmationCounted *InboundConfirmationCountedStage `json:"inbound_confirmation_counted,omitempty"` @@ -371,14 +371,14 @@ type TxStagesResponse struct { OutboundSigned *OutboundSignedStage `json:"outbound_signed,omitempty"` } -// Coin struct for Coin +// Coin struct for Coin. type Coin struct { Asset string `json:"asset"` Amount string `json:"amount"` Decimals *int64 `json:"decimals,omitempty"` } -// Tx struct for Tx +// Tx struct for Tx. type Tx struct { Id *string `json:"id,omitempty"` Chain *string `json:"chain,omitempty"` @@ -389,7 +389,7 @@ type Tx struct { Memo *string `json:"memo,omitempty"` } -// ObservedTx struct for ObservedTx +// ObservedTx struct for ObservedTx. type ObservedTx struct { Tx Tx `json:"tx"` ObservedPubKey *string `json:"observed_pub_key,omitempty"` @@ -409,7 +409,7 @@ type ObservedTx struct { Status *string `json:"status,omitempty"` } -// TxOutItem struct for TxOutItem +// TxOutItem struct for TxOutItem. type TxOutItem struct { Chain string `json:"chain"` ToAddress string `json:"to_address"` @@ -425,7 +425,7 @@ type TxOutItem struct { CloutSpent *string `json:"clout_spent,omitempty"` } -// TxDetailsResponse struct for TxDetailsResponse +// TxDetailsResponse struct for TxDetailsResponse. type TxDetailsResponse struct { TxId *string `json:"tx_id,omitempty"` Tx ObservedTx `json:"tx"` diff --git a/chain/thorchain/wallet.go b/chain/thorchain/wallet.go index e51fc254b..13b18ec8a 100644 --- a/chain/thorchain/wallet.go +++ b/chain/thorchain/wallet.go @@ -1,12 +1,15 @@ package thorchain import ( - "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v8/ibc" + + "github.com/cosmos/cosmos-sdk/types" ) -var _ ibc.Wallet = &CosmosWallet{} -var _ User = &CosmosWallet{} +var ( + _ ibc.Wallet = &CosmosWallet{} + _ User = &CosmosWallet{} +) type CosmosWallet struct { mnemonic string @@ -28,17 +31,17 @@ func (w *CosmosWallet) KeyName() string { return w.keyName } -// Get formatted address, passing in a prefix +// Get formatted address, passing in a prefix. func (w *CosmosWallet) FormattedAddress() string { return types.MustBech32ifyAddressBytes(w.chainCfg.Bech32Prefix, w.address) } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *CosmosWallet) Mnemonic() string { return w.mnemonic } -// Get Address with chain's prefix +// Get Address with chain's prefix. func (w *CosmosWallet) Address() []byte { return w.address } diff --git a/chain/utxo/cli.go b/chain/utxo/cli.go index 84138c22f..f05557756 100644 --- a/chain/utxo/cli.go +++ b/chain/utxo/cli.go @@ -9,7 +9,7 @@ import ( "strings" ) -// Depending on the wallet version, getwalletinfo may require a created wallet name +// Depending on the wallet version, getwalletinfo may require a created wallet name. func (c *UtxoChain) GetWalletVersion(ctx context.Context, keyName string) (int, error) { var walletInfo WalletInfo var stdout []byte @@ -183,7 +183,7 @@ func (c *UtxoChain) SetAccount(ctx context.Context, addr string, keyName string) } // sendToMwebAddress is used for creating the mweb transaction needed at block 431 -// no other use case is currently supported +// no other use case is currently supported. func (c *UtxoChain) sendToMwebAddress(ctx context.Context, keyName string, addr string, amount float64) error { wallet, err := c.getWalletForUse(keyName) if err != nil { diff --git a/chain/utxo/default_configs.go b/chain/utxo/default_configs.go index cd42df4d3..d1cc3b28e 100644 --- a/chain/utxo/default_configs.go +++ b/chain/utxo/default_configs.go @@ -125,8 +125,8 @@ func DefaultDogecoinChainConfig( { Repository: "registry.gitlab.com/thorchain/devops/node-launcher", Version: "dogecoin-daemon-1.14.7", - //Repository: "coinmetrics/dogecoin", - //Version: "1.14.7", + // Repository: "coinmetrics/dogecoin", + // Version: "1.14.7", UidGid: "1000:1000", }, }, diff --git a/chain/utxo/utxo_chain.go b/chain/utxo/utxo_chain.go index bc981ce73..94091ed45 100644 --- a/chain/utxo/utxo_chain.go +++ b/chain/utxo/utxo_chain.go @@ -2,16 +2,13 @@ package utxo import ( "context" - "fmt" "io" "math" - "time" - "strconv" "strings" + "time" - sdkmath "cosmossdk.io/math" dockertypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/volume" @@ -21,6 +18,8 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" "go.uber.org/zap" + + sdkmath "cosmossdk.io/math" ) var _ ibc.Chain = &UtxoChain{} @@ -170,7 +169,8 @@ func (c *UtxoChain) pullImages(ctx context.Context, cli *dockerclient.Client) { } func (c *UtxoChain) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error { - cmd := []string{c.BinDaemon, + cmd := []string{ + c.BinDaemon, "--regtest", "-printtoconsole", "-regtest=1", @@ -386,7 +386,7 @@ func (c *UtxoChain) CreateKey(ctx context.Context, keyName string) error { return c.SetAccount(ctx, addr, keyName) } -// Get address of account, cast to a string to use +// Get address of account, cast to a string to use. func (c *UtxoChain) GetAddress(ctx context.Context, keyName string) ([]byte, error) { wallet, ok := c.KeyNameToWalletMap[keyName] if ok { diff --git a/chain/utxo/wallet.go b/chain/utxo/wallet.go index 3cacf32e0..0549cf3e2 100644 --- a/chain/utxo/wallet.go +++ b/chain/utxo/wallet.go @@ -25,17 +25,17 @@ func (w *UtxoWallet) KeyName() string { return w.keyName } -// Get formatted address, passing in a prefix +// Get formatted address, passing in a prefix. func (w *UtxoWallet) FormattedAddress() string { return w.address } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *UtxoWallet) Mnemonic() string { return "" } -// Get Address with chain's prefix +// Get Address with chain's prefix. func (w *UtxoWallet) Address() []byte { return []byte(w.address) } diff --git a/chainfactory.go b/chainfactory.go index 124b8a19d..48e46f0f5 100644 --- a/chainfactory.go +++ b/chainfactory.go @@ -1,7 +1,6 @@ package interchaintest import ( - _ "embed" "fmt" "os" "strings" @@ -17,6 +16,8 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "go.uber.org/zap" "gopkg.in/yaml.v3" + + _ "embed" ) // ChainFactory describes how to get chains for tests. @@ -49,7 +50,7 @@ var embeddedConfiguredChains []byte var logConfiguredChainsSourceOnce sync.Once -// initBuiltinChainConfig returns an ibc.ChainConfig mapping all configured chains +// initBuiltinChainConfig returns an ibc.ChainConfig mapping all configured chains. func initBuiltinChainConfig(log *zap.Logger) (map[string]ibc.ChainConfig, error) { var dat []byte var err error @@ -144,10 +145,10 @@ func buildChain(log *zap.Logger, testName string, cfg ibc.ChainConfig, numValida switch { case strings.Contains(cfg.Name, "composable"): parachains := []polkadot.ParachainConfig{{ - //Bin: "composable", + // Bin: "composable", Bin: "parachain-node", ChainID: "dev-2000", - //ChainID: "dali-dev", + // ChainID: "dali-dev", Image: cfg.Images[1], NumNodes: nf, Flags: []string{"--execution=wasm", "--wasmtime-instantiation-strategy=recreate-instance-copy-on-write"}, diff --git a/chainset.go b/chainset.go index 5bd172693..b3c6a47bb 100644 --- a/chainset.go +++ b/chainset.go @@ -56,7 +56,6 @@ func (cs *chainSet) Initialize(ctx context.Context, testName string, cli *client c := c cs.log.Info("Initializing chain", zap.String("chain_id", c.Config().ChainID)) eg.Go(func() error { - if err := c.Initialize(ctx, testName, cli, networkID); err != nil { return fmt.Errorf("failed to initialize chain %s: %w", c.Config().Name, err) } diff --git a/cmd/interchaintest/interchaintest_test.go b/cmd/interchaintest/interchaintest_test.go index c46718578..742e52e1a 100644 --- a/cmd/interchaintest/interchaintest_test.go +++ b/cmd/interchaintest/interchaintest_test.go @@ -150,7 +150,7 @@ func configureTestReporter() error { return fmt.Errorf("failed to get user home dir: %w", err) } fpath := filepath.Join(home, ".interchaintest", "reports") - err = os.MkdirAll(fpath, 0755) + err = os.MkdirAll(fpath, 0o755) if err != nil { return fmt.Errorf("mkdirall: %w", err) } diff --git a/cmd/interchaintest/matrix_test.go b/cmd/interchaintest/matrix_test.go index 98aac8892..e2630bdf4 100644 --- a/cmd/interchaintest/matrix_test.go +++ b/cmd/interchaintest/matrix_test.go @@ -1,13 +1,14 @@ package interchaintest_test import ( - _ "embed" "encoding/json" "testing" interchaintest "github.com/strangelove-ventures/interchaintest/v8" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" + + _ "embed" ) // Embed the matrix files as strings since they aren't intended to be changed. diff --git a/conformance/flush.go b/conformance/flush.go index e8d508ca7..602b0c084 100644 --- a/conformance/flush.go +++ b/conformance/flush.go @@ -5,14 +5,16 @@ import ( "fmt" "testing" - "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/relayer" "github.com/strangelove-ventures/interchaintest/v8/testreporter" "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/require" + + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/types" ) func TestRelayerFlushing(t *testing.T, ctx context.Context, cf interchaintest.ChainFactory, rf interchaintest.RelayerFactory, rep *testreporter.Reporter) { diff --git a/conformance/relayersetup.go b/conformance/relayersetup.go index e2feb36a3..2bf348275 100644 --- a/conformance/relayersetup.go +++ b/conformance/relayersetup.go @@ -5,14 +5,15 @@ import ( "fmt" "testing" - conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" - "github.com/cosmos/ibc-go/v8/modules/core/exported" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testreporter" "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" + + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + "github.com/cosmos/ibc-go/v8/modules/core/exported" ) // TestRelayerSetup contains a series of subtests that configure a relayer step-by-step. diff --git a/conformance/test.go b/conformance/test.go index 1d095551c..7842a272f 100644 --- a/conformance/test.go +++ b/conformance/test.go @@ -35,8 +35,6 @@ import ( "testing" "time" - "cosmossdk.io/math" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" @@ -47,6 +45,10 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" + + "cosmossdk.io/math" + + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ) var ( @@ -465,7 +467,7 @@ func testPacketRelaySuccess( req.True(srcFinalBalance.Equal(srcInitialBalance.Add(testCoinAmount))) req.True(dstFinalBalance.Equal(dstInitialBalance.Sub(expectedDifference))) } - //[END] assert on destination to source transfer + // [END] assert on destination to source transfer } // Ensure that a queued packet that should not be relayed is not relayed. diff --git a/contract/cosmwasm/compile.go b/contract/cosmwasm/compile.go index 710ed50bb..1f3a0b385 100644 --- a/contract/cosmwasm/compile.go +++ b/contract/cosmwasm/compile.go @@ -17,7 +17,7 @@ import ( "github.com/hashicorp/go-version" ) -// compile will compile the specified repo using the specified docker image and version +// compile will compile the specified repo using the specified docker image and version. func compile(image string, optVersion string, repoPath string) (string, error) { // Set the image to pull/use arch := "" diff --git a/contract/cosmwasm/rust_optimizer.go b/contract/cosmwasm/rust_optimizer.go index 5e7c7c2d9..07a1c6fbc 100644 --- a/contract/cosmwasm/rust_optimizer.go +++ b/contract/cosmwasm/rust_optimizer.go @@ -16,7 +16,7 @@ type Contract struct { } // NewContract return a contract struct, populated with defaults and its relative path -// relativePath is the relative path to the contract on local machine +// relativePath is the relative path to the contract on local machine. func NewContract(relativePath string) *Contract { return &Contract{ DockerImage: "cosmwasm/rust-optimizer", @@ -25,13 +25,13 @@ func NewContract(relativePath string) *Contract { } } -// WithDockerImage sets a custom docker image to use +// WithDockerImage sets a custom docker image to use. func (c *Contract) WithDockerImage(image string) *Contract { c.DockerImage = image return c } -// WithVersion sets a custom version to use +// WithVersion sets a custom version to use. func (c *Contract) WithVersion(version string) *Contract { c.Version = version return c @@ -75,7 +75,7 @@ func (c *Contract) Compile() *Contract { } // WaitForCompile will wait until compilation is complete, this can be called after chain setup -// Successful compilation will return the binary location in a channel +// Successful compilation will return the binary location in a channel. func (c *Contract) WaitForCompile() (string, error) { contractBinary := "" select { diff --git a/contract/cosmwasm/workspace_optimizer.go b/contract/cosmwasm/workspace_optimizer.go index c23e573cf..afe5c51ab 100644 --- a/contract/cosmwasm/workspace_optimizer.go +++ b/contract/cosmwasm/workspace_optimizer.go @@ -17,7 +17,7 @@ type Workspace struct { } // NewWorkspace returns a workspace struct, populated with defaults and its relative path -// relativePath is the relative path to the workspace on local machine +// relativePath is the relative path to the workspace on local machine. func NewWorkspace(relativePath string) *Workspace { return &Workspace{ DockerImage: "cosmwasm/workspace-optimizer", @@ -26,13 +26,13 @@ func NewWorkspace(relativePath string) *Workspace { } } -// WithDockerImage sets a custom docker image to use +// WithDockerImage sets a custom docker image to use. func (w *Workspace) WithDockerImage(image string) *Workspace { w.DockerImage = image return w } -// WithVersion sets a custom version to use +// WithVersion sets a custom version to use. func (w *Workspace) WithVersion(version string) *Workspace { w.Version = version return w @@ -42,7 +42,7 @@ func (w *Workspace) WithVersion(version string) *Workspace { // // cosmwasm/workspace-optimizer is the expected docker image // -// The workspace object is returned, call WaitForCompile() to get results +// The workspace object is returned, call WaitForCompile() to get results. func (w *Workspace) Compile() *Workspace { w.wasmBinariesChan = make(chan map[string]string) w.errChan = make(chan error, 1) @@ -88,7 +88,7 @@ func (w *Workspace) Compile() *Workspace { } // WaitForCompile will wait until coyympilation is complete, this can be called after chain setup -// Successful compilation will return a map of crate names to binary locations in a channel +// Successful compilation will return a map of crate names to binary locations in a channel. func (w *Workspace) WaitForCompile() (map[string]string, error) { contractBinaries := make(map[string]string) select { diff --git a/dockerutil/container_lifecycle.go b/dockerutil/container_lifecycle.go index 56f8c0135..c1728affe 100644 --- a/dockerutil/container_lifecycle.go +++ b/dockerutil/container_lifecycle.go @@ -16,9 +16,8 @@ import ( dockerclient "github.com/docker/docker/client" "github.com/docker/docker/errdefs" "github.com/docker/go-connections/nat" - "go.uber.org/zap" - "github.com/strangelove-ventures/interchaintest/v8/ibc" + "go.uber.org/zap" ) // Example Go/Cosmos-SDK panic format is `panic: bad Duration: time: invalid duration "bad"\n` diff --git a/dockerutil/file.go b/dockerutil/file.go index 78cdd5353..d2e9e5b7e 100644 --- a/dockerutil/file.go +++ b/dockerutil/file.go @@ -64,7 +64,7 @@ func CopyCoverageFromContainer(ctx context.Context, t *testing.T, client *client name := hdr.Name extractedFileName := path.Base(name) - //Only extract coverage files + // Only extract coverage files if !strings.HasPrefix(extractedFileName, "cov") { continue } diff --git a/dockerutil/filewriter.go b/dockerutil/filewriter.go index 4f3466974..3db357825 100644 --- a/dockerutil/filewriter.go +++ b/dockerutil/filewriter.go @@ -90,7 +90,7 @@ func (w *FileWriter) WriteFile(ctx context.Context, volumeName, relPath string, Name: relPath, Size: int64(len(content)), - Mode: 0600, + Mode: 0o600, // Not setting uname because the container will chown it anyway. ModTime: time.Now(), diff --git a/dockerutil/image_test.go b/dockerutil/image_test.go index de0850d92..a3d266ffd 100644 --- a/dockerutil/image_test.go +++ b/dockerutil/image_test.go @@ -69,7 +69,7 @@ func TestImage_Run(t *testing.T) { echo -n hi from stderr >> /dev/stderr ` tmpDir := t.TempDir() - err := os.WriteFile(filepath.Join(tmpDir, "test.sh"), []byte(scriptBody), 0777) + err := os.WriteFile(filepath.Join(tmpDir, "test.sh"), []byte(scriptBody), 0o777) require.NoError(t, err) opts := ContainerOptions{ diff --git a/dockerutil/keyring.go b/dockerutil/keyring.go index 9d54393bf..b6f287659 100644 --- a/dockerutil/keyring.go +++ b/dockerutil/keyring.go @@ -9,11 +9,12 @@ import ( "path" "path/filepath" + "github.com/docker/docker/client" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/docker/docker/client" ) // NewLocalKeyringFromDockerContainer copies the contents of the given container directory into a specified local directory. diff --git a/dockerutil/setup.go b/dockerutil/setup.go index b112a838a..3143d2c44 100644 --- a/dockerutil/setup.go +++ b/dockerutil/setup.go @@ -88,7 +88,7 @@ func DockerSetup(t DockerSetupTestingT) (*client.Client, string) { return cli, network.ID } -// DockerCleanup will clean up Docker containers, networks, and the other various config files generated in testing +// DockerCleanup will clean up Docker containers, networks, and the other various config files generated in testing. func DockerCleanup(t DockerSetupTestingT, cli *client.Client) func() { return func() { showContainerLogs := os.Getenv("SHOW_CONTAINER_LOGS") @@ -198,7 +198,6 @@ func PruneVolumesWithRetry(ctx context.Context, t DockerSetupTestingT, cli *clie retry.Context(ctx), retry.DelayType(retry.FixedDelay), ) - if err != nil { t.Logf("Failed to prune volumes during docker cleanup: %v", err) return @@ -232,7 +231,6 @@ func PruneNetworksWithRetry(ctx context.Context, t DockerSetupTestingT, cli *cli retry.Context(ctx), retry.DelayType(retry.FixedDelay), ) - if err != nil { t.Logf("Failed to prune networks during docker cleanup: %v", err) return diff --git a/dockerutil/strings.go b/dockerutil/strings.go index 225055b75..8921b3434 100644 --- a/dockerutil/strings.go +++ b/dockerutil/strings.go @@ -33,7 +33,7 @@ func GetHostPort(cont types.ContainerJSON, portID string) string { var chars = []byte("abcdefghijklmnopqrstuvwxyz") -// RandLowerCaseLetterString returns a lowercase letter string of given length +// RandLowerCaseLetterString returns a lowercase letter string of given length. func RandLowerCaseLetterString(length int) string { b := make([]byte, length) for i := range b { diff --git a/docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..bbce80c0a --- /dev/null +++ b/docs/CODE_OF_CONDUCT.md @@ -0,0 +1,43 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others’ private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at . All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at diff --git a/docs/envOptions.md b/docs/envOptions.md index 5c31f2e61..595286ba4 100644 --- a/docs/envOptions.md +++ b/docs/envOptions.md @@ -2,7 +2,7 @@ - `CONTAINER_LOG_TAIL`: Specifies the number of lines to display from container logs. Defaults to 50 lines. -- `ICTEST_CONFIGURED_CHAINS`: override the default configuredChains.yaml embeded config. +- `ICTEST_CONFIGURED_CHAINS`: override the default configuredChains.yaml embedded config. - `ICTEST_DEBUG`: extra debugging information for test execution. diff --git a/examples/cosmos/chain_core_test.go b/examples/cosmos/chain_core_test.go index 795ba8078..5c1162db1 100644 --- a/examples/cosmos/chain_core_test.go +++ b/examples/cosmos/chain_core_test.go @@ -198,7 +198,6 @@ func testAuth(ctx context.Context, t *testing.T, chain *cosmos.CosmosChain) { accInfo, err := chain.AuthQueryAccountInfo(ctx, govAddr) require.NoError(t, err) require.EqualValues(t, govAddr, accInfo.Address) - } // testUpgrade test the queries for upgrade information. Actual upgrades take place in other test. @@ -625,7 +624,6 @@ func testStaking(ctx context.Context, t *testing.T, chain *cosmos.CosmosChain, u require.NoError(t, err) require.NotEmpty(t, delVals) require.True(t, delVals[0].OperatorAddress == val) - }) t.Run("misc", func(t *testing.T) { diff --git a/examples/cosmos/chain_genesis_stake_test.go b/examples/cosmos/chain_genesis_stake_test.go index 138cf43c4..962213845 100644 --- a/examples/cosmos/chain_genesis_stake_test.go +++ b/examples/cosmos/chain_genesis_stake_test.go @@ -95,5 +95,4 @@ func TestChainGenesisUnequalStake(t *testing.T) { require.Equal(t, val1_stake, tokens1Int) require.Equal(t, val2_stake, tokens2Int) } - } diff --git a/examples/cosmos/chain_miscellaneous_test.go b/examples/cosmos/chain_miscellaneous_test.go index 6203fb901..de0450a70 100644 --- a/examples/cosmos/chain_miscellaneous_test.go +++ b/examples/cosmos/chain_miscellaneous_test.go @@ -414,7 +414,6 @@ func testTokenFactory(ctx context.Context, t *testing.T, chain *cosmos.CosmosCha _, err = node.TokenFactoryBurnDenomFrom(ctx, user2.KeyName(), tfDenom, 1, user.FormattedAddress()) require.NoError(t, err) validateBalance(ctx, t, chain, user, tfDenom, 0) - } func testGetGovernanceAddress(ctx context.Context, t *testing.T, chain *cosmos.CosmosChain) { diff --git a/examples/cosmos/chain_param_change_test.go b/examples/cosmos/chain_param_change_test.go index 65a6c9222..74851e8dc 100644 --- a/examples/cosmos/chain_param_change_test.go +++ b/examples/cosmos/chain_param_change_test.go @@ -47,7 +47,7 @@ func CosmosChainParamChangeTest(t *testing.T, name, version string) { enableBlockDB := false ctx, _, _, _ := interchaintest.BuildInitialChain(t, chains, enableBlockDB) - var userFunds = math.NewInt(10_000_000_000) + userFunds := math.NewInt(10_000_000_000) users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain) chainUser := users[0] diff --git a/examples/cosmos/chain_upgrade_ibc_test.go b/examples/cosmos/chain_upgrade_ibc_test.go index ebcc62c7e..321759f40 100644 --- a/examples/cosmos/chain_upgrade_ibc_test.go +++ b/examples/cosmos/chain_upgrade_ibc_test.go @@ -122,7 +122,7 @@ func CosmosChainUpgradeIBCTest(t *testing.T, chainName, initialVersion, upgradeC _ = ic.Close() }) - var userFunds = math.NewInt(10_000_000_000) + userFunds := math.NewInt(10_000_000_000) users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain) chainUser := users[0] diff --git a/examples/cosmos/cometmock_test.go b/examples/cosmos/cometmock_test.go index 75dd201da..157f5918b 100644 --- a/examples/cosmos/cometmock_test.go +++ b/examples/cosmos/cometmock_test.go @@ -94,5 +94,4 @@ func TestCometMock(t *testing.T) { endBal, err := chain.GetBalance(ctx, user.FormattedAddress(), "ujuno") require.NoError(t, err) require.EqualValues(t, initBal, endBal) - } diff --git a/examples/cosmos/sdk_boundary_test.go b/examples/cosmos/sdk_boundary_test.go index f7ff3e568..280fc3782 100644 --- a/examples/cosmos/sdk_boundary_test.go +++ b/examples/cosmos/sdk_boundary_test.go @@ -28,15 +28,15 @@ func TestSDKBoundaries(t *testing.T) { t.Parallel() - var tests = []boundarySpecs{ + tests := []boundarySpecs{ { name: "sdk 45 <-> 50", chainSpecs: []*interchaintest.ChainSpec{ { - Name: "gaia", ChainName: "gaia", Version: "v7.0.3", //sdk 0.45.6 + Name: "gaia", ChainName: "gaia", Version: "v7.0.3", // sdk 0.45.6 }, { - Name: "ibc-go-simd", ChainName: "simd-50", Version: "feat-upgrade-sdk-v0.50", //sdk 0.50 alpha + Name: "ibc-go-simd", ChainName: "simd-50", Version: "feat-upgrade-sdk-v0.50", // sdk 0.50 alpha }, }, relayerVersion: "colin-event-fix", @@ -45,10 +45,10 @@ func TestSDKBoundaries(t *testing.T) { name: "sdk 47 <-> 50", chainSpecs: []*interchaintest.ChainSpec{ { - Name: "ibc-go-simd", ChainName: "simd-47", Version: "v7.2.0", //sdk 0.47.3 + Name: "ibc-go-simd", ChainName: "simd-47", Version: "v7.2.0", // sdk 0.47.3 }, { - Name: "ibc-go-simd", ChainName: "simd-50", Version: "feat-upgrade-sdk-v0.50", //sdk 0.50 alpha + Name: "ibc-go-simd", ChainName: "simd-50", Version: "feat-upgrade-sdk-v0.50", // sdk 0.50 alpha }, }, relayerVersion: "colin-event-fix", @@ -113,8 +113,6 @@ func TestSDKBoundaries(t *testing.T) { // test IBC conformance conformance.TestChainPair(t, ctx, client, network, chain, counterpartyChain, rf, rep, r, path) - }) } - } diff --git a/examples/hyperspace/hyperspace_test.go b/examples/hyperspace/hyperspace_test.go index 615f80245..3e08fc1f2 100644 --- a/examples/hyperspace/hyperspace_test.go +++ b/examples/hyperspace/hyperspace_test.go @@ -329,7 +329,7 @@ func TestHyperspace(t *testing.T) { require.NoError(t, err) exportedState, err := cosmosChain.ExportState(ctx, int64(exportStateHeight)) require.NoError(t, err) - err = os.WriteFile("exported_state.json", []byte(exportedState), 0644) + err = os.WriteFile("exported_state.json", []byte(exportedState), 0o644) require.NoError(t, err) } diff --git a/examples/ibc/client_creation_test.go b/examples/ibc/client_creation_test.go index 274788a66..64dd11868 100644 --- a/examples/ibc/client_creation_test.go +++ b/examples/ibc/client_creation_test.go @@ -29,7 +29,7 @@ func TestCreatClient(t *testing.T) { t.Parallel() - var tests = []relayerImp{ + tests := []relayerImp{ { name: "Cosmos Relayer", relayerImp: ibc.CosmosRly, @@ -135,9 +135,7 @@ func TestCreatClient(t *testing.T) { // createClients should only create a client on source, NOT destination chain require.Equal(t, len(destClientInfoBefore), len(destClientInfoAfter), "a client was created on the destination chain") - }) } - } diff --git a/examples/ibc/ics_test.go b/examples/ibc/ics_test.go index e3271925f..104f6c387 100644 --- a/examples/ibc/ics_test.go +++ b/examples/ibc/ics_test.go @@ -53,7 +53,6 @@ func TestICS(t *testing.T) { }) } } - } func icsTest(t *testing.T, version string, rly ibc.RelayerImplementation) { diff --git a/examples/ibc/learn_ibc_test.go b/examples/ibc/learn_ibc_test.go index 548666d7d..1b583e4cb 100644 --- a/examples/ibc/learn_ibc_test.go +++ b/examples/ibc/learn_ibc_test.go @@ -73,7 +73,8 @@ func TestLearn(t *testing.T) { NetworkID: network, // BlockDatabaseFile: interchaintest.DefaultBlockDatabaseFilepath(), - SkipPathCreation: false}, + SkipPathCreation: false, + }, ), ) diff --git a/examples/ibc/wasm/wasm_ibc_test.go b/examples/ibc/wasm/wasm_ibc_test.go index 1883a6607..ea6c3ddb8 100644 --- a/examples/ibc/wasm/wasm_ibc_test.go +++ b/examples/ibc/wasm/wasm_ibc_test.go @@ -229,7 +229,6 @@ func TestWasmIbc(t *testing.T) { err = juno2Chain.QueryContract(ctx, juno2ContractAddr, queryJuno2CountMsg, &juno2PreIncrementedCountResponse) require.NoError(t, err) require.Equal(t, 1, juno2PreIncrementedCountResponse.Data.Count) - } // cw_ibc_example response data diff --git a/examples/ibc/wasm/wasm_icq_test.go b/examples/ibc/wasm/wasm_icq_test.go index bbd53080f..2e8bdccbe 100644 --- a/examples/ibc/wasm/wasm_icq_test.go +++ b/examples/ibc/wasm/wasm_icq_test.go @@ -28,11 +28,11 @@ import ( // On the sender chain, CosmWasm capability is required to instantiate/execute the smart contract. On the receiver chain, // 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("ICTEST_CONFIGURED_CHAINS", "./icq_wasm_configured_chains.yaml") + // TODO (1): force relayer to use specific versions of the chains configured in the file. + // 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. + // 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. logger := zaptest.NewLogger(t) @@ -46,7 +46,7 @@ func TestInterchainQueriesWASM(t *testing.T) { rep := testreporter.NewReporter(f) eRep := rep.RelayerExecReporter(t) ctx := context.Background() - contractFilePath := "sample_contracts/icq.wasm" //Contract that will be initialized on chain + contractFilePath := "sample_contracts/icq.wasm" // Contract that will be initialized on chain wasmImage := ibc.DockerImage{ Repository: "ghcr.io/strangelove-ventures/heighliner/wasmd", @@ -82,7 +82,8 @@ func TestInterchainQueriesWASM(t *testing.T) { GasAdjustment: 1.1, EncodingConfig: wasm.WasmEncoding(), ModifyGenesis: modifyGenesisAtPath(genesisAllowICQ, "app_state"), - }}, + }, + }, { ChainName: "receiver", NumValidators: &minVal, @@ -99,7 +100,8 @@ func TestInterchainQueriesWASM(t *testing.T) { GasAdjustment: 1.1, EncodingConfig: wasm.WasmEncoding(), ModifyGenesis: modifyGenesisAtPath(genesisAllowICQ, "app_state"), - }}, + }, + }, }) chains, err := cf.Chains(t.Name()) @@ -175,7 +177,7 @@ func TestInterchainQueriesWASM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 5, chain1, chain2) require.NoError(t, err) - //Instantiate the smart contract on the test chain, facilitating testing of ICQ WASM functionality + // Instantiate the smart contract on the test chain, facilitating testing of ICQ WASM functionality contractAddr, err := chain1CChain.InstantiateContract(ctx, chain1User.KeyName(), wasmIcqCodeId, initMessage, true) require.NoError(t, err) logger.Info("icq contract deployed", zap.String("contractAddr", contractAddr)) @@ -227,13 +229,14 @@ func TestInterchainQueriesWASM(t *testing.T) { require.NoError(t, err) logger.Info("channel", zap.String("info", fmt.Sprintf("Channel Port: %s, Channel ID: %s, Counterparty Channel ID: %s", channel.PortID, channel.ChannelID, channel.Counterparty.ChannelID))) - //Query for the balances of an account on the counterparty chain using interchain queries. - //Get the base64 encoded chain2 user address in the format required by the AllBalances query + // Query for the balances of an account on the counterparty chain using interchain queries. + // Get the base64 encoded chain2 user address in the format required by the AllBalances query chain2UserAddrQuery := fmt.Sprintf(`{"address":"%s"}`, chain2UserAddress) chain2UserAddrQueryB64 := base64.StdEncoding.EncodeToString([]byte(chain2UserAddrQuery)) // Get current block height for chain 2 - cmd := []string{chain2.Config().Bin, "status", + cmd := []string{ + chain2.Config().Bin, "status", "--node", chain2.GetRPCAddress(), "--home", chain2.HomeDir(), } @@ -243,9 +246,10 @@ func TestInterchainQueriesWASM(t *testing.T) { err = json.Unmarshal(stdout, blockHeightC2) require.NoError(t, err) - //and chain 1 + // and chain 1 // Get current block height - cmd = []string{chain1.Config().Bin, "status", + cmd = []string{ + chain1.Config().Bin, "status", "--node", chain1.GetRPCAddress(), "--home", chain1.HomeDir(), } @@ -261,7 +265,7 @@ func TestInterchainQueriesWASM(t *testing.T) { Query: msgQuery{ Timeout: 1000, Channel: channel.ChannelID, - Requests: []RequestQuery{ //can't use abci.RequestQuery since Height/Prove JSON fields are omitted which causes contract errors + Requests: []RequestQuery{ // can't use abci.RequestQuery since Height/Prove JSON fields are omitted which causes contract errors { Height: 0, Prove: false, @@ -277,7 +281,7 @@ func TestInterchainQueriesWASM(t *testing.T) { msg := string(b) logger.Info("Executing msg ->", zap.String("msg", msg)) - //Query the contract on chain 1. The contract makes an interchain query to chain 2 to get the chain 2 user's balance. + // Query the contract on chain 1. The contract makes an interchain query to chain 2 to get the chain 2 user's balance. resp, err := chain1CChain.ExecuteContract(ctx, chain1User.KeyName(), contractAddr, msg) require.NoError(t, err) require.NotNil(t, resp) @@ -287,7 +291,8 @@ func TestInterchainQueriesWASM(t *testing.T) { require.NoError(t, err) // Check the results from the interchain query above. - cmd = []string{chain1.Config().Bin, "query", "wasm", "contract-state", "all", contractAddr, + cmd = []string{ + chain1.Config().Bin, "query", "wasm", "contract-state", "all", contractAddr, "--node", chain1.GetRPCAddress(), "--home", chain1.HomeDir(), "--chain-id", chain1.Config().ChainID, @@ -329,8 +334,8 @@ func FirstWithPort(channels []ibc.ChannelOutput, port string) *ibc.ChannelOutput type RequestQuery struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height"` //do NOT 'omitempty' for JSON field or contract queries will error - Prove bool `protobuf:"varint,4,opt,name=prove,proto3" json:"prove"` //do NOT 'omitempty' for JSON field or contract queries will error + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height"` // do NOT 'omitempty' for JSON field or contract queries will error + Prove bool `protobuf:"varint,4,opt,name=prove,proto3" json:"prove"` // do NOT 'omitempty' for JSON field or contract queries will error } type msgQuery struct { @@ -365,7 +370,7 @@ func modifyGenesisAtPath(insertedBlock map[string]interface{}, key string) func( return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) } - //Get the section of the genesis file under the given key (e.g. "app_state") + // Get the section of the genesis file under the given key (e.g. "app_state") genesisBlockI, ok := g[key] if !ok { return nil, fmt.Errorf("genesis json does not have top level key: %s", key) diff --git a/examples/penumbra/penumbra_ibc_test.go b/examples/penumbra/penumbra_ibc_test.go index 681444551..366ea6e88 100644 --- a/examples/penumbra/penumbra_ibc_test.go +++ b/examples/penumbra/penumbra_ibc_test.go @@ -113,7 +113,7 @@ func TestPenumbraToPenumbraIBC(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - panic(fmt.Errorf("an error occured while stopping the relayer: %s", err)) + panic(fmt.Errorf("an error occurred while stopping the relayer: %s", err)) } }, ) @@ -373,7 +373,7 @@ func TestPenumbraToCosmosIBC(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - panic(fmt.Errorf("an error occured while stopping the relayer: %s", err)) + panic(fmt.Errorf("an error occurred while stopping the relayer: %s", err)) } }, ) diff --git a/examples/polkadot/polkadot_chain_test.go b/examples/polkadot/polkadot_chain_test.go index 15acf2178..689f3d7e2 100644 --- a/examples/polkadot/polkadot_chain_test.go +++ b/examples/polkadot/polkadot_chain_test.go @@ -87,7 +87,7 @@ func TestPolkadotComposableChainStart(t *testing.T) { PARACHAIN_DEFAULT_AMOUNT := math.NewInt(1_152_921_504_606_847_000) RELAYCHAIN_DEFAULT_AMOUNT := math.NewInt(1_100_000_000_000_000_000) FAUCET_AMOUNT := math.NewInt(100_000_000_000_000_000) // set in interchain.go/global - //RELAYER_AMOUNT := 1_000_000_000_000 // set in interchain.go/global + // RELAYER_AMOUNT := 1_000_000_000_000 // set in interchain.go/global // Check the faucet amounts polkadotFaucetAddress, err := polkadotChain.GetAddress(ctx, "faucet") diff --git a/examples/polkadot/push_wasm_client_code_test.go b/examples/polkadot/push_wasm_client_code_test.go index 2233b1f8b..8134ac0f8 100644 --- a/examples/polkadot/push_wasm_client_code_test.go +++ b/examples/polkadot/push_wasm_client_code_test.go @@ -57,36 +57,37 @@ func TestPushWasmClientCode(t *testing.T) { rpcOverrides["max_header_bytes"] = 2_100_000 configTomlOverrides["rpc"] = rpcOverrides - //mempoolOverrides := make(testutil.Toml) - //mempoolOverrides["max_tx_bytes"] = 6000000 - //configTomlOverrides["mempool"] = mempoolOverrides + // mempoolOverrides := make(testutil.Toml) + // mempoolOverrides["max_tx_bytes"] = 6000000 + // configTomlOverrides["mempool"] = mempoolOverrides configFileOverrides["config/app.toml"] = appTomlOverrides configFileOverrides["config/config.toml"] = configTomlOverrides cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ - {ChainConfig: ibc.ChainConfig{ - Type: "cosmos", - Name: "ibc-go-simd", - ChainID: "simd", - Images: []ibc.DockerImage{ - { - Repository: "ghcr.io/strangelove-ventures/heighliner/ibc-go-simd", - Version: "feat-wasm-clients", - UidGid: "1025:1025", + { + ChainConfig: ibc.ChainConfig{ + Type: "cosmos", + Name: "ibc-go-simd", + ChainID: "simd", + Images: []ibc.DockerImage{ + { + Repository: "ghcr.io/strangelove-ventures/heighliner/ibc-go-simd", + Version: "feat-wasm-clients", + UidGid: "1025:1025", + }, }, + Bin: "simd", + Bech32Prefix: "cosmos", + Denom: "stake", + GasPrices: "0.00stake", + GasAdjustment: 1.3, + TrustingPeriod: "504h", + // EncodingConfig: WasmClientEncoding(), + NoHostMount: true, + ConfigFileOverrides: configFileOverrides, + ModifyGenesis: modifyGenesisShortProposals(votingPeriod, maxDepositPeriod), }, - Bin: "simd", - Bech32Prefix: "cosmos", - Denom: "stake", - GasPrices: "0.00stake", - GasAdjustment: 1.3, - TrustingPeriod: "504h", - //EncodingConfig: WasmClientEncoding(), - NoHostMount: true, - ConfigFileOverrides: configFileOverrides, - ModifyGenesis: modifyGenesisShortProposals(votingPeriod, maxDepositPeriod), - }, }, }) diff --git a/examples/polkadot/substrate_cosmos_ibc_test.go b/examples/polkadot/substrate_cosmos_ibc_test.go index 90c842687..6f6c0bde9 100644 --- a/examples/polkadot/substrate_cosmos_ibc_test.go +++ b/examples/polkadot/substrate_cosmos_ibc_test.go @@ -38,8 +38,8 @@ func TestSubstrateToCosmosIBC(t *testing.T) { // Get both chains cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { - //Name: "composable", - //Version: "seunlanlege/centauri-polkadot:v0.9.27,seunlanlege/centauri-parachain:v0.9.27", + // Name: "composable", + // Version: "seunlanlege/centauri-polkadot:v0.9.27,seunlanlege/centauri-parachain:v0.9.27", ChainConfig: ibc.ChainConfig{ Type: "polkadot", Name: "composable", @@ -84,9 +84,9 @@ func TestSubstrateToCosmosIBC(t *testing.T) { GasPrices: "0.00stake", GasAdjustment: 1.3, TrustingPeriod: "504h", - //EncodingConfig: WasmClientEncoding(), + // EncodingConfig: WasmClientEncoding(), NoHostMount: true, - //ConfigFileOverrides: configFileOverrides, + // ConfigFileOverrides: configFileOverrides, }, /* ChainName: "gaia", @@ -106,9 +106,9 @@ func TestSubstrateToCosmosIBC(t *testing.T) { zaptest.NewLogger(t), relayer.StartupFlags("-b", "100"), // These two fields are used to pass in a custom Docker image built locally - //relayer.ImagePull(false), + // relayer.ImagePull(false), relayer.CustomDockerImage("ghcr.io/composablefi/relayer", "sub-create-client", "100:1000"), - //relayer.CustomDockerImage("go-relayer", "local", "100:1000"), + // relayer.CustomDockerImage("go-relayer", "local", "100:1000"), ).Build(t, client, network) // Build the network; spin up the chains and configure the relayer @@ -135,9 +135,9 @@ func TestSubstrateToCosmosIBC(t *testing.T) { })) // If necessary you can wait for x number of blocks to pass before taking some action - //blocksToWait := 10 - //err = testutil.WaitForBlocks(ctx, blocksToWait, composable) - //require.NoError(t, err) + // blocksToWait := 10 + // err = testutil.WaitForBlocks(ctx, blocksToWait, composable) + // require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 2000, simd) require.NoError(t, err) // Generate a new IBC path between the chains diff --git a/examples/thorchain/contracts/lib/forge-std/src/Vm.sol b/examples/thorchain/contracts/lib/forge-std/src/Vm.sol index 04d8db79e..16a14e2fd 100644 --- a/examples/thorchain/contracts/lib/forge-std/src/Vm.sol +++ b/examples/thorchain/contracts/lib/forge-std/src/Vm.sol @@ -531,7 +531,7 @@ interface VmSafe { /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of :: where and parts are optional. - /// Additionaly accepts abi-encoded constructor arguments. + /// Additionally accepts abi-encoded constructor arguments. function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress); diff --git a/examples/thorchain/features/arb.go b/examples/thorchain/features/arb.go index c6eafe4ee..c75d5b766 100644 --- a/examples/thorchain/features/arb.go +++ b/examples/thorchain/features/arb.go @@ -170,7 +170,7 @@ func Arb( } else { fmt.Println("No arb error") } - //require.NoError(t, err) + // require.NoError(t, err) time.Sleep(time.Second) // Deposit already wait 2 blocks, ~4 seconds } diff --git a/examples/thorchain/features/helpers.go b/examples/thorchain/features/helpers.go index f8d3206f4..971250e2f 100644 --- a/examples/thorchain/features/helpers.go +++ b/examples/thorchain/features/helpers.go @@ -100,7 +100,6 @@ func PollForSaver(ctx context.Context, thorchain *tc.Thorchain, deltaBlocks int6 if strings.EqualFold(saver.AssetAddress, exoUser.FormattedAddress()) { return saver, nil } - } time.Sleep(time.Second) // rate limit return tc.Saver{}, fmt.Errorf("saver took longer than %d blocks to show", deltaBlocks) @@ -128,7 +127,6 @@ func PollForEjectedSaver(ctx context.Context, thorchain *tc.Thorchain, deltaBloc time.Sleep(time.Second) // rate limit return saver, fmt.Errorf("saver took longer than %d blocks to eject", deltaBlocks) } - } return tc.Saver{}, nil } diff --git a/examples/thorchain/thorchain_test.go b/examples/thorchain/thorchain_test.go index 60b47caa0..26c866853 100644 --- a/examples/thorchain/thorchain_test.go +++ b/examples/thorchain/thorchain_test.go @@ -124,6 +124,6 @@ func TestThorchainSim(t *testing.T) { } require.NoError(t, eg.Wait()) - //err = testutil.WaitForBlocks(ctx, 300, thorchain) - //require.NoError(t, err, "thorchain failed to make blocks") + // err = testutil.WaitForBlocks(ctx, 300, thorchain) + // require.NoError(t, err, "thorchain failed to make blocks") } diff --git a/examples/utxo/start_test.go b/examples/utxo/start_test.go index d8f8bcc56..85788199f 100644 --- a/examples/utxo/start_test.go +++ b/examples/utxo/start_test.go @@ -18,7 +18,6 @@ import ( ) func TestUtxo(t *testing.T) { - if testing.Short() { t.Skip() } diff --git a/ibc/chain.go b/ibc/chain.go index d7d11cd74..b6f4d4b3f 100644 --- a/ibc/chain.go +++ b/ibc/chain.go @@ -3,8 +3,9 @@ package ibc import ( "context" - "cosmossdk.io/math" "github.com/docker/docker/client" + + "cosmossdk.io/math" ) type Chain interface { diff --git a/ibc/packet.go b/ibc/packet.go index 85d9ece88..1b018cd87 100644 --- a/ibc/packet.go +++ b/ibc/packet.go @@ -5,15 +5,16 @@ import ( "fmt" "reflect" - host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "go.uber.org/multierr" + + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" ) type Nanoseconds uint64 // Packet is a packet sent over an IBC channel as defined in ICS-4. // See: https://github.com/cosmos/ibc/blob/52a9094a5bc8c5275e25c19d0b2d9e6fd80ba31c/spec/core/ics-004-channel-and-packet-semantics/README.md -// Proto defined at: github.com/cosmos/ibc-go/v3@v3.0.0/proto/ibc/core/channel/v1/tx.proto +// Proto defined at: github.com/cosmos/ibc-go/v3@v3.0.0/proto/ibc/core/channel/v1/tx.proto. type Packet struct { Sequence uint64 // the order of sends and receives, where a packet with an earlier sequence number must be sent and received before a packet with a later sequence number SourcePort string // the port on the sending chain diff --git a/ibc/relayer.go b/ibc/relayer.go index 6589796ef..ac337ba1c 100644 --- a/ibc/relayer.go +++ b/ibc/relayer.go @@ -276,7 +276,7 @@ func (o Order) Validate() error { // CreateClientOptions contains the configuration for creating a client. -// a zero value is the same as not specifying the flag and will use the relayer defaults +// a zero value is the same as not specifying the flag and will use the relayer defaults. type CreateClientOptions struct { TrustingPeriod string TrustingPeriodPercentage int64 // only available for Go Relayer @@ -286,7 +286,7 @@ type CreateClientOptions struct { // DefaultClientOpts returns the default settings for creating clients. -// empty values will use the relayer defaults +// empty values will use the relayer defaults. func DefaultClientOpts() CreateClientOptions { return CreateClientOptions{} } diff --git a/ibc/relayer_test.go b/ibc/relayer_test.go index 5d98a6cd4..779be0836 100644 --- a/ibc/relayer_test.go +++ b/ibc/relayer_test.go @@ -3,8 +3,9 @@ package ibc import ( "testing" - chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/stretchr/testify/require" + + chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) func TestChannelOptsConfigured(t *testing.T) { diff --git a/ibc/types.go b/ibc/types.go index d99699774..2524c5cd6 100644 --- a/ibc/types.go +++ b/ibc/types.go @@ -9,13 +9,16 @@ import ( "strconv" "strings" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module/testutil" - ibcexported "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/google/go-cmp/cmp" + + "cosmossdk.io/math" + + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module/testutil" ) // ChainConfig defines the chain parameters requires to run an interchaintest testnet for a chain. diff --git a/interchain.go b/interchain.go index 95d09108a..b6ef8a1b0 100644 --- a/interchain.go +++ b/interchain.go @@ -5,13 +5,14 @@ import ( "fmt" "math" - sdkmath "cosmossdk.io/math" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testreporter" "go.uber.org/zap" "golang.org/x/sync/errgroup" + + sdkmath "cosmossdk.io/math" ) // Interchain represents a full IBC network, encompassing a collection of diff --git a/interchain_builder.go b/interchain_builder.go index 11a5bce3f..31c6f539b 100644 --- a/interchain_builder.go +++ b/interchain_builder.go @@ -4,8 +4,6 @@ import ( "context" "testing" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v8/ibc" @@ -13,6 +11,9 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testreporter" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module/testutil" ) type codecRegistry func(registry codectypes.InterfaceRegistry) diff --git a/interchain_test.go b/interchain_test.go index 9d7062759..a6ceadca4 100644 --- a/interchain_test.go +++ b/interchain_test.go @@ -6,13 +6,6 @@ import ( "testing" "time" - "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v8/ibc" @@ -23,8 +16,17 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zaptest" + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" ) func TestInterchain_DuplicateChain_CosmosRly(t *testing.T) { diff --git a/interchaintest.go b/interchaintest.go index 6d999afbe..0da14cfbd 100644 --- a/interchaintest.go +++ b/interchaintest.go @@ -6,14 +6,14 @@ import ( "path/filepath" ) -// CreateLogFile creates a file with name in dir $HOME/.interchaintest/logs/ +// CreateLogFile creates a file with name in dir $HOME/.interchaintest/logs/. func CreateLogFile(name string) (*os.File, error) { home, err := os.UserHomeDir() if err != nil { return nil, fmt.Errorf("user home dir: %w", err) } fpath := filepath.Join(home, ".interchaintest", "logs") - err = os.MkdirAll(fpath, 0755) + err = os.MkdirAll(fpath, 0o755) if err != nil { return nil, fmt.Errorf("mkdirall: %w", err) } diff --git a/local-interchain/cmd/local-ic/interaction.go b/local-interchain/cmd/local-ic/interaction.go index b58c81de6..0d2e8a0f3 100644 --- a/local-interchain/cmd/local-ic/interaction.go +++ b/local-interchain/cmd/local-ic/interaction.go @@ -37,7 +37,6 @@ var interactCmd = &cobra.Command{ return GetFiles(), cobra.ShellCompDirectiveNoFileComp }, Run: func(cmd *cobra.Command, args []string) { - ah := &handlers.ActionHandler{ ChainId: args[0], Action: args[1], diff --git a/local-interchain/cmd/local-ic/root.go b/local-interchain/cmd/local-ic/root.go index 7c44f4f66..60c4cfc89 100644 --- a/local-interchain/cmd/local-ic/root.go +++ b/local-interchain/cmd/local-ic/root.go @@ -9,10 +9,8 @@ import ( "github.com/spf13/cobra" ) -var ( - // This must be global for the Makefile to build properly (ldflags). - MakeFileInstallDirectory string -) +// This must be global for the Makefile to build properly (ldflags). +var MakeFileInstallDirectory string var rootCmd = &cobra.Command{ Use: "local-ic", diff --git a/local-interchain/interchain/genesis.go b/local-interchain/interchain/genesis.go index 2d34f5975..a0440740f 100644 --- a/local-interchain/interchain/genesis.go +++ b/local-interchain/interchain/genesis.go @@ -26,7 +26,6 @@ func AddGenesisKeysToKeyring(ctx context.Context, config *types.Config, chains [ default: continue } - } } @@ -54,7 +53,6 @@ func PostStartupCommands(ctx context.Context, config *types.Config, chains []ibc log.Println("Startup command output", chainObj.Config().ChainID, cmd, string(output)) } } - } } @@ -83,7 +81,6 @@ func SetupGenesisWallets(config *types.Config, chains []ibc.Chain) map[ibc.Chain default: continue } - } return additionalWallets } diff --git a/local-interchain/interchain/handlers/chain_registry.go b/local-interchain/interchain/handlers/chain_registry.go index b98ac522e..652e5e85a 100644 --- a/local-interchain/interchain/handlers/chain_registry.go +++ b/local-interchain/interchain/handlers/chain_registry.go @@ -5,7 +5,7 @@ import ( "os" ) -// If the chain_registry.json file is found within the current running directory, show it as an enpoint. +// If the chain_registry.json file is found within the current running directory, show it as an endpoint. // Used in: spawn type chainRegistry struct { @@ -30,5 +30,4 @@ func (cr chainRegistry) GetChainRegistry(w http.ResponseWriter, r *http.Request) if _, err := w.Write(cr.DataJSON); err != nil { http.Error(w, "failed to write response", http.StatusInternalServerError) } - } diff --git a/local-interchain/interchain/logs.go b/local-interchain/interchain/logs.go index 00c46dee6..9ec2ba3b3 100644 --- a/local-interchain/interchain/logs.go +++ b/local-interchain/interchain/logs.go @@ -23,7 +23,7 @@ func WriteRunningChains(configsDir string, bz []byte) { } file := filepath.Join(path, "logs.json") - _ = os.WriteFile(file, bz, 0644) + _ = os.WriteFile(file, bz, 0o644) } func DumpChainsInfoToLogs(configDir string, config *types.Config, chains []ibc.Chain, connections []types.IBCChannel) { @@ -35,7 +35,6 @@ func DumpChainsInfoToLogs(configDir string, config *types.Config, chains []ibc.C // Iterate chain config & get the ibc chain's to save data to logs. for idx, chain := range config.Chains { - switch chains[idx].(type) { case *cosmos.CosmosChain: chainObj := chains[idx].(*cosmos.CosmosChain) diff --git a/local-interchain/interchain/router/router.go b/local-interchain/interchain/router/router.go index c93bc3b87..3694ed634 100644 --- a/local-interchain/interchain/router/router.go +++ b/local-interchain/interchain/router/router.go @@ -99,7 +99,6 @@ func getAllMethods(r mux.Router) []Route { }) return nil }) - if err != nil { panic(err) } diff --git a/local-interchain/interchain/types/chain_builder.go b/local-interchain/interchain/types/chain_builder.go index ba7ae4939..79e423e3b 100644 --- a/local-interchain/interchain/types/chain_builder.go +++ b/local-interchain/interchain/types/chain_builder.go @@ -178,7 +178,7 @@ func (c *Chain) SaveJSON(filePath string) error { return err } - return os.WriteFile(filePath, bz, 0777) + return os.WriteFile(filePath, bz, 0o777) } func (c *Chain) SaveYAML(filePath string) error { @@ -190,7 +190,7 @@ func (c *Chain) SaveYAML(filePath string) error { return err } - return os.WriteFile(filePath, bz, 0777) + return os.WriteFile(filePath, bz, 0o777) } func BaseHostPortOverride() map[string]string { diff --git a/local-interchain/interchain/types/chains_test.go b/local-interchain/interchain/types/chains_test.go index cde3730ce..7c820a2e3 100644 --- a/local-interchain/interchain/types/chains_test.go +++ b/local-interchain/interchain/types/chains_test.go @@ -34,5 +34,4 @@ func TestChainsGeneration(t *testing.T) { require.NoError(t, NewChainsConfig(hub, hub2, juno1, osmo1).SaveJSON("chains/gen-4-ibc.json")) }) - } diff --git a/local-interchain/interchain/types/types.go b/local-interchain/interchain/types/types.go index 6235fa426..579a42e90 100644 --- a/local-interchain/interchain/types/types.go +++ b/local-interchain/interchain/types/types.go @@ -146,7 +146,7 @@ func NewChainsConfig(chains ...*Chain) ChainsConfig { // SaveJSON saves the chains config to a file. func (cfg ChainsConfig) SaveJSON(file string) error { - if err := os.MkdirAll(filepath.Dir(file), 0777); err != nil { + if err := os.MkdirAll(filepath.Dir(file), 0o777); err != nil { return fmt.Errorf("failed to create directory: %w", err) } @@ -155,7 +155,7 @@ func (cfg ChainsConfig) SaveJSON(file string) error { return fmt.Errorf("failed to marshal chains config: %w", err) } - return os.WriteFile(file, bz, 0777) + return os.WriteFile(file, bz, 0o777) } // SaveYAML saves the chains config to a file. @@ -165,7 +165,7 @@ func (cfg ChainsConfig) SaveYAML(file string) error { return fmt.Errorf("failed to marshal chains config: %w", err) } - return os.WriteFile(file, bz, 0777) + return os.WriteFile(file, bz, 0o777) } // MainLogs is the main runtime log file of the application. diff --git a/mocktesting/t.go b/mocktesting/t.go index 85ff58bcb..ac3ef160d 100644 --- a/mocktesting/t.go +++ b/mocktesting/t.go @@ -8,7 +8,7 @@ import ( // T satisfies a subset of testing.TB useful for tests around how interchaintest interacts with instances of testing.T. // -// The methods that are unique to T are RunCleanups and Simulate +// The methods that are unique to T are RunCleanups and Simulate. type T struct { name string diff --git a/relayer/docker.go b/relayer/docker.go index 7db3a95fb..6a3aba88a 100644 --- a/relayer/docker.go +++ b/relayer/docker.go @@ -13,11 +13,10 @@ import ( volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" - "go.uber.org/zap" - "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" + "go.uber.org/zap" ) const ( @@ -148,7 +147,7 @@ func (r *DockerRelayer) ReadFileFromHomeDir(ctx context.Context, relativePath st return bytes, nil } -// Modify a toml config file in relayer home directory +// Modify a toml config file in relayer home directory. func (r *DockerRelayer) ModifyTomlConfigFile(ctx context.Context, relativePath string, modification testutil.Toml) error { return testutil.ModifyTomlConfigFile(ctx, r.log, r.client, r.testName, r.volumeName, relativePath, modification) } diff --git a/relayer/hermes/hermes_commander.go b/relayer/hermes/hermes_commander.go index add6400e1..0e8f8369e 100644 --- a/relayer/hermes/hermes_commander.go +++ b/relayer/hermes/hermes_commander.go @@ -71,7 +71,6 @@ func (c commander) ParseGetConnectionsOutput(stdout, stderr string) (ibc.Connect var outputs ibc.ConnectionOutputs for _, r := range queryResult.Result { - var versions []*ibcexported.Version for _, v := range r.ConnectionEnd.Versions { versions = append(versions, &ibcexported.Version{ diff --git a/relayer/hermes/hermes_relayer.go b/relayer/hermes/hermes_relayer.go index 47f7f4577..ab87ebbae 100644 --- a/relayer/hermes/hermes_relayer.go +++ b/relayer/hermes/hermes_relayer.go @@ -29,7 +29,7 @@ const ( var ( _ ibc.Relayer = &Relayer{} // parseRestoreKeyOutputPattern extracts the address from the hermes output. - // SUCCESS Restored key 'g2-2' (cosmos1czklnpzwaq3hfxtv6ne4vas2p9m5q3p3fgkz8e) on chain g2-2 + // SUCCESS Restored key 'g2-2' (cosmos1czklnpzwaq3hfxtv6ne4vas2p9m5q3p3fgkz8e) on chain g2-2. parseRestoreKeyOutputPattern = regexp.MustCompile(`\((.*)\)`) ) diff --git a/relayer/hermes/hermes_wallet.go b/relayer/hermes/hermes_wallet.go index 8d02c62a6..053e34b90 100644 --- a/relayer/hermes/hermes_wallet.go +++ b/relayer/hermes/hermes_wallet.go @@ -31,12 +31,12 @@ func (w *Wallet) FormattedAddress() string { return w.address } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *Wallet) Mnemonic() string { return w.mnemonic } -// Get Address +// Get Address. func (w *Wallet) Address() []byte { return []byte(w.address) } diff --git a/relayer/hyperspace/hyperspace_commander.go b/relayer/hyperspace/hyperspace_commander.go index 6ce5b3f02..8c7e4aaca 100644 --- a/relayer/hyperspace/hyperspace_commander.go +++ b/relayer/hyperspace/hyperspace_commander.go @@ -6,13 +6,14 @@ import ( "fmt" "path" - ibcexported "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" - types23 "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" "github.com/misko9/go-substrate-rpc-client/v4/signature" "github.com/pelletier/go-toml/v2" "github.com/strangelove-ventures/interchaintest/v8/chain/polkadot" "github.com/strangelove-ventures/interchaintest/v8/ibc" "go.uber.org/zap" + + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + types23 "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" ) // hyperspaceCommander satisfies relayer.RelayerCommander. @@ -43,14 +44,14 @@ func (hyperspaceCommander) DockerUser() string { func (c *hyperspaceCommander) AddChainConfiguration(containerFilePath, homeDir string) []string { fmt.Println("[hyperspace] AddChainConfiguration ", containerFilePath, homeDir) - //c.chainConfigPaths = append(c.chainConfigPaths, containerFilePath) + // c.chainConfigPaths = append(c.chainConfigPaths, containerFilePath) return []string{ "hyperspace", "-h", } } -// Hyperspace doesn't not have this functionality +// Hyperspace doesn't not have this functionality. func (hyperspaceCommander) AddKey(chainID, keyName, coinType, signingAlgorithm, homeDir string) []string { panic("[AddKey] Do not call me") } @@ -101,7 +102,7 @@ func (c *hyperspaceCommander) CreateClients(pathName string, opts ibc.CreateClie } } -// TODO: Implement if available in hyperspace relayer +// TODO: Implement if available in hyperspace relayer. func (hyperspaceCommander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { panic("[CreateClient] Not Implemented") } @@ -126,12 +127,12 @@ func (c *hyperspaceCommander) CreateConnections(pathName, homeDir string) []stri } } -// Hyperspace doesn't not have this functionality +// Hyperspace doesn't not have this functionality. func (hyperspaceCommander) FlushAcknowledgements(pathName, channelID, homeDir string) []string { panic("[FlushAcknowledgements] Do not call me") } -// Hyperspace doesn't not have this functionality +// Hyperspace doesn't not have this functionality. func (hyperspaceCommander) FlushPackets(pathName, channelID, homeDir string) []string { panic("[FlushPackets] Do not call me") } @@ -152,14 +153,13 @@ func (c *hyperspaceCommander) GeneratePath(srcChainID, dstChainID, pathName, hom return []string{"true"} } -// Hyperspace does not have paths, just two configs +// Hyperspace does not have paths, just two configs. func (hyperspaceCommander) UpdatePath(pathName, homeDir string, opts ibc.PathUpdateOptions) []string { panic("[UpdatePath] Do not call me") - } // Prints chain config which is populated by hyperspace -// Ideally, there should be a command from hyperspace to get this output +// Ideally, there should be a command from hyperspace to get this output. func (hyperspaceCommander) GetChannels(chainID, homeDir string) []string { fmt.Println("[hyperspace] Get Channels") configFilePath := path.Join(homeDir, chainID+".config") @@ -170,7 +170,7 @@ func (hyperspaceCommander) GetChannels(chainID, homeDir string) []string { } // Prints chain config which is populated by hyperspace -// Ideally, there should be a command from hyperspace to get this output +// Ideally, there should be a command from hyperspace to get this output. func (hyperspaceCommander) GetConnections(chainID, homeDir string) []string { fmt.Println("[hyperspace] Get Connections") configFilePath := path.Join(homeDir, chainID+".config") @@ -181,7 +181,7 @@ func (hyperspaceCommander) GetConnections(chainID, homeDir string) []string { } // Prints chain config which is populated by hyperspace -// Ideally, there should be a command from hyperspace to get this output +// Ideally, there should be a command from hyperspace to get this output. func (hyperspaceCommander) GetClients(chainID, homeDir string) []string { fmt.Println("[hyperspace] Get Clients") configFilePath := path.Join(homeDir, chainID+".config") @@ -191,18 +191,18 @@ func (hyperspaceCommander) GetClients(chainID, homeDir string) []string { } } -// Hyperspace does not have link cmd, call create clients, create connection, and create channel +// Hyperspace does not have link cmd, call create clients, create connection, and create channel. func (hyperspaceCommander) LinkPath(pathName, homeDir string, channelOpts ibc.CreateChannelOptions, clientOpt ibc.CreateClientOptions) []string { panic("[LinkPath] Do not use me") } // There is no hyperspace call to restore the key, so this can't return an executable. -// HyperspaceRelayer's RestoreKey will restore the key in the chain's config file +// HyperspaceRelayer's RestoreKey will restore the key in the chain's config file. func (hyperspaceCommander) RestoreKey(chainID, bech32Prefix, coinType, signingAlgorithm, mnemonic, homeDir string) []string { panic("[RestoreKey] Do not use me") } -// hyperspace can only start 1 path +// hyperspace can only start 1 path. func (c *hyperspaceCommander) StartRelayer(homeDir string, pathNames ...string) []string { fmt.Println("[hyperspace] StartRelayer", homeDir, pathNames) if len(pathNames) != 1 { @@ -225,7 +225,7 @@ func (c *hyperspaceCommander) StartRelayer(homeDir string, pathNames ...string) } } -// Hyperspace doesn't not have this functionality +// Hyperspace doesn't not have this functionality. func (hyperspaceCommander) UpdateClients(pathName, homeDir string) []string { panic("[UpdateClients] Do not use me") } @@ -249,13 +249,13 @@ func (hyperspaceCommander) DefaultContainerVersion() string { } // There is no hyperspace call to add key, so there is no stdout to parse. -// DockerRelayer's RestoreKey will restore the key in the chain's config file +// DockerRelayer's RestoreKey will restore the key in the chain's config file. func (hyperspaceCommander) ParseAddKeyOutput(stdout, stderr string) (ibc.Wallet, error) { panic("[ParseAddKeyOutput] Do not call me") } // There is no hyperspace call to restore the key, so there is no stdout to parse. -// DockerRelayer's RestoreKey will restore the key in the chain's config file +// DockerRelayer's RestoreKey will restore the key in the chain's config file. func (hyperspaceCommander) ParseRestoreKeyOutput(stdout, stderr string) string { panic("[ParseRestoreKeyOutput] Do not call me") } @@ -265,7 +265,7 @@ type ChannelsOutput struct { } // Parses output of chain config which is populated by hyperspace -// Ideally, there should be a command from hyperspace to get this output +// Ideally, there should be a command from hyperspace to get this output. func (hyperspaceCommander) ParseGetChannelsOutput(stdout, stderr string) ([]ibc.ChannelOutput, error) { var cfg ChannelsOutput err := toml.Unmarshal([]byte(stdout), &cfg) @@ -298,7 +298,7 @@ type ConnectionsOutput struct { // Parses output of chain config which is populated by hyperspace // Ideally, there should be a command from hyperspace to get this output -// Only supports 1 connection and limited info +// Only supports 1 connection and limited info. func (hyperspaceCommander) ParseGetConnectionsOutput(stdout, stderr string) (ibc.ConnectionOutputs, error) { var cfg ConnectionsOutput err := toml.Unmarshal([]byte(stdout), &cfg) @@ -336,7 +336,7 @@ type ClientOutput struct { // Parses output of chain config which is populated by hyperspace // Ideally, there should be a command from hyperspace to get this output -// Only supports 1 client +// Only supports 1 client. func (hyperspaceCommander) ParseGetClientsOutput(stdout, stderr string) (ibc.ClientOutputs, error) { var cfg ClientOutput err := toml.Unmarshal([]byte(stdout), &cfg) diff --git a/relayer/hyperspace/hyperspace_config.go b/relayer/hyperspace/hyperspace_config.go index 8004d05af..ffe214868 100644 --- a/relayer/hyperspace/hyperspace_config.go +++ b/relayer/hyperspace/hyperspace_config.go @@ -5,13 +5,14 @@ import ( "strconv" "strings" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v8/chain/polkadot" "github.com/strangelove-ventures/interchaintest/v8/ibc" bip32 "github.com/tyler-smith/go-bip32" bip39 "github.com/tyler-smith/go-bip39" + + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/types" ) type HyperspaceRelayerCoreConfig struct { @@ -97,6 +98,7 @@ func GenKeyEntry(bech32Prefix, coinType, mnemonic string) KeyEntry { Address: address.Bytes(), // i.e. [9, 13, 32, 191, 206, 194, 159, 239, 250, 89, 193, 7, 23, 99, 96, 46, 7, 74, 172, 14] } } + func ChainConfigToHyperspaceRelayerChainConfig(chainConfig ibc.ChainConfig, keyName, rpcAddr, grpcAddr string) interface{} { chainType := chainConfig.Type if chainType == "polkadot" || chainType == "parachain" || chainType == "relaychain" { diff --git a/relayer/hyperspace/hyperspace_relayer.go b/relayer/hyperspace/hyperspace_relayer.go index c956dae23..ae43b421b 100644 --- a/relayer/hyperspace/hyperspace_relayer.go +++ b/relayer/hyperspace/hyperspace_relayer.go @@ -69,7 +69,7 @@ func HyperspaceCapabilities() map[relayer.Capability]bool { // LinkPath performs the operations that happen when a path is linked. This includes creating clients, creating connections // and establishing a channel. This happens across multiple operations rather than a single link path cli command. -// Parachains need a Polkadot epoch/session before starting, do not link in interchain.Build() +// Parachains need a Polkadot epoch/session before starting, do not link in interchain.Build(). func (r *HyperspaceRelayer) LinkPath(ctx context.Context, rep ibc.RelayerExecReporter, pathName string, channelOpts ibc.CreateChannelOptions, clientOpts ibc.CreateClientOptions) error { if err := r.CreateClients(ctx, rep, pathName, clientOpts); err != nil { return err @@ -187,6 +187,7 @@ func (r *HyperspaceRelayer) GetRelayerChainConfig( } return nil, fmt.Errorf("unsupported chain config: %s", chainType) } + func (r *HyperspaceRelayer) SetRelayerChainConfig( ctx context.Context, filePath string, diff --git a/relayer/hyperspace/wallet.go b/relayer/hyperspace/wallet.go index 58093453a..e2cfb5522 100644 --- a/relayer/hyperspace/wallet.go +++ b/relayer/hyperspace/wallet.go @@ -33,12 +33,12 @@ func (w *HyperspaceWallet) FormattedAddress() string { return w.address } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *HyperspaceWallet) Mnemonic() string { return w.mnemonic } -// Get Address +// Get Address. func (w *HyperspaceWallet) Address() []byte { return []byte(w.address) } diff --git a/relayer/rly/cosmos_relayer.go b/relayer/rly/cosmos_relayer.go index 35a531beb..91c5b510b 100644 --- a/relayer/rly/cosmos_relayer.go +++ b/relayer/rly/cosmos_relayer.go @@ -7,11 +7,12 @@ import ( "fmt" "strings" - "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/relayer" "go.uber.org/zap" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" ) const ( diff --git a/relayer/rly/wallet.go b/relayer/rly/wallet.go index 84a58e80c..2b5d627e3 100644 --- a/relayer/rly/wallet.go +++ b/relayer/rly/wallet.go @@ -33,12 +33,12 @@ func (w *RlyWallet) FormattedAddress() string { return w.address } -// Get mnemonic, only used for relayer wallets +// Get mnemonic, only used for relayer wallets. func (w *RlyWallet) Mnemonic() string { return w.mnemonic } -// Get Address +// Get Address. func (w *RlyWallet) Address() []byte { return []byte(w.address) } diff --git a/test_setup.go b/test_setup.go index c9517bbfa..5a8480ba7 100644 --- a/test_setup.go +++ b/test_setup.go @@ -41,7 +41,7 @@ func DockerSetup(t dockerutil.DockerSetupTestingT) (*client.Client, string) { // creates wallets in the relayer for src and dst chain // funds relayer src and dst wallets on respective chain in genesis // creates a faucet account on the both chains (separate fullnode) -// funds faucet accounts in genesis +// funds faucet accounts in genesis. func StartChainPair( t *testing.T, ctx context.Context, diff --git a/test_user.go b/test_user.go index 3862881fa..f2480de64 100644 --- a/test_user.go +++ b/test_user.go @@ -5,12 +5,13 @@ import ( "fmt" "testing" - "cosmossdk.io/math" "github.com/strangelove-ventures/interchaintest/v8/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" + + "cosmossdk.io/math" ) // GetAndFundTestUserWithMnemonic restores a user using the given mnemonic diff --git a/testutil/gzip.go b/testutil/gzip.go index f5ef98c05..93b0ebcad 100644 --- a/testutil/gzip.go +++ b/testutil/gzip.go @@ -5,7 +5,7 @@ import ( "compress/gzip" ) -// GzipIt compresses the input ([]byte) +// GzipIt compresses the input ([]byte). func GzipIt(input []byte) ([]byte, error) { // Create gzip writer. var b bytes.Buffer diff --git a/testutil/poll_for_state.go b/testutil/poll_for_state.go index 2386d0476..ab40a5227 100644 --- a/testutil/poll_for_state.go +++ b/testutil/poll_for_state.go @@ -50,7 +50,7 @@ func (p BlockPoller[T]) DoPoll(ctx context.Context, startHeight, maxHeight int64 return zero, pollErr } -// ChainAcker is a chain that can get its acknowledgements at a specified height +// ChainAcker is a chain that can get its acknowledgements at a specified height. type ChainAcker interface { ChainHeighter Acknowledgements(ctx context.Context, height int64) ([]ibc.PacketAcknowledgement, error) @@ -86,7 +86,7 @@ func PollForAck(ctx context.Context, chain ChainAcker, startHeight, maxHeight in return found, nil } -// ChainTimeouter is a chain that can get its timeouts at a specified height +// ChainTimeouter is a chain that can get its timeouts at a specified height. type ChainTimeouter interface { ChainHeighter Timeouts(ctx context.Context, height int64) ([]ibc.PacketTimeout, error) @@ -138,7 +138,7 @@ func (pe *packetPollError) Unwrap() error { return pe.error } -// Format is expected to be used by testify/require which prints errors via %+v +// Format is expected to be used by testify/require which prints errors via %+v. func (pe *packetPollError) Format(s fmt.State, verb rune) { if verb != 'v' && !s.Flag('+') { fmt.Fprint(s, pe.error.Error())