Skip to content

Commit

Permalink
Merge branch 'main' into reece/add-authority-to-keeper-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Jul 17, 2024
2 parents 32635d8 + 14cd114 commit df17d5d
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
contents: read
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.4.0
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
# Depinject debug file
debug_container.dot

build/
build/\

go.work.sum
31 changes: 15 additions & 16 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ require (

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
cosmossdk.io/api v0.7.4 // indirect
Expand Down Expand Up @@ -73,7 +72,7 @@ require (
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.6 // indirect
github.com/cometbft/cometbft v0.38.9 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
Expand Down Expand Up @@ -118,7 +117,7 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -139,14 +138,15 @@ require (
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-getter v1.7.5 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
Expand Down Expand Up @@ -234,24 +234,23 @@ require (
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
65 changes: 32 additions & 33 deletions e2e/go.sum

Large diffs are not rendered by default.

34 changes: 23 additions & 11 deletions e2e/helpers/action_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
)
Expand All @@ -27,40 +29,50 @@ func ExecuteExec(ctx context.Context, chain *cosmos.CosmosChain, cmd []string, i
command = append(command, extraFlags...)
fmt.Println(command)

stdout, _, err := chain.Exec(ctx, command, nil)
stdout, stderr, err := chain.Exec(ctx, command, nil)
if err != nil {
fmt.Println(err)
}

fmt.Println(string(stdout))
if err := json.Unmarshal(stdout, &i); err != nil {
fmt.Println(err)
fmt.Println("ExecuteExec", "stdout", string(stdout), "stderr", string(stderr))

err2 := json.Unmarshal(stdout, &i)
if err2 != nil {
fmt.Println("json.Unmarshal", err2)
return // guard return as to not show the next error
}

// If the codec can not properly unmarshal, then it may be a standard json Unmarshal request.
// This is required since we are ExecuteExec'ing an interface{} instead of some concrete type.
err = chain.GetCodec().UnmarshalInterface(stdout, &i)
if err != nil && !strings.Contains(err.Error(), "illegal wireType") {
fmt.Println("chain.GetCodec.UnmarshalInterface", err)
}
}

// Executes a command from CommandBuilder
func ExecuteTransaction(ctx context.Context, chain *cosmos.CosmosChain, cmd []string) (TxResponse, error) {
func ExecuteTransaction(ctx context.Context, chain *cosmos.CosmosChain, cmd []string) (sdk.TxResponse, error) {
var err error
var stdout []byte

stdout, _, err = chain.Exec(ctx, cmd, nil)
if err != nil {
return TxResponse{}, err
return sdk.TxResponse{}, err
}

if err := testutil.WaitForBlocks(ctx, waitForBlocks, chain); err != nil {
return TxResponse{}, err
return sdk.TxResponse{}, err
}

var res TxResponse
if err := json.Unmarshal(stdout, &res); err != nil {
return TxResponse{}, err
var res sdk.TxResponse
if err := chain.GetCodec().UnmarshalJSON(stdout, &res); err != nil {
return sdk.TxResponse{}, err
}

return res, err
}

func ExecuteTransactionNoError(ctx context.Context, chain *cosmos.CosmosChain, cmd []string) TxResponse {
func ExecuteTransactionNoError(ctx context.Context, chain *cosmos.CosmosChain, cmd []string) sdk.TxResponse {
res, _ := ExecuteTransaction(ctx, chain, cmd)
return res
}
Expand Down
5 changes: 3 additions & 2 deletions e2e/helpers/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"strings"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
)

func ExecuteAuthzGrantMsg(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, granter ibc.Wallet, grantee ibc.Wallet, msgType string) (TxResponse, error) {
func ExecuteAuthzGrantMsg(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, granter ibc.Wallet, grantee ibc.Wallet, msgType string) (sdk.TxResponse, error) {
if !strings.HasPrefix(msgType, "/") {
msgType = "/" + msgType
}
Expand All @@ -19,7 +20,7 @@ func ExecuteAuthzGrantMsg(t *testing.T, ctx context.Context, chain *cosmos.Cosmo
return ExecuteTransaction(ctx, chain, cmd)
}

func ExecuteAuthzExecMsg(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, grantee ibc.Wallet, nestedMsgCmd []string) (TxResponse, error) {
func ExecuteAuthzExecMsg(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, grantee ibc.Wallet, nestedMsgCmd []string) (sdk.TxResponse, error) {
// generate the message to JSON, then exec the message
fileName := "authz.json"
node := chain.GetNode()
Expand Down
19 changes: 9 additions & 10 deletions e2e/helpers/poa.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,33 @@ import (
"fmt"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/poa"
"github.com/stretchr/testify/require"
)

func POASetPower(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string, power int64, flags ...string) (TxResponse, error) {
func POASetPower(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string, power int64, flags ...string) (sdk.TxResponse, error) {
cmd := TxCommandBuilder(ctx, chain, []string{"tx", "poa", "set-power", valoper, fmt.Sprintf("%d", power)}, user.KeyName(), flags...)
return ExecuteTransaction(ctx, chain, cmd)
}

func POARemove(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string) (TxResponse, error) {
func POARemove(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string) (sdk.TxResponse, error) {
cmd := TxCommandBuilder(ctx, chain, []string{"tx", "poa", "remove", valoper}, user.KeyName())
return ExecuteTransaction(ctx, chain, cmd)
}

func POARemovePending(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string) (TxResponse, error) {
func POARemovePending(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string) (sdk.TxResponse, error) {
cmd := TxCommandBuilder(ctx, chain, []string{"tx", "poa", "remove-pending", valoper}, user.KeyName())
return ExecuteTransaction(ctx, chain, cmd)
}

func POACreatePendingValidator(
t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet,
ed25519PubKey string, moniker string, commissionRate string, commissionMaxRate string, commissionMaxChangeRate string,
) (TxResponse, error) {
) (sdk.TxResponse, error) {
file := "validator_file.json"

content := fmt.Sprintf(`{
Expand Down Expand Up @@ -91,11 +92,9 @@ func GetPOAConsensusPower(t *testing.T, ctx context.Context, chain *cosmos.Cosmo
var res POAConsensusPower
ExecuteQuery(ctx, chain, []string{"query", "poa", "consensus-power", valoperAddr}, &res)

var power int64
power := int64(0)
_, err := fmt.Sscanf(res.Power, "%d", &power)
if err != nil {
return 0
}
fmt.Println("error", err) // does not panic incase omitempty

return power
}
Expand All @@ -106,7 +105,7 @@ func GetPOAPending(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain)
return res
}

func POAUpdateParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, gracefulExit bool) (TxResponse, error) {
func POAUpdateParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, gracefulExit bool) (sdk.TxResponse, error) {
gracefulParam := "true"
if !gracefulExit {
gracefulParam = "false"
Expand All @@ -116,7 +115,7 @@ func POAUpdateParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChai
return ExecuteTransaction(ctx, chain, cmd)
}

func POAUpdateStakingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, sp stakingtypes.Params) (TxResponse, error) {
func POAUpdateStakingParams(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, sp stakingtypes.Params) (sdk.TxResponse, error) {
command := []string{"tx", "poa", "update-staking-params",
sp.UnbondingTime.String(),
fmt.Sprintf("%d", sp.MaxValidators),
Expand Down
5 changes: 3 additions & 2 deletions e2e/helpers/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"context"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
)

func StakeTokens(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper, coinAmt string) (TxResponse, error) {
func StakeTokens(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper, coinAmt string) (sdk.TxResponse, error) {
cmd := TxCommandBuilder(ctx, chain, []string{"tx", "staking", "delegate", valoper, coinAmt}, user.KeyName())
return ExecuteTransaction(ctx, chain, cmd)
}

func ClaimStakingRewards(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string) (TxResponse, error) {
func ClaimStakingRewards(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, valoper string) (sdk.TxResponse, error) {
cmd := TxCommandBuilder(ctx, chain, []string{"tx", "distribution", "withdraw-rewards", valoper}, user.KeyName())
return ExecuteTransaction(ctx, chain, cmd)
}
Expand Down
60 changes: 0 additions & 60 deletions e2e/helpers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,66 +90,6 @@ type BlockData struct {
} `json:"last_commit"`
}

// sdk v50
type TxResponse struct {
Height string `json:"height"`
Txhash string `json:"txhash"`
Codespace string `json:"codespace"`
Code int `json:"code"`
Data string `json:"data"`
RawLog string `json:"raw_log"`
Logs []any `json:"logs"`
Info string `json:"info"`
GasWanted string `json:"gas_wanted"`
GasUsed string `json:"gas_used"`
Tx struct {
Type string `json:"@type"`
Body struct {
Messages []struct {
Type string `json:"@type"`
FromAddress string `json:"from_address"`
ValidatorAddress string `json:"validator_address"`
Power string `json:"power"`
} `json:"messages"`
Memo string `json:"memo"`
TimeoutHeight string `json:"timeout_height"`
ExtensionOptions []any `json:"extension_options"`
NonCriticalExtensionOptions []any `json:"non_critical_extension_options"`
} `json:"body"`
AuthInfo struct {
SignerInfos []struct {
PublicKey struct {
Type string `json:"@type"`
Key string `json:"key"`
} `json:"public_key"`
ModeInfo struct {
Single struct {
Mode string `json:"mode"`
} `json:"single"`
} `json:"mode_info"`
Sequence string `json:"sequence"`
} `json:"signer_infos"`
Fee struct {
Amount []any `json:"amount"`
GasLimit string `json:"gas_limit"`
Payer string `json:"payer"`
Granter string `json:"granter"`
} `json:"fee"`
Tip any `json:"tip"`
} `json:"auth_info"`
Signatures []string `json:"signatures"`
} `json:"tx"`
Timestamp string `json:"timestamp"`
Events []struct {
Type string `json:"type"`
Attributes []struct {
Key string `json:"key"`
Value string `json:"value"`
Index bool `json:"index"`
} `json:"attributes"`
} `json:"events"`
}

type POAConsensusPower struct {
Power string `json:"consensus_power"`
}
Expand Down
Loading

0 comments on commit df17d5d

Please sign in to comment.