refactor: bring cometbft back to v0.38.x family (#25285)

This commit is contained in:
Alex | Interchain Labs
2025-08-29 15:58:04 -04:00
committed by GitHub
parent a37940077e
commit 727faf0484
446 changed files with 15286 additions and 103152 deletions
+22 -13
View File
@@ -7,9 +7,9 @@ import (
"testing"
"time"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
abci "github.com/cometbft/cometbft/v2/abci/types"
"github.com/cometbft/cometbft/v2/crypto/tmhash"
abci "github.com/cometbft/cometbft/abci/types"
cryptoenc "github.com/cometbft/cometbft/crypto/encoding"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
)
type mockValidator struct {
@@ -19,7 +19,7 @@ type mockValidator struct {
func (mv mockValidator) String() string {
return fmt.Sprintf("mockValidator{%s power:%v state:%v}",
string(mv.val.PubKeyBytes),
mv.val.PubKey.String(),
mv.val.Power,
mv.livenessState)
}
@@ -31,7 +31,7 @@ func newMockValidators(r *rand.Rand, abciVals []abci.ValidatorUpdate, params Par
validators := make(mockValidators)
for _, validator := range abciVals {
str := fmt.Sprintf("%X", validator.PubKeyBytes)
str := fmt.Sprintf("%X", validator.PubKey.GetEd25519())
liveliness := GetMemberOfInitialState(r, params.InitialLivenessWeightings())
validators[str] = mockValidator{
@@ -68,8 +68,12 @@ func (vals mockValidators) randomProposer(r *rand.Rand) []byte {
key := keys[r.Intn(len(keys))]
proposer := vals[key].val
pk, err := cryptoenc.PubKeyFromProto(proposer.PubKey)
if err != nil {
panic(err)
}
return tmhash.SumTruncated(proposer.PubKeyBytes)
return pk.Address()
}
// updateValidators mimics CometBFT's update logic.
@@ -84,7 +88,7 @@ func updateValidators(
tb.Helper()
for _, update := range updates {
str := fmt.Sprintf("%X", update.PubKeyBytes)
str := fmt.Sprintf("%X", update.PubKey.GetEd25519())
if update.Power == 0 {
if _, ok := current[str]; !ok {
@@ -121,9 +125,9 @@ func RandomRequestFinalizeBlock(
blockHeight int64,
time time.Time,
proposer []byte,
) *abci.FinalizeBlockRequest {
) *abci.RequestFinalizeBlock {
if len(validators) == 0 {
return &abci.FinalizeBlockRequest{
return &abci.RequestFinalizeBlock{
Height: blockHeight,
Time: time,
ProposerAddress: proposer,
@@ -157,9 +161,14 @@ func RandomRequestFinalizeBlock(
commitStatus = cmtproto.BlockIDFlagAbsent
}
pubkey, err := cryptoenc.PubKeyFromProto(mVal.val.PubKey)
if err != nil {
panic(err)
}
voteInfos[i] = abci.VoteInfo{
Validator: abci.Validator{
Address: tmhash.SumTruncated(mVal.val.PubKeyBytes),
Address: pubkey.Address(),
Power: mVal.val.Power,
},
BlockIdFlag: commitStatus,
@@ -168,7 +177,7 @@ func RandomRequestFinalizeBlock(
// return if no past times
if len(pastTimes) == 0 {
return &abci.FinalizeBlockRequest{
return &abci.RequestFinalizeBlock{
Height: blockHeight,
Time: time,
ProposerAddress: proposer,
@@ -201,7 +210,7 @@ func RandomRequestFinalizeBlock(
evidence = append(evidence,
abci.Misbehavior{
Type: abci.MISBEHAVIOR_TYPE_DUPLICATE_VOTE,
Type: abci.MisbehaviorType_DUPLICATE_VOTE,
Validator: validator,
Height: height,
Time: misbehaviorTime,
@@ -212,7 +221,7 @@ func RandomRequestFinalizeBlock(
event("begin_block", "evidence", "ok")
}
return &abci.FinalizeBlockRequest{
return &abci.RequestFinalizeBlock{
Height: blockHeight,
Time: time,
ProposerAddress: proposer,
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"encoding/json"
"math/rand"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
"github.com/cometbft/cometbft/v2/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/simulation"
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"math/rand"
"testing"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
+3 -3
View File
@@ -10,8 +10,8 @@ import (
"testing"
"time"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
abci "github.com/cometbft/cometbft/v2/abci/types"
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"cosmossdk.io/core/header"
"cosmossdk.io/log"
@@ -40,7 +40,7 @@ func initChain(
}
appState, accounts, chainID, genesisTimestamp := appStateFn(r, accounts, config)
consensusParams := randomConsensusParams(r, appState, cdc, blockMaxGas)
req := abci.InitChainRequest{
req := abci.RequestInitChain{
AppStateBytes: appState,
ChainId: chainID,
ConsensusParams: consensusParams,