Browse Source

types: add TimeoutParams into ConsensusParams structs (#8177)

pull/8184/head
William Banfield 2 years ago
committed by GitHub
parent
commit
e2fc50ec9f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 839 additions and 67 deletions
  1. +8
    -0
      config/toml.go
  2. +2
    -2
      docs/architecture/adr-074-timeout-params.md
  3. +674
    -52
      proto/tendermint/types/params.pb.go
  4. +4
    -4
      proto/tendermint/types/params.proto
  5. +1
    -1
      spec/core/data_structures.md
  6. +8
    -0
      types/genesis_test.go
  7. +92
    -0
      types/params.go
  8. +50
    -8
      types/params_test.go

+ 8
- 0
config/toml.go View File

@ -602,6 +602,14 @@ var testGenesisFmt = `{
"message_delay": "500000000", "message_delay": "500000000",
"precision": "10000000" "precision": "10000000"
}, },
"timeout": {
"propose": "30000000000",
"propose_delta": "50000000",
"vote": "30000000000",
"vote_delta": "50000000",
"commit": "10000000000",
"bypass_commit_timeout": false
},
"evidence": { "evidence": {
"max_age_num_blocks": "100000", "max_age_num_blocks": "100000",
"max_age_duration": "172800000000000", "max_age_duration": "172800000000000",


+ 2
- 2
docs/architecture/adr-074-timeout-params.md View File

@ -67,7 +67,7 @@ The 8 timeout parameters will be consolidated down to 6. These will be as follow
parameters. parameters.
* `TimeoutCommit` * `TimeoutCommit`
* Same as current `TimeoutCommit`. * Same as current `TimeoutCommit`.
* `EnableTimeoutCommitBypass`
* `BypassCommitTimeout`
* Same as current `SkipTimeoutCommit`, renamed for clarity. * Same as current `SkipTimeoutCommit`, renamed for clarity.
A safe default will be provided by Tendermint for each of these parameters and A safe default will be provided by Tendermint for each of these parameters and
@ -149,7 +149,7 @@ message TimeoutParams {
google.protobuf.Duration vote = 3; google.protobuf.Duration vote = 3;
google.protobuf.Duration vote_delta = 4; google.protobuf.Duration vote_delta = 4;
google.protobuf.Duration commit = 5; google.protobuf.Duration commit = 5;
bool enable_commit_timeout_bypass = 6;
bool bypass_commit_timeout = 6;
} }
``` ```


+ 674
- 52
proto/tendermint/types/params.pb.go View File

@ -35,6 +35,7 @@ type ConsensusParams struct {
Validator *ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,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"` Version *VersionParams `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
Synchrony *SynchronyParams `protobuf:"bytes,5,opt,name=synchrony,proto3" json:"synchrony,omitempty"` Synchrony *SynchronyParams `protobuf:"bytes,5,opt,name=synchrony,proto3" json:"synchrony,omitempty"`
Timeout *TimeoutParams `protobuf:"bytes,6,opt,name=timeout,proto3" json:"timeout,omitempty"`
} }
func (m *ConsensusParams) Reset() { *m = ConsensusParams{} } func (m *ConsensusParams) Reset() { *m = ConsensusParams{} }
@ -105,6 +106,13 @@ func (m *ConsensusParams) GetSynchrony() *SynchronyParams {
return nil return nil
} }
func (m *ConsensusParams) GetTimeout() *TimeoutParams {
if m != nil {
return m.Timeout
}
return nil
}
// BlockParams contains limits on the block size. // BlockParams contains limits on the block size.
type BlockParams struct { type BlockParams struct {
// Max block size, in bytes. // Max block size, in bytes.
@ -441,6 +449,123 @@ func (m *SynchronyParams) GetPrecision() *time.Duration {
return nil return nil
} }
// TimeoutParams configure the timeouts for the steps of the Tendermint consensus algorithm.
type TimeoutParams struct {
// These fields configure the timeouts for the propose step of the Tendermint
// consensus algorithm: propose is the initial timeout and propose_delta
// determines how much the timeout grows in subsequent rounds.
// For the first round, this propose timeout is used and for every subsequent
// round, the timeout grows by propose_delta.
//
// For example:
// With propose = 10ms, propose_delta = 5ms, the first round's propose phase
// timeout would be 10ms, the second round's would be 15ms, the third 20ms and so on.
//
// If a node waiting for a proposal message does not receive one matching its
// current height and round before this timeout, the node will issue a
// nil prevote for the round and advance to the next step.
Propose *time.Duration `protobuf:"bytes,1,opt,name=propose,proto3,stdduration" json:"propose,omitempty"`
ProposeDelta *time.Duration `protobuf:"bytes,2,opt,name=propose_delta,json=proposeDelta,proto3,stdduration" json:"propose_delta,omitempty"`
// vote along with vote_delta configure the timeout for both of the prevote and
// precommit steps of the Tendermint consensus algorithm.
//
// These parameters influence the vote step timeouts in the the same way that
// the propose and propose_delta parameters do to the proposal step.
//
// The vote timeout does not begin until a quorum of votes has been received. Once
// a quorum of votes has been seen and this timeout elapses, Tendermint will
// procced to the next step of the consensus algorithm. If Tendermint receives
// all of the remaining votes before the end of the timeout, it will proceed
// to the next step immediately.
Vote *time.Duration `protobuf:"bytes,3,opt,name=vote,proto3,stdduration" json:"vote,omitempty"`
VoteDelta *time.Duration `protobuf:"bytes,4,opt,name=vote_delta,json=voteDelta,proto3,stdduration" json:"vote_delta,omitempty"`
// commit configures how long Tendermint will wait after receiving a quorum of
// precommits before beginning consensus for the next height. This can be
// used to allow slow precommits to arrive for inclusion in the next height before progressing.
Commit *time.Duration `protobuf:"bytes,5,opt,name=commit,proto3,stdduration" json:"commit,omitempty"`
// bypass_commit_timeout configures the node to proceed immediately to
// the next height once the node has received all precommits for a block, forgoing
// the remaining commit timeout.
// Setting bypass_commit_timeout false (the default) causes Tendermint to wait
// for the full commit timeout.
BypassCommitTimeout bool `protobuf:"varint,6,opt,name=bypass_commit_timeout,json=bypassCommitTimeout,proto3" json:"bypass_commit_timeout,omitempty"`
}
func (m *TimeoutParams) Reset() { *m = TimeoutParams{} }
func (m *TimeoutParams) String() string { return proto.CompactTextString(m) }
func (*TimeoutParams) ProtoMessage() {}
func (*TimeoutParams) Descriptor() ([]byte, []int) {
return fileDescriptor_e12598271a686f57, []int{7}
}
func (m *TimeoutParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *TimeoutParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_TimeoutParams.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *TimeoutParams) XXX_Merge(src proto.Message) {
xxx_messageInfo_TimeoutParams.Merge(m, src)
}
func (m *TimeoutParams) XXX_Size() int {
return m.Size()
}
func (m *TimeoutParams) XXX_DiscardUnknown() {
xxx_messageInfo_TimeoutParams.DiscardUnknown(m)
}
var xxx_messageInfo_TimeoutParams proto.InternalMessageInfo
func (m *TimeoutParams) GetPropose() *time.Duration {
if m != nil {
return m.Propose
}
return nil
}
func (m *TimeoutParams) GetProposeDelta() *time.Duration {
if m != nil {
return m.ProposeDelta
}
return nil
}
func (m *TimeoutParams) GetVote() *time.Duration {
if m != nil {
return m.Vote
}
return nil
}
func (m *TimeoutParams) GetVoteDelta() *time.Duration {
if m != nil {
return m.VoteDelta
}
return nil
}
func (m *TimeoutParams) GetCommit() *time.Duration {
if m != nil {
return m.Commit
}
return nil
}
func (m *TimeoutParams) GetBypassCommitTimeout() bool {
if m != nil {
return m.BypassCommitTimeout
}
return false
}
func init() { func init() {
proto.RegisterType((*ConsensusParams)(nil), "tendermint.types.ConsensusParams") proto.RegisterType((*ConsensusParams)(nil), "tendermint.types.ConsensusParams")
proto.RegisterType((*BlockParams)(nil), "tendermint.types.BlockParams") proto.RegisterType((*BlockParams)(nil), "tendermint.types.BlockParams")
@ -449,48 +574,56 @@ func init() {
proto.RegisterType((*VersionParams)(nil), "tendermint.types.VersionParams") proto.RegisterType((*VersionParams)(nil), "tendermint.types.VersionParams")
proto.RegisterType((*HashedParams)(nil), "tendermint.types.HashedParams") proto.RegisterType((*HashedParams)(nil), "tendermint.types.HashedParams")
proto.RegisterType((*SynchronyParams)(nil), "tendermint.types.SynchronyParams") proto.RegisterType((*SynchronyParams)(nil), "tendermint.types.SynchronyParams")
proto.RegisterType((*TimeoutParams)(nil), "tendermint.types.TimeoutParams")
} }
func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) } func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) }
var fileDescriptor_e12598271a686f57 = []byte{ var fileDescriptor_e12598271a686f57 = []byte{
// 565 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4d, 0x8b, 0xd3, 0x40,
0x18, 0xc7, 0x9b, 0xed, 0xbe, 0xb4, 0x4f, 0xb7, 0xdb, 0x65, 0x10, 0x8c, 0x2b, 0x9b, 0xd6, 0x1c,
0x64, 0x41, 0x48, 0xc4, 0x45, 0x44, 0x50, 0xc4, 0x6e, 0x45, 0x41, 0x56, 0x24, 0xbe, 0x1c, 0xf6,
0x12, 0x26, 0xed, 0x98, 0x86, 0x6d, 0x32, 0x43, 0x26, 0x29, 0xcd, 0xb7, 0xf0, 0x24, 0x7e, 0x04,
0xfd, 0x18, 0xde, 0xf6, 0xb8, 0x47, 0x4f, 0x2a, 0xed, 0x17, 0x91, 0x99, 0xcc, 0x6c, 0xb6, 0x5d,
0x15, 0x6f, 0xc9, 0x3c, 0xff, 0xdf, 0x3c, 0xcc, 0xef, 0x49, 0x06, 0xf6, 0x33, 0x92, 0x8c, 0x48,
0x1a, 0x47, 0x49, 0xe6, 0x66, 0x05, 0x23, 0xdc, 0x65, 0x38, 0xc5, 0x31, 0x77, 0x58, 0x4a, 0x33,
0x8a, 0x76, 0xab, 0xb2, 0x23, 0xcb, 0x7b, 0xd7, 0x42, 0x1a, 0x52, 0x59, 0x74, 0xc5, 0x53, 0x99,
0xdb, 0xb3, 0x42, 0x4a, 0xc3, 0x09, 0x71, 0xe5, 0x5b, 0x90, 0x7f, 0x70, 0x47, 0x79, 0x8a, 0xb3,
0x88, 0x26, 0x65, 0xdd, 0xfe, 0xb6, 0x06, 0x9d, 0x23, 0x9a, 0x70, 0x92, 0xf0, 0x9c, 0xbf, 0x96,
0x1d, 0xd0, 0x21, 0x6c, 0x04, 0x13, 0x3a, 0x3c, 0x35, 0x8d, 0x9e, 0x71, 0xd0, 0xba, 0xb7, 0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
0xea, 0xf5, 0x11, 0x6c, 0xca, 0xf5, 0xc3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x57, 0x89, 0x7c,
0xd9, 0x59, 0x04, 0x00, 0x00,
// 680 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcf, 0x6e, 0xd3, 0x4a,
0x14, 0xc6, 0xe3, 0x26, 0x4d, 0x93, 0x93, 0xa6, 0xa9, 0xe6, 0xde, 0xab, 0xeb, 0xdb, 0xab, 0x3a,
0xc5, 0x0b, 0x54, 0x09, 0xc9, 0x41, 0xad, 0x50, 0x85, 0xc4, 0x1f, 0x91, 0x06, 0x81, 0x84, 0x8a,
0x90, 0x29, 0x2c, 0xba, 0xb1, 0xc6, 0xc9, 0xe0, 0x5a, 0x8d, 0x3d, 0x96, 0xc7, 0x8e, 0xe2, 0xb7,
0x60, 0x85, 0x78, 0x04, 0x78, 0x93, 0x2e, 0xbb, 0x64, 0x05, 0x28, 0x7d, 0x03, 0xd6, 0x2c, 0xd0,
0xfc, 0x6b, 0x9a, 0x94, 0xd2, 0xac, 0xe2, 0xcc, 0xf9, 0x7e, 0xfe, 0x3c, 0xdf, 0x39, 0x33, 0xb0,
0x99, 0x91, 0x78, 0x40, 0xd2, 0x28, 0x8c, 0xb3, 0x4e, 0x56, 0x24, 0x84, 0x75, 0x12, 0x9c, 0xe2,
0x88, 0x39, 0x49, 0x4a, 0x33, 0x8a, 0xd6, 0xa7, 0x65, 0x47, 0x94, 0x37, 0xfe, 0x0e, 0x68, 0x40,
0x45, 0xb1, 0xc3, 0x9f, 0xa4, 0x6e, 0xc3, 0x0a, 0x28, 0x0d, 0x86, 0xa4, 0x23, 0xfe, 0xf9, 0xf9,
0xbb, 0xce, 0x20, 0x4f, 0x71, 0x16, 0xd2, 0x58, 0xd6, 0xed, 0x9f, 0x4b, 0xd0, 0xda, 0xa7, 0x31,
0x23,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c, 0x1a, 0x9f, 0xcd, 0x24, 0xa5, 0x09, 0x65, 0x64, 0xd1, 0x0f, 0xd2, 0x7a, 0xbe, 0x23, 0xf5,
0xc8, 0x77, 0x94, 0xe1, 0x45, 0xbf, 0x67, 0x55, 0x51, 0x3d, 0x0e, 0xa1, 0x5d, 0xa8, 0x8c, 0x68,
0x46, 0xd4, 0xa1, 0xbe, 0x11, 0x16, 0x62, 0xf4, 0x08, 0x80, 0xff, 0x2a, 0xdf, 0xca, 0x82, 0x39,
0x70, 0x44, 0x9a, 0xee, 0x41, 0xb5, 0x4f, 0xa3, 0x28, 0xcc, 0xd4, 0x79, 0xbe, 0x91, 0x55, 0x72,
0xb4, 0x03, 0xff, 0xf8, 0x45, 0x82, 0x19, 0xf3, 0xe4, 0x82, 0x77, 0xf9, 0x60, 0xd7, 0xdc, 0xbf,
0x64, 0x71, 0x5f, 0xd4, 0x54, 0xd0, 0xdd, 0x37, 0x9f, 0x26, 0x96, 0x71, 0x3a, 0xb1, 0x8c, 0xb3,
0x89, 0x65, 0x7c, 0x9f, 0x58, 0xc6, 0xfb, 0x73, 0xab, 0x74, 0x76, 0x6e, 0x95, 0xbe, 0x9c, 0x5b,
0xa5, 0xa3, 0xbd, 0x20, 0xcc, 0x8e, 0x73, 0xdf, 0xe9, 0xd3, 0xa8, 0x73, 0xf9, 0x4a, 0x9f, 0x3e,
0xca, 0x3b, 0x7b, 0xfe, 0xba, 0xf7, 0xab, 0x62, 0x7d, 0xf7, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff,
0xfc, 0x06, 0xae, 0x9f, 0x09, 0x06, 0x00, 0x00,
} }
func (this *ConsensusParams) Equal(that interface{}) bool { func (this *ConsensusParams) Equal(that interface{}) bool {
@ -527,6 +660,9 @@ func (this *ConsensusParams) Equal(that interface{}) bool {
if !this.Synchrony.Equal(that1.Synchrony) { if !this.Synchrony.Equal(that1.Synchrony) {
return false return false
} }
if !this.Timeout.Equal(that1.Timeout) {
return false
}
return true return true
} }
func (this *BlockParams) Equal(that interface{}) bool { func (this *BlockParams) Equal(that interface{}) bool {
@ -705,6 +841,75 @@ func (this *SynchronyParams) Equal(that interface{}) bool {
} }
return true return true
} }
func (this *TimeoutParams) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*TimeoutParams)
if !ok {
that2, ok := that.(TimeoutParams)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
return this == nil
} else if this == nil {
return false
}
if this.Propose != nil && that1.Propose != nil {
if *this.Propose != *that1.Propose {
return false
}
} else if this.Propose != nil {
return false
} else if that1.Propose != nil {
return false
}
if this.ProposeDelta != nil && that1.ProposeDelta != nil {
if *this.ProposeDelta != *that1.ProposeDelta {
return false
}
} else if this.ProposeDelta != nil {
return false
} else if that1.ProposeDelta != nil {
return false
}
if this.Vote != nil && that1.Vote != nil {
if *this.Vote != *that1.Vote {
return false
}
} else if this.Vote != nil {
return false
} else if that1.Vote != nil {
return false
}
if this.VoteDelta != nil && that1.VoteDelta != nil {
if *this.VoteDelta != *that1.VoteDelta {
return false
}
} else if this.VoteDelta != nil {
return false
} else if that1.VoteDelta != nil {
return false
}
if this.Commit != nil && that1.Commit != nil {
if *this.Commit != *that1.Commit {
return false
}
} else if this.Commit != nil {
return false
} else if that1.Commit != nil {
return false
}
if this.BypassCommitTimeout != that1.BypassCommitTimeout {
return false
}
return true
}
func (m *ConsensusParams) Marshal() (dAtA []byte, err error) { func (m *ConsensusParams) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@ -725,6 +930,18 @@ func (m *ConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if m.Timeout != nil {
{
size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x32
}
if m.Synchrony != nil { if m.Synchrony != nil {
{ {
size, err := m.Synchrony.MarshalToSizedBuffer(dAtA[:i]) size, err := m.Synchrony.MarshalToSizedBuffer(dAtA[:i])
@ -846,12 +1063,12 @@ func (m *EvidenceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i-- i--
dAtA[i] = 0x18 dAtA[i] = 0x18
} }
n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration):])
if err6 != nil {
return 0, err6
n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration):])
if err7 != nil {
return 0, err7
} }
i -= n6
i = encodeVarintParams(dAtA, i, uint64(n6))
i -= n7
i = encodeVarintParams(dAtA, i, uint64(n7))
i-- i--
dAtA[i] = 0x12 dAtA[i] = 0x12
if m.MaxAgeNumBlocks != 0 { if m.MaxAgeNumBlocks != 0 {
@ -976,22 +1193,105 @@ func (m *SynchronyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
var l int var l int
_ = l _ = l
if m.Precision != nil { if m.Precision != nil {
n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Precision, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Precision):])
if err7 != nil {
return 0, err7
n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Precision, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Precision):])
if err8 != nil {
return 0, err8
} }
i -= n7
i = encodeVarintParams(dAtA, i, uint64(n7))
i -= n8
i = encodeVarintParams(dAtA, i, uint64(n8))
i-- i--
dAtA[i] = 0x12 dAtA[i] = 0x12
} }
if m.MessageDelay != nil { if m.MessageDelay != nil {
n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.MessageDelay, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.MessageDelay):])
if err8 != nil {
return 0, err8
n9, err9 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.MessageDelay, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.MessageDelay):])
if err9 != nil {
return 0, err9
} }
i -= n8
i = encodeVarintParams(dAtA, i, uint64(n8))
i -= n9
i = encodeVarintParams(dAtA, i, uint64(n9))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *TimeoutParams) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *TimeoutParams) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *TimeoutParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.BypassCommitTimeout {
i--
if m.BypassCommitTimeout {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i--
dAtA[i] = 0x30
}
if m.Commit != nil {
n10, err10 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Commit, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Commit):])
if err10 != nil {
return 0, err10
}
i -= n10
i = encodeVarintParams(dAtA, i, uint64(n10))
i--
dAtA[i] = 0x2a
}
if m.VoteDelta != nil {
n11, err11 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.VoteDelta, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.VoteDelta):])
if err11 != nil {
return 0, err11
}
i -= n11
i = encodeVarintParams(dAtA, i, uint64(n11))
i--
dAtA[i] = 0x22
}
if m.Vote != nil {
n12, err12 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Vote, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Vote):])
if err12 != nil {
return 0, err12
}
i -= n12
i = encodeVarintParams(dAtA, i, uint64(n12))
i--
dAtA[i] = 0x1a
}
if m.ProposeDelta != nil {
n13, err13 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.ProposeDelta, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.ProposeDelta):])
if err13 != nil {
return 0, err13
}
i -= n13
i = encodeVarintParams(dAtA, i, uint64(n13))
i--
dAtA[i] = 0x12
}
if m.Propose != nil {
n14, err14 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Propose, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Propose):])
if err14 != nil {
return 0, err14
}
i -= n14
i = encodeVarintParams(dAtA, i, uint64(n14))
i-- i--
dAtA[i] = 0xa dAtA[i] = 0xa
} }
@ -1035,6 +1335,10 @@ func (m *ConsensusParams) Size() (n int) {
l = m.Synchrony.Size() l = m.Synchrony.Size()
n += 1 + l + sovParams(uint64(l)) n += 1 + l + sovParams(uint64(l))
} }
if m.Timeout != nil {
l = m.Timeout.Size()
n += 1 + l + sovParams(uint64(l))
}
return n return n
} }
@ -1129,6 +1433,38 @@ func (m *SynchronyParams) Size() (n int) {
return n return n
} }
func (m *TimeoutParams) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Propose != nil {
l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Propose)
n += 1 + l + sovParams(uint64(l))
}
if m.ProposeDelta != nil {
l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.ProposeDelta)
n += 1 + l + sovParams(uint64(l))
}
if m.Vote != nil {
l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Vote)
n += 1 + l + sovParams(uint64(l))
}
if m.VoteDelta != nil {
l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.VoteDelta)
n += 1 + l + sovParams(uint64(l))
}
if m.Commit != nil {
l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Commit)
n += 1 + l + sovParams(uint64(l))
}
if m.BypassCommitTimeout {
n += 2
}
return n
}
func sovParams(x uint64) (n int) { func sovParams(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7 return (math_bits.Len64(x|1) + 6) / 7
} }
@ -1344,6 +1680,42 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
return err return err
} }
iNdEx = postIndex iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Timeout == nil {
m.Timeout = &TimeoutParams{}
}
if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipParams(dAtA[iNdEx:]) skippy, err := skipParams(dAtA[iNdEx:])
@ -1935,6 +2307,256 @@ func (m *SynchronyParams) Unmarshal(dAtA []byte) error {
} }
return nil return nil
} }
func (m *TimeoutParams) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: TimeoutParams: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: TimeoutParams: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Propose", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Propose == nil {
m.Propose = new(time.Duration)
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.Propose, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ProposeDelta", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.ProposeDelta == nil {
m.ProposeDelta = new(time.Duration)
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.ProposeDelta, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Vote == nil {
m.Vote = new(time.Duration)
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.Vote, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field VoteDelta", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.VoteDelta == nil {
m.VoteDelta = new(time.Duration)
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.VoteDelta, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Commit == nil {
m.Commit = new(time.Duration)
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.Commit, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 6:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field BypassCommitTimeout", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
m.BypassCommitTimeout = bool(v != 0)
default:
iNdEx = preIndex
skippy, err := skipParams(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthParams
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipParams(dAtA []byte) (n int, err error) { func skipParams(dAtA []byte) (n int, err error) {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0


+ 4
- 4
proto/tendermint/types/params.proto View File

@ -120,10 +120,10 @@ message TimeoutParams {
// used to allow slow precommits to arrive for inclusion in the next height before progressing. // used to allow slow precommits to arrive for inclusion in the next height before progressing.
google.protobuf.Duration commit = 5 [(gogoproto.stdduration) = true]; google.protobuf.Duration commit = 5 [(gogoproto.stdduration) = true];
// enable_commit_timeout_bypass configures the node to proceed immediately to
// bypass_commit_timeout configures the node to proceed immediately to
// the next height once the node has received all precommits for a block, forgoing // the next height once the node has received all precommits for a block, forgoing
// the remaining commit timeout. // the remaining commit timeout.
// Setting enable_commit_timeout_bypass false (the default) causes Tendermint to wait
// for the full commit.
bool enable_commit_timeout_bypass = 6;
// Setting bypass_commit_timeout false (the default) causes Tendermint to wait
// for the full commit timeout.
bool bypass_commit_timeout = 6;
} }

+ 1
- 1
spec/core/data_structures.md View File

@ -466,7 +466,7 @@ func SumTruncated(bz []byte) []byte {
| vote | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration)| Parameter that, along with vote_delta, configures the timeout for the prevote and precommit step of the consensus algorithm. | 3 | | vote | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration)| Parameter that, along with vote_delta, configures the timeout for the prevote and precommit step of the consensus algorithm. | 3 |
| vote_delta | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration)| Parameter that, along with vote, configures the timeout for the prevote and precommit step of the consensus algorithm. | 4 | | vote_delta | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration)| Parameter that, along with vote, configures the timeout for the prevote and precommit step of the consensus algorithm. | 4 |
| commit | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration) | Parameter that configures how long Tendermint will wait after receiving a quorum of precommits before beginning consensus for the next height.| 5 | | commit | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration) | Parameter that configures how long Tendermint will wait after receiving a quorum of precommits before beginning consensus for the next height.| 5 |
| enable_commit_timeout_bypass | bool | Parameter that, if enabled, configures the node to proceed immediately to the next height once the node has received all precommits for a block, forgoing the commit timeout. | 6 |
| bypass_commit_timeout | bool | Parameter that, if enabled, configures the node to proceed immediately to the next height once the node has received all precommits for a block, forgoing the commit timeout. | 6 |
## Proof ## Proof


+ 8
- 0
types/genesis_test.go View File

@ -72,6 +72,14 @@ func TestBasicGenesisDoc(t *testing.T) {
"app_state":{"account_owner": "Bob"}, "app_state":{"account_owner": "Bob"},
"consensus_params": { "consensus_params": {
"synchrony": {"precision": "1", "message_delay": "10"}, "synchrony": {"precision": "1", "message_delay": "10"},
"timeout": {
"propose": "30000000000",
"propose_delta": "50000000",
"vote": "30000000000",
"vote_delta": "50000000",
"commit": "10000000000",
"bypass_commit_timeout": false
},
"validator": {"pub_key_types":["ed25519"]}, "validator": {"pub_key_types":["ed25519"]},
"block": {"max_bytes": "100"}, "block": {"max_bytes": "100"},
"evidence": {"max_age_num_blocks": "100", "max_age_duration": "10"} "evidence": {"max_age_num_blocks": "100", "max_age_duration": "10"}


+ 92
- 0
types/params.go View File

@ -42,6 +42,7 @@ type ConsensusParams struct {
Validator ValidatorParams `json:"validator"` Validator ValidatorParams `json:"validator"`
Version VersionParams `json:"version"` Version VersionParams `json:"version"`
Synchrony SynchronyParams `json:"synchrony"` Synchrony SynchronyParams `json:"synchrony"`
Timeout TimeoutParams `json:"timeout"`
} }
// HashedParams is a subset of ConsensusParams. // HashedParams is a subset of ConsensusParams.
@ -85,6 +86,16 @@ type SynchronyParams struct {
MessageDelay time.Duration `json:"message_delay,string"` MessageDelay time.Duration `json:"message_delay,string"`
} }
// TimeoutParams configure the timings of the steps of the Tendermint consensus algorithm.
type TimeoutParams struct {
Propose time.Duration `json:"propose,string"`
ProposeDelta time.Duration `json:"propose_delta,string"`
Vote time.Duration `json:"vote,string"`
VoteDelta time.Duration `json:"vote_delta,string"`
Commit time.Duration `json:"commit,string"`
BypassCommitTimeout bool `json:"bypass_commit_timeout"`
}
// DefaultConsensusParams returns a default ConsensusParams. // DefaultConsensusParams returns a default ConsensusParams.
func DefaultConsensusParams() *ConsensusParams { func DefaultConsensusParams() *ConsensusParams {
return &ConsensusParams{ return &ConsensusParams{
@ -93,6 +104,7 @@ func DefaultConsensusParams() *ConsensusParams {
Validator: DefaultValidatorParams(), Validator: DefaultValidatorParams(),
Version: DefaultVersionParams(), Version: DefaultVersionParams(),
Synchrony: DefaultSynchronyParams(), Synchrony: DefaultSynchronyParams(),
Timeout: DefaultTimeoutParams(),
} }
} }
@ -135,6 +147,18 @@ func DefaultSynchronyParams() SynchronyParams {
Precision: 505 * time.Millisecond, Precision: 505 * time.Millisecond,
MessageDelay: 12 * time.Second, MessageDelay: 12 * time.Second,
} }
}
func DefaultTimeoutParams() TimeoutParams {
return TimeoutParams{
Propose: 3000 * time.Millisecond,
ProposeDelta: 500 * time.Millisecond,
Vote: 1000 * time.Millisecond,
VoteDelta: 500 * time.Millisecond,
Commit: 1000 * time.Millisecond,
BypassCommitTimeout: false,
}
} }
func (val *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool { func (val *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool {
@ -150,6 +174,9 @@ func (params *ConsensusParams) Complete() {
if params.Synchrony == (SynchronyParams{}) { if params.Synchrony == (SynchronyParams{}) {
params.Synchrony = DefaultSynchronyParams() params.Synchrony = DefaultSynchronyParams()
} }
if params.Timeout == (TimeoutParams{}) {
params.Timeout = DefaultTimeoutParams()
}
} }
// Validate validates the ConsensusParams to ensure all values are within their // Validate validates the ConsensusParams to ensure all values are within their
@ -199,6 +226,26 @@ func (params ConsensusParams) ValidateConsensusParams() error {
params.Synchrony.Precision) params.Synchrony.Precision)
} }
if params.Timeout.Propose < 0 {
return fmt.Errorf("timeout.ProposeDelta must not be negative. Got: %d", params.Timeout.Propose)
}
if params.Timeout.ProposeDelta < 0 {
return fmt.Errorf("timeout.ProposeDelta must not be negative. Got: %d", params.Timeout.ProposeDelta)
}
if params.Timeout.Vote < 0 {
return fmt.Errorf("timeout.Vote must not be negative. Got: %d", params.Timeout.Vote)
}
if params.Timeout.VoteDelta < 0 {
return fmt.Errorf("timeout.VoteDelta must not be negative. Got: %d", params.Timeout.VoteDelta)
}
if params.Timeout.Commit < 0 {
return fmt.Errorf("timeout.Commit must not be negative. Got: %d", params.Timeout.Commit)
}
if len(params.Validator.PubKeyTypes) == 0 { if len(params.Validator.PubKeyTypes) == 0 {
return errors.New("len(Validator.PubKeyTypes) must be greater than 0") return errors.New("len(Validator.PubKeyTypes) must be greater than 0")
} }
@ -244,6 +291,7 @@ func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool {
params.Evidence == params2.Evidence && params.Evidence == params2.Evidence &&
params.Version == params2.Version && params.Version == params2.Version &&
params.Synchrony == params2.Synchrony && params.Synchrony == params2.Synchrony &&
params.Timeout == params2.Timeout &&
tmstrings.StringSliceEqual(params.Validator.PubKeyTypes, params2.Validator.PubKeyTypes) tmstrings.StringSliceEqual(params.Validator.PubKeyTypes, params2.Validator.PubKeyTypes)
} }
@ -282,6 +330,24 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa
res.Synchrony.Precision = *params2.Synchrony.GetPrecision() res.Synchrony.Precision = *params2.Synchrony.GetPrecision()
} }
} }
if params2.Timeout != nil {
if params2.Timeout.Propose != nil {
res.Timeout.Propose = *params2.Timeout.GetPropose()
}
if params2.Timeout.ProposeDelta != nil {
res.Timeout.ProposeDelta = *params2.Timeout.GetProposeDelta()
}
if params2.Timeout.Vote != nil {
res.Timeout.Vote = *params2.Timeout.GetVote()
}
if params2.Timeout.VoteDelta != nil {
res.Timeout.VoteDelta = *params2.Timeout.GetVoteDelta()
}
if params2.Timeout.Commit != nil {
res.Timeout.Commit = *params2.Timeout.GetCommit()
}
res.Timeout.BypassCommitTimeout = params2.Timeout.GetBypassCommitTimeout()
}
return res return res
} }
@ -306,6 +372,14 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
MessageDelay: &params.Synchrony.MessageDelay, MessageDelay: &params.Synchrony.MessageDelay,
Precision: &params.Synchrony.Precision, Precision: &params.Synchrony.Precision,
}, },
Timeout: &tmproto.TimeoutParams{
Propose: &params.Timeout.Propose,
ProposeDelta: &params.Timeout.ProposeDelta,
Vote: &params.Timeout.Vote,
VoteDelta: &params.Timeout.VoteDelta,
Commit: &params.Timeout.Commit,
BypassCommitTimeout: params.Timeout.BypassCommitTimeout,
},
} }
} }
@ -335,5 +409,23 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams
c.Synchrony.Precision = *pbParams.Synchrony.GetPrecision() c.Synchrony.Precision = *pbParams.Synchrony.GetPrecision()
} }
} }
if pbParams.Timeout != nil {
if pbParams.Timeout.Propose != nil {
c.Timeout.Propose = *pbParams.Timeout.GetPropose()
}
if pbParams.Timeout.ProposeDelta != nil {
c.Timeout.ProposeDelta = *pbParams.Timeout.GetProposeDelta()
}
if pbParams.Timeout.Vote != nil {
c.Timeout.Vote = *pbParams.Timeout.GetVote()
}
if pbParams.Timeout.VoteDelta != nil {
c.Timeout.VoteDelta = *pbParams.Timeout.GetVoteDelta()
}
if pbParams.Timeout.Commit != nil {
c.Timeout.Commit = *pbParams.Timeout.GetCommit()
}
c.Timeout.BypassCommitTimeout = pbParams.Timeout.BypassCommitTimeout
}
return c return c
} }

+ 50
- 8
types/params_test.go View File

@ -168,13 +168,19 @@ func TestConsensusParamsValidation(t *testing.T) {
} }
type makeParamsArgs struct { type makeParamsArgs struct {
blockBytes int64
blockGas int64
evidenceAge int64
maxEvidenceBytes int64
pubkeyTypes []string
precision time.Duration
messageDelay time.Duration
blockBytes int64
blockGas int64
evidenceAge int64
maxEvidenceBytes int64
pubkeyTypes []string
precision time.Duration
messageDelay time.Duration
propose time.Duration
proposeDelta time.Duration
vote time.Duration
voteDelta time.Duration
commit time.Duration
bypassCommitTimeout bool
} }
func makeParams(args makeParamsArgs) ConsensusParams { func makeParams(args makeParamsArgs) ConsensusParams {
@ -198,8 +204,15 @@ func makeParams(args makeParamsArgs) ConsensusParams {
Precision: args.precision, Precision: args.precision,
MessageDelay: args.messageDelay, MessageDelay: args.messageDelay,
}, },
Timeout: TimeoutParams{
Propose: args.propose,
ProposeDelta: args.proposeDelta,
Vote: args.vote,
VoteDelta: args.voteDelta,
Commit: args.commit,
BypassCommitTimeout: args.bypassCommitTimeout,
},
} }
} }
func TestConsensusParamsHash(t *testing.T) { func TestConsensusParamsHash(t *testing.T) {
@ -252,6 +265,35 @@ func TestConsensusParamsUpdate(t *testing.T) {
}, },
updatedParams: makeParams(makeParamsArgs{evidenceAge: 3, precision: 2 * time.Second, messageDelay: 4 * time.Second}), updatedParams: makeParams(makeParamsArgs{evidenceAge: 3, precision: 2 * time.Second, messageDelay: 4 * time.Second}),
}, },
{
// update timeout params
intialParams: makeParams(makeParamsArgs{
propose: 3 * time.Second,
proposeDelta: 500 * time.Millisecond,
vote: time.Second,
voteDelta: 500 * time.Millisecond,
commit: time.Second,
bypassCommitTimeout: false,
}),
updates: &tmproto.ConsensusParams{
Timeout: &tmproto.TimeoutParams{
Propose: durationPtr(2 * time.Second),
ProposeDelta: durationPtr(400 * time.Millisecond),
Vote: durationPtr(5 * time.Second),
VoteDelta: durationPtr(400 * time.Millisecond),
Commit: durationPtr(time.Minute),
BypassCommitTimeout: true,
},
},
updatedParams: makeParams(makeParamsArgs{
propose: 2 * time.Second,
proposeDelta: 400 * time.Millisecond,
vote: 5 * time.Second,
voteDelta: 400 * time.Millisecond,
commit: time.Minute,
bypassCommitTimeout: true,
}),
},
// fine updates // fine updates
{ {
intialParams: makeParams(makeParamsArgs{blockBytes: 1, blockGas: 2, evidenceAge: 3}), intialParams: makeParams(makeParamsArgs{blockBytes: 1, blockGas: 2, evidenceAge: 3}),


Loading…
Cancel
Save