Skip to content

Commit

Permalink
Merge branch 'main' into reece/simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Oct 16, 2023
2 parents e89138a + 08b20f6 commit e925c97
Show file tree
Hide file tree
Showing 160 changed files with 103,154 additions and 514 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
go-version: '1.21'

- name: checkout interchaintest
uses: actions/checkout@v3
uses: actions/checkout@v4

# cleanup environment on self-hosted test runner
- name: clean
Expand All @@ -42,7 +42,7 @@ jobs:
cache: false

- name: checkout interchaintest
uses: actions/checkout@v3
uses: actions/checkout@v4

# cleanup environment on self-hosted test runner
- name: clean
Expand All @@ -64,7 +64,7 @@ jobs:
cache: false

- name: checkout interchaintest
uses: actions/checkout@v3
uses: actions/checkout@v4

# cleanup environment on self-hosted test runner
- name: clean
Expand Down
23 changes: 22 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,31 @@ jobs:
with:
go-version: '1.21'
cache: false
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
only-new-issues: true
args: --timeout=5m

clippy-lint:
defaults:
run:
working-directory: local-interchain/rust/localic-std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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

56 changes: 54 additions & 2 deletions .github/workflows/local-interchain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,65 @@ jobs:
build:
runs-on: ubuntu-latest
name: build
defaults:
run:
working-directory: ./local-interchain
steps:
- name: Checkout interchaintest
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- run: cd local-interchain && go mod tidy && make install
- name: build local-interchain
run: go mod tidy && make install

- name: Upload localic artifact
uses: actions/upload-artifact@v3
with:
name: local-ic
path: ~/go/bin/local-ic

# TOOO: put the python workflow here. (https://github.com/strangelove-ventures/interchaintest/pull/775)

rust-e2e:
name: rust e2e
needs: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./local-interchain
strategy:
fail-fast: false

steps:
- name: checkout chain
uses: actions/checkout@v3

- name: Install latest toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
with:
name: local-ic
path: /tmp

- name: Make local-ic executable
run: chmod +x /tmp/local-ic

- name: Start background ibc local-interchain
run: /tmp/local-ic start juno_ibc --api-port 8080 &

- name: Run Rust Script
run: cd rust && cargo run --package localic-bin --bin localic-bin

- name: Cleanup
run: killall local-ic && exit 0
2 changes: 1 addition & 1 deletion .github/workflows/strangelove-project-management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened')
steps:
- name: Add Issue to "Motherboard" Project Board
uses: leonsteinhaeuser/project-beta-automations@v2.1.0
uses: leonsteinhaeuser/project-beta-automations@v2.2.1
with:
gh_app_secret_key: ${{ secrets.MB_SECRET_KEY }}
gh_app_ID: ${{ secrets.MB_APP_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
go-version: '1.21'

- name: checkout interchaintest
uses: actions/checkout@v3
uses: actions/checkout@v4

# run tests
- name: run unit tests
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
DOCKER := $(shell which docker)
protoVer=0.13.2
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

default: help

.PHONY: help
Expand All @@ -23,4 +28,9 @@ docker-mac-nuke: ## macOS only. Try docker-reset first. Kills and restarts Docke

.PHONY: gen
gen: ## Run code generators
go generate ./...
go generate ./...

.PHONY: proto-gen
proto-gen: ## Generate code from protos
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh
46 changes: 35 additions & 11 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,19 @@ func (tn *ChainNode) FindTxs(ctx context.Context, height uint64) ([]blockdb.Tx,
// with the chain node binary.
func (tn *ChainNode) TxCommand(keyName string, command ...string) []string {
command = append([]string{"tx"}, command...)
var gasPriceFound, gasAdjustmentFound = false, false
var gasPriceFound, gasAdjustmentFound, feesFound = false, false, false
for i := 0; i < len(command); i++ {
if command[i] == "--gas-prices" {
gasPriceFound = true
}
if command[i] == "--gas-adjustment" {
gasAdjustmentFound = true
}
if command[i] == "--fees" {
feesFound = true
}
}
if !gasPriceFound {
if !gasPriceFound && !feesFound {
command = append(command, "--gas-prices", tn.Chain.Config().GasPrices)
}
if !gasAdjustmentFound {
Expand Down Expand Up @@ -779,14 +782,17 @@ type CodeInfosResponse struct {
}

// StoreContract takes a file path to smart contract and stores it on-chain. Returns the contracts code id.
func (tn *ChainNode) StoreContract(ctx context.Context, keyName string, fileName string) (string, error) {
func (tn *ChainNode) StoreContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) {
_, file := filepath.Split(fileName)
err := tn.CopyFile(ctx, fileName, file)
if err != nil {
return "", fmt.Errorf("writing contract file to docker volume: %w", err)
}

if _, err := tn.ExecTx(ctx, keyName, "wasm", "store", path.Join(tn.HomeDir(), file), "--gas", "auto"); err != nil {
cmd := []string{"wasm", "store", path.Join(tn.HomeDir(), file), "--gas", "auto"}
cmd = append(cmd, extraExecTxArgs...)

if _, err := tn.ExecTx(ctx, keyName, cmd...); err != nil {
return "", err
}

Expand Down Expand Up @@ -955,10 +961,11 @@ func (tn *ChainNode) InstantiateContract(ctx context.Context, keyName string, co
}

// ExecuteContract executes a contract transaction with a message using it's address.
func (tn *ChainNode) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string) (txHash string, err error) {
return tn.ExecTx(ctx, keyName,
"wasm", "execute", contractAddress, message,
)
func (tn *ChainNode) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string, extraExecTxArgs ...string) (txHash string, err error) {
cmd := []string{"wasm", "execute", contractAddress, message}
cmd = append(cmd, extraExecTxArgs...)

return tn.ExecTx(ctx, keyName, cmd...)
}

// QueryContract performs a smart query, taking in a query struct and returning a error with the response struct populated.
Expand All @@ -976,7 +983,7 @@ func (tn *ChainNode) QueryContract(ctx context.Context, contractAddress string,
}

// StoreClientContract takes a file path to a client smart contract and stores it on-chain. Returns the contracts code id.
func (tn *ChainNode) StoreClientContract(ctx context.Context, keyName string, fileName string) (string, error) {
func (tn *ChainNode) StoreClientContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) {
content, err := os.ReadFile(fileName)
if err != nil {
return "", err
Expand All @@ -987,7 +994,10 @@ func (tn *ChainNode) StoreClientContract(ctx context.Context, keyName string, fi
return "", fmt.Errorf("writing contract file to docker volume: %w", err)
}

_, err = tn.ExecTx(ctx, keyName, "ibc-wasm", "store-code", path.Join(tn.HomeDir(), file), "--gas", "auto")
cmd := []string{"ibc-wasm", "store-code", path.Join(tn.HomeDir(), file), "--gas", "auto"}
cmd = append(cmd, extraExecTxArgs...)

_, err = tn.ExecTx(ctx, keyName, cmd...)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -1125,6 +1135,20 @@ func (tn *ChainNode) QueryParam(ctx context.Context, subspace, key string) (*Par
return &param, nil
}

// QueryBankMetadata returns the bank metadata of a token denomination.
func (tn *ChainNode) QueryBankMetadata(ctx context.Context, denom string) (*BankMetaData, error) {
stdout, _, err := tn.ExecQuery(ctx, "bank", "denom-metadata", "--denom", denom)
if err != nil {
return nil, err
}
var meta BankMetaData
err = json.Unmarshal(stdout, &meta)
if err != nil {
return nil, err
}
return &meta, nil
}

// DumpContractState dumps the state of a contract at a block height.
func (tn *ChainNode) DumpContractState(ctx context.Context, contractAddress string, height int64) (*DumpContractStateResponse, error) {
stdout, _, err := tn.ExecQuery(ctx,
Expand Down Expand Up @@ -1199,7 +1223,7 @@ func (tn *ChainNode) CreateNodeContainer(ctx context.Context) error {
cmd = []string{chainCfg.Bin, "start", "--home", tn.HomeDir(), "--x-crisis-skip-assert-invariants"}
}

return tn.containerLifecycle.CreateContainer(ctx, tn.TestName, tn.NetworkID, tn.Image, sentryPorts, tn.Bind(), tn.HostName(), cmd)
return tn.containerLifecycle.CreateContainer(ctx, tn.TestName, tn.NetworkID, tn.Image, sentryPorts, tn.Bind(), tn.HostName(), cmd, nil)
}

func (tn *ChainNode) StartContainer(ctx context.Context) error {
Expand Down
25 changes: 17 additions & 8 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ func (c *CosmosChain) getFullNode() *ChainNode {
return c.Validators[0]
}

func (c *CosmosChain) GetNode() *ChainNode {
return c.Validators[0]
}

// Exec implements ibc.Chain.
func (c *CosmosChain) Exec(ctx context.Context, cmd []string, env []string) (stdout, stderr []byte, err error) {
return c.getFullNode().Exec(ctx, cmd, env)
Expand Down Expand Up @@ -390,8 +394,8 @@ func (c *CosmosChain) PushNewWasmClientProposal(ctx context.Context, keyName str
return tx, "", err
}
message := wasmtypes.MsgStoreCode{
Signer: types.MustBech32ifyAddressBytes(c.cfg.Bech32Prefix, authtypes.NewModuleAddress(govtypes.ModuleName)),
WasmByteCode: content,
Signer: types.MustBech32ifyAddressBytes(c.cfg.Bech32Prefix, authtypes.NewModuleAddress(govtypes.ModuleName)),
WasmByteCode: content,
}
msg, err := c.cfg.EncodingConfig.Codec.MarshalInterfaceJSON(&message)
if err != nil {
Expand Down Expand Up @@ -472,6 +476,11 @@ func (c *CosmosChain) QueryParam(ctx context.Context, subspace, key string) (*Pa
return c.getFullNode().QueryParam(ctx, subspace, key)
}

// QueryBankMetadata returns the metadata of a given token denomination.
func (c *CosmosChain) QueryBankMetadata(ctx context.Context, denom string) (*BankMetaData, error) {
return c.getFullNode().QueryBankMetadata(ctx, denom)
}

func (c *CosmosChain) txProposal(txHash string) (tx TxProposal, _ error) {
txResp, err := c.getTransaction(txHash)
if err != nil {
Expand All @@ -493,8 +502,8 @@ func (c *CosmosChain) txProposal(txHash string) (tx TxProposal, _ error) {
}

// StoreContract takes a file path to smart contract and stores it on-chain. Returns the contracts code id.
func (c *CosmosChain) StoreContract(ctx context.Context, keyName string, fileName string) (string, error) {
return c.getFullNode().StoreContract(ctx, keyName, fileName)
func (c *CosmosChain) StoreContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) {
return c.getFullNode().StoreContract(ctx, keyName, fileName, extraExecTxArgs...)
}

// InstantiateContract takes a code id for a smart contract and initialization message and returns the instantiated contract address.
Expand All @@ -503,8 +512,8 @@ func (c *CosmosChain) InstantiateContract(ctx context.Context, keyName string, c
}

// ExecuteContract executes a contract transaction with a message using it's address.
func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string) (txHash string, err error) {
return c.getFullNode().ExecuteContract(ctx, keyName, contractAddress, message)
func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string, extraExecTxArgs ...string) (txHash string, err error) {
return c.getFullNode().ExecuteContract(ctx, keyName, contractAddress, message, extraExecTxArgs...)
}

// QueryContract performs a smart query, taking in a query struct and returning a error with the response struct populated.
Expand All @@ -518,8 +527,8 @@ func (c *CosmosChain) DumpContractState(ctx context.Context, contractAddress str
}

// StoreClientContract takes a file path to a client smart contract and stores it on-chain. Returns the contracts code id.
func (c *CosmosChain) StoreClientContract(ctx context.Context, keyName string, fileName string) (string, error) {
return c.getFullNode().StoreClientContract(ctx, keyName, fileName)
func (c *CosmosChain) StoreClientContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) {
return c.getFullNode().StoreClientContract(ctx, keyName, fileName, extraExecTxArgs...)
}

// QueryClientContractCode performs a query with the contract codeHash as the input and code as the output
Expand Down
2 changes: 1 addition & 1 deletion chain/cosmos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *SidecarProcess) logger() *zap.Logger {
}

func (s *SidecarProcess) CreateContainer(ctx context.Context) error {
return s.containerLifecycle.CreateContainer(ctx, s.TestName, s.NetworkID, s.Image, s.ports, s.Bind(), s.HostName(), s.startCmd)
return s.containerLifecycle.CreateContainer(ctx, s.TestName, s.NetworkID, s.Image, s.ports, s.Bind(), s.HostName(), s.startCmd, nil)
}

func (s *SidecarProcess) StartContainer(ctx context.Context) error {
Expand Down
Loading

0 comments on commit e925c97

Please sign in to comment.