Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Validation of SlashAcks fails due to marshaling to Bech32 #1570

Merged
merged 28 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a08ebba
add different Bech32Prefix for consumer and provider
mpoke Jan 16, 2024
cfaacdb
separate app encoding and params
mpoke Jan 16, 2024
0f2388c
remove ConsumerValPubKey from ValidatorConfig
mpoke Jan 16, 2024
fb721a1
update addresses in tests
mpoke Jan 16, 2024
f4e78c4
make SlashAcks consistent across chains
mpoke Jan 17, 2024
47d3a9c
add comments for clarity
mpoke Jan 17, 2024
f9b3bdf
Regenerate traces
p-offtermatt Jan 17, 2024
4027158
Fix argument order
p-offtermatt Jan 17, 2024
1ce3a93
set bech32prefix for provider to cosmos
mpoke Jan 17, 2024
07d4e30
fix merge conflict
mpoke Jan 17, 2024
22f4006
add changelog entries
mpoke Jan 17, 2024
413c43b
add consumer-double-downtime e2e test
mpoke Jan 17, 2024
47aac55
update nightly-e2e workflow
mpoke Jan 17, 2024
e78593d
fix typo
mpoke Jan 17, 2024
e5bd41d
add consumer-double-downtime to testConfigs
mpoke Jan 18, 2024
fb9b336
remove changes on provider
mpoke Jan 18, 2024
2094cf4
skip invalid SlashAcks
mpoke Jan 18, 2024
4979dfc
seal the config
mpoke Jan 18, 2024
905d666
clear the outstanding downtime flag for new vals
mpoke Jan 18, 2024
4626b78
add info on upgrading to v4.0.0
mpoke Jan 18, 2024
7b0cf50
fix upgrade handler
mpoke Jan 19, 2024
f0b9d7b
fix changeover e2e test
sainoe Jan 19, 2024
4c9588c
Update tests/e2e/config.go
mpoke Jan 19, 2024
1c00063
Update tests/e2e/config.go
mpoke Jan 19, 2024
7a8a5d5
add AccountPrefix to ChainConfig
mpoke Jan 19, 2024
db8feb1
fix docstrings
mpoke Jan 19, 2024
fc86224
update AccountAddressPrefix in app.go
mpoke Jan 19, 2024
03e740c
fix consumer-misb e2e test
sainoe Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/1570-slashack-bech32.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the validation of VSCPackets to not fail due to marshaling to string using Bech32.
([\#1570](https://github.com/cosmos/interchain-security/pull/1570))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the validation of VSCPackets to not fail due to marshaling to string using Bech32.
([\#1570](https://github.com/cosmos/interchain-security/pull/1570))
103 changes: 0 additions & 103 deletions .github/workflows/manual-e2e.yml

This file was deleted.

55 changes: 52 additions & 3 deletions .github/workflows/nightly-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Run integration tests nightly on main

# !! Relevant changes to this file should be propagated manual-integration.yml

name: nightly-e2e-main
on:
workflow_dispatch:
mpoke marked this conversation as resolved.
Show resolved Hide resolved
schedule:
# run every day at 03:00 UTC
# ┌───────────── minute (0 - 59)
Expand Down Expand Up @@ -114,6 +112,54 @@ jobs:
go-version: "1.21" # The Go version to download (if necessary) and use.
- name: E2E multi-consumer tests
run: go run ./tests/e2e/... --tc multiconsumer
consumer-misbehaviour-test:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sainoe Any reasons this was not added before?

runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21" # The Go version to download (if necessary) and use.
- name: E2E consumer-misbehaviour tests
run: go run ./tests/e2e/... --tc consumer-misbehaviour
consumer-double-sign-test:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: @sainoe Any reasons this was not added before?

runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21" # The Go version to download (if necessary) and use.
- name: E2E consumer-double-sign tests
run: go run ./tests/e2e/... --tc consumer-double-sign
consumer-double-downtime-test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21" # The Go version to download (if necessary) and use.
- name: E2E consumer-double-downtime tests
run: go run ./tests/e2e/... --tc consumer-double-downtime

nightly-test-fail:
needs:
Expand All @@ -123,6 +169,9 @@ jobs:
- democracy-test
- slash-throttle-test
- multiconsumer-test
- consumer-misbehaviour-test
- consumer-double-sign-test
- consumer-double-downtime-test
if: ${{ failure() }}
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 5 additions & 5 deletions app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import (
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"

appparams "github.com/cosmos/interchain-security/v4/app/params"
appencoding "github.com/cosmos/interchain-security/v4/app/encoding"
testutil "github.com/cosmos/interchain-security/v4/testutil/integration"
consumer "github.com/cosmos/interchain-security/v4/x/ccv/consumer"
consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper"
Expand Down Expand Up @@ -1005,17 +1005,17 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// should be used only in tests or when creating a new app instance (NewApp*()).
// App user shouldn't create new codecs - use the app.AppCodec instead.
// [DEPRECATED]
func MakeTestEncodingConfig() appparams.EncodingConfig {
encodingConfig := appparams.MakeTestEncodingConfig()
func MakeTestEncodingConfig() appencoding.EncodingConfig {
encodingConfig := appencoding.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}

func makeEncodingConfig() appparams.EncodingConfig {
encodingConfig := appparams.MakeTestEncodingConfig()
func makeEncodingConfig() appencoding.EncodingConfig {
encodingConfig := appencoding.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
Expand Down
4 changes: 2 additions & 2 deletions app/consumer/ante/disabled_modules_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"

"github.com/cosmos/interchain-security/v4/app/consumer/ante"
"github.com/cosmos/interchain-security/v4/app/params"
appencoding "github.com/cosmos/interchain-security/v4/app/encoding"
)

func TestDisabledModulesDecorator(t *testing.T) {
txCfg := params.MakeTestEncodingConfig().TxConfig
txCfg := appencoding.MakeTestEncodingConfig().TxConfig
authzMsgExecSlashing := authz.NewMsgExec(sdk.AccAddress{}, []sdk.Msg{&slashingtypes.MsgUnjail{}})
authzMsgExecEvidence := authz.NewMsgExec(sdk.AccAddress{}, []sdk.Msg{&evidencetypes.MsgSubmitEvidence{}})
nestedAuthzMsgExecSlashing := authz.NewMsgExec(sdk.AccAddress{}, []sdk.Msg{&authzMsgExecSlashing})
Expand Down
4 changes: 2 additions & 2 deletions app/consumer/ante/msg_filter_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/cosmos/interchain-security/v4/app/consumer/ante"
"github.com/cosmos/interchain-security/v4/app/params"
appencoding "github.com/cosmos/interchain-security/v4/app/encoding"
)

type consumerKeeper struct {
Expand All @@ -28,7 +28,7 @@ func noOpAnteDecorator() sdk.AnteHandler {
}

func TestMsgFilterDecorator(t *testing.T) {
txCfg := params.MakeTestEncodingConfig().TxConfig
txCfg := appencoding.MakeTestEncodingConfig().TxConfig

testCases := []struct {
name string
Expand Down
10 changes: 5 additions & 5 deletions app/consumer/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import (
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"

appparams "github.com/cosmos/interchain-security/v4/app/params"
appencoding "github.com/cosmos/interchain-security/v4/app/encoding"
testutil "github.com/cosmos/interchain-security/v4/testutil/integration"
ibcconsumer "github.com/cosmos/interchain-security/v4/x/ccv/consumer"
ibcconsumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper"
Expand Down Expand Up @@ -830,17 +830,17 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// return encodingConfig
// }

func MakeTestEncodingConfig() appparams.EncodingConfig {
encodingConfig := appparams.MakeTestEncodingConfig()
func MakeTestEncodingConfig() appencoding.EncodingConfig {
encodingConfig := appencoding.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}

func makeEncodingConfig() appparams.EncodingConfig {
encodingConfig := appparams.MakeTestEncodingConfig()
func makeEncodingConfig() appencoding.EncodingConfig {
encodingConfig := appencoding.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
Expand Down
12 changes: 11 additions & 1 deletion app/params/proto.go → app/encoding/encoding.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package params
package encoding

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

// EncodingConfig specifies the concrete encoding types to use for a given app.
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Codec codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}

// MakeTestEncodingConfig creates an EncodingConfig for an amino based test configuration.
func MakeTestEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
Expand Down
41 changes: 17 additions & 24 deletions app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,25 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var (
Bech32Prefix = "cosmos"

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
)

// SetAddressPrefixes builds the Config with Bech32 addressPrefix and publKeyPrefix for accounts, validators, and consensus nodes and verifies that addreeses have correct format.
// Not sealed yet
func SetAddressPrefixes() {
func SetAddressPrefixes(bech32Prefix string) {
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
cfg.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
cfg.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
}

func init() {
SetAddressPrefixes()
// bech32PrefixAccAddr defines the Bech32 prefix of an account's address
bech32PrefixAccAddr := bech32Prefix
// bech32PrefixAccPub defines the Bech32 prefix of an account's public key
bech32PrefixAccPub := bech32Prefix + sdk.PrefixPublic
// bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
bech32PrefixValAddr := bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
// bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
bech32PrefixValPub := bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
// bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
bech32PrefixConsAddr := bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
bech32PrefixConsPub := bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic

cfg.SetBech32PrefixForAccount(bech32PrefixAccAddr, bech32PrefixAccPub)
cfg.SetBech32PrefixForValidator(bech32PrefixValAddr, bech32PrefixValPub)
cfg.SetBech32PrefixForConsensusNode(bech32PrefixConsAddr, bech32PrefixConsPub)
}
19 changes: 0 additions & 19 deletions app/params/doc.go

This file was deleted.

16 changes: 0 additions & 16 deletions app/params/encoding.go

This file was deleted.

7 changes: 0 additions & 7 deletions app/params/params.go

This file was deleted.

Loading
Loading