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: observer rewards #855

Merged
merged 57 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
27f981b
add proto file for crosschain events
kingpinXD Jul 13, 2023
6a18920
add proto file for observer and emission events
kingpinXD Jul 13, 2023
6aa735f
remove unnecessary print lines
kingpinXD Jul 13, 2023
21c97ed
Merge branch 'develop' into refactor/typed-events
kingpinXD Jul 13, 2023
ea1123f
move node account from x/crosschain to x/observer
kingpinXD Jul 13, 2023
afd5d69
cli tests for observer module
kingpinXD Jul 14, 2023
945b468
resolve conflicts for status.go
kingpinXD Jul 17, 2023
7437fbe
add ignore annotations for gosec
kingpinXD Jul 18, 2023
4560925
add ignore annotations for gosec
kingpinXD Jul 18, 2023
6939020
move permission flags to observer module
kingpinXD Jul 18, 2023
4b631c5
add cli tests for permission_flags
kingpinXD Jul 19, 2023
2cd7092
add last block count
kingpinXD Jul 19, 2023
469bae5
move keygen to observer module
kingpinXD Jul 19, 2023
b29814e
remove extra proto files
kingpinXD Jul 19, 2023
09ee703
modify makefile to remove old types
kingpinXD Jul 19, 2023
054cc1b
fix unit tests for keygen
kingpinXD Jul 19, 2023
253175b
add modifying keygen to Begin Block
kingpinXD Jul 20, 2023
262f65e
add modifying keygen to Begin Block
kingpinXD Jul 20, 2023
b1d03f1
add migrator for node accounts in v6.0.0
kingpinXD Jul 20, 2023
a9f7641
add migrator for keygen and permission flags in v6.0.0
kingpinXD Jul 20, 2023
2a69338
modify consensus version in version map to trigger migration function
kingpinXD Jul 20, 2023
e5b3ce9
add log lines to explain migration
kingpinXD Jul 20, 2023
9782bf1
Set value for last block height count
kingpinXD Jul 20, 2023
c0d104d
add early return if LastBlockHeight count is not found
kingpinXD Jul 20, 2023
1cf887d
reset lasBlock observer count on on change in value
kingpinXD Jul 21, 2023
967e8dd
reset lasBlock observer count on on change in value
kingpinXD Jul 21, 2023
a04ae76
Add grpc query for last observer count
kingpinXD Jul 21, 2023
6e2c6df
rebase develop to merge changes for typed events
kingpinXD Jul 21, 2023
452206c
fix errors due to types in inbound voter
kingpinXD Jul 21, 2023
5c4637e
increment to version 7
kingpinXD Jul 21, 2023
7eadeaf
rebase develop to add blame logic to observer module
kingpinXD Jul 24, 2023
c2c4dab
add emissions test structure
kingpinXD Jul 25, 2023
0eda7fa
add new query for emissions
kingpinXD Jul 25, 2023
db38fc5
add new query for emissions
kingpinXD Jul 25, 2023
70ab971
add withdrawble_emisions.proto
kingpinXD Jul 25, 2023
67b0abe
observer emissions cli test
kingpinXD Jul 26, 2023
9d4de8e
remove test table
kingpinXD Jul 26, 2023
9841742
reduce test to use 20 randomized ballots
kingpinXD Jul 26, 2023
8499d8c
rebased develop
kingpinXD Jul 26, 2023
a136a0e
enable slashing even if all finalized ballots were fake
kingpinXD Jul 31, 2023
425418f
Add comments to explain logic
kingpinXD Jul 31, 2023
13813f0
Merge branch 'develop' into feature/observer-rewards
kingpinXD Jul 31, 2023
e476632
Merge branch 'develop' into feature/observer-rewards
kingpinXD Aug 1, 2023
9dae8c6
generate specs
kingpinXD Aug 1, 2023
8c4fc8a
rebase develop
kingpinXD Aug 1, 2023
ad32324
add creation height to ballot
kingpinXD Aug 1, 2023
6f7159e
modify identifiers to more meaningful names
kingpinXD Aug 8, 2023
3a1a4c3
include code suggestions
kingpinXD Aug 9, 2023
637584c
rebase develop
kingpinXD Aug 9, 2023
aef6b96
Merge branch 'develop' into feature/observer-rewards
lumtis Aug 10, 2023
d0015e4
modify protobuf styles
kingpinXD Aug 10, 2023
0d2dce7
add proto format
kingpinXD Aug 10, 2023
55c3930
update specs to match changes in proto files
kingpinXD Aug 10, 2023
8d11f40
Add proto-format back to the the makefile
kingpinXD Aug 11, 2023
90d9450
rebase develop
kingpinXD Aug 11, 2023
371a017
generate api specs
kingpinXD Aug 11, 2023
6d1dbcb
Merge branch 'develop' into feature/observer-rewards
kingpinXD Aug 14, 2023
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
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

put snake case on this field as well?

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;
kevinssgh marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading