Browse Source

params: remove blockTimeIota (#5987)

## Description

- removes blocktimeiota 
- merges block params in abci and core state
- spec change: https://github.com/tendermint/spec/pull/248


Closes: #5939
pull/6011/head
Marko 3 years ago
committed by GitHub
parent
commit
1f01e5d726
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 434 additions and 1163 deletions
  1. +2
    -1
      CHANGELOG_PENDING.md
  2. +1
    -1
      abci/client/mocks/client.go
  3. +194
    -754
      abci/types/types.pb.go
  4. +2
    -2
      consensus/replay.go
  5. +1
    -1
      evidence/mocks/block_store.go
  6. +0
    -1
      p2p/conn/secret_connection.go
  7. +2
    -4
      p2p/mocks/peer.go
  8. +0
    -1
      privval/secret_connection.go
  9. +11
    -28
      proto/tendermint/abci/types.proto
  10. +117
    -222
      proto/tendermint/types/params.pb.go
  11. +4
    -12
      proto/tendermint/types/params.proto
  12. +1
    -1
      proxy/mocks/app_conn_consensus.go
  13. +1
    -1
      proxy/mocks/app_conn_mempool.go
  14. +1
    -1
      proxy/mocks/app_conn_query.go
  15. +1
    -1
      proxy/mocks/app_conn_snapshot.go
  16. +2
    -2
      rpc/core/consensus.go
  17. +2
    -1
      rpc/core/types/responses.go
  18. +3
    -2
      state/helpers_test.go
  19. +1
    -1
      state/mocks/evidence_pool.go
  20. +9
    -11
      state/mocks/store.go
  21. +1
    -1
      state/state_test.go
  22. +10
    -6
      state/store.go
  23. +3
    -6
      state/store_test.go
  24. +1
    -1
      statesync/mocks/state_provider.go
  25. +2
    -2
      test/maverick/consensus/replay.go
  26. +1
    -1
      test/maverick/consensus/state.go
  27. +19
    -24
      types/params.go
  28. +42
    -46
      types/params_test.go
  29. +0
    -20
      types/protobuf.go
  30. +0
    -8
      types/protobuf_test.go

+ 2
- 1
CHANGELOG_PENDING.md View File

@ -52,7 +52,8 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [cli] \#5772 `gen_node_key` output now contains node ID (`id` field) (@melekes)
- [blockchain/v2] \#5774 Send status request when new peer joins (@melekes)
- [consensus] \#5792 Deprecates the `time_iota_ms` consensus parameter, to reduce the bug surface. The parameter is no longer used. (@valardragon)
- [types] \#5994 Reduce the use of protobuf types in core logic.
- [consensus] \#5987 Remove `time_iota_ms` from consensus params. Merge `tmproto.ConsensusParams` and `abci.ConsensusParams`. (@marbar3778)
- [types] \#5994 Reduce the use of protobuf types in core logic. (@marbar3778)
- `ConsensusParams`, `BlockParams`, `ValidatorParams`, `EvidenceParams`, `VersionParams`, `sm.Version` and `version.Consensus` have become native types. They still utilize protobuf when being sent over the wire or written to disk.
### BUG FIXES


+ 1
- 1
abci/client/mocks/client.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 194
- 754
abci/types/types.pb.go
File diff suppressed because it is too large
View File


+ 2
- 2
consensus/replay.go View File

@ -308,12 +308,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,
}


+ 1
- 1
evidence/mocks/block_store.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 0
- 1
p2p/conn/secret_connection.go View File

@ -275,7 +275,6 @@ func (sc *SecretConnection) Read(data []byte) (n int, err error) {
}
// Implements net.Conn
// nolint
func (sc *SecretConnection) Close() error { return sc.conn.Close() }
func (sc *SecretConnection) LocalAddr() net.Addr { return sc.conn.(net.Conn).LocalAddr() }
func (sc *SecretConnection) RemoteAddr() net.Addr { return sc.conn.(net.Conn).RemoteAddr() }


