proto: deduplicate consensus params (#9287)

This commit is contained in:
Callum Waters
2022-08-22 10:50:21 +02:00
committed by GitHub
parent 0ca3a89c90
commit 2d8df1bd4e
29 changed files with 623 additions and 1164 deletions

View File

@@ -15,9 +15,12 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [abci/counter] \#6684 Delete counter example app
- [txResults] \#9175 Remove `gas_used` & `gas_wanted` from being merkelized in the lastresulthash in the header
- [abci] \#5783 Make length delimiter encoding consistent (`uint64`) between ABCI and P2P wire-level protocols
- [abci] \#9145 Removes Response/Request `SetOption` from ABCI
- [abci] \#9145 Removes unused Response/Request `SetOption` from ABCI (@samricotta)
- [abci] \#8656 Added cli command for `PrepareProposal`. (@jmalicevic)
- [abci] \#8901 Added cli command for `ProcessProposal`. (@hvanz)
- [abci/params] \#9287 Deduplicate `ConsensusParams` and `BlockParams` so only `types` proto definitions are used (@cmwaters)
- Remove `TimeIotaMs` and use a hard-coded 1 millisecond value to ensure monotonically increasing block times.
- Rename `AppVersion` to `App` so as to not stutter.
- P2P Protocol

File diff suppressed because it is too large Load Diff

View File

@@ -307,12 +307,12 @@ func (h *Handshaker) ReplayBlocks(
}
validatorSet := types.NewValidatorSet(validators)
nextVals := types.TM2PB.ValidatorUpdates(validatorSet)
csParams := types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams)
pbparams := h.genDoc.ConsensusParams.ToProto()
req := abci.RequestInitChain{
Time: h.genDoc.GenesisTime,
ChainId: h.genDoc.ChainID,
InitialHeight: h.genDoc.InitialHeight,
ConsensusParams: csParams,
ConsensusParams: &pbparams,
Validators: nextVals,
AppStateBytes: h.genDoc.AppState,
}
@@ -344,8 +344,8 @@ func (h *Handshaker) ReplayBlocks(
}
if res.ConsensusParams != nil {
state.ConsensusParams = types.UpdateConsensusParams(state.ConsensusParams, res.ConsensusParams)
state.Version.Consensus.App = state.ConsensusParams.Version.AppVersion
state.ConsensusParams = state.ConsensusParams.Update(res.ConsensusParams)
state.Version.Consensus.App = state.ConsensusParams.Version.App
}
// We update the last results hash with the empty hash, to conform with RFC-6962.
state.LastResultsHash = merkle.HashFromByteSlices(nil)

View File

