diff --git a/.circleci/config.yml b/.circleci/config.yml index 35cf66ca0..f2b451306 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -127,3 +127,4 @@ workflows: branches: only: - main + - dev diff --git a/app/app.go b/app/app.go index ddef2f6c4..c878a001f 100644 --- a/app/app.go +++ b/app/app.go @@ -122,6 +122,9 @@ import ( govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" extendedkeeper "github.com/babylonchain/babylon/x/zoneconcierge/extended-client-keeper" + ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" + ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" + ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" "github.com/cosmos/ibc-go/v7/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -204,6 +207,7 @@ var ( ibctm.AppModuleBasic{}, transfer.AppModuleBasic{}, zoneconcierge.AppModuleBasic{}, + ibcfee.AppModuleBasic{}, ) // module account permissions @@ -215,6 +219,7 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcfeetypes.ModuleName: nil, // TODO: decide ZonConcierge's permissions here zctypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } @@ -309,6 +314,7 @@ type BabylonApp struct { // IBC-related modules IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCFeeKeeper ibcfeekeeper.Keeper // for relayer incentivization - https://github.com/cosmos/ibc/tree/main/spec/app/ics-029-fee-payment TransferKeeper ibctransferkeeper.Keeper // for cross-chain fungible token transfers ZoneConciergeKeeper zckeeper.Keeper // for cross-chain fungible token transfers @@ -378,6 +384,7 @@ func NewBabylonApp( // IBC-related modules ibcexported.StoreKey, ibctransfertypes.StoreKey, + ibcfeetypes.StoreKey, zctypes.StoreKey, wasm.StoreKey, ) @@ -502,6 +509,31 @@ func NewBabylonApp( ), ) + btclightclientKeeper := btclightclientkeeper.NewKeeper( + appCodec, + keys[btclightclienttypes.StoreKey], + keys[btclightclienttypes.MemStoreKey], + btcConfig, + ) + checkpointingKeeper := checkpointingkeeper.NewKeeper( + appCodec, + keys[checkpointingtypes.StoreKey], + keys[checkpointingtypes.MemStoreKey], + privSigner.WrappedPV, + &epochingKeeper, + privSigner.ClientCtx, + ) + btcCheckpointKeeper := btccheckpointkeeper.NewKeeper( + appCodec, + keys[btccheckpointtypes.StoreKey], + tkeys[btccheckpointtypes.TStoreKey], + keys[btccheckpointtypes.MemStoreKey], + &btclightclientKeeper, + &checkpointingKeeper, + &powLimit, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + // create Tendermint client tmClient, err := client.NewClientFromNode(privSigner.ClientCtx.NodeURI) // create a Tendermint client for ZoneConcierge if err != nil { @@ -512,21 +544,31 @@ func NewBabylonApp( if !ok { panic(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries")) } + + app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( + appCodec, keys[ibcfeetypes.StoreKey], + app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, + ) + zcKeeper := zckeeper.NewKeeper( appCodec, keys[zctypes.StoreKey], keys[zctypes.MemStoreKey], - app.IBCKeeper.ChannelKeeper, + app.IBCFeeKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, - nil, // CheckpointingKeeper is set later (TODO: figure out a proper way for this) - nil, // BTCCheckpoint is set later (TODO: figure out a proper way for this) + &btclightclientKeeper, + &checkpointingKeeper, + &btcCheckpointKeeper, epochingKeeper, tmClient, storeQuerier, scopedZoneConciergeKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // replace IBC keeper's client keeper with our ExtendedKeeper @@ -542,27 +584,9 @@ func NewBabylonApp( // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + app.IBCFeeKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, ) - transferModule := transfer.NewAppModule(app.TransferKeeper) - - // Create static IBC router, add ibc-tranfer module route, then set and seal it - ibcRouter := porttypes.NewRouter() - transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) - zcIBCModule := zoneconcierge.NewIBCModule(app.ZoneConciergeKeeper) - ibcRouter.AddRoute(zctypes.ModuleName, zcIBCModule) - // Setting Router will finalize all routes by sealing router - // No more routes can be added - app.IBCKeeper.SetRouter(ibcRouter) - - btclightclientKeeper := *btclightclientkeeper.NewKeeper( - appCodec, - keys[btclightclienttypes.StoreKey], - keys[btclightclienttypes.MemStoreKey], - btcConfig, - ) app.MonitorKeeper = monitorkeeper.NewKeeper( appCodec, @@ -574,40 +598,13 @@ func NewBabylonApp( // add msgServiceRouter so that the epoching module can forward unwrapped messages to the staking module epochingKeeper.SetMsgServiceRouter(app.BaseApp.MsgServiceRouter()) // make ZoneConcierge to subscribe to the epoching's hooks - epochingKeeper.SetHooks( + app.EpochingKeeper = *epochingKeeper.SetHooks( epochingtypes.NewMultiEpochingHooks(app.ZoneConciergeKeeper.Hooks(), app.MonitorKeeper.Hooks()), ) - app.EpochingKeeper = epochingKeeper - - checkpointingKeeper := - checkpointingkeeper.NewKeeper( - appCodec, - keys[checkpointingtypes.StoreKey], - keys[checkpointingtypes.MemStoreKey], - privSigner.WrappedPV, - app.EpochingKeeper, - privSigner.ClientCtx, - ) app.CheckpointingKeeper = *checkpointingKeeper.SetHooks( checkpointingtypes.NewMultiCheckpointingHooks(app.EpochingKeeper.Hooks(), app.ZoneConciergeKeeper.Hooks(), app.MonitorKeeper.Hooks()), ) - app.ZoneConciergeKeeper.SetCheckpointingKeeper(app.CheckpointingKeeper) - - // TODO for now use mocks, as soon as Checkpoining and lightClient will have correct interfaces - // change to correct implementations - app.BtcCheckpointKeeper = - btccheckpointkeeper.NewKeeper( - appCodec, - keys[btccheckpointtypes.StoreKey], - tkeys[btccheckpointtypes.TStoreKey], - keys[btccheckpointtypes.MemStoreKey], - &btclightclientKeeper, - app.CheckpointingKeeper, - &powLimit, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - app.ZoneConciergeKeeper.SetBtcCheckpointKeeper(app.BtcCheckpointKeeper) - + app.BtcCheckpointKeeper = btcCheckpointKeeper app.BTCLightClientKeeper = *btclightclientKeeper.SetHooks( btclightclienttypes.NewMultiBTCLightClientHooks(app.BtcCheckpointKeeper.Hooks()), ) @@ -634,6 +631,7 @@ func NewBabylonApp( app.BankKeeper, app.StakingKeeper, distrkeeper.NewQuerier(app.DistrKeeper), + app.IBCFeeKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, scopedWasmKeeper, @@ -647,6 +645,29 @@ func NewBabylonApp( wasmOpts..., ) + // Create all supported IBC routes + var transferStack porttypes.IBCModule + transferStack = transfer.NewIBCModule(app.TransferKeeper) + transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) + + var zoneConciergeStack porttypes.IBCModule + zoneConciergeStack = zoneconcierge.NewIBCModule(app.ZoneConciergeKeeper) + zoneConciergeStack = ibcfee.NewIBCMiddleware(zoneConciergeStack, app.IBCFeeKeeper) + + var wasmStack porttypes.IBCModule + wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper) + wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper) + + // Create static IBC router, add ibc-tranfer module route, then set and seal it + ibcRouter := porttypes.NewRouter(). + AddRoute(ibctransfertypes.ModuleName, transferStack). + AddRoute(zctypes.ModuleName, zoneConciergeStack). + AddRoute(wasm.ModuleName, wasmStack) + + // Setting Router will finalize all routes by sealing router + // No more routes can be added + app.IBCKeeper.SetRouter(ibcRouter) + // The gov proposal types can be individually enabled if len(wasmEnabledProposals) != 0 { govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, wasmEnabledProposals)) @@ -693,8 +714,9 @@ func NewBabylonApp( monitor.NewAppModule(appCodec, app.MonitorKeeper, app.AccountKeeper, app.BankKeeper), // IBC-related modules ibc.NewAppModule(app.IBCKeeper), - transferModule, + transfer.NewAppModule(app.TransferKeeper), zoneconcierge.NewAppModule(appCodec, app.ZoneConciergeKeeper, app.AccountKeeper, app.BankKeeper), + ibcfee.NewAppModule(app.IBCFeeKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -718,6 +740,7 @@ func NewBabylonApp( ibcexported.ModuleName, ibctransfertypes.ModuleName, zctypes.ModuleName, + ibcfeetypes.ModuleName, wasm.ModuleName, ) // TODO: there will be an architecture design on whether to modify slashing/evidence, specifically @@ -742,6 +765,7 @@ func NewBabylonApp( ibcexported.ModuleName, ibctransfertypes.ModuleName, zctypes.ModuleName, + ibcfeetypes.ModuleName, wasm.ModuleName, ) // Babylon does not want EndBlock processing in staking @@ -768,6 +792,7 @@ func NewBabylonApp( ibcexported.ModuleName, ibctransfertypes.ModuleName, zctypes.ModuleName, + ibcfeetypes.ModuleName, wasm.ModuleName, ) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 25146beee..14f146ca2 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -5737,6 +5737,16 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -5858,6 +5868,17 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block @@ -6535,6 +6556,17 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block @@ -6659,6 +6691,18 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ + ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon @@ -7053,6 +7097,17 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block @@ -7177,6 +7232,18 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ + ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon @@ -7579,6 +7646,17 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -7702,6 +7780,18 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ + ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon @@ -8588,6 +8678,18 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ + ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon @@ -8714,6 +8816,18 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ + ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the @@ -9589,6 +9703,16 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -10010,6 +10134,16 @@ paths: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -10319,6 +10453,224 @@ paths: format: uint64 tags: - Query + /babylon/zoneconcierge/v1/params: + get: + summary: Params queries the parameters of the module. + operationId: ZoneConciergeParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + ibc_packet_timeout_seconds: + type: integer + format: int64 + title: >- + ibc_packet_timeout_seconds is the time period after which + an unrelayed + + IBC packet becomes timeout, measured in seconds + description: >- + QueryParamsResponse is the response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + tags: + - Query definitions: babylon.btccheckpoint.v1.BTCCheckpointInfo: type: object @@ -15312,6 +15664,13 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: |- + time is the timestamp of this header on CZ ledger + it is needed for CZ to unbond all mature validators/delegations + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that includes @@ -15432,6 +15791,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -15602,6 +15971,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -15723,6 +16102,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -16357,6 +16746,13 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: |- + time is the timestamp of this header on CZ ledger + it is needed for CZ to unbond all mature validators/delegations + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that includes @@ -16499,6 +16895,13 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: |- + time is the timestamp of this header on CZ ledger + it is needed for CZ to unbond all mature validators/delegations + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that includes this @@ -16596,6 +16999,18 @@ definitions: the header on Babylon ledger title: IndexedHeader is the metadata of a CZ header + babylon.zoneconcierge.v1.Params: + type: object + properties: + ibc_packet_timeout_seconds: + type: integer + format: int64 + title: >- + ibc_packet_timeout_seconds is the time period after which an + unrelayed + + IBC packet becomes timeout, measured in seconds + description: Params defines the parameters for the module. babylon.zoneconcierge.v1.ProofEpochSealed: type: object properties: @@ -16975,6 +17390,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -17096,6 +17521,17 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -17276,6 +17712,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -17397,6 +17843,17 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -17578,6 +18035,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -17699,6 +18166,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -18347,6 +18824,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -18470,6 +18957,17 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is + BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block @@ -19110,6 +19608,13 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: |- + time is the timestamp of this header on CZ ledger + it is needed for CZ to unbond all mature validators/delegations + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that includes @@ -19230,6 +19735,16 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: >- + time is the timestamp of this header on CZ ledger + + it is needed for CZ to unbond all mature + validators/delegations + + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that @@ -19382,6 +19897,13 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: |- + time is the timestamp of this header on CZ ledger + it is needed for CZ to unbond all mature validators/delegations + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that includes @@ -19508,6 +20030,13 @@ definitions: (hash, height) jointly provides the position of the header on CZ ledger + time: + type: string + format: date-time + title: |- + time is the timestamp of this header on CZ ledger + it is needed for CZ to unbond all mature validators/delegations + before this timestamp when this header is BTC-finalised babylon_header: title: >- babylon_header is the header of the babylon block that includes @@ -19636,6 +20165,22 @@ definitions: description: |- QueryListHeadersResponse is response type for the Query/ListHeaders RPC method. + babylon.zoneconcierge.v1.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + ibc_packet_timeout_seconds: + type: integer + format: int64 + title: >- + ibc_packet_timeout_seconds is the time period after which an + unrelayed + + IBC packet becomes timeout, measured in seconds + description: QueryParamsResponse is the response type for the Query/Params RPC method. tendermint.crypto.Proof: type: object properties: diff --git a/contrib/images/babylond/Dockerfile b/contrib/images/babylond/Dockerfile index 11bb49450..71a148639 100644 --- a/contrib/images/babylond/Dockerfile +++ b/contrib/images/babylond/Dockerfile @@ -4,8 +4,8 @@ FROM golang:1.20-alpine AS build-env # TARGETPLATFORM should be one of linux/amd64 or linux/arm64. ARG TARGETPLATFORM="linux/amd64" -# Version to build. Default is the Git HEAD. -ARG VERSION="HEAD" +# Version to build. Default is empty +ARG VERSION # Use muslc for static libs ARG BUILD_TAGS="muslc" @@ -24,7 +24,10 @@ COPY go.mod go.sum /go/src/github.com/babylonchain/babylon/ RUN go mod download # Then copy everything else COPY ./ /go/src/github.com/babylonchain/babylon/ -RUN git checkout -f ${VERSION} +# If version is set, then checkout this version +RUN if [ -n "${VERSION}" ]; then \ + git checkout -f ${VERSION}; \ + fi # Cosmwasm - Download correct libwasmvm version RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ diff --git a/go.mod b/go.mod index d71a4bd01..b7f3020c7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ go 1.20 module github.com/babylonchain/babylon require ( - github.com/CosmWasm/wasmd v0.40.0-rc.1 + github.com/CosmWasm/wasmd v0.40.0-rc.2 github.com/btcsuite/btcd v0.23.4 github.com/cometbft/cometbft v0.37.1 github.com/cometbft/cometbft-db v0.7.0 @@ -147,7 +147,7 @@ require ( github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/docker/cli v20.10.21+incompatible // indirect - github.com/docker/distribution v2.8.1+incompatible // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/docker v20.10.24+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect diff --git a/go.sum b/go.sum index f9161abe8..1ddfd2685 100644 --- a/go.sum +++ b/go.sum @@ -209,8 +209,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/CosmWasm/wasmd v0.40.0-rc.1 h1:prIM2vP1jNh0zgs9seua5BgKdayBgp3FiHtwxFcZSGs= -github.com/CosmWasm/wasmd v0.40.0-rc.1/go.mod h1:uacdue6EGn9JA1TqBNHB3iCe4PCIChuFT23AzIl2VME= +github.com/CosmWasm/wasmd v0.40.0-rc.2 h1:UgOr8CaitJ8C8Y80viKLT6mL2Xh4yg2X4szCdTVr6xg= +github.com/CosmWasm/wasmd v0.40.0-rc.2/go.mod h1:l2s42GHKp1CHcR0N6J8P6p02b5RMWFCpcmRjyKMtqqg= github.com/CosmWasm/wasmvm v1.2.3 h1:OKYlobwmVGbl0eSn0mXoAAjE5hIuXnQCLPjbNd91sVY= github.com/CosmWasm/wasmvm v1.2.3/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -408,8 +408,8 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WA github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/cli v20.10.21+incompatible h1:qVkgyYUnOLQ98LtXBrwd/duVqPT2X4SHndOuGsfwyhU= github.com/docker/cli v20.10.21+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= diff --git a/proto/babylon/zoneconcierge/v1/genesis.proto b/proto/babylon/zoneconcierge/v1/genesis.proto index 65ed8cb19..468fa02eb 100644 --- a/proto/babylon/zoneconcierge/v1/genesis.proto +++ b/proto/babylon/zoneconcierge/v1/genesis.proto @@ -1,9 +1,13 @@ syntax = "proto3"; package babylon.zoneconcierge.v1; +import "gogoproto/gogo.proto"; +import "babylon/zoneconcierge/v1/params.proto"; + option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; // GenesisState defines the zoneconcierge module's genesis state. message GenesisState { string port_id = 1; + Params params = 2 [ (gogoproto.nullable) = false ]; } diff --git a/proto/babylon/zoneconcierge/v1/packet.proto b/proto/babylon/zoneconcierge/v1/packet.proto index a330e0141..a9b4ef163 100644 --- a/proto/babylon/zoneconcierge/v1/packet.proto +++ b/proto/babylon/zoneconcierge/v1/packet.proto @@ -1,15 +1,53 @@ syntax = "proto3"; package babylon.zoneconcierge.v1; +import "babylon/btccheckpoint/v1/btccheckpoint.proto"; +import "babylon/checkpointing/v1/checkpoint.proto"; +import "babylon/btclightclient/v1/btclightclient.proto"; +import "babylon/epoching/v1/epoching.proto"; +import "babylon/zoneconcierge/v1/zoneconcierge.proto"; + option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; // ZoneconciergePacketData is the message that defines the IBC packets of // ZoneConcierge message ZoneconciergePacketData { // packet is the actual message carried in the IBC packet - oneof packet { Heartbeat heartbeart = 1; } + oneof packet { + BTCTimestamp btc_timestamp = 1; + } } -// Heartbeat is a heartbeat message that can be carried in IBC packets of -// ZoneConcierge -message Heartbeat { string msg = 1; } +// BTCTimestamp is a BTC timestamp that carries information of a BTC-finalised epoch +// It includes a number of BTC headers, a raw checkpoint, an epoch metadata, and +// a CZ header if there exists CZ headers checkpointed to this epoch. +// Upon a newly finalised epoch in Babylon, Babylon will send a BTC timestamp to each +// Cosmos zone that has phase-2 integration with Babylon via IBC. +message BTCTimestamp { + // header is the last CZ header in the finalized Babylon epoch + babylon.zoneconcierge.v1.IndexedHeader header = 1; + + /* + Data for BTC light client + */ + // btc_headers is BTC headers between + // - the block AFTER the common ancestor of BTC tip at epoch `lastFinalizedEpoch-1` and BTC tip at epoch `lastFinalizedEpoch` + // - BTC tip at epoch `lastFinalizedEpoch` + // where `lastFinalizedEpoch` is the last finalised epoch in Babylon + repeated babylon.btclightclient.v1.BTCHeaderInfo btc_headers = 2; + + /* + Data for Babylon epoch chain + */ + // epoch_info is the metadata of the sealed epoch + babylon.epoching.v1.Epoch epoch_info = 3; + // raw_checkpoint is the raw checkpoint that seals this epoch + babylon.checkpointing.v1.RawCheckpoint raw_checkpoint = 4; + // btc_submission_key is position of two BTC txs that include the raw checkpoint of this epoch + babylon.btccheckpoint.v1.SubmissionKey btc_submission_key = 5; + + /* + Proofs that the header is finalized + */ + babylon.zoneconcierge.v1.ProofFinalizedChainInfo proof = 6; +} \ No newline at end of file diff --git a/proto/babylon/zoneconcierge/v1/params.proto b/proto/babylon/zoneconcierge/v1/params.proto new file mode 100644 index 000000000..bb3e23738 --- /dev/null +++ b/proto/babylon/zoneconcierge/v1/params.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package babylon.zoneconcierge.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.equal) = true; + + // ibc_packet_timeout_seconds is the time period after which an unrelayed + // IBC packet becomes timeout, measured in seconds + uint32 ibc_packet_timeout_seconds = 1 + [ (gogoproto.moretags) = "yaml:\"ibc_packet_timeout_seconds\"" ]; +} diff --git a/proto/babylon/zoneconcierge/v1/query.proto b/proto/babylon/zoneconcierge/v1/query.proto index e3675682d..aa65a805f 100644 --- a/proto/babylon/zoneconcierge/v1/query.proto +++ b/proto/babylon/zoneconcierge/v1/query.proto @@ -1,17 +1,23 @@ syntax = "proto3"; package babylon.zoneconcierge.v1; +import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "babylon/btccheckpoint/v1/btccheckpoint.proto"; import "babylon/checkpointing/v1/checkpoint.proto"; import "babylon/epoching/v1/epoching.proto"; import "babylon/zoneconcierge/v1/zoneconcierge.proto"; +import "babylon/zoneconcierge/v1/params.proto"; option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; // Query defines the gRPC querier service. service Query { + // Params queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/babylon/zoneconcierge/v1/params"; + } // Header queries the CZ header and fork headers at a given height. rpc Header(QueryHeaderRequest) returns (QueryHeaderResponse) { option (google.api.http).get = @@ -62,6 +68,15 @@ service Query { } } +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + babylon.zoneconcierge.v1.Params params = 1 [ (gogoproto.nullable) = false ]; +} + // QueryHeaderRequest is request type for the Query/Header RPC method. message QueryHeaderRequest { string chain_id = 1; diff --git a/proto/babylon/zoneconcierge/v1/tx.proto b/proto/babylon/zoneconcierge/v1/tx.proto index f3820e6fa..4fc9a78b9 100644 --- a/proto/babylon/zoneconcierge/v1/tx.proto +++ b/proto/babylon/zoneconcierge/v1/tx.proto @@ -1,7 +1,36 @@ syntax = "proto3"; package babylon.zoneconcierge.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "babylon/zoneconcierge/v1/params.proto"; + option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; // Msg defines the Msg service. -service Msg {} +service Msg { + // UpdateParams updates the btccheckpoint module parameters. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgUpdateParams defines a message for updating zoneconcierge module parameters. +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet implemented + // in cosmos-proto + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the epoching paramaeters parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; + } + + // MsgUpdateParamsResponse is the response to the MsgUpdateParams message. + message MsgUpdateParamsResponse {} + \ No newline at end of file diff --git a/proto/babylon/zoneconcierge/v1/zoneconcierge.proto b/proto/babylon/zoneconcierge/v1/zoneconcierge.proto index c19a34bba..53fa995a8 100644 --- a/proto/babylon/zoneconcierge/v1/zoneconcierge.proto +++ b/proto/babylon/zoneconcierge/v1/zoneconcierge.proto @@ -1,6 +1,8 @@ syntax = "proto3"; package babylon.zoneconcierge.v1; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "tendermint/types/types.proto"; import "tendermint/crypto/proof.proto"; import "babylon/btccheckpoint/v1/btccheckpoint.proto"; @@ -19,15 +21,19 @@ message IndexedHeader { // height is the height of this header on CZ ledger // (hash, height) jointly provides the position of the header on CZ ledger uint64 height = 3; + // time is the timestamp of this header on CZ ledger + // it is needed for CZ to unbond all mature validators/delegations + // before this timestamp when this header is BTC-finalised + google.protobuf.Timestamp time = 4 [ (gogoproto.stdtime) = true ]; // babylon_header is the header of the babylon block that includes this CZ // header - tendermint.types.Header babylon_header = 4; + tendermint.types.Header babylon_header = 5; // epoch is the epoch number of this header on Babylon ledger - uint64 babylon_epoch = 5; + uint64 babylon_epoch = 6; // babylon_tx_hash is the hash of the tx that includes this header // (babylon_block_height, babylon_tx_hash) jointly provides the position of // the header on Babylon ledger - bytes babylon_tx_hash = 6; + bytes babylon_tx_hash = 7; } // Forks is a list of non-canonical `IndexedHeader`s at the same height. diff --git a/test/e2e/README.md b/test/e2e/README.md index 0a09a5c72..fb9f1751d 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -1,7 +1,5 @@ # End-to-end Tests -## Structure - ### `e2e` Package The `e2e` package defines an integration testing suite used for full @@ -9,6 +7,12 @@ end-to-end testing functionality. The package is copy of Osmosis e2e testing approach. +### Wasm contract used for e2e testing + +Wasm contract located in `bytecode/storage_contract.wasm` is compiled from most recent commit `main` branch - https://github.com/babylonchain/storage-contract + +This contract uses feature specific to Babylon, through Babylon bindings library. + ### Common Problems Please note that if the tests are stopped mid-way, the e2e framework might fail to start again due to duplicated containers. Make sure that diff --git a/test/e2e/bytecode/storage_contract.wasm b/test/e2e/bytecode/storage_contract.wasm new file mode 100644 index 000000000..229a10d89 Binary files /dev/null and b/test/e2e/bytecode/storage_contract.wasm differ diff --git a/test/e2e/configurer/base.go b/test/e2e/configurer/base.go index 5e22941fc..f27ca0227 100644 --- a/test/e2e/configurer/base.go +++ b/test/e2e/configurer/base.go @@ -13,11 +13,11 @@ import ( "github.com/stretchr/testify/require" + "github.com/babylonchain/babylon/test/e2e/configurer/chain" "github.com/babylonchain/babylon/test/e2e/containers" "github.com/babylonchain/babylon/test/e2e/initialization" - - "github.com/babylonchain/babylon/test/e2e/configurer/chain" "github.com/babylonchain/babylon/test/e2e/util" + zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" ) // baseConfigurer is the base implementation for the @@ -168,7 +168,13 @@ func (bc *baseConfigurer) runIBCRelayer(chainConfigA *chain.Config, chainConfigB func (bc *baseConfigurer) connectIBCChains(chainA *chain.Config, chainB *chain.Config) error { bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id) - cmd := []string{"hermes", "create", "channel", "--a-chain", chainA.ChainMeta.Id, "--b-chain", chainB.ChainMeta.Id, "--a-port", "zoneconcierge", "--b-port", "zoneconcierge", "--new-client-connection", "--yes"} + cmd := []string{"hermes", "create", "channel", + "--a-chain", chainA.ChainMeta.Id, "--b-chain", chainB.ChainMeta.Id, // channel ID + "--a-port", zctypes.PortID, "--b-port", zctypes.PortID, // port + "--order", zctypes.Ordering.String(), // ordering + "--channel-version", zctypes.Version, // version + "--new-client-connection", "--yes", + } _, _, err := bc.containerManager.ExecHermesCmd(bc.t, cmd, "SUCCESS") if err != nil { return err diff --git a/test/e2e/configurer/chain/commands.go b/test/e2e/configurer/chain/commands.go index 6b1364fcb..945f85a20 100644 --- a/test/e2e/configurer/chain/commands.go +++ b/test/e2e/configurer/chain/commands.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "math/rand" + "strings" "time" "github.com/cosmos/cosmos-sdk/types/bech32" @@ -165,3 +166,30 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { } } } + +func (n *NodeConfig) StoreWasmCode(wasmFile, from string) { + n.LogActionF("storing wasm code from file %s", wasmFile) + cmd := []string{"babylond", "tx", "wasm", "store", wasmFile, fmt.Sprintf("--from=%s", from), "--gas=auto", "--gas-prices=1ubbn", "--gas-adjustment=1.3"} + n.LogActionF(strings.Join(cmd, " ")) + _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + require.NoError(n.t, err) + n.LogActionF("successfully stored") +} + +func (n *NodeConfig) InstantiateWasmContract(codeId, initMsg, from string) { + n.LogActionF("instantiating wasm contract %s with %s", codeId, initMsg) + cmd := []string{"babylond", "tx", "wasm", "instantiate", codeId, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=contract", "--gas=auto", "--gas-prices=1ubbn", "--gas-adjustment=1.3"} + n.LogActionF(strings.Join(cmd, " ")) + _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + require.NoError(n.t, err) + n.LogActionF("successfully initialized") +} + +func (n *NodeConfig) WasmExecute(contract, execMsg, from string) { + n.LogActionF("executing %s on wasm contract %s from %s", execMsg, contract, from) + cmd := []string{"babylond", "tx", "wasm", "execute", contract, execMsg, fmt.Sprintf("--from=%s", from)} + n.LogActionF(strings.Join(cmd, " ")) + _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + require.NoError(n.t, err) + n.LogActionF("successfully executed") +} diff --git a/test/e2e/configurer/chain/node.go b/test/e2e/configurer/chain/node.go index ac7c27f0b..bb51f3a8c 100644 --- a/test/e2e/configurer/chain/node.go +++ b/test/e2e/configurer/chain/node.go @@ -139,6 +139,14 @@ func (n *NodeConfig) WaitUntilBtcHeight(height uint64) { }, fmt.Sprintf("Timed out waiting for btc height %d", height)) } +func (n *NodeConfig) WaitForNextBlock() { + latest := n.LatestBlockNumber() + n.WaitForCondition(func() bool { + newLatest := n.LatestBlockNumber() + return newLatest > latest + }, fmt.Sprintf("Timed out waiting for next block. Current height is: %d", latest)) +} + func (n *NodeConfig) extractOperatorAddressIfValidator() error { if !n.IsValidator { n.t.Logf("node (%s) is not a validator, skipping", n.Name) diff --git a/test/e2e/configurer/chain/queries.go b/test/e2e/configurer/chain/queries.go index c832f5135..176c9da5b 100644 --- a/test/e2e/configurer/chain/queries.go +++ b/test/e2e/configurer/chain/queries.go @@ -19,6 +19,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/require" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/babylonchain/babylon/test/e2e/util" blc "github.com/babylonchain/babylon/x/btclightclient/types" ct "github.com/babylonchain/babylon/x/checkpointing/types" @@ -291,3 +292,63 @@ func (n *NodeConfig) QueryLightClientHeightCheckpointReported(ckptHash []byte) ( } return mResponse.BtcLightClientHeight, nil } + +func (n *NodeConfig) QueryLatestWasmCodeID() uint64 { + path := "/cosmwasm/wasm/v1/code" + + bz, err := n.QueryGRPCGateway(path, url.Values{}) + require.NoError(n.t, err) + + var response wasmtypes.QueryCodesResponse + err = util.Cdc.UnmarshalJSON(bz, &response) + require.NoError(n.t, err) + if len(response.CodeInfos) == 0 { + return 0 + } + return response.CodeInfos[len(response.CodeInfos)-1].CodeID +} + +func (n *NodeConfig) QueryContractsFromId(codeId int) ([]string, error) { + path := fmt.Sprintf("/cosmwasm/wasm/v1/code/%d/contracts", codeId) + bz, err := n.QueryGRPCGateway(path, url.Values{}) + + require.NoError(n.t, err) + + var contractsResponse wasmtypes.QueryContractsByCodeResponse + if err := util.Cdc.UnmarshalJSON(bz, &contractsResponse); err != nil { + return nil, err + } + + return contractsResponse.Contracts, nil +} + +func (n *NodeConfig) QueryWasmSmart(contract string, msg string, result any) error { + // base64-encode the msg + encodedMsg := base64.StdEncoding.EncodeToString([]byte(msg)) + path := fmt.Sprintf("/cosmwasm/wasm/v1/contract/%s/smart/%s", contract, encodedMsg) + + bz, err := n.QueryGRPCGateway(path, url.Values{}) + if err != nil { + return err + } + + var response wasmtypes.QuerySmartContractStateResponse + err = util.Cdc.UnmarshalJSON(bz, &response) + if err != nil { + return err + } + + err = json.Unmarshal(response.Data, &result) + if err != nil { + return err + } + return nil +} + +func (n *NodeConfig) QueryWasmSmartObject(contract string, msg string) (resultObject map[string]interface{}, err error) { + err = n.QueryWasmSmart(contract, msg, &resultObject) + if err != nil { + return nil, err + } + return resultObject, nil +} diff --git a/test/e2e/containers/containers.go b/test/e2e/containers/containers.go index 7806d6bda..e681753b5 100644 --- a/test/e2e/containers/containers.go +++ b/test/e2e/containers/containers.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "os" "regexp" "strings" "testing" @@ -201,6 +202,11 @@ func (m *Manager) RunHermesResource(chainAID, osmoARelayerNodeName, osmoAValMnem // RunNodeResource runs a node container. Assings containerName to the container. // Mounts the container on valConfigDir volume on the running host. Returns the container resource and error if any. func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir string) (*dockertest.Resource, error) { + pwd, err := os.Getwd() + if err != nil { + return nil, err + } + runOpts := &dockertest.RunOptions{ Name: containerName, Repository: BabylonContainerName, @@ -215,6 +221,7 @@ func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir st Platform: "linux/x86_64", Mounts: []string{ fmt.Sprintf("%s/:/home/babylon/babylondata", valCondifDir), + fmt.Sprintf("%s/bytecode:/bytecode", pwd), }, } diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index b5e69cf9a..1b9411895 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -4,10 +4,14 @@ package e2e import ( + "crypto/sha256" + "encoding/hex" "fmt" + "strconv" "github.com/babylonchain/babylon/test/e2e/initialization" ct "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/stretchr/testify/require" ) // Most simple test, just checking that two chains are up and connected through @@ -74,3 +78,44 @@ func (s *IntegrationTestSuite) TestIbcCheckpointing() { _, err = chainB.GetDefaultNode() s.NoError(err) } + +func (s *IntegrationTestSuite) TestWasm() { + contractPath := "/bytecode/storage_contract.wasm" + chainA := s.configurer.GetChainConfig(0) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + require.NoError(s.T(), err) + nonValidatorNode.StoreWasmCode(contractPath, initialization.ValidatorWalletName) + nonValidatorNode.WaitForNextBlock() + latestWasmId := int(nonValidatorNode.QueryLatestWasmCodeID()) + nonValidatorNode.InstantiateWasmContract( + strconv.Itoa(latestWasmId), + `{}`, + initialization.ValidatorWalletName, + ) + nonValidatorNode.WaitForNextBlock() + contracts, err := nonValidatorNode.QueryContractsFromId(1) + s.NoError(err) + s.Require().Len(contracts, 1, "Wrong number of contracts for the counter") + contractAddr := contracts[0] + + data := []byte{1, 2, 3, 4, 5} + dataHex := hex.EncodeToString(data) + dataHash := sha256.Sum256(data) + dataHashHex := hex.EncodeToString(dataHash[:]) + + storeMsg := fmt.Sprintf(`{"save_data":{"data":"%s"}}`, dataHex) + nonValidatorNode.WasmExecute(contractAddr, storeMsg, initialization.ValidatorWalletName) + nonValidatorNode.WaitForNextBlock() + queryMsg := fmt.Sprintf(`{"check_data": {"data_hash":"%s"}}`, dataHashHex) + queryResult, err := nonValidatorNode.QueryWasmSmartObject(contractAddr, queryMsg) + require.NoError(s.T(), err) + finalized := queryResult["finalized"].(bool) + latestFinalizedEpoch := int(queryResult["latest_finalized_epoch"].(float64)) + saveEpoch := int(queryResult["save_epoch"].(float64)) + + require.False(s.T(), finalized) + // in previous test we already finalized epoch 3 + require.Equal(s.T(), 3, latestFinalizedEpoch) + // data is not finalized yet, so save epoch should be strictly greater than latest finalized epoch + require.Greater(s.T(), saveEpoch, latestFinalizedEpoch) +} diff --git a/testutil/keeper/btclightclient.go b/testutil/keeper/btclightclient.go index 90d5ba44d..f6b887b3f 100644 --- a/testutil/keeper/btclightclient.go +++ b/testutil/keeper/btclightclient.go @@ -42,5 +42,5 @@ func BTCLightClientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - return k, ctx + return &k, ctx } diff --git a/testutil/keeper/zoneconcierge.go b/testutil/keeper/zoneconcierge.go index d4b6e67b0..5d11eff1d 100644 --- a/testutil/keeper/zoneconcierge.go +++ b/testutil/keeper/zoneconcierge.go @@ -15,8 +15,10 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" "github.com/stretchr/testify/require" @@ -41,6 +43,9 @@ func (zoneconciergeChannelKeeper) ChanCloseInit(ctx sdk.Context, portID, channel func (zoneconciergeChannelKeeper) GetAllChannels(ctx sdk.Context) []channeltypes.IdentifiedChannel { return nil } +func (zoneconciergeChannelKeeper) GetChannelClientState(ctx sdk.Context, portID, channelID string) (string, ibcexported.ClientState, error) { + return "", nil, nil +} // zoneconciergeportKeeper is a stub of PortKeeper type zoneconciergePortKeeper struct{} @@ -61,7 +66,7 @@ func (zoneconciergeStoreQuerier) Query(req abci.RequestQuery) abci.ResponseQuery } } -func ZoneConciergeKeeper(t testing.TB, checkpointingKeeper types.CheckpointingKeeper, btccKeeper types.BtcCheckpointKeeper, epochingKeeper types.EpochingKeeper, tmClient types.TMClient) (*keeper.Keeper, sdk.Context) { +func ZoneConciergeKeeper(t testing.TB, btclcKeeper types.BTCLightClientKeeper, checkpointingKeeper types.CheckpointingKeeper, btccKeeper types.BtcCheckpointKeeper, epochingKeeper types.EpochingKeeper, tmClient types.TMClient) (*keeper.Keeper, sdk.Context) { logger := log.NewNopLogger() storeKey := sdk.NewKVStoreKey(types.StoreKey) @@ -85,12 +90,14 @@ func ZoneConciergeKeeper(t testing.TB, checkpointingKeeper types.CheckpointingKe zoneconciergePortKeeper{}, nil, // TODO: mock this keeper nil, // TODO: mock this keeper + btclcKeeper, checkpointingKeeper, btccKeeper, epochingKeeper, tmClient, zoneconciergeStoreQuerier{}, capabilityKeeper.ScopeToModule("ZoneconciergeScopedKeeper"), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, logger) diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index da92aff54..8231ba260 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -27,9 +27,9 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, btcConfig bbn.BtcConfig, -) *Keeper { +) Keeper { - return &Keeper{ + return Keeper{ cdc: cdc, storeKey: storeKey, memKey: memKey, @@ -271,3 +271,20 @@ func (k Keeper) GetHeaderByHeight(ctx sdk.Context, height uint64) *types.BTCHead return info } + +// GetHighestCommonAncestor traverses the ancestors of both headers +// to identify the common ancestor with the highest height +func (k Keeper) GetHighestCommonAncestor(ctx sdk.Context, header1 *types.BTCHeaderInfo, header2 *types.BTCHeaderInfo) *types.BTCHeaderInfo { + return k.headersState(ctx).GetHighestCommonAncestor(header1, header2) +} + +// GetInOrderAncestorsUntil returns the list of nodes starting from the block *after* the `ancestor` and ending with the `descendant`. +func (k Keeper) GetInOrderAncestorsUntil(ctx sdk.Context, descendant *types.BTCHeaderInfo, ancestor *types.BTCHeaderInfo) []*types.BTCHeaderInfo { + return k.headersState(ctx).GetInOrderAncestorsUntil(descendant, ancestor) +} + +// GetMainChainUpTo returns the current canonical chain as a collection of block headers +// starting from the tip and ending on the header that has `depth` distance from it. +func (k Keeper) GetMainChainUpTo(ctx sdk.Context, depth uint64) []*types.BTCHeaderInfo { + return k.headersState(ctx).GetMainChainUpTo(depth) +} diff --git a/x/btclightclient/keeper/state.go b/x/btclightclient/keeper/state.go index cc3c19767..439d74356 100644 --- a/x/btclightclient/keeper/state.go +++ b/x/btclightclient/keeper/state.go @@ -210,8 +210,7 @@ func (s headersState) GetHeaderAncestryUpTo(currentHeader *types.BTCHeaderInfo, } // GetMainChainUpTo returns the current canonical chain as a collection of block headers -// -// starting from the tip and ending on the header that has a depth distance from it. +// starting from the tip and ending on the header that has `depth` distance from it. func (s headersState) GetMainChainUpTo(depth uint64) []*types.BTCHeaderInfo { // If there is no tip, there is no base header if !s.TipExists() { diff --git a/x/epoching/types/genesis.go b/x/epoching/types/genesis.go index 641451929..9fec52433 100644 --- a/x/epoching/types/genesis.go +++ b/x/epoching/types/genesis.go @@ -10,7 +10,7 @@ func DefaultGenesis() *GenesisState { } } -// NewGenesis creates a new GenesisState instanc e +// NewGenesis creates a new GenesisState instance func NewGenesis(params Params) *GenesisState { return &GenesisState{ Params: params, diff --git a/x/zoneconcierge/extended-client-keeper/hooks.go b/x/zoneconcierge/extended-client-keeper/hooks.go index 9c0367277..516e7ecac 100644 --- a/x/zoneconcierge/extended-client-keeper/hooks.go +++ b/x/zoneconcierge/extended-client-keeper/hooks.go @@ -1,6 +1,8 @@ package extended_client_keeper import ( + "time" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -13,6 +15,7 @@ type HeaderInfo struct { Hash []byte ChaindId string Height uint64 + Time time.Time } // MultiClientHooks is a concrete implementation of ClientHooks diff --git a/x/zoneconcierge/extended-client-keeper/keeper.go b/x/zoneconcierge/extended-client-keeper/keeper.go index 4c59119e9..68474423c 100644 --- a/x/zoneconcierge/extended-client-keeper/keeper.go +++ b/x/zoneconcierge/extended-client-keeper/keeper.go @@ -34,6 +34,7 @@ func GetHeaderInfo(ctx sdk.Context, m exported.ClientMessage) *HeaderInfo { Hash: msg.Header.LastCommitHash, ChaindId: msg.Header.ChainID, Height: uint64(msg.Header.Height), + Time: msg.Header.Time, } default: return nil diff --git a/x/zoneconcierge/genesis.go b/x/zoneconcierge/genesis.go index fb3758b66..eb5ec4424 100644 --- a/x/zoneconcierge/genesis.go +++ b/x/zoneconcierge/genesis.go @@ -8,6 +8,11 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // set params for this module + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } + k.SetPort(ctx, genState.PortId) // Only try to bind to port if it is not already bound, since we may already own // port capability from capability InitGenesis @@ -24,6 +29,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // ExportGenesis returns the module's exported genesis func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) genesis.PortId = k.GetPort(ctx) return genesis } diff --git a/x/zoneconcierge/genesis_test.go b/x/zoneconcierge/genesis_test.go index 731765ab6..04e049233 100644 --- a/x/zoneconcierge/genesis_test.go +++ b/x/zoneconcierge/genesis_test.go @@ -13,9 +13,10 @@ import ( func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ PortId: types.PortID, + Params: types.Params{IbcPacketTimeoutSeconds: 100}, } - k, ctx := keepertest.ZoneConciergeKeeper(t, nil, nil, nil, nil) + k, ctx := keepertest.ZoneConciergeKeeper(t, nil, nil, nil, nil, nil) zoneconcierge.InitGenesis(ctx, *k, genesisState) got := zoneconcierge.ExportGenesis(ctx, *k) require.NotNil(t, got) @@ -24,4 +25,5 @@ func TestGenesis(t *testing.T) { nullify.Fill(got) require.Equal(t, genesisState.PortId, got.PortId) + require.Equal(t, genesisState.Params, got.Params) } diff --git a/x/zoneconcierge/keeper/epochs.go b/x/zoneconcierge/keeper/epochs.go index 2fc919d99..ac0511a19 100644 --- a/x/zoneconcierge/keeper/epochs.go +++ b/x/zoneconcierge/keeper/epochs.go @@ -1,11 +1,32 @@ package keeper import ( + btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" epochingtypes "github.com/babylonchain/babylon/x/epoching/types" "github.com/babylonchain/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" ) +// GetFinalizingBTCTip gets the BTC tip when the last epoch is finalised +func (k Keeper) GetFinalizingBTCTip(ctx sdk.Context) *btclctypes.BTCHeaderInfo { + store := ctx.KVStore(k.storeKey) + if !store.Has(types.FinalizingBTCTipKey) { + return nil + } + btcTipBytes := store.Get(types.FinalizingBTCTipKey) + var btcTip btclctypes.BTCHeaderInfo + k.cdc.MustUnmarshal(btcTipBytes, &btcTip) + return &btcTip +} + +// setFinalizingBTCTip sets the last finalised BTC tip +// called upon each AfterRawCheckpointFinalized hook invocation +func (k Keeper) setFinalizingBTCTip(ctx sdk.Context, btcTip *btclctypes.BTCHeaderInfo) { + store := ctx.KVStore(k.storeKey) + btcTipBytes := k.cdc.MustMarshal(btcTip) + store.Set(types.FinalizingBTCTipKey, btcTipBytes) +} + // GetFinalizedEpoch gets the last finalised epoch // used upon querying the last BTC-finalised chain info for CZs func (k Keeper) GetFinalizedEpoch(ctx sdk.Context) (uint64, error) { diff --git a/x/zoneconcierge/keeper/grpc_query.go b/x/zoneconcierge/keeper/grpc_query.go index 191f59f32..657915801 100644 --- a/x/zoneconcierge/keeper/grpc_query.go +++ b/x/zoneconcierge/keeper/grpc_query.go @@ -3,20 +3,27 @@ package keeper import ( "context" + bbntypes "github.com/babylonchain/babylon/types" + "github.com/babylonchain/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - - bbntypes "github.com/babylonchain/babylon/types" - - "github.com/babylonchain/babylon/x/zoneconcierge/types" ) var _ types.QueryServer = Keeper{} const maxQueryChainsInfoLimit = 100 +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} + func (k Keeper) ChainList(c context.Context, req *types.QueryChainListRequest) (*types.QueryChainListResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/zoneconcierge/keeper/grpc_query_test.go b/x/zoneconcierge/keeper/grpc_query_test.go index 08ad7f6cf..4a5139e0f 100644 --- a/x/zoneconcierge/keeper/grpc_query_test.go +++ b/x/zoneconcierge/keeper/grpc_query_test.go @@ -395,6 +395,10 @@ func FuzzFinalizedChainInfo(f *testing.F) { epochingKeeper.EXPECT().GetEpoch(gomock.Any()).Return(epoch).AnyTimes() epochingKeeper.EXPECT().GetHistoricalEpoch(gomock.Any(), gomock.Eq(epoch.EpochNumber)).Return(epoch, nil).AnyTimes() epochingKeeper.EXPECT().ProveAppHashInEpoch(gomock.Any(), gomock.Any(), gomock.Eq(epoch.EpochNumber)).Return(&tmcrypto.Proof{}, nil).AnyTimes() + // mock btclc keeper + btclcKeeper := zctypes.NewMockBTCLightClientKeeper(ctrl) + mockBTCHeaderInfo := datagen.GenRandomBTCHeaderInfo(r) + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(mockBTCHeaderInfo).AnyTimes() // mock Tendermint client // TODO: integration tests with Tendermint @@ -404,7 +408,7 @@ func FuzzFinalizedChainInfo(f *testing.F) { } tmClient.EXPECT().Tx(gomock.Any(), gomock.Any(), true).Return(resTx, nil).AnyTimes() - zcKeeper, ctx := testkeeper.ZoneConciergeKeeper(t, checkpointingKeeper, btccKeeper, epochingKeeper, tmClient) + zcKeeper, ctx := testkeeper.ZoneConciergeKeeper(t, btclcKeeper, checkpointingKeeper, btccKeeper, epochingKeeper, tmClient) hooks := zcKeeper.Hooks() var ( diff --git a/x/zoneconcierge/keeper/hooks.go b/x/zoneconcierge/keeper/hooks.go index 95b52a65f..82d573955 100644 --- a/x/zoneconcierge/keeper/hooks.go +++ b/x/zoneconcierge/keeper/hooks.go @@ -29,6 +29,7 @@ func (h Hooks) AfterHeaderWithValidCommit(ctx sdk.Context, txHash []byte, header ChainId: header.ChaindId, Hash: header.Hash, Height: header.Height, + Time: &header.Time, BabylonHeader: &babylonHeader, BabylonEpoch: h.k.GetEpoch(ctx).EpochNumber, BabylonTxHash: txHash, @@ -92,6 +93,14 @@ func (h Hooks) AfterEpochEnds(ctx sdk.Context, epoch uint64) { func (h Hooks) AfterRawCheckpointFinalized(ctx sdk.Context, epoch uint64) error { // upon an epoch has been finalised, update the last finalised epoch h.k.setFinalizedEpoch(ctx, epoch) + + // send BTC timestamp to all open channels with ZoneConcierge + h.k.BroadcastBTCTimestamps(ctx, epoch) + + // retrieve and update the last finalising BTC tip + btcTip := h.k.btclcKeeper.GetTipInfo(ctx) + h.k.setFinalizingBTCTip(ctx, btcTip) + return nil } diff --git a/x/zoneconcierge/keeper/ibc_channels.go b/x/zoneconcierge/keeper/ibc_channels.go new file mode 100644 index 000000000..a3709caee --- /dev/null +++ b/x/zoneconcierge/keeper/ibc_channels.go @@ -0,0 +1,39 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" +) + +func (k Keeper) GetAllChannels(ctx sdk.Context) []channeltypes.IdentifiedChannel { + return k.channelKeeper.GetAllChannels(ctx) +} + +// GetAllOpenZCChannels returns all open channels that are connected to ZoneConcierge's port +func (k Keeper) GetAllOpenZCChannels(ctx sdk.Context) []channeltypes.IdentifiedChannel { + zcPort := k.GetPort(ctx) + channels := k.GetAllChannels(ctx) + + openZCChannels := []channeltypes.IdentifiedChannel{} + for _, channel := range channels { + if channel.State != channeltypes.OPEN { + continue + } + if channel.PortId != zcPort { + continue + } + openZCChannels = append(openZCChannels, channel) + } + + return openZCChannels +} + +// isChannelUninitialized checks whether the channel is not initilialised yet +// it's done by checking whether the packet sequence number is 1 (the first sequence number) or not +func (k Keeper) isChannelUninitialized(ctx sdk.Context, channel channeltypes.IdentifiedChannel) bool { + portID := channel.PortId + channelID := channel.ChannelId + // NOTE: channeltypes.IdentifiedChannel object is guaranteed to exist, so guaranteed to be found + nextSeqSend, _ := k.channelKeeper.GetNextSequenceSend(ctx, portID, channelID) + return nextSeqSend == 1 +} diff --git a/x/zoneconcierge/keeper/ibc_packet.go b/x/zoneconcierge/keeper/ibc_packet.go index a75fc2415..51b84cfec 100644 --- a/x/zoneconcierge/keeper/ibc_packet.go +++ b/x/zoneconcierge/keeper/ibc_packet.go @@ -32,7 +32,8 @@ func (k Keeper) SendIBCPacket(ctx sdk.Context, channel channeltypes.IdentifiedCh } // timeout - timeoutTime := uint64(ctx.BlockHeader().Time.Add(time.Hour * 24).UnixNano()) // TODO: parameterise + timeoutPeriod := time.Duration(k.GetParams(ctx).IbcPacketTimeoutSeconds) * time.Second + timeoutTime := uint64(ctx.BlockHeader().Time.Add(timeoutPeriod).UnixNano()) zeroheight := clienttypes.ZeroHeight() seq, err := k.ics4Wrapper.SendPacket( diff --git a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go new file mode 100644 index 000000000..1b44e9229 --- /dev/null +++ b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go @@ -0,0 +1,228 @@ +package keeper + +import ( + "fmt" + + bbn "github.com/babylonchain/babylon/types" + btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" + checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonchain/babylon/x/zoneconcierge/types" + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" +) + +// finalizedInfo is a private struct that stores metadata and proofs +// identical to all BTC timestamps in the same epoch +type finalizedInfo struct { + EpochInfo *epochingtypes.Epoch + RawCheckpoint *checkpointingtypes.RawCheckpoint + BTCSubmissionKey *btcctypes.SubmissionKey + ProofEpochSealed *types.ProofEpochSealed + ProofEpochSubmitted []*btcctypes.TransactionInfo + BTCHeaders []*btclctypes.BTCHeaderInfo +} + +// getChainID gets the ID of the counterparty chain under the given channel +func (k Keeper) getChainID(ctx sdk.Context, channel channeltypes.IdentifiedChannel) (string, error) { + // get clientState under this channel + _, clientState, err := k.channelKeeper.GetChannelClientState(ctx, channel.PortId, channel.ChannelId) + if err != nil { + return "", err + } + // cast clientState to tendermint clientState + // TODO: support for chains other than Cosmos zones + tmClient, ok := clientState.(*ibctmtypes.ClientState) + if !ok { + return "", fmt.Errorf("client must be a Tendermint client, expected: %T, got: %T", &ibctmtypes.ClientState{}, tmClient) + } + return tmClient.ChainId, nil +} + +// getBTCHeadersDuringLastFinalizedEpoch gets BTC headers between +// - the block AFTER the common ancestor of BTC tip at epoch `lastFinalizedEpoch-1` and BTC tip at epoch `lastFinalizedEpoch` +// - BTC tip at epoch `lastFinalizedEpoch` +// where `lastFinalizedEpoch` is the last finalised epoch +func (k Keeper) getBTCHeadersDuringLastFinalizedEpoch(ctx sdk.Context) []*btclctypes.BTCHeaderInfo { + oldBTCTip := k.GetFinalizingBTCTip(ctx) // NOTE: BTC tip in KVStore has not been updated yet + if oldBTCTip == nil { + // this happens upon the first finalised epoch. Use base header instead + oldBTCTip = k.btclcKeeper.GetBaseBTCHeader(ctx) + } + curBTCTip := k.btclcKeeper.GetTipInfo(ctx) + commonAncestor := k.btclcKeeper.GetHighestCommonAncestor(ctx, oldBTCTip, curBTCTip) + btcHeaders := k.btclcKeeper.GetInOrderAncestorsUntil(ctx, curBTCTip, commonAncestor) + + return btcHeaders +} + +// getFinalizedInfo returns metadata and proofs that are identical to all BTC timestamps in the same epoch +func (k Keeper) getFinalizedInfo(ctx sdk.Context, epochNum uint64) (*finalizedInfo, error) { + finalizedEpochInfo, err := k.epochingKeeper.GetHistoricalEpoch(ctx, epochNum) + if err != nil { + return nil, err + } + + // assign raw checkpoint + rawCheckpoint, err := k.checkpointingKeeper.GetRawCheckpoint(ctx, epochNum) + if err != nil { + return nil, err + } + + // assign BTC submission key + ed := k.btccKeeper.GetEpochData(ctx, epochNum) + bestSubmissionBtcInfo := k.btccKeeper.GetEpochBestSubmissionBtcInfo(ctx, ed) + if bestSubmissionBtcInfo == nil { + return nil, fmt.Errorf("empty bestSubmissionBtcInfo") + } + btcSubmissionKey := &bestSubmissionBtcInfo.SubmissionKey + + // proof that the epoch is sealed + proofEpochSealed, err := k.ProveEpochSealed(ctx, epochNum) + if err != nil { + return nil, err + } + + // proof that the epoch's checkpoint is submitted to BTC + // i.e., the two `TransactionInfo`s for the checkpoint + proofEpochSubmitted, err := k.ProveEpochSubmitted(ctx, btcSubmissionKey) + if err != nil { + return nil, err + } + + // get new BTC headers since the 2nd last finalised epoch and the last finalised epoch + btcHeaders := k.getBTCHeadersDuringLastFinalizedEpoch(ctx) + + // construct finalizedInfo + finalizedInfo := &finalizedInfo{ + EpochInfo: finalizedEpochInfo, + RawCheckpoint: rawCheckpoint.Ckpt, + BTCSubmissionKey: btcSubmissionKey, + ProofEpochSealed: proofEpochSealed, + ProofEpochSubmitted: proofEpochSubmitted, + BTCHeaders: btcHeaders, + } + + return finalizedInfo, nil +} + +// createBTCTimestamp creates a BTC timestamp from finalizedInfo for a given IBC channel +// where the counterparty is a Cosmos zone +func (k Keeper) createBTCTimestamp(ctx sdk.Context, chainID string, channel channeltypes.IdentifiedChannel, finalizedInfo *finalizedInfo) (*types.BTCTimestamp, error) { + // if the Babylon contract in this channel has not been initialised, get headers from + // the tip to (w+1+len(finalizedInfo.BTCHeaders))-deep header + var btcHeaders []*btclctypes.BTCHeaderInfo + if k.isChannelUninitialized(ctx, channel) { + w := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout + depth := w + 1 + uint64(len(finalizedInfo.BTCHeaders)) + + btcHeaders = k.btclcKeeper.GetMainChainUpTo(ctx, depth) + if btcHeaders == nil { + return nil, fmt.Errorf("failed to get Bitcoin main chain up to depth %d", depth) + } + bbn.Reverse(btcHeaders) + } else { + btcHeaders = finalizedInfo.BTCHeaders + } + + // get finalised chainInfo + // NOTE: it's possible that this chain does not have chain info at the moment + // In this case, skip sending BTC timestamp for this chain at this epoch + epochNum := finalizedInfo.EpochInfo.EpochNumber + finalizedChainInfo, err := k.GetEpochChainInfo(ctx, chainID, epochNum) + if err != nil { + return nil, fmt.Errorf("no finalizedChainInfo for chain %s at epoch %d", chainID, epochNum) + } + + // construct BTC timestamp from everything + // NOTE: it's possible that there is no header checkpointed in this epoch + btcTimestamp := &types.BTCTimestamp{ + Header: nil, + BtcHeaders: btcHeaders, + EpochInfo: finalizedInfo.EpochInfo, + RawCheckpoint: finalizedInfo.RawCheckpoint, + BtcSubmissionKey: finalizedInfo.BTCSubmissionKey, + Proof: &types.ProofFinalizedChainInfo{ + ProofTxInBlock: nil, + ProofHeaderInEpoch: nil, + ProofEpochSealed: finalizedInfo.ProofEpochSealed, + ProofEpochSubmitted: finalizedInfo.ProofEpochSubmitted, + }, + } + + // if there is a CZ header checkpointed in this finalised epoch, + // add this CZ header and corresponding proofs to the BTC timestamp + if finalizedChainInfo.LatestHeader.BabylonEpoch == epochNum { + // get proofTxInBlock + proofTxInBlock, err := k.ProveTxInBlock(ctx, finalizedChainInfo.LatestHeader.BabylonTxHash) + if err != nil { + return nil, fmt.Errorf("failed to generate proofTxInBlock for chain %s: %w", chainID, err) + } + + // get proofHeaderInEpoch + proofHeaderInEpoch, err := k.ProveHeaderInEpoch(ctx, finalizedChainInfo.LatestHeader.BabylonHeader, finalizedInfo.EpochInfo) + if err != nil { + return nil, fmt.Errorf("failed to generate proofHeaderInEpoch for chain %s: %w", chainID, err) + } + + btcTimestamp.Header = finalizedChainInfo.LatestHeader + btcTimestamp.Proof.ProofTxInBlock = proofTxInBlock + btcTimestamp.Proof.ProofHeaderInEpoch = proofHeaderInEpoch + } + + return btcTimestamp, nil +} + +// BroadcastBTCTimestamps sends an IBC packet of BTC timestamp to all open IBC channels to ZoneConcierge +func (k Keeper) BroadcastBTCTimestamps(ctx sdk.Context, epochNum uint64) { + // Babylon does not broadcast BTC timestamps until finalising epoch 1 + if epochNum < 1 { + k.Logger(ctx).Info("Babylon does not finalize epoch 1 yet, skip broadcasting BTC timestamps") + return + } + + // get all channels that are open and are connected to ZoneConcierge's port + openZCChannels := k.GetAllOpenZCChannels(ctx) + if len(openZCChannels) == 0 { + k.Logger(ctx).Info("no open IBC channel with ZoneConcierge, skip broadcasting BTC timestamps") + return + } + + k.Logger(ctx).Info("there exists open IBC channels with ZoneConcierge, generating BTC timestamps", "number of channels", len(openZCChannels)) + + // get all metadata shared across BTC timestamps in the same epoch + finalizedInfo, err := k.getFinalizedInfo(ctx, epochNum) + if err != nil { + k.Logger(ctx).Error("failed to generate metadata shared across BTC timestamps in the same epoch, skip broadcasting BTC timestamps", "error", err) + return + } + + // for each channel, construct and send BTC timestamp + for _, channel := range openZCChannels { + // get the ID of the chain under this channel + chainID, err := k.getChainID(ctx, channel) + if err != nil { + k.Logger(ctx).Error("failed to get chain ID, skip sending BTC timestamp for this chain", "channelID", channel.ChannelId, "error", err) + continue + } + + // generate timestamp for this channel + btcTimestamp, err := k.createBTCTimestamp(ctx, chainID, channel, finalizedInfo) + if err != nil { + k.Logger(ctx).Error("failed to generate BTC timestamp, skip sending BTC timestamp for this chain", "chainID", chainID, "error", err) + continue + } + + // wrap BTC timestamp to IBC packet + packet := types.NewBTCTimestampPacketData(btcTimestamp) + // send IBC packet + if err := k.SendIBCPacket(ctx, channel, packet); err != nil { + k.Logger(ctx).Error("failed to send BTC timestamp IBC packet, skip sending BTC timestamp for this chain", "chainID", chainID, "channelID", channel.ChannelId, "error", err) + continue + } + } +} + +// TODO: test case with at BTC headers and checkpoints diff --git a/x/zoneconcierge/keeper/keeper.go b/x/zoneconcierge/keeper/keeper.go index d2f928e8a..8231d6a10 100644 --- a/x/zoneconcierge/keeper/keeper.go +++ b/x/zoneconcierge/keeper/keeper.go @@ -7,7 +7,6 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ) @@ -23,12 +22,16 @@ type ( portKeeper types.PortKeeper authKeeper types.AccountKeeper bankKeeper types.BankKeeper + btclcKeeper types.BTCLightClientKeeper checkpointingKeeper types.CheckpointingKeeper btccKeeper types.BtcCheckpointKeeper epochingKeeper types.EpochingKeeper tmClient types.TMClient storeQuerier sdk.Queryable scopedKeeper types.ScopedKeeper + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string } ) @@ -41,12 +44,14 @@ func NewKeeper( portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + btclcKeeper types.BTCLightClientKeeper, checkpointingKeeper types.CheckpointingKeeper, btccKeeper types.BtcCheckpointKeeper, epochingKeeper types.EpochingKeeper, tmClient types.TMClient, storeQuerier sdk.Queryable, scopedKeeper types.ScopedKeeper, + authority string, ) *Keeper { return &Keeper{ cdc: cdc, @@ -57,12 +62,14 @@ func NewKeeper( portKeeper: portKeeper, authKeeper: authKeeper, bankKeeper: bankKeeper, + btclcKeeper: btclcKeeper, checkpointingKeeper: checkpointingKeeper, btccKeeper: btccKeeper, epochingKeeper: epochingKeeper, tmClient: tmClient, storeQuerier: storeQuerier, scopedKeeper: scopedKeeper, + authority: authority, } } @@ -106,15 +113,3 @@ func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Cap func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { return k.scopedKeeper.ClaimCapability(ctx, cap, name) } - -func (k Keeper) GetAllChannels(ctx sdk.Context) []channeltypes.IdentifiedChannel { - return k.channelKeeper.GetAllChannels(ctx) -} - -func (k *Keeper) SetBtcCheckpointKeeper(btccKeeper types.BtcCheckpointKeeper) { - k.btccKeeper = btccKeeper -} - -func (k *Keeper) SetCheckpointingKeeper(checkpointingKeeper types.CheckpointingKeeper) { - k.checkpointingKeeper = checkpointingKeeper -} diff --git a/x/zoneconcierge/keeper/msg_server.go b/x/zoneconcierge/keeper/msg_server.go index a4d989c6a..42d7a88fa 100644 --- a/x/zoneconcierge/keeper/msg_server.go +++ b/x/zoneconcierge/keeper/msg_server.go @@ -1,7 +1,12 @@ package keeper import ( + "context" + + errorsmod "cosmossdk.io/errors" "github.com/babylonchain/babylon/x/zoneconcierge/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) type msgServer struct { @@ -15,3 +20,20 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } var _ types.MsgServer = msgServer{} + +// UpdateParams updates the params. +// TODO investigate when it is the best time to update the params. We can update them +// when the epoch changes, but we can also update them during the epoch and extend +// the epoch duration. +func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if ms.authority != req.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := ms.SetParams(ctx, req.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/zoneconcierge/keeper/msg_server_test.go b/x/zoneconcierge/keeper/msg_server_test.go index 092ab042c..d7e4e1502 100644 --- a/x/zoneconcierge/keeper/msg_server_test.go +++ b/x/zoneconcierge/keeper/msg_server_test.go @@ -12,6 +12,6 @@ import ( //nolint:unused func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.ZoneConciergeKeeper(t, nil, nil, nil, nil) + k, ctx := keepertest.ZoneConciergeKeeper(t, nil, nil, nil, nil, nil) return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) } diff --git a/x/zoneconcierge/keeper/params.go b/x/zoneconcierge/keeper/params.go new file mode 100644 index 000000000..2cfae5c0f --- /dev/null +++ b/x/zoneconcierge/keeper/params.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "github.com/babylonchain/babylon/x/zoneconcierge/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +// SetParams sets the x/zoneconcierge module parameters. +func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { + if err := p.Validate(); err != nil { + return err + } + + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&p) + store.Set(types.ParamsKey, bz) + + return nil +} + +// GetParams returns the current x/zoneconcierge module parameters. +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return p + } + + k.cdc.MustUnmarshal(bz, &p) + return p +} diff --git a/x/zoneconcierge/keeper/params_test.go b/x/zoneconcierge/keeper/params_test.go new file mode 100644 index 000000000..70c1f96a6 --- /dev/null +++ b/x/zoneconcierge/keeper/params_test.go @@ -0,0 +1,20 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/babylonchain/babylon/testutil/keeper" + "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.ZoneConciergeKeeper(t, nil, nil, nil, nil, nil) + params := types.DefaultParams() + + if err := k.SetParams(ctx, params); err != nil { + panic(err) + } + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/zoneconcierge/keeper/proof_epoch_sealed_test.go b/x/zoneconcierge/keeper/proof_epoch_sealed_test.go index e29c6eae6..8f6dded9f 100644 --- a/x/zoneconcierge/keeper/proof_epoch_sealed_test.go +++ b/x/zoneconcierge/keeper/proof_epoch_sealed_test.go @@ -82,7 +82,7 @@ func FuzzProofEpochSealed_BLSSig(f *testing.F) { epochingKeeper.EXPECT().GetEpoch(gomock.Any()).Return(epoch).AnyTimes() epochingKeeper.EXPECT().GetHistoricalEpoch(gomock.Any(), gomock.Eq(epoch.EpochNumber)).Return(epoch, nil).AnyTimes() // create zcKeeper and ctx - zcKeeper, ctx := testkeeper.ZoneConciergeKeeper(t, checkpointingKeeper, nil, epochingKeeper, nil) + zcKeeper, ctx := testkeeper.ZoneConciergeKeeper(t, nil, checkpointingKeeper, nil, epochingKeeper, nil) // prove proof, err := zcKeeper.ProveEpochSealed(ctx, epoch.EpochNumber) diff --git a/x/zoneconcierge/module_ibc.go b/x/zoneconcierge/module_ibc.go index 758cc6451..074cbc9ad 100644 --- a/x/zoneconcierge/module_ibc.go +++ b/x/zoneconcierge/module_ibc.go @@ -1,8 +1,7 @@ package zoneconcierge import ( - "fmt" - + errorsmod "cosmossdk.io/errors" "github.com/babylonchain/babylon/x/zoneconcierge/keeper" "github.com/babylonchain/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,7 +11,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" - errorsmod "cosmossdk.io/errors" ) type IBCModule struct { @@ -36,12 +34,22 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) (string, error) { + // the IBC channel has to be ordered + if order != channeltypes.ORDERED { + return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s ", channeltypes.ORDERED, order) + } + // Require portID to be the one that ZoneConcierge is bound to boundPort := im.keeper.GetPort(ctx) if boundPort != portID { return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } + // ensure consistency of the protocol version + if version != types.Version { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) + } + // Claim channel capability passed back by IBC module if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { return "", err @@ -61,12 +69,22 @@ func (im IBCModule) OnChanOpenTry( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { + // the IBC channel has to be ordered + if order != channeltypes.ORDERED { + return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s ", channeltypes.ORDERED, order) + } + // Require portID to be the one that ZoneConcierge is bound to boundPort := im.keeper.GetPort(ctx) if boundPort != portID { return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } + // ensure consistency of the protocol version + if counterpartyVersion != types.Version { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version) + } + // Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos // (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry) // If module can already authenticate the capability then module already owns it so we don't need to claim @@ -89,10 +107,11 @@ func (im IBCModule) OnChanOpenAck( _, counterpartyVersion string, ) error { - // // TODO (Babylon): check version consistency (this requires modifying CZ code) - // if counterpartyVersion != types.Version { - // return errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version) - // } + // check version consistency + if counterpartyVersion != types.Version { + return errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version) + } + return nil } @@ -130,22 +149,9 @@ func (im IBCModule) OnRecvPacket( modulePacket channeltypes.Packet, relayer sdk.AccAddress, ) ibcexported.Acknowledgement { - var ack channeltypes.Acknowledgement - - var modulePacketData types.ZoneconciergePacketData - if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { - return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error())) - } - - // // TODO (Babylon): Dispatch and process packet - // switch packet := modulePacketData.Packet.(type) { - // default: - // err := fmt.Errorf("unrecognized %s packet type: %T", types.ModuleName, packet) - // return channeltypes.NewErrorAcknowledgement(err) - // } - + // Babylon is supposed to not take any IBC packet // NOTE: acknowledgement will be written synchronously during IBC handler execution. - return ack + return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "Babylon is supposed to not take any IBC packet")) } // OnAcknowledgementPacket implements the IBCModule interface @@ -156,12 +162,17 @@ func (im IBCModule) OnAcknowledgementPacket( relayer sdk.AccAddress, ) error { var ack channeltypes.Acknowledgement - if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement: %v", err) + // `x/wasm` uses both protobuf and json to encoded acknowledgement, so we need to try both here + // - for acknowledgment message with errors defined in `x/wasm`, it uses json + // - for all other acknowledgement messages, it uses protobuf + if errProto := types.ModuleCdc.Unmarshal(acknowledgement, &ack); errProto != nil { + im.keeper.Logger(ctx).Error("cannot unmarshal packet acknowledgement with protobuf", "error", errProto) + if errJson := types.ModuleCdc.Unmarshal(acknowledgement, &ack); errJson != nil { + im.keeper.Logger(ctx).Error("cannot unmarshal packet acknowledgement with json", "error", errJson) + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement with protobuf (error: %v) or json (error: %v)", errProto, errJson) + } } - var eventType string - // // TODO (Babylon): Dispatch and process packet // switch packet := modulePacketData.Packet.(type) { // default: @@ -169,26 +180,22 @@ func (im IBCModule) OnAcknowledgementPacket( // return errorsmod.Wrap(sdkerrors.ErrUnknownRequest, errMsg) // } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - eventType, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeKeyAck, fmt.Sprintf("%v", ack)), - ), - ) - switch resp := ack.Response.(type) { case *channeltypes.Acknowledgement_Result: + im.keeper.Logger(ctx).Info("received an Acknowledgement message", "result", string(resp.Result)) ctx.EventManager().EmitEvent( sdk.NewEvent( - eventType, + types.EventTypeAck, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), ), ) case *channeltypes.Acknowledgement_Error: + im.keeper.Logger(ctx).Error("received an Acknowledgement error message", "error", resp.Error) ctx.EventManager().EmitEvent( sdk.NewEvent( - eventType, + types.EventTypeAck, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), ), ) @@ -215,5 +222,7 @@ func (im IBCModule) OnTimeoutPacket( // return errorsmod.Wrap(sdkerrors.ErrUnknownRequest, errMsg) // } + // TODO: close channel upon timeout + return nil } diff --git a/x/zoneconcierge/module_ibc_packet_test.go b/x/zoneconcierge/module_ibc_packet_test.go index 3dbcdf712..790ed1cbf 100644 --- a/x/zoneconcierge/module_ibc_packet_test.go +++ b/x/zoneconcierge/module_ibc_packet_test.go @@ -38,10 +38,14 @@ func (suite *ZoneConciergeTestSuite) TestSetChannel() { path := ibctesting.NewPath(suite.babylonChain, suite.czChain) - // set the port ID to be consistent with ZoneConcierge - // in practice, such negotiation is done by the handshake protocol driven by the relayer - path.EndpointA.ChannelConfig.PortID = zctypes.PortID - path.EndpointB.ChannelConfig.PortID = zctypes.PortID + // overwrite the channel config + channelCfg := &ibctesting.ChannelConfig{ + PortID: zctypes.PortID, + Version: zctypes.Version, + Order: zctypes.Ordering, + } + path.EndpointA.ChannelConfig = channelCfg + path.EndpointB.ChannelConfig = channelCfg // create client and connections on both chains suite.coordinator.SetupConnections(path) @@ -74,7 +78,7 @@ func (suite *ZoneConciergeTestSuite) TestSetChannel() { nextSeqSend, found := suite.babylonChain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(suite.babylonChain.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) suite.True(found) - // commit blocks to create some pending heartbeat packets + // commit some blocks numBlocks := rand.Intn(10) for i := 0; i < numBlocks; i++ { suite.coordinator.CommitBlock(suite.babylonChain) @@ -84,7 +88,9 @@ func (suite *ZoneConciergeTestSuite) TestSetChannel() { newNextSeqSend, found := suite.babylonChain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(suite.babylonChain.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) suite.True(found) - // Assert the gap between two sequence numbers to be zero, since no packet is sent during these blocks + // Assert the gap between two sequence numbers to be zero + // No packet is supposed to be sent during these blocks. + // IBC packet (i.e., BTC timestamp) is sent only upon newly finalised epoch suite.Equal(newNextSeqSend, nextSeqSend) // update clients to ensure no panic happens diff --git a/x/zoneconcierge/module_test.go b/x/zoneconcierge/module_test.go index 27a531fc7..b0b96e45b 100644 --- a/x/zoneconcierge/module_test.go +++ b/x/zoneconcierge/module_test.go @@ -15,7 +15,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" clientexported "github.com/cosmos/ibc-go/v7/modules/core/02-client/exported" - "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v7/modules/core/exported" @@ -89,7 +88,7 @@ func (suite *ZoneConciergeTestSuite) SetupTest() { pubKey, err := suite.privVal.GetPubKey() suite.Require().NoError(err) - testClientHeightMinus1 := types.NewHeight(0, babylonChainHeight-1) + testClientHeightMinus1 := clienttypes.NewHeight(0, babylonChainHeight-1) validator := tmtypes.NewValidator(pubKey, 1) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) diff --git a/x/zoneconcierge/types/errors.go b/x/zoneconcierge/types/errors.go index a9d28f4bd..88e178199 100644 --- a/x/zoneconcierge/types/errors.go +++ b/x/zoneconcierge/types/errors.go @@ -8,20 +8,21 @@ import ( // x/zoneconcierge module sentinel errors var ( - ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") - ErrInvalidPacketTimeout = errorsmod.Register(ModuleName, 1101, "invalid packet timeout") - ErrInvalidVersion = errorsmod.Register(ModuleName, 1102, "invalid version") - ErrHeaderNotFound = errorsmod.Register(ModuleName, 1103, "no header exists at this height") - ErrInvalidHeader = errorsmod.Register(ModuleName, 1104, "input header is invalid") - ErrNoValidAncestorHeader = errorsmod.Register(ModuleName, 1105, "no valid ancestor for this header") - ErrForkNotFound = errorsmod.Register(ModuleName, 1106, "cannot find fork") - ErrInvalidForks = errorsmod.Register(ModuleName, 1107, "input forks is invalid") - ErrChainInfoNotFound = errorsmod.Register(ModuleName, 1108, "no chain info exists") - ErrEpochChainInfoNotFound = errorsmod.Register(ModuleName, 1109, "no chain info exists at this epoch") - ErrEpochHeadersNotFound = errorsmod.Register(ModuleName, 1110, "no timestamped header exists at this epoch") - ErrFinalizedEpochNotFound = errorsmod.Register(ModuleName, 1111, "cannot find a finalized epoch") - ErrInvalidProofEpochSealed = errorsmod.Register(ModuleName, 1112, "invalid ProofEpochSealed") - ErrInvalidMerkleProof = errorsmod.Register(ModuleName, 1113, "invalid Merkle inclusion proof") - ErrInvalidChainInfo = errorsmod.Register(ModuleName, 1114, "invalid chain info") - ErrInvalidChainIDs = errorsmod.Register(ModuleName, 1115, "chain ids contain duplicates or empty strings") + ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") + ErrInvalidPacketTimeout = errorsmod.Register(ModuleName, 1101, "invalid packet timeout") + ErrInvalidVersion = errorsmod.Register(ModuleName, 1102, "invalid version") + ErrHeaderNotFound = errorsmod.Register(ModuleName, 1103, "no header exists at this height") + ErrInvalidHeader = errorsmod.Register(ModuleName, 1104, "input header is invalid") + ErrNoValidAncestorHeader = errorsmod.Register(ModuleName, 1105, "no valid ancestor for this header") + ErrForkNotFound = errorsmod.Register(ModuleName, 1106, "cannot find fork") + ErrInvalidForks = errorsmod.Register(ModuleName, 1107, "input forks is invalid") + ErrChainInfoNotFound = errorsmod.Register(ModuleName, 1108, "no chain info exists") + ErrEpochChainInfoNotFound = errorsmod.Register(ModuleName, 1109, "no chain info exists at this epoch") + ErrEpochHeadersNotFound = errorsmod.Register(ModuleName, 1110, "no timestamped header exists at this epoch") + ErrFinalizedEpochNotFound = errorsmod.Register(ModuleName, 1111, "cannot find a finalized epoch") + ErrInvalidProofEpochSealed = errorsmod.Register(ModuleName, 1112, "invalid ProofEpochSealed") + ErrInvalidMerkleProof = errorsmod.Register(ModuleName, 1113, "invalid Merkle inclusion proof") + ErrInvalidChainInfo = errorsmod.Register(ModuleName, 1114, "invalid chain info") + ErrFinalizingBTCTipNotFound = errorsmod.Register(ModuleName, 1115, "cannot find a finalizing BTC tip") + ErrInvalidChainIDs = errorsmod.Register(ModuleName, 1116, "chain ids contain duplicates or empty strings") ) diff --git a/x/zoneconcierge/types/events_ibc.go b/x/zoneconcierge/types/events_ibc.go index 733bc89fd..fd4e2bba8 100644 --- a/x/zoneconcierge/types/events_ibc.go +++ b/x/zoneconcierge/types/events_ibc.go @@ -2,6 +2,7 @@ package types // IBC events const ( + EventTypeAck = "acknowledgement" EventTypeTimeout = "timeout" AttributeKeyAckSuccess = "success" diff --git a/x/zoneconcierge/types/expected_keepers.go b/x/zoneconcierge/types/expected_keepers.go index 42d9701b1..69d22c16b 100644 --- a/x/zoneconcierge/types/expected_keepers.go +++ b/x/zoneconcierge/types/expected_keepers.go @@ -6,6 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" epochingtypes "github.com/babylonchain/babylon/x/epoching/types" tmcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" @@ -52,6 +53,7 @@ type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) GetAllChannels(ctx sdk.Context) (channels []channeltypes.IdentifiedChannel) + GetChannelClientState(ctx sdk.Context, portID, channelID string) (string, ibcexported.ClientState, error) } // ClientKeeper defines the expected IBC client keeper @@ -77,9 +79,20 @@ type ScopedKeeper interface { ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error } +type BTCLightClientKeeper interface { + GetTipInfo(ctx sdk.Context) *btclctypes.BTCHeaderInfo + GetBaseBTCHeader(ctx sdk.Context) *btclctypes.BTCHeaderInfo + GetHighestCommonAncestor(ctx sdk.Context, header1 *btclctypes.BTCHeaderInfo, header2 *btclctypes.BTCHeaderInfo) *btclctypes.BTCHeaderInfo + GetInOrderAncestorsUntil(ctx sdk.Context, descendant *btclctypes.BTCHeaderInfo, ancestor *btclctypes.BTCHeaderInfo) []*btclctypes.BTCHeaderInfo + GetMainChainUpTo(ctx sdk.Context, depth uint64) []*btclctypes.BTCHeaderInfo +} + type BtcCheckpointKeeper interface { + GetParams(ctx sdk.Context) (p btcctypes.Params) + GetEpochData(ctx sdk.Context, e uint64) *btcctypes.EpochData GetBestSubmission(ctx sdk.Context, e uint64) (btcctypes.BtcStatus, *btcctypes.SubmissionKey, error) GetSubmissionData(ctx sdk.Context, sk btcctypes.SubmissionKey) *btcctypes.SubmissionData + GetEpochBestSubmissionBtcInfo(ctx sdk.Context, ed *btcctypes.EpochData) *btcctypes.SubmissionBtcInfo } type CheckpointingKeeper interface { diff --git a/x/zoneconcierge/types/genesis.go b/x/zoneconcierge/types/genesis.go index 5bd0f2ea7..37b63a085 100644 --- a/x/zoneconcierge/types/genesis.go +++ b/x/zoneconcierge/types/genesis.go @@ -11,6 +11,15 @@ const DefaultIndex uint64 = 1 func DefaultGenesis() *GenesisState { return &GenesisState{ PortId: PortID, + Params: DefaultParams(), + } +} + +// NewGenesis creates a new GenesisState instance +func NewGenesis(params Params) *GenesisState { + return &GenesisState{ + PortId: PortID, + Params: params, } } @@ -20,5 +29,8 @@ func (gs GenesisState) Validate() error { if err := host.PortIdentifierValidator(gs.PortId); err != nil { return err } + if err := gs.Params.Validate(); err != nil { + return err + } return nil } diff --git a/x/zoneconcierge/types/genesis.pb.go b/x/zoneconcierge/types/genesis.pb.go index 67c72b428..1eed06657 100644 --- a/x/zoneconcierge/types/genesis.pb.go +++ b/x/zoneconcierge/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -25,6 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the zoneconcierge module's genesis state. type GenesisState struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -67,6 +69,13 @@ func (m *GenesisState) GetPortId() string { return "" } +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "babylon.zoneconcierge.v1.GenesisState") } @@ -76,18 +85,22 @@ func init() { } var fileDescriptor_56f290ad7c2c7dc7 = []byte{ - // 173 bytes of a gzipped FileDescriptorProto + // 228 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 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0x20, 0xb1, + 0x28, 0x31, 0x17, 0x6a, 0xac, 0x52, 0x3a, 0x17, 0x8f, 0x3b, 0xc4, 0x9e, 0xe0, 0x92, 0xc4, 0x92, + 0x54, 0x21, 0x71, 0x2e, 0xf6, 0x82, 0xfc, 0xa2, 0x92, 0xf8, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0xce, 0x20, 0x36, 0x10, 0xd7, 0x33, 0x45, 0xc8, 0x8e, 0x8b, 0x0d, 0xa2, 0x51, 0x82, 0x49, + 0x81, 0x51, 0x83, 0xdb, 0x48, 0x41, 0x0f, 0x97, 0x83, 0xf4, 0x02, 0xc0, 0xea, 0x9c, 0x58, 0x4e, + 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x72, 0xf2, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, + 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, + 0x39, 0x86, 0x28, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, + 0x99, 0xc9, 0x19, 0x89, 0x99, 0x79, 0x30, 0x8e, 0x7e, 0x05, 0x9a, 0x1f, 0x4a, 0x2a, 0x0b, 0x52, + 0x8b, 0x93, 0xd8, 0xc0, 0x1e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xb2, 0x6d, 0xbb, + 0x41, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -110,6 +123,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if len(m.PortId) > 0 { i -= len(m.PortId) copy(dAtA[i:], m.PortId) @@ -141,6 +164,8 @@ func (m *GenesisState) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -211,6 +236,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.PortId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/zoneconcierge/types/genesis_test.go b/x/zoneconcierge/types/genesis_test.go index fc2ead9e0..0902eb6d7 100644 --- a/x/zoneconcierge/types/genesis_test.go +++ b/x/zoneconcierge/types/genesis_test.go @@ -22,6 +22,7 @@ func TestGenesisState_Validate(t *testing.T) { desc: "valid genesis state", genState: &types.GenesisState{ PortId: types.PortID, + Params: types.Params{IbcPacketTimeoutSeconds: 100}, }, valid: true, }, diff --git a/x/zoneconcierge/types/keys.go b/x/zoneconcierge/types/keys.go index ce3e1c2e3..b8b2bc1da 100644 --- a/x/zoneconcierge/types/keys.go +++ b/x/zoneconcierge/types/keys.go @@ -1,5 +1,9 @@ package types +import ( + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" +) + const ( // ModuleName defines the module name ModuleName = "zoneconcierge" @@ -16,17 +20,22 @@ const ( // Version defines the current version the IBC module supports Version = "zoneconcierge-1" + // Ordering defines the ordering the IBC module supports + Ordering = channeltypes.ORDERED + // PortID is the default port id that module binds to PortID = "zoneconcierge" ) var ( - PortKey = []byte{0x11} // PortKey defines the key to store the port ID in store - ChainInfoKey = []byte{0x12} // ChainInfoKey defines the key to store the chain info for each CZ in store - CanonicalChainKey = []byte{0x13} // CanonicalChainKey defines the key to store the canonical chain for each CZ in store - ForkKey = []byte{0x14} // ForkKey defines the key to store the forks for each CZ in store - EpochChainInfoKey = []byte{0x15} // EpochChainInfoKey defines the key to store each epoch's latests chain info for each CZ in store - FinalizedEpochKey = []byte{0x16} // FinalizedEpochKey defines the key to store the last finalised epoch + PortKey = []byte{0x11} // PortKey defines the key to store the port ID in store + ChainInfoKey = []byte{0x12} // ChainInfoKey defines the key to store the chain info for each CZ in store + CanonicalChainKey = []byte{0x13} // CanonicalChainKey defines the key to store the canonical chain for each CZ in store + ForkKey = []byte{0x14} // ForkKey defines the key to store the forks for each CZ in store + EpochChainInfoKey = []byte{0x15} // EpochChainInfoKey defines the key to store each epoch's latests chain info for each CZ in store + FinalizedEpochKey = []byte{0x16} // FinalizedEpochKey defines the key to store the last finalised epoch + FinalizingBTCTipKey = []byte{0x17} // FinalizingBTCTipKey defines the key to store the BTC tip when the last epoch is finalised + ParamsKey = []byte{0x18} // key prefix for the parameters ) func KeyPrefix(p string) []byte { diff --git a/x/zoneconcierge/types/mocked_keepers.go b/x/zoneconcierge/types/mocked_keepers.go index 1e3dbed9d..8cd850397 100644 --- a/x/zoneconcierge/types/mocked_keepers.go +++ b/x/zoneconcierge/types/mocked_keepers.go @@ -9,17 +9,19 @@ import ( reflect "reflect" types "github.com/babylonchain/babylon/x/btccheckpoint/types" - types0 "github.com/babylonchain/babylon/x/checkpointing/types" - types1 "github.com/babylonchain/babylon/x/epoching/types" - types2 "github.com/cosmos/cosmos-sdk/types" - types3 "github.com/cosmos/cosmos-sdk/x/auth/types" - types4 "github.com/cosmos/cosmos-sdk/x/capability/types" - types5 "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - types6 "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - exported "github.com/cosmos/ibc-go/v7/modules/core/exported" - gomock "github.com/golang/mock/gomock" + types0 "github.com/babylonchain/babylon/x/btclightclient/types" + types1 "github.com/babylonchain/babylon/x/checkpointing/types" + types2 "github.com/babylonchain/babylon/x/epoching/types" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" coretypes "github.com/cometbft/cometbft/rpc/core/types" + types3 "github.com/cosmos/cosmos-sdk/types" + types4 "github.com/cosmos/cosmos-sdk/x/auth/types" + types5 "github.com/cosmos/cosmos-sdk/x/capability/types" + types6 "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + types7 "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" + types8 "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + exported "github.com/cosmos/ibc-go/v7/modules/core/exported" + gomock "github.com/golang/mock/gomock" ) // MockAccountKeeper is a mock of AccountKeeper interface. @@ -46,10 +48,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types2.Context, name string) types3.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types3.Context, name string) types4.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) - ret0, _ := ret[0].(types3.ModuleAccountI) + ret0, _ := ret[0].(types4.ModuleAccountI) return ret0 } @@ -60,10 +62,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, name interface{}) } // GetModuleAddress mocks base method. -func (m *MockAccountKeeper) GetModuleAddress(name string) types2.AccAddress { +func (m *MockAccountKeeper) GetModuleAddress(name string) types3.AccAddress { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAddress", name) - ret0, _ := ret[0].(types2.AccAddress) + ret0, _ := ret[0].(types3.AccAddress) return ret0 } @@ -97,7 +99,7 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { } // BlockedAddr mocks base method. -func (m *MockBankKeeper) BlockedAddr(addr types2.AccAddress) bool { +func (m *MockBankKeeper) BlockedAddr(addr types3.AccAddress) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BlockedAddr", addr) ret0, _ := ret[0].(bool) @@ -111,7 +113,7 @@ func (mr *MockBankKeeperMockRecorder) BlockedAddr(addr interface{}) *gomock.Call } // BurnCoins mocks base method. -func (m *MockBankKeeper) BurnCoins(ctx types2.Context, moduleName string, amt types2.Coins) error { +func (m *MockBankKeeper) BurnCoins(ctx types3.Context, moduleName string, amt types3.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BurnCoins", ctx, moduleName, amt) ret0, _ := ret[0].(error) @@ -125,7 +127,7 @@ func (mr *MockBankKeeperMockRecorder) BurnCoins(ctx, moduleName, amt interface{} } // MintCoins mocks base method. -func (m *MockBankKeeper) MintCoins(ctx types2.Context, moduleName string, amt types2.Coins) error { +func (m *MockBankKeeper) MintCoins(ctx types3.Context, moduleName string, amt types3.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MintCoins", ctx, moduleName, amt) ret0, _ := ret[0].(error) @@ -139,7 +141,7 @@ func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{} } // SendCoins mocks base method. -func (m *MockBankKeeper) SendCoins(ctx types2.Context, fromAddr, toAddr types2.AccAddress, amt types2.Coins) error { +func (m *MockBankKeeper) SendCoins(ctx types3.Context, fromAddr, toAddr types3.AccAddress, amt types3.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoins", ctx, fromAddr, toAddr, amt) ret0, _ := ret[0].(error) @@ -153,7 +155,7 @@ func (mr *MockBankKeeperMockRecorder) SendCoins(ctx, fromAddr, toAddr, amt inter } // SendCoinsFromAccountToModule mocks base method. -func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types2.Context, senderAddr types2.AccAddress, recipientModule string, amt types2.Coins) error { +func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types3.Context, senderAddr types3.AccAddress, recipientModule string, amt types3.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) ret0, _ := ret[0].(error) @@ -167,7 +169,7 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAd } // SendCoinsFromModuleToAccount mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types2.Context, senderModule string, recipientAddr types2.AccAddress, amt types2.Coins) error { +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types3.Context, senderModule string, recipientAddr types3.AccAddress, amt types3.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) ret0, _ := ret[0].(error) @@ -204,17 +206,18 @@ func (m *MockICS4Wrapper) EXPECT() *MockICS4WrapperMockRecorder { } // SendPacket mocks base method. -func (m *MockICS4Wrapper) SendPacket(ctx types2.Context, channelCap *types4.Capability, packet exported.PacketI) error { +func (m *MockICS4Wrapper) SendPacket(ctx types3.Context, channelCap *types5.Capability, sourcePort, sourceChannel string, timeoutHeight types6.Height, timeoutTimestamp uint64, data []byte) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendPacket", ctx, channelCap, packet) - ret0, _ := ret[0].(error) - return ret0 + ret := m.ctrl.Call(m, "SendPacket", ctx, channelCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 } // SendPacket indicates an expected call of SendPacket. -func (mr *MockICS4WrapperMockRecorder) SendPacket(ctx, channelCap, packet interface{}) *gomock.Call { +func (mr *MockICS4WrapperMockRecorder) SendPacket(ctx, channelCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendPacket", reflect.TypeOf((*MockICS4Wrapper)(nil).SendPacket), ctx, channelCap, packet) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendPacket", reflect.TypeOf((*MockICS4Wrapper)(nil).SendPacket), ctx, channelCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } // MockChannelKeeper is a mock of ChannelKeeper interface. @@ -241,10 +244,10 @@ func (m *MockChannelKeeper) EXPECT() *MockChannelKeeperMockRecorder { } // GetAllChannels mocks base method. -func (m *MockChannelKeeper) GetAllChannels(ctx types2.Context) []types6.IdentifiedChannel { +func (m *MockChannelKeeper) GetAllChannels(ctx types3.Context) []types8.IdentifiedChannel { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllChannels", ctx) - ret0, _ := ret[0].([]types6.IdentifiedChannel) + ret0, _ := ret[0].([]types8.IdentifiedChannel) return ret0 } @@ -255,10 +258,10 @@ func (mr *MockChannelKeeperMockRecorder) GetAllChannels(ctx interface{}) *gomock } // GetChannel mocks base method. -func (m *MockChannelKeeper) GetChannel(ctx types2.Context, srcPort, srcChan string) (types6.Channel, bool) { +func (m *MockChannelKeeper) GetChannel(ctx types3.Context, srcPort, srcChan string) (types8.Channel, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetChannel", ctx, srcPort, srcChan) - ret0, _ := ret[0].(types6.Channel) + ret0, _ := ret[0].(types8.Channel) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -269,8 +272,24 @@ func (mr *MockChannelKeeperMockRecorder) GetChannel(ctx, srcPort, srcChan interf return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChannel", reflect.TypeOf((*MockChannelKeeper)(nil).GetChannel), ctx, srcPort, srcChan) } +// GetChannelClientState mocks base method. +func (m *MockChannelKeeper) GetChannelClientState(ctx types3.Context, portID, channelID string) (string, exported.ClientState, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetChannelClientState", ctx, portID, channelID) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(exported.ClientState) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetChannelClientState indicates an expected call of GetChannelClientState. +func (mr *MockChannelKeeperMockRecorder) GetChannelClientState(ctx, portID, channelID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChannelClientState", reflect.TypeOf((*MockChannelKeeper)(nil).GetChannelClientState), ctx, portID, channelID) +} + // GetNextSequenceSend mocks base method. -func (m *MockChannelKeeper) GetNextSequenceSend(ctx types2.Context, portID, channelID string) (uint64, bool) { +func (m *MockChannelKeeper) GetNextSequenceSend(ctx types3.Context, portID, channelID string) (uint64, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetNextSequenceSend", ctx, portID, channelID) ret0, _ := ret[0].(uint64) @@ -308,7 +327,7 @@ func (m *MockClientKeeper) EXPECT() *MockClientKeeperMockRecorder { } // GetClientConsensusState mocks base method. -func (m *MockClientKeeper) GetClientConsensusState(ctx types2.Context, clientID string) (exported.ConsensusState, bool) { +func (m *MockClientKeeper) GetClientConsensusState(ctx types3.Context, clientID string) (exported.ConsensusState, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetClientConsensusState", ctx, clientID) ret0, _ := ret[0].(exported.ConsensusState) @@ -346,10 +365,10 @@ func (m *MockConnectionKeeper) EXPECT() *MockConnectionKeeperMockRecorder { } // GetConnection mocks base method. -func (m *MockConnectionKeeper) GetConnection(ctx types2.Context, connectionID string) (types5.ConnectionEnd, bool) { +func (m *MockConnectionKeeper) GetConnection(ctx types3.Context, connectionID string) (types7.ConnectionEnd, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetConnection", ctx, connectionID) - ret0, _ := ret[0].(types5.ConnectionEnd) + ret0, _ := ret[0].(types7.ConnectionEnd) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -384,10 +403,10 @@ func (m *MockPortKeeper) EXPECT() *MockPortKeeperMockRecorder { } // BindPort mocks base method. -func (m *MockPortKeeper) BindPort(ctx types2.Context, portID string) *types4.Capability { +func (m *MockPortKeeper) BindPort(ctx types3.Context, portID string) *types5.Capability { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BindPort", ctx, portID) - ret0, _ := ret[0].(*types4.Capability) + ret0, _ := ret[0].(*types5.Capability) return ret0 } @@ -421,7 +440,7 @@ func (m *MockScopedKeeper) EXPECT() *MockScopedKeeperMockRecorder { } // AuthenticateCapability mocks base method. -func (m *MockScopedKeeper) AuthenticateCapability(ctx types2.Context, cap *types4.Capability, name string) bool { +func (m *MockScopedKeeper) AuthenticateCapability(ctx types3.Context, cap *types5.Capability, name string) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AuthenticateCapability", ctx, cap, name) ret0, _ := ret[0].(bool) @@ -435,7 +454,7 @@ func (mr *MockScopedKeeperMockRecorder) AuthenticateCapability(ctx, cap, name in } // ClaimCapability mocks base method. -func (m *MockScopedKeeper) ClaimCapability(ctx types2.Context, cap *types4.Capability, name string) error { +func (m *MockScopedKeeper) ClaimCapability(ctx types3.Context, cap *types5.Capability, name string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ClaimCapability", ctx, cap, name) ret0, _ := ret[0].(error) @@ -449,10 +468,10 @@ func (mr *MockScopedKeeperMockRecorder) ClaimCapability(ctx, cap, name interface } // GetCapability mocks base method. -func (m *MockScopedKeeper) GetCapability(ctx types2.Context, name string) (*types4.Capability, bool) { +func (m *MockScopedKeeper) GetCapability(ctx types3.Context, name string) (*types5.Capability, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCapability", ctx, name) - ret0, _ := ret[0].(*types4.Capability) + ret0, _ := ret[0].(*types5.Capability) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -464,11 +483,11 @@ func (mr *MockScopedKeeperMockRecorder) GetCapability(ctx, name interface{}) *go } // LookupModules mocks base method. -func (m *MockScopedKeeper) LookupModules(ctx types2.Context, name string) ([]string, *types4.Capability, error) { +func (m *MockScopedKeeper) LookupModules(ctx types3.Context, name string) ([]string, *types5.Capability, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LookupModules", ctx, name) ret0, _ := ret[0].([]string) - ret1, _ := ret[1].(*types4.Capability) + ret1, _ := ret[1].(*types5.Capability) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } @@ -479,6 +498,99 @@ func (mr *MockScopedKeeperMockRecorder) LookupModules(ctx, name interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupModules", reflect.TypeOf((*MockScopedKeeper)(nil).LookupModules), ctx, name) } +// MockBTCLightClientKeeper is a mock of BTCLightClientKeeper interface. +type MockBTCLightClientKeeper struct { + ctrl *gomock.Controller + recorder *MockBTCLightClientKeeperMockRecorder +} + +// MockBTCLightClientKeeperMockRecorder is the mock recorder for MockBTCLightClientKeeper. +type MockBTCLightClientKeeperMockRecorder struct { + mock *MockBTCLightClientKeeper +} + +// NewMockBTCLightClientKeeper creates a new mock instance. +func NewMockBTCLightClientKeeper(ctrl *gomock.Controller) *MockBTCLightClientKeeper { + mock := &MockBTCLightClientKeeper{ctrl: ctrl} + mock.recorder = &MockBTCLightClientKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBTCLightClientKeeper) EXPECT() *MockBTCLightClientKeeperMockRecorder { + return m.recorder +} + +// GetBaseBTCHeader mocks base method. +func (m *MockBTCLightClientKeeper) GetBaseBTCHeader(ctx types3.Context) *types0.BTCHeaderInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBaseBTCHeader", ctx) + ret0, _ := ret[0].(*types0.BTCHeaderInfo) + return ret0 +} + +// GetBaseBTCHeader indicates an expected call of GetBaseBTCHeader. +func (mr *MockBTCLightClientKeeperMockRecorder) GetBaseBTCHeader(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBaseBTCHeader", reflect.TypeOf((*MockBTCLightClientKeeper)(nil).GetBaseBTCHeader), ctx) +} + +// GetHighestCommonAncestor mocks base method. +func (m *MockBTCLightClientKeeper) GetHighestCommonAncestor(ctx types3.Context, header1, header2 *types0.BTCHeaderInfo) *types0.BTCHeaderInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetHighestCommonAncestor", ctx, header1, header2) + ret0, _ := ret[0].(*types0.BTCHeaderInfo) + return ret0 +} + +// GetHighestCommonAncestor indicates an expected call of GetHighestCommonAncestor. +func (mr *MockBTCLightClientKeeperMockRecorder) GetHighestCommonAncestor(ctx, header1, header2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHighestCommonAncestor", reflect.TypeOf((*MockBTCLightClientKeeper)(nil).GetHighestCommonAncestor), ctx, header1, header2) +} + +// GetInOrderAncestorsUntil mocks base method. +func (m *MockBTCLightClientKeeper) GetInOrderAncestorsUntil(ctx types3.Context, descendant, ancestor *types0.BTCHeaderInfo) []*types0.BTCHeaderInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetInOrderAncestorsUntil", ctx, descendant, ancestor) + ret0, _ := ret[0].([]*types0.BTCHeaderInfo) + return ret0 +} + +// GetInOrderAncestorsUntil indicates an expected call of GetInOrderAncestorsUntil. +func (mr *MockBTCLightClientKeeperMockRecorder) GetInOrderAncestorsUntil(ctx, descendant, ancestor interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInOrderAncestorsUntil", reflect.TypeOf((*MockBTCLightClientKeeper)(nil).GetInOrderAncestorsUntil), ctx, descendant, ancestor) +} + +// GetMainChainUpTo mocks base method. +func (m *MockBTCLightClientKeeper) GetMainChainUpTo(ctx types3.Context, depth uint64) []*types0.BTCHeaderInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMainChainUpTo", ctx, depth) + ret0, _ := ret[0].([]*types0.BTCHeaderInfo) + return ret0 +} + +// GetMainChainUpTo indicates an expected call of GetMainChainUpTo. +func (mr *MockBTCLightClientKeeperMockRecorder) GetMainChainUpTo(ctx, depth interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMainChainUpTo", reflect.TypeOf((*MockBTCLightClientKeeper)(nil).GetMainChainUpTo), ctx, depth) +} + +// GetTipInfo mocks base method. +func (m *MockBTCLightClientKeeper) GetTipInfo(ctx types3.Context) *types0.BTCHeaderInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTipInfo", ctx) + ret0, _ := ret[0].(*types0.BTCHeaderInfo) + return ret0 +} + +// GetTipInfo indicates an expected call of GetTipInfo. +func (mr *MockBTCLightClientKeeperMockRecorder) GetTipInfo(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTipInfo", reflect.TypeOf((*MockBTCLightClientKeeper)(nil).GetTipInfo), ctx) +} + // MockBtcCheckpointKeeper is a mock of BtcCheckpointKeeper interface. type MockBtcCheckpointKeeper struct { ctrl *gomock.Controller @@ -503,7 +615,7 @@ func (m *MockBtcCheckpointKeeper) EXPECT() *MockBtcCheckpointKeeperMockRecorder } // GetBestSubmission mocks base method. -func (m *MockBtcCheckpointKeeper) GetBestSubmission(ctx types2.Context, e uint64) (types.BtcStatus, *types.SubmissionKey, error) { +func (m *MockBtcCheckpointKeeper) GetBestSubmission(ctx types3.Context, e uint64) (types.BtcStatus, *types.SubmissionKey, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBestSubmission", ctx, e) ret0, _ := ret[0].(types.BtcStatus) @@ -518,8 +630,50 @@ func (mr *MockBtcCheckpointKeeperMockRecorder) GetBestSubmission(ctx, e interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBestSubmission", reflect.TypeOf((*MockBtcCheckpointKeeper)(nil).GetBestSubmission), ctx, e) } +// GetEpochBestSubmissionBtcInfo mocks base method. +func (m *MockBtcCheckpointKeeper) GetEpochBestSubmissionBtcInfo(ctx types3.Context, ed *types.EpochData) *types.SubmissionBtcInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEpochBestSubmissionBtcInfo", ctx, ed) + ret0, _ := ret[0].(*types.SubmissionBtcInfo) + return ret0 +} + +// GetEpochBestSubmissionBtcInfo indicates an expected call of GetEpochBestSubmissionBtcInfo. +func (mr *MockBtcCheckpointKeeperMockRecorder) GetEpochBestSubmissionBtcInfo(ctx, ed interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEpochBestSubmissionBtcInfo", reflect.TypeOf((*MockBtcCheckpointKeeper)(nil).GetEpochBestSubmissionBtcInfo), ctx, ed) +} + +// GetEpochData mocks base method. +func (m *MockBtcCheckpointKeeper) GetEpochData(ctx types3.Context, e uint64) *types.EpochData { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEpochData", ctx, e) + ret0, _ := ret[0].(*types.EpochData) + return ret0 +} + +// GetEpochData indicates an expected call of GetEpochData. +func (mr *MockBtcCheckpointKeeperMockRecorder) GetEpochData(ctx, e interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEpochData", reflect.TypeOf((*MockBtcCheckpointKeeper)(nil).GetEpochData), ctx, e) +} + +// GetParams mocks base method. +func (m *MockBtcCheckpointKeeper) GetParams(ctx types3.Context) types.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetParams", ctx) + ret0, _ := ret[0].(types.Params) + return ret0 +} + +// GetParams indicates an expected call of GetParams. +func (mr *MockBtcCheckpointKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockBtcCheckpointKeeper)(nil).GetParams), ctx) +} + // GetSubmissionData mocks base method. -func (m *MockBtcCheckpointKeeper) GetSubmissionData(ctx types2.Context, sk types.SubmissionKey) *types.SubmissionData { +func (m *MockBtcCheckpointKeeper) GetSubmissionData(ctx types3.Context, sk types.SubmissionKey) *types.SubmissionData { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSubmissionData", ctx, sk) ret0, _ := ret[0].(*types.SubmissionData) @@ -556,10 +710,10 @@ func (m *MockCheckpointingKeeper) EXPECT() *MockCheckpointingKeeperMockRecorder } // GetBLSPubKeySet mocks base method. -func (m *MockCheckpointingKeeper) GetBLSPubKeySet(ctx types2.Context, epochNumber uint64) ([]*types0.ValidatorWithBlsKey, error) { +func (m *MockCheckpointingKeeper) GetBLSPubKeySet(ctx types3.Context, epochNumber uint64) ([]*types1.ValidatorWithBlsKey, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBLSPubKeySet", ctx, epochNumber) - ret0, _ := ret[0].([]*types0.ValidatorWithBlsKey) + ret0, _ := ret[0].([]*types1.ValidatorWithBlsKey) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -571,10 +725,10 @@ func (mr *MockCheckpointingKeeperMockRecorder) GetBLSPubKeySet(ctx, epochNumber } // GetRawCheckpoint mocks base method. -func (m *MockCheckpointingKeeper) GetRawCheckpoint(ctx types2.Context, epochNumber uint64) (*types0.RawCheckpointWithMeta, error) { +func (m *MockCheckpointingKeeper) GetRawCheckpoint(ctx types3.Context, epochNumber uint64) (*types1.RawCheckpointWithMeta, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetRawCheckpoint", ctx, epochNumber) - ret0, _ := ret[0].(*types0.RawCheckpointWithMeta) + ret0, _ := ret[0].(*types1.RawCheckpointWithMeta) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -609,10 +763,10 @@ func (m *MockEpochingKeeper) EXPECT() *MockEpochingKeeperMockRecorder { } // GetEpoch mocks base method. -func (m *MockEpochingKeeper) GetEpoch(ctx types2.Context) *types1.Epoch { +func (m *MockEpochingKeeper) GetEpoch(ctx types3.Context) *types2.Epoch { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetEpoch", ctx) - ret0, _ := ret[0].(*types1.Epoch) + ret0, _ := ret[0].(*types2.Epoch) return ret0 } @@ -623,10 +777,10 @@ func (mr *MockEpochingKeeperMockRecorder) GetEpoch(ctx interface{}) *gomock.Call } // GetHistoricalEpoch mocks base method. -func (m *MockEpochingKeeper) GetHistoricalEpoch(ctx types2.Context, epochNumber uint64) (*types1.Epoch, error) { +func (m *MockEpochingKeeper) GetHistoricalEpoch(ctx types3.Context, epochNumber uint64) (*types2.Epoch, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetHistoricalEpoch", ctx, epochNumber) - ret0, _ := ret[0].(*types1.Epoch) + ret0, _ := ret[0].(*types2.Epoch) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -638,7 +792,7 @@ func (mr *MockEpochingKeeperMockRecorder) GetHistoricalEpoch(ctx, epochNumber in } // ProveAppHashInEpoch mocks base method. -func (m *MockEpochingKeeper) ProveAppHashInEpoch(ctx types2.Context, height, epochNumber uint64) (*crypto.Proof, error) { +func (m *MockEpochingKeeper) ProveAppHashInEpoch(ctx types3.Context, height, epochNumber uint64) (*crypto.Proof, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ProveAppHashInEpoch", ctx, height, epochNumber) ret0, _ := ret[0].(*crypto.Proof) diff --git a/x/zoneconcierge/types/msg.go b/x/zoneconcierge/types/msg.go new file mode 100644 index 000000000..fadaf538a --- /dev/null +++ b/x/zoneconcierge/types/msg.go @@ -0,0 +1,30 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ensure that these message types implement the sdk.Msg interface +var ( + _ sdk.Msg = &MsgUpdateParams{} +) + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data. +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errorsmod.Wrap(err, "invalid authority address") + } + + if err := m.Params.Validate(); err != nil { + return err + } + + return nil +} diff --git a/x/zoneconcierge/types/packet.pb.go b/x/zoneconcierge/types/packet.pb.go index 1f2bb92a2..d2f44c32e 100644 --- a/x/zoneconcierge/types/packet.pb.go +++ b/x/zoneconcierge/types/packet.pb.go @@ -5,6 +5,10 @@ package types import ( fmt "fmt" + types3 "github.com/babylonchain/babylon/x/btccheckpoint/types" + types "github.com/babylonchain/babylon/x/btclightclient/types" + types2 "github.com/babylonchain/babylon/x/checkpointing/types" + types1 "github.com/babylonchain/babylon/x/epoching/types" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -28,8 +32,7 @@ type ZoneconciergePacketData struct { // packet is the actual message carried in the IBC packet // // Types that are valid to be assigned to Packet: - // - // *ZoneconciergePacketData_Heartbeart + // *ZoneconciergePacketData_BtcTimestamp Packet isZoneconciergePacketData_Packet `protobuf_oneof:"packet"` } @@ -72,11 +75,11 @@ type isZoneconciergePacketData_Packet interface { Size() int } -type ZoneconciergePacketData_Heartbeart struct { - Heartbeart *Heartbeat `protobuf:"bytes,1,opt,name=heartbeart,proto3,oneof" json:"heartbeart,omitempty"` +type ZoneconciergePacketData_BtcTimestamp struct { + BtcTimestamp *BTCTimestamp `protobuf:"bytes,1,opt,name=btc_timestamp,json=btcTimestamp,proto3,oneof" json:"btc_timestamp,omitempty"` } -func (*ZoneconciergePacketData_Heartbeart) isZoneconciergePacketData_Packet() {} +func (*ZoneconciergePacketData_BtcTimestamp) isZoneconciergePacketData_Packet() {} func (m *ZoneconciergePacketData) GetPacket() isZoneconciergePacketData_Packet { if m != nil { @@ -85,9 +88,9 @@ func (m *ZoneconciergePacketData) GetPacket() isZoneconciergePacketData_Packet { return nil } -func (m *ZoneconciergePacketData) GetHeartbeart() *Heartbeat { - if x, ok := m.GetPacket().(*ZoneconciergePacketData_Heartbeart); ok { - return x.Heartbeart +func (m *ZoneconciergePacketData) GetBtcTimestamp() *BTCTimestamp { + if x, ok := m.GetPacket().(*ZoneconciergePacketData_BtcTimestamp); ok { + return x.BtcTimestamp } return nil } @@ -95,28 +98,46 @@ func (m *ZoneconciergePacketData) GetHeartbeart() *Heartbeat { // XXX_OneofWrappers is for the internal use of the proto package. func (*ZoneconciergePacketData) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*ZoneconciergePacketData_Heartbeart)(nil), + (*ZoneconciergePacketData_BtcTimestamp)(nil), } } -// Heartbeat is a heartbeat message that can be carried in IBC packets of -// ZoneConcierge -type Heartbeat struct { - Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` +// BTCTimestamp is a BTC timestamp that carries information of a BTC-finalised epoch +// It includes a number of BTC headers, a raw checkpoint, an epoch metadata, and +// a CZ header if there exists CZ headers checkpointed to this epoch. +// Upon a newly finalised epoch in Babylon, Babylon will send a BTC timestamp to each +// Cosmos zone that has phase-2 integration with Babylon via IBC. +type BTCTimestamp struct { + // header is the last CZ header in the finalized Babylon epoch + Header *IndexedHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + // btc_headers is BTC headers between + // - the block AFTER the common ancestor of BTC tip at epoch `lastFinalizedEpoch-1` and BTC tip at epoch `lastFinalizedEpoch` + // - BTC tip at epoch `lastFinalizedEpoch` + // where `lastFinalizedEpoch` is the last finalised epoch in Babylon + BtcHeaders []*types.BTCHeaderInfo `protobuf:"bytes,2,rep,name=btc_headers,json=btcHeaders,proto3" json:"btc_headers,omitempty"` + // epoch_info is the metadata of the sealed epoch + EpochInfo *types1.Epoch `protobuf:"bytes,3,opt,name=epoch_info,json=epochInfo,proto3" json:"epoch_info,omitempty"` + // raw_checkpoint is the raw checkpoint that seals this epoch + RawCheckpoint *types2.RawCheckpoint `protobuf:"bytes,4,opt,name=raw_checkpoint,json=rawCheckpoint,proto3" json:"raw_checkpoint,omitempty"` + // btc_submission_key is position of two BTC txs that include the raw checkpoint of this epoch + BtcSubmissionKey *types3.SubmissionKey `protobuf:"bytes,5,opt,name=btc_submission_key,json=btcSubmissionKey,proto3" json:"btc_submission_key,omitempty"` + // + // Proofs that the header is finalized + Proof *ProofFinalizedChainInfo `protobuf:"bytes,6,opt,name=proof,proto3" json:"proof,omitempty"` } -func (m *Heartbeat) Reset() { *m = Heartbeat{} } -func (m *Heartbeat) String() string { return proto.CompactTextString(m) } -func (*Heartbeat) ProtoMessage() {} -func (*Heartbeat) Descriptor() ([]byte, []int) { +func (m *BTCTimestamp) Reset() { *m = BTCTimestamp{} } +func (m *BTCTimestamp) String() string { return proto.CompactTextString(m) } +func (*BTCTimestamp) ProtoMessage() {} +func (*BTCTimestamp) Descriptor() ([]byte, []int) { return fileDescriptor_be12e124c5c4fdb9, []int{1} } -func (m *Heartbeat) XXX_Unmarshal(b []byte) error { +func (m *BTCTimestamp) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Heartbeat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCTimestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Heartbeat.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCTimestamp.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -126,28 +147,63 @@ func (m *Heartbeat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *Heartbeat) XXX_Merge(src proto.Message) { - xxx_messageInfo_Heartbeat.Merge(m, src) +func (m *BTCTimestamp) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCTimestamp.Merge(m, src) } -func (m *Heartbeat) XXX_Size() int { +func (m *BTCTimestamp) XXX_Size() int { return m.Size() } -func (m *Heartbeat) XXX_DiscardUnknown() { - xxx_messageInfo_Heartbeat.DiscardUnknown(m) +func (m *BTCTimestamp) XXX_DiscardUnknown() { + xxx_messageInfo_BTCTimestamp.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCTimestamp proto.InternalMessageInfo + +func (m *BTCTimestamp) GetHeader() *IndexedHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *BTCTimestamp) GetBtcHeaders() []*types.BTCHeaderInfo { + if m != nil { + return m.BtcHeaders + } + return nil +} + +func (m *BTCTimestamp) GetEpochInfo() *types1.Epoch { + if m != nil { + return m.EpochInfo + } + return nil +} + +func (m *BTCTimestamp) GetRawCheckpoint() *types2.RawCheckpoint { + if m != nil { + return m.RawCheckpoint + } + return nil } -var xxx_messageInfo_Heartbeat proto.InternalMessageInfo +func (m *BTCTimestamp) GetBtcSubmissionKey() *types3.SubmissionKey { + if m != nil { + return m.BtcSubmissionKey + } + return nil +} -func (m *Heartbeat) GetMsg() string { +func (m *BTCTimestamp) GetProof() *ProofFinalizedChainInfo { if m != nil { - return m.Msg + return m.Proof } - return "" + return nil } func init() { proto.RegisterType((*ZoneconciergePacketData)(nil), "babylon.zoneconcierge.v1.ZoneconciergePacketData") - proto.RegisterType((*Heartbeat)(nil), "babylon.zoneconcierge.v1.Heartbeat") + proto.RegisterType((*BTCTimestamp)(nil), "babylon.zoneconcierge.v1.BTCTimestamp") } func init() { @@ -155,21 +211,37 @@ func init() { } var fileDescriptor_be12e124c5c4fdb9 = []byte{ - // 209 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, 0x4c, 0xce, 0x4e, 0x2d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x92, 0x80, 0x2a, 0xd3, 0x43, 0x51, 0xa6, 0x57, 0x66, 0xa8, 0x94, 0xc5, 0x25, 0x1e, - 0x85, 0x2c, 0x16, 0x00, 0xd6, 0xe6, 0x92, 0x58, 0x92, 0x28, 0xe4, 0xca, 0xc5, 0x95, 0x91, 0x9a, - 0x58, 0x54, 0x92, 0x04, 0x22, 0x24, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x94, 0xf5, 0x70, 0x99, - 0xa4, 0xe7, 0x01, 0x55, 0x5b, 0xe2, 0xc1, 0x10, 0x84, 0xa4, 0xd1, 0x89, 0x83, 0x8b, 0x0d, 0xe2, - 0x16, 0x25, 0x59, 0x2e, 0x4e, 0xb8, 0x22, 0x21, 0x01, 0x2e, 0xe6, 0xdc, 0xe2, 0x74, 0xb0, 0xb1, - 0x9c, 0x41, 0x20, 0xa6, 0x93, 0xff, 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, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xed, 0x4f, 0xce, - 0x48, 0xcc, 0xcc, 0x83, 0x71, 0xf4, 0x2b, 0xd0, 0xfc, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, - 0x06, 0xf6, 0xbc, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xe0, 0xc6, 0x63, 0x3e, 0x25, 0x01, 0x00, - 0x00, + // 471 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x1b, 0xca, 0x2a, 0x70, 0x37, 0x84, 0x7c, 0x21, 0xda, 0x21, 0x9a, 0x2a, 0x01, 0x45, + 0x9a, 0x1c, 0x65, 0x88, 0x03, 0x27, 0xa4, 0x96, 0x3f, 0xab, 0x10, 0x30, 0x85, 0x71, 0xd9, 0xa5, + 0xb2, 0xdd, 0xb7, 0x8d, 0xd5, 0xd6, 0x8e, 0x12, 0xaf, 0x5b, 0xf7, 0x29, 0xf8, 0x52, 0x48, 0x1c, + 0x77, 0xe4, 0x88, 0xda, 0x2f, 0x82, 0xec, 0xfc, 0x69, 0x52, 0x94, 0x4b, 0xe4, 0xf7, 0xc9, 0xcf, + 0x8f, 0xfd, 0x3e, 0x7e, 0xd1, 0x73, 0x46, 0xd9, 0x7a, 0xa1, 0xa4, 0x7f, 0xa7, 0x24, 0x70, 0x25, + 0xb9, 0x80, 0x64, 0x06, 0xfe, 0x2a, 0xf0, 0x63, 0xca, 0xe7, 0xa0, 0x49, 0x9c, 0x28, 0xad, 0xb0, + 0x9b, 0x63, 0xa4, 0x86, 0x91, 0x55, 0x70, 0x7c, 0x5a, 0x18, 0x30, 0xcd, 0x79, 0x04, 0x7c, 0x1e, + 0x2b, 0x21, 0xb5, 0x31, 0xa8, 0x09, 0x99, 0xcf, 0xf1, 0xab, 0x82, 0xde, 0xfd, 0x11, 0x72, 0x66, + 0xe8, 0xff, 0x50, 0x52, 0x31, 0x5e, 0x88, 0x59, 0x64, 0xbe, 0x50, 0x3a, 0x57, 0x94, 0x9c, 0xef, + 0x15, 0x3c, 0xc4, 0x8a, 0x47, 0xb9, 0x6b, 0xb1, 0xce, 0x99, 0xd3, 0xc6, 0x6e, 0xeb, 0x7d, 0x59, + 0xba, 0x97, 0xa0, 0x67, 0x57, 0x55, 0xf9, 0xc2, 0x26, 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, + 0xff, 0x0c, 0xeb, 0xf0, 0x29, 0xd3, 0xbc, 0xa6, 0xe0, 0x4f, 0xe8, 0x20, 0x4e, 0x94, 0x9a, 0xba, + 0x1d, 0xeb, 0x14, 0x34, 0x87, 0x7d, 0x61, 0xb0, 0x8f, 0x42, 0xd2, 0x85, 0xb8, 0x83, 0xc9, 0x30, + 0xa2, 0x42, 0xda, 0xbc, 0xb2, 0xfd, 0x83, 0x6f, 0xbf, 0x37, 0x9e, 0x73, 0xbf, 0xf1, 0x9c, 0xbf, + 0x1b, 0xcf, 0xf9, 0xb9, 0xf5, 0x5a, 0xf7, 0x5b, 0xaf, 0xf5, 0x67, 0xeb, 0xb5, 0xae, 0xde, 0xcc, + 0x84, 0x8e, 0xae, 0x19, 0xe1, 0x6a, 0xe9, 0xe7, 0xee, 0xdc, 0xec, 0x2e, 0x0a, 0xff, 0x76, 0x6f, + 0x3a, 0xf5, 0x3a, 0x86, 0x94, 0x75, 0xec, 0x4c, 0xbe, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x31, + 0xea, 0x29, 0xbc, 0xb1, 0x03, 0x00, 0x00, } func (m *ZoneconciergePacketData) Marshal() (dAtA []byte, err error) { @@ -204,16 +276,16 @@ func (m *ZoneconciergePacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *ZoneconciergePacketData_Heartbeart) MarshalTo(dAtA []byte) (int, error) { +func (m *ZoneconciergePacketData_BtcTimestamp) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ZoneconciergePacketData_Heartbeart) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ZoneconciergePacketData_BtcTimestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - if m.Heartbeart != nil { + if m.BtcTimestamp != nil { { - size, err := m.Heartbeart.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.BtcTimestamp.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -225,7 +297,7 @@ func (m *ZoneconciergePacketData_Heartbeart) MarshalToSizedBuffer(dAtA []byte) ( } return len(dAtA) - i, nil } -func (m *Heartbeat) Marshal() (dAtA []byte, err error) { +func (m *BTCTimestamp) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -235,20 +307,87 @@ func (m *Heartbeat) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Heartbeat) MarshalTo(dAtA []byte) (int, error) { +func (m *BTCTimestamp) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Heartbeat) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BTCTimestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Msg) > 0 { - i -= len(m.Msg) - copy(dAtA[i:], m.Msg) - i = encodeVarintPacket(dAtA, i, uint64(len(m.Msg))) + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.BtcSubmissionKey != nil { + { + size, err := m.BtcSubmissionKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.RawCheckpoint != nil { + { + size, err := m.RawCheckpoint.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.EpochInfo != nil { + { + size, err := m.EpochInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.BtcHeaders) > 0 { + for iNdEx := len(m.BtcHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } @@ -278,26 +417,48 @@ func (m *ZoneconciergePacketData) Size() (n int) { return n } -func (m *ZoneconciergePacketData_Heartbeart) Size() (n int) { +func (m *ZoneconciergePacketData_BtcTimestamp) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Heartbeart != nil { - l = m.Heartbeart.Size() + if m.BtcTimestamp != nil { + l = m.BtcTimestamp.Size() n += 1 + l + sovPacket(uint64(l)) } return n } -func (m *Heartbeat) Size() (n int) { +func (m *BTCTimestamp) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Msg) - if l > 0 { + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovPacket(uint64(l)) + } + if len(m.BtcHeaders) > 0 { + for _, e := range m.BtcHeaders { + l = e.Size() + n += 1 + l + sovPacket(uint64(l)) + } + } + if m.EpochInfo != nil { + l = m.EpochInfo.Size() + n += 1 + l + sovPacket(uint64(l)) + } + if m.RawCheckpoint != nil { + l = m.RawCheckpoint.Size() + n += 1 + l + sovPacket(uint64(l)) + } + if m.BtcSubmissionKey != nil { + l = m.BtcSubmissionKey.Size() + n += 1 + l + sovPacket(uint64(l)) + } + if m.Proof != nil { + l = m.Proof.Size() n += 1 + l + sovPacket(uint64(l)) } return n @@ -340,7 +501,7 @@ func (m *ZoneconciergePacketData) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Heartbeart", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcTimestamp", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -367,11 +528,11 @@ func (m *ZoneconciergePacketData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &Heartbeat{} + v := &BTCTimestamp{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Packet = &ZoneconciergePacketData_Heartbeart{v} + m.Packet = &ZoneconciergePacketData_BtcTimestamp{v} iNdEx = postIndex default: iNdEx = preIndex @@ -394,7 +555,7 @@ func (m *ZoneconciergePacketData) Unmarshal(dAtA []byte) error { } return nil } -func (m *Heartbeat) Unmarshal(dAtA []byte) error { +func (m *BTCTimestamp) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -417,17 +578,17 @@ func (m *Heartbeat) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Heartbeat: wiretype end group for non-group") + return fmt.Errorf("proto: BTCTimestamp: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Heartbeat: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: BTCTimestamp: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPacket @@ -437,23 +598,205 @@ func (m *Heartbeat) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthPacket } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthPacket } if postIndex > l { return io.ErrUnexpectedEOF } - m.Msg = string(dAtA[iNdEx:postIndex]) + if m.Header == nil { + m.Header = &IndexedHeader{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcHeaders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcHeaders = append(m.BtcHeaders, &types.BTCHeaderInfo{}) + if err := m.BtcHeaders[len(m.BtcHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.EpochInfo == nil { + m.EpochInfo = &types1.Epoch{} + } + if err := m.EpochInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawCheckpoint", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RawCheckpoint == nil { + m.RawCheckpoint = &types2.RawCheckpoint{} + } + if err := m.RawCheckpoint.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcSubmissionKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BtcSubmissionKey == nil { + m.BtcSubmissionKey = &types3.SubmissionKey{} + } + if err := m.BtcSubmissionKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proof == nil { + m.Proof = &ProofFinalizedChainInfo{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/zoneconcierge/types/params.go b/x/zoneconcierge/types/params.go new file mode 100644 index 000000000..298ade2a7 --- /dev/null +++ b/x/zoneconcierge/types/params.go @@ -0,0 +1,34 @@ +package types + +import ( + "fmt" +) + +const ( + DefaultIbcPacketTimeoutSeconds uint32 = 60 * 60 * 24 // 24 hours + MaxIbcPacketTimeoutSeconds uint32 = 60 * 60 * 24 * 365 // 1 year +) + +// NewParams creates a new Params instance +func NewParams(ibcPacketTimeoutSeconds uint32) Params { + return Params{ + IbcPacketTimeoutSeconds: ibcPacketTimeoutSeconds, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams(DefaultIbcPacketTimeoutSeconds) +} + +// Validate validates the set of params +func (p Params) Validate() error { + if p.IbcPacketTimeoutSeconds == 0 { + return fmt.Errorf("IbcPacketTimeoutSeconds must be positive") + } + if p.IbcPacketTimeoutSeconds > MaxIbcPacketTimeoutSeconds { + return fmt.Errorf("IbcPacketTimeoutSeconds must be no larger than %d", MaxIbcPacketTimeoutSeconds) + } + + return nil +} diff --git a/x/zoneconcierge/types/params.pb.go b/x/zoneconcierge/types/params.pb.go new file mode 100644 index 000000000..ac4b27c33 --- /dev/null +++ b/x/zoneconcierge/types/params.pb.go @@ -0,0 +1,333 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: babylon/zoneconcierge/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +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"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_c0696c936eb15fe4, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetIbcPacketTimeoutSeconds() uint32 { + if m != nil { + return m.IbcPacketTimeoutSeconds + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "babylon.zoneconcierge.v1.Params") +} + +func init() { + proto.RegisterFile("babylon/zoneconcierge/v1/params.proto", fileDescriptor_c0696c936eb15fe4) +} + +var fileDescriptor_c0696c936eb15fe4 = []byte{ + // 227 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, 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, 0x93, 0xff, 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, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0x92, + 0x9c, 0x91, 0x98, 0x99, 0x07, 0xe3, 0xe8, 0x57, 0xa0, 0x79, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, + 0x89, 0x0d, 0xec, 0x17, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0xf3, 0xe4, 0xef, 0x24, + 0x01, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.IbcPacketTimeoutSeconds != that1.IbcPacketTimeoutSeconds { + return false + } + return true +} +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IbcPacketTimeoutSeconds != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.IbcPacketTimeoutSeconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IbcPacketTimeoutSeconds != 0 { + n += 1 + sovParams(uint64(m.IbcPacketTimeoutSeconds)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcPacketTimeoutSeconds", wireType) + } + m.IbcPacketTimeoutSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.IbcPacketTimeoutSeconds |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/zoneconcierge/types/params_test.go b/x/zoneconcierge/types/params_test.go new file mode 100644 index 000000000..c4be306d0 --- /dev/null +++ b/x/zoneconcierge/types/params_test.go @@ -0,0 +1,21 @@ +package types_test + +import ( + "testing" + + "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/stretchr/testify/require" +) + +func TestParamsEqual(t *testing.T) { + p1 := types.DefaultParams() + p2 := types.DefaultParams() + + ok := p1.Equal(p2) + require.True(t, ok) + + p2.IbcPacketTimeoutSeconds = 100 + + ok = p1.Equal(p2) + require.False(t, ok) +} diff --git a/x/zoneconcierge/types/query.pb.go b/x/zoneconcierge/types/query.pb.go index fa90d6a3d..64d219deb 100644 --- a/x/zoneconcierge/types/query.pb.go +++ b/x/zoneconcierge/types/query.pb.go @@ -10,6 +10,7 @@ import ( types1 "github.com/babylonchain/babylon/x/checkpointing/types" types "github.com/babylonchain/babylon/x/epoching/types" query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -32,6 +33,89 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_cd665af90102da38, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cd665af90102da38, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + // QueryHeaderRequest is request type for the Query/Header RPC method. type QueryHeaderRequest struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -42,7 +126,7 @@ func (m *QueryHeaderRequest) Reset() { *m = QueryHeaderRequest{} } func (m *QueryHeaderRequest) String() string { return proto.CompactTextString(m) } func (*QueryHeaderRequest) ProtoMessage() {} func (*QueryHeaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{0} + return fileDescriptor_cd665af90102da38, []int{2} } func (m *QueryHeaderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -95,7 +179,7 @@ func (m *QueryHeaderResponse) Reset() { *m = QueryHeaderResponse{} } func (m *QueryHeaderResponse) String() string { return proto.CompactTextString(m) } func (*QueryHeaderResponse) ProtoMessage() {} func (*QueryHeaderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{1} + return fileDescriptor_cd665af90102da38, []int{3} } func (m *QueryHeaderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -148,7 +232,7 @@ func (m *QueryChainListRequest) Reset() { *m = QueryChainListRequest{} } func (m *QueryChainListRequest) String() string { return proto.CompactTextString(m) } func (*QueryChainListRequest) ProtoMessage() {} func (*QueryChainListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{2} + return fileDescriptor_cd665af90102da38, []int{4} } func (m *QueryChainListRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -196,7 +280,7 @@ func (m *QueryChainListResponse) Reset() { *m = QueryChainListResponse{} func (m *QueryChainListResponse) String() string { return proto.CompactTextString(m) } func (*QueryChainListResponse) ProtoMessage() {} func (*QueryChainListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{3} + return fileDescriptor_cd665af90102da38, []int{5} } func (m *QueryChainListResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -248,7 +332,7 @@ func (m *QueryChainsInfoRequest) Reset() { *m = QueryChainsInfoRequest{} func (m *QueryChainsInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryChainsInfoRequest) ProtoMessage() {} func (*QueryChainsInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{4} + return fileDescriptor_cd665af90102da38, []int{6} } func (m *QueryChainsInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -293,7 +377,7 @@ func (m *QueryChainsInfoResponse) Reset() { *m = QueryChainsInfoResponse func (m *QueryChainsInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryChainsInfoResponse) ProtoMessage() {} func (*QueryChainsInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{5} + return fileDescriptor_cd665af90102da38, []int{7} } func (m *QueryChainsInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -340,7 +424,7 @@ func (m *QueryEpochChainsInfoRequest) Reset() { *m = QueryEpochChainsInf func (m *QueryEpochChainsInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryEpochChainsInfoRequest) ProtoMessage() {} func (*QueryEpochChainsInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{6} + return fileDescriptor_cd665af90102da38, []int{8} } func (m *QueryEpochChainsInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -394,7 +478,7 @@ func (m *QueryEpochChainsInfoResponse) Reset() { *m = QueryEpochChainsIn func (m *QueryEpochChainsInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryEpochChainsInfoResponse) ProtoMessage() {} func (*QueryEpochChainsInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{7} + return fileDescriptor_cd665af90102da38, []int{9} } func (m *QueryEpochChainsInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -441,7 +525,7 @@ func (m *QueryListHeadersRequest) Reset() { *m = QueryListHeadersRequest func (m *QueryListHeadersRequest) String() string { return proto.CompactTextString(m) } func (*QueryListHeadersRequest) ProtoMessage() {} func (*QueryListHeadersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{8} + return fileDescriptor_cd665af90102da38, []int{10} } func (m *QueryListHeadersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -497,7 +581,7 @@ func (m *QueryListHeadersResponse) Reset() { *m = QueryListHeadersRespon func (m *QueryListHeadersResponse) String() string { return proto.CompactTextString(m) } func (*QueryListHeadersResponse) ProtoMessage() {} func (*QueryListHeadersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{9} + return fileDescriptor_cd665af90102da38, []int{11} } func (m *QueryListHeadersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -551,7 +635,7 @@ func (m *QueryListEpochHeadersRequest) Reset() { *m = QueryListEpochHead func (m *QueryListEpochHeadersRequest) String() string { return proto.CompactTextString(m) } func (*QueryListEpochHeadersRequest) ProtoMessage() {} func (*QueryListEpochHeadersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{10} + return fileDescriptor_cd665af90102da38, []int{12} } func (m *QueryListEpochHeadersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -605,7 +689,7 @@ func (m *QueryListEpochHeadersResponse) Reset() { *m = QueryListEpochHea func (m *QueryListEpochHeadersResponse) String() string { return proto.CompactTextString(m) } func (*QueryListEpochHeadersResponse) ProtoMessage() {} func (*QueryListEpochHeadersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{11} + return fileDescriptor_cd665af90102da38, []int{13} } func (m *QueryListEpochHeadersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -654,7 +738,7 @@ func (m *QueryFinalizedChainsInfoRequest) Reset() { *m = QueryFinalizedC func (m *QueryFinalizedChainsInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedChainsInfoRequest) ProtoMessage() {} func (*QueryFinalizedChainsInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{12} + return fileDescriptor_cd665af90102da38, []int{14} } func (m *QueryFinalizedChainsInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -707,7 +791,7 @@ func (m *QueryFinalizedChainsInfoResponse) Reset() { *m = QueryFinalized func (m *QueryFinalizedChainsInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedChainsInfoResponse) ProtoMessage() {} func (*QueryFinalizedChainsInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{13} + return fileDescriptor_cd665af90102da38, []int{15} } func (m *QueryFinalizedChainsInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -764,7 +848,7 @@ func (m *QueryFinalizedChainInfoUntilHeightRequest) String() string { } func (*QueryFinalizedChainInfoUntilHeightRequest) ProtoMessage() {} func (*QueryFinalizedChainInfoUntilHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{14} + return fileDescriptor_cd665af90102da38, []int{16} } func (m *QueryFinalizedChainInfoUntilHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -838,7 +922,7 @@ func (m *QueryFinalizedChainInfoUntilHeightResponse) String() string { } func (*QueryFinalizedChainInfoUntilHeightResponse) ProtoMessage() {} func (*QueryFinalizedChainInfoUntilHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cd665af90102da38, []int{15} + return fileDescriptor_cd665af90102da38, []int{17} } func (m *QueryFinalizedChainInfoUntilHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -903,6 +987,8 @@ func (m *QueryFinalizedChainInfoUntilHeightResponse) GetProof() *ProofFinalizedC } func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "babylon.zoneconcierge.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "babylon.zoneconcierge.v1.QueryParamsResponse") proto.RegisterType((*QueryHeaderRequest)(nil), "babylon.zoneconcierge.v1.QueryHeaderRequest") proto.RegisterType((*QueryHeaderResponse)(nil), "babylon.zoneconcierge.v1.QueryHeaderResponse") proto.RegisterType((*QueryChainListRequest)(nil), "babylon.zoneconcierge.v1.QueryChainListRequest") @@ -926,76 +1012,81 @@ func init() { } var fileDescriptor_cd665af90102da38 = []byte{ - // 1101 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xce, 0x3a, 0x1f, 0x4d, 0x5e, 0xf3, 0x51, 0x4d, 0xda, 0x62, 0xb6, 0xad, 0x6b, 0x2d, 0x1f, - 0x4d, 0x4b, 0xb2, 0x8b, 0x5d, 0xd2, 0xaa, 0x5c, 0xaa, 0x36, 0x25, 0x69, 0x54, 0x54, 0xda, 0x85, - 0x80, 0xc4, 0x65, 0xd9, 0x5d, 0x8f, 0xed, 0x55, 0xe2, 0x1d, 0xd7, 0xb3, 0x76, 0xeb, 0x86, 0x70, - 0x40, 0xfc, 0x00, 0x24, 0x2e, 0x88, 0x13, 0x27, 0x0e, 0x1c, 0x7a, 0xe3, 0x27, 0x20, 0x71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, 0xc1, 0xe2, 0xaa, 0x22, - 0x2d, 0x3b, 0xae, 0xd4, 0x25, 0x8b, 0xfe, 0x95, 0xe0, 0xe2, 0xd8, 0x05, 0x85, 0x36, 0xa6, 0x92, - 0x95, 0xbe, 0x55, 0xe5, 0xbb, 0xff, 0x0f, 0x44, 0x44, 0xf9, 0x88, 0x45, 0x79, 0x1f, 0x6d, 0xe7, - 0x8e, 0x32, 0xe5, 0xe5, 0xf4, 0x11, 0x87, 0x2f, 0xe7, 0x9d, 0x8f, 0x7e, 0x3b, 0x2c, 0x4b, 0x2f, - 0x0e, 0xcb, 0xd2, 0x5f, 0x87, 0x65, 0xe9, 0xdb, 0xa3, 0xf2, 0xcc, 0x8b, 0xa3, 0xf2, 0xcc, 0x9f, - 0x47, 0xe5, 0x99, 0xcf, 0xd7, 0x9b, 0x8e, 0xd7, 0xea, 0x59, 0xaa, 0x4d, 0xda, 0x01, 0x1d, 0x83, - 0x19, 0x72, 0x3f, 0x8d, 0xb1, 0x7b, 0x83, 0x0e, 0xa6, 0xd6, 0x02, 0xfb, 0x8f, 0xf2, 0xda, 0x7f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x80, 0x0f, 0x7d, 0x88, 0x0f, 0x00, 0x00, + // 1176 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0x8e, 0xf3, 0xab, 0xc9, 0x5b, 0x0a, 0xd5, 0x24, 0x2d, 0x8b, 0xdb, 0x6e, 0x22, 0x43, 0x69, + 0x5a, 0x12, 0x9b, 0x4d, 0x49, 0xab, 0x72, 0xa0, 0x6a, 0x52, 0x92, 0x46, 0x45, 0xa5, 0x35, 0x04, + 0x24, 0x2e, 0xc6, 0xf6, 0xce, 0x7a, 0xad, 0x64, 0x3d, 0x5b, 0xdb, 0xbb, 0xed, 0x36, 0x84, 0x03, + 0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, 0xef, 0xb6, 0xb0, 0x67, 0x4c, 0xd3, 0x3f, 0xd4, 0xd7, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, + 0x03, 0xf9, 0xf2, 0x6b, 0xc4, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1010,6 +1101,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + // Params queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Header queries the CZ header and fork headers at a given height. Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) // ChainList queries the list of chains that checkpoint to Babylon @@ -1040,6 +1133,15 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/babylon.zoneconcierge.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) { out := new(QueryHeaderResponse) err := c.cc.Invoke(ctx, "/babylon.zoneconcierge.v1.Query/Header", in, out, opts...) @@ -1114,6 +1216,8 @@ func (c *queryClient) FinalizedChainInfoUntilHeight(ctx context.Context, in *Que // QueryServer is the server API for Query service. type QueryServer interface { + // Params queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Header queries the CZ header and fork headers at a given height. Header(context.Context, *QueryHeaderRequest) (*QueryHeaderResponse, error) // ChainList queries the list of chains that checkpoint to Babylon @@ -1140,6 +1244,9 @@ type QueryServer interface { type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} func (*UnimplementedQueryServer) Header(ctx context.Context, req *QueryHeaderRequest) (*QueryHeaderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Header not implemented") } @@ -1169,6 +1276,24 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.zoneconcierge.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_Header_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryHeaderRequest) if err := dec(in); err != nil { @@ -1317,6 +1442,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "babylon.zoneconcierge.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, { MethodName: "Header", Handler: _Query_Header_Handler, @@ -1354,6 +1483,62 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "babylon/zoneconcierge/v1/query.proto", } +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryHeaderRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2039,6 +2224,26 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryHeaderRequest) Size() (n int) { if m == nil { return 0 @@ -2321,6 +2526,139 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryHeaderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/zoneconcierge/types/query.pb.gw.go b/x/zoneconcierge/types/query.pb.gw.go index 607477240..fc22099f6 100644 --- a/x/zoneconcierge/types/query.pb.gw.go +++ b/x/zoneconcierge/types/query.pb.gw.go @@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Header_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryHeaderRequest var metadata runtime.ServerMetadata @@ -501,6 +519,29 @@ func local_request_Query_FinalizedChainInfoUntilHeight_0(ctx context.Context, ma // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Header_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -726,6 +767,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Header_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -890,6 +951,8 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "zoneconcierge", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Header_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"babylon", "zoneconcierge", "v1", "chain_info", "chain_id", "header", "height"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ChainList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "zoneconcierge", "v1", "chains"}, "", runtime.AssumeColonVerbOpt(false))) @@ -908,6 +971,8 @@ var ( ) var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_Header_0 = runtime.ForwardResponseMessage forward_Query_ChainList_0 = runtime.ForwardResponseMessage diff --git a/x/zoneconcierge/types/tx.pb.go b/x/zoneconcierge/types/tx.pb.go index 2c52ff6b3..c42d065d3 100644 --- a/x/zoneconcierge/types/tx.pb.go +++ b/x/zoneconcierge/types/tx.pb.go @@ -6,10 +6,17 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,19 +30,133 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgUpdateParams defines a message for updating zoneconcierge module parameters. +type MsgUpdateParams struct { + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet implemented + // in cosmos-proto + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the epoching paramaeters parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_35e2112d987e4e18, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse is the response to the MsgUpdateParams message. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_35e2112d987e4e18, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "babylon.zoneconcierge.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "babylon.zoneconcierge.v1.MsgUpdateParamsResponse") +} + func init() { proto.RegisterFile("babylon/zoneconcierge/v1/tx.proto", fileDescriptor_35e2112d987e4e18) } var fileDescriptor_35e2112d987e4e18 = []byte{ - // 140 bytes of a gzipped FileDescriptorProto + // 324 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 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, 0xa9, 0xd0, 0x2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ff, 0xff, 0x5a, 0xdf, 0x0c, 0x09, + 0x33, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -50,6 +171,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // UpdateParams updates the btccheckpoint module parameters. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -60,22 +183,414 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/babylon.zoneconcierge.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + // UpdateParams updates the btccheckpoint module parameters. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.zoneconcierge.v1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "babylon.zoneconcierge.v1.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "babylon/zoneconcierge/v1/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "babylon/zoneconcierge/v1/tx.proto", +} + +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/zoneconcierge/types/zoneconcierge.go b/x/zoneconcierge/types/zoneconcierge.go index be4071344..230715dd0 100644 --- a/x/zoneconcierge/types/zoneconcierge.go +++ b/x/zoneconcierge/types/zoneconcierge.go @@ -91,3 +91,11 @@ func (ci *ChainInfo) ValidateBasic() error { return nil } + +func NewBTCTimestampPacketData(btcTimestamp *BTCTimestamp) *ZoneconciergePacketData { + return &ZoneconciergePacketData{ + Packet: &ZoneconciergePacketData_BtcTimestamp{ + BtcTimestamp: btcTimestamp, + }, + } +} diff --git a/x/zoneconcierge/types/zoneconcierge.pb.go b/x/zoneconcierge/types/zoneconcierge.pb.go index f9e732c74..c5466c08b 100644 --- a/x/zoneconcierge/types/zoneconcierge.pb.go +++ b/x/zoneconcierge/types/zoneconcierge.pb.go @@ -10,16 +10,21 @@ import ( types1 "github.com/babylonchain/babylon/x/epoching/types" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" types "github.com/cometbft/cometbft/proto/tendermint/types" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -36,15 +41,19 @@ type IndexedHeader struct { // height is the height of this header on CZ ledger // (hash, height) jointly provides the position of the header on CZ ledger Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + // time is the timestamp of this header on CZ ledger + // it is needed for CZ to unbond all mature validators/delegations + // before this timestamp when this header is BTC-finalised + Time *time.Time `protobuf:"bytes,4,opt,name=time,proto3,stdtime" json:"time,omitempty"` // babylon_header is the header of the babylon block that includes this CZ // header - BabylonHeader *types.Header `protobuf:"bytes,4,opt,name=babylon_header,json=babylonHeader,proto3" json:"babylon_header,omitempty"` + BabylonHeader *types.Header `protobuf:"bytes,5,opt,name=babylon_header,json=babylonHeader,proto3" json:"babylon_header,omitempty"` // epoch is the epoch number of this header on Babylon ledger - BabylonEpoch uint64 `protobuf:"varint,5,opt,name=babylon_epoch,json=babylonEpoch,proto3" json:"babylon_epoch,omitempty"` + BabylonEpoch uint64 `protobuf:"varint,6,opt,name=babylon_epoch,json=babylonEpoch,proto3" json:"babylon_epoch,omitempty"` // babylon_tx_hash is the hash of the tx that includes this header // (babylon_block_height, babylon_tx_hash) jointly provides the position of // the header on Babylon ledger - BabylonTxHash []byte `protobuf:"bytes,6,opt,name=babylon_tx_hash,json=babylonTxHash,proto3" json:"babylon_tx_hash,omitempty"` + BabylonTxHash []byte `protobuf:"bytes,7,opt,name=babylon_tx_hash,json=babylonTxHash,proto3" json:"babylon_tx_hash,omitempty"` } func (m *IndexedHeader) Reset() { *m = IndexedHeader{} } @@ -101,6 +110,13 @@ func (m *IndexedHeader) GetHeight() uint64 { return 0 } +func (m *IndexedHeader) GetTime() *time.Time { + if m != nil { + return m.Time + } + return nil +} + func (m *IndexedHeader) GetBabylonHeader() *types.Header { if m != nil { return m.BabylonHeader @@ -519,60 +535,64 @@ func init() { } var fileDescriptor_ab886e1868e5c5cd = []byte{ - // 848 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xce, 0xc6, 0xf9, 0x21, 0xe3, 0x38, 0x84, 0x29, 0xd0, 0x4d, 0x00, 0x63, 0xb9, 0x52, 0x71, - 0x11, 0xac, 0xe5, 0x20, 0x2e, 0xe0, 0x06, 0x91, 0xd0, 0xd2, 0xb4, 0x88, 0xa2, 0x89, 0x5b, 0x10, - 0x12, 0x5a, 0xcd, 0xee, 0x8e, 0xbd, 0x23, 0xaf, 0x67, 0x56, 0x3b, 0x13, 0xd7, 0xee, 0x53, 0xf0, - 0x2a, 0xbc, 0x05, 0x97, 0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66, 0x75, 0x96, 0x1f, 0x77, 0x7f, 0x6b, 0x20, 0xfc, 0x80, 0x0b, 0x9a, 0xf0, 0x17, 0x2c, 0xba, - 0xd1, 0xfd, 0x9f, 0xa2, 0xb7, 0x47, 0x45, 0x80, 0x6f, 0x41, 0x62, 0x24, 0xad, 0x0d, 0x77, 0xea, - 0x95, 0x97, 0xec, 0x04, 0x8f, 0xd6, 0x33, 0x7e, 0x81, 0x10, 0x34, 0x84, 0x21, 0x33, 0x36, 0x1c, - 0x97, 0x64, 0x65, 0x7f, 0xcf, 0x06, 0x1e, 0xf4, 0x08, 0xd9, 0x83, 0x2d, 0x08, 0xfd, 0x1e, 0x1d, - 0x64, 0xf4, 0xb9, 0xbf, 0x9c, 0x14, 0xdb, 0x94, 0xcb, 0x92, 0xac, 0x4c, 0x55, 0xce, 0x41, 0xe8, - 0xf3, 0xb3, 0x72, 0x8f, 0xb4, 0xb2, 0xea, 0x12, 0x3f, 0x45, 0x38, 0xd0, 0xa1, 0xaf, 0x2e, 0x83, - 0x29, 0x57, 0x8a, 0x4b, 0x91, 0x0f, 0x2a, 0x34, 0x6a, 0x95, 0x73, 0x75, 0xdc, 0x67, 0x03, 0xef, - 0xa2, 0xc4, 0x3f, 0x66, 0x0b, 0x72, 0x18, 0xe8, 0x70, 0x65, 0x07, 0x7f, 0x8b, 0xb6, 0xe1, 0x21, - 0x81, 0x5e, 0x6e, 0x9e, 0x0c, 0xea, 0x9d, 0xfa, 0x21, 0x87, 0xad, 0x57, 0x85, 0x98, 0xf8, 0xee, - 0xbf, 0x0e, 0x3a, 0x04, 0x08, 0x38, 0x71, 0xc1, 0x68, 0xc2, 0x22, 0x4c, 0x50, 0x6b, 0x46, 0x13, - 0x1e, 0x51, 0x2d, 0x33, 0x5f, 0x31, 0xed, 0x3a, 0x30, 0x08, 0x9f, 0xd6, 0x7b, 0xf0, 0xac, 0x80, - 0xff, 0xc8, 0x75, 0x7c, 0x9a, 0xa8, 0x5c, 0xf5, 0x7e, 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79, 0xdd, - 0xde, 0xf8, 0xe3, 0xba, 0xbd, 0xf1, 0xf3, 0xe7, 0x63, 0xae, 0xe3, 0xcb, 0xc0, 0x0b, 0xe5, 0xb4, - 0x6f, 0x73, 0xc0, 0x2b, 0x50, 0x2c, 0xfa, 0xf3, 0x57, 0xbe, 0xcf, 0x60, 0x77, 0xb0, 0x03, 0x5f, - 0xa6, 0xcf, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xe5, 0x71, 0xc2, 0xc5, 0x07, 0x00, 0x00, + // 901 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcf, 0x6e, 0x1b, 0x45, + 0x1c, 0xce, 0xc6, 0x4e, 0x42, 0xc6, 0x71, 0x08, 0xd3, 0x42, 0x37, 0x01, 0x1c, 0xcb, 0x95, 0x8a, + 0x8b, 0x60, 0x2d, 0x07, 0x38, 0xc0, 0x05, 0xe1, 0xd0, 0xd2, 0xb4, 0x88, 0xa2, 0x89, 0x5b, 0x10, + 0x12, 0x5a, 0xcd, 0xee, 0x8e, 0xbd, 0xa3, 0xac, 0x67, 0xac, 0x9d, 0x89, 0x6b, 0xf7, 0x29, 0x7a, + 0xe6, 0x2d, 0x78, 0x0b, 0x8e, 0x3d, 0x72, 0x03, 0x25, 0xe2, 0x0d, 0xb8, 0x70, 0x43, 0xfb, 0x9b, + 0x19, 0x7b, 0x4d, 0x70, 0x9b, 0x4b, 0xb4, 0x33, 0xf3, 0xfd, 0xbe, 0xf9, 0xe6, 0xfb, 0xfd, 0x89, + 0xd1, 0x47, 0x11, 0x8d, 0x66, 0x99, 0x14, 0x9d, 0xe7, 0x52, 0xb0, 0x58, 0x8a, 0x98, 0xb3, 0x7c, + 0xc8, 0x3a, 0x93, 0xee, 0xf2, 0x46, 0x30, 0xce, 0xa5, 0x96, 0xd8, 0xb7, 0xe8, 0x60, 0xf9, 0x70, + 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e, 0x36, 0xd6, 0x7e, 0xbf, 0x6c, 0xac, 0xfd, 0xf4, 0xd9, 0x90, 0xeb, 0xf4, + 0x3c, 0x0a, 0x62, 0x39, 0xea, 0xd8, 0x3b, 0x60, 0x0a, 0xb8, 0x45, 0x67, 0xfa, 0x9f, 0x1f, 0x03, + 0x60, 0x77, 0xb4, 0x09, 0xff, 0x59, 0x3e, 0xf9, 0x37, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x27, 0xa0, + 0x60, 0x32, 0x08, 0x00, 0x00, } func (m *IndexedHeader) Marshal() (dAtA []byte, err error) { @@ -600,12 +620,12 @@ func (m *IndexedHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.BabylonTxHash) i = encodeVarintZoneconcierge(dAtA, i, uint64(len(m.BabylonTxHash))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if m.BabylonEpoch != 0 { i = encodeVarintZoneconcierge(dAtA, i, uint64(m.BabylonEpoch)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if m.BabylonHeader != nil { { @@ -617,6 +637,16 @@ func (m *IndexedHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintZoneconcierge(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x2a + } + if m.Time != nil { + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Time):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintZoneconcierge(dAtA, i, uint64(n2)) + i-- dAtA[i] = 0x22 } if m.Height != 0 { @@ -989,6 +1019,10 @@ func (m *IndexedHeader) Size() (n int) { if m.Height != 0 { n += 1 + sovZoneconcierge(uint64(m.Height)) } + if m.Time != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Time) + n += 1 + l + sovZoneconcierge(uint64(l)) + } if m.BabylonHeader != nil { l = m.BabylonHeader.Size() n += 1 + l + sovZoneconcierge(uint64(l)) @@ -1246,6 +1280,42 @@ func (m *IndexedHeader) Unmarshal(dAtA []byte) error { } } case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZoneconcierge + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZoneconcierge + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZoneconcierge + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Time == nil { + m.Time = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.Time, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BabylonHeader", wireType) } @@ -1281,7 +1351,7 @@ func (m *IndexedHeader) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field BabylonEpoch", wireType) } @@ -1300,7 +1370,7 @@ func (m *IndexedHeader) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BabylonTxHash", wireType) }