+ 2
- 4
p2p/mocks/peer.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks
@ -117,9 +117,7 @@ func (_m *Peer) NodeInfo() p2p.NodeInfo {
if rf, ok := ret.Get(0).(func() p2p.NodeInfo); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(p2p.NodeInfo)
}
r0 = ret.Get(0).(p2p.NodeInfo)
}
return r0


+ 0
- 1
privval/secret_connection.go View File

@ -279,7 +279,6 @@ func (sc *SecretConnection) Read(data []byte) (n int, err error) {
}
// Implements net.Conn
// nolint
func (sc *SecretConnection) Close() error { return sc.conn.Close() }
func (sc *SecretConnection) LocalAddr() net.Addr { return sc.conn.(net.Conn).LocalAddr() }
func (sc *SecretConnection) RemoteAddr() net.Addr { return sc.conn.(net.Conn).RemoteAddr() }


+ 11
- 28
proto/tendermint/abci/types.proto View File

@ -48,17 +48,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 {
@ -165,9 +165,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 {
@ -215,8 +215,8 @@ message ResponseDeliverTx {
message ResponseEndBlock {
repeated ValidatorUpdate validator_updates = 1
[(gogoproto.nullable) = false];
ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
tendermint.types.ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
}
@ -265,23 +265,6 @@ message ResponseApplySnapshotChunk {
//----------------------------------------
// 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 LastCommitInfo {
int32 round = 1;
repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];


+ 117
- 222
proto/tendermint/types/params.pb.go 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,8 +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"`
// This parameter is unused.
TimeIotaMs int64 `protobuf:"varint,3,opt,name=time_iota_ms,json=timeIotaMs,proto3" json:"time_iota_ms,omitempty"`
}
func (m *BlockParams) Reset() { *m = BlockParams{} }
@ -156,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.
@ -394,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, 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df, 0x38, 0x6c,
0xf9, 0xed, 0x34, 0x0f, 0xdf, 0xd2, 0xd9, 0x87, 0x62, 0x74, 0xd4, 0xfc, 0x7e, 0x65, 0xa1, 0x3f,
0x57, 0x16, 0xb2, 0x8f, 0xa0, 0x53, 0xcb, 0x1c, 0x5b, 0xd0, 0x26, 0x69, 0x1a, 0xe8, 0xa6, 0x0a,
0x8f, 0x9b, 0x3e, 0x90, 0x34, 0x5d, 0xc2, 0x56, 0xb8, 0x67, 0xb0, 0xf3, 0x9a, 0x88, 0x73, 0x3a,
0x5a, 0x52, 0x1f, 0x41, 0x57, 0x25, 0x13, 0xac, 0xd7, 0xd2, 0x51, 0xe3, 0x81, 0xee, 0xc6, 0x86,
0x4e, 0x85, 0xab, 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,
// 498 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xc1, 0x6a, 0xd4, 0x40,
0x1c, 0xc6, 0x77, 0x9a, 0xda, 0xee, 0xfe, 0xe3, 0x76, 0xcb, 0x20, 0x18, 0x2b, 0xcd, 0xae, 0x39,
0x48, 0x41, 0x48, 0xc4, 0x22, 0x22, 0x08, 0xe2, 0x56, 0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 0x3c, 0x84, 0x81, 0x6a, 0x21,
0x68, 0x17, 0xdc, 0x57, 0xc7, 0x27, 0xba, 0x65, 0x07, 0xfa, 0x0d, 0xd7, 0x74, 0x6d, 0x6a, 0xea,
0x98, 0xc8, 0xf1, 0xa7, 0x1f, 0x4b, 0x1b, 0x5d, 0x2c, 0x6d, 0x74, 0xb9, 0xb4, 0xd1, 0xdf, 0xa5,
0x8d, 0xbe, 0xad, 0xec, 0xce, 0xe5, 0xca, 0xee, 0xfc, 0x5a, 0xd9, 0x9d, 0xd3, 0x67, 0x71, 0x92,
0x9f, 0x15, 0xa1, 0x3b, 0xe1, 0xcc, 0xbb, 0x3a, 0x48, 0xcd, 0xb2, 0x9a, 0x94, 0xf6, 0x90, 0x85,
0x5b, 0xea, 0xfc, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x18, 0x54, 0x4f, 0xe1, 0x7f, 0x03,
0x00, 0x00,
}
func (this *ConsensusParams) Equal(that interface{}) bool {
@ -450,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
@ -489,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 {
@ -624,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
}
@ -687,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--
@ -850,112 +839,28 @@ func encodeVarintParams(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
return base
}
func NewPopulatedValidatorParams(r randyParams, easy bool) *ValidatorParams {
this := &ValidatorParams{}
v1 := r.Intn(10)
this.PubKeyTypes = make([]string, v1)
for i := 0; i < v1; i++ {
this.PubKeyTypes[i] = string(randStringParams(r))
}
if !easy && r.Intn(10) != 0 {
}
return this
}
func NewPopulatedVersionParams(r randyParams, easy bool) *VersionParams {
this := &VersionParams{}
this.AppVersion = uint64(uint64(r.Uint32()))
if !easy && r.Intn(10) != 0 {
}
return this
}
type randyParams interface {
Float32() float32
Float64() float64
Int63() int64
Int31() int32
Uint32() uint32
Intn(n int) int
}
func randUTF8RuneParams(r randyParams) rune {
ru := r.Intn(62)
if ru < 10 {
return rune(ru + 48)
} else if ru < 36 {
return rune(ru + 55)
}
return rune(ru + 61)
}
func randStringParams(r randyParams) string {
v2 := r.Intn(100)
tmps := make([]rune, v2)
for i := 0; i < v2; i++ {
tmps[i] = randUTF8RuneParams(r)
}
return string(tmps)
}
func randUnrecognizedParams(r randyParams, maxFieldNumber int) (dAtA []byte) {
l := r.Intn(5)
for i := 0; i < l; i++ {
wire := r.Intn(4)
if wire == 3 {
wire = 5
}
fieldNumber := maxFieldNumber + r.Intn(100)
dAtA = randFieldParams(dAtA, r, fieldNumber, wire)
}
return dAtA
}
func randFieldParams(dAtA []byte, r randyParams, fieldNumber int, wire int) []byte {
key := uint32(fieldNumber)<<3 | uint32(wire)
switch wire {
case 0:
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
v3 := r.Int63()
if r.Intn(2) == 0 {
v3 *= -1
}
dAtA = encodeVarintPopulateParams(dAtA, uint64(v3))
case 1:
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
case 2:
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
ll := r.Intn(100)
dAtA = encodeVarintPopulateParams(dAtA, uint64(ll))
for j := 0; j < ll; j++ {
dAtA = append(dAtA, byte(r.Intn(256)))
}
default:
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
}
return dAtA
}
func encodeVarintPopulateParams(dAtA []byte, v uint64) []byte {
for v >= 1<<7 {
dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
v >>= 7
}
dAtA = append(dAtA, uint8(v))
return dAtA
}
func (m *ConsensusParams) Size() (n int) {
if m == nil {
return 0
}
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
}
@ -971,9 +876,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
}
@ -1100,6 +1002,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
}
@ -1133,6 +1038,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
}
@ -1166,6 +1074,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
}
@ -1199,6 +1110,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
}
@ -1291,25 +1205,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:])


+ 4
- 12
proto/tendermint/types/params.proto 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,8 +25,6 @@ message BlockParams {
// Max gas per block.
// Note: must be greater or equal to -1
int64 max_gas = 2;
// This parameter is unused.
int64 time_iota_ms = 3;
}
// EvidenceParams determine how we handle evidence of malfeasance.
@ -54,17 +52,11 @@ message EvidenceParams {
// ValidatorParams restrict the public key types validators can use.
// NOTE: uses ABCI pubkey naming, not Amino names.
message ValidatorParams {
option (gogoproto.populate) = true;
option (gogoproto.equal) = true;
repeated string pub_key_types = 1;
}
// VersionParams contains the ABCI application version.
message VersionParams {
option (gogoproto.populate) = true;
option (gogoproto.equal) = true;
uint64 app_version = 1;
}


+ 1
- 1
proxy/mocks/app_conn_consensus.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 1
- 1
proxy/mocks/app_conn_mempool.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 1
- 1
proxy/mocks/app_conn_query.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 1
- 1
proxy/mocks/app_conn_snapshot.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 2
- 2
rpc/core/consensus.go View File

@ -102,8 +102,8 @@ func ConsensusParams(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCon
if err != nil {
return nil, err
}
params := types.ConsensusParamsFromProto(consensusParams)
return &ctypes.ResultConsensusParams{
BlockHeight: height,
ConsensusParams: params}, nil
ConsensusParams: consensusParams}, nil
}