@@ -1130,7 +1130,7 @@ func stateAndStore(
type mockBlockStore struct {
config *cfg.Config
params tmproto.ConsensusParams
params types.ConsensusParams
chain []*types.Block
commits []*types.Commit
base int64
@@ -1138,7 +1138,7 @@ type mockBlockStore struct {
}
// TODO: NewBlockStore(db.NewMemDB) ...
func newMockBlockStore(t *testing.T, config *cfg.Config, params tmproto.ConsensusParams) *mockBlockStore {
func newMockBlockStore(t *testing.T, config *cfg.Config, params types.ConsensusParams) *mockBlockStore {
return &mockBlockStore{
config: config,
params: params,

View File

@@ -2267,9 +2267,10 @@ func (cs *State) signVote(
func (cs *State) voteTime() time.Time {
now := tmtime.Now()
minVoteTime := now
// Minimum time increment between blocks
const timeIota = time.Millisecond
// TODO: We should remove next line in case we don't vote for v in case cs.ProposalBlock == nil,
// even if cs.LockedBlock != nil. See https://docs.tendermint.com/master/spec/.
timeIota := time.Duration(cs.state.ConsensusParams.Block.TimeIotaMs) * time.Millisecond
if cs.LockedBlock != nil {
// See the BFT time spec https://docs.tendermint.com/master/spec/consensus/bft-time.html
minVoteTime = cs.LockedBlock.Time.Add(timeIota)

View File

@@ -14,7 +14,6 @@ import (
"github.com/tendermint/tendermint/evidence"
"github.com/tendermint/tendermint/evidence/mocks"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
sm "github.com/tendermint/tendermint/state"
smmocks "github.com/tendermint/tendermint/state/mocks"
@@ -327,12 +326,12 @@ func TestRecoverPendingEvidence(t *testing.T) {
newStateStore.On("Load").Return(sm.State{
LastBlockTime: defaultEvidenceTime.Add(25 * time.Minute),
LastBlockHeight: height + 15,
ConsensusParams: tmproto.ConsensusParams{
Block: tmproto.BlockParams{
ConsensusParams: types.ConsensusParams{
Block: types.BlockParams{
MaxBytes: 22020096,
MaxGas: -1,
},
Evidence: tmproto.EvidenceParams{
Evidence: types.EvidenceParams{
MaxAgeNumBlocks: 20,
MaxAgeDuration: 20 * time.Minute,
MaxBytes: defaultEvidenceMaxBytes,
@@ -360,12 +359,12 @@ func initializeStateFromValidatorSet(valSet *types.ValidatorSet, height int64) s
NextValidators: valSet.CopyIncrementProposerPriority(1),
LastValidators: valSet,
LastHeightValidatorsChanged: 1,
ConsensusParams: tmproto.ConsensusParams{
Block: tmproto.BlockParams{
ConsensusParams: types.ConsensusParams{
Block: types.BlockParams{
MaxBytes: 22020096,
MaxGas: -1,
},
Evidence: tmproto.EvidenceParams{
Evidence: types.EvidenceParams{
MaxAgeNumBlocks: 20,
MaxAgeDuration: 20 * time.Minute,
MaxBytes: 1000,

View File

@@ -233,7 +233,7 @@ func (c *Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.Re
}
// Validate res.
if err := types.ValidateConsensusParams(res.ConsensusParams); err != nil {
if err := res.ConsensusParams.ValidateBasic(); err != nil {
return nil, err
}
if res.BlockHeight <= 0 {
@@ -247,7 +247,7 @@ func (c *Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.Re
}
// Verify hash.
if cH, tH := types.HashConsensusParams(res.ConsensusParams), l.ConsensusHash; !bytes.Equal(cH, tH) {
if cH, tH := res.ConsensusParams.Hash(), l.ConsensusHash; !bytes.Equal(cH, tH) {
return nil, fmt.Errorf("params hash %X does not match trusted hash %X",
cH, tH)
}

View File

@@ -51,17 +51,17 @@ message RequestInfo {
string version = 1;
uint64 block_version = 2;
uint64 p2p_version = 3;
string abci_version = 4;
string abci_version = 4;
}
message RequestInitChain {
google.protobuf.Timestamp time = 1
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
string chain_id = 2;
ConsensusParams consensus_params = 3;
repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
bytes app_state_bytes = 5;
int64 initial_height = 6;
string chain_id = 2;
tendermint.types.ConsensusParams consensus_params = 3;
repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
bytes app_state_bytes = 5;
int64 initial_height = 6;
}
message RequestQuery {
@@ -197,9 +197,9 @@ message ResponseInfo {
}
message ResponseInitChain {
ConsensusParams consensus_params = 1;
repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
bytes app_hash = 3;
tendermint.types.ConsensusParams consensus_params = 1;
repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
bytes app_hash = 3;
}
message ResponseQuery {
@@ -253,9 +253,9 @@ message ResponseDeliverTx {
}
message ResponseEndBlock {
repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
tendermint.types.ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
}
@@ -318,23 +318,6 @@ message ResponseProcessProposal {
//----------------------------------------
// Misc.
// ConsensusParams contains all consensus-relevant parameters
// that can be adjusted by the abci app
message ConsensusParams {
BlockParams block = 1;
tendermint.types.EvidenceParams evidence = 2;
tendermint.types.ValidatorParams validator = 3;
tendermint.types.VersionParams version = 4;
}
// BlockParams contains limits on the block size.
message BlockParams {
// Note: must be greater than 0
int64 max_bytes = 1;
// Note: must be greater or equal to -1
int64 max_gas = 2;
}
message CommitInfo {
int32 round = 1;
repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];

View File

@@ -30,10 +30,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// ConsensusParams contains consensus critical parameters that determine the
// validity of blocks.
type ConsensusParams struct {
Block BlockParams `protobuf:"bytes,1,opt,name=block,proto3" json:"block"`
Evidence EvidenceParams `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence"`
Validator ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator"`
Version VersionParams `protobuf:"bytes,4,opt,name=version,proto3" json:"version"`
Block *BlockParams `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"`
Evidence *EvidenceParams `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"`
Validator *ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty"`
Version *VersionParams `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
}
func (m *ConsensusParams) Reset() { *m = ConsensusParams{} }
@@ -69,32 +69,32 @@ func (m *ConsensusParams) XXX_DiscardUnknown() {
var xxx_messageInfo_ConsensusParams proto.InternalMessageInfo
func (m *ConsensusParams) GetBlock() BlockParams {
func (m *ConsensusParams) GetBlock() *BlockParams {
if m != nil {
return m.Block
}
return BlockParams{}
return nil
}
func (m *ConsensusParams) GetEvidence() EvidenceParams {
func (m *ConsensusParams) GetEvidence() *EvidenceParams {
if m != nil {
return m.Evidence
}
return EvidenceParams{}
return nil
}
func (m *ConsensusParams) GetValidator() ValidatorParams {
func (m *ConsensusParams) GetValidator() *ValidatorParams {
if m != nil {
return m.Validator
}
return ValidatorParams{}
return nil
}
func (m *ConsensusParams) GetVersion() VersionParams {
func (m *ConsensusParams) GetVersion() *VersionParams {
if m != nil {
return m.Version
}
return VersionParams{}
return nil
}
// BlockParams contains limits on the block size.
@@ -105,11 +105,6 @@ type BlockParams struct {
// Max gas per block.
// Note: must be greater or equal to -1
MaxGas int64 `protobuf:"varint,2,opt,name=max_gas,json=maxGas,proto3" json:"max_gas,omitempty"`
// Minimum time increment between consecutive blocks (in milliseconds) If the
// block header timestamp is ahead of the system clock, decrease this value.
//
// Not exposed to the application.
TimeIotaMs int64 `protobuf:"varint,3,opt,name=time_iota_ms,json=timeIotaMs,proto3" json:"time_iota_ms,omitempty"`
}
func (m *BlockParams) Reset() { *m = BlockParams{} }
@@ -159,13 +154,6 @@ func (m *BlockParams) GetMaxGas() int64 {
return 0
}
func (m *BlockParams) GetTimeIotaMs() int64 {
if m != nil {
return m.TimeIotaMs
}
return 0
}
// EvidenceParams determine how we handle evidence of malfeasance.
type EvidenceParams struct {
// Max age of evidence, in blocks.
@@ -287,7 +275,7 @@ func (m *ValidatorParams) GetPubKeyTypes() []string {
// VersionParams contains the ABCI application version.
type VersionParams struct {
AppVersion uint64 `protobuf:"varint,1,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"`
App uint64 `protobuf:"varint,1,opt,name=app,proto3" json:"app,omitempty"`
}
func (m *VersionParams) Reset() { *m = VersionParams{} }
@@ -323,9 +311,9 @@ func (m *VersionParams) XXX_DiscardUnknown() {
var xxx_messageInfo_VersionParams proto.InternalMessageInfo
func (m *VersionParams) GetAppVersion() uint64 {
func (m *VersionParams) GetApp() uint64 {
if m != nil {
return m.AppVersion
return m.App
}
return 0
}
@@ -397,41 +385,39 @@ func init() {
func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) }
var fileDescriptor_e12598271a686f57 = []byte{
// 537 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x31, 0x6f, 0xd3, 0x40,
0x18, 0xcd, 0xd5, 0xa5, 0x4d, 0xbe, 0x34, 0x4d, 0x75, 0x42, 0x22, 0x14, 0xd5, 0x0e, 0x1e, 0x50,
0x25, 0x24, 0x5b, 0x82, 0x01, 0xd1, 0xa5, 0xc2, 0x50, 0x15, 0x84, 0x82, 0x90, 0x05, 0x0c, 0x5d,
0xac, 0x73, 0x72, 0xb8, 0x56, 0x73, 0x3e, 0xcb, 0x77, 0x8e, 0x92, 0x7f, 0xc1, 0xd8, 0xb1, 0x23,
0xfc, 0x03, 0x7e, 0x42, 0xc7, 0x8e, 0x4c, 0x80, 0x92, 0x85, 0x9f, 0x81, 0x7c, 0xce, 0xe1, 0x38,
0x65, 0xf3, 0x7d, 0xdf, 0x7b, 0xef, 0xfc, 0xde, 0xd3, 0xc1, 0x81, 0xa4, 0xc9, 0x88, 0x66, 0x2c,
0x4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0x1a, 0x6a, 0x6b, 0xd4, 0x29, 0x11, 0xde, 0xc7, 0xaf, 0x73, 0x13, 0x5d, 0xcf,
0x4d, 0x74, 0x33, 0x37, 0xd1, 0xef, 0xb9, 0x89, 0xbe, 0x2c, 0xcc, 0xc6, 0xcd, 0xc2, 0x6c, 0xfc,
0x58, 0x98, 0x8d, 0xb3, 0x67, 0x51, 0x2c, 0xcf, 0xf3, 0xd0, 0x19, 0x72, 0xe6, 0xae, 0x3e, 0xcb,
0xea, 0xb3, 0x7c, 0x77, 0xeb, 0x4f, 0x36, 0xdc, 0x52, 0xf3, 0xa7, 0x7f, 0x03, 0x00, 0x00, 0xff,
0xff, 0xfe, 0xe0, 0x3d, 0x9c, 0xcd, 0x03, 0x00, 0x00,
// 506 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xc1, 0x6e, 0xd3, 0x30,
0x1c, 0xc6, 0xeb, 0x65, 0x6c, 0xed, 0xbf, 0x74, 0xad, 0x2c, 0x24, 0xc2, 0xd0, 0x92, 0x92, 0x03,
0x9a, 0x34, 0x29, 0x91, 0xd8, 0x01, 0x81, 0x90, 0x26, 0x3a, 0xd0, 0x90, 0xd0, 0x10, 0x8a, 0x80,
0xc3, 0x2e, 0x91, 0xd3, 0x98, 0x2c, 0x5a, 0x1d, 0x47, 0x71, 0x52, 0xb5, 0x37, 0x1e, 0x81, 0x23,
0xc7, 0x1d, 0xe1, 0x0d, 0x78, 0x84, 0x1d, 0x77, 0xe4, 0x04, 0xa8, 0xbd, 0xf0, 0x18, 0x28, 0x4e,
0x4c, 0xda, 0x8c, 0x9b, 0xed, 0xef, 0xf7, 0xd9, 0xfa, 0x3e, 0xeb, 0x0f, 0x7b, 0x19, 0x8d, 0x03,
0x9a, 0xb2, 0x28, 0xce, 0x9c, 0x6c, 0x9e, 0x50, 0xe1, 0x24, 0x24, 0x25, 0x4c, 0xd8, 0x49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 0x73, 0xe6, 0xac,
0x4e, 0x53, 0xbd, 0x2c, 0xc7, 0xa5, 0x39, 0x69, 0xfe, 0x96, 0x3c, 0x3f, 0xfc, 0x1b, 0x00, 0x00,
0xff, 0xff, 0x5a, 0x26, 0xc7, 0xc1, 0x84, 0x03, 0x00, 0x00,
}
func (this *ConsensusParams) Equal(that interface{}) bool {
@@ -453,16 +439,16 @@ func (this *ConsensusParams) Equal(that interface{}) bool {
} else if this == nil {
return false
}
if !this.Block.Equal(&that1.Block) {
if !this.Block.Equal(that1.Block) {
return false
}
if !this.Evidence.Equal(&that1.Evidence) {
if !this.Evidence.Equal(that1.Evidence) {
return false
}
if !this.Validator.Equal(&that1.Validator) {
if !this.Validator.Equal(that1.Validator) {
return false
}
if !this.Version.Equal(&that1.Version) {
if !this.Version.Equal(that1.Version) {
return false
}
return true
@@ -492,9 +478,6 @@ func (this *BlockParams) Equal(that interface{}) bool {
if this.MaxGas != that1.MaxGas {
return false
}
if this.TimeIotaMs != that1.TimeIotaMs {
return false
}
return true
}
func (this *EvidenceParams) Equal(that interface{}) bool {
@@ -575,7 +558,7 @@ func (this *VersionParams) Equal(that interface{}) bool {
} else if this == nil {
return false
}
if this.AppVersion != that1.AppVersion {
if this.App != that1.App {
return false
}
return true
@@ -627,46 +610,54 @@ func (m *ConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
{
size, err := m.Version.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Version != nil {
{
size, err := m.Version.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
i--
dAtA[i] = 0x22
}
i--
dAtA[i] = 0x22
{
size, err := m.Validator.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Validator != nil {
{
size, err := m.Validator.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
i--
dAtA[i] = 0x1a
}
i--
dAtA[i] = 0x1a
{
size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Evidence != nil {
{
size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
i--
dAtA[i] = 0x12
}
i--
dAtA[i] = 0x12
{
size, err := m.Block.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Block != nil {
{
size, err := m.Block.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
@@ -690,11 +681,6 @@ func (m *BlockParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.TimeIotaMs != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.TimeIotaMs))
i--
dAtA[i] = 0x18
}
if m.MaxGas != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.MaxGas))
i--
@@ -801,8 +787,8 @@ func (m *VersionParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.AppVersion != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.AppVersion))
if m.App != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.App))
i--
dAtA[i] = 0x8
}
@@ -867,7 +853,7 @@ func NewPopulatedValidatorParams(r randyParams, easy bool) *ValidatorParams {
func NewPopulatedVersionParams(r randyParams, easy bool) *VersionParams {
this := &VersionParams{}
this.AppVersion = uint64(uint64(r.Uint32()))
this.App = uint64(uint64(r.Uint32()))
if !easy && r.Intn(10) != 0 {
}
return this
@@ -951,14 +937,22 @@ func (m *ConsensusParams) Size() (n int) {
}
var l int
_ = l
l = m.Block.Size()
n += 1 + l + sovParams(uint64(l))
l = m.Evidence.Size()
n += 1 + l + sovParams(uint64(l))
l = m.Validator.Size()
n += 1 + l + sovParams(uint64(l))
l = m.Version.Size()
n += 1 + l + sovParams(uint64(l))
if m.Block != nil {
l = m.Block.Size()
n += 1 + l + sovParams(uint64(l))
}
if m.Evidence != nil {
l = m.Evidence.Size()
n += 1 + l + sovParams(uint64(l))
}
if m.Validator != nil {
l = m.Validator.Size()
n += 1 + l + sovParams(uint64(l))
}
if m.Version != nil {
l = m.Version.Size()
n += 1 + l + sovParams(uint64(l))
}
return n
}
@@ -974,9 +968,6 @@ func (m *BlockParams) Size() (n int) {
if m.MaxGas != 0 {
n += 1 + sovParams(uint64(m.MaxGas))
}
if m.TimeIotaMs != 0 {
n += 1 + sovParams(uint64(m.TimeIotaMs))
}
return n
}
@@ -1018,8 +1009,8 @@ func (m *VersionParams) Size() (n int) {
}
var l int
_ = l
if m.AppVersion != 0 {
n += 1 + sovParams(uint64(m.AppVersion))
if m.App != 0 {
n += 1 + sovParams(uint64(m.App))
}
return n
}
@@ -1103,6 +1094,9 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Block == nil {
m.Block = &BlockParams{}
}
if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@@ -1136,6 +1130,9 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Evidence == nil {
m.Evidence = &EvidenceParams{}
}
if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@@ -1169,6 +1166,9 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Validator == nil {
m.Validator = &ValidatorParams{}
}
if err := m.Validator.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@@ -1202,6 +1202,9 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Version == nil {
m.Version = &VersionParams{}
}
if err := m.Version.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@@ -1294,25 +1297,6 @@ func (m *BlockParams) Unmarshal(dAtA []byte) error {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field TimeIotaMs", wireType)
}
m.TimeIotaMs = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.TimeIotaMs |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipParams(dAtA[iNdEx:])
@@ -1568,9 +1552,9 @@ func (m *VersionParams) Unmarshal(dAtA []byte) error {
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field App", wireType)
}
m.AppVersion = 0
m.App = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
@@ -1580,7 +1564,7 @@ func (m *VersionParams) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
m.AppVersion |= uint64(b&0x7F) << shift
m.App |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}

View File

@@ -11,10 +11,10 @@ option (gogoproto.equal_all) = true;
// ConsensusParams contains consensus critical parameters that determine the
// validity of blocks.
message ConsensusParams {
BlockParams block = 1 [(gogoproto.nullable) = false];
EvidenceParams evidence = 2 [(gogoproto.nullable) = false];
ValidatorParams validator = 3 [(gogoproto.nullable) = false];
VersionParams version = 4 [(gogoproto.nullable) = false];
BlockParams block = 1;
EvidenceParams evidence = 2;
ValidatorParams validator = 3;
VersionParams version = 4;
}
// BlockParams contains limits on the block size.
@@ -25,11 +25,8 @@ message BlockParams {
// Max gas per block.
// Note: must be greater or equal to -1
int64 max_gas = 2;
// Minimum time increment between consecutive blocks (in milliseconds) If the
// block header timestamp is ahead of the system clock, decrease this value.
//
// Not exposed to the application.
int64 time_iota_ms = 3;
reserved 3; // was TimeIotaMs see https://github.com/tendermint/tendermint/pull/5792
}
// EvidenceParams determine how we handle evidence of malfeasance.
@@ -68,7 +65,7 @@ message VersionParams {
option (gogoproto.populate) = true;
option (gogoproto.equal) = true;
uint64 app_version = 1;
uint64 app = 1;
}
// HashedParams is a subset of ConsensusParams.

View File

@@ -52,7 +52,7 @@ type ResultBlockResults struct {
BeginBlockEvents []abci.Event `json:"begin_block_events"`
EndBlockEvents []abci.Event `json:"end_block_events"`
ValidatorUpdates []abci.ValidatorUpdate `json:"validator_updates"`
ConsensusParamUpdates *abci.ConsensusParams `json:"consensus_param_updates"`
ConsensusParamUpdates *tmproto.ConsensusParams `json:"consensus_param_updates"`
}
// NewResultCommit is a helper to initialize the ResultCommit with
@@ -144,8 +144,8 @@ type ResultValidators struct {
// ConsensusParams for given height
type ResultConsensusParams struct {
BlockHeight int64 `json:"block_height"`
ConsensusParams tmproto.ConsensusParams `json:"consensus_params"`
BlockHeight int64 `json:"block_height"`
ConsensusParams types.ConsensusParams `json:"consensus_params"`
}
// Info about the consensus state.

View File

@@ -11,7 +11,6 @@ import (
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/mempool"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types"
)
@@ -452,7 +451,7 @@ func extendedCommitInfo(c abci.CommitInfo, votes []*types.Vote) abci.ExtendedCom
}
func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate,
params tmproto.ValidatorParams) error {
params types.ValidatorParams) error {
for _, valUpdate := range abciUpdates {
if valUpdate.GetPower() < 0 {
return fmt.Errorf("voting power can't be negative %v", valUpdate)
@@ -508,13 +507,13 @@ func updateState(
lastHeightParamsChanged := state.LastHeightConsensusParamsChanged
if abciResponses.EndBlock.ConsensusParamUpdates != nil {
// NOTE: must not mutate s.ConsensusParams
nextParams = types.UpdateConsensusParams(state.ConsensusParams, abciResponses.EndBlock.ConsensusParamUpdates)
err := types.ValidateConsensusParams(nextParams)
nextParams = state.ConsensusParams.Update(abciResponses.EndBlock.ConsensusParamUpdates)
err := nextParams.ValidateBasic()
if err != nil {
return state, fmt.Errorf("error updating consensus params: %v", err)
}
state.Version.Consensus.App = nextParams.Version.AppVersion
state.Version.Consensus.App = nextParams.Version.App
// Change results from this height but only applies to the next height.
lastHeightParamsChanged = header.Height + 1

View File

@@ -19,7 +19,6 @@ import (
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/libs/log"
mpmocks "github.com/tendermint/tendermint/mempool/mocks"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
"github.com/tendermint/tendermint/proxy"
pmocks "github.com/tendermint/tendermint/proxy/mocks"
@@ -332,13 +331,13 @@ func TestValidateValidatorUpdates(t *testing.T) {
pk2, err := cryptoenc.PubKeyToProto(pubkey2)
assert.NoError(t, err)
defaultValidatorParams := tmproto.ValidatorParams{PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519}}
defaultValidatorParams := types.ValidatorParams{PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519}}
testCases := []struct {
name string
abciUpdates []abci.ValidatorUpdate
validatorParams tmproto.ValidatorParams
validatorParams types.ValidatorParams
shouldErr bool
}{

View File

@@ -5,7 +5,6 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/types"
)
@@ -36,7 +35,7 @@ func UpdateState(
// ValidateValidatorUpdates is an alias for validateValidatorUpdates exported
// from execution.go, exclusively and explicitly for testing.
func ValidateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, params tmproto.ValidatorParams) error {
func ValidateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, params types.ValidatorParams) error {
return validateValidatorUpdates(abciUpdates, params)
}

View File

@@ -23,7 +23,7 @@ import (
type paramsChangeTestCase struct {
height int64
params tmproto.ConsensusParams
params types.ConsensusParams
}
func newTestApp() proxy.AppConns {
@@ -197,7 +197,7 @@ func makeHeaderPartsResponsesParams(
block := sf.MakeBlock(state, state.LastBlockHeight+1, new(types.Commit))
abciResponses := &tmstate.ABCIResponses{
BeginBlock: &abci.ResponseBeginBlock{},
EndBlock: &abci.ResponseEndBlock{ConsensusParamUpdates: types.TM2PB.ConsensusParams(&params)},
EndBlock: &abci.ResponseEndBlock{ConsensusParamUpdates: &params},
}
return block.Header, types.BlockID{Hash: block.Hash(), PartSetHeader: types.PartSetHeader{}}, abciResponses
}
@@ -244,9 +244,9 @@ func (app *testApp) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlo
func (app *testApp) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlock {
return abci.ResponseEndBlock{
ValidatorUpdates: app.ValidatorUpdates,
ConsensusParamUpdates: &abci.ConsensusParams{
ConsensusParamUpdates: &tmproto.ConsensusParams{
Version: &tmproto.VersionParams{
AppVersion: 1}}}
App: 1}}}
}
func (app *testApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {

View File

@@ -8,9 +8,7 @@ import (
tendermintstate "github.com/tendermint/tendermint/proto/tendermint/state"
tenderminttypes "github.com/tendermint/tendermint/types"
types "github.com/tendermint/tendermint/proto/tendermint/types"
types "github.com/tendermint/tendermint/types"
)
// Store is an autogenerated mock type for the Store type
@@ -112,18 +110,18 @@ func (_m *Store) LoadConsensusParams(_a0 int64) (types.ConsensusParams, error) {
}
// LoadFromDBOrGenesisDoc provides a mock function with given fields: _a0
func (_m *Store) LoadFromDBOrGenesisDoc(_a0 *tenderminttypes.GenesisDoc) (state.State, error) {
func (_m *Store) LoadFromDBOrGenesisDoc(_a0 *types.GenesisDoc) (state.State, error) {
ret := _m.Called(_a0)
var r0 state.State
if rf, ok := ret.Get(0).(func(*tenderminttypes.GenesisDoc) state.State); ok {
if rf, ok := ret.Get(0).(func(*types.GenesisDoc) state.State); ok {
r0 = rf(_a0)
} else {
r0 = ret.Get(0).(state.State)
}
var r1 error
if rf, ok := ret.Get(1).(func(*tenderminttypes.GenesisDoc) error); ok {
if rf, ok := ret.Get(1).(func(*types.GenesisDoc) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
@@ -154,15 +152,15 @@ func (_m *Store) LoadFromDBOrGenesisFile(_a0 string) (state.State, error) {
}
// LoadValidators provides a mock function with given fields: _a0
func (_m *Store) LoadValidators(_a0 int64) (*tenderminttypes.ValidatorSet, error) {
func (_m *Store) LoadValidators(_a0 int64) (*types.ValidatorSet, error) {
ret := _m.Called(_a0)
var r0 *tenderminttypes.ValidatorSet
if rf, ok := ret.Get(0).(func(int64) *tenderminttypes.ValidatorSet); ok {
var r0 *types.ValidatorSet
if rf, ok := ret.Get(0).(func(int64) *types.ValidatorSet); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*tenderminttypes.ValidatorSet)
r0 = ret.Get(0).(*types.ValidatorSet)
}
}

View File

@@ -77,7 +77,7 @@ func Rollback(bs BlockStore, ss Store) (int64, []byte, error) {
Version: tmstate.Version{
Consensus: tmversion.Consensus{
Block: version.BlockProtocol,
App: previousParams.Version.AppVersion,
App: previousParams.Version.App,
},
Software: version.TMCoreSemVer,
},

View File

@@ -29,7 +29,7 @@ func TestRollback(t *testing.T) {
// perform the rollback over a version bump
newParams := types.DefaultConsensusParams()
newParams.Version.AppVersion = 11
newParams.Version.App = 11
newParams.Block.MaxBytes = 1000
nextState := initialState.Copy()
nextState.LastBlockHeight = nextHeight
@@ -119,7 +119,7 @@ func setupStateStore(t *testing.T, height int64) state.Store {
valSet, _ := types.RandValidatorSet(5, 10)
params := types.DefaultConsensusParams()
params.Version.AppVersion = 10
params.Version.App = 10
initialState := state.State{
Version: tmstate.Version{

View File

@@ -10,7 +10,6 @@ import (
"github.com/gogo/protobuf/proto"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
@@ -70,7 +69,7 @@ type State struct {
// Consensus parameters used for validating blocks.
// Changes returned by EndBlock and updated after Commit.
ConsensusParams tmproto.ConsensusParams
ConsensusParams types.ConsensusParams
LastHeightConsensusParamsChanged int64
// Merkle root of the results from executing prev block
@@ -167,7 +166,7 @@ func (state *State) ToProto() (*tmstate.State, error) {
}
sm.LastHeightValidatorsChanged = state.LastHeightValidatorsChanged
sm.ConsensusParams = state.ConsensusParams
sm.ConsensusParams = state.ConsensusParams.ToProto()
sm.LastHeightConsensusParamsChanged = state.LastHeightConsensusParamsChanged
sm.LastResultsHash = state.LastResultsHash
sm.AppHash = state.AppHash
@@ -218,7 +217,7 @@ func FromProto(pb *tmstate.State) (*State, error) { //nolint:golint
}
state.LastHeightValidatorsChanged = pb.LastHeightValidatorsChanged
state.ConsensusParams = pb.ConsensusParams
state.ConsensusParams = types.ConsensusParamsFromProto(pb.ConsensusParams)
state.LastHeightConsensusParamsChanged = pb.LastHeightConsensusParamsChanged
state.LastResultsHash = pb.LastResultsHash
state.AppHash = pb.AppHash
@@ -256,7 +255,7 @@ func (state State) MakeBlock(
state.Version.Consensus, state.ChainID,
timestamp, state.LastBlockID,
state.Validators.Hash(), state.NextValidators.Hash(),
types.HashConsensusParams(state.ConsensusParams), state.AppHash, state.LastResultsHash,
state.ConsensusParams.Hash(), state.AppHash, state.LastResultsHash,
proposerAddress,
)

View File

@@ -19,7 +19,6 @@ import (
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sm "github.com/tendermint/tendermint/state"
sf "github.com/tendermint/tendermint/state/test/factory"
"github.com/tendermint/tendermint/types"
@@ -1030,12 +1029,12 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) {
// Each valset is just one validator.
// create list of them.
params := make([]tmproto.ConsensusParams, N+1)
params := make([]types.ConsensusParams, N+1)
params[0] = state.ConsensusParams
for i := 1; i < N+1; i++ {
params[i] = *types.DefaultConsensusParams()
params[i].Block.MaxBytes += int64(i)
params[i].Block.TimeIotaMs = 10
}
// Build the params history by running updateState
@@ -1051,7 +1050,7 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) {
changeIndex++
cp = params[changeIndex]
}
header, blockID, responses := makeHeaderPartsResponsesParams(t, state, cp)
header, blockID, responses := makeHeaderPartsResponsesParams(t, state, cp.ToProto())
validatorUpdates, err = types.PB2TM.ValidatorUpdates(responses.EndBlock.ValidatorUpdates)
require.NoError(t, err)
state, err = sm.UpdateState(state, blockID, &header, responses, validatorUpdates)

View File

@@ -59,7 +59,7 @@ type Store interface {
// LoadABCIResponses loads the abciResponse for a given height
LoadABCIResponses(int64) (*tmstate.ABCIResponses, error)
// LoadConsensusParams loads the consensus params for a given height
LoadConsensusParams(int64) (tmproto.ConsensusParams, error)
LoadConsensusParams(int64) (types.ConsensusParams, error)
// Save overwrites the previous state with the updated one
Save(State) error
// SaveABCIResponses saves ABCIResponses for a given height
@@ -298,10 +298,11 @@ func (store dbStore) PruneStates(from int64, to int64) error {
}
if p.ConsensusParams.Equal(&tmproto.ConsensusParams{}) {
p.ConsensusParams, err = store.LoadConsensusParams(h)
params, err := store.LoadConsensusParams(h)
if err != nil {
return err
}
p.ConsensusParams = params.ToProto()
p.LastHeightChanged = h
bz, err := p.Marshal()
@@ -526,15 +527,17 @@ func (store dbStore) saveValidatorsInfo(height, lastHeightChanged int64, valSet
// ConsensusParamsInfo represents the latest consensus params, or the last height it changed
// LoadConsensusParams loads the ConsensusParams for a given height.
func (store dbStore) LoadConsensusParams(height int64) (tmproto.ConsensusParams, error) {
empty := tmproto.ConsensusParams{}
func (store dbStore) LoadConsensusParams(height int64) (types.ConsensusParams, error) {
var (
empty = types.ConsensusParams{}
emptypb = tmproto.ConsensusParams{}
)
paramsInfo, err := store.loadConsensusParamsInfo(height)
if err != nil {
return empty, fmt.Errorf("could not find consensus params for height #%d: %w", height, err)
}
if paramsInfo.ConsensusParams.Equal(&empty) {
if paramsInfo.ConsensusParams.Equal(&emptypb) {
paramsInfo2, err := store.loadConsensusParamsInfo(paramsInfo.LastHeightChanged)
if err != nil {
return empty, fmt.Errorf(
@@ -548,7 +551,7 @@ func (store dbStore) LoadConsensusParams(height int64) (tmproto.ConsensusParams,
paramsInfo = paramsInfo2
}
return paramsInfo.ConsensusParams, nil
return types.ConsensusParamsFromProto(paramsInfo.ConsensusParams), nil
}
func (store dbStore) loadConsensusParamsInfo(height int64) (*tmstate.ConsensusParamsInfo, error) {
@@ -575,13 +578,13 @@ func (store dbStore) loadConsensusParamsInfo(height int64) (*tmstate.ConsensusPa
// It should be called from s.Save(), right before the state itself is persisted.
// If the consensus params did not change after processing the latest block,
// only the last height for which they changed is persisted.
func (store dbStore) saveConsensusParamsInfo(nextHeight, changeHeight int64, params tmproto.ConsensusParams) error {
func (store dbStore) saveConsensusParamsInfo(nextHeight, changeHeight int64, params types.ConsensusParams) error {
paramsInfo := &tmstate.ConsensusParamsInfo{
LastHeightChanged: changeHeight,
}
if changeHeight == nextHeight {
paramsInfo.ConsensusParams = params
paramsInfo.ConsensusParams = params.ToProto()
}
bz, err := paramsInfo.Marshal()
if err != nil {

View File

@@ -16,7 +16,6 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
)
@@ -133,8 +132,8 @@ func TestPruneStates(t *testing.T) {
LastBlockHeight: h - 1,
Validators: validatorSet,
NextValidators: validatorSet,
ConsensusParams: tmproto.ConsensusParams{
Block: tmproto.BlockParams{MaxBytes: 10e6},
ConsensusParams: types.ConsensusParams{
Block: types.BlockParams{MaxBytes: 10e6},
},
LastHeightValidatorsChanged: valsChanged,
LastHeightConsensusParamsChanged: paramsChanged,
@@ -182,9 +181,10 @@ func TestPruneStates(t *testing.T) {
params, err := stateStore.LoadConsensusParams(h)
if expectParams[h] {
require.NoError(t, err, "params height %v", h)
require.False(t, params.Equal(&tmproto.ConsensusParams{}))
require.NotEmpty(t, params)
} else {
require.Error(t, err, "params height %v", h)
require.Empty(t, params)
}
abci, err := stateStore.LoadABCIResponses(h)

View File

@@ -57,10 +57,9 @@ func validateBlock(state State, block *types.Block) error {
block.AppHash,
)
}
hashCP := types.HashConsensusParams(state.ConsensusParams)
if !bytes.Equal(block.ConsensusHash, hashCP) {
if !bytes.Equal(block.ConsensusHash, state.ConsensusParams.Hash()) {
return fmt.Errorf("wrong Block.Header.ConsensusHash. Expected %X, got %v",
hashCP,
state.ConsensusParams.Hash(),
block.ConsensusHash,
)
}

View File

@@ -200,7 +200,7 @@ func MakeGenesis(testnet *e2e.Testnet) (types.GenesisDoc, error) {
InitialHeight: testnet.InitialHeight,
}
// set the app version to 1
genesis.ConsensusParams.Version.AppVersion = 1
genesis.ConsensusParams.Version.App = 1
for validator, power := range testnet.Validators {
genesis.Validators = append(genesis.Validators, types.GenesisValidator{
Name: validator.Name,

View File

@@ -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
}

View File

@@ -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,
},
}
}

View File

@@ -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)
}
}

View File

@@ -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: &params.Evidence,
Validator: &params.Validator,
}
}
// XXX: panics on nil or unknown pubkey type
func (tm2pb) NewValidatorUpdate(pubkey crypto.PubKey, power int64) abci.ValidatorUpdate {
pubkeyABCI, err := cryptoenc.PubKeyToProto(pubkey)

View File

@@ -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{} }