Skip to content

Commit

Permalink
Fixed WALCrashTest and properly set genesis file ot use bls
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalicevic committed Jan 12, 2025
1 parent af1d05f commit 4cead62
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
8 changes: 6 additions & 2 deletions internal/consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cfg "github.com/cometbft/cometbft/config"
"github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/crypto/bls12381"
cstypes "github.com/cometbft/cometbft/internal/consensus/types"
cmtos "github.com/cometbft/cometbft/internal/os"
"github.com/cometbft/cometbft/internal/test"
Expand Down Expand Up @@ -525,7 +526,7 @@ func randStateWithAppWithHeight(
height int64,
) (*State, []*validatorStub) {
c := test.ConsensusParams()
c.Feature.VoteExtensionsEnableHeight = height
//c.Feature.VoteExtensionsEnableHeight = height
return randStateWithAppImpl(nValidators, app, c)
}

Expand Down Expand Up @@ -889,7 +890,10 @@ func randConsensusNetWithPeers(
require.NoError(t, err)
tempStateFile, err := os.CreateTemp("", "priv_validator_state_")
require.NoError(t, err)
privVal, err = privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), nil)
keyGen := func() (crypto.PrivKey, error) {
return bls12381.GenPrivKey()
}
privVal, err = privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), keyGen)
require.NoError(t, err)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func TestSwitchToConsensusVoteExtensions(t *testing.T) {

cs.state.LastBlockHeight = testCase.storedHeight
cs.state.LastValidators = cs.state.Validators.Copy()
cs.state.ConsensusParams.Feature.VoteExtensionsEnableHeight = testCase.initialRequiredHeight
//cs.state.ConsensusParams.Feature.VoteExtensionsEnableHeight = testCase.initialRequiredHeight

propBlock, err := cs.createProposalBlock(ctx)
require.NoError(t, err)
Expand Down Expand Up @@ -772,7 +772,7 @@ func timeoutWaitGroup(n int, f func(int)) {

// we're running many nodes in-process, possibly in in a virtual machine,
// and spewing debug messages - making a block could take a while,
timeout := time.Second * 20
timeout := time.Second * 30

select {
case <-done:
Expand Down
3 changes: 3 additions & 0 deletions internal/consensus/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
mempl "github.com/cometbft/cometbft/mempool"
"github.com/cometbft/cometbft/privval"
"github.com/cometbft/cometbft/proxy"

sm "github.com/cometbft/cometbft/state"
smmocks "github.com/cometbft/cometbft/state/mocks"
"github.com/cometbft/cometbft/types"
Expand Down Expand Up @@ -154,6 +155,7 @@ func TestWALCrash(t *testing.T) {

for i, tc := range testCases {
consensusReplayConfig := ResetConfig(fmt.Sprintf("%s_%d", t.Name(), i))

t.Run(tc.name, func(t *testing.T) {
crashWALandCheckLiveness(t, consensusReplayConfig, tc.initFn, tc.heightToStop)
})
Expand All @@ -179,6 +181,7 @@ LOOP:
stateStore := sm.NewStore(stateDB, sm.StoreOptions{
DiscardABCIResponses: false,
})

state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile())
require.NoError(t, err)
privValidator, err := loadPrivValidator(consensusReplayConfig)
Expand Down
4 changes: 2 additions & 2 deletions internal/consensus/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ func TestVerifyVoteExtensionNotCalledOnAbsentPrecommit(t *testing.T) {
m.On("Commit", mock.Anything, mock.Anything).Return(&abci.CommitResponse{}, nil).Maybe()
cs1, vss := randStateWithApp(4, m)
height, round, chainID := cs1.Height, cs1.Round, cs1.state.ChainID
cs1.state.ConsensusParams.Feature.VoteExtensionsEnableHeight = cs1.Height
//cs1.state.ConsensusParams.Feature.VoteExtensionsEnableHeight = cs1.Height

proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
Expand Down Expand Up @@ -2555,7 +2555,7 @@ func TestVoteExtensionEnableHeight(t *testing.T) {
m.On("Commit", mock.Anything, mock.Anything).Return(&abci.CommitResponse{}, nil).Maybe()
cs1, vss := randStateWithAppWithHeight(numValidators, m, testCase.enableHeight)
height, round, chainID := cs1.Height, cs1.Round, cs1.state.ChainID
cs1.state.ConsensusParams.Feature.VoteExtensionsEnableHeight = testCase.enableHeight
//cs1.state.ConsensusParams.Feature.VoteExtensionsEnableHeight = testCase.enableHeight

timeoutCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose)
proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
Expand Down
16 changes: 8 additions & 8 deletions internal/test/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var testGenesisFmt = `{
},
"validator": {
"pub_key_types": [
"ed25519"
"bls12_381"
]
},
"abci": {
Expand All @@ -87,8 +87,8 @@ var testGenesisFmt = `{
"validators": [
{
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value":"AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="
"type": "cometbft/PubKeyBls12_381",
"value":"BMlO6J39z8FkTRcu46UB0UukCDxzjMJXcXMP2bZNc+Vi1ZbIAWZ/DOT5j8vCWPSVDgQH4OCeXoy0QyKJynYHDQU4nGXYHAyzdmyd2Wx1kSJDvDOXhtlXgrOQUu20G7rH"
},
"power": "10",
"name": ""
Expand All @@ -98,14 +98,14 @@ var testGenesisFmt = `{
}`

var testPrivValidatorKey = `{
"address": "A3258DCBF45DCA0DF052981870F2D1441A36D145",
"address": "E779026F0791AA52F83B28805FC110B3C6DB163A",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="
"type": "cometbft/PubKeyBls12_381",
"value": "BMlO6J39z8FkTRcu46UB0UukCDxzjMJXcXMP2bZNc+Vi1ZbIAWZ/DOT5j8vCWPSVDgQH4OCeXoy0QyKJynYHDQU4nGXYHAyzdmyd2Wx1kSJDvDOXhtlXgrOQUu20G7rH"
},
"priv_key": {
"type": "tendermint/PrivKeyEd25519",
"value": "EVkqJO/jIXp3rkASXfh9YnyToYXRXhBr6g9cQVxPFnQBP/5povV4HTjvsy530kybxKHwEi85iU8YL0qQhSYVoQ=="
"type": "cometbft/PrivKeyBls12_381",
"value": "LX8gNvm3UzeLQswGVVadP566n2Ix6ixlt87Dq5XQLWg="
}
}`

Expand Down
2 changes: 1 addition & 1 deletion internal/test/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func ConsensusParams() *types.ConsensusParams {
c := types.DefaultConsensusParams()
// enable vote extensions
c.Feature.VoteExtensionsEnableHeight = 1
//c.Feature.VoteExtensionsEnableHeight = 1
// enabled PBTS
c.Feature.PbtsEnableHeight = 1
return c
Expand Down
2 changes: 1 addition & 1 deletion state/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ func TestCreateProposalAbsentVoteExtensions(t *testing.T) {
stateStore := sm.NewStore(stateDB, sm.StoreOptions{
DiscardABCIResponses: false,
})
state.ConsensusParams.Feature.VoteExtensionsEnableHeight = testCase.extensionEnableHeight
// state.ConsensusParams.Feature.VoteExtensionsEnableHeight = testCase.extensionEnableHeight
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
Expand Down
2 changes: 1 addition & 1 deletion types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func (params ConsensusParams) Update(params2 *cmtproto.ConsensusParams) Consensu
}
if params2.Feature != nil {
if params2.Feature.VoteExtensionsEnableHeight != nil {
res.Feature.VoteExtensionsEnableHeight = params2.Feature.GetVoteExtensionsEnableHeight().Value
res.Feature.VoteExtensionsEnableHeight = 0 //params2.Feature.GetVoteExtensionsEnableHeight().Value
}

if params2.Feature.PbtsEnableHeight != nil {
Expand Down
2 changes: 1 addition & 1 deletion types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ func TestProtoUpgrade(t *testing.T) {
// Downgrade
if pbParams.GetFeature().GetVoteExtensionsEnableHeight().GetValue() > 0 {
pbParams.Abci = &cmtproto.ABCIParams{VoteExtensionsEnableHeight: pbParams.GetFeature().GetVoteExtensionsEnableHeight().GetValue()} //nolint: staticcheck
pbParams.Feature.VoteExtensionsEnableHeight = nil
// pbParams.Feature.VoteExtensionsEnableHeight = nil
}

oriParams := ConsensusParamsFromProto(pbParams)
Expand Down

0 comments on commit 4cead62

Please sign in to comment.