Skip to content

Commit

Permalink
refactor(observer): rename MsgAddBlameVote to MsgVoteBlame (#2290)
Browse files Browse the repository at this point in the history
* rename occurences

* do some renaming

* make generate

* changelog

* add breaking change note

* remove readme
  • Loading branch information
lumtis authored May 30, 2024
1 parent 85861be commit 8eadf56
Show file tree
Hide file tree
Showing 23 changed files with 236 additions and 233 deletions.
2 changes: 1 addition & 1 deletion app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool {
*crosschaintypes.MsgAddInboundTracker,
*observertypes.MsgVoteBlockHeader,
*observertypes.MsgVoteTSS,
*observertypes.MsgAddBlameVote:
*observertypes.MsgVoteBlame:
signers := innerMsg.GetSigners()
if len(signers) == 1 {
return isAuthorizedSigner(signers[0].String())
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 @@ -40,7 +40,7 @@ func TestIsSystemTx(t *testing.T) {
// *cctxtypes.MsgAddInboundTracker,
// *observertypes.MsgVoteBlockHeader,
// *observertypes.MsgVoteTSS,
// *observertypes.MsgAddBlameVote:
// *observertypes.MsgVoteBlame:
buildTxFromMsg := func(msg sdk.Msg) sdk.Tx {
txBuilder := app.MakeEncodingConfig().TxConfig.NewTxBuilder()
txBuilder.SetMsgs(msg)
Expand Down Expand Up @@ -225,17 +225,17 @@ func TestIsSystemTx(t *testing.T) {
true,
},
{
"MsgAddBlameVote",
buildTxFromMsg(&observertypes.MsgAddBlameVote{
"MsgVoteBlame",
buildTxFromMsg(&observertypes.MsgVoteBlame{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgAddBlameVote}",
buildAuthzTxFromMsg(&observertypes.MsgAddBlameVote{
"MsgExec{MsgVoteBlame}",
buildAuthzTxFromMsg(&observertypes.MsgVoteBlame{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
* [2205](https://github.com/zeta-chain/node/pull/2205) - remove deprecated variables pre-v17
* [2226](https://github.com/zeta-chain/node/pull/2226) - improve Go formatting with imports standardization and max line length to 120
* [2262](https://github.com/zeta-chain/node/pull/2262) - refactor MsgUpdateZRC20 into MsgPauseZrc20 and MsgUnPauseZRC20
* [2290](https://github.com/zeta-chain/node/pull/2290) - rename `MsgAddBlameVote` message to `MsgVoteBlame`
* [2269](https://github.com/zeta-chain/node/pull/2269) - refactor MsgUpdateCrosschainFlags into MsgEnableCCTX, MsgDisableCCTX and MsgUpdateGasPriceIncreaseFlags


### Tests

* [2047](https://github.com/zeta-chain/node/pull/2047) - fix liquidity cap advanced test
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/monitor_priority_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func isMsgTypeURLSystemTx(attr types.EventAttribute) bool {
"\"/zetachain.zetacore.crosschain.MsgAddInboundTracker\"",
"\"/zetachain.zetacore.observer.MsgVoteBlockHeader\"",
"\"/zetachain.zetacore.observer.MsgVoteTSS\"",
"\"/zetachain.zetacore.observer.MsgAddBlameVote\"",
"\"/zetachain.zetacore.observer.MsgVoteBlame\"",
}

for _, url := range systemTxsMsgTypeUrls {
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/zetacored/zetacored_tx_observer.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ zetacored tx observer [flags]
### SEE ALSO

* [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 disable-cctx](zetacored_tx_observer_disable-cctx.md) - Disable inbound and outbound for CCTX
* [zetacored tx observer enable-cctx](zetacored_tx_observer_enable-cctx.md) - Enable inbound and outbound for CCTX
Expand All @@ -37,5 +36,6 @@ zetacored tx observer [flags]
* [zetacored tx observer update-gas-price-increase-flags](zetacored_tx_observer_update-gas-price-increase-flags.md) - Update the gas price increase flags
* [zetacored tx observer update-keygen](zetacored_tx_observer_update-keygen.md) - command to update the keygen block via a group proposal
* [zetacored tx observer update-observer](zetacored_tx_observer_update-observer.md) - Broadcast message add-observer
* [zetacored tx observer vote-blame](zetacored_tx_observer_vote-blame.md) - Broadcast message vote-blame
* [zetacored tx observer vote-tss](zetacored_tx_observer_vote-tss.md) - Vote for a new TSS creation

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# tx observer add-blame-vote
# tx observer vote-blame

Broadcast message add-blame-vote
Broadcast message vote-blame

```
zetacored tx observer add-blame-vote [chain-id] [index] [failure-reason] [node-list] [flags]
zetacored tx observer vote-blame [chain-id] [index] [failure-reason] [node-list] [flags]
```

### Options
Expand All @@ -22,7 +22,7 @@ zetacored tx observer add-blame-vote [chain-id] [index] [failure-reason] [node-l
--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 add-blame-vote
-h, --help help for vote-blame
--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
Expand Down
4 changes: 2 additions & 2 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57746,8 +57746,6 @@ definitions:
last_change_height:
type: string
format: int64
observerMsgAddBlameVoteResponse:
type: object
observerMsgAddObserverResponse:
type: object
observerMsgDisableCCTXResponse:
Expand All @@ -57766,6 +57764,8 @@ definitions:
type: object
observerMsgUpdateObserverResponse:
type: object
observerMsgVoteBlameResponse:
type: object
observerMsgVoteBlockHeaderResponse:
type: object
properties:
Expand Down
4 changes: 4 additions & 0 deletions docs/releases/v17_breaking_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@
* `MsgUpdateZRC20` has been removed, and replaced with `MsgPauseZRC20` and `MsgUnpauseZRC20` messages.
* `MsgPauseZRC20` message pauses a ZRC20 token and can be triggered via `PolicyType_groupEmergency`
* `MsgUnpauseZRC20` message unpauses a ZRC20 token and can be triggered via `PolicyType_groupOperational`

### `MsgAddBlameVote` renaming

* `MsgAddBlameVote` has been renamed to `MsgVoteBlame` to maintain consistency with other voting messages
4 changes: 2 additions & 2 deletions docs/spec/observer/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ message MsgRemoveChainParams {
}
```

## MsgAddBlameVote
## MsgVoteBlame

```proto
message MsgAddBlameVote {
message MsgVoteBlame {
string creator = 1;
int64 chain_id = 2;
Blame blame_info = 3;
Expand Down
6 changes: 3 additions & 3 deletions proto/zetachain/zetacore/observer/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ service Msg {
returns (MsgUpdateChainParamsResponse);
rpc RemoveChainParams(MsgRemoveChainParams)
returns (MsgRemoveChainParamsResponse);
rpc AddBlameVote(MsgAddBlameVote) returns (MsgAddBlameVoteResponse);
rpc VoteBlame(MsgVoteBlame) returns (MsgVoteBlameResponse);
rpc UpdateKeygen(MsgUpdateKeygen) returns (MsgUpdateKeygenResponse);
rpc VoteBlockHeader(MsgVoteBlockHeader) returns (MsgVoteBlockHeaderResponse);
rpc ResetChainNonces(MsgResetChainNonces)
Expand Down Expand Up @@ -77,13 +77,13 @@ message MsgAddObserver {

message MsgAddObserverResponse {}

message MsgAddBlameVote {
message MsgVoteBlame {
string creator = 1;
int64 chain_id = 2;
Blame blame_info = 3 [ (gogoproto.nullable) = false ];
}

message MsgAddBlameVoteResponse {}
message MsgVoteBlameResponse {}

message MsgUpdateKeygen {
string creator = 1;
Expand Down
2 changes: 1 addition & 1 deletion testutil/sample/sample.go

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions typescript/zetachain/zetacore/observer/tx_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ export declare class MsgAddObserverResponse extends Message<MsgAddObserverRespon
}

/**
* @generated from message zetachain.zetacore.observer.MsgAddBlameVote
* @generated from message zetachain.zetacore.observer.MsgVoteBlame
*/
export declare class MsgAddBlameVote extends Message<MsgAddBlameVote> {
export declare class MsgVoteBlame extends Message<MsgVoteBlame> {
/**
* @generated from field: string creator = 1;
*/
Expand All @@ -316,38 +316,38 @@ export declare class MsgAddBlameVote extends Message<MsgAddBlameVote> {
*/
blameInfo?: Blame;

constructor(data?: PartialMessage<MsgAddBlameVote>);
constructor(data?: PartialMessage<MsgVoteBlame>);

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

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

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

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

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

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

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

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

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

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

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

/**
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/types/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetAllAuthzZetaclientTxTypes() []string {
sdk.MsgTypeURL(&MsgVoteOutbound{}),
sdk.MsgTypeURL(&MsgAddOutboundTracker{}),
sdk.MsgTypeURL(&observertypes.MsgVoteTSS{}),
sdk.MsgTypeURL(&observertypes.MsgAddBlameVote{}),
sdk.MsgTypeURL(&observertypes.MsgVoteBlame{}),
sdk.MsgTypeURL(&observertypes.MsgVoteBlockHeader{}),
}
}
2 changes: 1 addition & 1 deletion x/crosschain/types/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestGetAllAuthzZetaclientTxTypes(t *testing.T) {
"/zetachain.zetacore.crosschain.MsgVoteOutbound",
"/zetachain.zetacore.crosschain.MsgAddOutboundTracker",
"/zetachain.zetacore.observer.MsgVoteTSS",
"/zetachain.zetacore.observer.MsgAddBlameVote",
"/zetachain.zetacore.observer.MsgVoteBlame",
"/zetachain.zetacore.observer.MsgVoteBlockHeader"},
crosschaintypes.GetAllAuthzZetaclientTxTypes())
}
2 changes: 1 addition & 1 deletion x/observer/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func GetTxCmd() *cobra.Command {
CmdUpdateChainParams(),
CmdRemoveChainParams(),
CmdUpdateKeygen(),
CmdAddBlameVote(),
CmdVoteBlame(),
CmdUpdateObserver(),
CmdEncode(),
CmdResetChainNonces(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"github.com/zeta-chain/zetacore/x/observer/types"
)

func CmdAddBlameVote() *cobra.Command {
func CmdVoteBlame() *cobra.Command {
cmd := &cobra.Command{
Use: "add-blame-vote [chain-id] [index] [failure-reason] [node-list]",
Short: "Broadcast message add-blame-vote",
Use: "vote-blame [chain-id] [index] [failure-reason] [node-list]",
Short: "Broadcast message vote-blame",
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) (err error) {
chainID, err := strconv.Atoi(args[0])
Expand Down Expand Up @@ -55,9 +55,8 @@ func CmdAddBlameVote() *cobra.Command {
Nodes: blameNodes,
}

msg := types.NewMsgAddBlameVoteMsg(clientCtx.GetFromAddress().String(), int64(chainID), blameInfo)
msg := types.NewMsgVoteBlameMsg(clientCtx.GetFromAddress().String(), int64(chainID), blameInfo)

println("about to broadcast")
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"github.com/zeta-chain/zetacore/x/observer/types"
)

func (k msgServer) AddBlameVote(
func (k msgServer) VoteBlame(
goCtx context.Context,
vote *types.MsgAddBlameVote,
) (*types.MsgAddBlameVoteResponse, error) {
vote *types.MsgVoteBlame,
) (*types.MsgVoteBlameResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
observationType := types.ObservationType_TSSKeySign

Expand Down Expand Up @@ -52,13 +52,13 @@ func (k msgServer) AddBlameVote(
_, isFinalized := k.CheckIfFinalizingVote(ctx, ballot)
if !isFinalized {
// Return nil here to add vote to ballot and commit state
return &types.MsgAddBlameVoteResponse{}, nil
return &types.MsgVoteBlameResponse{}, nil
}

// ******************************************************************************
// below only happens when ballot is finalized: exactly when threshold vote is in
// ******************************************************************************

k.SetBlame(ctx, vote.BlameInfo)
return &types.MsgAddBlameVoteResponse{}, nil
return &types.MsgVoteBlameResponse{}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/zeta-chain/zetacore/x/observer/types"
)

func TestMsgServer_AddBlameVote(t *testing.T) {
func TestMsgServer_VoteBlame(t *testing.T) {
t.Run("should error if supported chain not found", func(t *testing.T) {
k, ctx, _, _ := keepertest.ObserverKeeper(t)
srv := keeper.NewMsgServerImpl(*k)

res, err := srv.AddBlameVote(ctx, &types.MsgAddBlameVote{
res, err := srv.VoteBlame(ctx, &types.MsgVoteBlame{
ChainId: 1,
})
require.Error(t, err)
Expand All @@ -34,7 +34,7 @@ func TestMsgServer_AddBlameVote(t *testing.T) {
chainId := getValidEthChainIDWithIndex(t, 0)
setSupportedChain(ctx, *k, chainId)

res, err := srv.AddBlameVote(ctx, &types.MsgAddBlameVote{
res, err := srv.VoteBlame(ctx, &types.MsgVoteBlame{
ChainId: chainId,
})
require.Error(t, err)
Expand Down Expand Up @@ -70,13 +70,13 @@ func TestMsgServer_AddBlameVote(t *testing.T) {
})

blameInfo := sample.BlameRecord(t, "index")
res, err := srv.AddBlameVote(ctx, &types.MsgAddBlameVote{
res, err := srv.VoteBlame(ctx, &types.MsgVoteBlame{
Creator: accAddressOfValidator.String(),
ChainId: chainId,
BlameInfo: blameInfo,
})
require.NoError(t, err)
require.Equal(t, &types.MsgAddBlameVoteResponse{}, res)
require.Equal(t, &types.MsgVoteBlameResponse{}, res)

blame, found := k.GetBlame(ctx, blameInfo.Index)
require.True(t, found)
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestMsgServer_AddBlameVote(t *testing.T) {
ObserverList: []string{accAddressOfValidator.String(), "Observer2"},
})
blameInfo := sample.BlameRecord(t, "index")
vote := &types.MsgAddBlameVote{
vote := &types.MsgVoteBlame{
Creator: accAddressOfValidator.String(),
ChainId: chainId,
BlameInfo: blameInfo,
Expand All @@ -126,7 +126,7 @@ func TestMsgServer_AddBlameVote(t *testing.T) {
}
k.SetBallot(ctx, &ballot)

_, err = srv.AddBlameVote(ctx, vote)
_, err = srv.VoteBlame(ctx, vote)
require.Error(t, err)
})

Expand Down Expand Up @@ -158,7 +158,7 @@ func TestMsgServer_AddBlameVote(t *testing.T) {
ObserverList: []string{accAddressOfValidator.String(), "Observer2"},
})
blameInfo := sample.BlameRecord(t, "index")
vote := &types.MsgAddBlameVote{
vote := &types.MsgVoteBlame{
Creator: accAddressOfValidator.String(),
ChainId: chainId,
BlameInfo: blameInfo,
Expand All @@ -173,9 +173,9 @@ func TestMsgServer_AddBlameVote(t *testing.T) {
}
k.SetBallot(ctx, &ballot)

res, err := srv.AddBlameVote(ctx, vote)
res, err := srv.VoteBlame(ctx, vote)
require.NoError(t, err)
require.Equal(t, &types.MsgAddBlameVoteResponse{}, res)
require.Equal(t, &types.MsgVoteBlameResponse{}, res)

_, found := k.GetBlame(ctx, blameInfo.Index)
require.False(t, found)
Expand Down
Loading

0 comments on commit 8eadf56

Please sign in to comment.