Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ replace (
github.com/allinbits/vaas => ../
github.com/bytedance/sonic => github.com/bytedance/sonic v1.15.0
github.com/cometbft/cometbft => github.com/atomone-hub/cometbft v0.0.0-20251216151559-a24cfa28b916
github.com/cosmos/cosmos-sdk => github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1.0.20251218143825-cbb67818e94a
github.com/cosmos/cosmos-sdk => github.com/atomone-hub/cosmos-sdk v0.500.2
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)

Expand All @@ -19,8 +19,10 @@ require (
cosmossdk.io/core v1.1.0-alpha.2
cosmossdk.io/errors v1.0.2
cosmossdk.io/log v1.6.1
cosmossdk.io/math v1.5.3
cosmossdk.io/store v1.3.0-alpha.1
cosmossdk.io/tools/confix v0.1.2
cosmossdk.io/x/evidence v0.2.0
cosmossdk.io/x/tx v1.2.0-alpha.1
cosmossdk.io/x/upgrade v0.2.0
github.com/allinbits/vaas v0.0.0-20260126105106-3bcd2c75855e
Expand All @@ -32,6 +34,7 @@ require (
github.com/spf13/cast v1.10.0
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
)

require (
Expand All @@ -45,9 +48,7 @@ require (
cloud.google.com/go/storage v1.50.0 // indirect
cosmossdk.io/collections v1.2.1 // indirect
cosmossdk.io/depinject v1.2.1 // indirect
cosmossdk.io/math v1.5.3 // indirect
cosmossdk.io/schema v1.1.0 // indirect
cosmossdk.io/x/evidence v0.2.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down Expand Up @@ -129,7 +130,6 @@ 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.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/btree v1.1.3 // indirect
Expand Down Expand Up @@ -199,7 +199,6 @@ require (
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand All @@ -220,6 +219,7 @@ require (
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
go.uber.org/mock v0.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
Expand Down
8 changes: 2 additions & 6 deletions app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/atomone-hub/cometbft v0.0.0-20251216151559-a24cfa28b916 h1:M6OdKPKbqJXWwhGEiE4mr5jwhiVlQ0Nhb+YzqttXgrw=
github.com/atomone-hub/cometbft v0.0.0-20251216151559-a24cfa28b916/go.mod h1:UCu8dlHqvkAsmAFmWDRWNZJPlu6ya2fTWZlDrWsivwo=
github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1.0.20251218143825-cbb67818e94a h1:Q8/YS/lWw2+EGsDe1qd9ljKJbfBZ+p4w4Z9toqKUDM4=
github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1.0.20251218143825-cbb67818e94a/go.mod h1:Ga+HHYYVVJ+32dKLM7RZxPTy2PfU8WDeR/4E0g8oL1E=
github.com/atomone-hub/cosmos-sdk v0.500.2 h1:yXvzlahnb6T3VuAEdzExi1c5MQRDa+T0s3PntfmlVbo=
github.com/atomone-hub/cosmos-sdk v0.500.2/go.mod h1:bV+SvzTTjmJ10xv0SaROxOZxp96Q4bmi8nnT2CpxkWc=
github.com/atomone-hub/cosmos-sdk/store v1.1.2-0.20260107105933-680c2b513b67 h1:mzORKQKL+QGAHlvS/5ZF3tYvoqyhSxeEk2SMdFMoG9w=
github.com/atomone-hub/cosmos-sdk/store v1.1.2-0.20260107105933-680c2b513b67/go.mod h1:MfJn/OPcNIVQfpatZgRfZAVtsoFI5bnxVA0WTog4lbw=
github.com/atomone-hub/cosmos-sdk/x/evidence v0.1.1 h1:6QimUuIrET6AlMeXiGRwBNn9WPDUmod1Mn3B1O9FUl8=
Expand Down Expand Up @@ -818,7 +818,6 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM=
github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
github.com/zondax/golem v0.27.0 h1:IbBjGIXF3SoGOZHsILJvIM/F/ylwJzMcHAcggiqniPw=
Expand Down Expand Up @@ -909,7 +908,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -951,7 +949,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1043,7 +1040,6 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
9 changes: 7 additions & 2 deletions app/provider/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
providerante "github.com/allinbits/vaas/x/vaas/provider/ante"
ibcproviderkeeper "github.com/allinbits/vaas/x/vaas/provider/keeper"

errorsmod "cosmossdk.io/errors"

Expand All @@ -9,10 +11,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
// HandlerOptions extend the SDK's AnteHandler options by requiring the VAAS
// provider keeper.
type HandlerOptions struct {
ante.HandlerOptions

ProviderKeeper ibcproviderkeeper.Keeper
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
Expand All @@ -35,6 +39,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSetUpContextDecorator(),
ante.NewExtensionOptionsDecorator(nil),
ante.NewValidateBasicDecorator(),
providerante.NewConsPubKeyRotationDecorator(options.ProviderKeeper),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
Expand Down
1 change: 1 addition & 0 deletions app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ func New(
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
ProviderKeeper: app.ProviderKeeper,
},
)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.26.0
replace (
cosmossdk.io/x/evidence => github.com/atomone-hub/cosmos-sdk/x/evidence v0.1.1
cosmossdk.io/x/upgrade => github.com/atomone-hub/cosmos-sdk/x/upgrade v0.1.5-atomone.1.0.20251218143825-cbb67818e94a
github.com/cosmos/cosmos-sdk => github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1.0.20251218143825-cbb67818e94a
github.com/cosmos/cosmos-sdk => github.com/atomone-hub/cosmos-sdk v0.500.2
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)

Expand Down Expand Up @@ -126,7 +126,6 @@ require (
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1.0.20251218143825-cbb67818e94a h1:Q8/YS/lWw2+EGsDe1qd9ljKJbfBZ+p4w4Z9toqKUDM4=
github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1.0.20251218143825-cbb67818e94a/go.mod h1:Ga+HHYYVVJ+32dKLM7RZxPTy2PfU8WDeR/4E0g8oL1E=
github.com/atomone-hub/cosmos-sdk v0.500.2 h1:yXvzlahnb6T3VuAEdzExi1c5MQRDa+T0s3PntfmlVbo=
github.com/atomone-hub/cosmos-sdk v0.500.2/go.mod h1:bV+SvzTTjmJ10xv0SaROxOZxp96Q4bmi8nnT2CpxkWc=
github.com/atomone-hub/cosmos-sdk/x/evidence v0.1.1 h1:6QimUuIrET6AlMeXiGRwBNn9WPDUmod1Mn3B1O9FUl8=
github.com/atomone-hub/cosmos-sdk/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc=
github.com/atomone-hub/cosmos-sdk/x/upgrade v0.1.5-atomone.1.0.20251218143825-cbb67818e94a h1:hoLPN0l4Z3ndSDoxyAFz9eRAKYsj49px/dYz4feX0BQ=
Expand Down Expand Up @@ -814,7 +814,6 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM=
github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
github.com/zondax/golem v0.27.0 h1:IbBjGIXF3SoGOZHsILJvIM/F/ylwJzMcHAcggiqniPw=
Expand Down Expand Up @@ -903,7 +902,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -946,7 +944,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1038,7 +1035,6 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
38 changes: 33 additions & 5 deletions x/vaas/consumer/keeper/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,47 @@ func (k Keeper) IsValidatorJailed(goCtx context.Context, addr sdk.ConsAddress) (
return false, nil
}

// ValidatorByConsAddr returns an empty validator
func (k Keeper) ValidatorByConsAddr(context.Context, sdk.ConsAddress) (stakingtypes.ValidatorI, error) {
// stubValidator is the stakingtypes.ValidatorI the consumer keeper hands to
// SDK modules that look validators up by consensus address. It is the zero
// staking validator (never jailed, status not UNBONDED) except that it can
// answer GetConsAddr: it echoes the address it was looked up under, since a
// consumer runs no consensus-key rotation and an address is therefore always
// its own current identity (the same invariant ValidatorIdentifier encodes).
// The zero validator alone no longer suffices because x/slashing's
// HandleValidatorSignature remaps the observed signer address through
// GetConsAddr to support rotation, and the zero validator panics there (its
// consensus pubkey Any is nil).
type stubValidator struct {
stakingtypes.Validator
consAddr sdk.ConsAddress
}

func (v stubValidator) GetConsAddr() ([]byte, error) {
return v.consAddr, nil
}

// ValidatorByConsAddr returns a minimal validator echoing the queried address.
func (k Keeper) ValidatorByConsAddr(_ context.Context, addr sdk.ConsAddress) (stakingtypes.ValidatorI, error) {
/*
NOTE:

The evidence module will call this function when it handles equivocation evidence.
The returned value must not be nil and must not have an UNBONDED validator status,
or evidence will reject it.

Also, the slashing module will cal lthis function when it observes downtime. In that case
the only requirement on the returned value is that it isn't null.
Also, the slashing module will call this function when it observes downtime
(HandleValidatorSignature). It requires the returned value to be non-nil, to
report the jailed status, and to answer GetConsAddr with the validator's
current consensus address; see stubValidator.
*/
return stakingtypes.Validator{}, nil
return stubValidator{consAddr: addr}, nil
}

// ValidatorIdentifier maps a consensus address to the identifier the slashing
// module tracks it under. The consumer runs no real staking and no consensus-key
// rotation, so the address is its own identifier.
func (k Keeper) ValidatorIdentifier(_ context.Context, consAddr sdk.ConsAddress) (sdk.ConsAddress, error) {
return consAddr, nil
}

// Calls SlashWithInfractionReason with Infraction_INFRACTION_UNSPECIFIED.
Expand Down
24 changes: 24 additions & 0 deletions x/vaas/consumer/keeper/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@ func TestIsValidatorJailed(t *testing.T) {
// Standalone changeover functionality removed
}

// TestValidatorByConsAddr pins the contract x/slashing's per-block
// HandleValidatorSignature relies on: the returned validator is non-nil, not
// jailed, not UNBONDED (the evidence module's requirement), and answers
// GetConsAddr with the queried address itself -- the consumer runs no
// consensus-key rotation, so the slashing module's rotation remap must be the
// identity. A zero staking validator instead panics inside GetConsAddr (nil
// consensus pubkey Any), which crashes every consumer at the first block
// whose BeginBlock processes signatures.
func TestValidatorByConsAddr(t *testing.T) {
consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

consAddr := sdk.ConsAddress([]byte{0x01, 0x02, 0x03})
val, err := consumerKeeper.ValidatorByConsAddr(ctx, consAddr)
require.NoError(t, err)
require.NotNil(t, val)
require.False(t, val.IsJailed())
require.NotEqual(t, stakingtypes.Unbonded, val.GetStatus())

got, err := val.GetConsAddr()
require.NoError(t, err, "GetConsAddr must not fail: x/slashing calls it every block per signer")
require.Equal(t, consAddr.Bytes(), got, "the rotation remap must be the identity on a consumer")
}

// TestSlash asserts that SlashWithInfractionReason never queues an evidence
// packet, for any infraction type. VAAS-owned tumbling-window tracking
// (downtime.go) is the sole source of downtime evidence; x/slashing calls
Expand Down
Loading