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

refactor: move TSS vote message from crosschain to observer #1966

Merged
merged 19 commits into from
Apr 3, 2024
Merged
2 changes: 1 addition & 1 deletion app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool {
*cctxtypes.MsgVoteOnObservedInboundTx,
*cctxtypes.MsgVoteOnObservedOutboundTx,
*cctxtypes.MsgAddToOutTxTracker,
*cctxtypes.MsgCreateTSSVoter,
*observertypes.MsgVoteTSS,
*observertypes.MsgAddBlockHeader,
*observertypes.MsgAddBlameVote:
signers := innerMsg.GetSigners()
Expand Down
10 changes: 5 additions & 5 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestIsSystemTx(t *testing.T) {
}{
{
"MsgCreateTSSVoter",
buildTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
buildTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
TssPubkey: "pubkey1234",
}),
Expand All @@ -74,7 +74,7 @@ func TestIsSystemTx(t *testing.T) {
},
{
"MsgCreateTSSVoter",
buildTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
buildTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
TssPubkey: "pubkey1234",
}),
Expand All @@ -83,7 +83,7 @@ func TestIsSystemTx(t *testing.T) {
},
{
"MsgExec{MsgCreateTSSVoter}",
buildAuthzTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
buildAuthzTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
TssPubkey: "pubkey1234",
}),
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestIsSystemTx(t *testing.T) {
},
{
"MsgCreateTSSVoter",
buildTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
buildTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand All @@ -179,7 +179,7 @@ func TestIsSystemTx(t *testing.T) {
},
{
"MsgExec{MsgCreateTSSVoter}",
buildAuthzTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
buildAuthzTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* [1914](https://github.com/zeta-chain/node/pull/1914) - move crosschain flags to core context in zetaclient
* [1948](https://github.com/zeta-chain/node/pull/1948) - remove deprecated GetTSSAddress query in crosschain module
* [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg
* [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer

### Features

Expand Down
17 changes: 8 additions & 9 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ import (
"strings"
"sync"

"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/onrik/ethrpc"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/testutil/sample"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/bitcoin"
"github.com/zeta-chain/zetacore/zetaclient/config"
corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context"
"github.com/zeta-chain/zetacore/zetaclient/evm"
"github.com/zeta-chain/zetacore/zetaclient/keys"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
"github.com/zeta-chain/zetacore/zetaclient/zetabridge"

"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/testutil/sample"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

var debugArgs = debugArguments{}
Expand Down
1 change: 0 additions & 1 deletion docs/cli/zetacored/zetacored_tx_crosschain.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ zetacored tx crosschain [flags]
* [zetacored tx crosschain add-to-in-tx-tracker](zetacored_tx_crosschain_add-to-in-tx-tracker.md) - Add a in-tx-tracker
Use 0:Zeta,1:Gas,2:ERC20
* [zetacored tx crosschain add-to-out-tx-tracker](zetacored_tx_crosschain_add-to-out-tx-tracker.md) - Add a out-tx-tracker
* [zetacored tx crosschain create-tss-voter](zetacored_tx_crosschain_create-tss-voter.md) - Create a new TSSVoter
* [zetacored tx crosschain gas-price-voter](zetacored_tx_crosschain_gas-price-voter.md) - Broadcast message gasPriceVoter
* [zetacored tx crosschain inbound-voter](zetacored_tx_crosschain_inbound-voter.md) - Broadcast message sendVoter
* [zetacored tx crosschain migrate-tss-funds](zetacored_tx_crosschain_migrate-tss-funds.md) - Migrate TSS funds to the latest TSS address
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 @@ -27,6 +27,7 @@ zetacored tx observer [flags]
* [zetacored tx](zetacored_tx.md) - Transactions subcommands
* [zetacored tx observer add-blame-vote](zetacored_tx_observer_add-blame-vote.md) - Broadcast message add-blame-vote
* [zetacored tx observer add-observer](zetacored_tx_observer_add-observer.md) - Broadcast message add-observer
* [zetacored tx observer create-tss-voter](zetacored_tx_observer_create-tss-voter.md) - Create a new TSSVoter
* [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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# tx crosschain create-tss-voter
# tx observer create-tss-voter

Create a new TSSVoter

```
zetacored tx crosschain create-tss-voter [pubkey] [keygenBlock] [status] [flags]
zetacored tx observer create-tss-voter [pubkey] [keygen-block] [status] [flags]
```

### Options
Expand Down Expand Up @@ -48,5 +48,5 @@ zetacored tx crosschain create-tss-voter [pubkey] [keygenBlock] [status] [flags]

### SEE ALSO

* [zetacored tx crosschain](zetacored_tx_crosschain.md) - crosschain transactions subcommands
* [zetacored tx observer](zetacored_tx_observer.md) - observer transactions subcommands

11 changes: 9 additions & 2 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53701,8 +53701,6 @@ definitions:
is_removed:
type: boolean
title: if the tx was removed from the tracker due to no pending cctx
crosschainMsgCreateTSSVoterResponse:
type: object
crosschainMsgGasPriceVoterResponse:
type: object
crosschainMsgMigrateTssFundsResponse:
Expand Down Expand Up @@ -54324,6 +54322,15 @@ definitions:
type: object
observerMsgUpdateObserverResponse:
type: object
observerMsgVoteTSSResponse:
type: object
properties:
ballot_created:
type: boolean
vote_finalized:
type: boolean
keygen_success:
type: boolean
observerNode:
type: object
properties:
Expand Down
22 changes: 0 additions & 22 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,6 @@ message MsgMigrateTssFunds {
}
```

## MsgCreateTSSVoter

CreateTSSVoter votes on creating a TSS key and recording the information about it (public
key, participant and operator addresses, finalized and keygen heights).

If the vote passes, the information about the TSS key is recorded on chain
and the status of the keygen is set to "success".

Fails if the keygen does not exist, the keygen has been already
completed, or the keygen has failed.

Only node accounts are authorized to broadcast this message.

```proto
message MsgCreateTSSVoter {
string creator = 1;
string tss_pubkey = 2;
int64 keyGenZetaHeight = 3;
chains.ReceiveStatus status = 4;
}
```

## MsgAbortStuckCCTX

AbortStuckCCTX aborts a stuck CCTX
Expand Down
22 changes: 22 additions & 0 deletions docs/spec/observer/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,25 @@ message MsgResetChainNonces {
}
```

## MsgVoteTSS

VoteTSS votes on creating a TSS key and recording the information about it (public
key, participant and operator addresses, finalized and keygen heights).

If the vote passes, the information about the TSS key is recorded on chain
and the status of the keygen is set to "success".

Fails if the keygen does not exist, the keygen has been already
completed, or the keygen has failed.

Only node accounts are authorized to broadcast this message.

```proto
message MsgVoteTSS {
string creator = 1;
string tss_pubkey = 2;
int64 keygen_zeta_height = 3;
chains.ReceiveStatus status = 4;
}
```

11 changes: 1 addition & 10 deletions proto/crosschain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,11 @@ service Msg {
rpc WhitelistERC20(MsgWhitelistERC20) returns (MsgWhitelistERC20Response);
rpc UpdateTssAddress(MsgUpdateTssAddress) returns (MsgUpdateTssAddressResponse);
rpc MigrateTssFunds(MsgMigrateTssFunds) returns (MsgMigrateTssFundsResponse);
rpc CreateTSSVoter(MsgCreateTSSVoter) returns (MsgCreateTSSVoterResponse);

rpc AbortStuckCCTX(MsgAbortStuckCCTX) returns (MsgAbortStuckCCTXResponse);
rpc RefundAbortedCCTX(MsgRefundAbortedCCTX) returns (MsgRefundAbortedCCTXResponse);
}

message MsgCreateTSSVoter {
string creator = 1;
string tss_pubkey = 2;
int64 keyGenZetaHeight = 3;
chains.ReceiveStatus status = 4;
}

message MsgCreateTSSVoterResponse {}

message MsgMigrateTssFunds {
string creator = 1;
int64 chain_id = 2;
Expand All @@ -43,6 +33,7 @@ message MsgMigrateTssFunds {
(gogoproto.nullable) = false
];
}

message MsgMigrateTssFundsResponse {}

message MsgUpdateTssAddress {
Expand Down
15 changes: 15 additions & 0 deletions proto/observer/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "observer/observer.proto";
import "observer/params.proto";
import "observer/pending_nonces.proto";
import "observer/tss.proto";
import "pkg/chains/chains.proto";
import "pkg/proofs/proofs.proto";

option go_package = "github.com/zeta-chain/zetacore/x/observer/types";
Expand All @@ -23,6 +24,7 @@ service Msg {
rpc UpdateKeygen(MsgUpdateKeygen) returns (MsgUpdateKeygenResponse);
rpc AddBlockHeader(MsgAddBlockHeader) returns (MsgAddBlockHeaderResponse);
rpc ResetChainNonces(MsgResetChainNonces) returns (MsgResetChainNoncesResponse);
rpc VoteTSS(MsgVoteTSS) returns (MsgVoteTSSResponse);
}

message MsgUpdateObserver {
Expand Down Expand Up @@ -98,3 +100,16 @@ message MsgResetChainNonces {
}

message MsgResetChainNoncesResponse {}

message MsgVoteTSS {
string creator = 1;
string tss_pubkey = 2;
int64 keygen_zeta_height = 3;
chains.ReceiveStatus status = 4;
}

message MsgVoteTSSResponse {
bool ballot_created = 1;
bool vote_finalized = 2;
bool keygen_success = 3;
}
4 changes: 1 addition & 3 deletions testutil/sample/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ func ObserverSet(n int) types.ObserverSet {
}

func NodeAccount() *types.NodeAccount {
operator := AccAddress()

return &types.NodeAccount{
Operator: operator,
Operator: AccAddress(),
GranteeAddress: AccAddress(),
GranteePubkey: PubKeySet(),
NodeStatus: types.NodeStatus_Active,
Expand Down
60 changes: 1 addition & 59 deletions typescript/crosschain/tx_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,9 @@

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import type { ReceiveStatus } from "../pkg/chains/chains_pb.js";
import type { CoinType } from "../pkg/coin/coin_pb.js";
import type { Proof } from "../pkg/proofs/proofs_pb.js";

/**
* @generated from message zetachain.zetacore.crosschain.MsgCreateTSSVoter
*/
export declare class MsgCreateTSSVoter extends Message<MsgCreateTSSVoter> {
/**
* @generated from field: string creator = 1;
*/
creator: string;

/**
* @generated from field: string tss_pubkey = 2;
*/
tssPubkey: string;

/**
* @generated from field: int64 keyGenZetaHeight = 3;
*/
keyGenZetaHeight: bigint;

/**
* @generated from field: chains.ReceiveStatus status = 4;
*/
status: ReceiveStatus;

constructor(data?: PartialMessage<MsgCreateTSSVoter>);

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

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

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

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

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

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

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

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

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

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

static equals(a: MsgCreateTSSVoterResponse | PlainMessage<MsgCreateTSSVoterResponse> | undefined, b: MsgCreateTSSVoterResponse | PlainMessage<MsgCreateTSSVoterResponse> | undefined): boolean;
}
import type { ReceiveStatus } from "../pkg/chains/chains_pb.js";

/**
* @generated from message zetachain.zetacore.crosschain.MsgMigrateTssFunds
Expand Down
Loading
Loading