proto: rename timing params to synchrony params

This commit is contained in:
William Banfield
2022-01-11 11:50:28 -05:00
parent 2617a5cf33
commit 81729d1ac3
9 changed files with 118 additions and 117 deletions

View File

@@ -66,7 +66,7 @@ type pbtsTestHarness struct {
type pbtsTestConfiguration struct {
// The timestamp consensus parameters to be used by the state machine under test.
timingParams types.TimingParams
synchronyParams types.SynchronyParams
// The setting to use for the TimeoutPropose configuration parameter.
timeoutPropose time.Duration
@@ -102,7 +102,7 @@ func newPBTSTestHarness(ctx context.Context, t *testing.T, tc pbtsTestConfigurat
}
cfg.Consensus.TimeoutPropose = tc.timeoutPropose
consensusParams := types.DefaultConsensusParams()
consensusParams.Timing = tc.timingParams
consensusParams.Synchrony = tc.synchronyParams
state, privVals := makeGenesisState(cfg, genesisStateArgs{
Params: consensusParams,
@@ -333,7 +333,7 @@ func TestProposerWaitsForGenesisTime(t *testing.T) {
// create a genesis time far (enough) in the future.
initialTime := time.Now().Add(800 * time.Millisecond)
cfg := pbtsTestConfiguration{
timingParams: types.TimingParams{
synchronyParams: types.SynchronyParams{
Precision: 10 * time.Millisecond,
MessageDelay: 10 * time.Millisecond,
},
@@ -361,7 +361,7 @@ func TestProposerWaitsForPreviousBlock(t *testing.T) {
defer cancel()
initialTime := time.Now().Add(time.Millisecond * 50)
cfg := pbtsTestConfiguration{
timingParams: types.TimingParams{
synchronyParams: types.SynchronyParams{
Precision: 100 * time.Millisecond,
MessageDelay: 500 * time.Millisecond,
},
@@ -430,7 +430,7 @@ func TestTimelyProposal(t *testing.T) {
initialTime := time.Now()
cfg := pbtsTestConfiguration{
timingParams: types.TimingParams{
synchronyParams: types.SynchronyParams{
Precision: 10 * time.Millisecond,
MessageDelay: 140 * time.Millisecond,
},
@@ -453,7 +453,7 @@ func TestTooFarInThePastProposal(t *testing.T) {
// localtime > proposedBlockTime + MsgDelay + Precision
cfg := pbtsTestConfiguration{
timingParams: types.TimingParams{
synchronyParams: types.SynchronyParams{
Precision: 1 * time.Millisecond,
MessageDelay: 10 * time.Millisecond,
},
@@ -478,7 +478,7 @@ func TestTooFarInTheFutureProposal(t *testing.T) {
// localtime < proposedBlockTime - Precision
cfg := pbtsTestConfiguration{
timingParams: types.TimingParams{
synchronyParams: types.SynchronyParams{
Precision: 1 * time.Millisecond,
MessageDelay: 10 * time.Millisecond,
},

View File

@@ -1314,12 +1314,12 @@ func (cs *State) enterPrevote(height int64, round int32) {
}
func (cs *State) proposalIsTimely() bool {
tp := types.TimingParams{
Precision: cs.state.ConsensusParams.Timing.Precision,
MessageDelay: cs.state.ConsensusParams.Timing.MessageDelay,
sp := types.SynchronyParams{
Precision: cs.state.ConsensusParams.Synchrony.Precision,
MessageDelay: cs.state.ConsensusParams.Synchrony.MessageDelay,
}
return cs.Proposal.IsTimely(cs.ProposalReceiveTime, tp, cs.state.InitialHeight)
return cs.Proposal.IsTimely(cs.ProposalReceiveTime, sp, cs.state.InitialHeight)
}
func (cs *State) defaultDoPrevote(height int64, round int32) {
@@ -1351,9 +1351,9 @@ func (cs *State) defaultDoPrevote(height int64, round int32) {
"received",
tmtime.Canonical(cs.ProposalReceiveTime).Format(time.RFC3339Nano),
"msg_delay",
cs.state.ConsensusParams.Timing.MessageDelay,
cs.state.ConsensusParams.Synchrony.MessageDelay,
"precision",
cs.state.ConsensusParams.Timing.Precision)
cs.state.ConsensusParams.Synchrony.Precision)
cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{})
return
}

View File

@@ -203,7 +203,7 @@ func TestStateSyncVectors(t *testing.T) {
Version: &tmproto.VersionParams{
AppVersion: 11,
},
Timing: &tmproto.TimingParams{
Synchrony: &tmproto.SynchronyParams{
MessageDelay: 550,
Precision: 90,
},

View File

@@ -34,7 +34,7 @@ type ConsensusParams struct {
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"`
Timing *TimingParams `protobuf:"bytes,5,opt,name=timing,proto3" json:"timing,omitempty"`
Synchrony *SynchronyParams `protobuf:"bytes,5,opt,name=synchrony,proto3" json:"synchrony,omitempty"`
}
func (m *ConsensusParams) Reset() { *m = ConsensusParams{} }
@@ -98,9 +98,9 @@ func (m *ConsensusParams) GetVersion() *VersionParams {
return nil
}
func (m *ConsensusParams) GetTiming() *TimingParams {
func (m *ConsensusParams) GetSynchrony() *SynchronyParams {
if m != nil {
return m.Timing
return m.Synchrony
}
return nil
}
@@ -381,23 +381,23 @@ func (m *HashedParams) GetBlockMaxGas() int64 {
return 0
}
type TimingParams struct {
type SynchronyParams struct {
MessageDelay time.Duration `protobuf:"bytes,1,opt,name=message_delay,json=messageDelay,proto3,stdduration" json:"message_delay"`
Precision time.Duration `protobuf:"bytes,2,opt,name=precision,proto3,stdduration" json:"precision"`
}
func (m *TimingParams) Reset() { *m = TimingParams{} }
func (m *TimingParams) String() string { return proto.CompactTextString(m) }
func (*TimingParams) ProtoMessage() {}
func (*TimingParams) Descriptor() ([]byte, []int) {
func (m *SynchronyParams) Reset() { *m = SynchronyParams{} }
func (m *SynchronyParams) String() string { return proto.CompactTextString(m) }
func (*SynchronyParams) ProtoMessage() {}
func (*SynchronyParams) Descriptor() ([]byte, []int) {
return fileDescriptor_e12598271a686f57, []int{6}
}
func (m *TimingParams) XXX_Unmarshal(b []byte) error {
func (m *SynchronyParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *TimingParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (m *SynchronyParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_TimingParams.Marshal(b, m, deterministic)
return xxx_messageInfo_SynchronyParams.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@@ -407,26 +407,26 @@ func (m *TimingParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
return b[:n], nil
}
}
func (m *TimingParams) XXX_Merge(src proto.Message) {
xxx_messageInfo_TimingParams.Merge(m, src)
func (m *SynchronyParams) XXX_Merge(src proto.Message) {
xxx_messageInfo_SynchronyParams.Merge(m, src)
}
func (m *TimingParams) XXX_Size() int {
func (m *SynchronyParams) XXX_Size() int {
return m.Size()
}
func (m *TimingParams) XXX_DiscardUnknown() {
xxx_messageInfo_TimingParams.DiscardUnknown(m)
func (m *SynchronyParams) XXX_DiscardUnknown() {
xxx_messageInfo_SynchronyParams.DiscardUnknown(m)
}
var xxx_messageInfo_TimingParams proto.InternalMessageInfo
var xxx_messageInfo_SynchronyParams proto.InternalMessageInfo
func (m *TimingParams) GetMessageDelay() time.Duration {
func (m *SynchronyParams) GetMessageDelay() time.Duration {
if m != nil {
return m.MessageDelay
}
return 0
}
func (m *TimingParams) GetPrecision() time.Duration {
func (m *SynchronyParams) GetPrecision() time.Duration {
if m != nil {
return m.Precision
}
@@ -440,48 +440,49 @@ func init() {
proto.RegisterType((*ValidatorParams)(nil), "tendermint.types.ValidatorParams")
proto.RegisterType((*VersionParams)(nil), "tendermint.types.VersionParams")
proto.RegisterType((*HashedParams)(nil), "tendermint.types.HashedParams")
proto.RegisterType((*TimingParams)(nil), "tendermint.types.TimingParams")
proto.RegisterType((*SynchronyParams)(nil), "tendermint.types.SynchronyParams")
}
func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) }
var fileDescriptor_e12598271a686f57 = []byte{
// 559 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6e, 0xd3, 0x30,
0x1c, 0xc7, 0x9b, 0x75, 0xeb, 0xda, 0x5f, 0xdb, 0x75, 0xb2, 0x90, 0x08, 0x43, 0x4b, 0x4b, 0x0e,
0x68, 0x12, 0x52, 0x82, 0x98, 0x00, 0x21, 0x21, 0xa1, 0x75, 0x43,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0x73, 0x5f,
0xcf, 0x2b, 0x3f, 0xd9, 0xa6, 0x07, 0x98, 0x73, 0x55, 0xb3, 0x2f, 0xa0, 0x75, 0x8a, 0xc5, 0x25,
0x19, 0x2a, 0xe0, 0x3e, 0x74, 0xa4, 0x05, 0x7f, 0x55, 0x70, 0x5b, 0x2e, 0x9f, 0x69, 0xcb, 0x36,
0xb4, 0xcb, 0x5e, 0xe9, 0xba, 0xa9, 0x5b, 0xb9, 0xf0, 0xcf, 0x06, 0xb4, 0x16, 0xc7, 0x89, 0x4e,
0xa1, 0x4d, 0x89, 0x10, 0xd2, 0x20, 0x19, 0xe1, 0xa9, 0xfa, 0xd5, 0xff, 0x93, 0xbe, 0x96, 0x22,
0x4f, 0x72, 0x10, 0x1d, 0x41, 0x83, 0x27, 0x64, 0x10, 0x89, 0xff, 0x1c, 0x42, 0x49, 0xf5, 0xdf,
0x7d, 0x99, 0x59, 0xc6, 0xf5, 0xcc, 0x32, 0x6e, 0x66, 0x96, 0xf1, 0x6b, 0x66, 0x19, 0x1f, 0xe7,
0x56, 0xe5, 0x66, 0x6e, 0x55, 0xbe, 0xcf, 0xad, 0xca, 0xc5, 0xd3, 0x30, 0x4a, 0x2f, 0xb3, 0xc0,
0x19, 0x30, 0xea, 0x2e, 0x5e, 0x0f, 0xe5, 0x63, 0xf1, 0xff, 0x5f, 0xbd, 0x3a, 0x82, 0x9a, 0x5c,
0x3f, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x57, 0x2d, 0xa2, 0x55, 0x04, 0x00, 0x00,
// 561 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4d, 0x6b, 0xd4, 0x40,
0x18, 0xc7, 0x37, 0xdd, 0xbe, 0xec, 0x3e, 0xdb, 0xed, 0x96, 0x41, 0x30, 0x56, 0x9a, 0x5d, 0x73,
0x90, 0x82, 0x90, 0x88, 0x45,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10, 0xda, 0x0b, 0x23, 0x40, 0x5d, 0x68, 0x61, 0xc6,
0x7c, 0x3d, 0x38, 0xb1, 0xb3, 0x55, 0x0f, 0x30, 0x63, 0x0a, 0xb3, 0x4f, 0x61, 0xf3, 0x18, 0xf3,
0x11, 0x19, 0x2a, 0xe1, 0x3e, 0x74, 0x64, 0x0a, 0xfe, 0x72, 0xc0, 0x6d, 0xb9, 0x7c, 0xa2, 0x53,
0xb6, 0xa1, 0x5d, 0x71, 0x55, 0xd6, 0x2d, 0x4d, 0x89, 0xc0, 0xbf, 0x18, 0xd0, 0x59, 0x1a, 0x2a,
0x3a, 0x86, 0x76, 0x4c, 0x38, 0x97, 0x21, 0x92, 0x31, 0x2e, 0xd4, 0x1f, 0xf0, 0x5f, 0x09, 0x6e,
0x2a, 0xf3, 0x48, 0x88, 0xe8, 0x00, 0x9a, 0x2c, 0x25, 0x83, 0x88, 0xdf, 0x70, 0x0e, 0x95, 0xd5,
0x7f, 0xff, 0x75, 0x66, 0x19, 0xe7, 0x33, 0xcb, 0xb8, 0x98, 0x59, 0xc6, 0xef, 0x99, 0x65, 0x7c,
0x9a, 0x5b, 0xb5, 0x8b, 0xb9, 0x55, 0xfb, 0x31, 0xb7, 0x6a, 0xa7, 0x4f, 0xc2, 0x28, 0x1b, 0xe5,
0x81, 0x33, 0xa0, 0xb1, 0x7b, 0xf5, 0xaa, 0xa8, 0x1e, 0xcb, 0xbb, 0x60, 0xf9, 0x1a, 0x09, 0xd6,
0xe5, 0xfa, 0xfe, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x26, 0x8a, 0x0b, 0x61, 0x04, 0x00,
0x00,
}
func (this *ConsensusParams) Equal(that interface{}) bool {
@@ -515,7 +516,7 @@ func (this *ConsensusParams) Equal(that interface{}) bool {
if !this.Version.Equal(that1.Version) {
return false
}
if !this.Timing.Equal(that1.Timing) {
if !this.Synchrony.Equal(that1.Synchrony) {
return false
}
return true
@@ -657,14 +658,14 @@ func (this *HashedParams) Equal(that interface{}) bool {
}
return true
}
func (this *TimingParams) Equal(that interface{}) bool {
func (this *SynchronyParams) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*TimingParams)
that1, ok := that.(*SynchronyParams)
if !ok {
that2, ok := that.(TimingParams)
that2, ok := that.(SynchronyParams)
if ok {
that1 = &that2
} else {
@@ -704,9 +705,9 @@ func (m *ConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.Timing != nil {
if m.Synchrony != nil {
{
size, err := m.Timing.MarshalToSizedBuffer(dAtA[:i])
size, err := m.Synchrony.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
@@ -934,7 +935,7 @@ func (m *HashedParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *TimingParams) Marshal() (dAtA []byte, err error) {
func (m *SynchronyParams) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@@ -944,12 +945,12 @@ func (m *TimingParams) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
func (m *TimingParams) MarshalTo(dAtA []byte) (int, error) {
func (m *SynchronyParams) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *TimingParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
func (m *SynchronyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
@@ -1006,8 +1007,8 @@ func (m *ConsensusParams) Size() (n int) {
l = m.Version.Size()
n += 1 + l + sovParams(uint64(l))
}
if m.Timing != nil {
l = m.Timing.Size()
if m.Synchrony != nil {
l = m.Synchrony.Size()
n += 1 + l + sovParams(uint64(l))
}
return n
@@ -1087,7 +1088,7 @@ func (m *HashedParams) Size() (n int) {
return n
}
func (m *TimingParams) Size() (n int) {
func (m *SynchronyParams) Size() (n int) {
if m == nil {
return 0
}
@@ -1281,7 +1282,7 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Timing", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Synchrony", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -1308,10 +1309,10 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Timing == nil {
m.Timing = &TimingParams{}
if m.Synchrony == nil {
m.Synchrony = &SynchronyParams{}
}
if err := m.Timing.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
if err := m.Synchrony.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
@@ -1784,7 +1785,7 @@ func (m *HashedParams) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *TimingParams) Unmarshal(dAtA []byte) error {
func (m *SynchronyParams) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@@ -1807,10 +1808,10 @@ func (m *TimingParams) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: TimingParams: wiretype end group for non-group")
return fmt.Errorf("proto: SynchronyParams: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: TimingParams: illegal tag %d (wire type %d)", fieldNum, wire)
return fmt.Errorf("proto: SynchronyParams: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:

View File

@@ -144,4 +144,4 @@ extend google.protobuf.FieldOptions {
optional bool wktpointer = 65012;
optional string castrepeated = 65013;
}
}

View File

@@ -41,7 +41,7 @@ type ConsensusParams struct {
Evidence EvidenceParams `json:"evidence"`
Validator ValidatorParams `json:"validator"`
Version VersionParams `json:"version"`
Timing TimingParams `json:"timing"`
Synchrony SynchronyParams `json:"synchrony"`
}
// HashedParams is a subset of ConsensusParams.
@@ -76,9 +76,9 @@ type VersionParams struct {
AppVersion uint64 `json:"app_version"`
}
// TimingParams influence the validity of block timestamps.
// SynchronyParams influence the validity of block timestamps.
// TODO (@wbanfield): add link to proposer-based timestamp spec when completed.
type TimingParams struct {
type SynchronyParams struct {
Precision time.Duration `json:"precision"`
MessageDelay time.Duration `json:"message_delay"`
}
@@ -90,7 +90,7 @@ func DefaultConsensusParams() *ConsensusParams {
Evidence: DefaultEvidenceParams(),
Validator: DefaultValidatorParams(),
Version: DefaultVersionParams(),
Timing: DefaultTimingParams(),
Synchrony: DefaultSynchronyParams(),
}
}
@@ -125,10 +125,10 @@ func DefaultVersionParams() VersionParams {
}
}
func DefaultTimingParams() TimingParams {
func DefaultSynchronyParams() SynchronyParams {
// TODO(@wbanfield): Determine experimental values for these defaults
// https://github.com/tendermint/tendermint/issues/7202
return TimingParams{
return SynchronyParams{
Precision: 10 * time.Millisecond,
MessageDelay: 500 * time.Millisecond,
}
@@ -180,14 +180,14 @@ func (params ConsensusParams) ValidateConsensusParams() error {
params.Evidence.MaxBytes)
}
if params.Timing.MessageDelay <= 0 {
if params.Synchrony.MessageDelay <= 0 {
return fmt.Errorf("timing.MessageDelay must be greater than 0. Got: %d",
params.Timing.MessageDelay)
params.Synchrony.MessageDelay)
}
if params.Timing.Precision <= 0 {
if params.Synchrony.Precision <= 0 {
return fmt.Errorf("timing.Precision must be greater than 0. Got: %d",
params.Timing.Precision)
params.Synchrony.Precision)
}
if len(params.Validator.PubKeyTypes) == 0 {
@@ -234,7 +234,7 @@ func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool {
return params.Block == params2.Block &&
params.Evidence == params2.Evidence &&
params.Version == params2.Version &&
params.Timing == params2.Timing &&
params.Synchrony == params2.Synchrony &&
tmstrings.StringSliceEqual(params.Validator.PubKeyTypes, params2.Validator.PubKeyTypes)
}
@@ -265,9 +265,9 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa
if params2.Version != nil {
res.Version.AppVersion = params2.Version.AppVersion
}
if params2.Timing != nil {
res.Timing.Precision = params2.Timing.Precision
res.Timing.MessageDelay = params2.Timing.MessageDelay
if params2.Synchrony != nil {
res.Synchrony.Precision = params2.Synchrony.Precision
res.Synchrony.MessageDelay = params2.Synchrony.MessageDelay
}
return res
}
@@ -289,9 +289,9 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
Version: &tmproto.VersionParams{
AppVersion: params.Version.AppVersion,
},
Timing: &tmproto.TimingParams{
MessageDelay: params.Timing.MessageDelay,
Precision: params.Timing.Precision,
Synchrony: &tmproto.SynchronyParams{
MessageDelay: params.Synchrony.MessageDelay,
Precision: params.Synchrony.Precision,
},
}
}
@@ -313,9 +313,9 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams
Version: VersionParams{
AppVersion: pbParams.Version.AppVersion,
},
Timing: TimingParams{
MessageDelay: pbParams.Timing.MessageDelay,
Precision: pbParams.Timing.Precision,
Synchrony: SynchronyParams{
MessageDelay: pbParams.Synchrony.MessageDelay,
Precision: pbParams.Synchrony.Precision,
},
}
}

View File

@@ -194,7 +194,7 @@ func makeParams(args makeParamsArgs) ConsensusParams {
Validator: ValidatorParams{
PubKeyTypes: args.pubkeyTypes,
},
Timing: TimingParams{
Synchrony: SynchronyParams{
Precision: args.precision,
MessageDelay: args.messageDelay,
},
@@ -245,7 +245,7 @@ func TestConsensusParamsUpdate(t *testing.T) {
// update timing params
intialParams: makeParams(makeParamsArgs{evidenceAge: 3, precision: time.Second, messageDelay: 3 * time.Second}),
updates: &tmproto.ConsensusParams{
Timing: &tmproto.TimingParams{
Synchrony: &tmproto.SynchronyParams{
Precision: time.Second * 2,
MessageDelay: time.Second * 4,
},

View File

@@ -91,11 +91,11 @@ func (p *Proposal) ValidateBasic() error {
// the timestamp in this case is set to the preconfigured genesis time.
// For more information on the meaning of 'timely', see the proposer-based timestamp specification:
// https://github.com/tendermint/spec/tree/master/spec/consensus/proposer-based-timestamp
func (p *Proposal) IsTimely(recvTime time.Time, tp TimingParams, initialHeight int64) bool {
func (p *Proposal) IsTimely(recvTime time.Time, sp SynchronyParams, initialHeight int64) bool {
// lhs is `proposedBlockTime - Precision` in the first inequality
lhs := p.Timestamp.Add(-tp.Precision)
lhs := p.Timestamp.Add(-sp.Precision)
// rhs is `proposedBlockTime + MsgDelay + Precision` in the second inequality
rhs := p.Timestamp.Add(tp.MessageDelay).Add(tp.Precision)
rhs := p.Timestamp.Add(sp.MessageDelay).Add(sp.Precision)
if recvTime.Before(lhs) || (p.Height != initialHeight && recvTime.After(rhs)) {
return false

View File

@@ -278,12 +278,12 @@ func TestIsTimely(t *testing.T) {
Timestamp: testCase.proposalTime,
}
tp := TimingParams{
sp := SynchronyParams{
Precision: testCase.precision,
MessageDelay: testCase.msgDelay,
}
ti := p.IsTimely(testCase.recvTime, tp, testCase.genesisHeight)
ti := p.IsTimely(testCase.recvTime, sp, testCase.genesisHeight)
assert.Equal(t, testCase.expectTimely, ti)
})
}