Skip to content

Regression in validator initialization #2937

@ebuchman

Description

@ebuchman

Bug in SDK testing due to upgrading to v0.26.4:

--- FAIL: TestKeys (0.14s)
panic: validator set initialization slice cannot be an empty slice (but it can be nil) [recovered]
    panic: validator set initialization slice cannot be an empty slice (but it can be nil)

goroutine 56 [running]:
testing.tRunner.func1(0xc000190e00)
    /usr/local/go/src/testing/testing.go:792 +0x387
panic(0xe74c40, 0x14b6880)
    /usr/local/go/src/runtime/panic.go:513 +0x1b9
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/types.NewValidatorSet(0x1d1a448, 0x0, 0x0, 0x1d1a448)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/types/validator_set.go:35 +0x282
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus.(*Handshaker).ReplayBlocks(0xc000b59080, 0x7, 0x0, 0x1005f91, 0x6, 0xc00003a2c0, 0xf, 0x0, 0x0, 0x0, ...)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus/replay.go:283 +0x3c2
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus.(*Handshaker).Handshake(0xc000b59080, 0x14d15c0, 0xc000245880, 0x2, 0x14c7080)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus/replay.go:252 +0x4c8
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/node.NewNode(0xc0008a05a0, 0x14c83c0, 0xc0000d6140, 0xc0001ac3b0, 0x14bacc0, 0xc000b5b080, 0xc0001ac3a0, 0x13c7db8, 0xc0001ac470, 0x14c7080, ...)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/node/node.go:204 +0x6cf
github.com/cosmos/cosmos-sdk/client/lcd.startTM(0xc0008a05a0, 0x14c7080, 0xc0004ba980, 0xc0004a0a00, 0x14c83c0, 0xc0000d6140, 0x14cdc20, 0xc000919c00, 0x0, 0x0, ...)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/client/lcd/test_helpers.go:340 +0x27e
github.com/cosmos/cosmos-sdk/client/lcd.InitializeTestLCD(0xc000190e00, 0x1, 0xc000b77f30, 0x1, 0x1, 0x14d3b80, 0xc00007fb30, 0xc000210460, 0x14, 0x20, ...)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/client/lcd/test_helpers.go:302 +0x2015
github.com/cosmos/cosmos-sdk/client/lcd.TestKeys(0xc000190e00)
    /home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/client/lcd/lcd_test.go:45 +0x138
testing.tRunner(0xc000190e00, 0x13c7d50)
    /usr/local/go/src/testing/testing.go:827 +0xbf
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:878 +0x353
FAIL    github.com/cosmos/cosmos-sdk/client/lcd    0.165s

Looks like it's due to fe3b97f since in

-               nextVals := types.TM2PB.ValidatorUpdates(state.NextValidators) // state.Validators would work too.
+               validators := make([]*types.Validator, len(h.genDoc.Validators))
+               for i, val := range h.genDoc.Validators {
+                       validators[i] = types.NewValidator(val.PubKey, val.Power)
+               }
+               validatorSet := types.NewValidatorSet(validators)
+               nextVals := types.TM2PB.ValidatorUpdates(validatorSet)
                csParams := types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams)

The genDoc.Validators could be nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions