mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-19 05:36:15 +00:00
proto: deduplicate consensus params (#9287)
This commit is contained in:
+8
-9
@@ -12,7 +12,6 @@ import (
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
tmos "github.com/tendermint/tendermint/libs/os"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
|
||||
@@ -37,13 +36,13 @@ type GenesisValidator struct {
|
||||
|
||||
// GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
|
||||
type GenesisDoc struct {
|
||||
GenesisTime time.Time `json:"genesis_time"`
|
||||
ChainID string `json:"chain_id"`
|
||||
InitialHeight int64 `json:"initial_height"`
|
||||
ConsensusParams *tmproto.ConsensusParams `json:"consensus_params,omitempty"`
|
||||
Validators []GenesisValidator `json:"validators,omitempty"`
|
||||
AppHash tmbytes.HexBytes `json:"app_hash"`
|
||||
AppState json.RawMessage `json:"app_state,omitempty"`
|
||||
GenesisTime time.Time `json:"genesis_time"`
|
||||
ChainID string `json:"chain_id"`
|
||||
InitialHeight int64 `json:"initial_height"`
|
||||
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
|
||||
Validators []GenesisValidator `json:"validators,omitempty"`
|
||||
AppHash tmbytes.HexBytes `json:"app_hash"`
|
||||
AppState json.RawMessage `json:"app_state,omitempty"`
|
||||
}
|
||||
|
||||
// SaveAs is a utility method for saving GenensisDoc as a JSON file.
|
||||
@@ -83,7 +82,7 @@ func (genDoc *GenesisDoc) ValidateAndComplete() error {
|
||||
|
||||
if genDoc.ConsensusParams == nil {
|
||||
genDoc.ConsensusParams = DefaultConsensusParams()
|
||||
} else if err := ValidateConsensusParams(*genDoc.ConsensusParams); err != nil {
|
||||
} else if err := genDoc.ConsensusParams.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
+101
-25
@@ -5,7 +5,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
)
|
||||
@@ -19,11 +20,52 @@ const (
|
||||
|
||||
// MaxBlockPartsCount is the maximum number of block parts.
|
||||
MaxBlockPartsCount = (MaxBlockSizeBytes / BlockPartSizeBytes) + 1
|
||||
|
||||
ABCIPubKeyTypeEd25519 = ed25519.KeyType
|
||||
ABCIPubKeyTypeSecp256k1 = secp256k1.KeyType
|
||||
)
|
||||
|
||||
var ABCIPubKeyTypesToNames = map[string]string{
|
||||
ABCIPubKeyTypeEd25519: ed25519.PubKeyName,
|
||||
ABCIPubKeyTypeSecp256k1: secp256k1.PubKeyName,
|
||||
}
|
||||
|
||||
// ConsensusParams contains consensus critical parameters that determine the
|
||||
// validity of blocks.
|
||||
type ConsensusParams struct {
|
||||
Block BlockParams `json:"block"`
|
||||
Evidence EvidenceParams `json:"evidence"`
|
||||
Validator ValidatorParams `json:"validator"`
|
||||
Version VersionParams `json:"version"`
|
||||
}
|
||||
|
||||
// BlockParams define limits on the block size and gas plus minimum time
|
||||
// between blocks.
|
||||
type BlockParams struct {
|
||||
MaxBytes int64 `json:"max_bytes"`
|
||||
MaxGas int64 `json:"max_gas"`
|
||||
}
|
||||
|
||||
// EvidenceParams determine how we handle evidence of malfeasance.
|
||||
type EvidenceParams struct {
|
||||
MaxAgeNumBlocks int64 `json:"max_age_num_blocks"` // only accept new evidence more recent than this
|
||||
MaxAgeDuration time.Duration `json:"max_age_duration"`
|
||||
MaxBytes int64 `json:"max_bytes"`
|
||||
}
|
||||
|
||||
// ValidatorParams restrict the public key types validators can use.
|
||||
// NOTE: uses ABCI pubkey naming, not Amino names.
|
||||
type ValidatorParams struct {
|
||||
PubKeyTypes []string `json:"pub_key_types"`
|
||||
}
|
||||
|
||||
type VersionParams struct {
|
||||
App uint64 `json:"app"`
|
||||
}
|
||||
|
||||
// DefaultConsensusParams returns a default ConsensusParams.
|
||||
func DefaultConsensusParams() *tmproto.ConsensusParams {
|
||||
return &tmproto.ConsensusParams{
|
||||
func DefaultConsensusParams() *ConsensusParams {
|
||||
return &ConsensusParams{
|
||||
Block: DefaultBlockParams(),
|
||||
Evidence: DefaultEvidenceParams(),
|
||||
Validator: DefaultValidatorParams(),
|
||||
@@ -32,17 +74,16 @@ func DefaultConsensusParams() *tmproto.ConsensusParams {
|
||||
}
|
||||
|
||||
// DefaultBlockParams returns a default BlockParams.
|
||||
func DefaultBlockParams() tmproto.BlockParams {
|
||||
return tmproto.BlockParams{
|
||||
MaxBytes: 22020096, // 21MB
|
||||
MaxGas: -1,
|
||||
TimeIotaMs: 1000, // 1s
|
||||
func DefaultBlockParams() BlockParams {
|
||||
return BlockParams{
|
||||
MaxBytes: 22020096, // 21MB
|
||||
MaxGas: -1,
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultEvidenceParams returns a default EvidenceParams.
|
||||
func DefaultEvidenceParams() tmproto.EvidenceParams {
|
||||
return tmproto.EvidenceParams{
|
||||
func DefaultEvidenceParams() EvidenceParams {
|
||||
return EvidenceParams{
|
||||
MaxAgeNumBlocks: 100000, // 27.8 hrs at 1block/s
|
||||
MaxAgeDuration: 48 * time.Hour,
|
||||
MaxBytes: 1048576, // 1MB
|
||||
@@ -51,19 +92,19 @@ func DefaultEvidenceParams() tmproto.EvidenceParams {
|
||||
|
||||
// DefaultValidatorParams returns a default ValidatorParams, which allows
|
||||
// only ed25519 pubkeys.
|
||||
func DefaultValidatorParams() tmproto.ValidatorParams {
|
||||
return tmproto.ValidatorParams{
|
||||
func DefaultValidatorParams() ValidatorParams {
|
||||
return ValidatorParams{
|
||||
PubKeyTypes: []string{ABCIPubKeyTypeEd25519},
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultVersionParams() tmproto.VersionParams {
|
||||
return tmproto.VersionParams{
|
||||
AppVersion: 0,
|
||||
func DefaultVersionParams() VersionParams {
|
||||
return VersionParams{
|
||||
App: 0,
|
||||
}
|
||||
}
|
||||
|
||||
func IsValidPubkeyType(params tmproto.ValidatorParams, pubkeyType string) bool {
|
||||
func IsValidPubkeyType(params ValidatorParams, pubkeyType string) bool {
|
||||
for i := 0; i < len(params.PubKeyTypes); i++ {
|
||||
if params.PubKeyTypes[i] == pubkeyType {
|
||||
return true
|
||||
@@ -74,7 +115,7 @@ func IsValidPubkeyType(params tmproto.ValidatorParams, pubkeyType string) bool {
|
||||
|
||||
// Validate validates the ConsensusParams to ensure all values are within their
|
||||
// allowed limits, and returns an error if they are not.
|
||||
func ValidateConsensusParams(params tmproto.ConsensusParams) error {
|
||||
func (params ConsensusParams) ValidateBasic() error {
|
||||
if params.Block.MaxBytes <= 0 {
|
||||
return fmt.Errorf("block.MaxBytes must be greater than 0. Got %d",
|
||||
params.Block.MaxBytes)
|
||||
@@ -89,11 +130,6 @@ func ValidateConsensusParams(params tmproto.ConsensusParams) error {
|
||||
params.Block.MaxGas)
|
||||
}
|
||||
|
||||
if params.Block.TimeIotaMs <= 0 {
|
||||
return fmt.Errorf("block.TimeIotaMs must be greater than 0. Got %v",
|
||||
params.Block.TimeIotaMs)
|
||||
}
|
||||
|
||||
if params.Evidence.MaxAgeNumBlocks <= 0 {
|
||||
return fmt.Errorf("evidence.MaxAgeNumBlocks must be greater than 0. Got %d",
|
||||
params.Evidence.MaxAgeNumBlocks)
|
||||
@@ -134,7 +170,7 @@ func ValidateConsensusParams(params tmproto.ConsensusParams) error {
|
||||
// Only the Block.MaxBytes and Block.MaxGas are included in the hash.
|
||||
// This allows the ConsensusParams to evolve more without breaking the block
|
||||
// protocol. No need for a Merkle tree here, just a small struct to hash.
|
||||
func HashConsensusParams(params tmproto.ConsensusParams) []byte {
|
||||
func (params ConsensusParams) Hash() []byte {
|
||||
hasher := tmhash.New()
|
||||
|
||||
hp := tmproto.HashedParams{
|
||||
@@ -156,7 +192,7 @@ func HashConsensusParams(params tmproto.ConsensusParams) []byte {
|
||||
|
||||
// Update returns a copy of the params with updates from the non-zero fields of p2.
|
||||
// NOTE: note: must not modify the original
|
||||
func UpdateConsensusParams(params tmproto.ConsensusParams, params2 *abci.ConsensusParams) tmproto.ConsensusParams {
|
||||
func (params ConsensusParams) Update(params2 *tmproto.ConsensusParams) ConsensusParams {
|
||||
res := params // explicit copy
|
||||
|
||||
if params2 == nil {
|
||||
@@ -179,7 +215,47 @@ func UpdateConsensusParams(params tmproto.ConsensusParams, params2 *abci.Consens
|
||||
res.Validator.PubKeyTypes = append([]string{}, params2.Validator.PubKeyTypes...)
|
||||
}
|
||||
if params2.Version != nil {
|
||||
res.Version.AppVersion = params2.Version.AppVersion
|
||||
res.Version.App = params2.Version.App
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
|
||||
return tmproto.ConsensusParams{
|
||||
Block: &tmproto.BlockParams{
|
||||
MaxBytes: params.Block.MaxBytes,
|
||||
MaxGas: params.Block.MaxGas,
|
||||
},
|
||||
Evidence: &tmproto.EvidenceParams{
|
||||
MaxAgeNumBlocks: params.Evidence.MaxAgeNumBlocks,
|
||||
MaxAgeDuration: params.Evidence.MaxAgeDuration,
|
||||
MaxBytes: params.Evidence.MaxBytes,
|
||||
},
|
||||
Validator: &tmproto.ValidatorParams{
|
||||
PubKeyTypes: params.Validator.PubKeyTypes,
|
||||
},
|
||||
Version: &tmproto.VersionParams{
|
||||
App: params.Version.App,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams {
|
||||
return ConsensusParams{
|
||||
Block: BlockParams{
|
||||
MaxBytes: pbParams.Block.MaxBytes,
|
||||
MaxGas: pbParams.Block.MaxGas,
|
||||
},
|
||||
Evidence: EvidenceParams{
|
||||
MaxAgeNumBlocks: pbParams.Evidence.MaxAgeNumBlocks,
|
||||
MaxAgeDuration: pbParams.Evidence.MaxAgeDuration,
|
||||
MaxBytes: pbParams.Evidence.MaxBytes,
|
||||
},
|
||||
Validator: ValidatorParams{
|
||||
PubKeyTypes: pbParams.Validator.PubKeyTypes,
|
||||
},
|
||||
Version: VersionParams{
|
||||
App: pbParams.Version.App,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
+72
-54
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
)
|
||||
|
||||
@@ -19,77 +18,73 @@ var (
|
||||
|
||||
func TestConsensusParamsValidation(t *testing.T) {
|
||||
testCases := []struct {
|
||||
params tmproto.ConsensusParams
|
||||
params ConsensusParams
|
||||
valid bool
|
||||
}{
|
||||
// test block params
|
||||
0: {makeParams(1, 0, 10, 2, 0, valEd25519), true},
|
||||
1: {makeParams(0, 0, 10, 2, 0, valEd25519), false},
|
||||
2: {makeParams(47*1024*1024, 0, 10, 2, 0, valEd25519), true},
|
||||
3: {makeParams(10, 0, 10, 2, 0, valEd25519), true},
|
||||
4: {makeParams(100*1024*1024, 0, 10, 2, 0, valEd25519), true},
|
||||
5: {makeParams(101*1024*1024, 0, 10, 2, 0, valEd25519), false},
|
||||
6: {makeParams(1024*1024*1024, 0, 10, 2, 0, valEd25519), false},
|
||||
7: {makeParams(1024*1024*1024, 0, 10, -1, 0, valEd25519), false},
|
||||
8: {makeParams(1, 0, -10, 2, 0, valEd25519), false},
|
||||
0: {makeParams(1, 0, 2, 0, valEd25519), true},
|
||||
1: {makeParams(0, 0, 2, 0, valEd25519), false},
|
||||
2: {makeParams(47*1024*1024, 0, 2, 0, valEd25519), true},
|
||||
3: {makeParams(10, 0, 2, 0, valEd25519), true},
|
||||
4: {makeParams(100*1024*1024, 0, 2, 0, valEd25519), true},
|
||||
5: {makeParams(101*1024*1024, 0, 2, 0, valEd25519), false},
|
||||
6: {makeParams(1024*1024*1024, 0, 2, 0, valEd25519), false},
|
||||
// test evidence params
|
||||
9: {makeParams(1, 0, 10, 0, 0, valEd25519), false},
|
||||
10: {makeParams(1, 0, 10, 2, 2, valEd25519), false},
|
||||
11: {makeParams(1000, 0, 10, 2, 1, valEd25519), true},
|
||||
12: {makeParams(1, 0, 10, -1, 0, valEd25519), false},
|
||||
7: {makeParams(1, 0, 0, 0, valEd25519), false},
|
||||
8: {makeParams(1, 0, 2, 2, valEd25519), false},
|
||||
9: {makeParams(1000, 0, 2, 1, valEd25519), true},
|
||||
10: {makeParams(1, 0, -1, 0, valEd25519), false},
|
||||
// test no pubkey type provided
|
||||
13: {makeParams(1, 0, 10, 2, 0, []string{}), false},
|
||||
11: {makeParams(1, 0, 2, 0, []string{}), false},
|
||||
// test invalid pubkey type provided
|
||||
14: {makeParams(1, 0, 10, 2, 0, []string{"potatoes make good pubkeys"}), false},
|
||||
12: {makeParams(1, 0, 2, 0, []string{"potatoes make good pubkeys"}), false},
|
||||
}
|
||||
for i, tc := range testCases {
|
||||
if tc.valid {
|
||||
assert.NoErrorf(t, ValidateConsensusParams(tc.params), "expected no error for valid params (#%d)", i)
|
||||
assert.NoErrorf(t, tc.params.ValidateBasic(), "expected no error for valid params (#%d)", i)
|
||||
} else {
|
||||
assert.Errorf(t, ValidateConsensusParams(tc.params), "expected error for non valid params (#%d)", i)
|
||||
assert.Errorf(t, tc.params.ValidateBasic(), "expected error for non valid params (#%d)", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func makeParams(
|
||||
blockBytes, blockGas int64,
|
||||
blockTimeIotaMs int64,
|
||||
evidenceAge int64,
|
||||
maxEvidenceBytes int64,
|
||||
pubkeyTypes []string,
|
||||
) tmproto.ConsensusParams {
|
||||
return tmproto.ConsensusParams{
|
||||
Block: tmproto.BlockParams{
|
||||
MaxBytes: blockBytes,
|
||||
MaxGas: blockGas,
|
||||
TimeIotaMs: blockTimeIotaMs,
|
||||
) ConsensusParams {
|
||||
return ConsensusParams{
|
||||
Block: BlockParams{
|
||||
MaxBytes: blockBytes,
|
||||
MaxGas: blockGas,
|
||||
},
|
||||
Evidence: tmproto.EvidenceParams{
|
||||
Evidence: EvidenceParams{
|
||||
MaxAgeNumBlocks: evidenceAge,
|
||||
MaxAgeDuration: time.Duration(evidenceAge),
|
||||
MaxBytes: maxEvidenceBytes,
|
||||
},
|
||||
Validator: tmproto.ValidatorParams{
|
||||
Validator: ValidatorParams{
|
||||
PubKeyTypes: pubkeyTypes,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsensusParamsHash(t *testing.T) {
|
||||
params := []tmproto.ConsensusParams{
|
||||
makeParams(4, 2, 10, 3, 1, valEd25519),
|
||||
makeParams(1, 4, 10, 3, 1, valEd25519),
|
||||
makeParams(1, 2, 10, 4, 1, valEd25519),
|
||||
makeParams(2, 5, 10, 7, 1, valEd25519),
|
||||
makeParams(1, 7, 10, 6, 1, valEd25519),
|
||||
makeParams(9, 5, 10, 4, 1, valEd25519),
|
||||
makeParams(7, 8, 10, 9, 1, valEd25519),
|
||||
makeParams(4, 6, 10, 5, 1, valEd25519),
|
||||
params := []ConsensusParams{
|
||||
makeParams(4, 2, 3, 1, valEd25519),
|
||||
makeParams(1, 4, 3, 1, valEd25519),
|
||||
makeParams(1, 2, 4, 1, valEd25519),
|
||||
makeParams(2, 5, 7, 1, valEd25519),
|
||||
makeParams(1, 7, 6, 1, valEd25519),
|
||||
makeParams(9, 5, 4, 1, valEd25519),
|
||||
makeParams(7, 8, 9, 1, valEd25519),
|
||||
makeParams(4, 6, 5, 1, valEd25519),
|
||||
}
|
||||
|
||||
hashes := make([][]byte, len(params))
|
||||
for i := range params {
|
||||
hashes[i] = HashConsensusParams(params[i])
|
||||
hashes[i] = params[i].Hash()
|
||||
}
|
||||
|
||||
// make sure there are no duplicates...
|
||||
@@ -104,21 +99,21 @@ func TestConsensusParamsHash(t *testing.T) {
|
||||
|
||||
func TestConsensusParamsUpdate(t *testing.T) {
|
||||
testCases := []struct {
|
||||
params tmproto.ConsensusParams
|
||||
updates *abci.ConsensusParams
|
||||
updatedParams tmproto.ConsensusParams
|
||||
params ConsensusParams
|
||||
updates *tmproto.ConsensusParams
|
||||
updatedParams ConsensusParams
|
||||
}{
|
||||
// empty updates
|
||||
{
|
||||
makeParams(1, 2, 10, 3, 0, valEd25519),
|
||||
&abci.ConsensusParams{},
|
||||
makeParams(1, 2, 10, 3, 0, valEd25519),
|
||||
makeParams(1, 2, 3, 0, valEd25519),
|
||||
&tmproto.ConsensusParams{},
|
||||
makeParams(1, 2, 3, 0, valEd25519),
|
||||
},
|
||||
// fine updates
|
||||
{
|
||||
makeParams(1, 2, 10, 3, 0, valEd25519),
|
||||
&abci.ConsensusParams{
|
||||
Block: &abci.BlockParams{
|
||||
makeParams(1, 2, 3, 0, valEd25519),
|
||||
&tmproto.ConsensusParams{
|
||||
Block: &tmproto.BlockParams{
|
||||
MaxBytes: 100,
|
||||
MaxGas: 200,
|
||||
},
|
||||
@@ -131,21 +126,44 @@ func TestConsensusParamsUpdate(t *testing.T) {
|
||||
PubKeyTypes: valSecp256k1,
|
||||
},
|
||||
},
|
||||
makeParams(100, 200, 10, 300, 50, valSecp256k1),
|
||||
makeParams(100, 200, 300, 50, valSecp256k1),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
assert.Equal(t, tc.updatedParams, UpdateConsensusParams(tc.params, tc.updates))
|
||||
assert.Equal(t, tc.updatedParams, tc.params.Update(tc.updates))
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsensusParamsUpdate_AppVersion(t *testing.T) {
|
||||
params := makeParams(1, 2, 10, 3, 0, valEd25519)
|
||||
params := makeParams(1, 2, 3, 0, valEd25519)
|
||||
|
||||
assert.EqualValues(t, 0, params.Version.AppVersion)
|
||||
assert.EqualValues(t, 0, params.Version.App)
|
||||
|
||||
updated := UpdateConsensusParams(params,
|
||||
&abci.ConsensusParams{Version: &tmproto.VersionParams{AppVersion: 1}})
|
||||
updated := params.Update(
|
||||
&tmproto.ConsensusParams{Version: &tmproto.VersionParams{App: 1}})
|
||||
|
||||
assert.EqualValues(t, 1, updated.Version.AppVersion)
|
||||
assert.EqualValues(t, 1, updated.Version.App)
|
||||
}
|
||||
|
||||
func TestProto(t *testing.T) {
|
||||
params := []ConsensusParams{
|
||||
makeParams(4, 2, 3, 1, valEd25519),
|
||||
makeParams(1, 4, 3, 1, valEd25519),
|
||||
makeParams(1, 2, 4, 1, valEd25519),
|
||||
makeParams(2, 5, 7, 1, valEd25519),
|
||||
makeParams(1, 7, 6, 1, valEd25519),
|
||||
makeParams(9, 5, 4, 1, valEd25519),
|
||||
makeParams(7, 8, 9, 1, valEd25519),
|
||||
makeParams(4, 6, 5, 1, valEd25519),
|
||||
}
|
||||
|
||||
for i := range params {
|
||||
pbParams := params[i].ToProto()
|
||||
|
||||
oriParams := ConsensusParamsFromProto(pbParams)
|
||||
|
||||
assert.Equal(t, params[i], oriParams)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,27 +3,10 @@ package types
|
||||
import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
)
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Use strings to distinguish types in ABCI messages
|
||||
|
||||
const (
|
||||
ABCIPubKeyTypeEd25519 = ed25519.KeyType
|
||||
ABCIPubKeyTypeSecp256k1 = secp256k1.KeyType
|
||||
)
|
||||
|
||||
// TODO: Make non-global by allowing for registration of more pubkey types
|
||||
|
||||
var ABCIPubKeyTypesToNames = map[string]string{
|
||||
ABCIPubKeyTypeEd25519: ed25519.PubKeyName,
|
||||
ABCIPubKeyTypeSecp256k1: secp256k1.PubKeyName,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
||||
// TM2PB is used for converting Tendermint ABCI to protobuf ABCI.
|
||||
@@ -97,17 +80,6 @@ func (tm2pb) ValidatorUpdates(vals *ValidatorSet) []abci.ValidatorUpdate {
|
||||
return validators
|
||||
}
|
||||
|
||||
func (tm2pb) ConsensusParams(params *tmproto.ConsensusParams) *abci.ConsensusParams {
|
||||
return &abci.ConsensusParams{
|
||||
Block: &abci.BlockParams{
|
||||
MaxBytes: params.Block.MaxBytes,
|
||||
MaxGas: params.Block.MaxGas,
|
||||
},
|
||||
Evidence: ¶ms.Evidence,
|
||||
Validator: ¶ms.Validator,
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: panics on nil or unknown pubkey type
|
||||
func (tm2pb) NewValidatorUpdate(pubkey crypto.PubKey, power int64) abci.ValidatorUpdate {
|
||||
pubkeyABCI, err := cryptoenc.PubKeyToProto(pubkey)
|
||||
|
||||
@@ -52,14 +52,6 @@ func TestABCIValidators(t *testing.T) {
|
||||
assert.Equal(t, tmValExpected, tmVals[0])
|
||||
}
|
||||
|
||||
func TestABCIConsensusParams(t *testing.T) {
|
||||
cp := DefaultConsensusParams()
|
||||
abciCP := TM2PB.ConsensusParams(cp)
|
||||
cp2 := UpdateConsensusParams(*cp, abciCP)
|
||||
|
||||
assert.Equal(t, *cp, cp2)
|
||||
}
|
||||
|
||||
type pubKeyEddie struct{}
|
||||
|
||||
func (pubKeyEddie) Address() Address { return []byte{} }
|
||||
|
||||
Reference in New Issue
Block a user