+ 2
- 1
rpc/core/types/responses.go View File

@ -8,6 +8,7 @@ import (
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/p2p"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/types"
)
@ -41,7 +42,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


+ 3
- 2
state/helpers_test.go View File

@ -204,9 +204,10 @@ func makeHeaderPartsResponsesParams(
) (types.Header, types.BlockID, *tmstate.ABCIResponses) {
block := makeBlock(state, state.LastBlockHeight+1)
pbParams := params.ToProto()
abciResponses := &tmstate.ABCIResponses{
BeginBlock: &abci.ResponseBeginBlock{},
EndBlock: &abci.ResponseEndBlock{ConsensusParamUpdates: types.TM2PB.ConsensusParams(params)},
EndBlock: &abci.ResponseEndBlock{ConsensusParamUpdates: &pbParams},
}
return block.Header, types.BlockID{Hash: block.Hash(), PartSetHeader: types.PartSetHeader{}}, abciResponses
}
@ -286,7 +287,7 @@ 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}}}
}


+ 1
- 1
state/mocks/evidence_pool.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 9
- 11
state/mocks/store.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks
@ -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
@ -98,18 +96,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)
@ -140,15 +138,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)
}
}


+ 1
- 1
state/state_test.go View File

@ -1002,7 +1002,6 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) {
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
@ -1044,6 +1043,7 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) {
for _, testCase := range testCases {
p, err := stateStore.LoadConsensusParams(testCase.height)
assert.Nil(t, err, fmt.Sprintf("expected no err at height %d", testCase.height))
assert.EqualValues(t, testCase.params, p, fmt.Sprintf(`unexpected consensus params at
height %d`, testCase.height))


+ 10
- 6
state/store.go View File

@ -76,7 +76,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
@ -567,16 +567,20 @@ 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{}
// Allocate empty Consensus params at compile time to avoid multiple allocations during runtime
var (
empty = types.ConsensusParams{}
emptypb = tmproto.ConsensusParams{}
)
// LoadConsensusParams loads the ConsensusParams for a given height.
func (store dbStore) LoadConsensusParams(height int64) (types.ConsensusParams, error) {
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(
@ -590,7 +594,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) {


+ 3
- 6
state/store_test.go 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"
)
@ -142,9 +141,8 @@ func TestStoreLoadConsensusParams(t *testing.T) {
stateStore := sm.NewStore(stateDB)
err := stateStore.Save(makeRandomStateFromConsensusParams(types.DefaultConsensusParams(), 1, 1))
require.NoError(t, err)
pbParams, err := stateStore.LoadConsensusParams(1)
params, err := stateStore.LoadConsensusParams(1)
require.NoError(t, err)
params := types.ConsensusParamsFromProto(pbParams)
require.Equal(t, types.DefaultConsensusParams(), &params)
// we give the state store different params but say that the height hasn't changed, hence
@ -153,8 +151,7 @@ func TestStoreLoadConsensusParams(t *testing.T) {
differentParams.Block.MaxBytes = 20000
err = stateStore.Save(makeRandomStateFromConsensusParams(differentParams, 10, 1))
require.NoError(t, err)
pbRes, err := stateStore.LoadConsensusParams(10)
res := types.ConsensusParamsFromProto(pbRes)
res, err := stateStore.LoadConsensusParams(10)
require.NoError(t, err)
require.Equal(t, res, params)
require.NotEqual(t, res, differentParams)
@ -257,7 +254,7 @@ 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{}), "params should not be empty")
require.False(t, params.Equals(&types.ConsensusParams{}), "params should not be empty")
} else {
require.Error(t, err, "params height %v", h)
}


+ 1
- 1
statesync/mocks/state_provider.go View File

@ -1,4 +1,4 @@
// Code generated by mockery v2.3.0. DO NOT EDIT.
// Code generated by mockery v2.5.1. DO NOT EDIT.
package mocks


+ 2
- 2
test/maverick/consensus/replay.go View File

@ -308,12 +308,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,
}


+ 1
- 1
test/maverick/consensus/state.go View File

@ -1826,7 +1826,7 @@ func (cs *State) voteTime() time.Time {
minVoteTime := now
// 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
const timeIota = 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)


+ 19
- 24
types/params.go View File

@ -5,8 +5,8 @@ import (
"fmt"
"time"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
tmstrings "github.com/tendermint/tendermint/libs/strings"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
@ -43,9 +43,6 @@ type HashedParams struct {
type BlockParams struct {
MaxBytes int64 `json:"max_bytes"`
MaxGas int64 `json:"max_gas"`
// Minimum time increment between consecutive blocks (in milliseconds)
// Not exposed to the application.
TimeIotaMs int64 `json:"time_iota_ms"`
}
// EvidenceParams determine how we handle evidence of malfeasance.
@ -78,9 +75,8 @@ func DefaultConsensusParams() *ConsensusParams {
// DefaultBlockParams returns a default BlockParams.
func DefaultBlockParams() BlockParams {
return BlockParams{
MaxBytes: 22020096, // 21MB
MaxGas: -1,
TimeIotaMs: 1, // 1s, parameter is now unused
MaxBytes: 22020096, // 21MB
MaxGas: -1,
}
}
@ -133,11 +129,6 @@ func (params ConsensusParams) ValidateConsensusParams() 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)
@ -198,9 +189,15 @@ func (params ConsensusParams) HashConsensusParams() []byte {
return hasher.Sum(nil)
}
func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool {
return params.Block == params2.Block &&
params.Evidence == params2.Evidence &&
tmstrings.StringSliceEqual(params.Validator.PubKeyTypes, params2.Validator.PubKeyTypes)
}
// Update returns a copy of the params with updates from the non-zero fields of p2.
// NOTE: note: must not modify the original
func (params ConsensusParams) UpdateConsensusParams(params2 *abci.ConsensusParams) ConsensusParams {
func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusParams) ConsensusParams {
res := params // explicit copy
if params2 == nil {
@ -228,22 +225,21 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *abci.ConsensusParam
return res
}
func (params ConsensusParams) ToProto() tmproto.ConsensusParams {
func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
return tmproto.ConsensusParams{
Block: tmproto.BlockParams{
MaxBytes: params.Block.MaxBytes,
MaxGas: params.Block.MaxGas,
TimeIotaMs: params.Block.TimeIotaMs,
Block: &tmproto.BlockParams{
MaxBytes: params.Block.MaxBytes,
MaxGas: params.Block.MaxGas,
},
Evidence: tmproto.EvidenceParams{
Evidence: &tmproto.EvidenceParams{
MaxAgeNumBlocks: params.Evidence.MaxAgeNumBlocks,
MaxAgeDuration: params.Evidence.MaxAgeDuration,
MaxBytes: params.Evidence.MaxBytes,
},
Validator: tmproto.ValidatorParams{
Validator: &tmproto.ValidatorParams{
PubKeyTypes: params.Validator.PubKeyTypes,
},
Version: tmproto.VersionParams{
Version: &tmproto.VersionParams{
AppVersion: params.Version.AppVersion,
},
}
@ -252,9 +248,8 @@ func (params ConsensusParams) ToProto() tmproto.ConsensusParams {
func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams {
return ConsensusParams{
Block: BlockParams{
MaxBytes: pbParams.Block.MaxBytes,
MaxGas: pbParams.Block.MaxGas,
TimeIotaMs: pbParams.Block.TimeIotaMs,
MaxBytes: pbParams.Block.MaxBytes,
MaxGas: pbParams.Block.MaxGas,
},
Evidence: EvidenceParams{
MaxAgeNumBlocks: pbParams.Evidence.MaxAgeNumBlocks,


+ 42
- 46
types/params_test.go 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"
)
@ -23,24 +22,23 @@ func TestConsensusParamsValidation(t *testing.T) {
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},
7: {makeParams(1024*1024*1024, 0, -1, 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},
8: {makeParams(1, 0, 0, 0, valEd25519), false},
9: {makeParams(1, 0, 2, 2, valEd25519), false},
10: {makeParams(1000, 0, 2, 1, valEd25519), true},
11: {makeParams(1, 0, -1, 0, valEd25519), false},
// test no pubkey type provided
13: {makeParams(1, 0, 10, 2, 0, []string{}), false},
12: {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},
13: {makeParams(1, 0, 2, 0, []string{"potatoes make good pubkeys"}), false},
}
for i, tc := range testCases {
if tc.valid {
@ -53,16 +51,14 @@ func TestConsensusParamsValidation(t *testing.T) {
func makeParams(
blockBytes, blockGas int64,
blockTimeIotaMs int64,
evidenceAge int64,
maxEvidenceBytes int64,
pubkeyTypes []string,
) ConsensusParams {
return ConsensusParams{
Block: BlockParams{
MaxBytes: blockBytes,
MaxGas: blockGas,
TimeIotaMs: blockTimeIotaMs,
MaxBytes: blockBytes,
MaxGas: blockGas,
},
Evidence: EvidenceParams{
MaxAgeNumBlocks: evidenceAge,
@ -77,14 +73,14 @@ func makeParams(
func TestConsensusParamsHash(t *testing.T) {
params := []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),
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))
@ -105,20 +101,20 @@ func TestConsensusParamsHash(t *testing.T) {
func TestConsensusParamsUpdate(t *testing.T) {
testCases := []struct {
params ConsensusParams
updates *abci.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,7 +127,7 @@ func TestConsensusParamsUpdate(t *testing.T) {
PubKeyTypes: valSecp256k1,
},
},
makeParams(100, 200, 10, 300, 50, valSecp256k1),
makeParams(100, 200, 300, 50, valSecp256k1),
},
}
for _, tc := range testCases {
@ -140,26 +136,26 @@ func TestConsensusParamsUpdate(t *testing.T) {
}
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)
updated := params.UpdateConsensusParams(
&abci.ConsensusParams{Version: &tmproto.VersionParams{AppVersion: 1}})
&tmproto.ConsensusParams{Version: &tmproto.VersionParams{AppVersion: 1}})
assert.EqualValues(t, 1, updated.Version.AppVersion)
}
func TestProto(t *testing.T) {
params := []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),
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 {


+ 0
- 20
types/protobuf.go View File

@ -97,26 +97,6 @@ func (tm2pb) ValidatorUpdates(vals *ValidatorSet) []abci.ValidatorUpdate {
return validators
}
func (tm2pb) ConsensusParams(params *ConsensusParams) *abci.ConsensusParams {
return &abci.ConsensusParams{
Block: &abci.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{
AppVersion: params.Version.AppVersion,
},
}
}
// XXX: panics on nil or unknown pubkey type
func (tm2pb) NewValidatorUpdate(pubkey crypto.PubKey, power int64) abci.ValidatorUpdate {
pubkeyABCI, err := cryptoenc.PubKeyToProto(pubkey)


+ 0
- 8
types/protobuf_test.go 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 := cp.UpdateConsensusParams(abciCP)
assert.Equal(t, *cp, cp2)
}
type pubKeyEddie struct{}
func (pubKeyEddie) Address() Address { return []byte{} }


Loading…
Cancel
Save