Skip to content

Commit

Permalink
feat: observer rewards (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD authored Aug 14, 2023
1 parent c5f5f58 commit 93fa870
Show file tree
Hide file tree
Showing 72 changed files with 3,745 additions and 746 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ proto:
@find . -name '*.pb.go' -type f -delete
@echo "--> Generating new Go types from protocol buffer files"
@bash ./scripts/protoc-gen-go.sh
@buf format -w
.PHONY: proto

proto-format:
@bash ./scripts/proto-format.sh

openapi:
@echo "--> Generating OpenAPI specs"
@bash ./scripts/protoc-gen-openapi.sh
Expand Down
5 changes: 4 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ func New(
keys[emissionsModuleTypes.MemStoreKey],
app.GetSubspace(emissionsModuleTypes.ModuleName),
authtypes.FeeCollectorName,
app.BankKeeper,
app.StakingKeeper,
app.ZetaObserverKeeper,
)
// Create Ethermint keepers
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
Expand Down Expand Up @@ -461,7 +464,7 @@ func New(
zetaCoreModule.NewAppModule(appCodec, app.ZetaCoreKeeper, app.StakingKeeper),
zetaObserverModule.NewAppModule(appCodec, *app.ZetaObserverKeeper, app.AccountKeeper, app.BankKeeper),
fungibleModule.NewAppModule(appCodec, app.FungibleKeeper, app.AccountKeeper, app.BankKeeper),
emissionsModule.NewAppModule(appCodec, app.EmissionsKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.ZetaObserverKeeper),
emissionsModule.NewAppModule(appCodec, app.EmissionsKeeper, app.AccountKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)

Expand Down
70 changes: 62 additions & 8 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27250,7 +27250,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/observer/get_client_params_for_chain/{chainID}:
/zeta-chain/observer/get_client_params_for_chain/{chain_id}:
get:
summary: Queries a list of GetClientParamsForChain items.
operationId: Query_GetCoreParamsForChain
Expand All @@ -27264,7 +27264,7 @@ paths:
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: chainID
- name: chain_id
in: path
required: true
type: string
Expand Down Expand Up @@ -27443,6 +27443,21 @@ paths:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/zetacore/emissions/get_emmisons_factors:
get:
summary: Queries a list of GetEmmisonsFactors items.
operationId: Query_GetEmmisonsFactors
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/emissionsQueryGetEmmisonsFactorsResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/zetacore/emissions/list_addresses:
get:
summary: Queries a list of ListBalances items.
Expand Down Expand Up @@ -27473,6 +27488,26 @@ paths:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/zetacore/emissions/show_available_emissions/{address}:
get:
summary: Queries a list of ShowAvailableEmissions items.
operationId: Query_ShowAvailableEmissions
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/emissionsQueryShowAvailableEmissionsResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: address
in: path
required: true
type: string
tags:
- Query
/zeta-chain/zetacore/fungible/foreign_coins:
get:
summary: Queries a list of ForeignCoins items.
Expand Down Expand Up @@ -50373,6 +50408,15 @@ definitions:
type: string
tx_signer:
type: string
emissionsQueryGetEmmisonsFactorsResponse:
type: object
properties:
reservesFactor:
type: string
bondFactor:
type: string
durationFactor:
type: string
emissionsQueryListPoolAddressesResponse:
type: object
properties:
Expand All @@ -50382,6 +50426,11 @@ definitions:
type: string
emission_module_address:
type: string
emissionsQueryShowAvailableEmissionsResponse:
type: object
properties:
amount:
type: string
fungibleForeignCoins:
type: object
properties:
Expand Down Expand Up @@ -50642,7 +50691,7 @@ definitions:
observerQueryAllBlameRecordsResponse:
type: object
properties:
blameInfo:
blame_info:
type: array
items:
type: object
Expand All @@ -50668,7 +50717,7 @@ definitions:
observerQueryBallotByIdentifierResponse:
type: object
properties:
BallotIdentifier:
ballot_identifier:
type: string
voters:
type: array
Expand All @@ -50682,7 +50731,7 @@ definitions:
observerQueryBlameByIdentifierResponse:
type: object
properties:
blameInfo:
blame_info:
$ref: '#/definitions/observerBlame'
observerQueryGetCoreParamsForChainResponse:
type: object
Expand All @@ -50697,17 +50746,17 @@ definitions:
observerQueryGetKeygenResponse:
type: object
properties:
Keygen:
keygen:
$ref: '#/definitions/observerKeygen'
observerQueryGetNodeAccountResponse:
type: object
properties:
NodeAccount:
node_account:
$ref: '#/definitions/observerNodeAccount'
observerQueryGetPermissionFlagsResponse:
type: object
properties:
PermissionFlags:
permission_flags:
$ref: '#/definitions/observerPermissionFlags'
observerQueryObserversByChainResponse:
type: object
Expand Down Expand Up @@ -50860,6 +50909,8 @@ definitions:
type: string
duration_factor_constant:
type: string
observer_slash_amount:
type: string
description: Params defines the parameters for the module.
zetacoreemissionsQueryParamsResponse:
type: object
Expand Down Expand Up @@ -50891,6 +50942,9 @@ definitions:
items:
type: object
$ref: '#/definitions/observerAdmin_Policy'
ballot_maturity_blocks:
type: string
format: int64
description: Params defines the parameters for the module.
zetacoreobserverQueryParamsResponse:
type: object
Expand Down
1 change: 0 additions & 1 deletion proto/crosschain/in_tx_hash_to_cctx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ message InTxHashToCctx {
string in_tx_hash = 1;
repeated string cctx_index = 2;
}

2 changes: 1 addition & 1 deletion proto/crosschain/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ message QueryLastZetaHeightResponse {
}

message QueryConvertGasToZetaRequest {
int64 chainId = 1;
int64 chainId = 1;
string gasLimit = 2;
}

Expand Down
20 changes: 20 additions & 0 deletions proto/emissions/events.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
syntax = "proto3";
package zetachain.zetacore.emissions;

import "gogoproto/gogo.proto";

option go_package = "github.com/zeta-chain/zetacore/x/emissions/types";

enum EmissionType {
option (gogoproto.goproto_enum_stringer) = true;
Slash = 0;
Rewards = 1;
}
message ObserverEmission {
EmissionType emission_type = 1;
string observer_address = 2;
string amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message EventObserverEmissions {
string msg_type_url = 1;
repeated ObserverEmission emissions = 2;
}
message EventBlockEmissions {
string msg_type_url = 1;
string bond_factor = 2;
Expand Down
4 changes: 4 additions & 0 deletions proto/emissions/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ message Params {
string observer_emission_percentage = 6;
string tss_signer_emission_percentage = 7;
string duration_factor_constant = 8;
string observer_slash_amount = 9 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
30 changes: 30 additions & 0 deletions proto/emissions/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ service Query {
rpc ListPoolAddresses(QueryListPoolAddressesRequest) returns (QueryListPoolAddressesResponse) {
option (google.api.http).get = "/zeta-chain/zetacore/emissions/list_addresses";
}

// Queries a list of GetEmmisonsFactors items.
rpc GetEmmisonsFactors(QueryGetEmmisonsFactorsRequest) returns (QueryGetEmmisonsFactorsResponse) {
option (google.api.http).get = "/zeta-chain/zetacore/emissions/get_emmisons_factors";
}

// Queries a list of ShowAvailableEmissions items.
rpc ShowAvailableEmissions(QueryShowAvailableEmissionsRequest) returns (QueryShowAvailableEmissionsResponse) {
option (google.api.http).get = "/zeta-chain/zetacore/emissions/show_available_emissions/{address}";
}

// this line is used by starport scaffolding # 2
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand All @@ -36,3 +48,21 @@ message QueryListPoolAddressesResponse {
string undistributed_tss_balances_address = 2;
string emission_module_address = 3;
}

message QueryGetEmmisonsFactorsRequest {}

message QueryGetEmmisonsFactorsResponse {
string reservesFactor = 1;
string bondFactor = 2;
string durationFactor = 3;
}

message QueryShowAvailableEmissionsRequest {
string address = 1;
}

message QueryShowAvailableEmissionsResponse {
string amount = 1;
}

// this line is used by starport scaffolding # 3
3 changes: 1 addition & 2 deletions proto/emissions/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/zeta-chain/zetacore/x/emissions/types";

// Msg defines the Msg service.
service Msg {
}
service Msg {}
14 changes: 14 additions & 0 deletions proto/emissions/withdrawable_emisions.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package zetachain.zetacore.emissions;

import "gogoproto/gogo.proto";

option go_package = "github.com/zeta-chain/zetacore/x/emissions/types";

message WithdrawableEmissions {
string address = 1;
string amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
2 changes: 1 addition & 1 deletion proto/fungible/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ message EventZRC20WithdrawFeeUpdated {
string old_withdraw_fee = 5;
string new_withdraw_fee = 6;
string signer = 7;
}
}
8 changes: 7 additions & 1 deletion proto/observer/ballot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ message Ballot {
repeated string voter_list = 3;
repeated VoteType votes = 4;
ObservationType observation_type = 5;
string BallotThreshold = 6 [
string ballot_threshold = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
BallotStatus ballot_status = 7;
int64 ballot_creation_height = 8;
}

message BallotListForHeight {
int64 height = 1;
repeated string ballots_index_list = 2;
}
8 changes: 4 additions & 4 deletions proto/observer/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ option go_package = "github.com/zeta-chain/zetacore/x/observer/types";

message EventBallotCreated {
string msg_type_url = 1;
string ballot_identifier = 3;
string observation_hash = 4;
string observation_chain = 5;
string ballot_type = 6;
string ballot_identifier = 2;
string observation_hash = 3;
string observation_chain = 4;
string ballot_type = 5;
}

message EventKeygenBlockUpdated {
Expand Down
3 changes: 2 additions & 1 deletion proto/observer/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ message GenesisState {
repeated Ballot ballots = 1;
repeated ObserverMapper observers = 2;
repeated NodeAccount nodeAccountList = 3;
PermissionFlags permissionFlags = 4;
PermissionFlags permission_flags = 4;
Params params = 5;
Keygen keygen = 6;
LastObserverCount last_observer_count = 7;
}
6 changes: 3 additions & 3 deletions proto/observer/keygen.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum KeygenStatus {
KeyGenFailed = 3;
}
message Keygen {
KeygenStatus status = 2; // 0--to generate key; 1--generated; 2--error
repeated string granteePubkeys = 3;
int64 blockNumber = 4; // the blocknum that the key needs to be generated
KeygenStatus status = 1; // 0--to generate key; 1--generated; 2--error
repeated string granteePubkeys = 2;
int64 blockNumber = 3; // the blocknum that the key needs to be generated
}
1 change: 1 addition & 0 deletions proto/observer/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ message Params {
option (gogoproto.goproto_stringer) = false;
repeated ObserverParams observer_params = 1;
repeated Admin_Policy admin_policy = 2;
int64 ballot_maturity_blocks = 3;
}
Loading

0 comments on commit 93fa870

Please sign in to comment.