diff --git a/Dockerfile-versioned-source b/Dockerfile-versioned-source index 9cbbbab68f..5e01e79356 100644 --- a/Dockerfile-versioned-source +++ b/Dockerfile-versioned-source @@ -17,7 +17,7 @@ WORKDIR /go/delivery/zeta-node RUN mkdir -p $GOPATH/bin/old RUN mkdir -p $GOPATH/bin/new -ENV NEW_VERSION=v14 +ENV NEW_VERSION=v15 # Build new release from the current source COPY go.mod /go/delivery/zeta-node/ diff --git a/Makefile b/Makefile index bf95f4008f..8ac108284c 100644 --- a/Makefile +++ b/Makefile @@ -240,7 +240,7 @@ stateful-upgrade: stateful-upgrade-source: @echo "--> Starting stateful smoketest" - $(DOCKER) build --build-arg old_version=v13.0.0 -t zetanode -f ./Dockerfile-versioned-source . + $(DOCKER) build --build-arg old_version=v14.0.1 -t zetanode -f ./Dockerfile-versioned-source . $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild . cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d diff --git a/app/setup_handlers.go b/app/setup_handlers.go index b773745398..35a095406f 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -5,10 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/upgrade/types" - crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) -const releaseVersion = "v14" +const releaseVersion = "v15" func SetupHandlers(app *App) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { @@ -17,7 +16,6 @@ func SetupHandlers(app *App) { for m, mb := range app.mm.Modules { vm[m] = mb.ConsensusVersion() } - VersionMigrator{v: vm}.TriggerMigration(crosschaintypes.ModuleName) return app.mm.RunMigrations(ctx, app.configurator, vm) }) diff --git a/changelog.md b/changelog.md index da536ca927..a2f717471b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,12 @@ # CHANGELOG + +## Version: v15 + +### Features + +*[1912](https://github.com/zeta-chain/node/pull/1912) - add reset chain nonces msg +*[1913](https://github.com/zeta-chain/node/pull/1913) - add upgrade handler for version v15.0.0 + ## Version: v14 ### Fixes diff --git a/docs/cli/zetacored/zetacored_tx_observer.md b/docs/cli/zetacored/zetacored_tx_observer.md index 5340a1041a..de1145c512 100644 --- a/docs/cli/zetacored/zetacored_tx_observer.md +++ b/docs/cli/zetacored/zetacored_tx_observer.md @@ -29,6 +29,7 @@ zetacored tx observer [flags] * [zetacored tx observer add-observer](zetacored_tx_observer_add-observer.md) - Broadcast message add-observer * [zetacored tx observer encode](zetacored_tx_observer_encode.md) - Encode a json string into hex * [zetacored tx observer remove-chain-params](zetacored_tx_observer_remove-chain-params.md) - Broadcast message to remove chain params +* [zetacored tx observer reset-chain-nonces](zetacored_tx_observer_reset-chain-nonces.md) - Broadcast message to reset chain nonces * [zetacored tx observer update-chain-params](zetacored_tx_observer_update-chain-params.md) - Broadcast message updateChainParams * [zetacored tx observer update-crosschain-flags](zetacored_tx_observer_update-crosschain-flags.md) - Update crosschain flags * [zetacored tx observer update-keygen](zetacored_tx_observer_update-keygen.md) - command to update the keygen block via a group proposal diff --git a/docs/cli/zetacored/zetacored_tx_observer_reset-chain-nonces.md b/docs/cli/zetacored/zetacored_tx_observer_reset-chain-nonces.md new file mode 100644 index 0000000000..6a858d99b2 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_observer_reset-chain-nonces.md @@ -0,0 +1,52 @@ +# tx observer reset-chain-nonces + +Broadcast message to reset chain nonces + +``` +zetacored tx observer reset-chain-nonces [chain-id] [chain-nonce-low] [chain-nonce-high] [flags] +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for reset-chain-nonces + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx observer](zetacored_tx_observer.md) - observer transactions subcommands + diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index a2108f73b1..6256da4514 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -54314,6 +54314,8 @@ definitions: type: object observerMsgRemoveChainParamsResponse: type: object + observerMsgResetChainNoncesResponse: + type: object observerMsgUpdateChainParamsResponse: type: object observerMsgUpdateCrosschainFlagsResponse: diff --git a/docs/spec/observer/messages.md b/docs/spec/observer/messages.md index 63e75cbe7c..9cddf0afd3 100644 --- a/docs/spec/observer/messages.md +++ b/docs/spec/observer/messages.md @@ -108,3 +108,17 @@ message MsgAddBlockHeader { } ``` +## MsgResetChainNonces + +ResetChainNonces handles resetting chain nonces +Authorized: admin policy group 2 (admin update) + +```proto +message MsgResetChainNonces { + string creator = 1; + int64 chain_id = 2; + int64 chain_nonce_low = 3; + int64 chain_nonce_high = 4; +} +``` + diff --git a/proto/observer/tx.proto b/proto/observer/tx.proto index b67e8e0741..85e0ffe9ef 100644 --- a/proto/observer/tx.proto +++ b/proto/observer/tx.proto @@ -22,6 +22,7 @@ service Msg { rpc UpdateCrosschainFlags(MsgUpdateCrosschainFlags) returns (MsgUpdateCrosschainFlagsResponse); rpc UpdateKeygen(MsgUpdateKeygen) returns (MsgUpdateKeygenResponse); rpc AddBlockHeader(MsgAddBlockHeader) returns (MsgAddBlockHeaderResponse); + rpc ResetChainNonces(MsgResetChainNonces) returns (MsgResetChainNoncesResponse); } message MsgUpdateObserver { @@ -88,3 +89,12 @@ message MsgUpdateKeygen { } message MsgUpdateKeygenResponse {} + +message MsgResetChainNonces { + string creator = 1; + int64 chain_id = 2; + int64 chain_nonce_low = 3; + int64 chain_nonce_high = 4; +} + +message MsgResetChainNoncesResponse {} diff --git a/typescript/observer/tx_pb.d.ts b/typescript/observer/tx_pb.d.ts index 3684b24d01..4f7a346cc2 100644 --- a/typescript/observer/tx_pb.d.ts +++ b/typescript/observer/tx_pb.d.ts @@ -450,3 +450,61 @@ export declare class MsgUpdateKeygenResponse extends Message | undefined, b: MsgUpdateKeygenResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message zetachain.zetacore.observer.MsgResetChainNonces + */ +export declare class MsgResetChainNonces extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: int64 chain_id = 2; + */ + chainId: bigint; + + /** + * @generated from field: int64 chain_nonce_low = 3; + */ + chainNonceLow: bigint; + + /** + * @generated from field: int64 chain_nonce_high = 4; + */ + chainNonceHigh: bigint; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.observer.MsgResetChainNonces"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgResetChainNonces; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgResetChainNonces; + + static fromJsonString(jsonString: string, options?: Partial): MsgResetChainNonces; + + static equals(a: MsgResetChainNonces | PlainMessage | undefined, b: MsgResetChainNonces | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.observer.MsgResetChainNoncesResponse + */ +export declare class MsgResetChainNoncesResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.observer.MsgResetChainNoncesResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgResetChainNoncesResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgResetChainNoncesResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgResetChainNoncesResponse; + + static equals(a: MsgResetChainNoncesResponse | PlainMessage | undefined, b: MsgResetChainNoncesResponse | PlainMessage | undefined): boolean; +} + diff --git a/x/crosschain/keeper/migrator.go b/x/crosschain/keeper/migrator.go index 4de64140c8..c50fd74c5f 100644 --- a/x/crosschain/keeper/migrator.go +++ b/x/crosschain/keeper/migrator.go @@ -22,20 +22,24 @@ func NewMigrator(keeper Keeper) Migrator { // Migrate1to2 migrates the store from consensus version 1 to 2 func (m Migrator) Migrate1to2(ctx sdk.Context) error { + ctx.Logger().Info("Migrating crosschain store from v1 to v2") return v2.MigrateStore(ctx, m.crossChainKeeper.zetaObserverKeeper, m.crossChainKeeper.storeKey, m.crossChainKeeper.cdc) } // Migrate2to3 migrates the store from consensus version 2 to 3 func (m Migrator) Migrate2to3(ctx sdk.Context) error { + ctx.Logger().Info("Migrating crosschain store from v2 to v3") return v3.MigrateStore(ctx, m.crossChainKeeper.storeKey, m.crossChainKeeper.cdc) } // Migrate3to4 migrates the store from consensus version 3 to 4 func (m Migrator) Migrate3to4(ctx sdk.Context) error { + ctx.Logger().Info("Migrating crosschain store from v3 to v4") return v4.MigrateStore(ctx, m.crossChainKeeper.zetaObserverKeeper, m.crossChainKeeper) } // Migrate4to5 migrates the store from consensus version 4 to 5 func (m Migrator) Migrate4to5(ctx sdk.Context) error { + ctx.Logger().Info("Migrating crosschain store from v4 to v5") return v5.MigrateStore(ctx, m.crossChainKeeper, m.crossChainKeeper.zetaObserverKeeper) } diff --git a/x/emissions/genesis_test.go b/x/emissions/genesis_test.go index 2af0766b81..6bfb54e840 100644 --- a/x/emissions/genesis_test.go +++ b/x/emissions/genesis_test.go @@ -1,9 +1,10 @@ package emissions_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" diff --git a/x/observer/client/cli/tx.go b/x/observer/client/cli/tx.go index 7f60f10be8..f581f878b9 100644 --- a/x/observer/client/cli/tx.go +++ b/x/observer/client/cli/tx.go @@ -29,6 +29,7 @@ func GetTxCmd() *cobra.Command { CmdAddBlameVote(), CmdUpdateObserver(), CmdEncode(), + CmdResetChainNonces(), ) return cmd diff --git a/x/observer/client/cli/tx_reset_chain_nonces.go b/x/observer/client/cli/tx_reset_chain_nonces.go new file mode 100644 index 0000000000..01a992bd9e --- /dev/null +++ b/x/observer/client/cli/tx_reset_chain_nonces.go @@ -0,0 +1,58 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func CmdResetChainNonces() *cobra.Command { + cmd := &cobra.Command{ + Use: "reset-chain-nonces [chain-id] [chain-nonce-low] [chain-nonce-high]", + Short: "Broadcast message to reset chain nonces", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // get chainID as int64 + chainID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return err + } + + // get chainNonceLow as int64 + chainNonceLow, err := strconv.ParseInt(args[1], 10, 64) + if err != nil { + return err + } + + // get chainNonceHigh as int64 + chainNonceHigh, err := strconv.ParseInt(args[2], 10, 64) + if err != nil { + return err + } + + msg := types.NewMsgResetChainNonces( + clientCtx.GetFromAddress().String(), + chainID, + chainNonceLow, + chainNonceHigh, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/observer/keeper/migrator.go b/x/observer/keeper/migrator.go index 0cee0ed183..6df4351346 100644 --- a/x/observer/keeper/migrator.go +++ b/x/observer/keeper/migrator.go @@ -23,22 +23,27 @@ func NewMigrator(keeper Keeper) Migrator { // Migrate1to2 migrates the store from consensus version 1 to 2 func (m Migrator) Migrate1to2(ctx sdk.Context) error { + ctx.Logger().Info("Migrating observer store from v1 to v2") return v2.MigrateStore(ctx, m.observerKeeper.storeKey, m.observerKeeper.cdc) } // Migrate2to3 migrates the store from consensus version 2 to 3 func (m Migrator) Migrate2to3(ctx sdk.Context) error { + ctx.Logger().Info("Migrating observer store from v2 to v3") return v3.MigrateStore(ctx, m.observerKeeper) } func (m Migrator) Migrate3to4(ctx sdk.Context) error { + ctx.Logger().Info("Migrating observer store from v3 to v4") return v4.MigrateStore(ctx, m.observerKeeper) } func (m Migrator) Migrate4to5(ctx sdk.Context) error { + ctx.Logger().Info("Migrating observer store from v4 to v5") return v5.MigrateStore(ctx, m.observerKeeper) } func (m Migrator) Migrate5to6(ctx sdk.Context) error { + ctx.Logger().Info("Migrating observer store from v5 to v6") return v6.MigrateStore(ctx, m.observerKeeper) } diff --git a/x/observer/keeper/msg_server_reset_chain_nonces.go b/x/observer/keeper/msg_server_reset_chain_nonces.go new file mode 100644 index 0000000000..48a9f59eb4 --- /dev/null +++ b/x/observer/keeper/msg_server_reset_chain_nonces.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +// ResetChainNonces handles resetting chain nonces +// Authorized: admin policy group 2 (admin update) +func (k msgServer) ResetChainNonces(goCtx context.Context, msg *types.MsgResetChainNonces) (*types.MsgResetChainNoncesResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if msg.Creator != k.GetParams(ctx).GetAdminPolicyAccount(types.Policy_Type_group2) { + return &types.MsgResetChainNoncesResponse{}, types.ErrNotAuthorizedPolicy + } + + tss, found := k.GetTSS(ctx) + if !found { + return nil, types.ErrTssNotFound + } + + chain := common.GetChainFromChainID(msg.ChainId) + if chain == nil { + return nil, types.ErrSupportedChains + } + + // set chain nonces + chainNonce := types.ChainNonces{ + Index: chain.ChainName.String(), + ChainId: chain.ChainId, + // #nosec G701 always positive + Nonce: uint64(msg.ChainNonceHigh), + // #nosec G701 always positive + FinalizedHeight: uint64(ctx.BlockHeight()), + } + k.SetChainNonces(ctx, chainNonce) + + // set pending nonces + p := types.PendingNonces{ + NonceLow: msg.ChainNonceLow, + NonceHigh: msg.ChainNonceHigh, + ChainId: chain.ChainId, + Tss: tss.TssPubkey, + } + k.SetPendingNonces(ctx, p) + + return &types.MsgResetChainNoncesResponse{}, nil +} diff --git a/x/observer/keeper/msg_server_reset_chain_nonces_test.go b/x/observer/keeper/msg_server_reset_chain_nonces_test.go new file mode 100644 index 0000000000..9a0c8cd696 --- /dev/null +++ b/x/observer/keeper/msg_server_reset_chain_nonces_test.go @@ -0,0 +1,143 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/common" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/keeper" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestMsgServer_ResetChainNonces(t *testing.T) { + t.Run("cannot reset chain nonces if not authorized", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + + chainId := common.GoerliLocalnetChain().ChainId + _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: chainId, + ChainNonceLow: 1, + ChainNonceHigh: 5, + }) + require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + + // group 1 should not be able to reset chain nonces + admin := sample.AccAddress() + setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group1) + + _, err = srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: chainId, + ChainNonceLow: 1, + ChainNonceHigh: 5, + }) + require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + }) + + t.Run("cannot reset chain nonces if tss not found", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group2) + + chainId := common.GoerliLocalnetChain().ChainId + _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ + Creator: admin, + ChainId: chainId, + ChainNonceLow: 1, + ChainNonceHigh: 5, + }) + require.ErrorIs(t, err, types.ErrTssNotFound) + }) + + t.Run("cannot reset chain nonces if chain not supported", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + tss := sample.Tss() + k.SetTSS(ctx, tss) + + admin := sample.AccAddress() + setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group2) + + _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ + Creator: admin, + ChainId: 999, + ChainNonceLow: 1, + ChainNonceHigh: 5, + }) + require.ErrorIs(t, err, types.ErrSupportedChains) + }) + + t.Run("can reset chain nonces", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + tss := sample.Tss() + k.SetTSS(ctx, tss) + + admin := sample.AccAddress() + setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group2) + + chainId := common.GoerliLocalnetChain().ChainId + index := common.GoerliLocalnetChain().ChainName.String() + + // check existing chain nonces + _, found := k.GetChainNonces(ctx, index) + require.False(t, found) + _, found = k.GetPendingNonces(ctx, tss.TssPubkey, chainId) + require.False(t, found) + + // reset chain nonces + nonceLow := 1 + nonceHigh := 5 + _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ + Creator: admin, + ChainId: chainId, + ChainNonceLow: int64(nonceLow), + ChainNonceHigh: int64(nonceHigh), + }) + require.NoError(t, err) + + // check updated chain nonces + chainNonces, found := k.GetChainNonces(ctx, index) + require.True(t, found) + require.Equal(t, chainId, chainNonces.ChainId) + require.Equal(t, index, chainNonces.Index) + require.Equal(t, uint64(nonceHigh), chainNonces.Nonce) + + pendingNonces, found := k.GetPendingNonces(ctx, tss.TssPubkey, chainId) + require.True(t, found) + require.Equal(t, chainId, pendingNonces.ChainId) + require.Equal(t, tss.TssPubkey, pendingNonces.Tss) + require.Equal(t, int64(nonceLow), pendingNonces.NonceLow) + require.Equal(t, int64(nonceHigh), pendingNonces.NonceHigh) + + // reset nonces back to 0 + _, err = srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ + Creator: admin, + ChainId: chainId, + ChainNonceLow: 0, + ChainNonceHigh: 0, + }) + require.NoError(t, err) + + // check updated chain nonces + chainNonces, found = k.GetChainNonces(ctx, index) + require.True(t, found) + require.Equal(t, chainId, chainNonces.ChainId) + require.Equal(t, index, chainNonces.Index) + require.Equal(t, uint64(0), chainNonces.Nonce) + + pendingNonces, found = k.GetPendingNonces(ctx, tss.TssPubkey, chainId) + require.True(t, found) + require.Equal(t, chainId, pendingNonces.ChainId) + require.Equal(t, tss.TssPubkey, pendingNonces.Tss) + require.Equal(t, int64(0), pendingNonces.NonceLow) + require.Equal(t, int64(0), pendingNonces.NonceHigh) + }) +} diff --git a/x/observer/types/codec.go b/x/observer/types/codec.go index b28c4d0041..af6e7d87a5 100644 --- a/x/observer/types/codec.go +++ b/x/observer/types/codec.go @@ -16,6 +16,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateKeygen{}, "crosschain/UpdateKeygen", nil) cdc.RegisterConcrete(&MsgAddBlockHeader{}, "crosschain/AddBlockHeader", nil) cdc.RegisterConcrete(&MsgUpdateObserver{}, "observer/UpdateObserver", nil) + cdc.RegisterConcrete(&MsgResetChainNonces{}, "observer/ResetChainNonces", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -28,6 +29,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdateKeygen{}, &MsgAddBlockHeader{}, &MsgUpdateObserver{}, + &MsgResetChainNonces{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/observer/types/message_reset_chain_nonces.go b/x/observer/types/message_reset_chain_nonces.go new file mode 100644 index 0000000000..71e438d103 --- /dev/null +++ b/x/observer/types/message_reset_chain_nonces.go @@ -0,0 +1,72 @@ +package types + +import ( + "errors" + + cosmoserrors "cosmossdk.io/errors" + "github.com/zeta-chain/zetacore/common" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgResetChainNonces = "reset_chain_nonces" + +var _ sdk.Msg = &MsgResetChainNonces{} + +func NewMsgResetChainNonces(creator string, chainID int64, chainNonceLow int64, chainNonceHigh int64) *MsgResetChainNonces { + return &MsgResetChainNonces{ + Creator: creator, + ChainId: chainID, + ChainNonceLow: chainNonceLow, + ChainNonceHigh: chainNonceHigh, + } +} + +func (msg *MsgResetChainNonces) Route() string { + return RouterKey +} + +func (msg *MsgResetChainNonces) Type() string { + return TypeMsgResetChainNonces +} + +func (msg *MsgResetChainNonces) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgResetChainNonces) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgResetChainNonces) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + // Check if chain exists + chain := common.GetChainFromChainID(msg.ChainId) + if chain == nil { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidChainID, "invalid chain id (%d)", msg.ChainId) + } + + if msg.ChainNonceLow < 0 { + return errors.New("chain nonce low must be greater or equal 0") + } + + if msg.ChainNonceHigh < 0 { + return errors.New("chain nonce high must be greater or equal 0") + } + + if msg.ChainNonceLow > msg.ChainNonceHigh { + return errors.New("chain nonce low must be less or equal than chain nonce high") + } + + return nil +} diff --git a/x/observer/types/message_reset_chain_nonces_test.go b/x/observer/types/message_reset_chain_nonces_test.go new file mode 100644 index 0000000000..8c79fbf4ea --- /dev/null +++ b/x/observer/types/message_reset_chain_nonces_test.go @@ -0,0 +1,111 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgResetChainNonces + wantErr bool + }{ + { + name: "valid message chain nonce high greater than nonce low", + msg: types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: common.ExternalChainList()[0].ChainId, + ChainNonceLow: 1, + ChainNonceHigh: 5, + }, + wantErr: false, + }, + { + name: "valid message chain nonce high same as nonce low", + msg: types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: common.ExternalChainList()[0].ChainId, + ChainNonceLow: 1, + ChainNonceHigh: 1, + }, + wantErr: false, + }, + { + name: "invalid address", + msg: types.MsgResetChainNonces{ + Creator: "invalid_address", + ChainId: common.ExternalChainList()[0].ChainId, + }, + wantErr: true, + }, + { + name: "invalid chain ID", + msg: types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: 999, + }, + wantErr: true, + }, + { + name: "invalid chain nonce low", + msg: types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: common.ExternalChainList()[0].ChainId, + ChainNonceLow: -1, + }, + wantErr: true, + }, + { + name: "invalid chain nonce high", + msg: types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: common.ExternalChainList()[0].ChainId, + ChainNonceLow: 1, + ChainNonceHigh: -1, + }, + wantErr: true, + }, + { + name: "invalid chain nonce low greater than chain nonce high", + msg: types.MsgResetChainNonces{ + Creator: sample.AccAddress(), + ChainId: common.ExternalChainList()[0].ChainId, + ChainNonceLow: 1, + ChainNonceHigh: 0, + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgResetChainNonces_Type(t *testing.T) { + msg := types.NewMsgResetChainNonces(sample.AccAddress(), 5, 1, 5) + require.Equal(t, types.TypeMsgResetChainNonces, msg.Type()) +} + +func TestMsgResetChainNonces_Route(t *testing.T) { + msg := types.NewMsgResetChainNonces(sample.AccAddress(), 5, 1, 5) + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgResetChainNonces_GetSignBytes(t *testing.T) { + msg := types.NewMsgResetChainNonces(sample.AccAddress(), 5, 1, 5) + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} diff --git a/x/observer/types/tx.pb.go b/x/observer/types/tx.pb.go index bd9bceaf1e..481efd0716 100644 --- a/x/observer/types/tx.pb.go +++ b/x/observer/types/tx.pb.go @@ -822,6 +822,110 @@ func (m *MsgUpdateKeygenResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateKeygenResponse proto.InternalMessageInfo +type MsgResetChainNonces struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ChainNonceLow int64 `protobuf:"varint,3,opt,name=chain_nonce_low,json=chainNonceLow,proto3" json:"chain_nonce_low,omitempty"` + ChainNonceHigh int64 `protobuf:"varint,4,opt,name=chain_nonce_high,json=chainNonceHigh,proto3" json:"chain_nonce_high,omitempty"` +} + +func (m *MsgResetChainNonces) Reset() { *m = MsgResetChainNonces{} } +func (m *MsgResetChainNonces) String() string { return proto.CompactTextString(m) } +func (*MsgResetChainNonces) ProtoMessage() {} +func (*MsgResetChainNonces) Descriptor() ([]byte, []int) { + return fileDescriptor_1bcd40fa296a2b1d, []int{16} +} +func (m *MsgResetChainNonces) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgResetChainNonces) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgResetChainNonces.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 *MsgResetChainNonces) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgResetChainNonces.Merge(m, src) +} +func (m *MsgResetChainNonces) XXX_Size() int { + return m.Size() +} +func (m *MsgResetChainNonces) XXX_DiscardUnknown() { + xxx_messageInfo_MsgResetChainNonces.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgResetChainNonces proto.InternalMessageInfo + +func (m *MsgResetChainNonces) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgResetChainNonces) GetChainId() int64 { + if m != nil { + return m.ChainId + } + return 0 +} + +func (m *MsgResetChainNonces) GetChainNonceLow() int64 { + if m != nil { + return m.ChainNonceLow + } + return 0 +} + +func (m *MsgResetChainNonces) GetChainNonceHigh() int64 { + if m != nil { + return m.ChainNonceHigh + } + return 0 +} + +type MsgResetChainNoncesResponse struct { +} + +func (m *MsgResetChainNoncesResponse) Reset() { *m = MsgResetChainNoncesResponse{} } +func (m *MsgResetChainNoncesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgResetChainNoncesResponse) ProtoMessage() {} +func (*MsgResetChainNoncesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1bcd40fa296a2b1d, []int{17} +} +func (m *MsgResetChainNoncesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgResetChainNoncesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgResetChainNoncesResponse.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 *MsgResetChainNoncesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgResetChainNoncesResponse.Merge(m, src) +} +func (m *MsgResetChainNoncesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgResetChainNoncesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgResetChainNoncesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgResetChainNoncesResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateObserver)(nil), "zetachain.zetacore.observer.MsgUpdateObserver") proto.RegisterType((*MsgUpdateObserverResponse)(nil), "zetachain.zetacore.observer.MsgUpdateObserverResponse") @@ -839,71 +943,78 @@ func init() { proto.RegisterType((*MsgUpdateCrosschainFlagsResponse)(nil), "zetachain.zetacore.observer.MsgUpdateCrosschainFlagsResponse") proto.RegisterType((*MsgUpdateKeygen)(nil), "zetachain.zetacore.observer.MsgUpdateKeygen") proto.RegisterType((*MsgUpdateKeygenResponse)(nil), "zetachain.zetacore.observer.MsgUpdateKeygenResponse") + proto.RegisterType((*MsgResetChainNonces)(nil), "zetachain.zetacore.observer.MsgResetChainNonces") + proto.RegisterType((*MsgResetChainNoncesResponse)(nil), "zetachain.zetacore.observer.MsgResetChainNoncesResponse") } func init() { proto.RegisterFile("observer/tx.proto", fileDescriptor_1bcd40fa296a2b1d) } var fileDescriptor_1bcd40fa296a2b1d = []byte{ - // 939 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x36, 0xe3, 0xc4, 0x3f, 0x23, 0xd7, 0x89, 0xb7, 0x76, 0x2c, 0x2b, 0x89, 0x62, 0xf0, 0xe4, - 0xb6, 0xae, 0x14, 0x2b, 0x6d, 0x81, 0x14, 0xe8, 0xc1, 0xee, 0x8f, 0xa3, 0x06, 0xa9, 0x0d, 0x02, - 0xf5, 0xa1, 0x17, 0x62, 0xc9, 0x1d, 0x53, 0x44, 0xa8, 0x5d, 0x81, 0x4b, 0x25, 0x56, 0xd1, 0x1e, - 0xfa, 0x00, 0x45, 0xfb, 0x2a, 0x7d, 0x87, 0x1e, 0x72, 0xcc, 0xb1, 0xa7, 0xa2, 0xb0, 0x4f, 0xed, - 0x0b, 0xf4, 0x1a, 0x70, 0x49, 0xae, 0x44, 0x51, 0xa2, 0xe4, 0x9c, 0xc4, 0xdd, 0xfd, 0xe6, 0x9b, - 0xf9, 0x66, 0xbf, 0x5d, 0x2d, 0x6c, 0x08, 0x47, 0x62, 0xf8, 0x12, 0xc3, 0x66, 0x74, 0xd1, 0xe8, - 0x85, 0x22, 0x12, 0xe4, 0xde, 0x8f, 0x18, 0x51, 0xb7, 0x43, 0x7d, 0xde, 0x50, 0x5f, 0x22, 0xc4, - 0x46, 0x86, 0xaa, 0xbd, 0xef, 0x8a, 0x6e, 0x57, 0xf0, 0x66, 0xf2, 0x93, 0x44, 0xd4, 0x36, 0x3d, - 0xe1, 0x09, 0xf5, 0xd9, 0x8c, 0xbf, 0xb2, 0x59, 0x4d, 0xed, 0x04, 0xb4, 0x8b, 0xe9, 0xec, 0x43, - 0x3d, 0xeb, 0x86, 0x42, 0x4a, 0x95, 0xc7, 0x3e, 0x0f, 0xa8, 0x27, 0x53, 0xc0, 0xb6, 0x06, 0x64, - 0x1f, 0xe9, 0xc2, 0x96, 0x5e, 0xe8, 0xd1, 0x90, 0x76, 0x33, 0xfc, 0x83, 0xe1, 0x34, 0x72, 0xe6, - 0x73, 0xcf, 0xe6, 0x82, 0xbb, 0x98, 0x2d, 0x93, 0xa1, 0x40, 0x99, 0xce, 0x99, 0xff, 0x1a, 0xb0, - 0xf1, 0x5c, 0x7a, 0xdf, 0xf7, 0x18, 0x8d, 0xf0, 0x24, 0x5d, 0x27, 0x55, 0x58, 0x76, 0x43, 0xa4, - 0x91, 0x08, 0xab, 0xc6, 0xae, 0xb1, 0xb7, 0x6a, 0x65, 0x43, 0xf2, 0x08, 0x36, 0x45, 0xc0, 0xec, - 0x8c, 0xc9, 0xa6, 0x8c, 0x85, 0x28, 0x65, 0xf5, 0x86, 0x82, 0x11, 0x11, 0xb0, 0x8c, 0xe4, 0x30, - 0x59, 0x89, 0x23, 0x38, 0xbe, 0x2a, 0x46, 0x2c, 0x26, 0x11, 0x1c, 0x5f, 0x8d, 0x47, 0x9c, 0xc1, - 0x7b, 0x7d, 0x55, 0x8f, 0x1d, 0x22, 0x95, 0x82, 0x57, 0x6f, 0xee, 0x1a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99, 0x4f, 0xe7, 0x6c, 0x66, 0x3e, - 0xac, 0xf6, 0xc5, 0x3b, 0x85, 0x8d, 0xf6, 0x20, 0x77, 0xb2, 0xf6, 0xe7, 0xa3, 0x4b, 0xd0, 0xb3, - 0x7b, 0x30, 0xe9, 0xc8, 0xc5, 0xce, 0x1f, 0x7b, 0xd4, 0x34, 0xe6, 0xea, 0xa5, 0xc6, 0xcf, 0x76, - 0xfe, 0xe4, 0x17, 0xc8, 0x51, 0xfb, 0xf5, 0x65, 0xdd, 0x78, 0x73, 0x59, 0x37, 0xfe, 0xb9, 0xac, - 0x1b, 0xbf, 0x5f, 0xd5, 0x17, 0xde, 0x5c, 0xd5, 0x17, 0xfe, 0xba, 0xaa, 0x2f, 0xfc, 0xd0, 0xf4, - 0xfc, 0xa8, 0xd3, 0x77, 0xe2, 0x07, 0x4e, 0x33, 0x66, 0xfc, 0x58, 0x91, 0x37, 0x33, 0xf2, 0xe6, - 0x45, 0x73, 0xf8, 0x54, 0x1d, 0xf4, 0x50, 0x3a, 0x4b, 0xea, 0xb5, 0xfa, 0xf8, 0x6d, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x9f, 0xe7, 0x2f, 0x7d, 0xa4, 0x0b, 0x00, 0x00, + // 1021 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcb, 0x6e, 0xdb, 0x46, + 0x17, 0x36, 0xa3, 0xc4, 0xb1, 0x8f, 0x1c, 0x5f, 0x26, 0x76, 0x2c, 0xcb, 0xb1, 0x62, 0x70, 0xf1, + 0x43, 0x7f, 0xeb, 0x4a, 0xb6, 0xd2, 0x16, 0x4d, 0x81, 0x2e, 0xec, 0x5e, 0x6c, 0x35, 0x4d, 0x6c, + 0x10, 0xa8, 0x17, 0xdd, 0x10, 0x23, 0xce, 0x98, 0x24, 0x42, 0xcd, 0x08, 0x1c, 0x2a, 0xb6, 0x8a, + 0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 0xf0, 0xe0, 0xcb, 0xc9, 0xfa, 0x1d, 0x58, 0x75, 0x45, 0x93, 0xb5, 0x78, 0x97, 0x91, + 0xcf, 0x19, 0x6e, 0x79, 0x94, 0xc8, 0x04, 0x17, 0x8c, 0xcc, 0x3c, 0xda, 0x83, 0x35, 0x57, 0x9c, + 0x76, 0x83, 0x14, 0x38, 0x6a, 0x6c, 0xd6, 0x80, 0x1c, 0xd8, 0xb0, 0xb1, 0x38, 0xf3, 0x5d, 0x8b, + 0x36, 0x59, 0x18, 0x4e, 0x50, 0x99, 0x4c, 0xbc, 0x0f, 0x1b, 0xb9, 0xf5, 0x1f, 0x8f, 0xf2, 0x34, + 0x46, 0x13, 0xa2, 0xef, 0xe1, 0x71, 0xab, 0xbf, 0x55, 0xcf, 0xa9, 0xef, 0x5e, 0xb8, 0x16, 0x0e, + 0x5c, 0x1e, 0x55, 0x5f, 0x9a, 0x97, 0x01, 0x9f, 0x4d, 0x68, 0xf8, 0x78, 0x02, 0x23, 0x97, 0x5e, + 0xd7, 0x61, 0x77, 0x5c, 0xe3, 0xd5, 0xea, 0x1c, 0x4a, 0x25, 0x45, 0x98, 0xe7, 0xb4, 0x67, 0x53, + 0x96, 0xb3, 0x26, 0xeb, 0x70, 0x4f, 0x06, 0x8c, 0x65, 0x14, 0x0d, 0xe2, 0xb5, 0x1f, 0xa4, 0x50, + 0xec, 0xbf, 0x6a, 0xf0, 0x50, 0x6e, 0x55, 0x41, 0x03, 0xb9, 0x53, 0x5f, 0xca, 0x0b, 0xea, 0x76, + 0x62, 0xfd, 0x1f, 0xac, 0x44, 0x26, 0x79, 0xcb, 0x99, 0x1e, 0xbf, 0x94, 0x82, 0x28, 0x18, 0x0f, + 0x2c, 0x45, 0xfd, 0x15, 0xbf, 0x44, 0x55, 0x58, 0x1d, 0xc4, 0x39, 0xae, 0xed, 0xc4, 0x47, 0xef, + 0x72, 0x1f, 0x78, 0xe2, 0xda, 0x8e, 0xbe, 0x03, 0xdb, 0x23, 0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dc, + 0x37, 0x75, 0xdb, 0x0d, 0x9c, 0x6e, 0x2b, 0x7c, 0x1e, 0xd6, 0x43, 0xce, 0xf7, 0x24, 0x7d, 0x3d, + 0xa1, 0xaf, 0x5f, 0xd5, 0xfb, 0x0f, 0xfd, 0x5e, 0x87, 0x8a, 0xd6, 0xbc, 0x7c, 0xeb, 0x3f, 0xfd, + 0x2f, 0x00, 0x00, 0xff, 0xff, 0xd0, 0xc2, 0x64, 0xda, 0xe2, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -926,6 +1037,7 @@ type MsgClient interface { UpdateCrosschainFlags(ctx context.Context, in *MsgUpdateCrosschainFlags, opts ...grpc.CallOption) (*MsgUpdateCrosschainFlagsResponse, error) UpdateKeygen(ctx context.Context, in *MsgUpdateKeygen, opts ...grpc.CallOption) (*MsgUpdateKeygenResponse, error) AddBlockHeader(ctx context.Context, in *MsgAddBlockHeader, opts ...grpc.CallOption) (*MsgAddBlockHeaderResponse, error) + ResetChainNonces(ctx context.Context, in *MsgResetChainNonces, opts ...grpc.CallOption) (*MsgResetChainNoncesResponse, error) } type msgClient struct { @@ -1008,6 +1120,15 @@ func (c *msgClient) AddBlockHeader(ctx context.Context, in *MsgAddBlockHeader, o return out, nil } +func (c *msgClient) ResetChainNonces(ctx context.Context, in *MsgResetChainNonces, opts ...grpc.CallOption) (*MsgResetChainNoncesResponse, error) { + out := new(MsgResetChainNoncesResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Msg/ResetChainNonces", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { AddObserver(context.Context, *MsgAddObserver) (*MsgAddObserverResponse, error) @@ -1018,6 +1139,7 @@ type MsgServer interface { UpdateCrosschainFlags(context.Context, *MsgUpdateCrosschainFlags) (*MsgUpdateCrosschainFlagsResponse, error) UpdateKeygen(context.Context, *MsgUpdateKeygen) (*MsgUpdateKeygenResponse, error) AddBlockHeader(context.Context, *MsgAddBlockHeader) (*MsgAddBlockHeaderResponse, error) + ResetChainNonces(context.Context, *MsgResetChainNonces) (*MsgResetChainNoncesResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1048,6 +1170,9 @@ func (*UnimplementedMsgServer) UpdateKeygen(ctx context.Context, req *MsgUpdateK func (*UnimplementedMsgServer) AddBlockHeader(ctx context.Context, req *MsgAddBlockHeader) (*MsgAddBlockHeaderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddBlockHeader not implemented") } +func (*UnimplementedMsgServer) ResetChainNonces(ctx context.Context, req *MsgResetChainNonces) (*MsgResetChainNoncesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ResetChainNonces not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1197,6 +1322,24 @@ func _Msg_AddBlockHeader_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Msg_ResetChainNonces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgResetChainNonces) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ResetChainNonces(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.observer.Msg/ResetChainNonces", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ResetChainNonces(ctx, req.(*MsgResetChainNonces)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.observer.Msg", HandlerType: (*MsgServer)(nil), @@ -1233,6 +1376,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AddBlockHeader", Handler: _Msg_AddBlockHeader_Handler, }, + { + MethodName: "ResetChainNonces", + Handler: _Msg_ResetChainNonces_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "observer/tx.proto", @@ -1813,6 +1960,74 @@ func (m *MsgUpdateKeygenResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgResetChainNonces) 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 *MsgResetChainNonces) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgResetChainNonces) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainNonceHigh != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ChainNonceHigh)) + i-- + dAtA[i] = 0x20 + } + if m.ChainNonceLow != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ChainNonceLow)) + i-- + dAtA[i] = 0x18 + } + if m.ChainId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgResetChainNoncesResponse) 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 *MsgResetChainNoncesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgResetChainNoncesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -2063,6 +2278,37 @@ func (m *MsgUpdateKeygenResponse) Size() (n int) { return n } +func (m *MsgResetChainNonces) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ChainId != 0 { + n += 1 + sovTx(uint64(m.ChainId)) + } + if m.ChainNonceLow != 0 { + n += 1 + sovTx(uint64(m.ChainNonceLow)) + } + if m.ChainNonceHigh != 0 { + n += 1 + sovTx(uint64(m.ChainNonceHigh)) + } + return n +} + +func (m *MsgResetChainNoncesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3635,6 +3881,195 @@ func (m *MsgUpdateKeygenResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgResetChainNonces) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgResetChainNonces: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgResetChainNonces: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainNonceLow", wireType) + } + m.ChainNonceLow = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainNonceLow |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainNonceHigh", wireType) + } + m.ChainNonceHigh = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainNonceHigh |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgResetChainNoncesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgResetChainNoncesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgResetChainNoncesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0