Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile-versioned-source
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
})
Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_tx_observer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions docs/cli/zetacored/zetacored_tx_observer_reset-chain-nonces.md
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54314,6 +54314,8 @@ definitions:
type: object
observerMsgRemoveChainParamsResponse:
type: object
observerMsgResetChainNoncesResponse:
type: object
observerMsgUpdateChainParamsResponse:
type: object
observerMsgUpdateCrosschainFlagsResponse:
Expand Down
14 changes: 14 additions & 0 deletions docs/spec/observer/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
```

10 changes: 10 additions & 0 deletions proto/observer/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {}
58 changes: 58 additions & 0 deletions typescript/observer/tx_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,61 @@ export declare class MsgUpdateKeygenResponse extends Message<MsgUpdateKeygenResp
static equals(a: MsgUpdateKeygenResponse | PlainMessage<MsgUpdateKeygenResponse> | undefined, b: MsgUpdateKeygenResponse | PlainMessage<MsgUpdateKeygenResponse> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.observer.MsgResetChainNonces
*/
export declare class MsgResetChainNonces extends Message<MsgResetChainNonces> {
/**
* @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<MsgResetChainNonces>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.observer.MsgResetChainNonces";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgResetChainNonces;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgResetChainNonces;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgResetChainNonces;

static equals(a: MsgResetChainNonces | PlainMessage<MsgResetChainNonces> | undefined, b: MsgResetChainNonces | PlainMessage<MsgResetChainNonces> | undefined): boolean;
}

/**
* @generated from message zetachain.zetacore.observer.MsgResetChainNoncesResponse
*/
export declare class MsgResetChainNoncesResponse extends Message<MsgResetChainNoncesResponse> {
constructor(data?: PartialMessage<MsgResetChainNoncesResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.observer.MsgResetChainNoncesResponse";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgResetChainNoncesResponse;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgResetChainNoncesResponse;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgResetChainNoncesResponse;

static equals(a: MsgResetChainNoncesResponse | PlainMessage<MsgResetChainNoncesResponse> | undefined, b: MsgResetChainNoncesResponse | PlainMessage<MsgResetChainNoncesResponse> | undefined): boolean;
}

4 changes: 4 additions & 0 deletions x/crosschain/keeper/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion x/emissions/genesis_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions x/observer/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetTxCmd() *cobra.Command {
CmdAddBlameVote(),
CmdUpdateObserver(),
CmdEncode(),
CmdResetChainNonces(),
)

return cmd
Expand Down
58 changes: 58 additions & 0 deletions x/observer/client/cli/tx_reset_chain_nonces.go
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 5 additions & 0 deletions x/observer/keeper/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading