From 06952c4555c48a3bc2a450ce339f8c0966756589 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 3 Feb 2025 21:48:20 -0600 Subject: [PATCH 1/9] add fine-grained confirmation to chain params; add migration script --- docs/openapi/openapi.swagger.yaml | 17 + .../zetacore/observer/confirmation.proto | 11 + .../zetachain/zetacore/observer/params.proto | 3 +- testutil/sample/observer.go | 14 + .../zetacore/observer/confirmation_pb.d.ts | 47 ++ .../zetachain/zetacore/observer/index.d.ts | 1 + .../zetacore/observer/params_pb.d.ts | 6 + x/observer/keeper/migrator.go | 6 + x/observer/migrations/v10/migrate.go | 41 ++ x/observer/migrations/v10/migrate_test.go | 100 +++++ x/observer/module.go | 5 +- x/observer/types/chain_params.go | 78 +++- x/observer/types/chain_params_test.go | 30 ++ x/observer/types/confirmation.pb.go | 410 ++++++++++++++++++ x/observer/types/params.pb.go | 140 ++++-- 15 files changed, 864 insertions(+), 45 deletions(-) create mode 100644 proto/zetachain/zetacore/observer/confirmation.proto create mode 100644 typescript/zetachain/zetacore/observer/confirmation_pb.d.ts create mode 100644 x/observer/migrations/v10/migrate.go create mode 100644 x/observer/migrations/v10/migrate_test.go create mode 100644 x/observer/types/confirmation.pb.go diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index daf6430c45..01eceec588 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -59799,6 +59799,8 @@ definitions: type: boolean gateway_address: type: string + confirmation: + $ref: '#/definitions/observerConfirmation' observerChainParamsList: type: object properties: @@ -59807,6 +59809,21 @@ definitions: items: type: object $ref: '#/definitions/observerChainParams' + observerConfirmation: + type: object + properties: + safe_inbound_count: + type: string + format: uint64 + fast_inbound_count: + type: string + format: uint64 + safe_outbound_count: + type: string + format: uint64 + fast_outbound_count: + type: string + format: uint64 observerCrosschainFlags: type: object properties: diff --git a/proto/zetachain/zetacore/observer/confirmation.proto b/proto/zetachain/zetacore/observer/confirmation.proto new file mode 100644 index 0000000000..84b4a3be23 --- /dev/null +++ b/proto/zetachain/zetacore/observer/confirmation.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package zetachain.zetacore.observer; + +option go_package = "github.com/zeta-chain/node/x/observer/types"; + +message Confirmation { + uint64 safe_inbound_count = 1; + uint64 fast_inbound_count = 2; + uint64 safe_outbound_count = 3; + uint64 fast_outbound_count = 4; +} diff --git a/proto/zetachain/zetacore/observer/params.proto b/proto/zetachain/zetacore/observer/params.proto index 0d9208ad4f..0125229823 100644 --- a/proto/zetachain/zetacore/observer/params.proto +++ b/proto/zetachain/zetacore/observer/params.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "zetachain/zetacore/observer/observer.proto"; +import "zetachain/zetacore/observer/confirmation.proto"; option go_package = "github.com/zeta-chain/node/x/observer/types"; @@ -30,6 +30,7 @@ message ChainParams { ]; bool is_supported = 16; string gateway_address = 17; + Confirmation confirmation = 18 [ (gogoproto.nullable) = false ]; } // Deprecated(v17) diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 354aa53c96..2a86508633 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -113,6 +113,8 @@ func ChainParams(chainID int64) *types.ChainParams { BallotThreshold: fiftyPercent, MinObserverDelegation: sdkmath.LegacyNewDec(r.Int63()), IsSupported: false, + GatewayAddress: EthAddress().String(), + Confirmation: Confirmation(), } } @@ -337,3 +339,15 @@ func OperationalFlags() types.OperationalFlags { SignerBlockTimeOffset: ptr.Ptr(time.Second), } } + +func Confirmation() types.Confirmation { + randInboundCount := Uint64InRange(1, 200) + randOutboundCount := Uint64InRange(1, 200) + + return types.Confirmation{ + SafeInboundCount: randInboundCount, + FastInboundCount: randInboundCount - 1, + SafeOutboundCount: randOutboundCount, + FastOutboundCount: randOutboundCount - 1, + } +} diff --git a/typescript/zetachain/zetacore/observer/confirmation_pb.d.ts b/typescript/zetachain/zetacore/observer/confirmation_pb.d.ts new file mode 100644 index 0000000000..fa3424ae6d --- /dev/null +++ b/typescript/zetachain/zetacore/observer/confirmation_pb.d.ts @@ -0,0 +1,47 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file zetachain/zetacore/observer/confirmation.proto (package zetachain.zetacore.observer, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message zetachain.zetacore.observer.Confirmation + */ +export declare class Confirmation extends Message { + /** + * @generated from field: uint64 safe_inbound_count = 1; + */ + safeInboundCount: bigint; + + /** + * @generated from field: uint64 fast_inbound_count = 2; + */ + fastInboundCount: bigint; + + /** + * @generated from field: uint64 safe_outbound_count = 3; + */ + safeOutboundCount: bigint; + + /** + * @generated from field: uint64 fast_outbound_count = 4; + */ + fastOutboundCount: bigint; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.observer.Confirmation"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Confirmation; + + static fromJson(jsonValue: JsonValue, options?: Partial): Confirmation; + + static fromJsonString(jsonString: string, options?: Partial): Confirmation; + + static equals(a: Confirmation | PlainMessage | undefined, b: Confirmation | PlainMessage | undefined): boolean; +} + diff --git a/typescript/zetachain/zetacore/observer/index.d.ts b/typescript/zetachain/zetacore/observer/index.d.ts index bdb0cde736..ce79a333f4 100644 --- a/typescript/zetachain/zetacore/observer/index.d.ts +++ b/typescript/zetachain/zetacore/observer/index.d.ts @@ -1,6 +1,7 @@ export * from "./ballot_pb"; export * from "./blame_pb"; export * from "./chain_nonces_pb"; +export * from "./confirmation_pb"; export * from "./crosschain_flags_pb"; export * from "./events_pb"; export * from "./genesis_pb"; diff --git a/typescript/zetachain/zetacore/observer/params_pb.d.ts b/typescript/zetachain/zetacore/observer/params_pb.d.ts index 9155826e05..b21d9fb4cb 100644 --- a/typescript/zetachain/zetacore/observer/params_pb.d.ts +++ b/typescript/zetachain/zetacore/observer/params_pb.d.ts @@ -5,6 +5,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; +import type { Confirmation } from "./confirmation_pb.js"; /** * @generated from message zetachain.zetacore.observer.ChainParamsList @@ -109,6 +110,11 @@ export declare class ChainParams extends Message { */ gatewayAddress: string; + /** + * @generated from field: zetachain.zetacore.observer.Confirmation confirmation = 18; + */ + confirmation?: Confirmation; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/x/observer/keeper/migrator.go b/x/observer/keeper/migrator.go index c98ccd9e0c..93372f6f3e 100644 --- a/x/observer/keeper/migrator.go +++ b/x/observer/keeper/migrator.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + v10 "github.com/zeta-chain/node/x/observer/migrations/v10" v8 "github.com/zeta-chain/node/x/observer/migrations/v8" v9 "github.com/zeta-chain/node/x/observer/migrations/v9" ) @@ -55,3 +56,8 @@ func (m Migrator) Migrate7to8(ctx sdk.Context) error { func (m Migrator) Migrate8to9(ctx sdk.Context) error { return v9.MigrateStore(ctx, m.observerKeeper) } + +// Migrate9to10 migrates the store from consensus version 9 to 10 +func (m Migrator) Migrate9to10(ctx sdk.Context) error { + return v10.MigrateStore(ctx, m.observerKeeper) +} diff --git a/x/observer/migrations/v10/migrate.go b/x/observer/migrations/v10/migrate.go new file mode 100644 index 0000000000..c40a4f98aa --- /dev/null +++ b/x/observer/migrations/v10/migrate.go @@ -0,0 +1,41 @@ +package v10 + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/zeta-chain/node/x/observer/types" +) + +type observerKeeper interface { + GetChainParamsList(ctx sdk.Context) (val types.ChainParamsList, found bool) + SetChainParamsList(ctx sdk.Context, chainParams types.ChainParamsList) +} + +// MigrateStore migrates the x/observer module state from the consensus version 9 to version 10. +// The migration sets existing 'confirmation_count' as default value for newly added fields: +// - 'safe_inbound_count' +// - 'fast_inbound_count' +// - 'safe_outbound_count' +// - 'fast_outbound_count' +func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { + allChainParams, found := observerKeeper.GetChainParamsList(ctx) + if !found { + return errorsmod.Wrap(types.ErrChainParamsNotFound, "failed to get chain params") + } + + // set new fields to the same value as 'confirmation_count' + for _, chainParams := range allChainParams.ChainParams { + if chainParams != nil { + chainParams.Confirmation.SafeInboundCount = chainParams.ConfirmationCount + chainParams.Confirmation.FastInboundCount = chainParams.ConfirmationCount + chainParams.Confirmation.SafeOutboundCount = chainParams.ConfirmationCount + chainParams.Confirmation.FastOutboundCount = chainParams.ConfirmationCount + } + } + + // set the updated chain params list + observerKeeper.SetChainParamsList(ctx, allChainParams) + + return nil +} diff --git a/x/observer/migrations/v10/migrate_test.go b/x/observer/migrations/v10/migrate_test.go new file mode 100644 index 0000000000..3b307c0bc5 --- /dev/null +++ b/x/observer/migrations/v10/migrate_test.go @@ -0,0 +1,100 @@ +package v10_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/node/testutil/keeper" + "github.com/zeta-chain/node/testutil/sample" + "github.com/zeta-chain/node/x/observer/keeper" + v10 "github.com/zeta-chain/node/x/observer/migrations/v10" + "github.com/zeta-chain/node/x/observer/types" +) + +var chainParams = types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + makeChainParamsEmptyConfirmation(1, 14), + makeChainParamsEmptyConfirmation(56, 20), + makeChainParamsEmptyConfirmation(8332, 3), + makeChainParamsEmptyConfirmation(7000, 0), + makeChainParamsEmptyConfirmation(137, 200), + makeChainParamsEmptyConfirmation(8453, 90), + makeChainParamsEmptyConfirmation(900, 32), + }, +} + +func TestMigrateStore(t *testing.T) { + t.Run("can migrate confirmation count", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + + // set chain params + setChainParamsList(ctx, *k, chainParams) + + // ensure the chain params are set correctly + oldChainParams, found := k.GetChainParamsList(ctx) + require.True(t, found) + require.EqualValues(t, chainParams, oldChainParams) + + // migrate the store + err := v10.MigrateStore(ctx, *k) + require.NoError(t, err) + + // ensure we still have 7 chain params after migration + newChainParams, found := k.GetChainParamsList(ctx) + require.True(t, found) + require.Len(t, newChainParams.ChainParams, len(oldChainParams.ChainParams)) + + // compare the old and new chain params + for i, newParam := range newChainParams.ChainParams { + oldParam := oldChainParams.ChainParams[i] + + // ensure the confirmation fields are set correctly + require.Equal(t, newParam.Confirmation.SafeInboundCount, oldParam.ConfirmationCount) + require.Equal(t, newParam.Confirmation.FastInboundCount, oldParam.ConfirmationCount) + require.Equal(t, newParam.Confirmation.SafeOutboundCount, oldParam.ConfirmationCount) + require.Equal(t, newParam.Confirmation.FastOutboundCount, oldParam.ConfirmationCount) + + // ensure nothing else has changed except the confirmation + oldParam.Confirmation.SafeInboundCount = oldParam.ConfirmationCount + oldParam.Confirmation.FastInboundCount = oldParam.ConfirmationCount + oldParam.Confirmation.SafeOutboundCount = oldParam.ConfirmationCount + oldParam.Confirmation.FastOutboundCount = oldParam.ConfirmationCount + require.Equal(t, newParam, oldParam) + } + }) + + t.Run("migrate nothing if chain params not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + + // ensure no chain params are set + allChainParams, found := k.GetChainParamsList(ctx) + require.False(t, found) + require.Empty(t, allChainParams.ChainParams) + + // migrate the store + err := v10.MigrateStore(ctx, *k) + require.ErrorIs(t, err, types.ErrChainParamsNotFound) + + // ensure nothing has changed + allChainParams, found = k.GetChainParamsList(ctx) + require.False(t, found) + require.Empty(t, allChainParams.ChainParams) + }) +} + +// makeChainParamsEmptyConfirmation creates a sample chain params with empty confirmation +func makeChainParamsEmptyConfirmation(chainID int64, confirmationCount uint64) *types.ChainParams { + chainParams := sample.ChainParams(chainID) + chainParams.ConfirmationCount = confirmationCount + chainParams.Confirmation = types.Confirmation{} + return chainParams +} + +// setChainParamsList set chain params list in the store +func setChainParamsList(ctx sdk.Context, observerKeeper keeper.Keeper, chainParams types.ChainParamsList) { + store := ctx.KVStore(observerKeeper.StoreKey()) + b := observerKeeper.Codec().MustMarshal(&chainParams) + key := types.KeyPrefix(types.AllChainParamsKey) + store.Set(key, b) +} diff --git a/x/observer/module.go b/x/observer/module.go index aa7db5cd42..ab49afd97f 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -152,6 +152,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 8, m.Migrate8to9); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 9, m.Migrate9to10); err != nil { + panic(err) + } } // RegisterInvariants registers the observer module's invariants. @@ -176,7 +179,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 9 } +func (AppModule) ConsensusVersion() uint64 { return 10 } // BeginBlock executes all ABCI BeginBlock logic respective to the observer module. func (am AppModule) BeginBlock(c context.Context) error { diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index a2a8e31942..4047256b80 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -56,9 +56,30 @@ func ValidateChainParams(params *ChainParams) error { return errorsmod.Wrap(sdkerrors.ErrInvalidChainID, "zeta chain cannot have observer chain parameters") } + // validate confirmation counts if params.ConfirmationCount == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "ConfirmationCount must be greater than 0") } + if params.Confirmation.SafeInboundCount == 0 { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeInboundCount must be greater than 0") + } + if params.Confirmation.FastInboundCount > params.Confirmation.SafeInboundCount { + return errorsmod.Wrapf( + sdkerrors.ErrInvalidRequest, + "FastInboundCount must be less than or equal to SafeInboundCount", + ) + } + if params.Confirmation.SafeOutboundCount == 0 { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeOutboundCount must be greater than 0") + } + if params.Confirmation.FastOutboundCount > params.Confirmation.SafeOutboundCount { + return errorsmod.Wrapf( + sdkerrors.ErrInvalidRequest, + "FastOutboundCount must be less than or equal to SafeOutboundCount", + ) + } + + // validate tickers and intervals if params.GasPriceTicker <= 0 || params.GasPriceTicker > 300 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "GasPriceTicker %d out of range", params.GasPriceTicker) } @@ -168,6 +189,12 @@ func GetDefaultEthMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 14, + FastInboundCount: 14, + SafeOutboundCount: 14, + FastOutboundCount: 14, + }, } } func GetDefaultBscMainnetChainParams() *ChainParams { @@ -186,6 +213,12 @@ func GetDefaultBscMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 14, + FastInboundCount: 14, + SafeOutboundCount: 14, + FastOutboundCount: 14, + }, } } func GetDefaultBtcMainnetChainParams() *ChainParams { @@ -204,6 +237,12 @@ func GetDefaultBtcMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 2, + FastInboundCount: 2, + SafeOutboundCount: 2, + FastOutboundCount: 2, + }, } } func GetDefaultGoerliTestnetChainParams() *ChainParams { @@ -223,6 +262,12 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 6, + FastInboundCount: 6, + SafeOutboundCount: 6, + FastOutboundCount: 6, + }, } } func GetDefaultBscTestnetChainParams() *ChainParams { @@ -241,6 +286,12 @@ func GetDefaultBscTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 6, + FastInboundCount: 6, + SafeOutboundCount: 6, + FastOutboundCount: 6, + }, } } func GetDefaultMumbaiTestnetChainParams() *ChainParams { @@ -259,6 +310,12 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 12, + FastInboundCount: 12, + SafeOutboundCount: 12, + FastOutboundCount: 12, + }, } } func GetDefaultBtcTestnetChainParams() *ChainParams { @@ -277,6 +334,12 @@ func GetDefaultBtcTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 2, + FastInboundCount: 2, + SafeOutboundCount: 2, + FastOutboundCount: 2, + }, } } func GetDefaultBtcRegtestChainParams() *ChainParams { @@ -295,6 +358,12 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, + Confirmation: Confirmation{ + SafeInboundCount: 1, + FastInboundCount: 1, + SafeOutboundCount: 1, + FastOutboundCount: 1, + }, } } func GetDefaultGoerliLocalnetChainParams() *ChainParams { @@ -314,6 +383,12 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", + Confirmation: Confirmation{ + SafeInboundCount: 1, + FastInboundCount: 1, + SafeOutboundCount: 1, + FastOutboundCount: 1, + }, } } func GetDefaultZetaPrivnetChainParams() *ChainParams { @@ -351,5 +426,6 @@ func ChainParamsEqual(params1, params2 ChainParams) bool { params1.BallotThreshold.Equal(params2.BallotThreshold) && params1.MinObserverDelegation.Equal(params2.MinObserverDelegation) && params1.IsSupported == params2.IsSupported && - params1.GatewayAddress == params2.GatewayAddress + params1.GatewayAddress == params2.GatewayAddress && + params1.Confirmation == params2.Confirmation } diff --git a/x/observer/types/chain_params_test.go b/x/observer/types/chain_params_test.go index 04cae4e99a..9be72d4d5b 100644 --- a/x/observer/types/chain_params_test.go +++ b/x/observer/types/chain_params_test.go @@ -69,6 +69,12 @@ func (s *UpdateChainParamsSuite) SetupTest() { MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", + Confirmation: types.Confirmation{ + SafeInboundCount: 2, + FastInboundCount: 0, // zero means disabled + SafeOutboundCount: 2, + FastOutboundCount: 1, + }, } s.btcParams = &types.ChainParams{ ConfirmationCount: 1, @@ -85,6 +91,12 @@ func (s *UpdateChainParamsSuite) SetupTest() { BallotThreshold: types.DefaultBallotThreshold, MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, + Confirmation: types.Confirmation{ + SafeInboundCount: 1, + FastInboundCount: 0, // zero means disabled + SafeOutboundCount: 1, + FastOutboundCount: 1, + }, } } @@ -145,6 +157,24 @@ func (s *UpdateChainParamsSuite) Validate(params *types.ChainParams) { err := types.ValidateChainParams(©) require.NotNil(s.T(), err) + copy = *params + copy.Confirmation.SafeInboundCount = 0 + err = types.ValidateChainParams(©) + require.NotNil(s.T(), err) + copy = *params + copy.Confirmation.FastInboundCount = copy.Confirmation.SafeInboundCount + 1 + err = types.ValidateChainParams(©) + require.NotNil(s.T(), err) + + copy = *params + copy.Confirmation.SafeOutboundCount = 0 + err = types.ValidateChainParams(©) + require.NotNil(s.T(), err) + copy = *params + copy.Confirmation.FastOutboundCount = copy.Confirmation.SafeOutboundCount + 1 + err = types.ValidateChainParams(©) + require.NotNil(s.T(), err) + copy = *params copy.GasPriceTicker = 0 err = types.ValidateChainParams(©) diff --git a/x/observer/types/confirmation.pb.go b/x/observer/types/confirmation.pb.go new file mode 100644 index 0000000000..8a6bb58c28 --- /dev/null +++ b/x/observer/types/confirmation.pb.go @@ -0,0 +1,410 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zetachain/zetacore/observer/confirmation.proto + +package types + +import ( + fmt "fmt" + 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 + +type Confirmation struct { + SafeInboundCount uint64 `protobuf:"varint,1,opt,name=safe_inbound_count,json=safeInboundCount,proto3" json:"safe_inbound_count,omitempty"` + FastInboundCount uint64 `protobuf:"varint,2,opt,name=fast_inbound_count,json=fastInboundCount,proto3" json:"fast_inbound_count,omitempty"` + SafeOutboundCount uint64 `protobuf:"varint,3,opt,name=safe_outbound_count,json=safeOutboundCount,proto3" json:"safe_outbound_count,omitempty"` + FastOutboundCount uint64 `protobuf:"varint,4,opt,name=fast_outbound_count,json=fastOutboundCount,proto3" json:"fast_outbound_count,omitempty"` +} + +func (m *Confirmation) Reset() { *m = Confirmation{} } +func (m *Confirmation) String() string { return proto.CompactTextString(m) } +func (*Confirmation) ProtoMessage() {} +func (*Confirmation) Descriptor() ([]byte, []int) { + return fileDescriptor_26b45655bc4002d5, []int{0} +} +func (m *Confirmation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Confirmation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Confirmation.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 *Confirmation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Confirmation.Merge(m, src) +} +func (m *Confirmation) XXX_Size() int { + return m.Size() +} +func (m *Confirmation) XXX_DiscardUnknown() { + xxx_messageInfo_Confirmation.DiscardUnknown(m) +} + +var xxx_messageInfo_Confirmation proto.InternalMessageInfo + +func (m *Confirmation) GetSafeInboundCount() uint64 { + if m != nil { + return m.SafeInboundCount + } + return 0 +} + +func (m *Confirmation) GetFastInboundCount() uint64 { + if m != nil { + return m.FastInboundCount + } + return 0 +} + +func (m *Confirmation) GetSafeOutboundCount() uint64 { + if m != nil { + return m.SafeOutboundCount + } + return 0 +} + +func (m *Confirmation) GetFastOutboundCount() uint64 { + if m != nil { + return m.FastOutboundCount + } + return 0 +} + +func init() { + proto.RegisterType((*Confirmation)(nil), "zetachain.zetacore.observer.Confirmation") +} + +func init() { + proto.RegisterFile("zetachain/zetacore/observer/confirmation.proto", fileDescriptor_26b45655bc4002d5) +} + +var fileDescriptor_26b45655bc4002d5 = []byte{ + // 236 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xab, 0x4a, 0x2d, 0x49, + 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x07, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0xf3, 0x93, 0x8a, 0x53, + 0x8b, 0xca, 0x52, 0x8b, 0xf4, 0x93, 0xf3, 0xf3, 0xd2, 0x32, 0x8b, 0x72, 0x13, 0x4b, 0x32, 0xf3, + 0xf3, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xa4, 0xe1, 0xea, 0xf5, 0x60, 0xea, 0xf5, 0x60, + 0xea, 0x95, 0x4e, 0x31, 0x72, 0xf1, 0x38, 0x23, 0xe9, 0x11, 0xd2, 0xe1, 0x12, 0x2a, 0x4e, 0x4c, + 0x4b, 0x8d, 0xcf, 0xcc, 0x4b, 0xca, 0x2f, 0xcd, 0x4b, 0x89, 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x91, + 0x60, 0x54, 0x60, 0xd4, 0x60, 0x09, 0x12, 0x00, 0xc9, 0x78, 0x42, 0x24, 0x9c, 0x41, 0xe2, 0x20, + 0xd5, 0x69, 0x89, 0xc5, 0x25, 0x68, 0xaa, 0x99, 0x20, 0xaa, 0x41, 0x32, 0x28, 0xaa, 0xf5, 0xb8, + 0x84, 0xc1, 0x66, 0xe7, 0x97, 0x96, 0x20, 0x2b, 0x67, 0x06, 0x2b, 0x17, 0x04, 0x49, 0xf9, 0x43, + 0x65, 0xe0, 0xea, 0xc1, 0xa6, 0xa3, 0xa9, 0x67, 0x81, 0xa8, 0x07, 0x49, 0xa1, 0xa8, 0x77, 0x72, + 0x3d, 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, 0xed, 0xf4, 0xcc, 0x92, 0x8c, + 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x70, 0xa0, 0xe9, 0x42, 0xc2, 0x2f, 0x2f, 0x3f, 0x25, 0x55, + 0xbf, 0x02, 0x11, 0x7a, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x70, 0x33, 0x06, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x34, 0xb5, 0xf0, 0xb5, 0x69, 0x01, 0x00, 0x00, +} + +func (m *Confirmation) 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 *Confirmation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Confirmation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FastOutboundCount != 0 { + i = encodeVarintConfirmation(dAtA, i, uint64(m.FastOutboundCount)) + i-- + dAtA[i] = 0x20 + } + if m.SafeOutboundCount != 0 { + i = encodeVarintConfirmation(dAtA, i, uint64(m.SafeOutboundCount)) + i-- + dAtA[i] = 0x18 + } + if m.FastInboundCount != 0 { + i = encodeVarintConfirmation(dAtA, i, uint64(m.FastInboundCount)) + i-- + dAtA[i] = 0x10 + } + if m.SafeInboundCount != 0 { + i = encodeVarintConfirmation(dAtA, i, uint64(m.SafeInboundCount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintConfirmation(dAtA []byte, offset int, v uint64) int { + offset -= sovConfirmation(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Confirmation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SafeInboundCount != 0 { + n += 1 + sovConfirmation(uint64(m.SafeInboundCount)) + } + if m.FastInboundCount != 0 { + n += 1 + sovConfirmation(uint64(m.FastInboundCount)) + } + if m.SafeOutboundCount != 0 { + n += 1 + sovConfirmation(uint64(m.SafeOutboundCount)) + } + if m.FastOutboundCount != 0 { + n += 1 + sovConfirmation(uint64(m.FastOutboundCount)) + } + return n +} + +func sovConfirmation(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozConfirmation(x uint64) (n int) { + return sovConfirmation(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Confirmation) 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 ErrIntOverflowConfirmation + } + 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: Confirmation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Confirmation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SafeInboundCount", wireType) + } + m.SafeInboundCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfirmation + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SafeInboundCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FastInboundCount", wireType) + } + m.FastInboundCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfirmation + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FastInboundCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SafeOutboundCount", wireType) + } + m.SafeOutboundCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfirmation + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SafeOutboundCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FastOutboundCount", wireType) + } + m.FastOutboundCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfirmation + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FastOutboundCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipConfirmation(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfirmation + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipConfirmation(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, ErrIntOverflowConfirmation + } + 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, ErrIntOverflowConfirmation + } + 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, ErrIntOverflowConfirmation + } + 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, ErrInvalidLengthConfirmation + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupConfirmation + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthConfirmation + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthConfirmation = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConfirmation = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConfirmation = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/observer/types/params.pb.go b/x/observer/types/params.pb.go index 803bdb97bf..375d25c4b7 100644 --- a/x/observer/types/params.pb.go +++ b/x/observer/types/params.pb.go @@ -84,6 +84,7 @@ type ChainParams struct { MinObserverDelegation cosmossdk_io_math.LegacyDec `protobuf:"bytes,15,opt,name=min_observer_delegation,json=minObserverDelegation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_observer_delegation"` IsSupported bool `protobuf:"varint,16,opt,name=is_supported,json=isSupported,proto3" json:"is_supported,omitempty"` GatewayAddress string `protobuf:"bytes,17,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` + Confirmation Confirmation `protobuf:"bytes,18,opt,name=confirmation,proto3" json:"confirmation"` } func (m *ChainParams) Reset() { *m = ChainParams{} } @@ -210,6 +211,13 @@ func (m *ChainParams) GetGatewayAddress() string { return "" } +func (m *ChainParams) GetConfirmation() Confirmation { + if m != nil { + return m.Confirmation + } + return Confirmation{} +} + // Deprecated(v17) type Params struct { // Deprecated(v17):Moved into the emissions module @@ -267,48 +275,49 @@ func init() { } var fileDescriptor_e7fa4666eddf88e5 = []byte{ - // 641 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xd1, 0x4e, 0xd4, 0x4e, - 0x14, 0xc6, 0xb7, 0xff, 0xe5, 0x8f, 0x30, 0x0b, 0xbb, 0xd0, 0xa0, 0x16, 0x36, 0x29, 0x2b, 0xc6, - 0xd8, 0x60, 0xe8, 0x1a, 0xf4, 0x52, 0x49, 0x64, 0xf1, 0x82, 0x88, 0x4a, 0x0a, 0xde, 0x68, 0xe2, - 0x64, 0x76, 0x3a, 0xb6, 0x93, 0x6d, 0x7b, 0x36, 0x33, 0x53, 0x60, 0x7d, 0x0a, 0x9f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, 0x87, - 0x8d, 0x72, 0x54, 0x64, 0x10, 0xb2, 0xee, 0xc9, 0xd5, 0xa0, 0x50, 0xa3, 0x21, 0x93, 0xfd, 0x69, - 0x3d, 0x26, 0x9e, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x11, 0xa1, 0x1e, 0xfe, 0xb1, 0x04, 0x00, - 0x00, + // 666 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcd, 0x6e, 0xd3, 0x4e, + 0x14, 0xc5, 0xe3, 0x7f, 0xfa, 0xef, 0xc7, 0x24, 0x4d, 0x5a, 0xab, 0x80, 0xdb, 0x48, 0x6e, 0x28, + 0x42, 0x18, 0x50, 0x1d, 0x54, 0x58, 0x42, 0x25, 0x92, 0xb2, 0xa8, 0x28, 0x50, 0xb9, 0x65, 0x03, + 0x12, 0xa3, 0xc9, 0x78, 0xb0, 0x47, 0xb1, 0x7d, 0xa3, 0x99, 0x71, 0xdb, 0xf0, 0x0a, 0x6c, 0x78, + 0xac, 0x2e, 0xbb, 0x44, 0x2c, 0x2a, 0xd4, 0xbe, 0x08, 0xf2, 0xd8, 0x4e, 0xd3, 0x16, 0x45, 0xec, + 0xec, 0x7b, 0x7e, 0xe7, 0xf8, 0x7a, 0x3e, 0x2e, 0x72, 0xbe, 0x31, 0x45, 0x68, 0x48, 0x78, 0xd2, + 0xd1, 0x4f, 0x20, 0x58, 0x07, 0xfa, 0x92, 0x89, 0x23, 0x26, 0x3a, 0x43, 0x22, 0x48, 0x2c, 0xdd, + 0xa1, 0x00, 0x05, 0x66, 0x6b, 0x4c, 0xba, 0x25, 0xe9, 0x96, 0xe4, 0xda, 0x4a, 0x00, 0x01, 0x68, + 0xae, 0x93, 0x3d, 0xe5, 0x96, 0x35, 0x77, 0x5a, 0x38, 0x85, 0xe4, 0x2b, 0x17, 0x31, 0x51, 0x1c, + 0x92, 0x9c, 0xd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 0x28, 0xe6, + 0x5b, 0x4b, 0x6d, 0xc3, 0x99, 0xf7, 0x6a, 0x5c, 0x1e, 0x94, 0xa5, 0xec, 0x90, 0x05, 0x44, 0xb1, + 0x63, 0x32, 0x1a, 0xef, 0xc1, 0xb2, 0xde, 0x83, 0x46, 0x51, 0x2e, 0x97, 0xfd, 0x00, 0xd5, 0x27, + 0xcf, 0xbc, 0x65, 0xb6, 0x0d, 0xa7, 0xb6, 0xf5, 0x78, 0xfa, 0x2d, 0x9c, 0x30, 0x74, 0x67, 0xb2, + 0x1f, 0xf1, 0xae, 0x85, 0x6c, 0x6c, 0xa3, 0xd9, 0xe2, 0x1e, 0xbe, 0x40, 0x77, 0x8b, 0x75, 0x8d, + 0x89, 0x4a, 0x05, 0x57, 0x23, 0xdc, 0x8f, 0x80, 0x0e, 0xa4, 0xbe, 0x1b, 0x55, 0x6f, 0x25, 0x57, + 0xdf, 0x15, 0x62, 0x57, 0x6b, 0xdd, 0x37, 0xa7, 0x17, 0xb6, 0x71, 0x76, 0x61, 0x1b, 0xbf, 0x2f, + 0x6c, 0xe3, 0xc7, 0xa5, 0x5d, 0x39, 0xbb, 0xb4, 0x2b, 0x3f, 0x2f, 0xed, 0xca, 0xa7, 0xa7, 0x01, + 0x57, 0x61, 0xda, 0x77, 0x29, 0xc4, 0x7a, 0xf0, 0x6c, 0xe6, 0x33, 0x28, 0x01, 0x9f, 0x75, 0x4e, + 0xae, 0x26, 0x90, 0x1a, 0x0d, 0x99, 0xec, 0xcf, 0xea, 0xd9, 0xf3, 0xfc, 0x4f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x9f, 0xbf, 0x13, 0xe3, 0x0a, 0x05, 0x00, 0x00, } func (m *ChainParamsList) Marshal() (dAtA []byte, err error) { @@ -368,6 +377,18 @@ func (m *ChainParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Confirmation.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 if len(m.GatewayAddress) > 0 { i -= len(m.GatewayAddress) copy(dAtA[i:], m.GatewayAddress) @@ -580,6 +601,8 @@ func (m *ChainParams) Size() (n int) { if l > 0 { n += 2 + l + sovParams(uint64(l)) } + l = m.Confirmation.Size() + n += 2 + l + sovParams(uint64(l)) return n } @@ -1082,6 +1105,39 @@ func (m *ChainParams) Unmarshal(dAtA []byte) error { } m.GatewayAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 18: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Confirmation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Confirmation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) From 9463a79d4955f573ee3ce503d058eccffe2212ca Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 3 Feb 2025 21:56:03 -0600 Subject: [PATCH 2/9] add changelog entry --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 5db074482a..f3184c5df6 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ * [3358](https://github.com/zeta-chain/node/pull/3358) - register aborted CCTX for Bitcoin inbound that carries insufficient depositor fee * [3368](https://github.com/zeta-chain/node/pull/3368) - cli command to fetch inbound ballot from inbound hash added to zetatools. * [3425](https://github.com/zeta-chain/node/pull/3425) - enable inscription parsing on Bitcoin mainnet +* [3461](https://github.com/zeta-chain/node/pull/3461) - enable multiple confirmation count values in chain params ### Refactor From a72b421e24bde748f7f6f079a51eb3e0f2fc3cfa Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 3 Feb 2025 22:24:20 -0600 Subject: [PATCH 3/9] fix unit test --- zetaclient/testutils/mocks/chain_params.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zetaclient/testutils/mocks/chain_params.go b/zetaclient/testutils/mocks/chain_params.go index 4458589ab8..a5bdeeccea 100644 --- a/zetaclient/testutils/mocks/chain_params.go +++ b/zetaclient/testutils/mocks/chain_params.go @@ -45,6 +45,10 @@ func MockChainParams(chainID int64, confirmation uint64) observertypes.ChainPara MinObserverDelegation: observertypes.DefaultMinObserverDelegation, GatewayAddress: gwAddress, IsSupported: true, + Confirmation: observertypes.Confirmation{ + SafeInboundCount: confirmation, + SafeOutboundCount: confirmation, + }, } } From d0c9bec28c16e63f58b74a5907e328bd8e6396f5 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 4 Feb 2025 12:47:36 -0600 Subject: [PATCH 4/9] rename Confirmation as ConfirmationParams; remove 0 check on safe inbound, outbound count --- changelog.md | 7 +- docs/openapi/openapi.swagger.yaml | 7 +- ...mation.proto => confirmation_params.proto} | 2 +- .../zetachain/zetacore/observer/params.proto | 6 +- testutil/sample/observer.go | 10 +- ...on_pb.d.ts => confirmation_params_pb.d.ts} | 18 +-- .../zetachain/zetacore/observer/index.d.ts | 2 +- .../zetacore/observer/params_pb.d.ts | 8 +- x/observer/migrations/v10/migrate.go | 8 +- x/observer/migrations/v10/migrate_test.go | 22 +-- x/observer/types/chain_params.go | 30 ++-- x/observer/types/chain_params_test.go | 20 +-- ...mation.pb.go => confirmation_params.pb.go} | 153 +++++++++--------- x/observer/types/params.pb.go | 103 ++++++------ zetaclient/testutils/mocks/chain_params.go | 2 +- 15 files changed, 198 insertions(+), 200 deletions(-) rename proto/zetachain/zetacore/observer/{confirmation.proto => confirmation_params.proto} (90%) rename typescript/zetachain/zetacore/observer/{confirmation_pb.d.ts => confirmation_params_pb.d.ts} (70%) rename x/observer/types/{confirmation.pb.go => confirmation_params.pb.go} (53%) diff --git a/changelog.md b/changelog.md index f3184c5df6..15e0fb1427 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # CHANGELOG +## Unreleased + +### Features + +* [3461](https://github.com/zeta-chain/node/pull/3461) - enable multiple confirmation count values in chain params + ## v27.0.0 ### Breaking Changes @@ -15,7 +21,6 @@ * [3358](https://github.com/zeta-chain/node/pull/3358) - register aborted CCTX for Bitcoin inbound that carries insufficient depositor fee * [3368](https://github.com/zeta-chain/node/pull/3368) - cli command to fetch inbound ballot from inbound hash added to zetatools. * [3425](https://github.com/zeta-chain/node/pull/3425) - enable inscription parsing on Bitcoin mainnet -* [3461](https://github.com/zeta-chain/node/pull/3461) - enable multiple confirmation count values in chain params ### Refactor diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 01eceec588..e0790b6cc7 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -59799,8 +59799,9 @@ definitions: type: boolean gateway_address: type: string - confirmation: - $ref: '#/definitions/observerConfirmation' + confirmation_params: + $ref: '#/definitions/observerConfirmationParams' + title: Advanced confirmation parameters for chain to support fast observation observerChainParamsList: type: object properties: @@ -59809,7 +59810,7 @@ definitions: items: type: object $ref: '#/definitions/observerChainParams' - observerConfirmation: + observerConfirmationParams: type: object properties: safe_inbound_count: diff --git a/proto/zetachain/zetacore/observer/confirmation.proto b/proto/zetachain/zetacore/observer/confirmation_params.proto similarity index 90% rename from proto/zetachain/zetacore/observer/confirmation.proto rename to proto/zetachain/zetacore/observer/confirmation_params.proto index 84b4a3be23..8348f2f8a8 100644 --- a/proto/zetachain/zetacore/observer/confirmation.proto +++ b/proto/zetachain/zetacore/observer/confirmation_params.proto @@ -3,7 +3,7 @@ package zetachain.zetacore.observer; option go_package = "github.com/zeta-chain/node/x/observer/types"; -message Confirmation { +message ConfirmationParams { uint64 safe_inbound_count = 1; uint64 fast_inbound_count = 2; uint64 safe_outbound_count = 3; diff --git a/proto/zetachain/zetacore/observer/params.proto b/proto/zetachain/zetacore/observer/params.proto index 0125229823..880dfb9e2d 100644 --- a/proto/zetachain/zetacore/observer/params.proto +++ b/proto/zetachain/zetacore/observer/params.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "zetachain/zetacore/observer/confirmation.proto"; +import "zetachain/zetacore/observer/confirmation_params.proto"; option go_package = "github.com/zeta-chain/node/x/observer/types"; @@ -30,7 +30,9 @@ message ChainParams { ]; bool is_supported = 16; string gateway_address = 17; - Confirmation confirmation = 18 [ (gogoproto.nullable) = false ]; + + // Advanced confirmation parameters for chain to support fast observation + ConfirmationParams confirmation_params = 18 [ (gogoproto.nullable) = false ]; } // Deprecated(v17) diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 2a86508633..6121fd7d6b 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -114,7 +114,7 @@ func ChainParams(chainID int64) *types.ChainParams { MinObserverDelegation: sdkmath.LegacyNewDec(r.Int63()), IsSupported: false, GatewayAddress: EthAddress().String(), - Confirmation: Confirmation(), + ConfirmationParams: ConfirmationParams(), } } @@ -340,14 +340,14 @@ func OperationalFlags() types.OperationalFlags { } } -func Confirmation() types.Confirmation { +func ConfirmationParams() types.ConfirmationParams { randInboundCount := Uint64InRange(1, 200) randOutboundCount := Uint64InRange(1, 200) - return types.Confirmation{ + return types.ConfirmationParams{ SafeInboundCount: randInboundCount, - FastInboundCount: randInboundCount - 1, + FastInboundCount: Uint64InRange(1, randInboundCount), SafeOutboundCount: randOutboundCount, - FastOutboundCount: randOutboundCount - 1, + FastOutboundCount: Uint64InRange(1, randOutboundCount), } } diff --git a/typescript/zetachain/zetacore/observer/confirmation_pb.d.ts b/typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts similarity index 70% rename from typescript/zetachain/zetacore/observer/confirmation_pb.d.ts rename to typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts index fa3424ae6d..eecf0e623c 100644 --- a/typescript/zetachain/zetacore/observer/confirmation_pb.d.ts +++ b/typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts @@ -1,5 +1,5 @@ // @generated by protoc-gen-es v1.3.0 with parameter "target=dts" -// @generated from file zetachain/zetacore/observer/confirmation.proto (package zetachain.zetacore.observer, syntax proto3) +// @generated from file zetachain/zetacore/observer/confirmation_params.proto (package zetachain.zetacore.observer, syntax proto3) /* eslint-disable */ // @ts-nocheck @@ -7,9 +7,9 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; /** - * @generated from message zetachain.zetacore.observer.Confirmation + * @generated from message zetachain.zetacore.observer.ConfirmationParams */ -export declare class Confirmation extends Message { +export declare class ConfirmationParams extends Message { /** * @generated from field: uint64 safe_inbound_count = 1; */ @@ -30,18 +30,18 @@ export declare class Confirmation extends Message { */ fastOutboundCount: bigint; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.Confirmation"; + static readonly typeName = "zetachain.zetacore.observer.ConfirmationParams"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): Confirmation; + static fromBinary(bytes: Uint8Array, options?: Partial): ConfirmationParams; - static fromJson(jsonValue: JsonValue, options?: Partial): Confirmation; + static fromJson(jsonValue: JsonValue, options?: Partial): ConfirmationParams; - static fromJsonString(jsonString: string, options?: Partial): Confirmation; + static fromJsonString(jsonString: string, options?: Partial): ConfirmationParams; - static equals(a: Confirmation | PlainMessage | undefined, b: Confirmation | PlainMessage | undefined): boolean; + static equals(a: ConfirmationParams | PlainMessage | undefined, b: ConfirmationParams | PlainMessage | undefined): boolean; } diff --git a/typescript/zetachain/zetacore/observer/index.d.ts b/typescript/zetachain/zetacore/observer/index.d.ts index ce79a333f4..7e44abde93 100644 --- a/typescript/zetachain/zetacore/observer/index.d.ts +++ b/typescript/zetachain/zetacore/observer/index.d.ts @@ -1,7 +1,7 @@ export * from "./ballot_pb"; export * from "./blame_pb"; export * from "./chain_nonces_pb"; -export * from "./confirmation_pb"; +export * from "./confirmation_params_pb"; export * from "./crosschain_flags_pb"; export * from "./events_pb"; export * from "./genesis_pb"; diff --git a/typescript/zetachain/zetacore/observer/params_pb.d.ts b/typescript/zetachain/zetacore/observer/params_pb.d.ts index b21d9fb4cb..6e405fe841 100644 --- a/typescript/zetachain/zetacore/observer/params_pb.d.ts +++ b/typescript/zetachain/zetacore/observer/params_pb.d.ts @@ -5,7 +5,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; -import type { Confirmation } from "./confirmation_pb.js"; +import type { ConfirmationParams } from "./confirmation_params_pb.js"; /** * @generated from message zetachain.zetacore.observer.ChainParamsList @@ -111,9 +111,11 @@ export declare class ChainParams extends Message { gatewayAddress: string; /** - * @generated from field: zetachain.zetacore.observer.Confirmation confirmation = 18; + * Advanced confirmation parameters for chain to support fast observation + * + * @generated from field: zetachain.zetacore.observer.ConfirmationParams confirmation_params = 18; */ - confirmation?: Confirmation; + confirmationParams?: ConfirmationParams; constructor(data?: PartialMessage); diff --git a/x/observer/migrations/v10/migrate.go b/x/observer/migrations/v10/migrate.go index c40a4f98aa..7f0061059c 100644 --- a/x/observer/migrations/v10/migrate.go +++ b/x/observer/migrations/v10/migrate.go @@ -27,10 +27,10 @@ func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { // set new fields to the same value as 'confirmation_count' for _, chainParams := range allChainParams.ChainParams { if chainParams != nil { - chainParams.Confirmation.SafeInboundCount = chainParams.ConfirmationCount - chainParams.Confirmation.FastInboundCount = chainParams.ConfirmationCount - chainParams.Confirmation.SafeOutboundCount = chainParams.ConfirmationCount - chainParams.Confirmation.FastOutboundCount = chainParams.ConfirmationCount + chainParams.ConfirmationParams.SafeInboundCount = chainParams.ConfirmationCount + chainParams.ConfirmationParams.FastInboundCount = chainParams.ConfirmationCount + chainParams.ConfirmationParams.SafeOutboundCount = chainParams.ConfirmationCount + chainParams.ConfirmationParams.FastOutboundCount = chainParams.ConfirmationCount } } diff --git a/x/observer/migrations/v10/migrate_test.go b/x/observer/migrations/v10/migrate_test.go index 3b307c0bc5..e1131e9dc8 100644 --- a/x/observer/migrations/v10/migrate_test.go +++ b/x/observer/migrations/v10/migrate_test.go @@ -34,13 +34,13 @@ func TestMigrateStore(t *testing.T) { // ensure the chain params are set correctly oldChainParams, found := k.GetChainParamsList(ctx) require.True(t, found) - require.EqualValues(t, chainParams, oldChainParams) + require.Equal(t, chainParams, oldChainParams) // migrate the store err := v10.MigrateStore(ctx, *k) require.NoError(t, err) - // ensure we still have 7 chain params after migration + // ensure we still have same number of chain params after migration newChainParams, found := k.GetChainParamsList(ctx) require.True(t, found) require.Len(t, newChainParams.ChainParams, len(oldChainParams.ChainParams)) @@ -50,16 +50,16 @@ func TestMigrateStore(t *testing.T) { oldParam := oldChainParams.ChainParams[i] // ensure the confirmation fields are set correctly - require.Equal(t, newParam.Confirmation.SafeInboundCount, oldParam.ConfirmationCount) - require.Equal(t, newParam.Confirmation.FastInboundCount, oldParam.ConfirmationCount) - require.Equal(t, newParam.Confirmation.SafeOutboundCount, oldParam.ConfirmationCount) - require.Equal(t, newParam.Confirmation.FastOutboundCount, oldParam.ConfirmationCount) + require.Equal(t, oldParam.ConfirmationCount, newParam.ConfirmationParams.SafeInboundCount) + require.Equal(t, oldParam.ConfirmationCount, newParam.ConfirmationParams.FastInboundCount) + require.Equal(t, oldParam.ConfirmationCount, newParam.ConfirmationParams.SafeOutboundCount) + require.Equal(t, oldParam.ConfirmationCount, newParam.ConfirmationParams.FastOutboundCount) // ensure nothing else has changed except the confirmation - oldParam.Confirmation.SafeInboundCount = oldParam.ConfirmationCount - oldParam.Confirmation.FastInboundCount = oldParam.ConfirmationCount - oldParam.Confirmation.SafeOutboundCount = oldParam.ConfirmationCount - oldParam.Confirmation.FastOutboundCount = oldParam.ConfirmationCount + oldParam.ConfirmationParams.SafeInboundCount = oldParam.ConfirmationCount + oldParam.ConfirmationParams.FastInboundCount = oldParam.ConfirmationCount + oldParam.ConfirmationParams.SafeOutboundCount = oldParam.ConfirmationCount + oldParam.ConfirmationParams.FastOutboundCount = oldParam.ConfirmationCount require.Equal(t, newParam, oldParam) } }) @@ -87,7 +87,7 @@ func TestMigrateStore(t *testing.T) { func makeChainParamsEmptyConfirmation(chainID int64, confirmationCount uint64) *types.ChainParams { chainParams := sample.ChainParams(chainID) chainParams.ConfirmationCount = confirmationCount - chainParams.Confirmation = types.Confirmation{} + chainParams.ConfirmationParams = types.ConfirmationParams{} return chainParams } diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 4047256b80..b168c43a8f 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -60,19 +60,13 @@ func ValidateChainParams(params *ChainParams) error { if params.ConfirmationCount == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "ConfirmationCount must be greater than 0") } - if params.Confirmation.SafeInboundCount == 0 { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeInboundCount must be greater than 0") - } - if params.Confirmation.FastInboundCount > params.Confirmation.SafeInboundCount { + if params.ConfirmationParams.FastInboundCount > params.ConfirmationParams.SafeInboundCount { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "FastInboundCount must be less than or equal to SafeInboundCount", ) } - if params.Confirmation.SafeOutboundCount == 0 { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeOutboundCount must be greater than 0") - } - if params.Confirmation.FastOutboundCount > params.Confirmation.SafeOutboundCount { + if params.ConfirmationParams.FastOutboundCount > params.ConfirmationParams.SafeOutboundCount { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "FastOutboundCount must be less than or equal to SafeOutboundCount", @@ -189,7 +183,7 @@ func GetDefaultEthMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 14, FastInboundCount: 14, SafeOutboundCount: 14, @@ -213,7 +207,7 @@ func GetDefaultBscMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 14, FastInboundCount: 14, SafeOutboundCount: 14, @@ -237,7 +231,7 @@ func GetDefaultBtcMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 2, SafeOutboundCount: 2, @@ -262,7 +256,7 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 6, FastInboundCount: 6, SafeOutboundCount: 6, @@ -286,7 +280,7 @@ func GetDefaultBscTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 6, FastInboundCount: 6, SafeOutboundCount: 6, @@ -310,7 +304,7 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 12, FastInboundCount: 12, SafeOutboundCount: 12, @@ -334,7 +328,7 @@ func GetDefaultBtcTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 2, SafeOutboundCount: 2, @@ -358,7 +352,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 1, FastInboundCount: 1, SafeOutboundCount: 1, @@ -383,7 +377,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", - Confirmation: Confirmation{ + ConfirmationParams: ConfirmationParams{ SafeInboundCount: 1, FastInboundCount: 1, SafeOutboundCount: 1, @@ -427,5 +421,5 @@ func ChainParamsEqual(params1, params2 ChainParams) bool { params1.MinObserverDelegation.Equal(params2.MinObserverDelegation) && params1.IsSupported == params2.IsSupported && params1.GatewayAddress == params2.GatewayAddress && - params1.Confirmation == params2.Confirmation + params1.ConfirmationParams == params2.ConfirmationParams } diff --git a/x/observer/types/chain_params_test.go b/x/observer/types/chain_params_test.go index 9be72d4d5b..3fc2709dbb 100644 --- a/x/observer/types/chain_params_test.go +++ b/x/observer/types/chain_params_test.go @@ -69,7 +69,7 @@ func (s *UpdateChainParamsSuite) SetupTest() { MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", - Confirmation: types.Confirmation{ + ConfirmationParams: types.ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 0, // zero means disabled SafeOutboundCount: 2, @@ -91,9 +91,9 @@ func (s *UpdateChainParamsSuite) SetupTest() { BallotThreshold: types.DefaultBallotThreshold, MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, - Confirmation: types.Confirmation{ - SafeInboundCount: 1, - FastInboundCount: 0, // zero means disabled + ConfirmationParams: types.ConfirmationParams{ + SafeInboundCount: 0, // zero means fallback to confirmation count + FastInboundCount: 0, SafeOutboundCount: 1, FastOutboundCount: 1, }, @@ -158,20 +158,12 @@ func (s *UpdateChainParamsSuite) Validate(params *types.ChainParams) { require.NotNil(s.T(), err) copy = *params - copy.Confirmation.SafeInboundCount = 0 - err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) - copy = *params - copy.Confirmation.FastInboundCount = copy.Confirmation.SafeInboundCount + 1 + copy.ConfirmationParams.FastInboundCount = copy.ConfirmationParams.SafeInboundCount + 1 err = types.ValidateChainParams(©) require.NotNil(s.T(), err) copy = *params - copy.Confirmation.SafeOutboundCount = 0 - err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) - copy = *params - copy.Confirmation.FastOutboundCount = copy.Confirmation.SafeOutboundCount + 1 + copy.ConfirmationParams.FastOutboundCount = copy.ConfirmationParams.SafeOutboundCount + 1 err = types.ValidateChainParams(©) require.NotNil(s.T(), err) diff --git a/x/observer/types/confirmation.pb.go b/x/observer/types/confirmation_params.pb.go similarity index 53% rename from x/observer/types/confirmation.pb.go rename to x/observer/types/confirmation_params.pb.go index 8a6bb58c28..60232a7dd6 100644 --- a/x/observer/types/confirmation.pb.go +++ b/x/observer/types/confirmation_params.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: zetachain/zetacore/observer/confirmation.proto +// source: zetachain/zetacore/observer/confirmation_params.proto package types @@ -22,25 +22,25 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type Confirmation struct { +type ConfirmationParams struct { SafeInboundCount uint64 `protobuf:"varint,1,opt,name=safe_inbound_count,json=safeInboundCount,proto3" json:"safe_inbound_count,omitempty"` FastInboundCount uint64 `protobuf:"varint,2,opt,name=fast_inbound_count,json=fastInboundCount,proto3" json:"fast_inbound_count,omitempty"` SafeOutboundCount uint64 `protobuf:"varint,3,opt,name=safe_outbound_count,json=safeOutboundCount,proto3" json:"safe_outbound_count,omitempty"` FastOutboundCount uint64 `protobuf:"varint,4,opt,name=fast_outbound_count,json=fastOutboundCount,proto3" json:"fast_outbound_count,omitempty"` } -func (m *Confirmation) Reset() { *m = Confirmation{} } -func (m *Confirmation) String() string { return proto.CompactTextString(m) } -func (*Confirmation) ProtoMessage() {} -func (*Confirmation) Descriptor() ([]byte, []int) { - return fileDescriptor_26b45655bc4002d5, []int{0} +func (m *ConfirmationParams) Reset() { *m = ConfirmationParams{} } +func (m *ConfirmationParams) String() string { return proto.CompactTextString(m) } +func (*ConfirmationParams) ProtoMessage() {} +func (*ConfirmationParams) Descriptor() ([]byte, []int) { + return fileDescriptor_3d50fce477b3e8db, []int{0} } -func (m *Confirmation) XXX_Unmarshal(b []byte) error { +func (m *ConfirmationParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Confirmation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ConfirmationParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Confirmation.Marshal(b, m, deterministic) + return xxx_messageInfo_ConfirmationParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -50,40 +50,40 @@ func (m *Confirmation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *Confirmation) XXX_Merge(src proto.Message) { - xxx_messageInfo_Confirmation.Merge(m, src) +func (m *ConfirmationParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConfirmationParams.Merge(m, src) } -func (m *Confirmation) XXX_Size() int { +func (m *ConfirmationParams) XXX_Size() int { return m.Size() } -func (m *Confirmation) XXX_DiscardUnknown() { - xxx_messageInfo_Confirmation.DiscardUnknown(m) +func (m *ConfirmationParams) XXX_DiscardUnknown() { + xxx_messageInfo_ConfirmationParams.DiscardUnknown(m) } -var xxx_messageInfo_Confirmation proto.InternalMessageInfo +var xxx_messageInfo_ConfirmationParams proto.InternalMessageInfo -func (m *Confirmation) GetSafeInboundCount() uint64 { +func (m *ConfirmationParams) GetSafeInboundCount() uint64 { if m != nil { return m.SafeInboundCount } return 0 } -func (m *Confirmation) GetFastInboundCount() uint64 { +func (m *ConfirmationParams) GetFastInboundCount() uint64 { if m != nil { return m.FastInboundCount } return 0 } -func (m *Confirmation) GetSafeOutboundCount() uint64 { +func (m *ConfirmationParams) GetSafeOutboundCount() uint64 { if m != nil { return m.SafeOutboundCount } return 0 } -func (m *Confirmation) GetFastOutboundCount() uint64 { +func (m *ConfirmationParams) GetFastOutboundCount() uint64 { if m != nil { return m.FastOutboundCount } @@ -91,33 +91,34 @@ func (m *Confirmation) GetFastOutboundCount() uint64 { } func init() { - proto.RegisterType((*Confirmation)(nil), "zetachain.zetacore.observer.Confirmation") + proto.RegisterType((*ConfirmationParams)(nil), "zetachain.zetacore.observer.ConfirmationParams") } func init() { - proto.RegisterFile("zetachain/zetacore/observer/confirmation.proto", fileDescriptor_26b45655bc4002d5) + proto.RegisterFile("zetachain/zetacore/observer/confirmation_params.proto", fileDescriptor_3d50fce477b3e8db) } -var fileDescriptor_26b45655bc4002d5 = []byte{ - // 236 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xab, 0x4a, 0x2d, 0x49, - 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x07, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0xf3, 0x93, 0x8a, 0x53, - 0x8b, 0xca, 0x52, 0x8b, 0xf4, 0x93, 0xf3, 0xf3, 0xd2, 0x32, 0x8b, 0x72, 0x13, 0x4b, 0x32, 0xf3, - 0xf3, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xa4, 0xe1, 0xea, 0xf5, 0x60, 0xea, 0xf5, 0x60, - 0xea, 0x95, 0x4e, 0x31, 0x72, 0xf1, 0x38, 0x23, 0xe9, 0x11, 0xd2, 0xe1, 0x12, 0x2a, 0x4e, 0x4c, - 0x4b, 0x8d, 0xcf, 0xcc, 0x4b, 0xca, 0x2f, 0xcd, 0x4b, 0x89, 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x91, - 0x60, 0x54, 0x60, 0xd4, 0x60, 0x09, 0x12, 0x00, 0xc9, 0x78, 0x42, 0x24, 0x9c, 0x41, 0xe2, 0x20, - 0xd5, 0x69, 0x89, 0xc5, 0x25, 0x68, 0xaa, 0x99, 0x20, 0xaa, 0x41, 0x32, 0x28, 0xaa, 0xf5, 0xb8, - 0x84, 0xc1, 0x66, 0xe7, 0x97, 0x96, 0x20, 0x2b, 0x67, 0x06, 0x2b, 0x17, 0x04, 0x49, 0xf9, 0x43, - 0x65, 0xe0, 0xea, 0xc1, 0xa6, 0xa3, 0xa9, 0x67, 0x81, 0xa8, 0x07, 0x49, 0xa1, 0xa8, 0x77, 0x72, - 0x3d, 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, 0xed, 0xf4, 0xcc, 0x92, 0x8c, - 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x70, 0xa0, 0xe9, 0x42, 0xc2, 0x2f, 0x2f, 0x3f, 0x25, 0x55, - 0xbf, 0x02, 0x11, 0x7a, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x70, 0x33, 0x06, 0x04, - 0x00, 0x00, 0xff, 0xff, 0x34, 0xb5, 0xf0, 0xb5, 0x69, 0x01, 0x00, 0x00, +var fileDescriptor_3d50fce477b3e8db = []byte{ + // 244 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xbf, 0x4e, 0xc5, 0x20, + 0x14, 0x87, 0x8b, 0xde, 0x38, 0x74, 0xd2, 0xba, 0x98, 0x98, 0x10, 0xe3, 0x64, 0xa2, 0xc2, 0x60, + 0x7c, 0x01, 0x6f, 0x1c, 0x9c, 0x34, 0x8e, 0x2e, 0x0d, 0x70, 0xa9, 0x97, 0xa1, 0x9c, 0x06, 0x0e, + 0x46, 0x7d, 0x0a, 0x1f, 0xcb, 0xb1, 0xa3, 0xa3, 0x69, 0x5f, 0xc4, 0x00, 0xde, 0x7f, 0xdd, 0x08, + 0xdf, 0xf7, 0x9d, 0xe1, 0x57, 0xde, 0x7e, 0x6a, 0x14, 0x6a, 0x29, 0x8c, 0xe5, 0xe9, 0x05, 0x4e, + 0x73, 0x90, 0x5e, 0xbb, 0x37, 0xed, 0xb8, 0x02, 0xdb, 0x18, 0xd7, 0x0a, 0x34, 0x60, 0xeb, 0x4e, + 0x38, 0xd1, 0x7a, 0xd6, 0x39, 0x40, 0xa8, 0x4e, 0xd7, 0x19, 0x5b, 0x65, 0x6c, 0x95, 0x9d, 0xf7, + 0xa4, 0xac, 0xe6, 0x5b, 0xe9, 0x53, 0x2a, 0xab, 0xab, 0xb2, 0xf2, 0xa2, 0xd1, 0xb5, 0xb1, 0x12, + 0x82, 0x5d, 0xd4, 0x0a, 0x82, 0xc5, 0x13, 0x72, 0x46, 0x2e, 0x66, 0xcf, 0x87, 0x91, 0x3c, 0x64, + 0x30, 0x8f, 0xff, 0xd1, 0x6e, 0x84, 0xc7, 0x89, 0xbd, 0x97, 0xed, 0x48, 0x76, 0x6c, 0x56, 0x1e, + 0xa7, 0xdb, 0x10, 0x70, 0x5b, 0xdf, 0x4f, 0xfa, 0x51, 0x44, 0x8f, 0xff, 0x64, 0xed, 0xa7, 0xeb, + 0x13, 0x7f, 0x96, 0xfd, 0x88, 0x76, 0xfc, 0xbb, 0xfb, 0xef, 0x81, 0x92, 0x7e, 0xa0, 0xe4, 0x77, + 0xa0, 0xe4, 0x6b, 0xa4, 0x45, 0x3f, 0xd2, 0xe2, 0x67, 0xa4, 0xc5, 0xcb, 0xe5, 0xab, 0xc1, 0x65, + 0x90, 0x4c, 0x41, 0x9b, 0x16, 0xbc, 0xce, 0x63, 0x5a, 0x58, 0x68, 0xfe, 0xbe, 0x99, 0x12, 0x3f, + 0x3a, 0xed, 0xe5, 0x41, 0x5a, 0xef, 0xe6, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x5a, 0xf5, 0x7c, + 0x76, 0x01, 0x00, 0x00, } -func (m *Confirmation) Marshal() (dAtA []byte, err error) { +func (m *ConfirmationParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -127,41 +128,41 @@ func (m *Confirmation) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Confirmation) MarshalTo(dAtA []byte) (int, error) { +func (m *ConfirmationParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Confirmation) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ConfirmationParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l if m.FastOutboundCount != 0 { - i = encodeVarintConfirmation(dAtA, i, uint64(m.FastOutboundCount)) + i = encodeVarintConfirmationParams(dAtA, i, uint64(m.FastOutboundCount)) i-- dAtA[i] = 0x20 } if m.SafeOutboundCount != 0 { - i = encodeVarintConfirmation(dAtA, i, uint64(m.SafeOutboundCount)) + i = encodeVarintConfirmationParams(dAtA, i, uint64(m.SafeOutboundCount)) i-- dAtA[i] = 0x18 } if m.FastInboundCount != 0 { - i = encodeVarintConfirmation(dAtA, i, uint64(m.FastInboundCount)) + i = encodeVarintConfirmationParams(dAtA, i, uint64(m.FastInboundCount)) i-- dAtA[i] = 0x10 } if m.SafeInboundCount != 0 { - i = encodeVarintConfirmation(dAtA, i, uint64(m.SafeInboundCount)) + i = encodeVarintConfirmationParams(dAtA, i, uint64(m.SafeInboundCount)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func encodeVarintConfirmation(dAtA []byte, offset int, v uint64) int { - offset -= sovConfirmation(v) +func encodeVarintConfirmationParams(dAtA []byte, offset int, v uint64) int { + offset -= sovConfirmationParams(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -171,34 +172,34 @@ func encodeVarintConfirmation(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Confirmation) Size() (n int) { +func (m *ConfirmationParams) Size() (n int) { if m == nil { return 0 } var l int _ = l if m.SafeInboundCount != 0 { - n += 1 + sovConfirmation(uint64(m.SafeInboundCount)) + n += 1 + sovConfirmationParams(uint64(m.SafeInboundCount)) } if m.FastInboundCount != 0 { - n += 1 + sovConfirmation(uint64(m.FastInboundCount)) + n += 1 + sovConfirmationParams(uint64(m.FastInboundCount)) } if m.SafeOutboundCount != 0 { - n += 1 + sovConfirmation(uint64(m.SafeOutboundCount)) + n += 1 + sovConfirmationParams(uint64(m.SafeOutboundCount)) } if m.FastOutboundCount != 0 { - n += 1 + sovConfirmation(uint64(m.FastOutboundCount)) + n += 1 + sovConfirmationParams(uint64(m.FastOutboundCount)) } return n } -func sovConfirmation(x uint64) (n int) { +func sovConfirmationParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozConfirmation(x uint64) (n int) { - return sovConfirmation(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozConfirmationParams(x uint64) (n int) { + return sovConfirmationParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Confirmation) Unmarshal(dAtA []byte) error { +func (m *ConfirmationParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -206,7 +207,7 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowConfirmation + return ErrIntOverflowConfirmationParams } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -221,10 +222,10 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Confirmation: wiretype end group for non-group") + return fmt.Errorf("proto: ConfirmationParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Confirmation: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ConfirmationParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -234,7 +235,7 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { m.SafeInboundCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowConfirmation + return ErrIntOverflowConfirmationParams } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -253,7 +254,7 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { m.FastInboundCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowConfirmation + return ErrIntOverflowConfirmationParams } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -272,7 +273,7 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { m.SafeOutboundCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowConfirmation + return ErrIntOverflowConfirmationParams } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -291,7 +292,7 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { m.FastOutboundCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowConfirmation + return ErrIntOverflowConfirmationParams } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -305,12 +306,12 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipConfirmation(dAtA[iNdEx:]) + skippy, err := skipConfirmationParams(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthConfirmation + return ErrInvalidLengthConfirmationParams } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -324,7 +325,7 @@ func (m *Confirmation) Unmarshal(dAtA []byte) error { } return nil } -func skipConfirmation(dAtA []byte) (n int, err error) { +func skipConfirmationParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -332,7 +333,7 @@ func skipConfirmation(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowConfirmation + return 0, ErrIntOverflowConfirmationParams } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -349,7 +350,7 @@ func skipConfirmation(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowConfirmation + return 0, ErrIntOverflowConfirmationParams } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -365,7 +366,7 @@ func skipConfirmation(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowConfirmation + return 0, ErrIntOverflowConfirmationParams } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -378,14 +379,14 @@ func skipConfirmation(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthConfirmation + return 0, ErrInvalidLengthConfirmationParams } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupConfirmation + return 0, ErrUnexpectedEndOfGroupConfirmationParams } depth-- case 5: @@ -394,7 +395,7 @@ func skipConfirmation(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthConfirmation + return 0, ErrInvalidLengthConfirmationParams } if depth == 0 { return iNdEx, nil @@ -404,7 +405,7 @@ func skipConfirmation(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthConfirmation = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowConfirmation = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupConfirmation = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthConfirmationParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConfirmationParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConfirmationParams = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/observer/types/params.pb.go b/x/observer/types/params.pb.go index 375d25c4b7..d91777431e 100644 --- a/x/observer/types/params.pb.go +++ b/x/observer/types/params.pb.go @@ -84,7 +84,8 @@ type ChainParams struct { MinObserverDelegation cosmossdk_io_math.LegacyDec `protobuf:"bytes,15,opt,name=min_observer_delegation,json=minObserverDelegation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_observer_delegation"` IsSupported bool `protobuf:"varint,16,opt,name=is_supported,json=isSupported,proto3" json:"is_supported,omitempty"` GatewayAddress string `protobuf:"bytes,17,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` - Confirmation Confirmation `protobuf:"bytes,18,opt,name=confirmation,proto3" json:"confirmation"` + // Advanced confirmation parameters for chain to support fast observation + ConfirmationParams ConfirmationParams `protobuf:"bytes,18,opt,name=confirmation_params,json=confirmationParams,proto3" json:"confirmation_params"` } func (m *ChainParams) Reset() { *m = ChainParams{} } @@ -211,11 +212,11 @@ func (m *ChainParams) GetGatewayAddress() string { return "" } -func (m *ChainParams) GetConfirmation() Confirmation { +func (m *ChainParams) GetConfirmationParams() ConfirmationParams { if m != nil { - return m.Confirmation + return m.ConfirmationParams } - return Confirmation{} + return ConfirmationParams{} } // Deprecated(v17) @@ -275,49 +276,49 @@ func init() { } var fileDescriptor_e7fa4666eddf88e5 = []byte{ - // 666 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcd, 0x6e, 0xd3, 0x4e, - 0x14, 0xc5, 0xe3, 0x7f, 0xfa, 0xef, 0xc7, 0x24, 0x4d, 0x5a, 0xab, 0x80, 0xdb, 0x48, 0x6e, 0x28, - 0x42, 0x18, 0x50, 0x1d, 0x54, 0x58, 0x42, 0x25, 0x92, 0xb2, 0xa8, 0x28, 0x50, 0xb9, 0x65, 0x03, - 0x12, 0xa3, 0xc9, 0x78, 0xb0, 0x47, 0xb1, 0x7d, 0xa3, 0x99, 0x71, 0xdb, 0xf0, 0x0a, 0x6c, 0x78, - 0xac, 0x2e, 0xbb, 0x44, 0x2c, 0x2a, 0xd4, 0xbe, 0x08, 0xf2, 0xd8, 0x4e, 0xd3, 0x16, 0x45, 0xec, - 0xec, 0x7b, 0x7e, 0xe7, 0xf8, 0x7a, 0x3e, 0x2e, 0x72, 0xbe, 0x31, 0x45, 0x68, 0x48, 0x78, 0xd2, - 0xd1, 0x4f, 0x20, 0x58, 0x07, 0xfa, 0x92, 0x89, 0x23, 0x26, 0x3a, 0x43, 0x22, 0x48, 0x2c, 0xdd, - 0xa1, 0x00, 0x05, 0x66, 0x6b, 0x4c, 0xba, 0x25, 0xe9, 0x96, 0xe4, 0xda, 0x4a, 0x00, 0x01, 0x68, - 0xae, 0x93, 0x3d, 0xe5, 0x96, 0x35, 0x77, 0x5a, 0x38, 0x85, 0xe4, 0x2b, 0x17, 0x31, 0x51, 0x1c, - 0x92, 0x9c, 0xdf, 0xf8, 0x82, 0x9a, 0xbd, 0x8c, 0xde, 0xd7, 0xdf, 0xdd, 0xe3, 0x52, 0x99, 0x6f, - 0x51, 0x5d, 0x07, 0xe0, 0xbc, 0x17, 0xcb, 0x68, 0x57, 0x9d, 0xda, 0x96, 0xe3, 0x4e, 0x69, 0xc6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x97, 0xfd, 0x00, 0xd5, 0x27, - 0xcf, 0xbc, 0x65, 0xb6, 0x0d, 0xa7, 0xb6, 0xf5, 0x78, 0xfa, 0x2d, 0x9c, 0x30, 0x74, 0x67, 0xb2, - 0x1f, 0xf1, 0xae, 0x85, 0x6c, 0x6c, 0xa3, 0xd9, 0xe2, 0x1e, 0xbe, 0x40, 0x77, 0x8b, 0x75, 0x8d, - 0x89, 0x4a, 0x05, 0x57, 0x23, 0xdc, 0x8f, 0x80, 0x0e, 0xa4, 0xbe, 0x1b, 0x55, 0x6f, 0x25, 0x57, - 0xdf, 0x15, 0x62, 0x57, 0x6b, 0xdd, 0x37, 0xa7, 0x17, 0xb6, 0x71, 0x76, 0x61, 0x1b, 0xbf, 0x2f, - 0x6c, 0xe3, 0xc7, 0xa5, 0x5d, 0x39, 0xbb, 0xb4, 0x2b, 0x3f, 0x2f, 0xed, 0xca, 0xa7, 0xa7, 0x01, - 0x57, 0x61, 0xda, 0x77, 0x29, 0xc4, 0x7a, 0xf0, 0x6c, 0xe6, 0x33, 0x28, 0x01, 0x9f, 0x75, 0x4e, - 0xae, 0x26, 0x90, 0x1a, 0x0d, 0x99, 0xec, 0xcf, 0xea, 0xd9, 0xf3, 0xfc, 0x4f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x9f, 0xbf, 0x13, 0xe3, 0x0a, 0x05, 0x00, 0x00, + // 670 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdf, 0x4e, 0xd4, 0x40, + 0x14, 0xc6, 0xb7, 0x2e, 0xf2, 0x67, 0x16, 0x76, 0xa1, 0xa2, 0x16, 0x36, 0x59, 0x56, 0x8c, 0xb1, + 0xd1, 0xd0, 0x1a, 0xd4, 0x3b, 0x25, 0x71, 0x17, 0x2f, 0x88, 0xa8, 0xa4, 0xe0, 0x8d, 0x26, 0x36, + 0xb3, 0xd3, 0xa1, 0x9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0x25, 0x23, 0x7d, 0xca, 0xad, + 0x3b, 0x0a, 0xae, 0x87, 0x58, 0xec, 0xe4, 0xe5, 0x3d, 0x55, 0x35, 0x9f, 0xa0, 0x3a, 0x4b, 0x7b, + 0x90, 0xa5, 0x41, 0xc9, 0x55, 0x15, 0x37, 0xa7, 0xab, 0x1a, 0x7b, 0x8a, 0x1a, 0x90, 0xc9, 0x4b, + 0xdc, 0x44, 0x91, 0x57, 0x96, 0x35, 0xf8, 0x0c, 0x2d, 0x1c, 0x62, 0x49, 0x22, 0x3f, 0x93, 0x47, + 0x50, 0xa2, 0x77, 0x15, 0xda, 0x50, 0xc2, 0x17, 0x79, 0x04, 0x9a, 0x7d, 0x8b, 0xd4, 0x59, 0xfa, + 0x12, 0xfa, 0x34, 0xff, 0xa5, 0x54, 0x72, 0x4c, 0xa4, 0x8f, 0x83, 0x80, 0x53, 0x21, 0xac, 0xe9, + 0xb6, 0x61, 0xcf, 0x78, 0x56, 0x8e, 0xec, 0xe5, 0x44, 0x57, 0x03, 0xef, 0x0a, 0xdd, 0x7c, 0x83, + 0x96, 0x09, 0xa4, 0x29, 0x25, 0x12, 0xf8, 0x75, 0xf7, 0x4c, 0xe1, 0x1e, 0x11, 0x57, 0xdd, 0x5d, + 0xd4, 0xa2, 0x9c, 0xac, 0xbf, 0xf0, 0x49, 0x26, 0x24, 0x04, 0xc3, 0xeb, 0x09, 0x48, 0x25, 0x34, + 0x15, 0xd5, 0x2d, 0xa0, 0x1b, 0x96, 0x30, 0xda, 0x16, 0x41, 0x22, 0x1a, 0x64, 0x31, 0xf5, 0x59, + 0x2a, 0x29, 0x3f, 0xc0, 0xb1, 0x35, 0xab, 0xce, 0xd0, 0x2a, 0x89, 0x5d, 0x0d, 0x6c, 0x69, 0xdd, + 0xdc, 0x40, 0xcd, 0xeb, 0xee, 0x18, 0xa0, 0x8f, 0x23, 0x8a, 0x03, 0x6b, 0x4e, 0xd9, 0x97, 0xae, + 0xda, 0xb7, 0x4b, 0xc0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x3f, 0x3e, 0x6b, 0x19, 0x27, 0x67, + 0x2d, 0xe3, 0xef, 0x59, 0xcb, 0xf8, 0x79, 0xde, 0xaa, 0x9c, 0x9c, 0xb7, 0x2a, 0xbf, 0xcf, 0x5b, + 0x95, 0xaf, 0xcf, 0x43, 0x26, 0xa3, 0xac, 0xe7, 0x10, 0x48, 0xd4, 0x48, 0x5a, 0x2b, 0xa6, 0x53, + 0x0a, 0x01, 0x75, 0x8f, 0x2e, 0x66, 0x93, 0x1c, 0x0e, 0xa8, 0xe8, 0x4d, 0xaa, 0x71, 0xf4, 0xf2, + 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc8, 0xe5, 0x29, 0x22, 0x24, 0x05, 0x00, 0x00, } func (m *ChainParamsList) Marshal() (dAtA []byte, err error) { @@ -378,7 +379,7 @@ func (m *ChainParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.Confirmation.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ConfirmationParams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -601,7 +602,7 @@ func (m *ChainParams) Size() (n int) { if l > 0 { n += 2 + l + sovParams(uint64(l)) } - l = m.Confirmation.Size() + l = m.ConfirmationParams.Size() n += 2 + l + sovParams(uint64(l)) return n } @@ -1107,7 +1108,7 @@ func (m *ChainParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 18: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Confirmation", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConfirmationParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1134,7 +1135,7 @@ func (m *ChainParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Confirmation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ConfirmationParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/zetaclient/testutils/mocks/chain_params.go b/zetaclient/testutils/mocks/chain_params.go index a5bdeeccea..5cb3c18862 100644 --- a/zetaclient/testutils/mocks/chain_params.go +++ b/zetaclient/testutils/mocks/chain_params.go @@ -45,7 +45,7 @@ func MockChainParams(chainID int64, confirmation uint64) observertypes.ChainPara MinObserverDelegation: observertypes.DefaultMinObserverDelegation, GatewayAddress: gwAddress, IsSupported: true, - Confirmation: observertypes.Confirmation{ + ConfirmationParams: observertypes.ConfirmationParams{ SafeInboundCount: confirmation, SafeOutboundCount: confirmation, }, From 6c5c55f03d0909499811b873458a5ec3cc2f0668 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 4 Feb 2025 12:57:01 -0600 Subject: [PATCH 5/9] leave ConfirmationParams as empty in mock chain params, we don't check 0 count any more --- zetaclient/testutils/mocks/chain_params.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zetaclient/testutils/mocks/chain_params.go b/zetaclient/testutils/mocks/chain_params.go index 5cb3c18862..4458589ab8 100644 --- a/zetaclient/testutils/mocks/chain_params.go +++ b/zetaclient/testutils/mocks/chain_params.go @@ -45,10 +45,6 @@ func MockChainParams(chainID int64, confirmation uint64) observertypes.ChainPara MinObserverDelegation: observertypes.DefaultMinObserverDelegation, GatewayAddress: gwAddress, IsSupported: true, - ConfirmationParams: observertypes.ConfirmationParams{ - SafeInboundCount: confirmation, - SafeOutboundCount: confirmation, - }, } } From 58928a67b2b02c722a021a31ea77ebc39b7eb3b0 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 4 Feb 2025 14:08:57 -0600 Subject: [PATCH 6/9] mark chain params ConfirmationCount as deprecated --- docs/openapi/openapi.swagger.yaml | 1 + .../zetachain/zetacore/observer/params.proto | 3 +- .../zetacore/observer/params_pb.d.ts | 5 +- x/observer/types/chain_params.go | 9 ++ x/observer/types/chain_params_test.go | 18 +++- x/observer/types/params.pb.go | 93 ++++++++++--------- zetaclient/testutils/mocks/chain_params.go | 4 + 7 files changed, 81 insertions(+), 52 deletions(-) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index e0790b6cc7..57548e8682 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -59767,6 +59767,7 @@ definitions: confirmation_count: type: string format: uint64 + title: 'Deprecated(v28): use confirmation_params instead' gas_price_ticker: type: string format: uint64 diff --git a/proto/zetachain/zetacore/observer/params.proto b/proto/zetachain/zetacore/observer/params.proto index 880dfb9e2d..792cf94514 100644 --- a/proto/zetachain/zetacore/observer/params.proto +++ b/proto/zetachain/zetacore/observer/params.proto @@ -10,7 +10,8 @@ message ChainParamsList { repeated ChainParams chain_params = 1; } message ChainParams { int64 chain_id = 11; - uint64 confirmation_count = 1; + // Deprecated(v28): use confirmation_params instead + uint64 confirmation_count = 1 [ deprecated = true ]; uint64 gas_price_ticker = 2; uint64 inbound_ticker = 3; uint64 outbound_ticker = 4; diff --git a/typescript/zetachain/zetacore/observer/params_pb.d.ts b/typescript/zetachain/zetacore/observer/params_pb.d.ts index 6e405fe841..3309a91a5f 100644 --- a/typescript/zetachain/zetacore/observer/params_pb.d.ts +++ b/typescript/zetachain/zetacore/observer/params_pb.d.ts @@ -41,7 +41,10 @@ export declare class ChainParams extends Message { chainId: bigint; /** - * @generated from field: uint64 confirmation_count = 1; + * Deprecated(v28): use confirmation_params instead + * + * @generated from field: uint64 confirmation_count = 1 [deprecated = true]; + * @deprecated */ confirmationCount: bigint; diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index b168c43a8f..f7c422ee83 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -57,15 +57,24 @@ func ValidateChainParams(params *ChainParams) error { } // validate confirmation counts + // TODO: ensure 'ConfirmationCount === 0' in the chain params update msg after migration (no other values allowed) + // zetaclient will unconditionally use 'ConfirmationParams' fields in the future + // https://github.com/zeta-chain/node/issues/3466 if params.ConfirmationCount == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "ConfirmationCount must be greater than 0") } + if params.ConfirmationParams.SafeInboundCount == 0 { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeInboundCount must be greater than 0") + } if params.ConfirmationParams.FastInboundCount > params.ConfirmationParams.SafeInboundCount { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "FastInboundCount must be less than or equal to SafeInboundCount", ) } + if params.ConfirmationParams.SafeOutboundCount == 0 { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeOutboundCount must be greater than 0") + } if params.ConfirmationParams.FastOutboundCount > params.ConfirmationParams.SafeOutboundCount { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, diff --git a/x/observer/types/chain_params_test.go b/x/observer/types/chain_params_test.go index 3fc2709dbb..ef0309fec5 100644 --- a/x/observer/types/chain_params_test.go +++ b/x/observer/types/chain_params_test.go @@ -71,9 +71,9 @@ func (s *UpdateChainParamsSuite) SetupTest() { GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", ConfirmationParams: types.ConfirmationParams{ SafeInboundCount: 2, - FastInboundCount: 0, // zero means disabled + FastInboundCount: 0, // zero means fast observation is disabled SafeOutboundCount: 2, - FastOutboundCount: 1, + FastOutboundCount: 0, // zero means fast observation is disabled }, } s.btcParams = &types.ChainParams{ @@ -92,9 +92,9 @@ func (s *UpdateChainParamsSuite) SetupTest() { MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, ConfirmationParams: types.ConfirmationParams{ - SafeInboundCount: 0, // zero means fallback to confirmation count - FastInboundCount: 0, - SafeOutboundCount: 1, + SafeInboundCount: 2, + FastInboundCount: 1, + SafeOutboundCount: 2, FastOutboundCount: 1, }, } @@ -157,11 +157,19 @@ func (s *UpdateChainParamsSuite) Validate(params *types.ChainParams) { err := types.ValidateChainParams(©) require.NotNil(s.T(), err) + copy = *params + copy.ConfirmationParams.SafeInboundCount = 0 + err = types.ValidateChainParams(©) + require.NotNil(s.T(), err) copy = *params copy.ConfirmationParams.FastInboundCount = copy.ConfirmationParams.SafeInboundCount + 1 err = types.ValidateChainParams(©) require.NotNil(s.T(), err) + copy = *params + copy.ConfirmationParams.SafeOutboundCount = 0 + err = types.ValidateChainParams(©) + require.NotNil(s.T(), err) copy = *params copy.ConfirmationParams.FastOutboundCount = copy.ConfirmationParams.SafeOutboundCount + 1 err = types.ValidateChainParams(©) diff --git a/x/observer/types/params.pb.go b/x/observer/types/params.pb.go index d91777431e..bfe945e54f 100644 --- a/x/observer/types/params.pb.go +++ b/x/observer/types/params.pb.go @@ -69,8 +69,9 @@ func (m *ChainParamsList) GetChainParams() []*ChainParams { } type ChainParams struct { - ChainId int64 `protobuf:"varint,11,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - ConfirmationCount uint64 `protobuf:"varint,1,opt,name=confirmation_count,json=confirmationCount,proto3" json:"confirmation_count,omitempty"` + ChainId int64 `protobuf:"varint,11,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // Deprecated(v28): use confirmation_params instead + ConfirmationCount uint64 `protobuf:"varint,1,opt,name=confirmation_count,json=confirmationCount,proto3" json:"confirmation_count,omitempty"` // Deprecated: Do not use. GasPriceTicker uint64 `protobuf:"varint,2,opt,name=gas_price_ticker,json=gasPriceTicker,proto3" json:"gas_price_ticker,omitempty"` InboundTicker uint64 `protobuf:"varint,3,opt,name=inbound_ticker,json=inboundTicker,proto3" json:"inbound_ticker,omitempty"` OutboundTicker uint64 `protobuf:"varint,4,opt,name=outbound_ticker,json=outboundTicker,proto3" json:"outbound_ticker,omitempty"` @@ -128,6 +129,7 @@ func (m *ChainParams) GetChainId() int64 { return 0 } +// Deprecated: Do not use. func (m *ChainParams) GetConfirmationCount() uint64 { if m != nil { return m.ConfirmationCount @@ -276,49 +278,50 @@ func init() { } var fileDescriptor_e7fa4666eddf88e5 = []byte{ - // 670 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 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9a, - 0x2e, 0xc2, 0x59, 0x60, 0xd5, 0xda, 0x86, 0x5d, 0xf5, 0xa6, 0xd4, 0xfb, 0x56, 0x60, 0xae, 0x21, - 0xf3, 0xd2, 0x3a, 0x09, 0x64, 0xa9, 0xb4, 0x8c, 0xb6, 0x61, 0x4f, 0x78, 0x0b, 0xe3, 0x4a, 0x37, - 0x17, 0x4c, 0x1b, 0xcd, 0x87, 0x58, 0xf8, 0x03, 0xce, 0x08, 0xf5, 0x25, 0x23, 0x7d, 0xca, 0xad, - 0x3b, 0x0a, 0xae, 0x87, 0x58, 0xec, 0xe4, 0xe5, 0x3d, 0x55, 0x35, 0x9f, 0xa0, 0x3a, 0x4b, 0x7b, - 0x90, 0xa5, 0x41, 0xc9, 0x55, 0x15, 0x37, 0xa7, 0xab, 0x1a, 0x7b, 0x8a, 0x1a, 0x90, 0xc9, 0x4b, - 0xdc, 0x44, 0x91, 0x57, 0x96, 0x35, 0xf8, 0x0c, 0x2d, 0x1c, 0x62, 0x49, 0x22, 0x3f, 0x93, 0x47, - 0x50, 0xa2, 0x77, 0x15, 0xda, 0x50, 0xc2, 0x17, 0x79, 0x04, 0x9a, 0x7d, 0x8b, 0xd4, 0x59, 0xfa, - 0x12, 0xfa, 0x34, 0xff, 0xa5, 0x54, 0x72, 0x4c, 0xa4, 0x8f, 0x83, 0x80, 0x53, 0x21, 0xac, 0xe9, - 0xb6, 0x61, 0xcf, 0x78, 0x56, 0x8e, 0xec, 0xe5, 0x44, 0x57, 0x03, 0xef, 0x0a, 0xdd, 0x7c, 0x83, - 0x96, 0x09, 0xa4, 0x29, 0x25, 0x12, 0xf8, 0x75, 0xf7, 0x4c, 0xe1, 0x1e, 0x11, 0x57, 0xdd, 0x5d, - 0xd4, 0xa2, 0x9c, 0xac, 0xbf, 0xf0, 0x49, 0x26, 0x24, 0x04, 0xc3, 0xeb, 0x09, 0x48, 0x25, 0x34, - 0x15, 0xd5, 0x2d, 0xa0, 0x1b, 0x96, 0x30, 0xda,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6d, 0xd7, - 0x99, 0xc8, 0xff, 0xca, 0xbb, 0xd4, 0x5f, 0xba, 0x41, 0x37, 0xd0, 0xa4, 0x6e, 0xcd, 0x57, 0xe8, - 0x81, 0xde, 0xea, 0x04, 0xcb, 0x8c, 0x33, 0x39, 0xf4, 0x7b, 0x31, 0x90, 0xbe, 0x50, 0xed, 0x52, - 0xf5, 0x16, 0x0b, 0xf5, 0xa3, 0x16, 0x3b, 0x4a, 0xeb, 0xbc, 0x3f, 0x3e, 0x6b, 0x19, 0x27, 0x67, - 0x2d, 0xe3, 0xef, 0x59, 0xcb, 0xf8, 0x79, 0xde, 0xaa, 0x9c, 0x9c, 0xb7, 0x2a, 0xbf, 0xcf, 0x5b, - 0x95, 0xaf, 0xcf, 0x43, 0x26, 0xa3, 0xac, 0xe7, 0x10, 0x48, 0xd4, 0x48, 0x5a, 0x2b, 0xa6, 0x53, - 0x0a, 0x01, 0x75, 0x8f, 0x2e, 0x66, 0x93, 0x1c, 0x0e, 0xa8, 0xe8, 0x4d, 0xaa, 0x71, 0xf4, 0xf2, - 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc8, 0xe5, 0x29, 0x22, 0x24, 0x05, 0x00, 0x00, + // 676 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdd, 0x4e, 0xd4, 0x4e, + 0x18, 0xc6, 0xb7, 0x2c, 0x7f, 0x3e, 0x66, 0x61, 0x17, 0xfa, 0x47, 0x2d, 0x6c, 0xb2, 0xac, 0x18, + 0x63, 0xa3, 0xb1, 0x55, 0xd4, 0x33, 0x25, 0x71, 0x17, 0x0f, 0x88, 0xa8, 0xa4, 0xe0, 0x89, 0x26, + 0x36, 0xb3, 0xd3, 0xa1, 0x9d, 0x6c, 0xdb, 0x77, 0x33, 0x33, 0x05, 0xd6, 0xab, 0xf0, 0x1a, 0xbc, + 0x1a, 0x0e, 0x39, 0x34, 0x1e, 0x10, 0x03, 0x37, 0x62, 0x3a, 0x9d, 0x2e, 0xcb, 0x47, 0x88, 0x67, + 0xed, 0xfb, 0xfc, 0x9e, 0xa7, 0xd3, 0x99, 0x79, 0x5f, 0x64, 0x7f, 0xa7, 0x12, 0x93, 0x08, 0xb3, + 0xd4, 0x55, 0x4f, 0xc0, 0xa9, 0x0b, 0x3d, 0x41, 0xf9, 0x01, 0xe5, 0xee, 0x00, 0x73, 0x9c, 0x08, + 0x67, 0xc0, 0x41, 0x82, 0xd9, 0x1c, 0x91, 0x4e, 0x49, 0x3a, 0x25, 0xb9, 0xb2, 0x14, 0x42, 0x08, + 0x8a, 0x73, 0xf3, 0xa7, 0xc2, 0xb2, 0xf2, 0xea, 0xb6, 0x70, 0x02, 0xe9, 0x3e, 0xe3, 0x09, 0x96, + 0x0c, 0x52, 0x7f, 0xfc, 0x4b, 0x6b, 0xdf, 0x50, 0xa3, 0x9b, 0x9b, 0x76, 0x54, 0x71, 0x9b, 0x09, + 0x69, 0xbe, 0x47, 0x73, 0x2a, 0x47, 0x83, 0x96, 0xd1, 0xae, 0xda, 0xb5, 0x75, 0xdb, 0xb9, 0x65, + 0x4d, 0xce, 0x58, 0x86, 0x57, 0x23, 0x17, 0x2f, 0x6b, 0x3f, 0xa7, 0x51, 0x6d, 0x4c, 0x34, 0x97, + 0xd1, 0x4c, 0x11, 0xce, 0x02, 0xab, 0xd6, 0x36, 0xec, 0xaa, 0x37, 0xad, 0xde, 0xb7, 0x02, 0xf3, + 0x39, 0x32, 0x2f, 0xad, 0x93, 0x40, 0x96, 0x4a, 0xcb, 0x68, 0x1b, 0xf6, 0x64, 0x67, 0xc2, 0x32, + 0xbc, 0xc5, 0x71, 0xb5, 0x9b, 0x8b, 0xa6, 0x8d, 0x16, 0x42, 0x2c, 0xfc, 0x01, 0x67, 0x84, 0xfa, + 0x92, 0x91, 0x3e, 0xe5, 0xd6, 0x44, 0x6e, 0xf0, 0xea, 0x21, 0x16, 0x3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 0xcf, 0x59, 0xcb, 0xf8, 0x71, 0xde, 0xaa, 0x9c, + 0x9c, 0xb7, 0x2a, 0xbf, 0xce, 0x5b, 0x95, 0x2f, 0x4f, 0x42, 0x26, 0xa3, 0xac, 0xe7, 0x10, 0x48, + 0xd4, 0x58, 0x7a, 0x5a, 0x4c, 0xa8, 0x14, 0x02, 0xea, 0x1e, 0x5d, 0xcc, 0x27, 0x39, 0x1c, 0x50, + 0xd1, 0x9b, 0x52, 0x23, 0xe9, 0xc5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x56, 0xbc, 0xc2, + 0x28, 0x05, 0x00, 0x00, } func (m *ChainParamsList) Marshal() (dAtA []byte, err error) { diff --git a/zetaclient/testutils/mocks/chain_params.go b/zetaclient/testutils/mocks/chain_params.go index 4458589ab8..5cb3c18862 100644 --- a/zetaclient/testutils/mocks/chain_params.go +++ b/zetaclient/testutils/mocks/chain_params.go @@ -45,6 +45,10 @@ func MockChainParams(chainID int64, confirmation uint64) observertypes.ChainPara MinObserverDelegation: observertypes.DefaultMinObserverDelegation, GatewayAddress: gwAddress, IsSupported: true, + ConfirmationParams: observertypes.ConfirmationParams{ + SafeInboundCount: confirmation, + SafeOutboundCount: confirmation, + }, } } From ea3f43b2cf2fc46c60459e7487ce0ddc60000194 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 4 Feb 2025 17:27:02 -0600 Subject: [PATCH 7/9] make changelog entry explicit; add proto message comment; improve migrate script and unit test --- changelog.md | 2 +- docs/openapi/openapi.swagger.yaml | 12 ++++++++++++ .../zetacore/observer/confirmation_params.proto | 11 +++++++++++ testutil/sample/observer.go | 8 ++++---- .../zetacore/observer/confirmation_params_pb.d.ts | 12 ++++++++++++ x/observer/migrations/v10/migrate.go | 10 ++++++---- x/observer/migrations/v10/migrate_test.go | 12 +----------- x/observer/types/confirmation_params.pb.go | 12 ++++++++++-- 8 files changed, 57 insertions(+), 22 deletions(-) diff --git a/changelog.md b/changelog.md index e76b3d3e27..e3fe346ead 100644 --- a/changelog.md +++ b/changelog.md @@ -4,7 +4,7 @@ ### Features -* [3461](https://github.com/zeta-chain/node/pull/3461) - enable multiple confirmation count values in chain params +* [3461](https://github.com/zeta-chain/node/pull/3461) - add new 'ConfirmationParams' field to chain params to enable multiple confirmation count values, deprecating `confirmation_count` ### Tests diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 57548e8682..3ad546151f 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -59817,15 +59817,27 @@ definitions: safe_inbound_count: type: string format: uint64 + description: |- + This is the safe number of confirmations to wait before an inbound is + considered finalized. fast_inbound_count: type: string format: uint64 + description: |- + This is the number of confirmations for fast inbound observation, which is + shorter than safe_inbound_count. safe_outbound_count: type: string format: uint64 + description: |- + This is the safe number of confirmations to wait before an outbound is + considered finalized. fast_outbound_count: type: string format: uint64 + description: |- + This is the number of confirmations for fast outbound observation, which is + shorter than safe_outbound_count. observerCrosschainFlags: type: object properties: diff --git a/proto/zetachain/zetacore/observer/confirmation_params.proto b/proto/zetachain/zetacore/observer/confirmation_params.proto index 8348f2f8a8..d55d6c0168 100644 --- a/proto/zetachain/zetacore/observer/confirmation_params.proto +++ b/proto/zetachain/zetacore/observer/confirmation_params.proto @@ -4,8 +4,19 @@ package zetachain.zetacore.observer; option go_package = "github.com/zeta-chain/node/x/observer/types"; message ConfirmationParams { + // This is the safe number of confirmations to wait before an inbound is + // considered finalized. uint64 safe_inbound_count = 1; + + // This is the number of confirmations for fast inbound observation, which is + // shorter than safe_inbound_count. uint64 fast_inbound_count = 2; + + // This is the safe number of confirmations to wait before an outbound is + // considered finalized. uint64 safe_outbound_count = 3; + + // This is the number of confirmations for fast outbound observation, which is + // shorter than safe_outbound_count. uint64 fast_outbound_count = 4; } diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 6121fd7d6b..aa06d8e457 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -114,7 +114,7 @@ func ChainParams(chainID int64) *types.ChainParams { MinObserverDelegation: sdkmath.LegacyNewDec(r.Int63()), IsSupported: false, GatewayAddress: EthAddress().String(), - ConfirmationParams: ConfirmationParams(), + ConfirmationParams: ConfirmationParams(r), } } @@ -340,9 +340,9 @@ func OperationalFlags() types.OperationalFlags { } } -func ConfirmationParams() types.ConfirmationParams { - randInboundCount := Uint64InRange(1, 200) - randOutboundCount := Uint64InRange(1, 200) +func ConfirmationParams(r *rand.Rand) types.ConfirmationParams { + randInboundCount := Uint64InRangeFromRand(r, 1, 200) + randOutboundCount := Uint64InRangeFromRand(r, 1, 200) return types.ConfirmationParams{ SafeInboundCount: randInboundCount, diff --git a/typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts b/typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts index eecf0e623c..5704a472c5 100644 --- a/typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts +++ b/typescript/zetachain/zetacore/observer/confirmation_params_pb.d.ts @@ -11,21 +11,33 @@ import { Message, proto3 } from "@bufbuild/protobuf"; */ export declare class ConfirmationParams extends Message { /** + * This is the safe number of confirmations to wait before an inbound is + * considered finalized. + * * @generated from field: uint64 safe_inbound_count = 1; */ safeInboundCount: bigint; /** + * This is the number of confirmations for fast inbound observation, which is + * shorter than safe_inbound_count. + * * @generated from field: uint64 fast_inbound_count = 2; */ fastInboundCount: bigint; /** + * This is the safe number of confirmations to wait before an outbound is + * considered finalized. + * * @generated from field: uint64 safe_outbound_count = 3; */ safeOutboundCount: bigint; /** + * This is the number of confirmations for fast outbound observation, which is + * shorter than safe_outbound_count. + * * @generated from field: uint64 fast_outbound_count = 4; */ fastOutboundCount: bigint; diff --git a/x/observer/migrations/v10/migrate.go b/x/observer/migrations/v10/migrate.go index 7f0061059c..1031406012 100644 --- a/x/observer/migrations/v10/migrate.go +++ b/x/observer/migrations/v10/migrate.go @@ -27,10 +27,12 @@ func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { // set new fields to the same value as 'confirmation_count' for _, chainParams := range allChainParams.ChainParams { if chainParams != nil { - chainParams.ConfirmationParams.SafeInboundCount = chainParams.ConfirmationCount - chainParams.ConfirmationParams.FastInboundCount = chainParams.ConfirmationCount - chainParams.ConfirmationParams.SafeOutboundCount = chainParams.ConfirmationCount - chainParams.ConfirmationParams.FastOutboundCount = chainParams.ConfirmationCount + chainParams.ConfirmationParams = types.ConfirmationParams{ + SafeInboundCount: chainParams.ConfirmationCount, + FastInboundCount: chainParams.ConfirmationCount, + SafeOutboundCount: chainParams.ConfirmationCount, + FastOutboundCount: chainParams.ConfirmationCount, + } } } diff --git a/x/observer/migrations/v10/migrate_test.go b/x/observer/migrations/v10/migrate_test.go index e1131e9dc8..c1466ed986 100644 --- a/x/observer/migrations/v10/migrate_test.go +++ b/x/observer/migrations/v10/migrate_test.go @@ -3,11 +3,9 @@ package v10_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/node/testutil/keeper" "github.com/zeta-chain/node/testutil/sample" - "github.com/zeta-chain/node/x/observer/keeper" v10 "github.com/zeta-chain/node/x/observer/migrations/v10" "github.com/zeta-chain/node/x/observer/types" ) @@ -29,7 +27,7 @@ func TestMigrateStore(t *testing.T) { k, ctx, _, _ := keepertest.ObserverKeeper(t) // set chain params - setChainParamsList(ctx, *k, chainParams) + k.SetChainParamsList(ctx, chainParams) // ensure the chain params are set correctly oldChainParams, found := k.GetChainParamsList(ctx) @@ -90,11 +88,3 @@ func makeChainParamsEmptyConfirmation(chainID int64, confirmationCount uint64) * chainParams.ConfirmationParams = types.ConfirmationParams{} return chainParams } - -// setChainParamsList set chain params list in the store -func setChainParamsList(ctx sdk.Context, observerKeeper keeper.Keeper, chainParams types.ChainParamsList) { - store := ctx.KVStore(observerKeeper.StoreKey()) - b := observerKeeper.Codec().MustMarshal(&chainParams) - key := types.KeyPrefix(types.AllChainParamsKey) - store.Set(key, b) -} diff --git a/x/observer/types/confirmation_params.pb.go b/x/observer/types/confirmation_params.pb.go index 60232a7dd6..bd0306deab 100644 --- a/x/observer/types/confirmation_params.pb.go +++ b/x/observer/types/confirmation_params.pb.go @@ -23,9 +23,17 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ConfirmationParams struct { - SafeInboundCount uint64 `protobuf:"varint,1,opt,name=safe_inbound_count,json=safeInboundCount,proto3" json:"safe_inbound_count,omitempty"` - FastInboundCount uint64 `protobuf:"varint,2,opt,name=fast_inbound_count,json=fastInboundCount,proto3" json:"fast_inbound_count,omitempty"` + // This is the safe number of confirmations to wait before an inbound is + // considered finalized. + SafeInboundCount uint64 `protobuf:"varint,1,opt,name=safe_inbound_count,json=safeInboundCount,proto3" json:"safe_inbound_count,omitempty"` + // This is the number of confirmations for fast inbound observation, which is + // shorter than safe_inbound_count. + FastInboundCount uint64 `protobuf:"varint,2,opt,name=fast_inbound_count,json=fastInboundCount,proto3" json:"fast_inbound_count,omitempty"` + // This is the safe number of confirmations to wait before an outbound is + // considered finalized. SafeOutboundCount uint64 `protobuf:"varint,3,opt,name=safe_outbound_count,json=safeOutboundCount,proto3" json:"safe_outbound_count,omitempty"` + // This is the number of confirmations for fast outbound observation, which is + // shorter than safe_outbound_count. FastOutboundCount uint64 `protobuf:"varint,4,opt,name=fast_outbound_count,json=fastOutboundCount,proto3" json:"fast_outbound_count,omitempty"` } From 2f46928f7b66edeb3be8a3d68749b3e05114592b Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 4 Feb 2025 20:20:06 -0600 Subject: [PATCH 8/9] validate all chain params during migration; return error if validation fails --- x/observer/migrations/v10/migrate.go | 5 ++ x/observer/migrations/v10/migrate_test.go | 59 +++++++++++++++++------ x/observer/types/chain_params.go | 4 +- x/observer/types/chain_params_test.go | 26 ++++++++-- 4 files changed, 76 insertions(+), 18 deletions(-) diff --git a/x/observer/migrations/v10/migrate.go b/x/observer/migrations/v10/migrate.go index 1031406012..8a17adaeed 100644 --- a/x/observer/migrations/v10/migrate.go +++ b/x/observer/migrations/v10/migrate.go @@ -36,6 +36,11 @@ func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { } } + // validate the updated chain params list + if err := allChainParams.Validate(); err != nil { + return errorsmod.Wrap(types.ErrInvalidChainParams, err.Error()) + } + // set the updated chain params list observerKeeper.SetChainParamsList(ctx, allChainParams) diff --git a/x/observer/migrations/v10/migrate_test.go b/x/observer/migrations/v10/migrate_test.go index c1466ed986..1a1925e2ec 100644 --- a/x/observer/migrations/v10/migrate_test.go +++ b/x/observer/migrations/v10/migrate_test.go @@ -10,29 +10,18 @@ import ( "github.com/zeta-chain/node/x/observer/types" ) -var chainParams = types.ChainParamsList{ - ChainParams: []*types.ChainParams{ - makeChainParamsEmptyConfirmation(1, 14), - makeChainParamsEmptyConfirmation(56, 20), - makeChainParamsEmptyConfirmation(8332, 3), - makeChainParamsEmptyConfirmation(7000, 0), - makeChainParamsEmptyConfirmation(137, 200), - makeChainParamsEmptyConfirmation(8453, 90), - makeChainParamsEmptyConfirmation(900, 32), - }, -} - func TestMigrateStore(t *testing.T) { t.Run("can migrate confirmation count", func(t *testing.T) { k, ctx, _, _ := keepertest.ObserverKeeper(t) // set chain params - k.SetChainParamsList(ctx, chainParams) + testChainParams := getTestChainParams() + k.SetChainParamsList(ctx, testChainParams) // ensure the chain params are set correctly oldChainParams, found := k.GetChainParamsList(ctx) require.True(t, found) - require.Equal(t, chainParams, oldChainParams) + require.Equal(t, testChainParams, oldChainParams) // migrate the store err := v10.MigrateStore(ctx, *k) @@ -79,6 +68,33 @@ func TestMigrateStore(t *testing.T) { require.False(t, found) require.Empty(t, allChainParams.ChainParams) }) + + t.Run("migrate nothing if chain params list validation fails", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + + // get test chain params + testChainParams := getTestChainParams() + + // make the first chain params invalid + testChainParams.ChainParams[0].InboundTicker = 0 + + // set chain params + k.SetChainParamsList(ctx, testChainParams) + + // ensure the chain params are set correctly + oldChainParams, found := k.GetChainParamsList(ctx) + require.True(t, found) + require.Equal(t, testChainParams, oldChainParams) + + // migrate the store + err := v10.MigrateStore(ctx, *k) + require.ErrorIs(t, err, types.ErrInvalidChainParams) + + // ensure nothing has changed + newChainParams, found := k.GetChainParamsList(ctx) + require.True(t, found) + require.Equal(t, oldChainParams, newChainParams) + }) } // makeChainParamsEmptyConfirmation creates a sample chain params with empty confirmation @@ -88,3 +104,18 @@ func makeChainParamsEmptyConfirmation(chainID int64, confirmationCount uint64) * chainParams.ConfirmationParams = types.ConfirmationParams{} return chainParams } + +// getTestChainParams returns a list of chain params for testing +func getTestChainParams() types.ChainParamsList { + return types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + makeChainParamsEmptyConfirmation(1, 14), + makeChainParamsEmptyConfirmation(56, 20), + makeChainParamsEmptyConfirmation(8332, 3), + makeChainParamsEmptyConfirmation(7000, 0), + makeChainParamsEmptyConfirmation(137, 200), + makeChainParamsEmptyConfirmation(8453, 90), + makeChainParamsEmptyConfirmation(900, 32), + }, + } +} diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index f7c422ee83..3a338d7a91 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -52,8 +52,10 @@ func ValidateChainParams(params *ChainParams) error { return fmt.Errorf("chain params cannot be nil") } + // don't validate ZetaChain params, because the validation will fail on existing params in the store + // we might remove the ZetaChain params in the future, this is TBD if chains.IsZetaChain(params.ChainId, nil) { - return errorsmod.Wrap(sdkerrors.ErrInvalidChainID, "zeta chain cannot have observer chain parameters") + return nil } // validate confirmation counts diff --git a/x/observer/types/chain_params_test.go b/x/observer/types/chain_params_test.go index ef0309fec5..4009610849 100644 --- a/x/observer/types/chain_params_test.go +++ b/x/observer/types/chain_params_test.go @@ -36,8 +36,9 @@ func TestChainParamsList_Validate(t *testing.T) { type UpdateChainParamsSuite struct { suite.Suite - evmParams *types.ChainParams - btcParams *types.ChainParams + zetaParams *types.ChainParams + evmParams *types.ChainParams + btcParams *types.ChainParams } var _ = Suite(&UpdateChainParamsSuite{}) @@ -53,6 +54,23 @@ func TestChainParamsEqual(t *testing.T) { } func (s *UpdateChainParamsSuite) SetupTest() { + s.zetaParams = &types.ChainParams{ + ConfirmationCount: 0, + GasPriceTicker: 0, + InboundTicker: 0, + OutboundTicker: 0, + WatchUtxoTicker: 0, + ZetaTokenContractAddress: "0x0000000000000000000000000000000000000000", + ConnectorContractAddress: "0x0000000000000000000000000000000000000000", + Erc20CustodyContractAddress: "0x0000000000000000000000000000000000000000", + ChainId: 7000, + OutboundScheduleInterval: 0, + OutboundScheduleLookahead: 0, + BallotThreshold: types.DefaultBallotThreshold, + MinObserverDelegation: types.DefaultMinObserverDelegation, + IsSupported: true, + GatewayAddress: "", + } s.evmParams = &types.ChainParams{ ConfirmationCount: 1, GasPriceTicker: 1, @@ -101,7 +119,9 @@ func (s *UpdateChainParamsSuite) SetupTest() { } func (s *UpdateChainParamsSuite) TestValidParams() { - err := types.ValidateChainParams(s.evmParams) + err := types.ValidateChainParams(s.zetaParams) + require.Nil(s.T(), err) + err = types.ValidateChainParams(s.evmParams) require.Nil(s.T(), err) err = types.ValidateChainParams(s.btcParams) require.Nil(s.T(), err) From 314ab8bc1a73171fda4c0328509feb40a951a71c Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 5 Feb 2025 16:18:00 -0600 Subject: [PATCH 9/9] make ConfirmationParams nullable to avoid upgrade test failure; adjust checks and tests accordingly --- .../zetachain/zetacore/observer/params.proto | 2 +- testutil/sample/observer.go | 4 +- x/observer/migrations/v10/migrate.go | 2 +- x/observer/migrations/v10/migrate_test.go | 12 +- x/observer/types/chain_params.go | 21 ++-- x/observer/types/chain_params_test.go | 104 +++++++++------ x/observer/types/params.pb.go | 118 +++++++++--------- zetaclient/testutils/mocks/chain_params.go | 2 +- 8 files changed, 152 insertions(+), 113 deletions(-) diff --git a/proto/zetachain/zetacore/observer/params.proto b/proto/zetachain/zetacore/observer/params.proto index 792cf94514..0db7a1253b 100644 --- a/proto/zetachain/zetacore/observer/params.proto +++ b/proto/zetachain/zetacore/observer/params.proto @@ -33,7 +33,7 @@ message ChainParams { string gateway_address = 17; // Advanced confirmation parameters for chain to support fast observation - ConfirmationParams confirmation_params = 18 [ (gogoproto.nullable) = false ]; + ConfirmationParams confirmation_params = 18; } // Deprecated(v17) diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index aa06d8e457..bf29b93770 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -97,6 +97,8 @@ func ChainParams(chainID int64) *types.ChainParams { return nil } + confirmationParams := ConfirmationParams(r) + return &types.ChainParams{ ChainId: chainID, ConfirmationCount: r.Uint64(), @@ -114,7 +116,7 @@ func ChainParams(chainID int64) *types.ChainParams { MinObserverDelegation: sdkmath.LegacyNewDec(r.Int63()), IsSupported: false, GatewayAddress: EthAddress().String(), - ConfirmationParams: ConfirmationParams(r), + ConfirmationParams: &confirmationParams, } } diff --git a/x/observer/migrations/v10/migrate.go b/x/observer/migrations/v10/migrate.go index 8a17adaeed..381f3b8f4c 100644 --- a/x/observer/migrations/v10/migrate.go +++ b/x/observer/migrations/v10/migrate.go @@ -27,7 +27,7 @@ func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { // set new fields to the same value as 'confirmation_count' for _, chainParams := range allChainParams.ChainParams { if chainParams != nil { - chainParams.ConfirmationParams = types.ConfirmationParams{ + chainParams.ConfirmationParams = &types.ConfirmationParams{ SafeInboundCount: chainParams.ConfirmationCount, FastInboundCount: chainParams.ConfirmationCount, SafeOutboundCount: chainParams.ConfirmationCount, diff --git a/x/observer/migrations/v10/migrate_test.go b/x/observer/migrations/v10/migrate_test.go index 1a1925e2ec..61b192122e 100644 --- a/x/observer/migrations/v10/migrate_test.go +++ b/x/observer/migrations/v10/migrate_test.go @@ -43,10 +43,12 @@ func TestMigrateStore(t *testing.T) { require.Equal(t, oldParam.ConfirmationCount, newParam.ConfirmationParams.FastOutboundCount) // ensure nothing else has changed except the confirmation - oldParam.ConfirmationParams.SafeInboundCount = oldParam.ConfirmationCount - oldParam.ConfirmationParams.FastInboundCount = oldParam.ConfirmationCount - oldParam.ConfirmationParams.SafeOutboundCount = oldParam.ConfirmationCount - oldParam.ConfirmationParams.FastOutboundCount = oldParam.ConfirmationCount + oldParam.ConfirmationParams = &types.ConfirmationParams{ + SafeInboundCount: oldParam.ConfirmationCount, + FastInboundCount: oldParam.ConfirmationCount, + SafeOutboundCount: oldParam.ConfirmationCount, + FastOutboundCount: oldParam.ConfirmationCount, + } require.Equal(t, newParam, oldParam) } }) @@ -101,7 +103,7 @@ func TestMigrateStore(t *testing.T) { func makeChainParamsEmptyConfirmation(chainID int64, confirmationCount uint64) *types.ChainParams { chainParams := sample.ChainParams(chainID) chainParams.ConfirmationCount = confirmationCount - chainParams.ConfirmationParams = types.ConfirmationParams{} + chainParams.ConfirmationParams = nil return chainParams } diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 3a338d7a91..67e6f8debf 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -65,6 +65,9 @@ func ValidateChainParams(params *ChainParams) error { if params.ConfirmationCount == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "ConfirmationCount must be greater than 0") } + if params.ConfirmationParams == nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "confirmation params cannot be nil") + } if params.ConfirmationParams.SafeInboundCount == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "SafeInboundCount must be greater than 0") } @@ -194,7 +197,7 @@ func GetDefaultEthMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 14, FastInboundCount: 14, SafeOutboundCount: 14, @@ -218,7 +221,7 @@ func GetDefaultBscMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 14, FastInboundCount: 14, SafeOutboundCount: 14, @@ -242,7 +245,7 @@ func GetDefaultBtcMainnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 2, SafeOutboundCount: 2, @@ -267,7 +270,7 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 6, FastInboundCount: 6, SafeOutboundCount: 6, @@ -291,7 +294,7 @@ func GetDefaultBscTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 6, FastInboundCount: 6, SafeOutboundCount: 6, @@ -315,7 +318,7 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 12, FastInboundCount: 12, SafeOutboundCount: 12, @@ -339,7 +342,7 @@ func GetDefaultBtcTestnetChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 2, SafeOutboundCount: 2, @@ -363,7 +366,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 1, FastInboundCount: 1, SafeOutboundCount: 1, @@ -388,7 +391,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { MinObserverDelegation: DefaultMinObserverDelegation, IsSupported: false, GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", - ConfirmationParams: ConfirmationParams{ + ConfirmationParams: &ConfirmationParams{ SafeInboundCount: 1, FastInboundCount: 1, SafeOutboundCount: 1, diff --git a/x/observer/types/chain_params_test.go b/x/observer/types/chain_params_test.go index 4009610849..83b64b3b85 100644 --- a/x/observer/types/chain_params_test.go +++ b/x/observer/types/chain_params_test.go @@ -87,7 +87,7 @@ func (s *UpdateChainParamsSuite) SetupTest() { MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, GatewayAddress: "0xF0deebCB0E9C829519C4baa794c5445171973826", - ConfirmationParams: types.ConfirmationParams{ + ConfirmationParams: &types.ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 0, // zero means fast observation is disabled SafeOutboundCount: 2, @@ -109,7 +109,7 @@ func (s *UpdateChainParamsSuite) SetupTest() { BallotThreshold: types.DefaultBallotThreshold, MinObserverDelegation: types.DefaultMinObserverDelegation, IsSupported: false, - ConfirmationParams: types.ConfirmationParams{ + ConfirmationParams: &types.ConfirmationParams{ SafeInboundCount: 2, FastInboundCount: 1, SafeOutboundCount: 2, @@ -172,100 +172,126 @@ func (s *UpdateChainParamsSuite) TestCoreContractAddresses() { } func (s *UpdateChainParamsSuite) Validate(params *types.ChainParams) { - copy := *params + copy := copyParams(params) copy.ConfirmationCount = 0 - err := types.ValidateChainParams(©) + err := types.ValidateChainParams(copy) + require.NotNil(s.T(), err) + + copy = copyParams(params) + copy.ConfirmationParams = nil + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.ConfirmationParams.SafeInboundCount = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.ConfirmationParams.FastInboundCount = copy.ConfirmationParams.SafeInboundCount + 1 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.ConfirmationParams.SafeOutboundCount = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.ConfirmationParams.FastOutboundCount = copy.ConfirmationParams.SafeOutboundCount + 1 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.GasPriceTicker = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.GasPriceTicker = 300 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) copy.GasPriceTicker = 301 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.InboundTicker = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.InboundTicker = 300 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) copy.InboundTicker = 301 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.OutboundTicker = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.OutboundTicker = 300 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) copy.OutboundTicker = 301 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.OutboundScheduleInterval = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.OutboundScheduleInterval = 100 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) copy.OutboundScheduleInterval = 101 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.OutboundScheduleLookahead = 0 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.OutboundScheduleLookahead = 500 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) copy.OutboundScheduleLookahead = 501 - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) - copy = *params + copy = copyParams(params) copy.BallotThreshold = sdkmath.LegacyDec{} - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.BallotThreshold = sdkmath.LegacyMustNewDecFromStr("1.2") - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.BallotThreshold = sdkmath.LegacyMustNewDecFromStr("0.9") - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) - copy = *params + copy = copyParams(params) copy.MinObserverDelegation = sdkmath.LegacyDec{} - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.NotNil(s.T(), err) copy.MinObserverDelegation = sdkmath.LegacyMustNewDecFromStr("0.9") - err = types.ValidateChainParams(©) + err = types.ValidateChainParams(copy) require.Nil(s.T(), err) } + +// copyParams creates a deep copy of the given ChainParams. +func copyParams(src *types.ChainParams) *types.ChainParams { + if src == nil { + return nil + } + + copy := *src + if src.ConfirmationParams == nil { + return © + } + + copy.ConfirmationParams = &types.ConfirmationParams{ + SafeInboundCount: src.ConfirmationParams.SafeInboundCount, + FastInboundCount: src.ConfirmationParams.FastInboundCount, + SafeOutboundCount: src.ConfirmationParams.SafeOutboundCount, + FastOutboundCount: src.ConfirmationParams.FastOutboundCount, + } + + return © +} diff --git a/x/observer/types/params.pb.go b/x/observer/types/params.pb.go index bfe945e54f..03c02b0b73 100644 --- a/x/observer/types/params.pb.go +++ b/x/observer/types/params.pb.go @@ -86,7 +86,7 @@ type ChainParams struct { IsSupported bool `protobuf:"varint,16,opt,name=is_supported,json=isSupported,proto3" json:"is_supported,omitempty"` GatewayAddress string `protobuf:"bytes,17,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // Advanced confirmation parameters for chain to support fast observation - ConfirmationParams ConfirmationParams `protobuf:"bytes,18,opt,name=confirmation_params,json=confirmationParams,proto3" json:"confirmation_params"` + ConfirmationParams *ConfirmationParams `protobuf:"bytes,18,opt,name=confirmation_params,json=confirmationParams,proto3" json:"confirmation_params,omitempty"` } func (m *ChainParams) Reset() { *m = ChainParams{} } @@ -214,11 +214,11 @@ func (m *ChainParams) GetGatewayAddress() string { return "" } -func (m *ChainParams) GetConfirmationParams() ConfirmationParams { +func (m *ChainParams) GetConfirmationParams() *ConfirmationParams { if m != nil { return m.ConfirmationParams } - return ConfirmationParams{} + return nil } // Deprecated(v17) @@ -278,50 +278,49 @@ func init() { } var fileDescriptor_e7fa4666eddf88e5 = []byte{ - // 676 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdd, 0x4e, 0xd4, 0x4e, - 0x18, 0xc6, 0xb7, 0x2c, 0x7f, 0x3e, 0x66, 0x61, 0x17, 0xfa, 0x47, 0x2d, 0x6c, 0xb2, 0xac, 0x18, - 0x63, 0xa3, 0xb1, 0x55, 0xd4, 0x33, 0x25, 0x71, 0x17, 0x0f, 0x88, 0xa8, 0xa4, 0xe0, 0x89, 0x26, - 0x36, 0xb3, 0xd3, 0xa1, 0x9d, 0x6c, 0xdb, 0x77, 0x33, 0x33, 0x05, 0xd6, 0xab, 0xf0, 0x1a, 0xbc, - 0x1a, 0x0e, 0x39, 0x34, 0x1e, 0x10, 0x03, 0x37, 0x62, 0x3a, 0x9d, 0x2e, 0xcb, 0x47, 0x88, 0x67, - 0xed, 0xfb, 0xfc, 0x9e, 0xa7, 0xd3, 0x99, 0x79, 0x5f, 0x64, 0x7f, 0xa7, 0x12, 0x93, 0x08, 0xb3, - 0xd4, 0x55, 0x4f, 0xc0, 0xa9, 0x0b, 0x3d, 0x41, 0xf9, 0x01, 0xe5, 0xee, 0x00, 0x73, 0x9c, 0x08, + // 671 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdd, 0x6e, 0xd3, 0x3e, + 0x18, 0xc6, 0x9b, 0x75, 0xff, 0x7d, 0xb8, 0x5b, 0xbb, 0xe5, 0x3f, 0x20, 0x5b, 0xa5, 0xae, 0x0c, + 0x21, 0x22, 0x10, 0x09, 0x0c, 0x38, 0x83, 0x49, 0xb4, 0xe3, 0x60, 0x62, 0xc0, 0x94, 0x8d, 0x13, + 0x90, 0x08, 0xae, 0x63, 0x12, 0xab, 0x49, 0xde, 0xca, 0x76, 0xb6, 0x95, 0xab, 0xe0, 0x02, 0xb8, + 0xa0, 0x1d, 0xee, 0x10, 0x71, 0x30, 0xa1, 0xed, 0x46, 0x50, 0x1c, 0xa7, 0xeb, 0x3e, 0x34, 0x71, + 0x16, 0xbf, 0xcf, 0xef, 0x79, 0xea, 0xda, 0x7e, 0x5f, 0x64, 0x7f, 0xa7, 0x12, 0x93, 0x08, 0xb3, + 0xd4, 0x55, 0x5f, 0xc0, 0xa9, 0x0b, 0x3d, 0x41, 0xf9, 0x3e, 0xe5, 0xee, 0x00, 0x73, 0x9c, 0x08, 0x67, 0xc0, 0x41, 0x82, 0xd9, 0x1c, 0x91, 0x4e, 0x49, 0x3a, 0x25, 0xb9, 0xb2, 0x14, 0x42, 0x08, - 0x8a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0x97, 0xe8, 0xae, 0xde, 0xea, 0x04, 0xcb, 0x8c, 0x33, 0x39, 0xf4, 0x7b, - 0x31, 0x90, 0xbe, 0x50, 0xed, 0x52, 0xf5, 0x96, 0x0a, 0xf5, 0x83, 0x16, 0x3b, 0x4a, 0xeb, 0xbc, - 0x3b, 0x3e, 0x6b, 0x19, 0x27, 0x67, 0x2d, 0xe3, 0xcf, 0x59, 0xcb, 0xf8, 0x71, 0xde, 0xaa, 0x9c, - 0x9c, 0xb7, 0x2a, 0xbf, 0xce, 0x5b, 0x95, 0x2f, 0x4f, 0x42, 0x26, 0xa3, 0xac, 0xe7, 0x10, 0x48, - 0xd4, 0x58, 0x7a, 0x5a, 0x4c, 0xa8, 0x14, 0x02, 0xea, 0x1e, 0x5d, 0xcc, 0x27, 0x39, 0x1c, 0x50, - 0xd1, 0x9b, 0x52, 0x23, 0xe9, 0xc5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x56, 0xbc, 0xc2, - 0x28, 0x05, 0x00, 0x00, + 0xcd, 0xfb, 0xa8, 0xce, 0xd2, 0x1e, 0x64, 0x69, 0x50, 0x72, 0x55, 0xc5, 0xcd, 0xeb, 0xaa, 0xc6, + 0x1e, 0xa0, 0x06, 0x64, 0xf2, 0x02, 0x37, 0x59, 0xe4, 0x95, 0x65, 0x0d, 0x3e, 0x44, 0x8b, 0x07, + 0x58, 0x92, 0xc8, 0xcf, 0xe4, 0x21, 0x94, 0xe8, 0x7f, 0x0a, 0x6d, 0x28, 0xe1, 0xa3, 0x3c, 0x04, + 0xcd, 0xbe, 0x42, 0xea, 0x3e, 0x7d, 0x09, 0x7d, 0x9a, 0xff, 0xad, 0x54, 0x72, 0x4c, 0xa4, 0x8f, + 0x83, 0x80, 0x53, 0x21, 0xac, 0x99, 0xb6, 0x61, 0xcf, 0x7a, 0x56, 0x8e, 0xec, 0xe5, 0x44, 0x57, + 0x03, 0xaf, 0x0b, 0xdd, 0x7c, 0x89, 0x56, 0x08,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0x2d, + 0x4b, 0xf9, 0x23, 0x0b, 0xb1, 0xa4, 0x07, 0x78, 0x38, 0xba, 0x83, 0x45, 0x75, 0x07, 0x75, 0x5d, + 0x2e, 0x8f, 0xfd, 0x2b, 0xfa, 0xff, 0x9a, 0xce, 0xb5, 0xcc, 0xb6, 0x61, 0xd7, 0xd6, 0xdd, 0x9b, + 0x1b, 0x72, 0xcc, 0xa7, 0xfb, 0xf2, 0x42, 0x77, 0xe9, 0xf6, 0xdc, 0x40, 0x53, 0xba, 0x31, 0x9f, + 0xa3, 0xdb, 0xfa, 0x90, 0x13, 0x2c, 0x33, 0xce, 0xe4, 0xd0, 0xef, 0xc5, 0x40, 0xfa, 0x42, 0x35, + 0x4a, 0xd5, 0x5b, 0x2a, 0xd4, 0x77, 0x5a, 0xec, 0x28, 0xad, 0xf3, 0xe6, 0xe8, 0xb4, 0x65, 0x1c, + 0x9f, 0xb6, 0x8c, 0x3f, 0xa7, 0x2d, 0xe3, 0xc7, 0x59, 0xab, 0x72, 0x7c, 0xd6, 0xaa, 0xfc, 0x3a, + 0x6b, 0x55, 0x3e, 0x3d, 0x0a, 0x99, 0x8c, 0xb2, 0x9e, 0x43, 0x20, 0x51, 0x03, 0xe9, 0x71, 0x31, + 0x9b, 0x52, 0x08, 0xa8, 0x7b, 0x78, 0x3e, 0x99, 0xe4, 0x70, 0x40, 0x45, 0x6f, 0x4a, 0x0d, 0xa3, + 0x67, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x2b, 0x18, 0x7c, 0x22, 0x05, 0x00, 0x00, } func (m *ChainParamsList) Marshal() (dAtA []byte, err error) { @@ -381,18 +380,20 @@ func (m *ChainParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.ConfirmationParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.ConfirmationParams != nil { + { + size, err := m.ConfirmationParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x92 if len(m.GatewayAddress) > 0 { i -= len(m.GatewayAddress) copy(dAtA[i:], m.GatewayAddress) @@ -605,8 +606,10 @@ func (m *ChainParams) Size() (n int) { if l > 0 { n += 2 + l + sovParams(uint64(l)) } - l = m.ConfirmationParams.Size() - n += 2 + l + sovParams(uint64(l)) + if m.ConfirmationParams != nil { + l = m.ConfirmationParams.Size() + n += 2 + l + sovParams(uint64(l)) + } return n } @@ -1138,6 +1141,9 @@ func (m *ChainParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + if m.ConfirmationParams == nil { + m.ConfirmationParams = &ConfirmationParams{} + } if err := m.ConfirmationParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/zetaclient/testutils/mocks/chain_params.go b/zetaclient/testutils/mocks/chain_params.go index 5cb3c18862..f43df14f3f 100644 --- a/zetaclient/testutils/mocks/chain_params.go +++ b/zetaclient/testutils/mocks/chain_params.go @@ -45,7 +45,7 @@ func MockChainParams(chainID int64, confirmation uint64) observertypes.ChainPara MinObserverDelegation: observertypes.DefaultMinObserverDelegation, GatewayAddress: gwAddress, IsSupported: true, - ConfirmationParams: observertypes.ConfirmationParams{ + ConfirmationParams: &observertypes.ConfirmationParams{ SafeInboundCount: confirmation, SafeOutboundCount: confirmation, },