Skip to content

Commit 26b4f69

Browse files
authored
feat: add MsgAddAuthorization to add or update and authorization and MsgRemoveAuthorization to remove a authorization (#2305)
1 parent c93d1c6 commit 26b4f69

34 files changed

+2330
-124
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [2275](https://github.com/zeta-chain/node/pull/2275) - add ChainInfo singleton state variable in authority
2323
* [2291](https://github.com/zeta-chain/node/pull/2291) - initialize cctx gateway interface
2424
* [2289](https://github.com/zeta-chain/node/pull/2289) - add an authorization list to keep track of all authorizations on the chain
25+
* [2305](https://github.com/zeta-chain/node/pull/2305) - add new messages `MsgAddAuthorization` and `MsgRemoveAuthorization` that can be used to update the authorization list
2526

2627
### Refactor
2728

docs/cli/zetacored/zetacored_tx_authority.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ zetacored tx authority [flags]
2626
### SEE ALSO
2727

2828
* [zetacored tx](zetacored_tx.md) - Transactions subcommands
29+
* [zetacored tx authority add-authorization](zetacored_tx_authority_add-authorization.md) - Add a new authorization or update the policy of an existing authorization. Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin.
30+
* [zetacored tx authority remove-authorization](zetacored_tx_authority_remove-authorization.md) - removes an existing authorization
2931
* [zetacored tx authority update-chain-info](zetacored_tx_authority_update-chain-info.md) - Update the chain info
30-
* [zetacored tx authority update-policies](zetacored_tx_authority_update-policies.md) - Update the policies
32+
* [zetacored tx authority update-policies](zetacored_tx_authority_update-policies.md) - Update policies to values provided in the JSON file.
3133

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# tx authority add-authorization
2+
3+
Add a new authorization or update the policy of an existing authorization. Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin.
4+
5+
```
6+
zetacored tx authority add-authorization [msg-url] [authorized-policy] [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-a, --account-number uint The account number of the signing account (offline mode only)
13+
--aux Generate aux signer data instead of sending a tx
14+
-b, --broadcast-mode string Transaction broadcasting mode (sync|async)
15+
--chain-id string The network chain ID
16+
--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)
17+
--fee-granter string Fee granter grants fees for the transaction
18+
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
19+
--fees string Fees to pay along with transaction; eg: 10uatom
20+
--from string Name or address of private key with which to sign
21+
--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)
22+
--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)
23+
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
24+
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
25+
-h, --help help for add-authorization
26+
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
27+
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
28+
--ledger Use a connected Ledger device
29+
--node string [host]:[port] to tendermint rpc interface for this chain
30+
--note string Note to add a description to the transaction (previously --memo)
31+
--offline Offline mode (does not allow any online functionality)
32+
-o, --output string Output format (text|json)
33+
-s, --sequence uint The sequence number of the signing account (offline mode only)
34+
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
35+
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
36+
--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
37+
-y, --yes Skip tx broadcasting prompt confirmation
38+
```
39+
40+
### Options inherited from parent commands
41+
42+
```
43+
--home string directory for config and data
44+
--log_format string The logging format (json|plain)
45+
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
46+
--log_no_color Disable colored logs
47+
--trace print out full stack trace on errors
48+
```
49+
50+
### SEE ALSO
51+
52+
* [zetacored tx authority](zetacored_tx_authority.md) - authority transactions subcommands
53+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# tx authority remove-authorization
2+
3+
removes an existing authorization
4+
5+
```
6+
zetacored tx authority remove-authorization [msg-url] [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-a, --account-number uint The account number of the signing account (offline mode only)
13+
--aux Generate aux signer data instead of sending a tx
14+
-b, --broadcast-mode string Transaction broadcasting mode (sync|async)
15+
--chain-id string The network chain ID
16+
--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)
17+
--fee-granter string Fee granter grants fees for the transaction
18+
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
19+
--fees string Fees to pay along with transaction; eg: 10uatom
20+
--from string Name or address of private key with which to sign
21+
--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)
22+
--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)
23+
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
24+
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
25+
-h, --help help for remove-authorization
26+
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
27+
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
28+
--ledger Use a connected Ledger device
29+
--node string [host]:[port] to tendermint rpc interface for this chain
30+
--note string Note to add a description to the transaction (previously --memo)
31+
--offline Offline mode (does not allow any online functionality)
32+
-o, --output string Output format (text|json)
33+
-s, --sequence uint The sequence number of the signing account (offline mode only)
34+
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
35+
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
36+
--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
37+
-y, --yes Skip tx broadcasting prompt confirmation
38+
```
39+
40+
### Options inherited from parent commands
41+
42+
```
43+
--home string directory for config and data
44+
--log_format string The logging format (json|plain)
45+
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
46+
--log_no_color Disable colored logs
47+
--trace print out full stack trace on errors
48+
```
49+
50+
### SEE ALSO
51+
52+
* [zetacored tx authority](zetacored_tx_authority.md) - authority transactions subcommands
53+

docs/cli/zetacored/zetacored_tx_authority_update-policies.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tx authority update-policies
22

3-
Update the policies
3+
Update policies to values provided in the JSON file.
44

55
```
66
zetacored tx authority update-policies [policies-json-file] [flags]

docs/openapi/openapi.swagger.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -56730,6 +56730,14 @@ definitions:
5673056730
ChainInfo contains static information about the chains
5673156731
This structure is used to dynamically update these info on a live network
5673256732
before hardcoding the values in a upgrade
56733+
authorityMsgAddAuthorizationResponse:
56734+
type: object
56735+
description: MsgAddAuthorizationResponse defines the MsgAddAuthorizationResponse service.
56736+
authorityMsgRemoveAuthorizationResponse:
56737+
type: object
56738+
description: |-
56739+
MsgRemoveAuthorizationResponse defines the MsgRemoveAuthorizationResponse
56740+
service.
5673356741
authorityMsgUpdateChainInfoResponse:
5673456742
type: object
5673556743
description: MsgUpdateChainInfoResponse defines the MsgUpdateChainInfoResponse service.
@@ -56758,13 +56766,17 @@ definitions:
5675856766
- groupEmergency
5675956767
- groupOperational
5676056768
- groupAdmin
56769+
- groupEmpty
5676156770
default: groupEmergency
5676256771
description: |-
5676356772
- groupEmergency: Used for emergency situations that require immediate action
5676456773
- groupOperational: Used for operational tasks like changing
5676556774
- groupAdmin: non-sensitive protocol parameters
5676656775

5676756776
Used for administrative tasks like changing sensitive
56777+
- groupEmpty: protocol parameters or moving funds
56778+
56779+
Used for empty policy, no action is allowed
5676856780
title: PolicyType defines the type of policy
5676956781
authorityQueryGetChainInfoResponse:
5677056782
type: object

docs/spec/authority/messages.md

+24
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,27 @@ message MsgUpdateChainInfo {
2323
}
2424
```
2525

26+
## MsgAddAuthorization
27+
28+
AddAuthorization defines a method to add an authorization.If the authorization already exists, it will be overwritten with the provided policy.
29+
This should be called by the admin policy account.
30+
31+
```proto
32+
message MsgAddAuthorization {
33+
string creator = 1;
34+
string msg_url = 2;
35+
PolicyType authorized_policy = 3;
36+
}
37+
```
38+
39+
## MsgRemoveAuthorization
40+
41+
RemoveAuthorization removes the authorization from the list. It should be called by the admin policy account.
42+
43+
```proto
44+
message MsgRemoveAuthorization {
45+
string creator = 1;
46+
string msg_url = 2;
47+
}
48+
```
49+

proto/zetachain/zetacore/authority/policies.proto

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum PolicyType {
1414
// non-sensitive protocol parameters
1515
groupAdmin = 2; // Used for administrative tasks like changing sensitive
1616
// protocol parameters or moving funds
17+
groupEmpty = 3; // Used for empty policy, no action is allowed
1718
}
1819

1920
message Policy {

proto/zetachain/zetacore/authority/tx.proto

+27
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,35 @@ option go_package = "github.com/zeta-chain/zetacore/x/authority/types";
1212
service Msg {
1313
rpc UpdatePolicies(MsgUpdatePolicies) returns (MsgUpdatePoliciesResponse);
1414
rpc UpdateChainInfo(MsgUpdateChainInfo) returns (MsgUpdateChainInfoResponse);
15+
rpc AddAuthorization(MsgAddAuthorization)
16+
returns (MsgAddAuthorizationResponse);
17+
rpc RemoveAuthorization(MsgRemoveAuthorization)
18+
returns (MsgRemoveAuthorizationResponse);
1519
}
1620

21+
// MsgAddAuthorization defines the MsgAddAuthorization service.
22+
// Adds an authorization to the chain. If the authorization already exists, it
23+
// will be updated.
24+
message MsgAddAuthorization {
25+
string creator = 1;
26+
string msg_url = 2;
27+
PolicyType authorized_policy = 3;
28+
}
29+
30+
// MsgAddAuthorizationResponse defines the MsgAddAuthorizationResponse service.
31+
message MsgAddAuthorizationResponse {}
32+
33+
// MsgRemoveAuthorization defines the MsgRemoveAuthorization service.
34+
// Removes an authorization from the chain.
35+
message MsgRemoveAuthorization {
36+
string creator = 1;
37+
string msg_url = 2;
38+
}
39+
40+
// MsgRemoveAuthorizationResponse defines the MsgRemoveAuthorizationResponse
41+
// service.
42+
message MsgRemoveAuthorizationResponse {}
43+
1744
// MsgUpdatePolicies defines the MsgUpdatePolicies service.
1845
message MsgUpdatePolicies {
1946
string creator = 1;

testutil/keeper/authority.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func MockIsAuthorized(m *mock.Mock, address string, policyType types.PolicyType,
7979
m.On("IsAuthorized", mock.Anything, address, policyType).Return(isAuthorized).Once()
8080
}
8181

82-
func SetAdminPolices(ctx sdk.Context, ak *keeper.Keeper) string {
82+
func SetAdminPolicies(ctx sdk.Context, ak *keeper.Keeper) string {
8383
admin := sample.AccAddress()
8484
ak.SetPolicies(ctx, types.Policies{Items: []*types.Policy{
8585
{

typescript/zetachain/zetacore/authority/policies_pb.d.ts

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export declare enum PolicyType {
3434
* @generated from enum value: groupAdmin = 2;
3535
*/
3636
groupAdmin = 2,
37+
38+
/**
39+
* protocol parameters or moving funds
40+
*
41+
* Used for empty policy, no action is allowed
42+
*
43+
* @generated from enum value: groupEmpty = 3;
44+
*/
45+
groupEmpty = 3,
3746
}
3847

3948
/**

typescript/zetachain/zetacore/authority/tx_pb.d.ts

+114-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,122 @@
55

66
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
77
import { Message, proto3 } from "@bufbuild/protobuf";
8-
import type { Policies } from "./policies_pb.js";
8+
import type { Policies, PolicyType } from "./policies_pb.js";
99
import type { ChainInfo } from "./chain_info_pb.js";
1010

11+
/**
12+
* MsgAddAuthorization defines the MsgAddAuthorization service.
13+
* Adds an authorization to the chain. If the authorization already exists, it
14+
* will be updated.
15+
*
16+
* @generated from message zetachain.zetacore.authority.MsgAddAuthorization
17+
*/
18+
export declare class MsgAddAuthorization extends Message<MsgAddAuthorization> {
19+
/**
20+
* @generated from field: string creator = 1;
21+
*/
22+
creator: string;
23+
24+
/**
25+
* @generated from field: string msg_url = 2;
26+
*/
27+
msgUrl: string;
28+
29+
/**
30+
* @generated from field: zetachain.zetacore.authority.PolicyType authorized_policy = 3;
31+
*/
32+
authorizedPolicy: PolicyType;
33+
34+
constructor(data?: PartialMessage<MsgAddAuthorization>);
35+
36+
static readonly runtime: typeof proto3;
37+
static readonly typeName = "zetachain.zetacore.authority.MsgAddAuthorization";
38+
static readonly fields: FieldList;
39+
40+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgAddAuthorization;
41+
42+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgAddAuthorization;
43+
44+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgAddAuthorization;
45+
46+
static equals(a: MsgAddAuthorization | PlainMessage<MsgAddAuthorization> | undefined, b: MsgAddAuthorization | PlainMessage<MsgAddAuthorization> | undefined): boolean;
47+
}
48+
49+
/**
50+
* MsgAddAuthorizationResponse defines the MsgAddAuthorizationResponse service.
51+
*
52+
* @generated from message zetachain.zetacore.authority.MsgAddAuthorizationResponse
53+
*/
54+
export declare class MsgAddAuthorizationResponse extends Message<MsgAddAuthorizationResponse> {
55+
constructor(data?: PartialMessage<MsgAddAuthorizationResponse>);
56+
57+
static readonly runtime: typeof proto3;
58+
static readonly typeName = "zetachain.zetacore.authority.MsgAddAuthorizationResponse";
59+
static readonly fields: FieldList;
60+
61+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgAddAuthorizationResponse;
62+
63+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgAddAuthorizationResponse;
64+
65+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgAddAuthorizationResponse;
66+
67+
static equals(a: MsgAddAuthorizationResponse | PlainMessage<MsgAddAuthorizationResponse> | undefined, b: MsgAddAuthorizationResponse | PlainMessage<MsgAddAuthorizationResponse> | undefined): boolean;
68+
}
69+
70+
/**
71+
* MsgRemoveAuthorization defines the MsgRemoveAuthorization service.
72+
* Removes an authorization from the chain.
73+
*
74+
* @generated from message zetachain.zetacore.authority.MsgRemoveAuthorization
75+
*/
76+
export declare class MsgRemoveAuthorization extends Message<MsgRemoveAuthorization> {
77+
/**
78+
* @generated from field: string creator = 1;
79+
*/
80+
creator: string;
81+
82+
/**
83+
* @generated from field: string msg_url = 2;
84+
*/
85+
msgUrl: string;
86+
87+
constructor(data?: PartialMessage<MsgRemoveAuthorization>);
88+
89+
static readonly runtime: typeof proto3;
90+
static readonly typeName = "zetachain.zetacore.authority.MsgRemoveAuthorization";
91+
static readonly fields: FieldList;
92+
93+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgRemoveAuthorization;
94+
95+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgRemoveAuthorization;
96+
97+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgRemoveAuthorization;
98+
99+
static equals(a: MsgRemoveAuthorization | PlainMessage<MsgRemoveAuthorization> | undefined, b: MsgRemoveAuthorization | PlainMessage<MsgRemoveAuthorization> | undefined): boolean;
100+
}
101+
102+
/**
103+
* MsgRemoveAuthorizationResponse defines the MsgRemoveAuthorizationResponse
104+
* service.
105+
*
106+
* @generated from message zetachain.zetacore.authority.MsgRemoveAuthorizationResponse
107+
*/
108+
export declare class MsgRemoveAuthorizationResponse extends Message<MsgRemoveAuthorizationResponse> {
109+
constructor(data?: PartialMessage<MsgRemoveAuthorizationResponse>);
110+
111+
static readonly runtime: typeof proto3;
112+
static readonly typeName = "zetachain.zetacore.authority.MsgRemoveAuthorizationResponse";
113+
static readonly fields: FieldList;
114+
115+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgRemoveAuthorizationResponse;
116+
117+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgRemoveAuthorizationResponse;
118+
119+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgRemoveAuthorizationResponse;
120+
121+
static equals(a: MsgRemoveAuthorizationResponse | PlainMessage<MsgRemoveAuthorizationResponse> | undefined, b: MsgRemoveAuthorizationResponse | PlainMessage<MsgRemoveAuthorizationResponse> | undefined): boolean;
122+
}
123+
11124
/**
12125
* MsgUpdatePolicies defines the MsgUpdatePolicies service.
13126
*

x/authority/client/cli/tx.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ func GetTxCmd() *cobra.Command {
2020
}
2121

2222
cmd.AddCommand(
23-
CmdUpdatePolices(),
23+
CmdUpdatePolicies(),
2424
CmdUpdateChainInfo(),
25+
CmdAddAuthorization(),
26+
CmdRemoveAuthorization(),
2527
)
2628

2729
return cmd

0 commit comments

Comments
 (0)