From 6e06a7d8b18b4fa896e66c0f84d80f8ff5380158 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Wed, 4 Sep 2024 14:44:59 +1000 Subject: [PATCH] use singleton boolean as feature gate --- client/docs/swagger-ui/swagger.yaml | 6 -- proto/babylon/zoneconcierge/v1/params.proto | 3 - x/zoneconcierge/keeper/header_handler.go | 2 +- x/zoneconcierge/keeper/hooks.go | 6 +- x/zoneconcierge/module_ibc.go | 8 +-- x/zoneconcierge/types/params.go | 4 ++ x/zoneconcierge/types/params.pb.go | 71 ++++----------------- 7 files changed, 24 insertions(+), 76 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index b4b908978..a59dd6156 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -8403,8 +8403,6 @@ paths: an unrelayed IBC packet becomes timeout, measured in seconds - enable_integration: - type: boolean description: >- QueryParamsResponse is the response type for the Query/Params RPC method. @@ -12192,8 +12190,6 @@ definitions: unrelayed IBC packet becomes timeout, measured in seconds - enable_integration: - type: boolean description: Params defines the parameters for the module. babylon.zoneconcierge.v1.ProofEpochSealed: type: object @@ -14195,8 +14191,6 @@ definitions: unrelayed IBC packet becomes timeout, measured in seconds - enable_integration: - type: boolean description: QueryParamsResponse is the response type for the Query/Params RPC method. tendermint.crypto.ProofOp: type: object diff --git a/proto/babylon/zoneconcierge/v1/params.proto b/proto/babylon/zoneconcierge/v1/params.proto index 208d02fce..48fa6c9e5 100644 --- a/proto/babylon/zoneconcierge/v1/params.proto +++ b/proto/babylon/zoneconcierge/v1/params.proto @@ -13,7 +13,4 @@ message Params { // IBC packet becomes timeout, measured in seconds uint32 ibc_packet_timeout_seconds = 1 [ (gogoproto.moretags) = "yaml:\"ibc_packet_timeout_seconds\"" ]; - - bool enable_integration = 2 - [ (gogoproto.moretags) = "yaml:\"enable_integration\"" ]; } diff --git a/x/zoneconcierge/keeper/header_handler.go b/x/zoneconcierge/keeper/header_handler.go index 45cac6975..957265bf1 100644 --- a/x/zoneconcierge/keeper/header_handler.go +++ b/x/zoneconcierge/keeper/header_handler.go @@ -12,7 +12,7 @@ import ( // HandleHeaderWithValidCommit handles a CZ header with a valid QC func (k Keeper) HandleHeaderWithValidCommit(ctx context.Context, txHash []byte, header *types.HeaderInfo, isOnFork bool) { // if integration is not enabled, do not process headers - if !k.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return } diff --git a/x/zoneconcierge/keeper/hooks.go b/x/zoneconcierge/keeper/hooks.go index 980fe2925..fdec241eb 100644 --- a/x/zoneconcierge/keeper/hooks.go +++ b/x/zoneconcierge/keeper/hooks.go @@ -23,7 +23,7 @@ func (k Keeper) Hooks() Hooks { return Hooks{k} } func (h Hooks) AfterEpochEnds(ctx context.Context, epoch uint64) { // if integration is not enabled, do not trigger hooks // NOTE: might not be needed, since the post handler is disabled - if !h.k.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return } @@ -37,7 +37,7 @@ func (h Hooks) AfterEpochEnds(ctx context.Context, epoch uint64) { func (h Hooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { // if integration is not enabled, do not trigger hooks // NOTE: might not be needed, since the proofs do not depend on consumer chains - if !h.k.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return nil } @@ -51,7 +51,7 @@ func (h Hooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error // AfterRawCheckpointFinalized is triggered upon an epoch has been finalised func (h Hooks) AfterRawCheckpointFinalized(ctx context.Context, epoch uint64) error { // if integration is not enabled, do not trigger hooks - if !h.k.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return nil } diff --git a/x/zoneconcierge/module_ibc.go b/x/zoneconcierge/module_ibc.go index a5647619d..d0ac0314f 100644 --- a/x/zoneconcierge/module_ibc.go +++ b/x/zoneconcierge/module_ibc.go @@ -34,7 +34,7 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) (string, error) { - if !im.keeper.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return "", types.ErrIntegrationDisabled } @@ -73,7 +73,7 @@ func (im IBCModule) OnChanOpenTry( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { - if !im.keeper.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return "", types.ErrIntegrationDisabled } @@ -115,7 +115,7 @@ func (im IBCModule) OnChanOpenAck( _, counterpartyVersion string, ) error { - if !im.keeper.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return types.ErrIntegrationDisabled } @@ -133,7 +133,7 @@ func (im IBCModule) OnChanOpenConfirm( portID, channelID string, ) error { - if !im.keeper.GetParams(ctx).EnableIntegration { + if !types.EnableIntegration { return types.ErrIntegrationDisabled } diff --git a/x/zoneconcierge/types/params.go b/x/zoneconcierge/types/params.go index 298ade2a7..05ad56a2d 100644 --- a/x/zoneconcierge/types/params.go +++ b/x/zoneconcierge/types/params.go @@ -4,6 +4,10 @@ import ( "fmt" ) +var ( + EnableIntegration = false +) + const ( DefaultIbcPacketTimeoutSeconds uint32 = 60 * 60 * 24 // 24 hours MaxIbcPacketTimeoutSeconds uint32 = 60 * 60 * 24 * 365 // 1 year diff --git a/x/zoneconcierge/types/params.pb.go b/x/zoneconcierge/types/params.pb.go index 3d3e02f52..732cfcecd 100644 --- a/x/zoneconcierge/types/params.pb.go +++ b/x/zoneconcierge/types/params.pb.go @@ -28,7 +28,6 @@ type Params struct { // ibc_packet_timeout_seconds is the time period after which an unrelayed // IBC packet becomes timeout, measured in seconds IbcPacketTimeoutSeconds uint32 `protobuf:"varint,1,opt,name=ibc_packet_timeout_seconds,json=ibcPacketTimeoutSeconds,proto3" json:"ibc_packet_timeout_seconds,omitempty" yaml:"ibc_packet_timeout_seconds"` - EnableIntegration bool `protobuf:"varint,2,opt,name=enable_integration,json=enableIntegration,proto3" json:"enable_integration,omitempty" yaml:"enable_integration"` } func (m *Params) Reset() { *m = Params{} } @@ -71,13 +70,6 @@ func (m *Params) GetIbcPacketTimeoutSeconds() uint32 { return 0 } -func (m *Params) GetEnableIntegration() bool { - if m != nil { - return m.EnableIntegration - } - return false -} - func init() { proto.RegisterType((*Params)(nil), "babylon.zoneconcierge.v1.Params") } @@ -87,25 +79,22 @@ func init() { } var fileDescriptor_c0696c936eb15fe4 = []byte{ - // 276 bytes of a gzipped FileDescriptorProto + // 229 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xaf, 0xca, 0xcf, 0x4b, 0x4d, 0xce, 0xcf, 0x4b, 0xce, 0x4c, 0x2d, 0x4a, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, 0x2a, 0xd3, 0x43, 0x51, 0xa6, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, - 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x2b, 0x1d, 0x60, 0xe4, 0x62, 0x0b, 0x00, 0x1b, - 0x20, 0x94, 0xc4, 0x25, 0x95, 0x99, 0x94, 0x1c, 0x5f, 0x90, 0x98, 0x9c, 0x9d, 0x5a, 0x12, 0x5f, - 0x92, 0x99, 0x9b, 0x9a, 0x5f, 0x5a, 0x12, 0x5f, 0x0c, 0x32, 0x25, 0xa5, 0x58, 0x82, 0x51, 0x81, - 0x51, 0x83, 0xd7, 0x49, 0xf5, 0xd3, 0x3d, 0x79, 0xc5, 0xca, 0xc4, 0xdc, 0x1c, 0x2b, 0x25, 0xdc, - 0x6a, 0x95, 0x82, 0xc4, 0x33, 0x93, 0x92, 0x03, 0xc0, 0x72, 0x21, 0x10, 0xa9, 0x60, 0x88, 0x8c, - 0x90, 0x0f, 0x97, 0x50, 0x6a, 0x5e, 0x62, 0x52, 0x4e, 0x6a, 0x7c, 0x66, 0x5e, 0x49, 0x6a, 0x7a, - 0x51, 0x62, 0x49, 0x66, 0x7e, 0x9e, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x87, 0x93, 0xec, 0xa7, 0x7b, - 0xf2, 0x92, 0x10, 0xb3, 0x31, 0xd5, 0x28, 0x05, 0x09, 0x42, 0x04, 0x3d, 0x11, 0x62, 0x56, 0x2c, - 0x2f, 0x16, 0xc8, 0x33, 0x3a, 0x05, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, - 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, - 0x94, 0x79, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x34, 0x5c, 0x72, - 0x12, 0x93, 0x8a, 0x75, 0x33, 0xf3, 0x61, 0x5c, 0xfd, 0x0a, 0xb4, 0xf0, 0x2c, 0xa9, 0x2c, 0x48, - 0x2d, 0x4e, 0x62, 0x03, 0x07, 0x8e, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xc6, 0x42, 0x0f, 0x0b, - 0x75, 0x01, 0x00, 0x00, + 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x2b, 0x15, 0x71, 0xb1, 0x05, 0x80, 0xf5, 0x0b, + 0x25, 0x71, 0x49, 0x65, 0x26, 0x25, 0xc7, 0x17, 0x24, 0x26, 0x67, 0xa7, 0x96, 0xc4, 0x97, 0x64, + 0xe6, 0xa6, 0xe6, 0x97, 0x96, 0xc4, 0x17, 0x83, 0x0c, 0x49, 0x29, 0x96, 0x60, 0x54, 0x60, 0xd4, + 0xe0, 0x75, 0x52, 0xfd, 0x74, 0x4f, 0x5e, 0xb1, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0xb7, 0x5a, + 0xa5, 0x20, 0xf1, 0xcc, 0xa4, 0xe4, 0x00, 0xb0, 0x5c, 0x08, 0x44, 0x2a, 0x18, 0x22, 0x63, 0xc5, + 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x53, 0xe0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, + 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, + 0x44, 0x99, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0x92, + 0x93, 0x98, 0x54, 0xac, 0x9b, 0x99, 0x0f, 0xe3, 0xea, 0x57, 0xa0, 0x05, 0x40, 0x49, 0x65, 0x41, + 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x37, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x2b, 0x77, + 0x59, 0x26, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -130,9 +119,6 @@ func (this *Params) Equal(that interface{}) bool { if this.IbcPacketTimeoutSeconds != that1.IbcPacketTimeoutSeconds { return false } - if this.EnableIntegration != that1.EnableIntegration { - return false - } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -155,16 +141,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.EnableIntegration { - i-- - if m.EnableIntegration { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } if m.IbcPacketTimeoutSeconds != 0 { i = encodeVarintParams(dAtA, i, uint64(m.IbcPacketTimeoutSeconds)) i-- @@ -193,9 +169,6 @@ func (m *Params) Size() (n int) { if m.IbcPacketTimeoutSeconds != 0 { n += 1 + sovParams(uint64(m.IbcPacketTimeoutSeconds)) } - if m.EnableIntegration { - n += 2 - } return n } @@ -253,26 +226,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableIntegration", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.EnableIntegration = bool(v != 0) default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])