From eb7c50e82f3e12e32b520473b0fd61c0501236ac Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Fri, 22 Nov 2024 16:21:09 +0530 Subject: [PATCH 1/8] Cherry picked all those changes which include functionalities for next block delay --- ...move-timeout-commit-into-finalize-block.md | 2 + abci/types/application.go | 4 +- abci/types/types.pb.go | 455 ++++++++++-------- config/config.go | 6 +- consensus/state.go | 25 +- docs/app-dev/indexing-transactions.md | 110 ++--- docs/guides/go-built-in.md | 3 + docs/guides/go.md | 7 +- proto/tendermint/abci/types.proto | 7 + proto/tendermint/state/types.pb.go | 190 +++++--- proto/tendermint/state/types.proto | 9 + spec/abci/abci++_methods.md | 30 +- state/execution.go | 14 + state/state.go | 11 + test/e2e/app/app.go | 1 + 15 files changed, 528 insertions(+), 346 deletions(-) create mode 100644 .changelog/v0.38.6/features/2655-move-timeout-commit-into-finalize-block.md diff --git a/.changelog/v0.38.6/features/2655-move-timeout-commit-into-finalize-block.md b/.changelog/v0.38.6/features/2655-move-timeout-commit-into-finalize-block.md new file mode 100644 index 00000000000..95989071422 --- /dev/null +++ b/.changelog/v0.38.6/features/2655-move-timeout-commit-into-finalize-block.md @@ -0,0 +1,2 @@ +- `[config]` Move `timeout_commit` into the ABCI `FinalizeBlockResponse` + ([\#2655](https://github.com/cometbft/cometbft/issues/2655)) diff --git a/abci/types/application.go b/abci/types/application.go index 4ccfd229ebc..0a785a9c737 100644 --- a/abci/types/application.go +++ b/abci/types/application.go @@ -1,6 +1,8 @@ package types -import "context" +import ( + "context" +) //go:generate ../../scripts/mockery_generate.sh Application diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index 5b9860d6b7e..243e4021277 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -13,6 +13,7 @@ import ( proto "github.com/cosmos/gogoproto/proto" _ "github.com/cosmos/gogoproto/types" github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "github.com/golang/protobuf/ptypes/duration" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -2748,6 +2749,9 @@ type ResponseFinalizeBlock struct { ConsensusParamUpdates *types1.ConsensusParams `protobuf:"bytes,4,opt,name=consensus_param_updates,json=consensusParamUpdates,proto3" json:"consensus_param_updates,omitempty"` // app_hash is the hash of the applications' state which is used to confirm that execution of the transactions was deterministic. It is up to the application to decide which algorithm to use. AppHash []byte `protobuf:"bytes,5,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` + // delay between the time when this block is committed and the next height is started. + // previously `timeout_commit` in config.toml + NextBlockDelay time.Duration `protobuf:"bytes,6,opt,name=next_block_delay,json=nextBlockDelay,proto3,stdduration" json:"next_block_delay"` } func (m *ResponseFinalizeBlock) Reset() { *m = ResponseFinalizeBlock{} } @@ -2818,6 +2822,13 @@ func (m *ResponseFinalizeBlock) GetAppHash() []byte { return nil } +func (m *ResponseFinalizeBlock) GetNextBlockDelay() time.Duration { + if m != nil { + return m.NextBlockDelay + } + return 0 +} + type CommitInfo struct { Round int32 `protobuf:"varint,1,opt,name=round,proto3" json:"round,omitempty"` Votes []VoteInfo `protobuf:"bytes,2,rep,name=votes,proto3" json:"votes"` @@ -3664,205 +3675,208 @@ func init() { func init() { proto.RegisterFile("tendermint/abci/types.proto", fileDescriptor_252557cfdd89a31a) } var fileDescriptor_252557cfdd89a31a = []byte{ - // 3167 bytes of a gzipped FileDescriptorProto + // 3216 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x5a, 0xcb, 0x73, 0x23, 0xd5, 0xd5, 0x57, 0xeb, 0xad, 0xa3, 0x87, 0xdb, 0xd7, 0x9e, 0x41, 0x23, 0x06, 0xdb, 0x34, 0x05, 0x0c, 0x03, 0xd8, 0x7c, 0x9e, 0x6f, 0x78, 0xd4, 0xc0, 0x57, 0x25, 0x6b, 0x34, 0x9f, 0xec, 0x31, 0xb6, 0x69, 0xc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0f, 0x14, 0x15, 0x4a, 0xe1, 0xd8, 0x8f, 0x4a, 0x10, 0x27, 0x23, 0x31, - 0x4b, 0x9c, 0x8c, 0xd0, 0x4b, 0x90, 0xa4, 0x86, 0x64, 0x73, 0x94, 0xa6, 0x64, 0x3b, 0x21, 0xd7, - 0xbc, 0xb0, 0xb0, 0xca, 0x38, 0x95, 0x25, 0x28, 0x86, 0x72, 0x82, 0x72, 0x15, 0x56, 0xa7, 0x85, - 0x78, 0xa5, 0xeb, 0xd1, 0x43, 0xa1, 0x1a, 0xdd, 0x86, 0xac, 0x17, 0xe3, 0xb9, 0xe3, 0x5c, 0x9b, - 0x98, 0xd6, 0x65, 0x56, 0x3d, 0x56, 0xea, 0x31, 0x74, 0x03, 0xba, 0xba, 0xc8, 0xe8, 0x05, 0x35, - 0xa3, 0x5b, 0x56, 0x43, 0x77, 0xba, 0xca, 0x7b, 0x50, 0x8e, 0x8a, 0xdf, 0x01, 0x83, 0x49, 0xcc, - 0xed, 0x5d, 0x83, 0x5d, 0x85, 0x74, 0xc7, 0xb4, 0xfb, 0x3a, 0x61, 0xca, 0x8a, 0xaa, 0x18, 0x51, - 0x43, 0xf2, 0x58, 0x9e, 0x60, 0x64, 0x3e, 0x50, 0x34, 0xb8, 0x16, 0x19, 0xc3, 0xa9, 0x88, 0x31, - 0x68, 0x63, 0x6e, 0xd6, 0xa2, 0xca, 0x07, 0xbe, 0x22, 0xfe, 0xb1, 0x7c, 0x40, 0xa7, 0x75, 0xd8, - 0x5a, 0x99, 0xfe, 0x9c, 0x2a, 0x46, 0xca, 0x67, 0x09, 0xb8, 0x3a, 0x3d, 0x92, 0xa3, 0x0d, 0x28, - 0xf4, 0xf5, 0x91, 0x46, 0x46, 0xc2, 0xed, 0x24, 0xb6, 0xf1, 0xd0, 0xd7, 0x47, 0xcd, 0x11, 0xf7, - 0x39, 0x19, 0x12, 0x64, 0xe4, 0x94, 0xe3, 0x1b, 0x89, 0x1b, 0x05, 0x95, 0x3e, 0xa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 0x20, 0x84, 0xc7, 0xa1, - 0x80, 0xc3, 0x09, 0x28, 0x80, 0xb7, 0xee, 0xcf, 0x44, 0xaa, 0x98, 0x81, 0x05, 0x1c, 0x4e, 0x60, - 0x01, 0xa5, 0x19, 0x0a, 0x67, 0x80, 0x01, 0x3f, 0x9a, 0x0e, 0x06, 0x44, 0xb7, 0xeb, 0xe2, 0x33, - 0xe7, 0x43, 0x03, 0xb4, 0x08, 0x34, 0x40, 0x8e, 0xec, 0x5c, 0xb9, 0xfa, 0xb9, 0xe1, 0x80, 0x93, - 0x29, 0x70, 0x00, 0x6f, 0xdc, 0x6f, 0x44, 0x2a, 0x9f, 0x03, 0x0f, 0x38, 0x99, 0x82, 0x07, 0xa0, - 0x99, 0x6a, 0x67, 0x02, 0x02, 0xf7, 0xc2, 0x80, 0xc0, 0x4a, 0x44, 0xd5, 0xe9, 0x9f, 0xf6, 0x08, - 0x44, 0xe0, 0x34, 0x0a, 0x11, 0xe0, 0x5d, 0xfb, 0x0b, 0x91, 0x1a, 0x17, 0x80, 0x04, 0x0e, 0x27, - 0x20, 0x81, 0x2b, 0x33, 0x3c, 0x6d, 0x7e, 0x4c, 0x20, 0x25, 0xa7, 0xf7, 0x92, 0xd9, 0xac, 0x9c, - 0xe3, 0x68, 0xc0, 0x5e, 0x32, 0x9b, 0x97, 0x0b, 0xca, 0x73, 0xb4, 0x82, 0x19, 0x8b, 0x73, 0xb4, - 0x57, 0xc0, 0xb6, 0x6d, 0xda, 0xa2, 0xbb, 0xe7, 0x03, 0xe5, 0x06, 0xed, 0x11, 0xfd, 0x98, 0x76, - 0x09, 0x7e, 0xc0, 0x7a, 0xb2, 0x40, 0x1c, 0x53, 0x7e, 0x2f, 0xf9, 0xb2, 0x0c, 0x41, 0x08, 0xf6, - 0x97, 0x39, 0xd1, 0x5f, 0x06, 0x50, 0x85, 0x78, 0x18, 0x55, 0x58, 0x87, 0x3c, 0xed, 0xb5, 0xc6, - 0x00, 0x03, 0xdd, 0xf2, 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x15, 0x75, 0x57, 0xa4, 0x11, 0x53, 0x57, 0xce, 0x27, 0xc9, 0xd4, + 0xc5, 0x3a, 0xc6, 0x40, 0xef, 0x19, 0x1f, 0x61, 0xed, 0xb4, 0x67, 0xb6, 0x1e, 0x96, 0x57, 0x2f, + 0x77, 0xb1, 0x7b, 0x82, 0x7b, 0x87, 0x32, 0x53, 0x17, 0xeb, 0x04, 0x09, 0x3b, 0x19, 0x48, 0x9d, + 0xeb, 0xbd, 0x21, 0xde, 0x4b, 0x66, 0x93, 0x72, 0x6a, 0x2f, 0x99, 0xcd, 0xc8, 0xd9, 0xbd, 0x64, + 0x36, 0x27, 0xc3, 0x5e, 0x32, 0x0b, 0x72, 0x5e, 0x79, 0x16, 0xf2, 0x81, 0xc0, 0x84, 0xca, 0x90, + 0xe9, 0x63, 0xc7, 0xd1, 0xcf, 0x30, 0x8b, 0x63, 0x39, 0xd5, 0x1d, 0x2a, 0x25, 0x28, 0x04, 0x83, + 0x91, 0xf2, 0xa9, 0xe4, 0x49, 0xd2, 0x38, 0x43, 0x25, 0xcf, 0xb1, 0xcd, 0xcc, 0x21, 0x24, 0xc5, + 0x10, 0x3d, 0x05, 0x45, 0xb6, 0x14, 0xcd, 0x7d, 0x4f, 0x83, 0x5d, 0x52, 0x2d, 0x30, 0xe2, 0x03, + 0xc1, 0xb4, 0x0e, 0x79, 0x6b, 0xdb, 0xf2, 0x58, 0x12, 0x8c, 0x05, 0xac, 0x6d, 0xcb, 0x65, 0x78, + 0x12, 0x0a, 0x74, 0xdd, 0x1e, 0x47, 0x92, 0x4d, 0x92, 0xa7, 0x34, 0xc1, 0xa2, 0xfc, 0x29, 0x0e, + 0xf2, 0x78, 0x00, 0x43, 0xaf, 0x42, 0x92, 0xc6, 0x7a, 0x11, 0x96, 0x2b, 0x9b, 0x3c, 0xce, 0x6f, + 0xba, 0x71, 0x7e, 0xb3, 0xe9, 0x26, 0x82, 0x9d, 0xec, 0x17, 0x5f, 0xad, 0xc7, 0x3e,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 0xfd, 0xa8, 0x04, 0x71, 0x32, 0x12, 0xb3, 0xc4, 0xc9, 0x08, 0xbd, + 0x04, 0x49, 0x6a, 0x48, 0x36, 0x47, 0x69, 0x4a, 0xb6, 0x13, 0x72, 0xcd, 0x0b, 0x0b, 0xab, 0x8c, + 0x53, 0x59, 0x82, 0x62, 0x28, 0x27, 0x28, 0x57, 0x61, 0x75, 0x5a, 0x88, 0x57, 0xba, 0x1e, 0x3d, + 0x14, 0xaa, 0xd1, 0x6d, 0xc8, 0x7a, 0x31, 0x9e, 0x3b, 0xce, 0xb5, 0x89, 0x69, 0x5d, 0x66, 0xd5, + 0x63, 0xa5, 0x1e, 0x43, 0x37, 0xa0, 0xab, 0x8b, 0x8c, 0x5e, 0x50, 0x33, 0xba, 0x65, 0x35, 0x74, + 0xa7, 0xab, 0xbc, 0x07, 0xe5, 0xa8, 0xf8, 0x1d, 0x30, 0x98, 0xc4, 0xdc, 0xde, 0x35, 0xd8, 0x55, + 0x48, 0x77, 0x4c, 0xbb, 0xaf, 0x13, 0xa6, 0xac, 0xa8, 0x8a, 0x11, 0x35, 0x24, 0x8f, 0xe5, 0x09, + 0x46, 0xe6, 0x03, 0x45, 0x83, 0x6b, 0x91, 0x31, 0x9c, 0x8a, 0x18, 0x83, 0x36, 0xe6, 0x66, 0x2d, + 0xaa, 0x7c, 0xe0, 0x2b, 0xe2, 0x1f, 0xcb, 0x07, 0x74, 0x5a, 0x87, 0xad, 0x95, 0xe9, 0xcf, 0xa9, + 0x62, 0xa4, 0x7c, 0x96, 0x80, 0xab, 0xd3, 0x23, 0x39, 0xda, 0x80, 0x42, 0x5f, 0x1f, 0x69, 0x64, + 0x24, 0xdc, 0x4e, 0x62, 0x1b, 0x0f, 0x7d, 0x7d, 0xd4, 0x1c, 0x71, 0x9f, 0x93, 0x21, 0x41, 0x46, + 0x4e, 0x39, 0xbe, 0x91, 0xb8, 0x51, 0x50, 0xe9, 0x23, 0x3a, 0x81, 0xe5, 0x9e, 0xd9,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x0a, 0x38, 0x9c, 0x80, 0x02, + 0x78, 0xeb, 0xfe, 0x4c, 0xa4, 0x8a, 0x19, 0x58, 0xc0, 0xe1, 0x04, 0x16, 0x50, 0x9a, 0xa1, 0x70, + 0x06, 0x18, 0xf0, 0x83, 0xe9, 0x60, 0x40, 0x74, 0xbb, 0x2e, 0x3e, 0x73, 0x3e, 0x34, 0x40, 0x8b, + 0x40, 0x03, 0xe4, 0xc8, 0xce, 0x95, 0xab, 0x9f, 0x1b, 0x0e, 0x38, 0x99, 0x02, 0x07, 0xf0, 0xc6, + 0xfd, 0x46, 0xa4, 0xf2, 0x39, 0xf0, 0x80, 0x93, 0x29, 0x78, 0x00, 0x9a, 0xa9, 0x76, 0x26, 0x20, + 0x70, 0x2f, 0x0c, 0x08, 0xac, 0x44, 0x54, 0x9d, 0xfe, 0x69, 0x8f, 0x40, 0x04, 0x4e, 0xa3, 0x10, + 0x01, 0xde, 0xb5, 0xbf, 0x10, 0xa9, 0x71, 0x01, 0x48, 0xe0, 0x70, 0x02, 0x12, 0xb8, 0x32, 0xc3, + 0xd3, 0xe6, 0xc7, 0x04, 0x52, 0x72, 0x7a, 0x2f, 0x99, 0xcd, 0xca, 0x39, 0x8e, 0x06, 0xec, 0x25, + 0xb3, 0x79, 0xb9, 0xa0, 0x3c, 0x47, 0x2b, 0x98, 0xb1, 0x38, 0x47, 0x7b, 0x05, 0x6c, 0xdb, 0xa6, + 0x2d, 0xba, 0x7b, 0x3e, 0x50, 0x6e, 0xd0, 0x1e, 0xd1, 0x8f, 0x69, 0x97, 0xe0, 0x07, 0xac, 0x27, + 0x0b, 0xc4, 0x31, 0xe5, 0xb7, 0x92, 0x2f, 0xcb, 0x10, 0x84, 0x60, 0x7f, 0x99, 0x13, 0xfd, 0x65, + 0x00, 0x55, 0x88, 0x87, 0x51, 0x85, 0x75, 0xc8, 0xd3, 0x5e, 0x6b, 0x0c, 0x30, 0xd0, 0x2d, 0x0f, + 0x30, 0xb8, 0x09, 0xcb, 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, 0xe7, 0x6f, 0xd6, 0x62, 0xdf, 0x7b, 0xf6, 0xcc, 0x20, 0xdd, 0xe1, 0xe9, 0x66, 0xcb, 0xec, + 0x6f, 0xb5, 0xcc, 0x3e, 0x26, 0xa7, 0x1d, 0xe2, 0x3f, 0xf8, 0x3f, 0x4a, 0x9f, 0xa6, 0x59, 0x06, + 0xbd, 0xf5, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x0f, 0x00, 0x2c, 0x48, 0x2d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -6777,6 +6791,14 @@ func (m *ResponseFinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + n49, err49 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.NextBlockDelay, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay):]) + if err49 != nil { + return 0, err49 + } + i -= n49 + i = encodeVarintTypes(dAtA, i, uint64(n49)) + i-- + dAtA[i] = 0x32 if len(m.AppHash) > 0 { i -= len(m.AppHash) copy(dAtA[i:], m.AppHash) @@ -7334,12 +7356,12 @@ func (m *Misbehavior) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - n54, err54 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) - if err54 != nil { - return 0, err54 + n55, err55 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) + if err55 != nil { + return 0, err55 } - i -= n54 - i = encodeVarintTypes(dAtA, i, uint64(n54)) + i -= n55 + i = encodeVarintTypes(dAtA, i, uint64(n55)) i-- dAtA[i] = 0x22 if m.Height != 0 { @@ -8548,6 +8570,8 @@ func (m *ResponseFinalizeBlock) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay) + n += 1 + l + sovTypes(uint64(l)) return n } @@ -14792,6 +14816,39 @@ func (m *ResponseFinalizeBlock) Unmarshal(dAtA []byte) error { m.AppHash = []byte{} } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextBlockDelay", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.NextBlockDelay, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/config/config.go b/config/config.go index f78f8088293..5c3c5288c6c 100644 --- a/config/config.go +++ b/config/config.go @@ -158,9 +158,12 @@ func (cfg *Config) ValidateBasic() error { return nil } -// CheckDeprecated returns any deprecation warnings. These are printed to the operator on startup +// CheckDeprecated returns any deprecation warnings. These are printed to the operator on startup. func (cfg *Config) CheckDeprecated() []string { var warnings []string + if cfg.Consensus.TimeoutCommit != 0 { + warnings = append(warnings, "[consensus.timeout_commit] is deprecated. Use `next_block_delay` in the ABCI `FinalizeBlockResponse`.") + } return warnings } @@ -1079,6 +1082,7 @@ func (cfg *ConsensusConfig) Precommit(round int32) time.Duration { // Commit returns the amount of time to wait for straggler votes after receiving +2/3 precommits // for a single block (ie. a commit). +// Deprecated: use `next_block_delay` in the ABCI application's `FinalizeBlockResponse`. func (cfg *ConsensusConfig) Commit(t time.Time) time.Time { return t.Add(cfg.TimeoutCommit) } diff --git a/consensus/state.go b/consensus/state.go index d47b43f2413..2ad2aa58817 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -719,15 +719,20 @@ func (cs *State) updateToState(state sm.State) { cs.updateHeight(height) cs.updateRoundStep(0, cstypes.RoundStepNewHeight) + timeoutCommit := state.NextBlockDelay + // If the ABCI app didn't set a delay, use the deprecated config value. + if timeoutCommit == 0 { + timeoutCommit = cs.config.TimeoutCommit //nolint:staticcheck + } if cs.CommitTime.IsZero() { // "Now" makes it easier to sync up dev nodes. - // We add timeoutCommit to allow transactions - // to be gathered for the first block. - // And alternative solution that relies on clocks: - // cs.StartTime = state.LastBlockTime.Add(timeoutCommit) - cs.StartTime = cs.config.Commit(cmttime.Now()) + // + // We add timeoutCommit to allow transactions to be gathered for + // the first block. An alternative solution that relies on clocks: + // `cs.StartTime = state.LastBlockTime.Add(timeoutCommit)` + cs.StartTime = cmttime.Now().Add(timeoutCommit) } else { - cs.StartTime = cs.config.Commit(cs.CommitTime) + cs.StartTime = cs.CommitTime.Add(timeoutCommit) } cs.Validators = validators @@ -1043,7 +1048,7 @@ func (cs *State) handleTxsAvailable() { // Enter: `timeoutNewHeight` by startTime (commitTime+timeoutCommit), // -// or, if SkipTimeoutCommit==true, after receiving all precommits from (height,round-1) +// or, if NextBlockDelay==0, after receiving all precommits from (height,round-1) // // Enter: `timeoutPrecommits` after any +2/3 precommits from (height,round-1) // Enter: +2/3 precommits for nil at (height,round-1) @@ -2155,7 +2160,8 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.ID) (added bool, err error cs.evsw.FireEvent(types.EventVote, vote) // if we can skip timeoutCommit and have all the votes now, - if cs.config.SkipTimeoutCommit && cs.LastCommit.HasAll() { + skipTimeoutCommit := cs.state.NextBlockDelay == 0 && cs.config.TimeoutCommit == 0 //nolint:staticcheck + if skipTimeoutCommit && cs.LastCommit.HasAll() { // go straight to new round (skip timeout commit) // cs.scheduleTimeout(time.Duration(0), cs.Height, 0, cstypes.RoundStepNewHeight) cs.enterNewRound(cs.Height, 0) @@ -2333,7 +2339,8 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.ID) (added bool, err error if len(blockID.Hash) != 0 { cs.enterCommit(height, vote.Round) - if cs.config.SkipTimeoutCommit && precommits.HasAll() { + skipTimeoutCommit := cs.state.NextBlockDelay == 0 && cs.config.TimeoutCommit == 0 //nolint:staticcheck + if skipTimeoutCommit && precommits.HasAll() { cs.enterNewRound(cs.Height, 0) } } else { diff --git a/docs/app-dev/indexing-transactions.md b/docs/app-dev/indexing-transactions.md index f20f173e993..1d64dc59b28 100644 --- a/docs/app-dev/indexing-transactions.md +++ b/docs/app-dev/indexing-transactions.md @@ -118,7 +118,6 @@ transferBalance200FinalizeBlock12 1 transferNodeNothingFinalizeBlock12 1 ``` - The event number is a local variable kept by the indexer and incremented when a new event is processed. It is an `int64` variable and has no other semantics besides being used to associate attributes belonging to the same events within a height. This variable is not atomically incremented as event indexing is deterministic. **Should this ever change**, the event id generation @@ -173,51 +172,50 @@ UTF-8 encoded strings (e.g. "transfer.sender": "Bob", "transfer.recipient": Example: ```go -func (app *Application) FinalizeBlock(_ context.Context, req *types.RequestFinalizeBlock) (*types.ResponseFinalizeBlock, error) { - +func (app *Application) FinalizeBlock(_ context.Context, req *types.FinalizeBlockRequest) (*types.FinalizeBlockResponse, error) { //... - tx_results[0] := &types.ExecTxResult{ - Code: CodeTypeOK, - // With every transaction we can emit a series of events. To make it simple, we just emit the same events. - Events: []types.Event{ - { - Type: "app", - Attributes: []types.EventAttribute{ - {Key: "creator", Value: "Cosmoshi Netowoko", Index: true}, - {Key: "key", Value: key, Index: true}, - {Key: "index_key", Value: "index is working", Index: true}, - {Key: "noindex_key", Value: "index is working", Index: false}, - }, - }, - { - Type: "app", - Attributes: []types.EventAttribute{ - {Key: "creator", Value: "Cosmoshi", Index: true}, - {Key: "key", Value: value, Index: true}, - {Key: "index_key", Value: "index is working", Index: true}, - {Key: "noindex_key", Value: "index is working", Index: false}, - }, - }, - }, - } + tx_results[0] := &types.ExecTxResult{ + Code: CodeTypeOK, + // With every transaction we can emit a series of events. To make it simple, we just emit the same events. + Events: []types.Event{ + { + Type: "app", + Attributes: []types.EventAttribute{ + {Key: "creator", Value: "Cosmoshi Netowoko", Index: true}, + {Key: "key", Value: key, Index: true}, + {Key: "index_key", Value: "index is working", Index: true}, + {Key: "noindex_key", Value: "index is working", Index: false}, + }, + }, + { + Type: "app", + Attributes: []types.EventAttribute{ + {Key: "creator", Value: "Cosmoshi", Index: true}, + {Key: "key", Value: value, Index: true}, + {Key: "index_key", Value: "index is working", Index: true}, + {Key: "noindex_key", Value: "index is working", Index: false}, + }, + }, + }, + } block_events = []types.Event{ - { - Type: "loan", - Attributes: []types.EventAttribute{ - { Key: "account_no", Value: "1", Index: true}, - { Key: "amount", Value: "200", Index: true }, - }, - }, - { - Type: "loan", - Attributes: []types.EventAttribute{ - { Key: "account_no", Value: "2", Index: true }, - { Key: "amount", Value: "300", Index: true}, - }, - }, - } - return &types.ResponseFinalizeBlock{TxResults: tx_results, Events: block_events} + { + Type: "loan", + Attributes: []types.EventAttribute{ + {Key: "account_no", Value: "1", Index: true}, + {Key: "amount", Value: "200", Index: true}, + }, + }, + { + Type: "loan", + Attributes: []types.EventAttribute{ + {Key: "account_no", Value: "2", Index: true}, + {Key: "amount", Value: "300", Index: true}, + }, + }, + } + return &types.FinalizeBlockResponse{TxResults: tx_results, Events: block_events, NextBlockDelay: 1 * time.Second}, nil } ``` @@ -266,16 +264,13 @@ curl "localhost:26657/block_search?query=\"block.height > 10\"" ``` -Storing the event sequence was introduced in CometBFT 0.34.26. Before that, up -until Tendermint Core 0.34.26, the event sequence was not stored in the kvstore -and events were stored only by height. That means that queries returned blocks -and transactions whose event attributes match within the height but can match -across different events on that height. - -This behavior was fixed with CometBFT 0.34.26+. However, if the data was -indexed with earlier versions of Tendermint Core and not re-indexed, that data -will be queried as if all the attributes within a height occurred within the -same event. +Storing the event sequence was introduced in CometBFT 0.34.26. Before that, up until Tendermint Core 0.34.26, +the event sequence was not stored in the kvstore and events were stored only by height. That means that queries +returned blocks and transactions whose event attributes match within the height but can match across different +events on that height. +This behavior was fixed with CometBFT 0.34.26+. However, if the data was indexed with earlier versions of +Tendermint Core and not re-indexed, that data will be queried as if all the attributes within a height +occurred within the same event. ## Event attribute value types @@ -283,13 +278,10 @@ Users can use anything as an event value. However, if the event attribute value is a number, the following needs to be taken into account: - Negative numbers will not be properly retrieved when querying the indexer. -- Event values are converted to big floats (from the `big/math` package). The - precision of the floating point number is set to the bit length of the - integer it is supposed to represent, so that there is no loss of information - due to insufficient precision. This was not present before CometBFT v0.38.x - and all float values were ignored. +- Event values are converted to big floats (from the `big/math` package). The precision of the floating point number is set to the bit length +of the integer it is supposed to represent, so that there is no loss of information due to insufficient precision. This was not present before CometBFT v0.38.x and all float values were ignored. - As of CometBFT v0.38.x, queries can contain floating point numbers as well. -- Note that comparing to floats can be imprecise with a high number of decimals. +- Note that comparing to floats can be imprecise with a high number of decimals. ## Event type and attribute key format diff --git a/docs/guides/go-built-in.md b/docs/guides/go-built-in.md index b545a06ad4a..0eac085bc7b 100644 --- a/docs/guides/go-built-in.md +++ b/docs/guides/go-built-in.md @@ -375,10 +375,13 @@ func (app *KVStoreApplication) FinalizeBlock(_ context.Context, req *abcitypes.R return &abcitypes.ResponseFinalizeBlock{ TxResults: txs, + NextBlockDelay: 1 * time.Second, }, nil } ``` +`NextBlockDelay` is a delay between the time when the current block is committed and the next height is started. Normally you don't need to change the default value (1s). Please refer to the [spec](../../spec/abci/abci++_methods.md#finalizeblock) for more information. + Transactions are not guaranteed to be valid when they are delivered to an application, even if they were valid when they were proposed. This can happen if the application state is used to determine transaction validity. diff --git a/docs/guides/go.md b/docs/guides/go.md index 0e5cdc79873..d1383459006 100644 --- a/docs/guides/go.md +++ b/docs/guides/go.md @@ -373,12 +373,15 @@ func (app *KVStoreApplication) FinalizeBlock(_ context.Context, req *abcitypes.R } } - return &abcitypes.ResponseFinalizeBlock{ - TxResults: txs, + return &abcitypes.FinalizeBlockResponse{ + TxResults: txs, + NextBlockDelay: 1 * time.Second, }, nil } ``` +`NextBlockDelay` is a delay between the time when the current block is committed and the next height is started. Normally you don't need to change the default value (1s). Please refer to the [spec](../../spec/abci/abci++_methods.md#finalizeblock) for more information. + Transactions are not guaranteed to be valid when they are delivered to an application, even if they were valid when they were proposed. This can happen if the application state is used to determine transaction validity. The application state may have changed between the initial execution of `CheckTx` and the transaction delivery in `FinalizeBlock` in a way that rendered the transaction no longer valid. diff --git a/proto/tendermint/abci/types.proto b/proto/tendermint/abci/types.proto index 89bafb6cd54..f6e33cab578 100644 --- a/proto/tendermint/abci/types.proto +++ b/proto/tendermint/abci/types.proto @@ -10,6 +10,7 @@ import "tendermint/crypto/keys.proto"; import "tendermint/types/params.proto"; import "tendermint/types/validator.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; import "gogoproto/gogo.proto"; // NOTE: When using custom types, mind the warnings. @@ -363,6 +364,12 @@ message ResponseFinalizeBlock { tendermint.types.ConsensusParams consensus_param_updates = 4; // app_hash is the hash of the applications' state which is used to confirm that execution of the transactions was deterministic. It is up to the application to decide which algorithm to use. bytes app_hash = 5; + // delay between the time when this block is committed and the next height is started. + // previously `timeout_commit` in config.toml + google.protobuf.Duration next_block_delay = 6 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true + ]; } //---------------------------------------- diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index 4426543ed9b..ca648c5614d 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -12,6 +12,7 @@ import ( proto "github.com/cosmos/gogoproto/proto" _ "github.com/cosmos/gogoproto/types" github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "github.com/golang/protobuf/ptypes/duration" io "io" math "math" math_bits "math/bits" @@ -445,6 +446,9 @@ type State struct { LastResultsHash []byte `protobuf:"bytes,12,opt,name=last_results_hash,json=lastResultsHash,proto3" json:"last_results_hash,omitempty"` // the latest AppHash we've received from calling abci.Commit() AppHash []byte `protobuf:"bytes,13,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` + // delay between the time when this block is committed and the next height is started. + // previously `timeout_commit` in config.toml + NextBlockDelay time.Duration `protobuf:"bytes,15,opt,name=next_block_delay,json=nextBlockDelay,proto3,stdduration" json:"next_block_delay"` } func (m *State) Reset() { *m = State{} } @@ -578,6 +582,13 @@ func (m *State) GetAppHash() []byte { return nil } +func (m *State) GetNextBlockDelay() time.Duration { + if m != nil { + return m.NextBlockDelay + } + return 0 +} + func init() { proto.RegisterType((*LegacyABCIResponses)(nil), "tendermint.state.LegacyABCIResponses") proto.RegisterType((*ResponseBeginBlock)(nil), "tendermint.state.ResponseBeginBlock") @@ -592,68 +603,70 @@ func init() { func init() { proto.RegisterFile("tendermint/state/types.proto", fileDescriptor_ccfacf933f22bf93) } var fileDescriptor_ccfacf933f22bf93 = []byte{ - // 963 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4b, 0x6f, 0xdb, 0x46, - 0x17, 0x35, 0xe3, 0x44, 0x8f, 0x2b, 0xcb, 0x96, 0x47, 0x9f, 0x13, 0x45, 0xf9, 0x22, 0xa9, 0x42, - 0x12, 0x18, 0x45, 0x41, 0x01, 0xc9, 0xaa, 0x9b, 0x14, 0x96, 0xec, 0xd6, 0x02, 0xdc, 0xa2, 0xa0, - 0xdd, 0x00, 0xe9, 0x22, 0xc4, 0x88, 0x1c, 0x49, 0x83, 0x4a, 0x24, 0xc1, 0x19, 0xa9, 0x72, 0xf7, - 0xdd, 0x75, 0x91, 0x6d, 0xff, 0x51, 0x96, 0x59, 0x76, 0x53, 0xb7, 0x95, 0x81, 0x2e, 0xfa, 0x2b, - 0x8a, 0x79, 0xf0, 0x25, 0xba, 0xa8, 0x8b, 0xec, 0xc8, 0xb9, 0xe7, 0x9e, 0x7b, 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xe5, 0x66, 0x3d, 0x4a, 0x26, 0x38, 0xc9, 0xd6, 0xb3, 0x7c, - 0xe3, 0x7d, 0x02, 0x1f, 0x78, 0x9f, 0x7c, 0x05, 0x4f, 0x32, 0xf7, 0xc9, 0x06, 0x7f, 0x2c, 0xaf, - 0x22, 0xe5, 0x75, 0x52, 0x17, 0x4c, 0x96, 0x28, 0xd2, 0x18, 0x1d, 0xc4, 0x50, 0x7e, 0xa5, 0x99, - 0x3d, 0xc5, 0x6c, 0xda, 0xd8, 0xe9, 0x18, 0x87, 0x3b, 0xea, 0x20, 0xaa, 0xaf, 0x37, 0x3b, 0xc5, - 0x6c, 0x8a, 0x1e, 0x42, 0x09, 0x07, 0x81, 0x82, 0x54, 0x25, 0xa4, 0x88, 0x83, 0x40, 0x84, 0xfa, - 0x5f, 0xbe, 0x5b, 0xb7, 0x8c, 0xf7, 0xeb, 0x96, 0xf1, 0xfb, 0xba, 0x65, 0xbc, 0xbd, 0x6e, 0x6d, - 0xbd, 0xbf, 0x6e, 0x6d, 0xfd, 0x72, 0xdd, 0xda, 0xfa, 0xf6, 0xc5, 0x84, 0xf2, 0xe9, 0x62, 0x64, - 0x3a, 0xfe, 0xbc, 0xe7, 0xf8, 0x73, 0xc2, 0x47, 0x63, 0x9e, 0x3c, 0xa8, 0xff, 0xa5, 0xcd, 0x3f, - 0xad, 0x51, 0x41, 0xae, 0xbf, 0xf8, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xec, 0x26, 0xcf, 0x93, 0x84, - 0x09, 0x00, 0x00, + // 1007 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0xe3, 0xc4, 0x92, 0x47, 0xfe, 0x91, 0xd7, 0x75, 0xc2, 0x38, 0x8d, 0xa4, 0x0a, 0x49, + 0x60, 0x14, 0x05, 0x05, 0x24, 0xa7,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x45, 0xc3, 0xf8, 0x6b, 0xd1, 0x30, 0xde, 0x5c, 0x35, 0x56, 0xde, 0x5d, 0x35, 0x56, + 0x7e, 0xbf, 0x6a, 0xac, 0x7c, 0xf7, 0x6c, 0x44, 0xf9, 0x78, 0x3a, 0xb0, 0xdc, 0x70, 0xd2, 0x71, + 0xc3, 0x09, 0xe1, 0x83, 0x21, 0xcf, 0x3e, 0xd4, 0xef, 0xd9, 0xf2, 0x8f, 0xdd, 0x60, 0x4d, 0xee, + 0x3f, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6f, 0x26, 0x24, 0xf3, 0x09, 0x00, 0x00, } func (m *LegacyABCIResponses) Marshal() (dAtA []byte, err error) { @@ -1007,6 +1020,14 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + n9, err9 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.NextBlockDelay, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintTypes(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0x7a if m.InitialHeight != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.InitialHeight)) i-- @@ -1082,12 +1103,12 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - n13, err13 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastBlockTime):]) - if err13 != nil { - return 0, err13 + n14, err14 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastBlockTime):]) + if err14 != nil { + return 0, err14 } - i -= n13 - i = encodeVarintTypes(dAtA, i, uint64(n13)) + i -= n14 + i = encodeVarintTypes(dAtA, i, uint64(n14)) i-- dAtA[i] = 0x2a { @@ -1314,6 +1335,8 @@ func (m *State) Size() (n int) { if m.InitialHeight != 0 { n += 1 + sovTypes(uint64(m.InitialHeight)) } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay) + n += 1 + l + sovTypes(uint64(l)) return n } @@ -2625,6 +2648,39 @@ func (m *State) Unmarshal(dAtA []byte) error { break } } + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextBlockDelay", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.NextBlockDelay, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/tendermint/state/types.proto b/proto/tendermint/state/types.proto index c76c25fa852..eb2fc3caf32 100644 --- a/proto/tendermint/state/types.proto +++ b/proto/tendermint/state/types.proto @@ -10,6 +10,8 @@ import "tendermint/types/validator.proto"; import "tendermint/types/params.proto"; import "tendermint/version/types.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; + // LegacyABCIResponses retains the responses // of the legacy ABCI calls during block processing. @@ -93,4 +95,11 @@ message State { // the latest AppHash we've received from calling abci.Commit() bytes app_hash = 13; + + // delay between the time when this block is committed and the next height is started. + // previously `timeout_commit` in config.toml + google.protobuf.Duration next_block_delay = 15 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true + ]; } diff --git a/spec/abci/abci++_methods.md b/spec/abci/abci++_methods.md index d9d6eb9ea08..c14de3e3be0 100644 --- a/spec/abci/abci++_methods.md +++ b/spec/abci/abci++_methods.md @@ -619,13 +619,14 @@ without calling `RequestVerifyVoteExtension` to verify it. * **Response**: - | Name | Type | Description | Field Number | Deterministic | - |-------------------------|---------------------------------------------------|----------------------------------------------------------------------------------|--------------|---------------| - | events | repeated [Event](abci++_basic_concepts.md#events) | Type & Key-Value events for indexing | 1 | No | - | tx_results | repeated [ExecTxResult](#exectxresult) | List of structures containing the data resulting from executing the transactions | 2 | Yes | - | validator_updates | repeated [ValidatorUpdate](#validatorupdate) | Changes to validator set (set voting power to 0 to remove). | 3 | Yes | - | consensus_param_updates | [ConsensusParams](#consensusparams) | Changes to gas, size, and other consensus-related parameters. | 4 | Yes | - | app_hash | bytes | The Merkle root hash of the application state. | 5 | Yes | + | Name | Type | Description | Field Number | Deterministic | + |-------------------------|---------------------------------------------------|-------------------------------------------------------------------------------------|--------------|---------------| + | events | repeated [Event](abci++_basic_concepts.md#events) | Type & Key-Value events for indexing | 1 | No | + | tx_results | repeated [ExecTxResult](#exectxresult) | List of structures containing the data resulting from executing the transactions | 2 | Yes | + | validator_updates | repeated [ValidatorUpdate](#validatorupdate) | Changes to validator set (set voting power to 0 to remove). | 3 | Yes | + | consensus_param_updates | [ConsensusParams](#consensusparams) | Changes to gas, size, and other consensus-related parameters. | 4 | Yes | + | app_hash | bytes | The Merkle root hash of the application state. | 5 | Yes | + | next_block_delay | [google.protobuf.Duration][protobuf-duration] | Delay between the time when this block is committed and the next height is started. | 6 | No | * **Usage**: * Contains the fields of the newly decided block. @@ -668,6 +669,18 @@ without calling `RequestVerifyVoteExtension` to verify it. already passed on to the Application via `RequestPrepareProposal` or `RequestProcessProposal`. * When calling `FinalizeBlock` with a block, the consensus algorithm run by CometBFT guarantees that at least one non-byzantine validator has run `ProcessProposal` on that block. + * `FinalizeBlockResponse.next_block_delay` - how long CometBFT waits after + committing a block, before starting on the new height (this gives the + proposer a chance to receive some more precommits, even though it + already has +2/3). Set to 0 if you want a proposer to make progress as + soon as it has all the precommits. Previously `timeout_commit` in + CometBFT config. **Set to constant 1s to preserve the old (v0.34 - v1.0) behavior**. + * `FinalizeBlockResponse.next_block_delay` is a non-deterministic field. + This means that each node MAY provide a different value, which is + supposed to depend on how long things are taking at the local node. It's + reasonable to use real --wallclock-- time and mandate for the nodes to have + synchronized clocks (NTP, or other; PBTS also requires this) for the + variable delay to work properly. #### When does CometBFT call `FinalizeBlock`? @@ -906,4 +919,5 @@ enum VerifyStatus { * If `Status` is `ACCEPT`, the consensus algorithm will accept the vote as valid. * If `Status` is `REJECT`, the consensus algorithm will reject the vote as invalid. -[protobuf-timestamp]: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp +[protobuf-timestamp]: https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp +[protobuf-duration]: https://protobuf.dev/reference/protobuf/google.protobuf/#duration diff --git a/state/execution.go b/state/execution.go index 4accf1639d6..9708f3e397d 100644 --- a/state/execution.go +++ b/state/execution.go @@ -3,6 +3,7 @@ package state import ( "bytes" "context" + "errors" "fmt" "time" @@ -280,6 +281,11 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b blockExec.metrics.ConsensusParamUpdates.Add(1) } + err = validateNextBlockDelay(abciResponse.NextBlockDelay) + if err != nil { + return state, fmt.Errorf("error in next block delay: %w", err) + } + // Update the state with the block and responses. state, err = updateState(state, blockID, &block.Header, abciResponse, validatorUpdates) if err != nil { @@ -589,6 +595,13 @@ func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, return nil } +func validateNextBlockDelay(nextBlockDelay time.Duration) error { + if nextBlockDelay < 0 { + return errors.New("negative duration") + } + return nil +} + // updateState returns a new State updated according to the header and responses. func updateState( state State, @@ -657,6 +670,7 @@ func updateState( LastHeightConsensusParamsChanged: lastHeightParamsChanged, LastResultsHash: TxResultsHash(abciResponse.TxResults), AppHash: nil, + NextBlockDelay: abciResponse.NextBlockDelay, }, nil } diff --git a/state/state.go b/state/state.go index 15fb8e5e62b..8f44cefd81e 100644 --- a/state/state.go +++ b/state/state.go @@ -77,6 +77,10 @@ type State struct { // the latest AppHash we've received from calling abci.Commit() AppHash []byte + + // delay between the time when this block is committed and the next height is started. + // previously `timeout_commit` in config.toml + NextBlockDelay time.Duration } // Copy makes a copy of the State for mutating. @@ -102,6 +106,8 @@ func (state State) Copy() State { AppHash: state.AppHash, LastResultsHash: state.LastResultsHash, + + NextBlockDelay: state.NextBlockDelay, } } @@ -170,6 +176,7 @@ func (state *State) ToProto() (*cmtstate.State, error) { sm.LastHeightConsensusParamsChanged = state.LastHeightConsensusParamsChanged sm.LastResultsHash = state.LastResultsHash sm.AppHash = state.AppHash + sm.NextBlockDelay = state.NextBlockDelay return sm, nil } @@ -221,6 +228,7 @@ func FromProto(pb *cmtstate.State) (*State, error) { //nolint:golint state.LastHeightConsensusParamsChanged = pb.LastHeightConsensusParamsChanged state.LastResultsHash = pb.LastResultsHash state.AppHash = pb.AppHash + state.NextBlockDelay = pb.NextBlockDelay return state, nil } @@ -351,5 +359,8 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { LastHeightConsensusParamsChanged: genDoc.InitialHeight, AppHash: genDoc.AppHash, + + // NextBlockDelay is set to 0 because the genesis block is committed. + NextBlockDelay: 0, }, nil } diff --git a/test/e2e/app/app.go b/test/e2e/app/app.go index 34489a892d3..d497d17a645 100644 --- a/test/e2e/app/app.go +++ b/test/e2e/app/app.go @@ -277,6 +277,7 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali }, }, }, + NextBlockDelay: 1 * time.Second, }, nil } From 385a8870a3086d7bd9f5eb11574b7db7e0620f6d Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Sat, 23 Nov 2024 12:20:10 +0530 Subject: [PATCH 2/8] add:blockTime field in the consensus block's params --- proto/tendermint/types/params.pb.go | 141 +++++++++++++++++++--------- proto/tendermint/types/params.proto | 4 + state/execution.go | 23 +++++ types/params.go | 27 ++++-- 4 files changed, 145 insertions(+), 50 deletions(-) diff --git a/proto/tendermint/types/params.pb.go b/proto/tendermint/types/params.pb.go index 3184fdd1a1c..fc13064ed09 100644 --- a/proto/tendermint/types/params.pb.go +++ b/proto/tendermint/types/params.pb.go @@ -113,6 +113,8 @@ 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"` + // block time + BlockTime time.Duration `protobuf:"bytes,4,opt,name=block_time,json=blockTime,proto3,stdduration" json:"block_time"` } func (m *BlockParams) Reset() { *m = BlockParams{} } @@ -162,6 +164,13 @@ func (m *BlockParams) GetMaxGas() int64 { return 0 } +func (m *BlockParams) GetBlockTime() time.Duration { + if m != nil { + return m.BlockTime + } + return 0 +} + // EvidenceParams determine how we handle evidence of malfeasance. type EvidenceParams struct { // Max age of evidence, in blocks. @@ -448,43 +457,45 @@ func init() { func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) } var fileDescriptor_e12598271a686f57 = []byte{ - // 576 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x3f, 0x6f, 0xd3, 0x4e, - 0x18, 0xc7, 0x73, 0x75, 0xda, 0xa6, 0x4f, 0x7e, 0x69, 0xa2, 0xd3, 0x4f, 0xc2, 0x14, 0xe2, 0x04, - 0x0f, 0xa8, 0x52, 0x25, 0x1b, 0x91, 0x09, 0x84, 0x54, 0x25, 0x25, 0x6a, 0x0b, 0x2a, 0x7f, 0x2c, - 0xc4, 0xd0, 0xc5, 0x3a, 0x27, 0x57, 0xc7, 0x6a, 0xec, 0xb3, 0x7c, 0xe7, 0x28, 0x79, 0x17, 0x8c, - 0x8c, 0x1d, 0x61, 0x65, 0xe2, 0x25, 0x74, 0xec, 0xc8, 0x04, 0x28, 0x59, 0x78, 0x19, 0xc8, 0x67, - 0xbb,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 0xf6, 0x31, - 0xd4, 0x65, 0x14, 0xf6, 0x6a, 0xd6, 0x35, 0xb9, 0x7c, 0x96, 0x07, 0xae, 0x43, 0xad, 0xe0, 0x8a, - 0xd8, 0xab, 0x39, 0x75, 0x4c, 0xb8, 0xfe, 0x16, 0xa0, 0x68, 0x2a, 0xee, 0x42, 0x73, 0xc2, 0x04, - 0xb5, 0xe9, 0x54, 0xd0, 0x20, 0xb9, 0x1d, 0xb7, 0x69, 0x40, 0x9c, 0x31, 0xb5, 0x47, 0xd4, 0x73, - 0x47, 0x22, 0x3b, 0x67, 0x2f, 0x81, 0xfa, 0xb7, 0x4c, 0x5f, 0x22, 0x27, 0x92, 0xe8, 0xbd, 0xff, - 0x32, 0xd7, 0xd0, 0xf5, 0x5c, 0x43, 0x37, 0x73, 0x0d, 0xfd, 0x9e, 0x6b, 0xe8, 0xd3, 0x42, 0x2b, - 0xdd, 0x2c, 0xb4, 0xd2, 0x8f, 0x85, 0x56, 0x3a, 0xef, 0xb8, 0x9e, 0x18, 0xc5, 0x8e, 0x31, 0x60, - 0xbe, 0x39, 0x60, 0x3e, 0x15, 0xce, 0x85, 0x28, 0x06, 0xe9, 0x9f, 0x5d, 0xfd, 0xee, 0xce, 0x96, - 0x5c, 0xef, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xe8, 0xce, 0x9a, 0x09, 0x04, 0x00, 0x00, + // 601 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcf, 0x6e, 0xd3, 0x4c, + 0x14, 0xc5, 0x33, 0x75, 0xda, 0x26, 0x37, 0x5f, 0x9a, 0x68, 0xf4, 0x49, 0x84, 0x42, 0x9d, 0xe2, + 0x05, 0xaa, 0x54, 0xc9, 0x41, 0x74, 0x05, 0x42, 0xaa, 0x9a, 0x52, 0xb5, 0x80, 0xca, 0x9f, 0xa8, + 0x62, 0xd1, 0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 0x2a, 0x3b, 0x4e, 0x04, 0x00, 0x00, } func (this *ConsensusParams) Equal(that interface{}) bool { @@ -548,6 +559,9 @@ func (this *BlockParams) Equal(that interface{}) bool { if this.MaxGas != that1.MaxGas { return false } + if this.BlockTime != that1.BlockTime { + return false + } return true } func (this *EvidenceParams) Equal(that interface{}) bool { @@ -787,6 +801,14 @@ func (m *BlockParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + n6, err6 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.BlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.BlockTime):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintParams(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0x22 if m.MaxGas != 0 { i = encodeVarintParams(dAtA, i, uint64(m.MaxGas)) i-- @@ -825,12 +847,12 @@ func (m *EvidenceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - n6, err6 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.MaxAgeDuration):]) - if err6 != nil { - return 0, err6 + n7, err7 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_cosmos_gogoproto_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-- dAtA[i] = 0x12 if m.MaxAgeNumBlocks != 0 { @@ -1106,6 +1128,8 @@ func (m *BlockParams) Size() (n int) { if m.MaxGas != 0 { n += 1 + sovParams(uint64(m.MaxGas)) } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.BlockTime) + n += 1 + l + sovParams(uint64(l)) return n } @@ -1483,6 +1507,39 @@ func (m *BlockParams) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockTime", 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 err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.BlockTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/proto/tendermint/types/params.proto b/proto/tendermint/types/params.proto index f96a2e2f572..b184cdf1eec 100644 --- a/proto/tendermint/types/params.proto +++ b/proto/tendermint/types/params.proto @@ -28,6 +28,10 @@ message BlockParams { int64 max_gas = 2; reserved 3; // was TimeIotaMs see https://github.com/tendermint/tendermint/pull/5792 + + // block time + google.protobuf.Duration block_time =4 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; } // EvidenceParams determine how we handle evidence of malfeasance. diff --git a/state/execution.go b/state/execution.go index 9708f3e397d..8dd131f80dc 100644 --- a/state/execution.go +++ b/state/execution.go @@ -233,6 +233,29 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b Txs: block.Txs.ToSliceOfBytes(), }) endTime := time.Now().UnixNano() + + // In the following code, nextBlockDelay is being set based on block time + // taken from consensus parameters and time spend since the block.Time. + consensusParams, err := blockExec.Store().LoadConsensusParams(int64(block.Height - 1)) + if err != nil { + blockExec.logger.Error("error in fetching the consensus params at height %d", int64(block.Height-1), "err", err) + return state, err + } + + blockTime := consensusParams.Block.BlockTime + nextBlockDelay := 10 * time.Millisecond + + currentTime := time.Now() + + if currentTime.After(block.Time) { + difference := blockTime - (currentTime.Sub(block.Time)) + if difference > 0 { + nextBlockDelay = difference + } + } + + abciResponse.NextBlockDelay = nextBlockDelay + blockExec.metrics.BlockProcessingTime.Observe(float64(endTime-startTime) / 1000000) if err != nil { blockExec.logger.Error("error in proxyAppConn.FinalizeBlock", "err", err) diff --git a/types/params.go b/types/params.go index 81bfa5aa2bc..2224c3af5c7 100644 --- a/types/params.go +++ b/types/params.go @@ -43,8 +43,9 @@ type ConsensusParams struct { // BlockParams define limits on the block size and gas plus minimum time // between blocks. type BlockParams struct { - MaxBytes int64 `json:"max_bytes"` - MaxGas int64 `json:"max_gas"` + MaxBytes int64 `json:"max_bytes"` + MaxGas int64 `json:"max_gas"` + BlockTime time.Duration `json:"block_time"` } // EvidenceParams determine how we handle evidence of malfeasance. @@ -96,8 +97,9 @@ func DefaultConsensusParams() *ConsensusParams { // DefaultBlockParams returns a default BlockParams. func DefaultBlockParams() BlockParams { return BlockParams{ - MaxBytes: 22020096, // 21MB - MaxGas: -1, + MaxBytes: 22020096, // 21MB + MaxGas: -1, + BlockTime: 2 * time.Second, } } @@ -151,6 +153,12 @@ func (params ConsensusParams) ValidateBasic() error { params.Block.MaxBytes) } + + if params.Block.BlockTime.Abs() <= 0 { + return fmt.Errorf("block.BlockTime must be non zero Got %d", + params.Block.BlockTime) + } + if params.Block.MaxBytes > MaxBlockSizeBytes { return fmt.Errorf("block.MaxBytes is too big. %d > %d", params.Block.MaxBytes, MaxBlockSizeBytes) @@ -302,6 +310,7 @@ func (params ConsensusParams) Update(params2 *cmtproto.ConsensusParams) Consensu if params2.Block != nil { res.Block.MaxBytes = params2.Block.MaxBytes res.Block.MaxGas = params2.Block.MaxGas + res.Block.BlockTime = params.Block.BlockTime } if params2.Evidence != nil { res.Evidence.MaxAgeNumBlocks = params2.Evidence.MaxAgeNumBlocks @@ -325,8 +334,9 @@ func (params ConsensusParams) Update(params2 *cmtproto.ConsensusParams) Consensu func (params *ConsensusParams) ToProto() cmtproto.ConsensusParams { return cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ - MaxBytes: params.Block.MaxBytes, - MaxGas: params.Block.MaxGas, + MaxBytes: params.Block.MaxBytes, + MaxGas: params.Block.MaxGas, + BlockTime: params.Block.BlockTime, }, Evidence: &cmtproto.EvidenceParams{ MaxAgeNumBlocks: params.Evidence.MaxAgeNumBlocks, @@ -348,8 +358,9 @@ func (params *ConsensusParams) ToProto() cmtproto.ConsensusParams { func ConsensusParamsFromProto(pbParams cmtproto.ConsensusParams) ConsensusParams { c := ConsensusParams{ Block: BlockParams{ - MaxBytes: pbParams.Block.MaxBytes, - MaxGas: pbParams.Block.MaxGas, + MaxBytes: pbParams.Block.MaxBytes, + MaxGas: pbParams.Block.MaxGas, + BlockTime: pbParams.Block.BlockTime, }, Evidence: EvidenceParams{ MaxAgeNumBlocks: pbParams.Evidence.MaxAgeNumBlocks, From c68a738a787c5300a7ab933409056a4f2ec51773 Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Sat, 23 Nov 2024 18:04:51 +0530 Subject: [PATCH 3/8] add: extra check for assigning nextBlockDelay --- state/execution.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/state/execution.go b/state/execution.go index 8dd131f80dc..97c0657f8ec 100644 --- a/state/execution.go +++ b/state/execution.go @@ -234,27 +234,29 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b }) endTime := time.Now().UnixNano() - // In the following code, nextBlockDelay is being set based on block time - // taken from consensus parameters and time spend since the block.Time. - consensusParams, err := blockExec.Store().LoadConsensusParams(int64(block.Height - 1)) - if err != nil { - blockExec.logger.Error("error in fetching the consensus params at height %d", int64(block.Height-1), "err", err) - return state, err - } + if block.Height != 0 { + // In the following code, nextBlockDelay is being set based on block time + // taken from consensus parameters and time spend since the block.Time. + consensusParams, err := blockExec.Store().LoadConsensusParams(int64(block.Height - 1)) + if err != nil { + blockExec.logger.Error("error in fetching the consensus params at height %d", int64(block.Height-1), "err", err) + return state, err + } - blockTime := consensusParams.Block.BlockTime - nextBlockDelay := 10 * time.Millisecond + blockTime := consensusParams.Block.BlockTime + nextBlockDelay := 10 * time.Millisecond - currentTime := time.Now() + currentTime := time.Now() - if currentTime.After(block.Time) { - difference := blockTime - (currentTime.Sub(block.Time)) - if difference > 0 { - nextBlockDelay = difference + if currentTime.After(block.Time) { + difference := blockTime - (currentTime.Sub(block.Time)) + if difference > 0 { + nextBlockDelay = difference + } } - } - abciResponse.NextBlockDelay = nextBlockDelay + abciResponse.NextBlockDelay = nextBlockDelay + } blockExec.metrics.BlockProcessingTime.Observe(float64(endTime-startTime) / 1000000) if err != nil { From 1cfd140ea54371ac60d9a5648e04f6cba31524c6 Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Sat, 23 Nov 2024 18:32:25 +0530 Subject: [PATCH 4/8] chg:refactored --- state/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state/execution.go b/state/execution.go index 97c0657f8ec..04c3465668b 100644 --- a/state/execution.go +++ b/state/execution.go @@ -234,7 +234,7 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b }) endTime := time.Now().UnixNano() - if block.Height != 0 { + if block.Height <= 1 { // In the following code, nextBlockDelay is being set based on block time // taken from consensus parameters and time spend since the block.Time. consensusParams, err := blockExec.Store().LoadConsensusParams(int64(block.Height - 1)) From 624cf84d9114c75c0fcc5b87674c218f23978acf Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Sat, 23 Nov 2024 18:41:43 +0530 Subject: [PATCH 5/8] chg:refactored --- state/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state/execution.go b/state/execution.go index 04c3465668b..d98e6a10f61 100644 --- a/state/execution.go +++ b/state/execution.go @@ -234,7 +234,7 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b }) endTime := time.Now().UnixNano() - if block.Height <= 1 { + if block.Height > 1 { // In the following code, nextBlockDelay is being set based on block time // taken from consensus parameters and time spend since the block.Time. consensusParams, err := blockExec.Store().LoadConsensusParams(int64(block.Height - 1)) From 80abfeed10c90cff429834813f1027b505117792 Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Sat, 23 Nov 2024 23:11:13 +0530 Subject: [PATCH 6/8] chg:refactored --- state/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state/execution.go b/state/execution.go index d98e6a10f61..23833f61696 100644 --- a/state/execution.go +++ b/state/execution.go @@ -246,7 +246,7 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b blockTime := consensusParams.Block.BlockTime nextBlockDelay := 10 * time.Millisecond - currentTime := time.Now() + currentTime := time.Now().UTC() if currentTime.After(block.Time) { difference := blockTime - (currentTime.Sub(block.Time)) From d81ebacdba6b6dc2b79b53381b685978341c89e9 Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Sat, 1 Feb 2025 15:37:18 +0530 Subject: [PATCH 7/8] add: implemented the feedback loop to keep the avg blocktime const --- go.sum | 2 +- proto/tendermint/state/types.pb.go | 195 ++++++++++++------- proto/tendermint/state/types.proto | 3 + state/execution.go | 25 +-- state/state.go | 7 + state/util.go | 60 ++++++ state/util_test.go | 302 +++++++++++++++++++++++++++++ 7 files changed, 500 insertions(+), 94 deletions(-) create mode 100644 state/util.go create mode 100644 state/util_test.go diff --git a/go.sum b/go.sum index 6bcc6b443e1..41160e4cb2a 100644 --- a/go.sum +++ b/go.sum @@ -629,7 +629,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/moricho/tparallel v0.3.0 h1:8dDx3S3e+jA+xiQXC7O3dvfRTe/J+FYlTDDW01Y7z/Q= +github.com/moricho/tparallel v0.3.0 h1:EthKzLoZA6C11YB1vMPWLYmF2nnPCUX712TjDgsP31A= github.com/moricho/tparallel v0.3.0/go.mod h1:leENX2cUv7Sv2qDgdi0D0fCftN8fRC67Bcn8pqzeYNI= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index ca648c5614d..4378e0dd486 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -449,6 +449,7 @@ type State struct { // delay between the time when this block is committed and the next height is started. // previously `timeout_commit` in config.toml NextBlockDelay time.Duration `protobuf:"bytes,15,opt,name=next_block_delay,json=nextBlockDelay,proto3,stdduration" json:"next_block_delay"` + GenesisTime time.Time `protobuf:"bytes,16,opt,name=genesis_time,json=genesisTime,proto3,stdtime" json:"genesis_time"` } func (m *State) Reset() { *m = State{} } @@ -589,6 +590,13 @@ func (m *State) GetNextBlockDelay() time.Duration { return 0 } +func (m *State) GetGenesisTime() time.Time { + if m != nil { + return m.GenesisTime + } + return time.Time{} +} + func init() { proto.RegisterType((*LegacyABCIResponses)(nil), "tendermint.state.LegacyABCIResponses") proto.RegisterType((*ResponseBeginBlock)(nil), "tendermint.state.ResponseBeginBlock") @@ -603,70 +611,72 @@ func init() { func init() { proto.RegisterFile("tendermint/state/types.proto", fileDescriptor_ccfacf933f22bf93) } var fileDescriptor_ccfacf933f22bf93 = []byte{ - // 1007 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 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ad, 0xdb, 0x74, 0xb9, 0xa1, 0x8e, 0xf4, 0x4f, 0x86, 0xea, - 0xa7, 0x5f, 0x44, 0x3f, 0xc9, 0x3e, 0x90, 0xfd, 0x74, 0x24, 0x42, 0xbb, 0x2f, 0xde, 0x2e, 0x1a, - 0xc6, 0xbb, 0x45, 0xc3, 0xf8, 0x6b, 0xd1, 0x30, 0xde, 0x5c, 0x35, 0x56, 0xde, 0x5d, 0x35, 0x56, - 0x7e, 0xbf, 0x6a, 0xac, 0x7c, 0xf7, 0x6c, 0x44, 0xf9, 0x78, 0x3a, 0xb0, 0xdc, 0x70, 0xd2, 0x71, - 0xc3, 0x09, 0xe1, 0x83, 0x21, 0xcf, 0x3e, 0xd4, 0xef, 0xd9, 0xf2, 0x8f, 0xdd, 0x60, 0x4d, 0xee, - 0x3f, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6f, 0x26, 0x24, 0xf3, 0x09, 0x00, 0x00, + // 1026 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4d, 0x6f, 0xdb, 0x46, + 0x13, 0x36, 0xe3, 0xc4, 0x92, 0x47, 0xfe, 0x90, 0xd7, 0xaf, 0x13, 0xc6, 0x79, 0x23, 0xa9, 0x42, + 0x12, 0x18, 0x45, 0x41, 0x01, 0xc9, 0xa9, 0x97, 0x14, 0x96, 0xec, 0xc6, 0x02, 0x9c, 0xa2, 0xa0, + 0xdd, 0x00, 0xe9, 0x21, 0xc4, 0x8a, 0x5c, 0x53, 0x8b, 0x52, 0x24, 0xc1, 0x5d, 0xa9, 0x76, 0xef, + 0xbd, 0xf5, 0x90, 0x63, 0xfb, 0x8f, 0x72, 0xcc, 0xb1, 0x97, 0xba, 0x85, 0x0c, 0xf4, 0xd0, 0x7f, + 0xd0, 0x5b, 0xb1, 0x1f, 0xfc, 0x12, 0x5d, 0xd4, 0x41, 0x6e, 0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 0xfd, 0xe7, 0x2d, 0xfe, 0x21, 0x8e, + 0x56, 0xe4, 0xfe, 0xb3, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xb1, 0xe6, 0x96, 0x3c, 0x0a, + 0x00, 0x00, } func (m *LegacyABCIResponses) Marshal() (dAtA []byte, err error) { @@ -1020,13 +1030,23 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n9, err9 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.NextBlockDelay, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay):]) + n9, err9 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.GenesisTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.GenesisTime):]) if err9 != nil { return 0, err9 } i -= n9 i = encodeVarintTypes(dAtA, i, uint64(n9)) i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + n10, err10 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.NextBlockDelay, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay):]) + if err10 != nil { + return 0, err10 + } + i -= n10 + i = encodeVarintTypes(dAtA, i, uint64(n10)) + i-- dAtA[i] = 0x7a if m.InitialHeight != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.InitialHeight)) @@ -1103,12 +1123,12 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - n14, err14 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastBlockTime):]) - if err14 != nil { - return 0, err14 + n15, err15 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastBlockTime):]) + if err15 != nil { + return 0, err15 } - i -= n14 - i = encodeVarintTypes(dAtA, i, uint64(n14)) + i -= n15 + i = encodeVarintTypes(dAtA, i, uint64(n15)) i-- dAtA[i] = 0x2a { @@ -1337,6 +1357,8 @@ func (m *State) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.NextBlockDelay) n += 1 + l + sovTypes(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.GenesisTime) + n += 2 + l + sovTypes(uint64(l)) return n } @@ -2681,6 +2703,39 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GenesisTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.GenesisTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/tendermint/state/types.proto b/proto/tendermint/state/types.proto index eb2fc3caf32..0a7849e5ecc 100644 --- a/proto/tendermint/state/types.proto +++ b/proto/tendermint/state/types.proto @@ -102,4 +102,7 @@ message State { (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + + google.protobuf.Timestamp genesis_time = 16 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } diff --git a/state/execution.go b/state/execution.go index 23833f61696..cbdb85e01e7 100644 --- a/state/execution.go +++ b/state/execution.go @@ -234,29 +234,7 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b }) endTime := time.Now().UnixNano() - if block.Height > 1 { - // In the following code, nextBlockDelay is being set based on block time - // taken from consensus parameters and time spend since the block.Time. - consensusParams, err := blockExec.Store().LoadConsensusParams(int64(block.Height - 1)) - if err != nil { - blockExec.logger.Error("error in fetching the consensus params at height %d", int64(block.Height-1), "err", err) - return state, err - } - - blockTime := consensusParams.Block.BlockTime - nextBlockDelay := 10 * time.Millisecond - - currentTime := time.Now().UTC() - - if currentTime.After(block.Time) { - difference := blockTime - (currentTime.Sub(block.Time)) - if difference > 0 { - nextBlockDelay = difference - } - } - - abciResponse.NextBlockDelay = nextBlockDelay - } + abciResponse.NextBlockDelay = CalculateDelay(blockExec.store, block) blockExec.metrics.BlockProcessingTime.Observe(float64(endTime-startTime) / 1000000) if err != nil { @@ -696,6 +674,7 @@ func updateState( LastResultsHash: TxResultsHash(abciResponse.TxResults), AppHash: nil, NextBlockDelay: abciResponse.NextBlockDelay, + GenesisTime: state.GenesisTime, }, nil } diff --git a/state/state.go b/state/state.go index 8f44cefd81e..d8605d7ed33 100644 --- a/state/state.go +++ b/state/state.go @@ -81,6 +81,9 @@ type State struct { // delay between the time when this block is committed and the next height is started. // previously `timeout_commit` in config.toml NextBlockDelay time.Duration + + // genesis time + GenesisTime time.Time } // Copy makes a copy of the State for mutating. @@ -108,6 +111,7 @@ func (state State) Copy() State { LastResultsHash: state.LastResultsHash, NextBlockDelay: state.NextBlockDelay, + GenesisTime: state.GenesisTime, } } @@ -177,6 +181,7 @@ func (state *State) ToProto() (*cmtstate.State, error) { sm.LastResultsHash = state.LastResultsHash sm.AppHash = state.AppHash sm.NextBlockDelay = state.NextBlockDelay + sm.GenesisTime = state.GenesisTime return sm, nil } @@ -229,6 +234,7 @@ func FromProto(pb *cmtstate.State) (*State, error) { //nolint:golint state.LastResultsHash = pb.LastResultsHash state.AppHash = pb.AppHash state.NextBlockDelay = pb.NextBlockDelay + state.GenesisTime = pb.GenesisTime return state, nil } @@ -362,5 +368,6 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { // NextBlockDelay is set to 0 because the genesis block is committed. NextBlockDelay: 0, + GenesisTime: genDoc.GenesisTime, }, nil } diff --git a/state/util.go b/state/util.go new file mode 100644 index 00000000000..0406cdb7c84 --- /dev/null +++ b/state/util.go @@ -0,0 +1,60 @@ +package state + +import ( + "time" + + "github.com/cometbft/cometbft/types" +) + +// This file contains utility functions for the state package. + +func CalculateDelay(store Store, currentBlock *types.Block) time.Duration { + // load the state from the store + state, err := store.Load() + if err != nil { + return 0 + } + + // load the consensus params from the store for the one block less than current block + consensusParams, err := store.LoadConsensusParams(currentBlock.Height - 1) + if err != nil { + return 0 + } + + // get the block time + blockTime := consensusParams.Block.BlockTime + + // ideal next block delay (assuming 10% of block time lost in execution and network delays) + idealNextBlockDelay := blockTime - blockTime/10 + + // get the genesis time, it is a time for the block=1 + genesisTime := state.GenesisTime + if genesisTime.IsZero() { + return 0 + } + + // get the duration from the genesis time to the current block time + gotDuration := currentBlock.Time.Sub(genesisTime) + + // calculate the expected duration + expected := blockTime.Nanoseconds() * (int64(currentBlock.Height) - int64(1)) + expectedDuration := time.Duration(expected) + + // calculate the difference between the expected duration and the got duration + diff := gotDuration - expectedDuration + + // calculate the threshold for the difference + threshold := idealNextBlockDelay / 5 + + // check if the absolute value of the difference is more than 20% of the ideal block delay + if diff.Abs() > idealNextBlockDelay/5 { + if diff > 0 { + return idealNextBlockDelay - threshold + } else { + return idealNextBlockDelay + threshold + } + } + + // return the ideal block delay adjusted by the difference + return idealNextBlockDelay - diff +} diff --git a/state/util_test.go b/state/util_test.go new file mode 100644 index 00000000000..daab6fba79d --- /dev/null +++ b/state/util_test.go @@ -0,0 +1,302 @@ +package state_test + +import ( + "errors" + "testing" + "time" + + "github.com/cometbft/cometbft/state" + "github.com/cometbft/cometbft/state/mocks" + "github.com/cometbft/cometbft/types" + "github.com/stretchr/testify/assert" +) + +func TestStateError(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + // empty state + mockState := state.State{} + + consensusParams := types.ConsensusParams{ + Block: types.BlockParams{ + BlockTime: blockTime, + }, + } + + height := int64(10) + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * blockTime), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, errors.New("error")) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, nil) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // when there is any error we expect the 0 because it is handled itseld later on + expectedDelay := time.Duration(0) + + assert.Equal(t, expectedDelay, delay) +} + +func TestConsensusParamError(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + mockState := state.State{ + GenesisTime: genesisTime, + } + + // empty consensus params + consensusParams := types.ConsensusParams{} + + height := int64(10) + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * blockTime), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, nil) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, errors.New("error")) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // when there is any error we expect the 0 because it is handled itseld later on + expectedDelay := time.Duration(0) + + assert.Equal(t, expectedDelay, delay) +} + +func TestCalculateDelayWhenDiffIsZero(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + mockState := state.State{ + GenesisTime: genesisTime, + } + + consensusParams := types.ConsensusParams{ + Block: types.BlockParams{ + BlockTime: blockTime, + }, + } + + height := int64(10) + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * time.Second), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, nil) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, nil) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // ideal next block delay (assuming 10% of block time lost in execution and network delays) + idealExpectedDelay := blockTime - blockTime/10 + + assert.Equal(t, idealExpectedDelay, delay) +} + +func TestCalculateDelayWhenDiffIsMorePositiveThanMaxDeflection(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + mockState := state.State{ + GenesisTime: genesisTime, + } + + consensusParams := types.ConsensusParams{ + Block: types.BlockParams{ + BlockTime: blockTime, + }, + } + + // ideal next block delay (assuming 10% of block time lost in execution and network delays) + idealExpectedDelay := blockTime - blockTime/10 + + // maxdepliction is 20% of idealExpectedDelay + maxDeflection := idealExpectedDelay / 5 + + height := int64(10) + addedDiff := maxDeflection + maxDeflection/2 + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * time.Second).Add(addedDiff), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, nil) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, nil) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // as addedDiff is more than the maxDeflection we expect the idealExpectedDelay - maxDeflection + expectedDelay := idealExpectedDelay - maxDeflection + + assert.Equal(t, expectedDelay, delay) +} + +func TestCalculateDelayWhenDiffIsLessPositiveThanMaxDeflection(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + mockState := state.State{ + GenesisTime: genesisTime, + } + + consensusParams := types.ConsensusParams{ + Block: types.BlockParams{ + BlockTime: blockTime, + }, + } + + // ideal next block delay (assuming 10% of block time lost in execution and network delays) + idealExpectedDelay := blockTime - blockTime/10 + + // maxdepliction is 20% of idealExpectedDelay + maxDeflection := idealExpectedDelay / 5 + + height := int64(10) + addedDiff := maxDeflection - maxDeflection/2 + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * time.Second).Add(addedDiff), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, nil) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, nil) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // as addedDiff is less than the maxDeflection we expect the idealExpectedDelay - addedDiff + expectedDelay := idealExpectedDelay - addedDiff + + assert.Equal(t, expectedDelay, delay) +} + +func TestCalculateDelayWhenDiffIsMoreNegativeThanMaxDeflection(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + mockState := state.State{ + GenesisTime: genesisTime, + } + + consensusParams := types.ConsensusParams{ + Block: types.BlockParams{ + BlockTime: blockTime, + }, + } + + // ideal next block delay (assuming 10% of block time lost in execution and network delays) + idealExpectedDelay := blockTime - blockTime/10 + + // maxdepliction is 20% of idealExpectedDelay + maxDeflection := idealExpectedDelay / 5 + + height := int64(10) + addedDiff := -1 * (maxDeflection + maxDeflection/2) + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * time.Second).Add(addedDiff), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, nil) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, nil) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // as addedDiff is more than the maxDeflection we expect the idealExpectedDelay - maxDeflection + expectedDelay := idealExpectedDelay + maxDeflection + + assert.Equal(t, expectedDelay, delay) +} + +func TestCalculateDelayWhenDiffIsLessNegativeThanMaxDeflection(t *testing.T) { + blockStore := &mocks.Store{} + + genesisTime := time.Now() + blockTime := 1 * time.Second + + mockState := state.State{ + GenesisTime: genesisTime, + } + + consensusParams := types.ConsensusParams{ + Block: types.BlockParams{ + BlockTime: blockTime, + }, + } + + // ideal next block delay (assuming 10% of block time lost in execution and network delays) + idealExpectedDelay := blockTime - blockTime/10 + + // maxdepliction is 20% of idealExpectedDelay + maxDeflection := idealExpectedDelay / 5 + + height := int64(10) + addedDiff := -1 * (maxDeflection - maxDeflection/2) + + header := types.Header{ + Height: height, + Time: genesisTime.Add(9 * time.Second).Add(addedDiff), + } + + currentBlock := &types.Block{ + Header: header, + } + + blockStore.On("Load").Return(mockState, nil) + blockStore.On("LoadConsensusParams", (height-1)).Return(consensusParams, nil) + + delay := state.CalculateDelay(blockStore, currentBlock) + + // as addedDiff is less than the maxDeflection we expect the idealExpectedDelay - addedDiff + expectedDelay := idealExpectedDelay - addedDiff + + assert.Equal(t, expectedDelay, delay) +} From 18f3dc68a9feb744a32e6cc1beae308118ec93fc Mon Sep 17 00:00:00 2001 From: Vaibhav Jindal Date: Wed, 12 Feb 2025 14:49:05 +0530 Subject: [PATCH 8/8] Refactored test cases --- docs/core/using-cometbft.md | 1 + internal/test/config.go | 1 + rpc/openapi/openapi.yaml | 1 + spec/rpc/README.md | 3 +++ state/util.go | 21 +++++++++++++++------ state/util_test.go | 18 +++++++++--------- types/params_test.go | 5 +++-- 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/docs/core/using-cometbft.md b/docs/core/using-cometbft.md index cafa8d34319..7fec9a053e3 100644 --- a/docs/core/using-cometbft.md +++ b/docs/core/using-cometbft.md @@ -93,6 +93,7 @@ definition](https://github.com/cometbft/cometbft/blob/v0.38.x/types/genesis.go)) "consensus_params": { "block": { "max_bytes": "22020096", + "block_time": "2000000000", "max_gas": "-1", }, "evidence": { diff --git a/internal/test/config.go b/internal/test/config.go index 2685584e178..612af098307 100644 --- a/internal/test/config.go +++ b/internal/test/config.go @@ -50,6 +50,7 @@ var testGenesisFmt = `{ "block": { "max_bytes": "22020096", "max_gas": "-1", + "block_time": "2000000000", "time_iota_ms": "10" }, "evidence": { diff --git a/rpc/openapi/openapi.yaml b/rpc/openapi/openapi.yaml index 568ff1a8471..990458019a8 100644 --- a/rpc/openapi/openapi.yaml +++ b/rpc/openapi/openapi.yaml @@ -2765,6 +2765,7 @@ components: required: - "max_bytes" - "max_gas" + - "block_time" - "time_iota_ms" properties: max_bytes: diff --git a/spec/rpc/README.md b/spec/rpc/README.md index ff9ce2ce9e4..11e0f319e69 100644 --- a/spec/rpc/README.md +++ b/spec/rpc/README.md @@ -594,6 +594,7 @@ curl -X POST https://localhost:26657 -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\ "block": { "max_bytes": "22020096", "max_gas": "1000", + "block_time": "2000000000", "time_iota_ms": "1000" }, "evidence": { @@ -771,6 +772,7 @@ curl -X POST https://localhost:26657 -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\ "block": { "max_bytes": "22020096", "max_gas": "1000", + "block_time": "2000000000", "time_iota_ms": "1000" }, "evidence": { @@ -871,6 +873,7 @@ curl -X POST https://localhost:26657 -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\ "block": { "max_bytes": "22020096", "max_gas": "1000", + "block_time": "2000000000", "time_iota_ms": "1000" }, "evidence": { diff --git a/state/util.go b/state/util.go index 0406cdb7c84..12e567fac39 100644 --- a/state/util.go +++ b/state/util.go @@ -7,6 +7,14 @@ import ( ) // This file contains utility functions for the state package. +const ( + // msgProcDelayRatio is the ratio of block time to message processing delay + // assuming block time lost in execution and network delays + MsgProcDelayRatio = 10 + + // deflectionRation is the ratio of the ideal block time to the threshold for the difference + DeflectionRatio = 5 +) func CalculateDelay(store Store, currentBlock *types.Block) time.Duration { // load the state from the store @@ -24,8 +32,9 @@ func CalculateDelay(store Store, currentBlock *types.Block) time.Duration { // get the block time blockTime := consensusParams.Block.BlockTime - // ideal next block delay (assuming 10% of block time lost in execution and network delays) - idealNextBlockDelay := blockTime - blockTime/10 + msgProcDelay := blockTime / MsgProcDelayRatio + + idealNextBlockDelay := blockTime - msgProcDelay // get the genesis time, it is a time for the block=1 genesisTime := state.GenesisTime @@ -43,11 +52,11 @@ func CalculateDelay(store Store, currentBlock *types.Block) time.Duration { // calculate the difference between the expected duration and the got duration diff := gotDuration - expectedDuration - // calculate the threshold for the difference - threshold := idealNextBlockDelay / 5 + // calculate the threshold for the difference using deflection ratio + threshold := idealNextBlockDelay / DeflectionRatio - // check if the absolute value of the difference is more than 20% of the ideal block delay - if diff.Abs() > idealNextBlockDelay/5 { + // check if the absolute value of the difference is more than the threshold + if diff.Abs() > threshold { if diff > 0 { return idealNextBlockDelay - threshold } else { diff --git a/state/util_test.go b/state/util_test.go index daab6fba79d..b298ad1311c 100644 --- a/state/util_test.go +++ b/state/util_test.go @@ -116,7 +116,7 @@ func TestCalculateDelayWhenDiffIsZero(t *testing.T) { delay := state.CalculateDelay(blockStore, currentBlock) // ideal next block delay (assuming 10% of block time lost in execution and network delays) - idealExpectedDelay := blockTime - blockTime/10 + idealExpectedDelay := blockTime - blockTime/state.MsgProcDelayRatio assert.Equal(t, idealExpectedDelay, delay) } @@ -138,10 +138,10 @@ func TestCalculateDelayWhenDiffIsMorePositiveThanMaxDeflection(t *testing.T) { } // ideal next block delay (assuming 10% of block time lost in execution and network delays) - idealExpectedDelay := blockTime - blockTime/10 + idealExpectedDelay := blockTime - blockTime/state.MsgProcDelayRatio // maxdepliction is 20% of idealExpectedDelay - maxDeflection := idealExpectedDelay / 5 + maxDeflection := idealExpectedDelay / state.DeflectionRatio height := int64(10) addedDiff := maxDeflection + maxDeflection/2 @@ -183,10 +183,10 @@ func TestCalculateDelayWhenDiffIsLessPositiveThanMaxDeflection(t *testing.T) { } // ideal next block delay (assuming 10% of block time lost in execution and network delays) - idealExpectedDelay := blockTime - blockTime/10 + idealExpectedDelay := blockTime - blockTime/state.MsgProcDelayRatio // maxdepliction is 20% of idealExpectedDelay - maxDeflection := idealExpectedDelay / 5 + maxDeflection := idealExpectedDelay / state.DeflectionRatio height := int64(10) addedDiff := maxDeflection - maxDeflection/2 @@ -228,10 +228,10 @@ func TestCalculateDelayWhenDiffIsMoreNegativeThanMaxDeflection(t *testing.T) { } // ideal next block delay (assuming 10% of block time lost in execution and network delays) - idealExpectedDelay := blockTime - blockTime/10 + idealExpectedDelay := blockTime - blockTime/state.MsgProcDelayRatio // maxdepliction is 20% of idealExpectedDelay - maxDeflection := idealExpectedDelay / 5 + maxDeflection := idealExpectedDelay / state.DeflectionRatio height := int64(10) addedDiff := -1 * (maxDeflection + maxDeflection/2) @@ -273,10 +273,10 @@ func TestCalculateDelayWhenDiffIsLessNegativeThanMaxDeflection(t *testing.T) { } // ideal next block delay (assuming 10% of block time lost in execution and network delays) - idealExpectedDelay := blockTime - blockTime/10 + idealExpectedDelay := blockTime - blockTime/state.MsgProcDelayRatio // maxdepliction is 20% of idealExpectedDelay - maxDeflection := idealExpectedDelay / 5 + maxDeflection := idealExpectedDelay / state.DeflectionRatio height := int64(10) addedDiff := -1 * (maxDeflection - maxDeflection/2) diff --git a/types/params_test.go b/types/params_test.go index f3e758237c9..ced3b6e7b28 100644 --- a/types/params_test.go +++ b/types/params_test.go @@ -60,8 +60,9 @@ func makeParams( ) ConsensusParams { return ConsensusParams{ Block: BlockParams{ - MaxBytes: blockBytes, - MaxGas: blockGas, + MaxBytes: blockBytes, + MaxGas: blockGas, + BlockTime: 1, }, Evidence: EvidenceParams{ MaxAgeNumBlocks: evidenceAge,