Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new a new msg to remove inbound trackers #3469

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

* [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`
* [3469](https://github.com/zeta-chain/node/pull/3469) - add `MsgRemoveInboundTracker` to remove inbound trackers. This message can be triggered by the emergency policy.

### Tests

Expand Down
54 changes: 54 additions & 0 deletions docs/cli/zetacored/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -10501,6 +10501,7 @@ zetacored tx crosschain [flags]
* [zetacored tx crosschain add-outbound-tracker](#zetacored-tx-crosschain-add-outbound-tracker) - Add an outbound tracker
* [zetacored tx crosschain migrate-tss-funds](#zetacored-tx-crosschain-migrate-tss-funds) - Migrate TSS funds to the latest TSS address
* [zetacored tx crosschain refund-aborted](#zetacored-tx-crosschain-refund-aborted) - Refund an aborted tx , the refund address is optional, if not provided, the refund will be sent to the sender/tx origin of the cctx.
* [zetacored tx crosschain remove-inbound-tracker](#zetacored-tx-crosschain-remove-inbound-tracker) - Remove an inbound tracker
* [zetacored tx crosschain remove-outbound-tracker](#zetacored-tx-crosschain-remove-outbound-tracker) - Remove an outbound tracker
* [zetacored tx crosschain update-tss-address](#zetacored-tx-crosschain-update-tss-address) - Create a new TSSVoter
* [zetacored tx crosschain vote-gas-price](#zetacored-tx-crosschain-vote-gas-price) - Broadcast message to vote gas price
Comment on lines 10501 to 10507
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

New Command Entry and Markdown Style Consistency
The new command entry for zetacored tx crosschain remove-inbound-tracker is well integrated into the command list. Please verify that the anchor link (#zetacored-tx-crosschain-remove-inbound-tracker) correctly points to the corresponding section. Additionally, the static analysis hint indicates that a hard tab is detected on this line; consider replacing any hard tabs with spaces to adhere to markdownlint guidelines.

Proposed diff for hard tab replacement (if applicable):

-	* [zetacored tx crosschain remove-inbound-tracker](#zetacored-tx-crosschain-remove-inbound-tracker)	 - Remove an inbound tracker
+  * [zetacored tx crosschain remove-inbound-tracker](#zetacored-tx-crosschain-remove-inbound-tracker)  - Remove an inbound tracker

Error: No shell scripts or web queries found


🏁 Script executed:

#!/bin/bash
# Verify that the anchor link for "remove-inbound-tracker" in the command list correctly points to an existing section header
# and check if there are any hard tabs in the vicinity (lines 10320 to 10340) in the markdown file.

echo "Searching for markdown headers containing 'remove-inbound-tracker':"
rg -n "^#{1,6}\s+.*remove-inbound-tracker" docs/cli/zetacored/cli.md

echo ""
echo "Displaying lines 10320 to 10340 to inspect potential hard tabs (visible as '^I'):"
sed -n '10320,10340p' docs/cli/zetacored/cli.md | cat -A

Length of output: 2364

Anchor Link Validity and Hard Tab Removal

  • The anchor link #zetacored-tx-crosschain-remove-inbound-tracker correctly points to the corresponding header found at line 10607 in the markdown file.
  • Hard tabs are present in the command list entries (as shown by the ^I characters). It is recommended to replace these with spaces to comply with markdownlint guidelines.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

10330-10330: Hard tabs
Column: 96

(MD010, no-hard-tabs)


10331-10331: Hard tabs
Column: 90

(MD010, no-hard-tabs)


10332-10332: Hard tabs
Column: 84

(MD010, no-hard-tabs)


10333-10333: Hard tabs
Column: 100

(MD010, no-hard-tabs)


10334-10334: Hard tabs
Column: 102

(MD010, no-hard-tabs)


10335-10335: Hard tabs
Column: 92

(MD010, no-hard-tabs)


10336-10336: Hard tabs
Column: 84

(MD010, no-hard-tabs)

Expand Down Expand Up @@ -10774,6 +10775,59 @@ zetacored tx crosschain refund-aborted [cctx-index] [refund-address] [flags]

* [zetacored tx crosschain](#zetacored-tx-crosschain) - crosschain transactions subcommands

## zetacored tx crosschain remove-inbound-tracker

Remove an inbound tracker

```
zetacored tx crosschain remove-inbound-tracker [chain-id] [tx-hash] [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)
--chain-id string The network chain ID
--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 remove-inbound-tracker
--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 CometBFT 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|textual), 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

```
--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|disabled or '*:[level],[key]:[level]')
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx crosschain](#zetacored-tx-crosschain) - crosschain transactions subcommands

## zetacored tx crosschain remove-outbound-tracker

Remove an outbound tracker
Expand Down
2 changes: 2 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59095,6 +59095,8 @@ definitions:
type: object
crosschainMsgRefundAbortedCCTXResponse:
type: object
crosschainMsgRemoveInboundTrackerResponse:
type: object
crosschainMsgRemoveOutboundTrackerResponse:
type: object
crosschainMsgUpdateERC20CustodyPauseStatusResponse:
Expand Down
12 changes: 12 additions & 0 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ message MsgAddInboundTracker {
}
```

## MsgRemoveInboundTracker

RemoveInboundTracker removes the inbound tracker if it exists.

```proto
message MsgRemoveInboundTracker {
string creator = 1;
int64 chain_id = 2;
string tx_hash = 3;
}
```

## MsgRemoveOutboundTracker

RemoveOutboundTracker removes a record from the outbound transaction tracker by chain ID and nonce.
Expand Down
17 changes: 17 additions & 0 deletions proto/zetachain/zetacore/crosschain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ service Msg {
returns (MsgAddOutboundTrackerResponse);
rpc AddInboundTracker(MsgAddInboundTracker)
returns (MsgAddInboundTrackerResponse);
rpc RemoveInboundTracker(MsgRemoveInboundTracker)
returns (MsgRemoveInboundTrackerResponse);
rpc RemoveOutboundTracker(MsgRemoveOutboundTracker)
returns (MsgRemoveOutboundTrackerResponse);

Expand Down Expand Up @@ -64,6 +66,9 @@ message MsgUpdateTssAddress {

message MsgUpdateTssAddressResponse {}

// MsgAddInboundTracker defines a message to add an inbound tracker.
// The index used for the saving the tracker to the store is of the format
// <chain_id>-<tx_hash>
message MsgAddInboundTracker {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
Expand All @@ -77,6 +82,18 @@ message MsgAddInboundTracker {
}
message MsgAddInboundTrackerResponse {}

// MsgRemoveInboundTracker defines a message to remove an inbound tracker.
// The index used for the fetching the tracker to the store is of the format
// <chain_id>-<tx_hash>
message MsgRemoveInboundTracker {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
int64 chain_id = 2;
string tx_hash = 3;
}

message MsgRemoveInboundTrackerResponse {}

// TODO: https://github.com/zeta-chain/node/issues/3083
message MsgWhitelistERC20 {
option (cosmos.msg.v1.signer) = "creator";
Expand Down
61 changes: 61 additions & 0 deletions typescript/zetachain/zetacore/crosschain/tx_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export declare class MsgUpdateTssAddressResponse extends Message<MsgUpdateTssAdd
}

/**
* MsgAddInboundTracker defines a message to add an inbound tracker.
* The index used for the saving the tracker to the store is of the format
* <chain_id>-<tx_hash>
*
* @generated from message zetachain.zetacore.crosschain.MsgAddInboundTracker
*/
export declare class MsgAddInboundTracker extends Message<MsgAddInboundTracker> {
Expand Down Expand Up @@ -188,6 +192,63 @@ export declare class MsgAddInboundTrackerResponse extends Message<MsgAddInboundT
static equals(a: MsgAddInboundTrackerResponse | PlainMessage<MsgAddInboundTrackerResponse> | undefined, b: MsgAddInboundTrackerResponse | PlainMessage<MsgAddInboundTrackerResponse> | undefined): boolean;
}

/**
* MsgRemoveInboundTracker defines a message to remove an inbound tracker.
* The index used for the fetching the tracker to the store is of the format
* <chain_id>-<tx_hash>
*
* @generated from message zetachain.zetacore.crosschain.MsgRemoveInboundTracker
*/
export declare class MsgRemoveInboundTracker extends Message<MsgRemoveInboundTracker> {
/**
* @generated from field: string creator = 1;
*/
creator: string;

/**
* @generated from field: int64 chain_id = 2;
*/
chainId: bigint;

/**
* @generated from field: string tx_hash = 3;
*/
txHash: string;

constructor(data?: PartialMessage<MsgRemoveInboundTracker>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.crosschain.MsgRemoveInboundTracker";
static readonly fields: FieldList;

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

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

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

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

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

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.crosschain.MsgRemoveInboundTrackerResponse";
static readonly fields: FieldList;

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

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

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

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

/**
* TODO: https://github.com/zeta-chain/node/issues/3083
*
Expand Down
6 changes: 6 additions & 0 deletions x/authority/keeper/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

v2 "github.com/zeta-chain/node/x/authority/migrations/v2"
v3 "github.com/zeta-chain/node/x/authority/migrations/v3"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -22,3 +23,8 @@ func NewMigrator(keeper Keeper) Migrator {
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v2.MigrateStore(ctx, m.authorityKeeper)
}

// Migrate2to3 migrates the authority store from consensus version 2 to 3
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.authorityKeeper)
}
46 changes: 46 additions & 0 deletions x/authority/migrations/v3/migrate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package v3

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/zeta-chain/node/x/authority/types"
)

type authorityKeeper interface {
SetAuthorizationList(ctx sdk.Context, list types.AuthorizationList)
GetAuthorizationList(ctx sdk.Context) (val types.AuthorizationList, found bool)
}

// MigrateStore migrates the authority module state from the consensus version 2 to 3
func MigrateStore(
ctx sdk.Context,
keeper authorityKeeper,
) error {
//
var (
authorizationList = types.DefaultAuthorizationsList()
removeInboundAuthorization = types.Authorization{
MsgUrl: "/zetachain.zetacore.crosschain.MsgRemoveInboundTracker",
AuthorizedPolicy: types.PolicyType_groupEmergency,
}
)

// Fetch the current authorization list, if found use that instead of default list
al, found := keeper.GetAuthorizationList(ctx)
if found {
authorizationList = al
}

// Add the new authorization
authorizationList.SetAuthorization(removeInboundAuthorization)

// Validate the authorization list
err := authorizationList.Validate()
if err != nil {
return err
}

// Set the new authorization list
keeper.SetAuthorizationList(ctx, authorizationList)
return nil
}
67 changes: 67 additions & 0 deletions x/authority/migrations/v3/migrate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package v3_test

import (
"testing"

"github.com/stretchr/testify/require"

keepertest "github.com/zeta-chain/node/testutil/keeper"
v3 "github.com/zeta-chain/node/x/authority/migrations/v3"
"github.com/zeta-chain/node/x/authority/types"
)

func TestMigrateStore(t *testing.T) {
t.Run("update authorization list", func(t *testing.T) {
// Arrange
k, ctx := keepertest.AuthorityKeeper(t)

list := types.DefaultAuthorizationsList()
list.RemoveAuthorization("/zetachain.zetacore.crosschain.MsgRemoveInboundTracker")
k.SetAuthorizationList(ctx, list)

// Act
err := v3.MigrateStore(ctx, *k)

// Assert
require.NoError(t, err)
list, found := k.GetAuthorizationList(ctx)
require.True(t, found)
require.Equal(t, types.DefaultAuthorizationsList(), list)
})

t.Run("set default authorization list if list is not found", func(t *testing.T) {
// Arrange
k, ctx := keepertest.AuthorityKeeper(t)

// Act
err := v3.MigrateStore(ctx, *k)

// Assert
require.NoError(t, err)
list, found := k.GetAuthorizationList(ctx)
require.True(t, found)
require.Equal(t, types.DefaultAuthorizationsList(), list)
})

t.Run("return error list is invalid", func(t *testing.T) {
// Arrange
k, ctx := keepertest.AuthorityKeeper(t)

k.SetAuthorizationList(ctx, types.AuthorizationList{Authorizations: []types.Authorization{
{
MsgUrl: "ABC",
AuthorizedPolicy: types.PolicyType_groupEmergency,
},
{
MsgUrl: "ABC",
AuthorizedPolicy: types.PolicyType_groupEmergency,
},
}})

// Act
err := v3.MigrateStore(ctx, *k)

// Assert
require.Error(t, err)
})
}
7 changes: 6 additions & 1 deletion x/authority/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/zeta-chain/node/x/authority/types"
)

const ConsensusVersion = 3

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
Expand Down Expand Up @@ -126,6 +128,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil {
panic(err)
}
if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
panic(err)
}
}

// RegisterInvariants registers the authority module's invariants.
Expand All @@ -150,7 +155,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }

// BeginBlock executes all ABCI BeginBlock logic respective to the authority module.
func (am AppModule) BeginBlock(_ context.Context) error {
Expand Down
1 change: 1 addition & 0 deletions x/authority/types/authorization_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
"/zetachain.zetacore.crosschain.MsgAddInboundTracker",
"/zetachain.zetacore.crosschain.MsgAddOutboundTracker",
"/zetachain.zetacore.crosschain.MsgRemoveOutboundTracker",
"/zetachain.zetacore.crosschain.MsgRemoveInboundTracker",
"/zetachain.zetacore.fungible.MsgPauseZRC20",
"/zetachain.zetacore.observer.MsgUpdateKeygen",
"/zetachain.zetacore.observer.MsgDisableCCTX",
Expand Down
1 change: 1 addition & 0 deletions x/authority/types/authorization_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ func TestDefaultAuthorizationsList(t *testing.T) {
// EmergencyPolicyMessageList is a list of messages that can be authorized by the emergency policy
var EmergencyPolicyMessageList = []string{
sdk.MsgTypeURL(&crosschaintypes.MsgAddInboundTracker{}),
sdk.MsgTypeURL(&crosschaintypes.MsgRemoveInboundTracker{}),
sdk.MsgTypeURL(&crosschaintypes.MsgAddOutboundTracker{}),
sdk.MsgTypeURL(&crosschaintypes.MsgRemoveOutboundTracker{}),
sdk.MsgTypeURL(&fungibletypes.MsgPauseZRC20{}),
Expand Down
Loading