diff --git a/Makefile b/Makefile index 9ec1c636a..e33ca9da1 100644 --- a/Makefile +++ b/Makefile @@ -182,11 +182,11 @@ build_and_watch: ## Continous build Pocket's main entrypoint as files change # TODO(olshansky): Need to think of a Pocket related name for `compose_and_watch`, maybe just `pocket_watch`? .PHONY: compose_and_watch compose_and_watch: docker_check db_start monitoring_start ## Run a localnet composed of 4 consensus validators w/ hot reload & debugging - ${docker-compose} up --force-recreate validator1 validator2 validator3 validator4 servicer1 fisherman1 + ${docker-compose} up --force-recreate validator1 validator2 validator3 validator4 servicer1 watcher1 .PHONY: rebuild_and_compose_and_watch rebuild_and_compose_and_watch: docker_check db_start monitoring_start ## Rebuilds the container from scratch and launches compose_and_watch - ${docker-compose} up --build --force-recreate validator1 validator2 validator3 validator4 servicer1 fisherman1 + ${docker-compose} up --build --force-recreate validator1 validator2 validator3 validator4 servicer1 watcher1 .PHONY: db_start db_start: docker_check ## Start a detached local postgres and admin instance; compose_and_watch is responsible for instantiating the actual schemas @@ -538,11 +538,11 @@ todo_this_commit: ## List all the TODOs needed to be done in this commit numValidators ?= 4 numServicers ?= 1 numApplications ?= 1 -numFishermen ?= 1 +numWatchers ?= 1 .PHONY: gen_genesis_and_config gen_genesis_and_config: ## Generate the genesis and config files for LocalNet - go run ./build/config/main.go --genPrefix="gen." --numValidators=${numValidators} --numServicers=${numServicers} --numApplications=${numApplications} --numFishermen=${numFishermen} + go run ./build/config/main.go --genPrefix="gen." --numValidators=${numValidators} --numServicers=${numServicers} --numApplications=${numApplications} --numWatchers=${numWatchers} .PHONY: gen_genesis_and_config clear_genesis_and_config: ## Clear the genesis and config files for LocalNet diff --git a/app/client/cli/actor.go b/app/client/cli/actor.go index f215d0291..e79ca2fc3 100644 --- a/app/client/cli/actor.go +++ b/app/client/cli/actor.go @@ -45,7 +45,7 @@ type ( func NewActorCommands() []*cobra.Command { actorCmdDefs := []actorCmdDef{ {"Application", coreTypes.ActorType_ACTOR_TYPE_APP}, - {"Fisherman", coreTypes.ActorType_ACTOR_TYPE_FISH}, + {"Watcher", coreTypes.ActorType_ACTOR_TYPE_WATCHER}, {"Validator", coreTypes.ActorType_ACTOR_TYPE_VAL}, } diff --git a/app/client/cli/query.go b/app/client/cli/query.go index 0552b8c30..1ab992411 100644 --- a/app/client/cli/query.go +++ b/app/client/cli/query.go @@ -203,11 +203,11 @@ func queryHeightCommands() []*cobra.Command { }, }, { - Use: "Fisherman
[--height]", - Short: "Get the fisherman data of an address", - Long: "Queries the node RPC to obtain the fisherman data of the speicifed address at the given (or latest if unspecified) height", + Use: "Watcher
[--height]", + Short: "Get the watcher data of an address", + Long: "Queries the node RPC to obtain the watcher data of the speicifed address at the given (or latest if unspecified) height", Args: cobra.ExactArgs(1), - Aliases: []string{"fisherman"}, + Aliases: []string{"watcher"}, RunE: func(cmd *cobra.Command, args []string) error { client, err := rpc.NewClientWithResponses(flags.RemoteCLIURL) if err != nil { @@ -219,7 +219,7 @@ func queryHeightCommands() []*cobra.Command { Height: height, } - response, err := client.PostV1QueryFisherman(cmd.Context(), body) + response, err := client.PostV1QueryWatcher(cmd.Context(), body) if err != nil { return unableToConnectToRpc(err) } @@ -524,11 +524,11 @@ func queryHeightPaginatedCommands() []*cobra.Command { }, }, { - Use: "Fishermen [--height] [--page] [--per_page]", - Short: "Get all the data of all fishermen", - Long: "Queries the node RPC to obtain the paginated data for all fishermen at the given (or latest if unspecified) height", + Use: "Watchers [--height] [--page] [--per_page]", + Short: "Get all the data of all watchers", + Long: "Queries the node RPC to obtain the paginated data for all watchers at the given (or latest if unspecified) height", Args: cobra.ExactArgs(0), - Aliases: []string{"fishermen"}, + Aliases: []string{"watchers"}, RunE: func(cmd *cobra.Command, args []string) error { client, err := rpc.NewClientWithResponses(flags.RemoteCLIURL) if err != nil { @@ -541,7 +541,7 @@ func queryHeightPaginatedCommands() []*cobra.Command { PerPage: per_page, } - response, err := client.PostV1QueryFishermen(cmd.Context(), body) + response, err := client.PostV1QueryWatchers(cmd.Context(), body) if err != nil { return unableToConnectToRpc(err) } diff --git a/app/client/doc/README.md b/app/client/doc/README.md index 1c60dec46..382452905 100644 --- a/app/client/doc/README.md +++ b/app/client/doc/README.md @@ -18,7 +18,7 @@ Command tree available [here](./commands/client.md) ```bash ├── cli │ ├── account.go # Account subcommand -│ ├── actor.go # Actor (Application, Node, Fisherman, Validator) subcommands +│ ├── actor.go # Actor (Application, Node, Watcher, Validator) subcommands │ ├── cmd.go # main (root) command called by the entrypoint │ ├── debug.go # Debug subcommand │ ├── doc diff --git a/app/client/doc/commands/client.md b/app/client/doc/commands/client.md index 6727def48..059990aab 100644 --- a/app/client/doc/commands/client.md +++ b/app/client/doc/commands/client.md @@ -22,7 +22,7 @@ The CLI is meant to be an user but also a machine friendly way for interacting w * [client Account](client_Account.md) - Account specific commands * [client Application](client_Application.md) - Application actor specific commands * [client Consensus](client_Consensus.md) - Consensus specific commands -* [client Fisherman](client_Fisherman.md) - Fisherman actor specific commands +* [client Watcher](client_Watcher.md) - Watcher actor specific commands * [client Governance](client_Governance.md) - Governance specific commands * [client Keys](client_Keys.md) - Key specific commands * [client Query](client_Query.md) - Commands related to querying on-chain data via the node's RPC server diff --git a/app/client/doc/commands/client_Query.md b/app/client/doc/commands/client_Query.md index db90da21c..9e5565ce9 100644 --- a/app/client/doc/commands/client_Query.md +++ b/app/client/doc/commands/client_Query.md @@ -30,8 +30,8 @@ Commands related to querying on-chain data via the node's RPC server * [client Query Balance](client_Query_Balance.md) - Get the balance of an address * [client Query Block](client_Query_Block.md) - Get the block data * [client Query BlockTxs](client_Query_BlockTxs.md) - Get all the transactions in the block -* [client Query Fisherman](client_Query_Fisherman.md) - Get the fisherman data of an address -* [client Query Fishermen](client_Query_Fishermen.md) - Get all the data of all fishermen +* [client Query Watcher](client_Query_Watcher.md) - Get the watcher data of an address +* [client Query Watchers](client_Query_Watchers.md) - Get all the data of all watchers * [client Query Height](client_Query_Height.md) - Get current block height * [client Query Param](client_Query_Param.md) - Get the value of the parameter * [client Query Servicer](client_Query_Servicer.md) - Get the servicer data of an address diff --git a/app/client/doc/commands/client_Query_Fisherman.md b/app/client/doc/commands/client_Query_Watcher.md similarity index 74% rename from app/client/doc/commands/client_Query_Fisherman.md rename to app/client/doc/commands/client_Query_Watcher.md index fa2339478..c6b223d0b 100644 --- a/app/client/doc/commands/client_Query_Fisherman.md +++ b/app/client/doc/commands/client_Query_Watcher.md @@ -1,20 +1,20 @@ -## client Query Fisherman +## client Query Watcher -Get the fisherman data of an address +Get the watcher data of an address ### Synopsis -Queries the node RPC to obtain the fisherman data of the speicifed address at the given (or latest if unspecified) height +Queries the node RPC to obtain the watcher data of the speicifed address at the given (or latest if unspecified) height ``` -client Query Fisherman
[--height] [flags] +client Query Watcher
[--height] [flags] ``` ### Options ``` --height int block height to query, (default = 0, latest) - -h, --help help for Fisherman + -h, --help help for Watcher ``` ### Options inherited from parent commands diff --git a/app/client/doc/commands/client_Query_Fishermen.md b/app/client/doc/commands/client_Query_Watchers.md similarity index 78% rename from app/client/doc/commands/client_Query_Fishermen.md rename to app/client/doc/commands/client_Query_Watchers.md index 89addedcb..4ea96870f 100644 --- a/app/client/doc/commands/client_Query_Fishermen.md +++ b/app/client/doc/commands/client_Query_Watchers.md @@ -1,20 +1,20 @@ -## client Query Fishermen +## client Query Watchers -Get all the data of all fishermen +Get all the data of all watchers ### Synopsis -Queries the node RPC to obtain the paginated data for all fishermen at the given (or latest if unspecified) height +Queries the node RPC to obtain the paginated data for all watchers at the given (or latest if unspecified) height ``` -client Query Fishermen [--height] [--page] [--per_page] [flags] +client Query Watchers [--height] [--page] [--per_page] [flags] ``` ### Options ``` --height int block height to query, (default = 0, latest) - -h, --help help for Fishermen + -h, --help help for Watchers --page int page number to return of paginated query (default 1) (default 1) --per_page int number of results to show per page in a paginated query (default 1000, max=1000) (default 1000) ``` diff --git a/app/client/doc/commands/client_Fisherman.md b/app/client/doc/commands/client_Watcher.md similarity index 55% rename from app/client/doc/commands/client_Fisherman.md rename to app/client/doc/commands/client_Watcher.md index 0a350fd5e..dd8490efc 100644 --- a/app/client/doc/commands/client_Fisherman.md +++ b/app/client/doc/commands/client_Watcher.md @@ -1,11 +1,11 @@ -## client Fisherman +## client Watcher -Fisherman actor specific commands +Watcher actor specific commands ### Options ``` - -h, --help help for Fisherman + -h, --help help for Watcher ``` ### Options inherited from parent commands @@ -21,9 +21,9 @@ Fisherman actor specific commands ### SEE ALSO * [client](client.md) - Pocket Network Command Line Interface (CLI) -* [client Fisherman EditStake](client_Fisherman_EditStake.md) - EditStake -* [client Fisherman Stake](client_Fisherman_Stake.md) - Stake a Fisherman in the network. Custodial stake uses the same address as operator/output for rewards/return of staked funds. -* [client Fisherman Unpause](client_Fisherman_Unpause.md) - Unpause -* [client Fisherman Unstake](client_Fisherman_Unstake.md) - Unstake +* [client Watcher EditStake](client_Watcher_EditStake.md) - EditStake +* [client Watcher Stake](client_Watcher_Stake.md) - Stake a Watcher in the network. Custodial stake uses the same address as operator/output for rewards/return of staked funds. +* [client Watcher Unpause](client_Watcher_Unpause.md) - Unpause +* [client Watcher Unstake](client_Watcher_Unstake.md) - Unstake ###### Auto generated by spf13/cobra on 4-May-2023 diff --git a/app/client/doc/commands/client_Fisherman_EditStake.md b/app/client/doc/commands/client_Watcher_EditStake.md similarity index 79% rename from app/client/doc/commands/client_Fisherman_EditStake.md rename to app/client/doc/commands/client_Watcher_EditStake.md index 9a5648c31..010e1ca94 100644 --- a/app/client/doc/commands/client_Fisherman_EditStake.md +++ b/app/client/doc/commands/client_Watcher_EditStake.md @@ -1,13 +1,13 @@ -## client Fisherman EditStake +## client Watcher EditStake EditStake ### Synopsis -Stakes a new for the Fisherman actor with address for the specified and . +Stakes a new for the Watcher actor with address for the specified and . ``` -client Fisherman EditStake [flags] +client Watcher EditStake [flags] ``` ### Options @@ -33,6 +33,6 @@ client Fisherman EditStake [fla ### SEE ALSO -* [client Fisherman](client_Fisherman.md) - Fisherman actor specific commands +* [client Watcher](client_Watcher.md) - Watcher actor specific commands ###### Auto generated by spf13/cobra on 4-May-2023 diff --git a/app/client/doc/commands/client_Fisherman_Stake.md b/app/client/doc/commands/client_Watcher_Stake.md similarity index 65% rename from app/client/doc/commands/client_Fisherman_Stake.md rename to app/client/doc/commands/client_Watcher_Stake.md index 2c547df49..9a27f1263 100644 --- a/app/client/doc/commands/client_Fisherman_Stake.md +++ b/app/client/doc/commands/client_Watcher_Stake.md @@ -1,21 +1,21 @@ -## client Fisherman Stake +## client Watcher Stake -Stake a Fisherman in the network. Custodial stake uses the same address as operator/output for rewards/return of staked funds. +Stake a Watcher in the network. Custodial stake uses the same address as operator/output for rewards/return of staked funds. ### Synopsis -Stake the Fisherman into the network, making it available for service. +Stake the Watcher into the network, making it available for service. -Will prompt the user for the *fromAddr* account passphrase. If the Fisherman is already staked, this transaction acts as an *update* transaction. +Will prompt the user for the *fromAddr* account passphrase. If the Watcher is already staked, this transaction acts as an *update* transaction. -A Fisherman can update relayChainIDs, serviceURI, and raise the stake amount with this transaction. +A Watcher can update relayChainIDs, serviceURI, and raise the stake amount with this transaction. -If the Fisherman is currently staked at X and you submit an update with new stake Y. Only Y-X will be subtracted from an account. +If the Watcher is currently staked at X and you submit an update with new stake Y. Only Y-X will be subtracted from an account. If no changes are desired for the parameter, just enter the current param value just as before. ``` -client Fisherman Stake [flags] +client Watcher Stake [flags] ``` ### Options @@ -41,6 +41,6 @@ client Fisherman Stake [flags] ### SEE ALSO -* [client Fisherman](client_Fisherman.md) - Fisherman actor specific commands +* [client Watcher](client_Watcher.md) - Watcher actor specific commands ###### Auto generated by spf13/cobra on 4-May-2023 diff --git a/app/client/doc/commands/client_Fisherman_Unpause.md b/app/client/doc/commands/client_Watcher_Unpause.md similarity index 85% rename from app/client/doc/commands/client_Fisherman_Unpause.md rename to app/client/doc/commands/client_Watcher_Unpause.md index d07a4fb66..79e1c779c 100644 --- a/app/client/doc/commands/client_Fisherman_Unpause.md +++ b/app/client/doc/commands/client_Watcher_Unpause.md @@ -1,13 +1,13 @@ -## client Fisherman Unpause +## client Watcher Unpause Unpause ### Synopsis -Unpauses the Fisherman actor with address +Unpauses the Watcher actor with address ``` -client Fisherman Unpause [flags] +client Watcher Unpause [flags] ``` ### Options @@ -33,6 +33,6 @@ client Fisherman Unpause [flags] ### SEE ALSO -* [client Fisherman](client_Fisherman.md) - Fisherman actor specific commands +* [client Watcher](client_Watcher.md) - Watcher actor specific commands ###### Auto generated by spf13/cobra on 4-May-2023 diff --git a/app/client/doc/commands/client_Fisherman_Unstake.md b/app/client/doc/commands/client_Watcher_Unstake.md similarity index 83% rename from app/client/doc/commands/client_Fisherman_Unstake.md rename to app/client/doc/commands/client_Watcher_Unstake.md index 9ccd0dd19..c7288bb9e 100644 --- a/app/client/doc/commands/client_Fisherman_Unstake.md +++ b/app/client/doc/commands/client_Watcher_Unstake.md @@ -1,13 +1,13 @@ -## client Fisherman Unstake +## client Watcher Unstake Unstake ### Synopsis -Unstakes the previously staked tokens for the Fisherman actor with address +Unstakes the previously staked tokens for the Watcher actor with address ``` -client Fisherman Unstake [flags] +client Watcher Unstake [flags] ``` ### Options @@ -33,6 +33,6 @@ client Fisherman Unstake [flags] ### SEE ALSO -* [client Fisherman](client_Fisherman.md) - Fisherman actor specific commands +* [client Watcher](client_Watcher.md) - Watcher actor specific commands ###### Auto generated by spf13/cobra on 4-May-2023 diff --git a/build/config/README.md b/build/config/README.md index 24d8d110c..ecf8dd460 100644 --- a/build/config/README.md +++ b/build/config/README.md @@ -23,7 +23,7 @@ The output files are written to `./build/config/`. From the project's root: ```bash -go run ./build/config/main.go --numFishermen=1 +go run ./build/config/main.go --numWatchers=1 ``` ### Using Make Target @@ -37,7 +37,7 @@ make numValidators=5 numServicers=1 gen_genesis_and_config - `numValidators` is an int flag that sets the number of validators that will be in the network; this affects the contents of the genesis file as well as the number of config files - `numServicers` is an int flag that set the number of servicers that will be in the network's genesis file - `numApplications` is an int flag that set the number of applications that will be in the network's genesis file -- `numFishermen` is an int flag that set the number of fishermen that will be in the network's genesis file +- `numWatchers` is an int flag that set the number of watchers that will be in the network's genesis file - `genPrefix` is a string flag that adds a prefix to the generated files; is an empty string by default ## **WIP NOTE** diff --git a/build/config/config.fisherman1.json b/build/config/config.watcher1.json similarity index 95% rename from build/config/config.fisherman1.json rename to build/config/config.watcher1.json index ea20cff45..edc712172 100644 --- a/build/config/config.fisherman1.json +++ b/build/config/config.watcher1.json @@ -17,7 +17,7 @@ }, "persistence": { "postgres_url": "postgres://postgres:postgres@pocket-db:5432/postgres", - "node_schema": "fisherman1", + "node_schema": "watcher1", "block_store_path": "/var/blockstore", "tx_indexer_path": "/var/txindexer", "trees_store_dir": "/var/trees", @@ -28,7 +28,7 @@ "health_check_period": "30s" }, "p2p": { - "hostname": "fisherman1", + "hostname": "watcher1", "port": 42069, "use_rain_tree": true, "is_empty_connection_type": false, @@ -50,7 +50,7 @@ "timeout": 30000, "use_cors": false }, - "fisherman": { + "watcher": { "enabled": true } } diff --git a/build/config/genesis.json b/build/config/genesis.json index 1c8dd19f5..7e28acdc6 100755 --- a/build/config/genesis.json +++ b/build/config/genesis.json @@ -1600,7 +1600,7 @@ } ], "chain_id": "testnet", - "fishermen": [ + "watchers": [ { "actor_type": 3, "address": "0010336c3a2cc1ec71fecc45c360214f757194aa", @@ -1610,7 +1610,7 @@ "output": "0010336c3a2cc1ec71fecc45c360214f757194aa", "paused_height": -1, "public_key": "d913a05a6f4bde35413bdcc6343238960cfc7d8aff425fb712dcaa52f1476dbf", - "service_url": "fisherman1:42069", + "service_url": "watcher1:42069", "staked_amount": "1000000000000", "unstaking_height": -1 } @@ -1638,36 +1638,36 @@ "blocks_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "double_sign_burn_percentage": 5, "double_sign_burn_percentage_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_max_chains": 15, - "fisherman_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_max_pause_blocks": 672, - "fisherman_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_minimum_pause_blocks": 4, - "fisherman_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_minimum_stake": "15000000000", - "fisherman_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_per_session": 1, - "fisherman_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_unstaking_blocks": 2016, - "fisherman_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_max_chains": 15, + "watcher_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_max_pause_blocks": 672, + "watcher_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_minimum_pause_blocks": 4, + "watcher_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_minimum_stake": "15000000000", + "watcher_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_per_session": 1, + "watcher_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_unstaking_blocks": 2016, + "watcher_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_change_parameter_fee": "10000", "message_change_parameter_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_double_sign_fee": "10000", "message_double_sign_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_edit_stake_app_fee": "10000", "message_edit_stake_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_edit_stake_fisherman_fee": "10000", - "message_edit_stake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_edit_stake_watcher_fee": "10000", + "message_edit_stake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_edit_stake_servicer_fee": "10000", "message_edit_stake_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_edit_stake_validator_fee": "10000", "message_edit_stake_validator_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_fisherman_pause_servicer_fee": "10000", - "message_fisherman_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_watcher_pause_servicer_fee": "10000", + "message_watcher_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_pause_app_fee": "10000", "message_pause_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_pause_fisherman_fee": "10000", - "message_pause_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_pause_watcher_fee": "10000", + "message_pause_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_pause_servicer_fee": "10000", "message_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_pause_validator_fee": "10000", @@ -1678,8 +1678,8 @@ "message_send_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_stake_app_fee": "10000", "message_stake_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_stake_fisherman_fee": "10000", - "message_stake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_stake_watcher_fee": "10000", + "message_stake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_stake_servicer_fee": "10000", "message_stake_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_stake_validator_fee": "10000", @@ -1688,16 +1688,16 @@ "message_test_score_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_unpause_app_fee": "10000", "message_unpause_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_unpause_fisherman_fee": "10000", - "message_unpause_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_unpause_watcher_fee": "10000", + "message_unpause_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_unpause_servicer_fee": "10000", "message_unpause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_unpause_validator_fee": "10000", "message_unpause_validator_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_unstake_app_fee": "10000", "message_unstake_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_unstake_fisherman_fee": "10000", - "message_unstake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_unstake_watcher_fee": "10000", + "message_unstake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_unstake_servicer_fee": "10000", "message_unstake_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_unstake_validator_fee": "10000", @@ -1753,7 +1753,7 @@ "amount": "100000000000000" }, { - "address": "4669736865726d616e5374616b65506f6f6c0000", + "address": "576174636865725374616b65506f6f6c00000000", "amount": "100000000000000" } ], diff --git a/build/config/main.go b/build/config/main.go index d51fa6340..29accccb5 100644 --- a/build/config/main.go +++ b/build/config/main.go @@ -21,7 +21,7 @@ var ( numValidators = flag.Int("numValidators", 4, "number of validators that will be in the network; this affects the contents of the genesis file as well as the # of config files") numServicers = flag.Int("numServicers", 1, "number of servicers that will be in the network's genesis file") numApplications = flag.Int("numApplications", 1, "number of applications that will be in the network's genesis file") - numFishermen = flag.Int("numFishermen", 1, "number of fishermen that will be in the network's genesis file") + numWatchers = flag.Int("numWatchers", 1, "number of watchers that will be in the network's genesis file") genPrefix = flag.String("genPrefix", "", "the prefix, if any, to append to the genesis and config files") ) @@ -30,7 +30,7 @@ func init() { } func main() { - genesis, validatorPrivateKeys := test_artifacts.NewGenesisState(*numValidators, *numServicers, *numFishermen, *numApplications) + genesis, validatorPrivateKeys := test_artifacts.NewGenesisState(*numValidators, *numServicers, *numWatchers, *numApplications) configs := test_artifacts.NewDefaultConfigs(validatorPrivateKeys) genesisJson, err := json.MarshalIndent(genesis, "", " ") if err != nil { diff --git a/build/debug_keybase/8b7cc7e70ff0cabc68abd1e691a6a047.md5 b/build/debug_keybase/3c361affa531966b2040447069af51f5.md5 similarity index 100% rename from build/debug_keybase/8b7cc7e70ff0cabc68abd1e691a6a047.md5 rename to build/debug_keybase/3c361affa531966b2040447069af51f5.md5 diff --git a/build/debug_keybase/debug_keybase.bak b/build/debug_keybase/debug_keybase.bak index 804d264e0..2dea72465 100644 Binary files a/build/debug_keybase/debug_keybase.bak and b/build/debug_keybase/debug_keybase.bak differ diff --git a/build/deployments/.env.example b/build/deployments/.env.example index 6bcd95ace..de7016fb9 100644 --- a/build/deployments/.env.example +++ b/build/deployments/.env.example @@ -19,10 +19,10 @@ # SERVICER1_RPC_PORT:-0.0.0.0:50836 # SERVICER1_SERVICER_ENABLED=true -# FISHERMAN1_DEBUG_PORT:-0.0.0.0:7085 -# FISHERMAN1_P2P_PORT:-0.0.0.0:42074 -# FISHERMAN1_RPC_PORT:-0.0.0.0:50836 -# FISHERMAN1_FISHERMAN_ENABLED=true +# WATCHER1_DEBUG_PORT:-0.0.0.0:7085 +# WATCHER1_P2P_PORT:-0.0.0.0:42074 +# WATCHER1_RPC_PORT:-0.0.0.0:50836 +# WATCHER1_WATCHER_ENABLED=true # GRAFANA_PORT_3000=127.0.0.1:3000 # POSTGRES_PORT_5432=127.0.0.1:5432 diff --git a/build/deployments/docker-compose.yaml b/build/deployments/docker-compose.yaml index 366967711..1d7ad2cbd 100755 --- a/build/deployments/docker-compose.yaml +++ b/build/deployments/docker-compose.yaml @@ -172,18 +172,18 @@ services: # Uncomment to enable DLV debugging # - DEBUG_PORT=7085 - fisherman1: + watcher1: logging: *loki-logging - container_name: fisherman1 - image: pocket/fisherman:latest + container_name: watcher1 + image: pocket/watcher:latest command: > sh -c ' - if [ "$FISHERMAN1_FISHERMAN_ENABLED" = "true" ]; then + if [ "$WATCHER1_WATCHER_ENABLED" = "true" ]; then build/scripts/watch.sh \ - build/config/config.fisherman1.json \ + build/config/config.watcher1.json \ build/config/genesis.json; else - echo "😴 Going to sleep. Fisherman is not enabled."; + echo "😴 Going to sleep. Watcher is not enabled."; fi' build: context: ../.. @@ -194,9 +194,9 @@ services: - "9000" - "50832" ports: - - "${FISHERMAN1_DEBUG_PORT:-0.0.0.0:7086}:7086" - - "${FISHERMAN1_P2P_PORT:-0.0.0.0:42075}:42069" - - "${FISHERMAN1_RPC_PORT:-0.0.0.0:50837}:50832" + - "${WATCHER1_DEBUG_PORT:-0.0.0.0:7086}:7086" + - "${WATCHER1_P2P_PORT:-0.0.0.0:42075}:42069" + - "${WATCHER1_RPC_PORT:-0.0.0.0:50837}:50832" volumes: - ${PWD}:/go/src/github.com/pocket-network # Needed for DLV debugging diff --git a/build/localnet/README.md b/build/localnet/README.md index ae52c319a..e05fb4cf4 100644 --- a/build/localnet/README.md +++ b/build/localnet/README.md @@ -139,13 +139,13 @@ The current mapping for `XX` is: - `01` - Application - `02` - Servicer -- `03` - Fisherman +- `03` - Watcher - `04` - Validator For example: - `420043b854e78f2d5f03895bba9ef16972913320` is a validator #420. -- `66603bc4082281b7de23001ffd237da62c66a839` is a fisherperson #666. +- `66603bc4082281b7de23001ffd237da62c66a839` is a watcher #666. - `0010297b55fc9278e4be4f1bcfe52bf9bd0443f8` is a servicer #001. - `314019dbb7faf8390c1f0cf4976ef1215c90b7e4` is an application #314. @@ -180,7 +180,7 @@ You may also create a overrides YAML file in the `charts/pocket` directory and o Override files supported: -- pocket-fisherman-overrides.yaml +- pocket-watcher-overrides.yaml - pocket-servicer-overrides.yaml - pocket-validator-overrides.yaml diff --git a/build/localnet/Tiltfile b/build/localnet/Tiltfile index a88a3d8d5..bb64942c4 100644 --- a/build/localnet/Tiltfile +++ b/build/localnet/Tiltfile @@ -12,7 +12,7 @@ localnet_config_path = root_dir + "/localnet_config.yaml" localnet_config_defaults = { "validators": {"count": 4}, "servicers": {"count": 1}, - "fishermen": {"count": 1}, + "watchers": {"count": 1}, "full_nodes": {"count": 1} } @@ -224,18 +224,18 @@ for x in range(localnet_config["servicers"]["count"]): k8s_resource("servicer-%s-pocket" % formatted_number, labels=['pocket-servicers']) -# Provisions fishermen nodes +# Provisions watchers nodes actor_number = 0 -for x in range(localnet_config["fishermen"]["count"]): +for x in range(localnet_config["watchers"]["count"]): actor_number = actor_number + 1 formatted_number = formatted_actor_number(actor_number) k8s_yaml(helm(chart_dir, - name="fisherman-%s-pocket" % formatted_number, + name="watcher-%s-pocket" % formatted_number, set=[ "global.postgresql.auth.postgresPassword=LocalNetPassword", "image.repository=pocket-image", - "privateKeySecretKeyRef.name=fishermen-private-keys", + "privateKeySecretKeyRef.name=watchers-private-keys", "privateKeySecretKeyRef.key=%s" % formatted_number, "genesis.preProvisionedGenesis.enabled=false", "genesis.externalConfigMap.name=v1-localnet-genesis", @@ -243,12 +243,12 @@ for x in range(localnet_config["fishermen"]["count"]): "postgresql.primary.persistence.enabled=false", "podAnnotations.prometheus\\.io/scrape=true", "podAnnotations.prometheus\\.io/port=9000", - "config.fisherman.enabled=true", - "nodeType=fisherman", + "config.watcher.enabled=true", + "nodeType=watcher", ], - values=[chart_dir + "/pocket-fisherman-overrides.yaml"] if os.path.exists(chart_dir + "/pocket-fisherman-overrides.yaml") else [],)) + values=[chart_dir + "/pocket-watcher-overrides.yaml"] if os.path.exists(chart_dir + "/pocket-watcher-overrides.yaml") else [],)) - k8s_resource("fisherman-%s-pocket" % formatted_number, labels=['pocket-fishermen']) + k8s_resource("watcher-%s-pocket" % formatted_number, labels=['pocket-watchers']) # Provisions full nodes actor_number = 0 diff --git a/build/localnet/manifests/configs.yaml b/build/localnet/manifests/configs.yaml index da8a091e7..ec5e8ae75 100644 --- a/build/localnet/manifests/configs.yaml +++ b/build/localnet/manifests/configs.yaml @@ -1611,7 +1611,7 @@ data: "amount": "100000000000000" }, { - "address": "4669736865726d616e5374616b65506f6f6c0000", + "address": "576174636865725374616b65506f6f6c00000000", "amount": "100000000000000" } ], @@ -1718,12 +1718,12 @@ data: "actor_type": 2 } ], - "fishermen": [ + "watchers": [ { "address": "0010336c3a2cc1ec71fecc45c360214f757194aa", "public_key": "d913a05a6f4bde35413bdcc6343238960cfc7d8aff425fb712dcaa52f1476dbf", "chains": ["0001"], - "service_url": "fisherman-001-pocket:42069", + "service_url": "watcher-001-pocket:42069", "staked_amount": "1000000000000", "paused_height": -1, "unstaking_height": -1, @@ -1745,12 +1745,12 @@ data: "servicer_minimum_pause_blocks": 4, "servicer_max_pause_blocks": 672, "servicers_per_session": 24, - "fisherman_minimum_stake": "15000000000", - "fisherman_max_chains": 15, - "fisherman_unstaking_blocks": 2016, - "fisherman_minimum_pause_blocks": 4, - "fisherman_max_pause_blocks": 672, - "fisherman_per_session": 1, + "watcher_minimum_stake": "15000000000", + "watcher_max_chains": 15, + "watcher_unstaking_blocks": 2016, + "watcher_minimum_pause_blocks": 4, + "watcher_max_pause_blocks": 672, + "watcher_per_session": 1, "validator_minimum_stake": "15000000000", "validator_unstaking_blocks": 2016, "validator_minimum_pause_blocks": 4, @@ -1762,12 +1762,12 @@ data: "double_sign_burn_percentage": 5, "message_double_sign_fee": "10000", "message_send_fee": "10000", - "message_stake_fisherman_fee": "10000", - "message_edit_stake_fisherman_fee": "10000", - "message_unstake_fisherman_fee": "10000", - "message_pause_fisherman_fee": "10000", - "message_unpause_fisherman_fee": "10000", - "message_fisherman_pause_servicer_fee": "10000", + "message_stake_watcher_fee": "10000", + "message_edit_stake_watcher_fee": "10000", + "message_unstake_watcher_fee": "10000", + "message_pause_watcher_fee": "10000", + "message_unpause_watcher_fee": "10000", + "message_watcher_pause_servicer_fee": "10000", "message_test_score_fee": "10000", "message_prove_test_score_fee": "10000", "message_stake_app_fee": "10000", @@ -1800,12 +1800,12 @@ data: "servicer_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "servicer_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "servicers_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "validator_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "validator_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "validator_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", @@ -1817,12 +1817,12 @@ data: "double_sign_burn_percentage_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_double_sign_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_send_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_stake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_edit_stake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_unstake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_pause_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_unpause_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_fisherman_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_stake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_edit_stake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_unstake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_pause_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_unpause_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_watcher_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_test_score_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_prove_test_score_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_stake_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", diff --git a/build/localnet/manifests/network.yaml b/build/localnet/manifests/network.yaml index 6748a7465..c9b682e83 100644 --- a/build/localnet/manifests/network.yaml +++ b/build/localnet/manifests/network.yaml @@ -38,13 +38,13 @@ spec: apiVersion: v1 kind: Service metadata: - name: pocket-fishermen + name: pocket-watchers annotations: prometheus.io/scrape: "false" prometheus.io/port: "9000" spec: selector: - pokt.network/purpose: fisherman + pokt.network/purpose: watcher ports: - port: 50832 targetPort: 50832 diff --git a/build/localnet/manifests/private-keys.yaml b/build/localnet/manifests/private-keys.yaml index 365dcd893..1e14339cf 100644 --- a/build/localnet/manifests/private-keys.yaml +++ b/build/localnet/manifests/private-keys.yaml @@ -4040,7 +4040,7 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: fishermen-private-keys + name: watchers-private-keys type: Opaque stringData: "000": 4a3334ccda886924cc3bc6bbf1f543d206b3defe7edcaee1f385c4103d05672e5641512f469e48c21c56c0052643357cf324c55a1a09b18dd543fc4b506a5ffe # 0000389effc7ee0228526847bb5eaced48adc2f4 (5641512f469e48c21c56c0052643357cf324c55a1a09b18dd543fc4b506a5ffe) diff --git a/charts/pocket/README.md b/charts/pocket/README.md index bbac55a3d..29edaa3ec 100644 --- a/charts/pocket/README.md +++ b/charts/pocket/README.md @@ -43,7 +43,7 @@ privateKeySecretKeyRef: | config.consensus.pacemaker_config.manual | bool | `true` | | | config.consensus.pacemaker_config.timeout_msec | int | `10000` | | | config.consensus.private_key | string | `""` | | -| config.fisherman.enabled | bool | `false` | | +| config.watcher.enabled | bool | `false` | | | config.ibc.enabled | bool | `true` | | | config.ibc.host.private_key | string | `""` | | | config.ibc.stores_dir | string | `"/pocket/data/ibc"` | | @@ -105,7 +105,7 @@ privateKeySecretKeyRef: | ingress.tls | list | `[]` | | | nameOverride | string | `""` | | | nodeSelector | object | `{}` | | -| nodeType | string | `"full"` | type of the blockchain node to run. Can be either `full`, `validator`, `servicer`, `fishermen` | +| nodeType | string | `"full"` | type of the blockchain node to run. Can be either `full`, `validator`, `servicer`, `watchers` | | persistence.accessModes | list | `["ReadWriteOnce"]` | persistent Volume Access Modes | | persistence.annotations | object | `{}` | annotations of the persistent volume claim | | persistence.dataSource | object | `{}` | custom data source of the persistent volume claim | diff --git a/charts/pocket/templates/configmap-genesis.yaml b/charts/pocket/templates/configmap-genesis.yaml index 29705e497..70c92876b 100644 --- a/charts/pocket/templates/configmap-genesis.yaml +++ b/charts/pocket/templates/configmap-genesis.yaml @@ -1617,7 +1617,7 @@ data: "amount": "100000000000000" }, { - "address": "4669736865726d616e5374616b65506f6f6c0000", + "address": "576174636865725374616b65506f6f6c00000000", "amount": "100000000000000" } ], @@ -1724,12 +1724,12 @@ data: "actor_type": 2 } ], - "fishermen": [ + "watchers": [ { "address": "0010336c3a2cc1ec71fecc45c360214f757194aa", "public_key": "d913a05a6f4bde35413bdcc6343238960cfc7d8aff425fb712dcaa52f1476dbf", "chains": ["0001"], - "service_url": "fisherman-001-pocket:42069", + "service_url": "watcher-001-pocket:42069", "staked_amount": "1000000000000", "paused_height": -1, "unstaking_height": -1, @@ -1751,12 +1751,12 @@ data: "servicer_minimum_pause_blocks": 4, "servicer_max_pause_blocks": 672, "servicers_per_session": 24, - "fisherman_minimum_stake": "15000000000", - "fisherman_max_chains": 15, - "fisherman_unstaking_blocks": 2016, - "fisherman_minimum_pause_blocks": 4, - "fisherman_max_pause_blocks": 672, - "fisherman_per_session": 1, + "watcher_minimum_stake": "15000000000", + "watcher_max_chains": 15, + "watcher_unstaking_blocks": 2016, + "watcher_minimum_pause_blocks": 4, + "watcher_max_pause_blocks": 672, + "watcher_per_session": 1, "validator_minimum_stake": "15000000000", "validator_unstaking_blocks": 2016, "validator_minimum_pause_blocks": 4, @@ -1768,12 +1768,12 @@ data: "double_sign_burn_percentage": 5, "message_double_sign_fee": "10000", "message_send_fee": "10000", - "message_stake_fisherman_fee": "10000", - "message_edit_stake_fisherman_fee": "10000", - "message_unstake_fisherman_fee": "10000", - "message_pause_fisherman_fee": "10000", - "message_unpause_fisherman_fee": "10000", - "message_fisherman_pause_servicer_fee": "10000", + "message_stake_watcher_fee": "10000", + "message_edit_stake_watcher_fee": "10000", + "message_unstake_watcher_fee": "10000", + "message_pause_watcher_fee": "10000", + "message_unpause_watcher_fee": "10000", + "message_watcher_pause_servicer_fee": "10000", "message_test_score_fee": "10000", "message_prove_test_score_fee": "10000", "message_stake_app_fee": "10000", @@ -1806,12 +1806,12 @@ data: "servicer_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "servicer_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "servicers_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "fisherman_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_max_chains_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_max_paused_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "watcher_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "validator_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "validator_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "validator_minimum_pause_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45", @@ -1823,12 +1823,12 @@ data: "double_sign_burn_percentage_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_double_sign_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_send_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_stake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_edit_stake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_unstake_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_pause_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_unpause_fisherman_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", - "message_fisherman_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_stake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_edit_stake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_unstake_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_pause_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_unpause_watcher_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", + "message_watcher_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_test_score_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_prove_test_score_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", "message_stake_app_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45", diff --git a/charts/pocket/values.yaml b/charts/pocket/values.yaml index 9587814c7..265b9ac85 100644 --- a/charts/pocket/values.yaml +++ b/charts/pocket/values.yaml @@ -61,7 +61,7 @@ persistence: # -- custom data source of the persistent volume claim dataSource: {} -# -- type of the blockchain node to run. Can be either `full`, `validator`, `servicer`, `fishermen` +# -- type of the blockchain node to run. Can be either `full`, `validator`, `servicer`, `watchers` nodeType: "full" privateKeySecretKeyRef: @@ -117,7 +117,7 @@ config: enabled: true servicer: enabled: false - fisherman: + watcher: enabled: false ibc: enabled: true diff --git a/consensus/e2e_tests/utils_test.go b/consensus/e2e_tests/utils_test.go index fef2fbc00..b71ae7894 100644 --- a/consensus/e2e_tests/utils_test.go +++ b/consensus/e2e_tests/utils_test.go @@ -445,7 +445,7 @@ func basePersistenceMock(t *testing.T, _ modules.EventsChannel, bus modules.Bus) return testutil.Concatenate[*coreTypes.Actor]( genesisState.Validators, genesisState.Servicers, - genesisState.Fishermen, + genesisState.Watchers, genesisState.Applications, ), nil }). diff --git a/ibc/main_test.go b/ibc/main_test.go index 51fa0c63f..6ff9757b9 100644 --- a/ibc/main_test.go +++ b/ibc/main_test.go @@ -97,13 +97,13 @@ func prepareEnvironment( numValidators, // nolint:unparam // we are not currently modifying parameter but want to keep it modifiable in the future numServicers, numApplications, - numFisherman int, + numWatcher int, genesisOpts ...test_artifacts.GenesisOption, ) (*runtime.Manager, modules.ConsensusModule, modules.UtilityModule, modules.PersistenceModule, modules.IBCModule) { t.Helper() teardownDeterministicKeygen := keygen.GetInstance().SetSeed(42) - runtimeCfg := newTestRuntimeConfig(t, numValidators, numServicers, numApplications, numFisherman, genesisOpts...) + runtimeCfg := newTestRuntimeConfig(t, numValidators, numServicers, numApplications, numWatcher, genesisOpts...) bus, err := runtime.CreateBus(runtimeCfg) require.NoError(t, err) @@ -162,7 +162,7 @@ func newTestRuntimeConfig( numValidators, numServicers, numApplications, - numFisherman int, + numWatcher int, genesisOpts ...test_artifacts.GenesisOption, ) *runtime.Manager { t.Helper() @@ -210,7 +210,7 @@ func newTestRuntimeConfig( numValidators, numServicers, numApplications, - numFisherman, + numWatcher, genesisOpts..., ) runtimeCfg := runtime.NewManager(cfg, genesisState) diff --git a/p2p/utils_test.go b/p2p/utils_test.go index bebab237f..b2bb9a9fe 100644 --- a/p2p/utils_test.go +++ b/p2p/utils_test.go @@ -329,7 +329,7 @@ func preparePersistenceMock(t *testing.T, busMock *mockModules.MockBus, genesisS return testutil.Concatenate[*coreTypes.Actor]( genesisState.GetValidators(), genesisState.GetServicers(), - genesisState.GetFishermen(), + genesisState.GetWatchers(), genesisState.GetApplications(), ), nil }).AnyTimes() diff --git a/persistence/actor.go b/persistence/actor.go index e2ff160b9..eb0acc999 100644 --- a/persistence/actor.go +++ b/persistence/actor.go @@ -14,8 +14,8 @@ func (p *PostgresContext) GetActor(actorType coreTypes.ActorType, address []byte schema = types.ApplicationActor case types.ServicerActor.GetActorType(): schema = types.ServicerActor - case types.FishermanActor.GetActorType(): - schema = types.FishermanActor + case types.WatcherActor.GetActorType(): + schema = types.WatcherActor case types.ValidatorActor.GetActorType(): schema = types.ValidatorActor default: @@ -124,16 +124,16 @@ func (p *PostgresContext) GetAllServicers(height int64) (sn []*coreTypes.Actor, return } -func (p *PostgresContext) GetAllFishermen(height int64) (f []*coreTypes.Actor, err error) { +func (p *PostgresContext) GetAllWatchers(height int64) (f []*coreTypes.Actor, err error) { ctx, tx := p.getCtxAndTx() - rows, err := tx.Query(ctx, types.FishermanActor.GetAllQuery(height)) + rows, err := tx.Query(ctx, types.WatcherActor.GetAllQuery(height)) if err != nil { return nil, err } var actors []*coreTypes.Actor for rows.Next() { var actor *coreTypes.Actor - actor, height, err = p.getActorFromRow(types.FishermanActor.GetActorType(), rows) + actor, height, err = p.getActorFromRow(types.WatcherActor.GetActorType(), rows) if err != nil { return } @@ -141,7 +141,7 @@ func (p *PostgresContext) GetAllFishermen(height int64) (f []*coreTypes.Actor, e } rows.Close() for _, actor := range actors { - actor, err = p.getChainsForActor(ctx, tx, types.FishermanActor, actor, height) + actor, err = p.getChainsForActor(ctx, tx, types.WatcherActor, actor, height) if err != nil { return } @@ -153,7 +153,7 @@ func (p *PostgresContext) GetAllFishermen(height int64) (f []*coreTypes.Actor, e // OPTIMIZE: There is an opportunity to have one SQL query returning all the actorsp func (p *PostgresContext) GetAllStakedActors(height int64) (allActors []*coreTypes.Actor, err error) { type actorGetter func(height int64) ([]*coreTypes.Actor, error) - actorGetters := []actorGetter{p.GetAllValidators, p.GetAllServicers, p.GetAllFishermen, p.GetAllApps} + actorGetters := []actorGetter{p.GetAllValidators, p.GetAllServicers, p.GetAllWatchers, p.GetAllApps} for _, actorGetter := range actorGetters { var actors []*coreTypes.Actor actors, err = actorGetter(height) diff --git a/persistence/db.go b/persistence/db.go index 73e64cada..ef898545b 100644 --- a/persistence/db.go +++ b/persistence/db.go @@ -32,7 +32,7 @@ const ( // TODO: Move schema related functionality into its own package var protocolActorSchemas = []types.ProtocolActorSchema{ types.ApplicationActor, - types.FishermanActor, + types.WatcherActor, types.ServicerActor, types.ValidatorActor, } diff --git a/persistence/docs/PROTOCOL_STATE_HASH.md b/persistence/docs/PROTOCOL_STATE_HASH.md index d98040ccc..184eb3d59 100644 --- a/persistence/docs/PROTOCOL_STATE_HASH.md +++ b/persistence/docs/PROTOCOL_STATE_HASH.md @@ -27,7 +27,7 @@ This document defines how Pocket V1 takes a snapshot of its world state. An intr | Component | Data Type | Implementation Options - Examples | Implementation Selected - Current | Example | Use Case | | --------------------- | ------------------------------------- | ------------------------------------------------------ | ----------------------------------- | ------------------- | -------------------------------------------------------------------------------- | | Data Tables | SQL Database / Engine | MySQL, SQLite, PostgreSQL | PostgresSQL | Validator SQL Table | Validating & updating information when applying a transaction | -| Merkle Trees | Merkle Trie backed by Key-Value Store | Celestia's SMT, Libra's JMT, Cosmos' IAVL, Verkle Tree | Pocket's SMT (Forked from Celestia) | Fisherman Trie | Maintains the state of all account based trees | +| Merkle Trees | Merkle Trie backed by Key-Value Store | Celestia's SMT, Libra's JMT, Cosmos' IAVL, Verkle Tree | Pocket's SMT (Forked from Celestia) | Watcher Trie | Maintains the state of all account based trees | | Blocks | Serialization Codec | Amino, Protobuf, Thrift, Avro | Protobuf | Block protobuf | Serialized and inserted into the Block Store | | Objects (e.g. Actors) | Serialization Codec | Amino, Protobuf, Thrift, Avro | Protobuf | Servicer protobuf | Serialized and inserted into the corresponding Tree | | Block Store | Key Value Store | LevelDB, BadgerDB, RocksDB, BoltDB | BadgerDb | Block Store | Maintains a key-value store of the blockchain blocks | @@ -45,7 +45,7 @@ An individual Merkle Tree is created for each type of actor, record or data type - Applications - Validators -- Fisherman +- Watcher - Servicers **Account Merkle Trees**: diff --git a/persistence/docs/README.md b/persistence/docs/README.md index d29b5fab0..ec6c40ce3 100644 --- a/persistence/docs/README.md +++ b/persistence/docs/README.md @@ -56,7 +56,7 @@ persistence # Directly contains the persistence module interface for eac ├── context.go # Postgres context logic ├── debug.go # For temporary LocalNet ├── db.go # Helpers to connect and initialize the Postgres database -├── fisherman.go +├── watcher.go ├── genesis.go # Populate genesis logic ├── gov.go ├── module.go # Implementation of the persistence module interface @@ -77,7 +77,7 @@ persistence # Directly contains the persistence module interface for eac │   ├── application.go │   ├── base_actor.go # Implementation of the `protocol_actor.go` interface shared across all actors │   ├── block.go -│   ├── fisherman.go +│   ├── watcher.go │   ├── gov.go │   ├── persistence_genesis.go # Implements shared genesis interface │   ├── protocol_actor.go # Interface definition for the schema shared across all actors @@ -223,12 +223,12 @@ These are major TODOs spanning the entire repo so they are documented in one pla Short-term (i.e. simpler starter) tasks: - [ ] DOCUMENT: Need to do a better job at documenting the process of paused apps being turned into unstaking apps. -- [ ] CLEANUP: Remove unused parameters from `the PostgresContext` interface (i.e. see where \_ is used in the implementation such as in `InsertFisherman`) +- [ ] CLEANUP: Remove unused parameters from `the PostgresContext` interface (i.e. see where \_ is used in the implementation such as in `InsertWatcher`) - [ ] IMPROVE: Consider converting all address params from bytes to string to avoid unnecessary encoding - [ ] CLEANUP(#76): Review all the `gov_*.go` related files and simplify the code - [ ] REFACTOR/DISCUSS: Should we prefix the functions in the `PersistenceModule` with the Param / Actor it's impacting to make autocomplete in implementation better? - [ ] DISCUSS: Consider removing all `Set` methods (e.g. `SetAccountAmount`) and replace with `Add` (e.g. `AddAccountAmount`) by having it leverage a "default zero". -- [ ] REFACTOR(https://github.com/pokt-network/pocket/issues/102): Split `account` and `pool` into a shared actor (e.g. like fisherman/validator/servicer/application) and simplify the code in half +- [ ] REFACTOR(https://github.com/pokt-network/pocket/issues/102): Split `account` and `pool` into a shared actor (e.g. like watcher/validator/servicer/application) and simplify the code in half - [ ] CLEANUP: Remove `tokens` or `stakedTokens` in favor of using `amount` everywhere since the denomination is not clear. As a follow up. Consider a massive rename to make the denomination explicit. Mid-term (i.e. new feature or major refactor) tasks: diff --git a/persistence/docs/SAVEPOINTS_ROLLBACKS.md b/persistence/docs/SAVEPOINTS_ROLLBACKS.md index 0df7b1b9d..2c65e0d0e 100644 --- a/persistence/docs/SAVEPOINTS_ROLLBACKS.md +++ b/persistence/docs/SAVEPOINTS_ROLLBACKS.md @@ -34,7 +34,7 @@ As it stands we use multiple data stores (please refer to [PROTOCOL_STATE_HASH.m | Block Store | Key Value Store | BadgerDB | | Merkle Trees | Merkle Trie backed by Key-Value Store | BadgerDB | -Something worth mentioning specifically about `Merkle Trees` is the fact that we store a separate tree for each `Actor` type (i.e. `App`, `Validator`, `Fisherman`, etc.), for `Accounts` & `Pools` and for the data types such as `Transactions`, `Params` and `Flags`. +Something worth mentioning specifically about `Merkle Trees` is the fact that we store a separate tree for each `Actor` type (i.e. `App`, `Validator`, `Watcher`, etc.), for `Accounts` & `Pools` and for the data types such as `Transactions`, `Params` and `Flags`. This means that each tree is a separate data store. diff --git a/persistence/fisherman.go b/persistence/fisherman.go deleted file mode 100644 index f6cebc09f..000000000 --- a/persistence/fisherman.go +++ /dev/null @@ -1,77 +0,0 @@ -package persistence - -import ( - "encoding/hex" - - "github.com/pokt-network/pocket/persistence/types" - coreTypes "github.com/pokt-network/pocket/shared/core/types" - moduleTypes "github.com/pokt-network/pocket/shared/modules/types" -) - -func (p *PostgresContext) GetFishermanExists(address []byte, height int64) (exists bool, err error) { - return p.GetExists(types.FishermanActor, address, height) -} - -func (p *PostgresContext) GetFisherman(address []byte, height int64) (*coreTypes.Actor, error) { - return p.getActor(types.FishermanActor, address, height) -} - -func (p *PostgresContext) InsertFisherman(address, publicKey, output []byte, _ bool, _ int32, serviceURL, stakedTokens string, chains []string, pausedHeight, unstakingHeight int64) error { - return p.InsertActor(types.FishermanActor, &coreTypes.Actor{ - ActorType: coreTypes.ActorType_ACTOR_TYPE_FISH, - Address: hex.EncodeToString(address), - PublicKey: hex.EncodeToString(publicKey), - Chains: chains, - ServiceUrl: serviceURL, - StakedAmount: stakedTokens, - PausedHeight: pausedHeight, - UnstakingHeight: unstakingHeight, - Output: hex.EncodeToString(output), - }) -} - -func (p *PostgresContext) UpdateFisherman(address []byte, serviceURL, stakedAmount string, chains []string) error { - return p.UpdateActor(types.FishermanActor, &coreTypes.Actor{ - ActorType: coreTypes.ActorType_ACTOR_TYPE_FISH, - Address: hex.EncodeToString(address), - StakedAmount: stakedAmount, - ServiceUrl: serviceURL, - Chains: chains, - }) -} - -func (p *PostgresContext) GetFishermanStakeAmount(height int64, address []byte) (string, error) { - return p.getActorStakeAmount(types.FishermanActor, address, height) -} - -func (p *PostgresContext) SetFishermanStakeAmount(address []byte, stakeAmount string) error { - return p.setActorStakeAmount(types.FishermanActor, address, stakeAmount) -} - -func (p *PostgresContext) GetFishermenReadyToUnstake(height int64, status int32) ([]*moduleTypes.UnstakingActor, error) { - return p.GetActorsReadyToUnstake(types.FishermanActor, height) -} - -func (p *PostgresContext) GetFishermanStatus(address []byte, height int64) (status int32, err error) { - return p.GetActorStatus(types.FishermanActor, address, height) -} - -func (p *PostgresContext) SetFishermanUnstakingHeightAndStatus(address []byte, unstakingHeight int64, status int32) error { - return p.SetActorUnstakingHeightAndStatus(types.FishermanActor, address, unstakingHeight) -} - -func (p *PostgresContext) GetFishermanPauseHeightIfExists(address []byte, height int64) (int64, error) { - return p.GetActorPauseHeightIfExists(types.FishermanActor, address, height) -} - -func (p *PostgresContext) SetFishermanStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unstakingHeight int64, status int32) error { - return p.SetActorStatusAndUnstakingHeightIfPausedBefore(types.FishermanActor, pausedBeforeHeight, unstakingHeight) -} - -func (p *PostgresContext) SetFishermanPauseHeight(address []byte, height int64) error { - return p.SetActorPauseHeight(types.FishermanActor, address, height) -} - -func (p *PostgresContext) GetFishermanOutputAddress(operator []byte, height int64) (output []byte, err error) { - return p.GetActorOutputAddress(types.FishermanActor, operator, height) -} diff --git a/persistence/genesis.go b/persistence/genesis.go index 91f16716d..6a399eb98 100644 --- a/persistence/genesis.go +++ b/persistence/genesis.go @@ -77,10 +77,10 @@ func (m *persistenceModule) populateGenesisState(state *genesis.GenesisState) { Pool: coreTypes.Pools_POOLS_SERVICER_STAKE, }, { - Name: "fisherman", - Getter: state.GetFishermen, - InsertFn: rwCtx.InsertFisherman, - Pool: coreTypes.Pools_POOLS_FISHERMAN_STAKE, + Name: "watcher", + Getter: state.GetWatchers, + InsertFn: rwCtx.InsertWatcher, + Pool: coreTypes.Pools_POOLS_WATCHER_STAKE, }, { Name: "validator", diff --git a/persistence/sql/sql.go b/persistence/sql/sql.go index 9e99189bb..d4e3930a3 100644 --- a/persistence/sql/sql.go +++ b/persistence/sql/sql.go @@ -14,7 +14,7 @@ import ( var actorTypeToSchemaName = map[coreTypes.ActorType]ptypes.ProtocolActorSchema{ coreTypes.ActorType_ACTOR_TYPE_APP: ptypes.ApplicationActor, coreTypes.ActorType_ACTOR_TYPE_VAL: ptypes.ValidatorActor, - coreTypes.ActorType_ACTOR_TYPE_FISH: ptypes.FishermanActor, + coreTypes.ActorType_ACTOR_TYPE_WATCHER: ptypes.WatcherActor, coreTypes.ActorType_ACTOR_TYPE_SERVICER: ptypes.ServicerActor, } diff --git a/persistence/test/actor_test.go b/persistence/test/actor_test.go index 1f605f240..c84ca789e 100644 --- a/persistence/test/actor_test.go +++ b/persistence/test/actor_test.go @@ -13,7 +13,7 @@ import ( func TestGetAllStakedActors(t *testing.T) { db := NewTestPostgresContext(t, 0) - expectedActorCount := genesisStateNumValidators + genesisStateNumServicers + genesisStateNumApplications + genesisStateNumFishermen + expectedActorCount := genesisStateNumValidators + genesisStateNumServicers + genesisStateNumApplications + genesisStateNumWatchers actors, err := db.GetAllStakedActors(0) require.NoError(t, err) @@ -22,7 +22,7 @@ func TestGetAllStakedActors(t *testing.T) { actualValidators := 0 actualServicers := 0 actualApplications := 0 - actualFishermen := 0 + actualWatchers := 0 for _, actor := range actors { switch actor.ActorType { case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -31,14 +31,14 @@ func TestGetAllStakedActors(t *testing.T) { actualServicers++ case coreTypes.ActorType_ACTOR_TYPE_APP: actualApplications++ - case coreTypes.ActorType_ACTOR_TYPE_FISH: - actualFishermen++ + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + actualWatchers++ } } require.Equal(t, genesisStateNumValidators, actualValidators) require.Equal(t, genesisStateNumServicers, actualServicers) require.Equal(t, genesisStateNumApplications, actualApplications) - require.Equal(t, genesisStateNumFishermen, actualFishermen) + require.Equal(t, genesisStateNumWatchers, actualWatchers) } func TestPostgresContext_GetValidatorSet(t *testing.T) { diff --git a/persistence/test/fisherman_test.go b/persistence/test/fisherman_test.go deleted file mode 100644 index a3a245f37..000000000 --- a/persistence/test/fisherman_test.go +++ /dev/null @@ -1,281 +0,0 @@ -package test - -import ( - "encoding/hex" - "log" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/pokt-network/pocket/persistence" - ptypes "github.com/pokt-network/pocket/persistence/types" - coreTypes "github.com/pokt-network/pocket/shared/core/types" - "github.com/pokt-network/pocket/shared/crypto" -) - -func FuzzFisherman(f *testing.F) { - fuzzSingleProtocolActor(f, - newTestGenericActor(ptypes.FishermanActor, newTestFisherman), - getGenericActor(ptypes.FishermanActor, getTestFisherman), - ptypes.FishermanActor) -} - -func TestGetSetFishermanStakeAmount(t *testing.T) { - db := NewTestPostgresContext(t, 1) - getTestGetSetStakeAmountTest(t, db, createAndInsertDefaultTestFisherman, db.GetFishermanStakeAmount, db.SetFishermanStakeAmount, 1) -} - -func TestGetFishermanUpdatedAtHeight(t *testing.T) { - getFishermanUpdatedFunc := func(db *persistence.PostgresContext, height int64) ([]*coreTypes.Actor, error) { - return db.GetActorsUpdated(ptypes.FishermanActor, height) - } - getAllActorsUpdatedAtHeightTest(t, createAndInsertDefaultTestFisherman, getFishermanUpdatedFunc, 1) -} - -func TestInsertFishermanAndExists(t *testing.T) { - db := NewTestPostgresContext(t, 0) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - db.Height = 1 - - fisherman2, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - addrBz2, err := hex.DecodeString(fisherman2.Address) - require.NoError(t, err) - - exists, err := db.GetFishermanExists(addrBz, 0) - require.NoError(t, err) - require.True(t, exists, "actor that should exist at previous height does not") - exists, err = db.GetFishermanExists(addrBz, 1) - require.NoError(t, err) - require.True(t, exists, "actor that should exist at current height does not") - - exists, err = db.GetFishermanExists(addrBz2, 0) - require.NoError(t, err) - require.False(t, exists, "actor that should not exist at previous height fishermanears to") - exists, err = db.GetFishermanExists(addrBz2, 1) - require.NoError(t, err) - require.True(t, exists, "actor that should exist at current height does not") -} - -func TestUpdateFisherman(t *testing.T) { - db := NewTestPostgresContext(t, 0) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - - fisher, err := db.GetFisherman(addrBz, 0) - require.NoError(t, err) - require.NotNil(t, fisher) - require.Equal(t, DefaultChains, fisher.Chains, "default chains incorrect for current height") - require.Equal(t, DefaultStake, fisher.StakedAmount, "default stake incorrect for current height") - - db.Height = 1 - - require.NotEqual(t, DefaultStake, StakeToUpdate) // sanity check to make sure the tests are correct - require.NotEqual(t, DefaultChains, ChainsToUpdate) // sanity check to make sure the tests are correct - err = db.UpdateFisherman(addrBz, fisherman.ServiceUrl, StakeToUpdate, ChainsToUpdate) - require.NoError(t, err) - - fisher, err = db.GetFisherman(addrBz, 0) - require.NoError(t, err) - require.NotNil(t, fisher) - require.Equal(t, DefaultChains, fisher.Chains, "default chains incorrect for current height") - require.Equal(t, DefaultStake, fisher.StakedAmount, "default stake incorrect for current height") - - fisher, err = db.GetFisherman(addrBz, 1) - require.NoError(t, err) - require.NotNil(t, fisher) - require.Equal(t, ChainsToUpdate, fisher.Chains, "chains not updated for current height") - require.Equal(t, StakeToUpdate, fisher.StakedAmount, "stake not updated for current height") -} - -func TestGetFishermenReadyToUnstake(t *testing.T) { - db := NewTestPostgresContext(t, 0) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - fisherman2, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - fisherman3, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - addrBz2, err := hex.DecodeString(fisherman2.Address) - require.NoError(t, err) - addrBz3, err := hex.DecodeString(fisherman3.Address) - require.NoError(t, err) - - // Unstake fisherman at height 0 - err = db.SetFishermanUnstakingHeightAndStatus(addrBz, 0, int32(coreTypes.StakeStatus_Unstaking)) - require.NoError(t, err) - - // Unstake fisherman2 and fisherman3 at height 1 - err = db.SetFishermanUnstakingHeightAndStatus(addrBz2, 1, int32(coreTypes.StakeStatus_Unstaking)) - require.NoError(t, err) - err = db.SetFishermanUnstakingHeightAndStatus(addrBz3, 1, int32(coreTypes.StakeStatus_Unstaking)) - require.NoError(t, err) - - // Check unstaking fishermans at height 0 - unstakingFishermen, err := db.GetFishermenReadyToUnstake(0, int32(coreTypes.StakeStatus_Unstaking)) - require.NoError(t, err) - require.Equal(t, 1, len(unstakingFishermen), "wrong number of actors ready to unstake at height 0") - require.Equal(t, fisherman.Address, unstakingFishermen[0].GetAddress(), "unexpected fishermanlication actor returned") - - // Check unstaking fishermans at height 1 - unstakingFishermen, err = db.GetFishermenReadyToUnstake(1, int32(coreTypes.StakeStatus_Unstaking)) - require.NoError(t, err) - require.Equal(t, 2, len(unstakingFishermen), "wrong number of actors ready to unstake at height 1") - require.ElementsMatch(t, []string{fisherman2.Address, fisherman3.Address}, []string{unstakingFishermen[0].Address, unstakingFishermen[1].Address}) -} - -func TestGetFishermanStatus(t *testing.T) { - db := NewTestPostgresContext(t, 1) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - - // Check status before the fisherman exists - status, err := db.GetFishermanStatus(addrBz, 0) - require.Error(t, err) - require.Equal(t, int32(coreTypes.StakeStatus_UnknownStatus), status, "unexpected status") - - // Check status after the fisherman exists - status, err = db.GetFishermanStatus(addrBz, 1) - require.NoError(t, err) - require.Equal(t, DefaultStakeStatus, status, "unexpected status") -} - -func TestGetFishermanPauseHeightIfExists(t *testing.T) { - db := NewTestPostgresContext(t, 1) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - - // Check pause height when fisherman does not exist - pauseHeight, err := db.GetFishermanPauseHeightIfExists(addrBz, 0) - require.Error(t, err) - require.Equal(t, DefaultPauseHeight, pauseHeight, "unexpected pause height") - - // Check pause height when fisherman does not exist - pauseHeight, err = db.GetFishermanPauseHeightIfExists(addrBz, 1) - require.NoError(t, err) - require.Equal(t, DefaultPauseHeight, pauseHeight, "unexpected pause height") -} - -func TestSetFishermanPauseHeightAndUnstakeLater(t *testing.T) { - db := NewTestPostgresContext(t, 0) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - pauseHeight := int64(1) - unstakingHeight := pauseHeight + 10 - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - - err = db.SetFishermanPauseHeight(addrBz, pauseHeight) - require.NoError(t, err) - - fisher, err := db.GetFisherman(addrBz, 0) - require.NoError(t, err) - require.NotNil(t, fisher) - require.Equal(t, pauseHeight, fisher.PausedHeight, "pause height not updated") - - err = db.SetFishermanStatusAndUnstakingHeightIfPausedBefore(pauseHeight+1, unstakingHeight, -1 /*unused*/) - require.NoError(t, err) - - fisher, err = db.GetFisherman(addrBz, 0) - require.NoError(t, err) - require.NotNil(t, fisher) - require.Equal(t, unstakingHeight, fisher.UnstakingHeight, "unstaking height was not set correctly") -} - -func TestGetFishermanOutputAddress(t *testing.T) { - db := NewTestPostgresContext(t, 0) - - fisherman, err := createAndInsertDefaultTestFisherman(db) - require.NoError(t, err) - - addrBz, err := hex.DecodeString(fisherman.Address) - require.NoError(t, err) - - output, err := db.GetFishermanOutputAddress(addrBz, 0) - require.NoError(t, err) - require.Equal(t, fisherman.Output, hex.EncodeToString(output), "unexpected output address") -} - -func newTestFisherman() (*coreTypes.Actor, error) { - operatorKey, err := crypto.GeneratePublicKey() - if err != nil { - return nil, err - } - - outputAddr, err := crypto.GenerateAddress() - if err != nil { - return nil, err - } - - return &coreTypes.Actor{ - Address: hex.EncodeToString(operatorKey.Address()), - PublicKey: hex.EncodeToString(operatorKey.Bytes()), - Chains: DefaultChains, - ServiceUrl: DefaultServiceURL, - StakedAmount: DefaultStake, - PausedHeight: DefaultPauseHeight, - UnstakingHeight: DefaultUnstakingHeight, - Output: hex.EncodeToString(outputAddr), - }, nil -} - -func createAndInsertDefaultTestFisherman(db *persistence.PostgresContext) (*coreTypes.Actor, error) { - fisherman, err := newTestFisherman() - if err != nil { - return nil, err - } - addrBz, err := hex.DecodeString(fisherman.Address) - if err != nil { - log.Fatalf("an error occurred converting address to bytes %s", fisherman.Address) - } - pubKeyBz, err := hex.DecodeString(fisherman.PublicKey) - if err != nil { - log.Fatalf("an error occurred converting pubKey to bytes %s", fisherman.PublicKey) - } - outputBz, err := hex.DecodeString(fisherman.Output) - if err != nil { - log.Fatalf("an error occurred converting output to bytes %s", fisherman.Output) - } - return fisherman, db.InsertFisherman( - addrBz, - pubKeyBz, - outputBz, - false, - DefaultStakeStatus, - DefaultServiceURL, - DefaultStake, - DefaultChains, - DefaultPauseHeight, - DefaultUnstakingHeight) -} - -func getTestFisherman(db *persistence.PostgresContext, address []byte) (*coreTypes.Actor, error) { - return db.GetFisherman(address, db.Height) -} diff --git a/persistence/test/setup_test.go b/persistence/test/setup_test.go index 70ac0603b..de35aacdd 100644 --- a/persistence/test/setup_test.go +++ b/persistence/test/setup_test.go @@ -53,7 +53,7 @@ var ( genesisStateNumValidators = 5 genesisStateNumServicers = 1 genesisStateNumApplications = 1 - genesisStateNumFishermen = 1 + genesisStateNumWatchers = 1 // Initialized in TestMain testPersistenceMod modules.PersistenceModule @@ -115,7 +115,7 @@ func newTestPersistenceModule(databaseUrl string) modules.PersistenceModule { genesisStateNumValidators, genesisStateNumServicers, genesisStateNumApplications, - genesisStateNumServicers, + genesisStateNumWatchers, ) runtimeMgr := runtime.NewManager(cfg, genesisState) bus, err := runtime.CreateBus(runtimeMgr) diff --git a/persistence/test/state_test.go b/persistence/test/state_test.go index d2b67fcf6..d27f7c622 100644 --- a/persistence/test/state_test.go +++ b/persistence/test/state_test.go @@ -42,9 +42,9 @@ func TestStateHash_DeterministicStateWhenUpdatingAppStake(t *testing.T) { // logic changes, these hashes will need to be updated based on the test output. // TODO: Add an explicit updateSnapshots flag to the test to make this more clear. stateHashes := []string{ - "1e433a8905c7b1cf42222f8d01ba222038653f8ff35ae97cce1fd6a32d18b51e", - "4542dea3eedb99ad46b3c6e0ea901a9ee365b590b2f2ac7f12678ac369a2fe90", - "1524529fa827852e397adf1938eb058848209c4916cdacef929d050efc472c1d", + "9b14f17144cf259ad45ac01f26521a50d201712ad916e1e848b6980102c16410", + "7261de0f8dc780723448b17a6f3be219f9760ed69952935f906854039856abef", + "0d323a6f18c5a5e0f4e894174dc3e7b9c3ea561e31a82b70b7f024296ffcfa1b", } stakeAmount := initialStakeAmount diff --git a/persistence/test/watcher_test.go b/persistence/test/watcher_test.go new file mode 100644 index 000000000..ec16965a4 --- /dev/null +++ b/persistence/test/watcher_test.go @@ -0,0 +1,281 @@ +package test + +import ( + "encoding/hex" + "log" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/pokt-network/pocket/persistence" + ptypes "github.com/pokt-network/pocket/persistence/types" + coreTypes "github.com/pokt-network/pocket/shared/core/types" + "github.com/pokt-network/pocket/shared/crypto" +) + +func FuzzWatcher(f *testing.F) { + fuzzSingleProtocolActor(f, + newTestGenericActor(ptypes.WatcherActor, newTestWatcher), + getGenericActor(ptypes.WatcherActor, getTestWatcher), + ptypes.WatcherActor) +} + +func TestGetSetWatcherStakeAmount(t *testing.T) { + db := NewTestPostgresContext(t, 1) + getTestGetSetStakeAmountTest(t, db, createAndInsertDefaultTestWatcher, db.GetWatcherStakeAmount, db.SetWatcherStakeAmount, 1) +} + +func TestGetWatcherUpdatedAtHeight(t *testing.T) { + getWatcherUpdatedFunc := func(db *persistence.PostgresContext, height int64) ([]*coreTypes.Actor, error) { + return db.GetActorsUpdated(ptypes.WatcherActor, height) + } + getAllActorsUpdatedAtHeightTest(t, createAndInsertDefaultTestWatcher, getWatcherUpdatedFunc, 1) +} + +func TestInsertWatcherAndExists(t *testing.T) { + db := NewTestPostgresContext(t, 0) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + db.Height = 1 + + watcher2, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + addrBz2, err := hex.DecodeString(watcher2.Address) + require.NoError(t, err) + + exists, err := db.GetWatcherExists(addrBz, 0) + require.NoError(t, err) + require.True(t, exists, "actor that should exist at previous height does not") + exists, err = db.GetWatcherExists(addrBz, 1) + require.NoError(t, err) + require.True(t, exists, "actor that should exist at current height does not") + + exists, err = db.GetWatcherExists(addrBz2, 0) + require.NoError(t, err) + require.False(t, exists, "actor that should not exist at previous height watcherears to") + exists, err = db.GetWatcherExists(addrBz2, 1) + require.NoError(t, err) + require.True(t, exists, "actor that should exist at current height does not") +} + +func TestUpdateWatcher(t *testing.T) { + db := NewTestPostgresContext(t, 0) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + + watch, err := db.GetWatcher(addrBz, 0) + require.NoError(t, err) + require.NotNil(t, watch) + require.Equal(t, DefaultChains, watch.Chains, "default chains incorrect for current height") + require.Equal(t, DefaultStake, watch.StakedAmount, "default stake incorrect for current height") + + db.Height = 1 + + require.NotEqual(t, DefaultStake, StakeToUpdate) // sanity check to make sure the tests are correct + require.NotEqual(t, DefaultChains, ChainsToUpdate) // sanity check to make sure the tests are correct + err = db.UpdateWatcher(addrBz, watcher.ServiceUrl, StakeToUpdate, ChainsToUpdate) + require.NoError(t, err) + + watch, err = db.GetWatcher(addrBz, 0) + require.NoError(t, err) + require.NotNil(t, watch) + require.Equal(t, DefaultChains, watch.Chains, "default chains incorrect for current height") + require.Equal(t, DefaultStake, watch.StakedAmount, "default stake incorrect for current height") + + watch, err = db.GetWatcher(addrBz, 1) + require.NoError(t, err) + require.NotNil(t, watch) + require.Equal(t, ChainsToUpdate, watch.Chains, "chains not updated for current height") + require.Equal(t, StakeToUpdate, watch.StakedAmount, "stake not updated for current height") +} + +func TestGetWatchersReadyToUnstake(t *testing.T) { + db := NewTestPostgresContext(t, 0) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + watcher2, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + watcher3, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + addrBz2, err := hex.DecodeString(watcher2.Address) + require.NoError(t, err) + addrBz3, err := hex.DecodeString(watcher3.Address) + require.NoError(t, err) + + // Unstake watcher at height 0 + err = db.SetWatcherUnstakingHeightAndStatus(addrBz, 0, int32(coreTypes.StakeStatus_Unstaking)) + require.NoError(t, err) + + // Unstake watcher2 and watcher3 at height 1 + err = db.SetWatcherUnstakingHeightAndStatus(addrBz2, 1, int32(coreTypes.StakeStatus_Unstaking)) + require.NoError(t, err) + err = db.SetWatcherUnstakingHeightAndStatus(addrBz3, 1, int32(coreTypes.StakeStatus_Unstaking)) + require.NoError(t, err) + + // Check unstaking watchers at height 0 + unstakingWatchers, err := db.GetWatchersReadyToUnstake(0, int32(coreTypes.StakeStatus_Unstaking)) + require.NoError(t, err) + require.Equal(t, 1, len(unstakingWatchers), "wrong number of actors ready to unstake at height 0") + require.Equal(t, watcher.Address, unstakingWatchers[0].GetAddress(), "unexpected watcherlication actor returned") + + // Check unstaking watchers at height 1 + unstakingWatchers, err = db.GetWatchersReadyToUnstake(1, int32(coreTypes.StakeStatus_Unstaking)) + require.NoError(t, err) + require.Equal(t, 2, len(unstakingWatchers), "wrong number of actors ready to unstake at height 1") + require.ElementsMatch(t, []string{watcher2.Address, watcher3.Address}, []string{unstakingWatchers[0].Address, unstakingWatchers[1].Address}) +} + +func TestGetWatcherStatus(t *testing.T) { + db := NewTestPostgresContext(t, 1) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + + // Check status before the watcher exists + status, err := db.GetWatcherStatus(addrBz, 0) + require.Error(t, err) + require.Equal(t, int32(coreTypes.StakeStatus_UnknownStatus), status, "unexpected status") + + // Check status after the watcher exists + status, err = db.GetWatcherStatus(addrBz, 1) + require.NoError(t, err) + require.Equal(t, DefaultStakeStatus, status, "unexpected status") +} + +func TestGetWatcherPauseHeightIfExists(t *testing.T) { + db := NewTestPostgresContext(t, 1) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + + // Check pause height when watcher does not exist + pauseHeight, err := db.GetWatcherPauseHeightIfExists(addrBz, 0) + require.Error(t, err) + require.Equal(t, DefaultPauseHeight, pauseHeight, "unexpected pause height") + + // Check pause height when watcher does not exist + pauseHeight, err = db.GetWatcherPauseHeightIfExists(addrBz, 1) + require.NoError(t, err) + require.Equal(t, DefaultPauseHeight, pauseHeight, "unexpected pause height") +} + +func TestSetWatcherPauseHeightAndUnstakeLater(t *testing.T) { + db := NewTestPostgresContext(t, 0) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + pauseHeight := int64(1) + unstakingHeight := pauseHeight + 10 + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + + err = db.SetWatcherPauseHeight(addrBz, pauseHeight) + require.NoError(t, err) + + watch, err := db.GetWatcher(addrBz, 0) + require.NoError(t, err) + require.NotNil(t, watch) + require.Equal(t, pauseHeight, watch.PausedHeight, "pause height not updated") + + err = db.SetWatcherStatusAndUnstakingHeightIfPausedBefore(pauseHeight+1, unstakingHeight, -1 /*unused*/) + require.NoError(t, err) + + watch, err = db.GetWatcher(addrBz, 0) + require.NoError(t, err) + require.NotNil(t, watch) + require.Equal(t, unstakingHeight, watch.UnstakingHeight, "unstaking height was not set correctly") +} + +func TestGetWatcherOutputAddress(t *testing.T) { + db := NewTestPostgresContext(t, 0) + + watcher, err := createAndInsertDefaultTestWatcher(db) + require.NoError(t, err) + + addrBz, err := hex.DecodeString(watcher.Address) + require.NoError(t, err) + + output, err := db.GetWatcherOutputAddress(addrBz, 0) + require.NoError(t, err) + require.Equal(t, watcher.Output, hex.EncodeToString(output), "unexpected output address") +} + +func newTestWatcher() (*coreTypes.Actor, error) { + operatorKey, err := crypto.GeneratePublicKey() + if err != nil { + return nil, err + } + + outputAddr, err := crypto.GenerateAddress() + if err != nil { + return nil, err + } + + return &coreTypes.Actor{ + Address: hex.EncodeToString(operatorKey.Address()), + PublicKey: hex.EncodeToString(operatorKey.Bytes()), + Chains: DefaultChains, + ServiceUrl: DefaultServiceURL, + StakedAmount: DefaultStake, + PausedHeight: DefaultPauseHeight, + UnstakingHeight: DefaultUnstakingHeight, + Output: hex.EncodeToString(outputAddr), + }, nil +} + +func createAndInsertDefaultTestWatcher(db *persistence.PostgresContext) (*coreTypes.Actor, error) { + watcher, err := newTestWatcher() + if err != nil { + return nil, err + } + addrBz, err := hex.DecodeString(watcher.Address) + if err != nil { + log.Fatalf("an error occurred converting address to bytes %s", watcher.Address) + } + pubKeyBz, err := hex.DecodeString(watcher.PublicKey) + if err != nil { + log.Fatalf("an error occurred converting pubKey to bytes %s", watcher.PublicKey) + } + outputBz, err := hex.DecodeString(watcher.Output) + if err != nil { + log.Fatalf("an error occurred converting output to bytes %s", watcher.Output) + } + return watcher, db.InsertWatcher( + addrBz, + pubKeyBz, + outputBz, + false, + DefaultStakeStatus, + DefaultServiceURL, + DefaultStake, + DefaultChains, + DefaultPauseHeight, + DefaultUnstakingHeight) +} + +func getTestWatcher(db *persistence.PostgresContext, address []byte) (*coreTypes.Actor, error) { + return db.GetWatcher(address, db.Height) +} diff --git a/persistence/trees/atomic_test.go b/persistence/trees/atomic_test.go index 06fdbaf8c..3dada314b 100644 --- a/persistence/trees/atomic_test.go +++ b/persistence/trees/atomic_test.go @@ -15,9 +15,9 @@ import ( const ( // the root hash of a tree store where each tree is empty but present and initialized - h0 = "302f2956c084cc3e0e760cf1b8c2da5de79c45fa542f68a660a5fc494b486972" + h0 = "11dc4c7c1697ab33acc396f9566e753919548f1c0517ab3d7199a79a673366b7" // the root hash of a tree store where each tree has has key foo value bar added to it - h1 = "7d5712ea1507915c40e295845fa58773baa405b24b87e9d99761125d826ff915" + h1 = "584f62448c67ab0262a10c7332f0c1ec855835c0c87acf828718e9a138e3fbac" ) func TestTreeStore_AtomicUpdatesWithSuccessfulRollback(t *testing.T) { diff --git a/persistence/trees/module_test.go b/persistence/trees/module_test.go index 91ec5249f..b11bf9e9c 100644 --- a/persistence/trees/module_test.go +++ b/persistence/trees/module_test.go @@ -105,7 +105,7 @@ func preparePersistenceMock(t *testing.T, busMock *mockModules.MockBus, genesisS return testutil.Concatenate[*coreTypes.Actor]( genesisState.GetValidators(), genesisState.GetServicers(), - genesisState.GetFishermen(), + genesisState.GetWatchers(), genesisState.GetApplications(), ), nil }). diff --git a/persistence/trees/trees.go b/persistence/trees/trees.go index 8fdc43676..c25bb5c5c 100644 --- a/persistence/trees/trees.go +++ b/persistence/trees/trees.go @@ -39,7 +39,7 @@ const ( RootTreeName = "root" AppTreeName = "app" ValTreeName = "val" - FishTreeName = "fish" + WatcherTreeName = "watcher" ServicerTreeName = "servicer" AccountTreeName = "account" PoolTreeName = "pool" @@ -52,20 +52,20 @@ const ( var actorTypeToMerkleTreeName = map[coreTypes.ActorType]string{ coreTypes.ActorType_ACTOR_TYPE_APP: AppTreeName, coreTypes.ActorType_ACTOR_TYPE_VAL: ValTreeName, - coreTypes.ActorType_ACTOR_TYPE_FISH: FishTreeName, + coreTypes.ActorType_ACTOR_TYPE_WATCHER: WatcherTreeName, coreTypes.ActorType_ACTOR_TYPE_SERVICER: ServicerTreeName, } var merkleTreeNameToActorTypeName = map[string]coreTypes.ActorType{ AppTreeName: coreTypes.ActorType_ACTOR_TYPE_APP, ValTreeName: coreTypes.ActorType_ACTOR_TYPE_VAL, - FishTreeName: coreTypes.ActorType_ACTOR_TYPE_FISH, + WatcherTreeName: coreTypes.ActorType_ACTOR_TYPE_WATCHER, ServicerTreeName: coreTypes.ActorType_ACTOR_TYPE_SERVICER, } var stateTreeNames = []string{ // Actor Trees - AppTreeName, ValTreeName, FishTreeName, ServicerTreeName, + AppTreeName, ValTreeName, WatcherTreeName, ServicerTreeName, // Account Trees AccountTreeName, PoolTreeName, // Data Trees @@ -192,7 +192,7 @@ func (t *treeStore) updateMerkleTrees(pgtx pgx.Tx, txi indexer.TxIndexer, height for treeName := range t.merkleTrees { switch treeName { // Actor Merkle Trees - case AppTreeName, ValTreeName, FishTreeName, ServicerTreeName: + case AppTreeName, ValTreeName, WatcherTreeName, ServicerTreeName: actorType, ok := merkleTreeNameToActorTypeName[treeName] if !ok { return "", fmt.Errorf("no actor type found for merkle tree: %s", treeName) diff --git a/persistence/trees/trees_test.go b/persistence/trees/trees_test.go index aa8c41ab4..d86b687a9 100644 --- a/persistence/trees/trees_test.go +++ b/persistence/trees/trees_test.go @@ -37,7 +37,7 @@ var ( ) const ( - treesHash1 = "5282ee91a3ec0a6f2b30e4780b369bae78c80ef3ea40587fef6ae263bf41f244" + treesHash1 = "9c08f045640a3578354a73068008c0907ab20562515c23f8a0b36b6023e71e6b" ) func TestTreeStore_Update(t *testing.T) { diff --git a/persistence/types/fisherman.go b/persistence/types/fisherman.go deleted file mode 100644 index 1ffe2e8b7..000000000 --- a/persistence/types/fisherman.go +++ /dev/null @@ -1,30 +0,0 @@ -package types - -import coreTypes "github.com/pokt-network/pocket/shared/core/types" - -var _ ProtocolActorSchema = &FishermanSchema{} - -type FishermanSchema struct { - BaseProtocolActorSchema -} - -const ( - FishermanTableName = "fisherman" - FishermanChainsTableName = "fisherman_chains" - FishermanHeightConstraintName = "fisherman_height" - FishermanChainsConstraintName = "fisherman_chain_height" -) - -var FishermanActor ProtocolActorSchema = &FishermanSchema{ - BaseProtocolActorSchema: BaseProtocolActorSchema{ - actorType: coreTypes.ActorType_ACTOR_TYPE_FISH, - - tableName: FishermanTableName, - chainsTableName: FishermanChainsTableName, - - actorSpecificColName: ServiceURLCol, - - heightConstraintName: FishermanHeightConstraintName, - chainsHeightConstraintName: FishermanChainsConstraintName, - }, -} diff --git a/persistence/types/gov_test.go b/persistence/types/gov_test.go index 6a07f7ede..ea9ec0257 100644 --- a/persistence/types/gov_test.go +++ b/persistence/types/gov_test.go @@ -36,12 +36,12 @@ func TestInsertParams(t *testing.T) { "('servicer_minimum_pause_blocks', -1, 'SMALLINT', 4)," + "('servicer_max_pause_blocks', -1, 'BIGINT', 672)," + "('servicers_per_session', -1, 'SMALLINT', 24)," + - "('fisherman_minimum_stake', -1, 'STRING', '15000000000')," + - "('fisherman_max_chains', -1, 'SMALLINT', 15)," + - "('fisherman_unstaking_blocks', -1, 'BIGINT', 2016)," + - "('fisherman_minimum_pause_blocks', -1, 'SMALLINT', 4)," + - "('fisherman_max_pause_blocks', -1, 'SMALLINT', 672)," + - "('fisherman_per_session', -1, 'SMALLINT', 1)," + + "('watcher_minimum_stake', -1, 'STRING', '15000000000')," + + "('watcher_max_chains', -1, 'SMALLINT', 15)," + + "('watcher_unstaking_blocks', -1, 'BIGINT', 2016)," + + "('watcher_minimum_pause_blocks', -1, 'SMALLINT', 4)," + + "('watcher_max_pause_blocks', -1, 'SMALLINT', 672)," + + "('watcher_per_session', -1, 'SMALLINT', 1)," + "('validator_minimum_stake', -1, 'STRING', '15000000000')," + "('validator_unstaking_blocks', -1, 'BIGINT', 2016)," + "('validator_minimum_pause_blocks', -1, 'SMALLINT', 4)," + @@ -53,12 +53,12 @@ func TestInsertParams(t *testing.T) { "('double_sign_burn_percentage', -1, 'SMALLINT', 5)," + "('message_double_sign_fee', -1, 'STRING', '10000')," + "('message_send_fee', -1, 'STRING', '10000')," + - "('message_stake_fisherman_fee', -1, 'STRING', '10000')," + - "('message_edit_stake_fisherman_fee', -1, 'STRING', '10000')," + - "('message_unstake_fisherman_fee', -1, 'STRING', '10000')," + - "('message_pause_fisherman_fee', -1, 'STRING', '10000')," + - "('message_unpause_fisherman_fee', -1, 'STRING', '10000')," + - "('message_fisherman_pause_servicer_fee', -1, 'STRING', '10000')," + + "('message_stake_watcher_fee', -1, 'STRING', '10000')," + + "('message_edit_stake_watcher_fee', -1, 'STRING', '10000')," + + "('message_unstake_watcher_fee', -1, 'STRING', '10000')," + + "('message_pause_watcher_fee', -1, 'STRING', '10000')," + + "('message_unpause_watcher_fee', -1, 'STRING', '10000')," + + "('message_watcher_pause_servicer_fee', -1, 'STRING', '10000')," + "('message_test_score_fee', -1, 'STRING', '10000')," + "('message_prove_test_score_fee', -1, 'STRING', '10000')," + "('message_stake_app_fee', -1, 'STRING', '10000')," + @@ -91,12 +91,12 @@ func TestInsertParams(t *testing.T) { "('servicer_minimum_pause_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('servicer_max_paused_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('servicers_per_session_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('fisherman_minimum_stake_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('fisherman_max_chains_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('fisherman_unstaking_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('fisherman_minimum_pause_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('fisherman_max_paused_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('fisherman_per_session_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('watcher_minimum_stake_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('watcher_max_chains_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('watcher_unstaking_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('watcher_minimum_pause_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('watcher_max_paused_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('watcher_per_session_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('validator_minimum_stake_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('validator_unstaking_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('validator_minimum_pause_blocks_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + @@ -108,12 +108,12 @@ func TestInsertParams(t *testing.T) { "('double_sign_burn_percentage_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('message_double_sign_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('message_send_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('message_stake_fisherman_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('message_edit_stake_fisherman_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('message_unstake_fisherman_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('message_pause_fisherman_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('message_unpause_fisherman_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + - "('message_fisherman_pause_servicer_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('message_stake_watcher_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('message_edit_stake_watcher_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('message_unstake_watcher_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('message_pause_watcher_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('message_unpause_watcher_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + + "('message_watcher_pause_servicer_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('message_test_score_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('message_prove_test_score_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + "('message_stake_app_fee_owner', -1, 'STRING', 'da034209758b78eaea06dd99c07909ab54c99b45')," + diff --git a/persistence/types/watcher.go b/persistence/types/watcher.go new file mode 100644 index 000000000..fb40249e6 --- /dev/null +++ b/persistence/types/watcher.go @@ -0,0 +1,30 @@ +package types + +import coreTypes "github.com/pokt-network/pocket/shared/core/types" + +var _ ProtocolActorSchema = &WatcherSchema{} + +type WatcherSchema struct { + BaseProtocolActorSchema +} + +const ( + WatcherTableName = "watcher" + WatcherChainsTableName = "watcher_chains" + WatcherHeightConstraintName = "watcher_height" + WatcherChainsConstraintName = "watcher_chain_height" +) + +var WatcherActor ProtocolActorSchema = &WatcherSchema{ + BaseProtocolActorSchema: BaseProtocolActorSchema{ + actorType: coreTypes.ActorType_ACTOR_TYPE_WATCHER, + + tableName: WatcherTableName, + chainsTableName: WatcherChainsTableName, + + actorSpecificColName: ServiceURLCol, + + heightConstraintName: WatcherHeightConstraintName, + chainsHeightConstraintName: WatcherChainsConstraintName, + }, +} diff --git a/persistence/watcher.go b/persistence/watcher.go new file mode 100644 index 000000000..766463efb --- /dev/null +++ b/persistence/watcher.go @@ -0,0 +1,77 @@ +package persistence + +import ( + "encoding/hex" + + "github.com/pokt-network/pocket/persistence/types" + coreTypes "github.com/pokt-network/pocket/shared/core/types" + moduleTypes "github.com/pokt-network/pocket/shared/modules/types" +) + +func (p *PostgresContext) GetWatcherExists(address []byte, height int64) (exists bool, err error) { + return p.GetExists(types.WatcherActor, address, height) +} + +func (p *PostgresContext) GetWatcher(address []byte, height int64) (*coreTypes.Actor, error) { + return p.getActor(types.WatcherActor, address, height) +} + +func (p *PostgresContext) InsertWatcher(address, publicKey, output []byte, _ bool, _ int32, serviceURL, stakedTokens string, chains []string, pausedHeight, unstakingHeight int64) error { + return p.InsertActor(types.WatcherActor, &coreTypes.Actor{ + ActorType: coreTypes.ActorType_ACTOR_TYPE_WATCHER, + Address: hex.EncodeToString(address), + PublicKey: hex.EncodeToString(publicKey), + Chains: chains, + ServiceUrl: serviceURL, + StakedAmount: stakedTokens, + PausedHeight: pausedHeight, + UnstakingHeight: unstakingHeight, + Output: hex.EncodeToString(output), + }) +} + +func (p *PostgresContext) UpdateWatcher(address []byte, serviceURL, stakedAmount string, chains []string) error { + return p.UpdateActor(types.WatcherActor, &coreTypes.Actor{ + ActorType: coreTypes.ActorType_ACTOR_TYPE_WATCHER, + Address: hex.EncodeToString(address), + StakedAmount: stakedAmount, + ServiceUrl: serviceURL, + Chains: chains, + }) +} + +func (p *PostgresContext) GetWatcherStakeAmount(height int64, address []byte) (string, error) { + return p.getActorStakeAmount(types.WatcherActor, address, height) +} + +func (p *PostgresContext) SetWatcherStakeAmount(address []byte, stakeAmount string) error { + return p.setActorStakeAmount(types.WatcherActor, address, stakeAmount) +} + +func (p *PostgresContext) GetWatchersReadyToUnstake(height int64, status int32) ([]*moduleTypes.UnstakingActor, error) { + return p.GetActorsReadyToUnstake(types.WatcherActor, height) +} + +func (p *PostgresContext) GetWatcherStatus(address []byte, height int64) (status int32, err error) { + return p.GetActorStatus(types.WatcherActor, address, height) +} + +func (p *PostgresContext) SetWatcherUnstakingHeightAndStatus(address []byte, unstakingHeight int64, status int32) error { + return p.SetActorUnstakingHeightAndStatus(types.WatcherActor, address, unstakingHeight) +} + +func (p *PostgresContext) GetWatcherPauseHeightIfExists(address []byte, height int64) (int64, error) { + return p.GetActorPauseHeightIfExists(types.WatcherActor, address, height) +} + +func (p *PostgresContext) SetWatcherStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unstakingHeight int64, status int32) error { + return p.SetActorStatusAndUnstakingHeightIfPausedBefore(types.WatcherActor, pausedBeforeHeight, unstakingHeight) +} + +func (p *PostgresContext) SetWatcherPauseHeight(address []byte, height int64) error { + return p.SetActorPauseHeight(types.WatcherActor, address, height) +} + +func (p *PostgresContext) GetWatcherOutputAddress(operator []byte, height int64) (output []byte, err error) { + return p.GetActorOutputAddress(types.WatcherActor, operator, height) +} diff --git a/rpc/handlers.go b/rpc/handlers.go index e222b3e66..b3ffb5477 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -63,10 +63,10 @@ func (s *rpcServer) PostV1ClientGetSession(ctx echo.Context) error { rpcServicers = append(rpcServicers, actor) } - rpcFishermen := make([]ProtocolActor, 0) - for _, fisher := range session.GetFishermen() { - actor := protocolActorToRPCProtocolActor(fisher) - rpcFishermen = append(rpcFishermen, actor) + rpcWatchers := make([]ProtocolActor, 0) + for _, watcher := range session.GetWatchers() { + actor := protocolActorToRPCProtocolActor(watcher) + rpcWatchers = append(rpcWatchers, actor) } return ctx.JSON(http.StatusOK, Session{ @@ -78,7 +78,7 @@ func (s *rpcServer) PostV1ClientGetSession(ctx echo.Context) error { Geozone: string(session.GetGeoZone()), Application: rpcApp, Servicers: rpcServicers, - Fishermen: rpcFishermen, + Watchers: rpcWatchers, }) } diff --git a/rpc/handlers_query.go b/rpc/handlers_query.go index ed913cbeb..ad544c798 100644 --- a/rpc/handlers_query.go +++ b/rpc/handlers_query.go @@ -303,7 +303,7 @@ func (s *rpcServer) PostV1QueryBlockTxs(ctx echo.Context) error { }) } -func (s *rpcServer) PostV1QueryFisherman(ctx echo.Context) error { +func (s *rpcServer) PostV1QueryWatcher(ctx echo.Context) error { var body QueryAccountHeight if err := ctx.Bind(&body); err != nil { return ctx.String(http.StatusBadRequest, "bad request") @@ -320,16 +320,16 @@ func (s *rpcServer) PostV1QueryFisherman(ctx echo.Context) error { if err != nil { return ctx.String(http.StatusInternalServerError, err.Error()) } - fisherman, err := readCtx.GetFisherman(addrBz, height) + watcher, err := readCtx.GetWatcher(addrBz, height) if err != nil { return ctx.String(http.StatusInternalServerError, err.Error()) } - actor := protocolActorToRPCProtocolActor(fisherman) + actor := protocolActorToRPCProtocolActor(watcher) return ctx.JSON(http.StatusOK, actor) } -func (s *rpcServer) PostV1QueryFishermen(ctx echo.Context) error { +func (s *rpcServer) PostV1QueryWatchers(ctx echo.Context) error { var body QueryHeightPaginated if err := ctx.Bind(&body); err != nil { return ctx.String(http.StatusBadRequest, "bad request") @@ -342,26 +342,26 @@ func (s *rpcServer) PostV1QueryFishermen(ctx echo.Context) error { } defer readCtx.Release() //nolint:errcheck // We only need to make sure the readCtx is released - allFishermen, err := readCtx.GetAllFishermen(height) + allWatchers, err := readCtx.GetAllWatchers(height) if err != nil { return ctx.String(http.StatusInternalServerError, err.Error()) } - start, end, totalPages, err := getPageIndexes(len(allFishermen), int(body.Page), int(body.PerPage)) + start, end, totalPages, err := getPageIndexes(len(allWatchers), int(body.Page), int(body.PerPage)) if err != nil && !errors.Is(err, errNoItems) { return ctx.String(http.StatusBadRequest, err.Error()) } if totalPages == 0 || errors.Is(err, errNoItems) { - return ctx.JSON(http.StatusOK, QueryFishermenResponse{}) + return ctx.JSON(http.StatusOK, QueryWatchersResponse{}) } - rpcFishermen := protocolActorToRPCProtocolActors(allFishermen[start : end+1]) + rpcWatchers := protocolActorToRPCProtocolActors(allWatchers[start : end+1]) - return ctx.JSON(http.StatusOK, QueryFishermenResponse{ - Fishermen: rpcFishermen, - TotalFishermen: int64(len(allFishermen)), - Page: body.Page, - TotalPages: int64(totalPages), + return ctx.JSON(http.StatusOK, QueryWatchersResponse{ + Watchers: rpcWatchers, + TotalWatchers: int64(len(allWatchers)), + Page: body.Page, + TotalPages: int64(totalPages), }) } diff --git a/rpc/utils.go b/rpc/utils.go index 349408bba..b6ea10faf 100644 --- a/rpc/utils.go +++ b/rpc/utils.go @@ -320,16 +320,16 @@ func (s *rpcServer) calculateMessageFeeForActor(actorType coreTypes.ActorType, m case "MessageUnpause": return readCtx.GetStringParam(utilTypes.MessageUnpauseAppFee, height) } - case coreTypes.ActorType_ACTOR_TYPE_FISH: + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: switch messageType { case "MessageStake": - return readCtx.GetStringParam(utilTypes.MessageStakeFishermanFee, height) + return readCtx.GetStringParam(utilTypes.MessageStakeWatcherFee, height) case "MessageEditStake": - return readCtx.GetStringParam(utilTypes.MessageEditStakeFishermanFee, height) + return readCtx.GetStringParam(utilTypes.MessageEditStakeWatcherFee, height) case "MessageUnstake": - return readCtx.GetStringParam(utilTypes.MessageUnstakeFishermanFee, height) + return readCtx.GetStringParam(utilTypes.MessageUnstakeWatcherFee, height) case "MessageUnpause": - return readCtx.GetStringParam(utilTypes.MessageUnpauseFishermanFee, height) + return readCtx.GetStringParam(utilTypes.MessageUnpauseWatcherFee, height) } case coreTypes.ActorType_ACTOR_TYPE_SERVICER: switch messageType { @@ -445,8 +445,8 @@ func protocolActorToRPCActorTypeEnum(protocolActorType coreTypes.ActorType) Acto switch protocolActorType { case coreTypes.ActorType_ACTOR_TYPE_APP: return Application - case coreTypes.ActorType_ACTOR_TYPE_FISH: - return Fisherman + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + return Watcher case coreTypes.ActorType_ACTOR_TYPE_SERVICER: return Servicer case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -461,8 +461,8 @@ func getProtocolActorGetter(persistenceContext modules.PersistenceReadContext, p switch *params.ActorType { case Application: protocolActorGetter = persistenceContext.GetAllApps - case Fisherman: - protocolActorGetter = persistenceContext.GetAllFishermen + case Watcher: + protocolActorGetter = persistenceContext.GetAllWatchers case Servicer: protocolActorGetter = persistenceContext.GetAllServicers case Validator: diff --git a/rpc/v1/openapi.yaml b/rpc/v1/openapi.yaml index c068b4238..300907eeb 100644 --- a/rpc/v1/openapi.yaml +++ b/rpc/v1/openapi.yaml @@ -504,13 +504,13 @@ paths: content: text/plain: example: "description of failure" - /v1/query/fisherman: + /v1/query/watcher: post: tags: - query - summary: Returns the data for the specific fisherman address at a given height + summary: Returns the data for the specific watcher address at a given height requestBody: - description: Request fisherman data at the specified height, height = 0 is used as the latest + description: Request watcher data at the specified height, height = 0 is used as the latest content: application/json: schema: @@ -521,7 +521,7 @@ paths: required: true responses: "200": - description: Returns fisherman data at the specified height + description: Returns watcher data at the specified height content: application/json: schema: @@ -532,17 +532,17 @@ paths: text/plain: example: "description of failure" "500": - description: An error occurred while retrieving the fisherman data at the specified height + description: An error occurred while retrieving the watcher data at the specified height content: text/plain: example: "description of failure" - /v1/query/fishermen: + /v1/query/watchers: post: tags: - query - summary: Returns the data for the all fishermen at the specified height + summary: Returns the data for the all watchers at the specified height requestBody: - description: Request all fishermen data at the specified height, height = 0 is used as the latest; Max per_page=1000 + description: Request all watchers data at the specified height, height = 0 is used as the latest; Max per_page=1000 content: application/json: schema: @@ -554,18 +554,18 @@ paths: required: true responses: "200": - description: Returns all fishermen data at the specified height + description: Returns all watchers data at the specified height content: application/json: schema: - $ref: "#/components/schemas/QueryFishermenResponse" + $ref: "#/components/schemas/QueryWatchersResponse" "400": description: Bad request content: text/plain: example: "description of failure" "500": - description: An error occurred while retrieving all fishermen data at the specified height + description: An error occurred while retrieving all watchers data at the specified height content: text/plain: example: "description of failure" @@ -1265,19 +1265,19 @@ components: properties: block: $ref: "#/components/schemas/Block" - QueryFishermenResponse: + QueryWatchersResponse: type: object required: - - fishermen - - total_fishermen + - watchers + - total_watchers - page - total_pages properties: - fishermen: + watchers: type: array items: $ref: "#/components/schemas/ProtocolActor" - total_fishermen: + total_watchers: type: integer format: int64 page: @@ -1411,7 +1411,7 @@ components: - geozone - application - servicers - - fishermen + - watchers properties: session_id: type: string @@ -1434,7 +1434,7 @@ components: type: array items: $ref: "#/components/schemas/ProtocolActor" - fishermen: + watchers: type: array items: $ref: "#/components/schemas/ProtocolActor" @@ -1461,7 +1461,7 @@ components: enum: - validator - servicer - - fisherman + - watcher - application Actor: type: object diff --git a/runtime/configs/config.go b/runtime/configs/config.go index a4cbb0e53..bcc6fcc5a 100644 --- a/runtime/configs/config.go +++ b/runtime/configs/config.go @@ -31,7 +31,7 @@ type Config struct { Keybase *KeybaseConfig `json:"keybase"` // Determines and configures which keybase to use, `file` or `vault`. IMPROVE(#626): See for rationale around proto design. We have proposed a better config design, but did not implement it due to viper limitations Validator *ValidatorConfig `json:"validator"` Servicer *ServicerConfig `json:"servicer"` - Fisherman *FishermanConfig `json:"fisherman"` + Watcher *WatcherConfig `json:"watcher"` IBC *IBCConfig `json:"ibc"` IBCHost *IBCHostConfig `json:"ibc_host"` } @@ -158,9 +158,9 @@ func NewDefaultConfig(options ...func(*Config)) *Config { VaultMountPath: defaults.DefaultKeybaseVaultMountPath, }, Validator: &ValidatorConfig{}, - // INCOMPLETE(#858): use defaultServicerConfig once the default configuration issue is resolved, i.e. once configuring fisherman disables default servicer - Servicer: &ServicerConfig{}, - Fisherman: &FishermanConfig{}, + // INCOMPLETE(#858): use defaultServicerConfig once the default configuration issue is resolved, i.e. once configuring watcher disables default servicer + Servicer: &ServicerConfig{}, + Watcher: &WatcherConfig{}, IBC: &IBCConfig{ Enabled: defaults.DefaultIBCEnabled, StoresDir: defaults.DefaultIBCStoresDir, diff --git a/runtime/configs/proto/fisherman_config.proto b/runtime/configs/proto/fisherman_config.proto deleted file mode 100644 index 48efb7819..000000000 --- a/runtime/configs/proto/fisherman_config.proto +++ /dev/null @@ -1,12 +0,0 @@ - -syntax = "proto3"; - -package configs; - -option go_package = "github.com/pokt-network/pocket/runtime/configs"; - -// FishermanConfig defines the configuration for the node acting as a fisherman. Fishermen grade and enforce the quality of the Web3 access provided by Servicers -message FishermanConfig { - // Enabled defines whether or not the node is a fisherman. - bool enabled = 1; -} diff --git a/runtime/configs/proto/watcher_config.proto b/runtime/configs/proto/watcher_config.proto new file mode 100644 index 000000000..450011639 --- /dev/null +++ b/runtime/configs/proto/watcher_config.proto @@ -0,0 +1,12 @@ + +syntax = "proto3"; + +package configs; + +option go_package = "github.com/pokt-network/pocket/runtime/configs"; + +// WatcherConfig defines the configuration for the node acting as a watcher. Watchers grade and enforce the quality of the Web3 access provided by Servicers +message WatcherConfig { + // Enabled defines whether or not the node is a watcher. + bool enabled = 1; +} diff --git a/runtime/genesis/proto/genesis.proto b/runtime/genesis/proto/genesis.proto index 5db5100ea..b171b38f0 100644 --- a/runtime/genesis/proto/genesis.proto +++ b/runtime/genesis/proto/genesis.proto @@ -17,11 +17,10 @@ message GenesisState { repeated core.Actor applications = 6; repeated core.Actor validators = 7; repeated core.Actor servicers = 8; - repeated core.Actor fishermen = 9; + repeated core.Actor watchers = 9; Params params = 10; } -// TODO: Rename the appropriate fields from `fisherman_` to `fishermen_` or `fisherbeing_`, etc... // TECHDEBT: Explore a more general purpose "feature flag" approach that makes it easy to add/remove // parameters and add activation heights for them as well. @@ -53,18 +52,18 @@ message Params { //@gotags: pokt:"val_type=SMALLINT,owner=servicers_per_session_owner" int32 servicers_per_session = 13; - //@gotags: pokt:"val_type=STRING,owner=fisherman_minimum_stake_owner" - string fisherman_minimum_stake = 14; - //@gotags: pokt:"val_type=SMALLINT,owner=fisherman_max_chains_owner" - int32 fisherman_max_chains = 15; - //@gotags: pokt:"val_type=BIGINT,owner=fisherman_unstaking_blocks_owner" - int32 fisherman_unstaking_blocks = 16; - //@gotags: pokt:"val_type=SMALLINT,owner=fisherman_minimum_pause_blocks_owner" - int32 fisherman_minimum_pause_blocks = 17; - //@gotags: pokt:"val_type=SMALLINT,owner=fisherman_max_paused_blocks_owner" - int32 fisherman_max_pause_blocks = 18; - //@gotags: pokt:"val_type=SMALLINT,owner=fisherman_per_session_owner" - int32 fisherman_per_session = 19; + //@gotags: pokt:"val_type=STRING,owner=watcher_minimum_stake_owner" + string watcher_minimum_stake = 14; + //@gotags: pokt:"val_type=SMALLINT,owner=watcher_max_chains_owner" + int32 watcher_max_chains = 15; + //@gotags: pokt:"val_type=BIGINT,owner=watcher_unstaking_blocks_owner" + int32 watcher_unstaking_blocks = 16; + //@gotags: pokt:"val_type=SMALLINT,owner=watcher_minimum_pause_blocks_owner" + int32 watcher_minimum_pause_blocks = 17; + //@gotags: pokt:"val_type=SMALLINT,owner=watcher_max_paused_blocks_owner" + int32 watcher_max_pause_blocks = 18; + //@gotags: pokt:"val_type=SMALLINT,owner=watcher_per_session_owner" + int32 watcher_per_session = 19; //@gotags: pokt:"val_type=STRING,owner=validator_minimum_stake_owner" string validator_minimum_stake = 20; @@ -90,18 +89,18 @@ message Params { string message_double_sign_fee = 29; //@gotags: pokt:"val_type=STRING,owner=message_send_fee_owner" string message_send_fee = 30; - //@gotags: pokt:"val_type=STRING,owner=message_stake_fisherman_fee_owner" - string message_stake_fisherman_fee = 31; - //@gotags: pokt:"val_type=STRING,owner=message_edit_stake_fisherman_fee_owner" - string message_edit_stake_fisherman_fee = 32; - //@gotags: pokt:"val_type=STRING,owner=message_unstake_fisherman_fee_owner" - string message_unstake_fisherman_fee = 33; - //@gotags: pokt:"val_type=STRING,owner=message_pause_fisherman_fee_owner" - string message_pause_fisherman_fee = 34; - //@gotags: pokt:"val_type=STRING,owner=message_unpause_fisherman_fee_owner" - string message_unpause_fisherman_fee = 35; - //@gotags: pokt:"val_type=STRING,owner=message_fisherman_pause_servicer_fee_owner" - string message_fisherman_pause_servicer_fee = 36; + //@gotags: pokt:"val_type=STRING,owner=message_stake_watcher_fee_owner" + string message_stake_watcher_fee = 31; + //@gotags: pokt:"val_type=STRING,owner=message_edit_stake_watcher_fee_owner" + string message_edit_stake_watcher_fee = 32; + //@gotags: pokt:"val_type=STRING,owner=message_unstake_watcher_fee_owner" + string message_unstake_watcher_fee = 33; + //@gotags: pokt:"val_type=STRING,owner=message_pause_watcher_fee_owner" + string message_pause_watcher_fee = 34; + //@gotags: pokt:"val_type=STRING,owner=message_unpause_watcher_fee_owner" + string message_unpause_watcher_fee = 35; + //@gotags: pokt:"val_type=STRING,owner=message_watcher_pause_servicer_fee_owner" + string message_watcher_pause_servicer_fee = 36; //@gotags: pokt:"val_type=STRING,owner=message_test_score_fee_owner" string message_test_score_fee = 37; //@gotags: pokt:"val_type=STRING,owner=message_prove_test_score_fee_owner" @@ -168,17 +167,17 @@ message Params { //@gotags: pokt:"val_type=STRING,owner=acl_owner" string servicers_per_session_owner = 68; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string fisherman_minimum_stake_owner = 69; + string watcher_minimum_stake_owner = 69; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string fisherman_max_chains_owner = 70; + string watcher_max_chains_owner = 70; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string fisherman_unstaking_blocks_owner = 71; + string watcher_unstaking_blocks_owner = 71; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string fisherman_minimum_pause_blocks_owner = 72; + string watcher_minimum_pause_blocks_owner = 72; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string fisherman_max_paused_blocks_owner = 73; + string watcher_max_paused_blocks_owner = 73; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string fisherman_per_session_owner = 74; + string watcher_per_session_owner = 74; //@gotags: pokt:"val_type=STRING,owner=acl_owner" string validator_minimum_stake_owner = 75; //@gotags: pokt:"val_type=STRING,owner=acl_owner" @@ -202,17 +201,17 @@ message Params { //@gotags: pokt:"val_type=STRING,owner=acl_owner" string message_send_fee_owner = 85; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string message_stake_fisherman_fee_owner = 86; + string message_stake_watcher_fee_owner = 86; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string message_edit_stake_fisherman_fee_owner = 87; + string message_edit_stake_watcher_fee_owner = 87; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string message_unstake_fisherman_fee_owner = 88; + string message_unstake_watcher_fee_owner = 88; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string message_pause_fisherman_fee_owner = 89; + string message_pause_watcher_fee_owner = 89; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string message_unpause_fisherman_fee_owner = 90; + string message_unpause_watcher_fee_owner = 90; //@gotags: pokt:"val_type=STRING,owner=acl_owner" - string message_fisherman_pause_servicer_fee_owner = 91; + string message_watcher_pause_servicer_fee_owner = 91; //@gotags: pokt:"val_type=STRING,owner=acl_owner" string message_test_score_fee_owner = 92; //@gotags: pokt:"val_type=STRING,owner=acl_owner" diff --git a/runtime/manager_test.go b/runtime/manager_test.go index dbd1b009f..b92457f03 100644 --- a/runtime/manager_test.go +++ b/runtime/manager_test.go @@ -46,7 +46,7 @@ var expectedGenesis = &genesis.GenesisState{ Amount: "100000000000000", }, { - Address: "4669736865726d616e5374616b65506f6f6c0000", + Address: "576174636865725374616b65506f6f6c00000000", Amount: "100000000000000", }, }, @@ -1718,13 +1718,13 @@ var expectedGenesis = &genesis.GenesisState{ Output: "001022b138896c4c5466ac86b24a9bbe249905c2", }, }, - Fishermen: []*types.Actor{ + Watchers: []*types.Actor{ { - ActorType: types.ActorType_ACTOR_TYPE_FISH, + ActorType: types.ActorType_ACTOR_TYPE_WATCHER, Address: "0010336c3a2cc1ec71fecc45c360214f757194aa", PublicKey: "d913a05a6f4bde35413bdcc6343238960cfc7d8aff425fb712dcaa52f1476dbf", Chains: []string{"0001"}, - ServiceUrl: "fisherman1:42069", + ServiceUrl: "watcher1:42069", StakedAmount: "1000000000000", PausedHeight: -1, UnstakingHeight: -1, @@ -1819,7 +1819,7 @@ func TestNewManagerFromReaders(t *testing.T) { Keybase: defaultCfg.Keybase, Servicer: &configs.ServicerConfig{Enabled: true}, Validator: &configs.ValidatorConfig{Enabled: true}, - Fisherman: defaultCfg.Fisherman, + Watcher: defaultCfg.Watcher, IBC: &configs.IBCConfig{ Enabled: true, StoresDir: defaults.DefaultIBCStoresDir, diff --git a/runtime/test_artifacts/defaults.go b/runtime/test_artifacts/defaults.go index c9c8f3074..a8fce157e 100644 --- a/runtime/test_artifacts/defaults.go +++ b/runtime/test_artifacts/defaults.go @@ -28,114 +28,114 @@ var ( func DefaultParams() *genesis.Params { return &genesis.Params{ - BlocksPerSession: 1, - AppMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), - AppMaxChains: 15, - AppSessionTokensMultiplier: 100, - AppUnstakingBlocks: 2016, - AppMinimumPauseBlocks: 4, - AppMaxPauseBlocks: 672, - ServicerMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), - ServicerMaxChains: 15, - ServicerUnstakingBlocks: 2016, - ServicerMinimumPauseBlocks: 4, - ServicerMaxPauseBlocks: 672, - ServicersPerSession: 24, - FishermanMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), - FishermanMaxChains: 15, - FishermanUnstakingBlocks: 2016, - FishermanMinimumPauseBlocks: 4, - FishermanMaxPauseBlocks: 672, - FishermanPerSession: 1, - ValidatorMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), - ValidatorUnstakingBlocks: 2016, - ValidatorMinimumPauseBlocks: 4, - ValidatorMaxPauseBlocks: 672, - ValidatorMaximumMissedBlocks: 5, - ValidatorMaxEvidenceAgeInBlocks: 8, - ProposerPercentageOfFees: 10, - MissedBlocksBurnPercentage: 1, - DoubleSignBurnPercentage: 5, - MessageDoubleSignFee: utils.BigIntToString(big.NewInt(10000)), - MessageSendFee: utils.BigIntToString(big.NewInt(10000)), - MessageStakeFishermanFee: utils.BigIntToString(big.NewInt(10000)), - MessageEditStakeFishermanFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnstakeFishermanFee: utils.BigIntToString(big.NewInt(10000)), - MessagePauseFishermanFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnpauseFishermanFee: utils.BigIntToString(big.NewInt(10000)), - MessageFishermanPauseServicerFee: utils.BigIntToString(big.NewInt(10000)), - MessageTestScoreFee: utils.BigIntToString(big.NewInt(10000)), - MessageProveTestScoreFee: utils.BigIntToString(big.NewInt(10000)), - MessageStakeAppFee: utils.BigIntToString(big.NewInt(10000)), - MessageEditStakeAppFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnstakeAppFee: utils.BigIntToString(big.NewInt(10000)), - MessagePauseAppFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnpauseAppFee: utils.BigIntToString(big.NewInt(10000)), - MessageStakeValidatorFee: utils.BigIntToString(big.NewInt(10000)), - MessageEditStakeValidatorFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnstakeValidatorFee: utils.BigIntToString(big.NewInt(10000)), - MessagePauseValidatorFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnpauseValidatorFee: utils.BigIntToString(big.NewInt(10000)), - MessageStakeServicerFee: utils.BigIntToString(big.NewInt(10000)), - MessageEditStakeServicerFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnstakeServicerFee: utils.BigIntToString(big.NewInt(10000)), - MessagePauseServicerFee: utils.BigIntToString(big.NewInt(10000)), - MessageUnpauseServicerFee: utils.BigIntToString(big.NewInt(10000)), - MessageChangeParameterFee: utils.BigIntToString(big.NewInt(10000)), - AclOwner: DefaultParamsOwner.Address().String(), - BlocksPerSessionOwner: DefaultParamsOwner.Address().String(), - AppMinimumStakeOwner: DefaultParamsOwner.Address().String(), - AppMaxChainsOwner: DefaultParamsOwner.Address().String(), - AppSessionTokensMultiplierOwner: DefaultParamsOwner.Address().String(), - AppUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), - AppMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), - AppMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), - ServicerMinimumStakeOwner: DefaultParamsOwner.Address().String(), - ServicerMaxChainsOwner: DefaultParamsOwner.Address().String(), - ServicerUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), - ServicerMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), - ServicerMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), - ServicersPerSessionOwner: DefaultParamsOwner.Address().String(), - FishermanMinimumStakeOwner: DefaultParamsOwner.Address().String(), - FishermanMaxChainsOwner: DefaultParamsOwner.Address().String(), - FishermanUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), - FishermanMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), - FishermanMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), - FishermanPerSessionOwner: DefaultParamsOwner.Address().String(), - ValidatorMinimumStakeOwner: DefaultParamsOwner.Address().String(), - ValidatorUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), - ValidatorMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), - ValidatorMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), - ValidatorMaximumMissedBlocksOwner: DefaultParamsOwner.Address().String(), - ValidatorMaxEvidenceAgeInBlocksOwner: DefaultParamsOwner.Address().String(), - ProposerPercentageOfFeesOwner: DefaultParamsOwner.Address().String(), - MissedBlocksBurnPercentageOwner: DefaultParamsOwner.Address().String(), - DoubleSignBurnPercentageOwner: DefaultParamsOwner.Address().String(), - MessageDoubleSignFeeOwner: DefaultParamsOwner.Address().String(), - MessageSendFeeOwner: DefaultParamsOwner.Address().String(), - MessageStakeFishermanFeeOwner: DefaultParamsOwner.Address().String(), - MessageEditStakeFishermanFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnstakeFishermanFeeOwner: DefaultParamsOwner.Address().String(), - MessagePauseFishermanFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnpauseFishermanFeeOwner: DefaultParamsOwner.Address().String(), - MessageFishermanPauseServicerFeeOwner: DefaultParamsOwner.Address().String(), - MessageTestScoreFeeOwner: DefaultParamsOwner.Address().String(), - MessageProveTestScoreFeeOwner: DefaultParamsOwner.Address().String(), - MessageStakeAppFeeOwner: DefaultParamsOwner.Address().String(), - MessageEditStakeAppFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnstakeAppFeeOwner: DefaultParamsOwner.Address().String(), - MessagePauseAppFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnpauseAppFeeOwner: DefaultParamsOwner.Address().String(), - MessageStakeValidatorFeeOwner: DefaultParamsOwner.Address().String(), - MessageEditStakeValidatorFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnstakeValidatorFeeOwner: DefaultParamsOwner.Address().String(), - MessagePauseValidatorFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnpauseValidatorFeeOwner: DefaultParamsOwner.Address().String(), - MessageStakeServicerFeeOwner: DefaultParamsOwner.Address().String(), - MessageEditStakeServicerFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnstakeServicerFeeOwner: DefaultParamsOwner.Address().String(), - MessagePauseServicerFeeOwner: DefaultParamsOwner.Address().String(), - MessageUnpauseServicerFeeOwner: DefaultParamsOwner.Address().String(), - MessageChangeParameterFeeOwner: DefaultParamsOwner.Address().String(), + BlocksPerSession: 1, + AppMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), + AppMaxChains: 15, + AppSessionTokensMultiplier: 100, + AppUnstakingBlocks: 2016, + AppMinimumPauseBlocks: 4, + AppMaxPauseBlocks: 672, + ServicerMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), + ServicerMaxChains: 15, + ServicerUnstakingBlocks: 2016, + ServicerMinimumPauseBlocks: 4, + ServicerMaxPauseBlocks: 672, + ServicersPerSession: 24, + WatcherMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), + WatcherMaxChains: 15, + WatcherUnstakingBlocks: 2016, + WatcherMinimumPauseBlocks: 4, + WatcherMaxPauseBlocks: 672, + WatcherPerSession: 1, + ValidatorMinimumStake: utils.BigIntToString(big.NewInt(15000000000)), + ValidatorUnstakingBlocks: 2016, + ValidatorMinimumPauseBlocks: 4, + ValidatorMaxPauseBlocks: 672, + ValidatorMaximumMissedBlocks: 5, + ValidatorMaxEvidenceAgeInBlocks: 8, + ProposerPercentageOfFees: 10, + MissedBlocksBurnPercentage: 1, + DoubleSignBurnPercentage: 5, + MessageDoubleSignFee: utils.BigIntToString(big.NewInt(10000)), + MessageSendFee: utils.BigIntToString(big.NewInt(10000)), + MessageStakeWatcherFee: utils.BigIntToString(big.NewInt(10000)), + MessageEditStakeWatcherFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnstakeWatcherFee: utils.BigIntToString(big.NewInt(10000)), + MessagePauseWatcherFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnpauseWatcherFee: utils.BigIntToString(big.NewInt(10000)), + MessageWatcherPauseServicerFee: utils.BigIntToString(big.NewInt(10000)), + MessageTestScoreFee: utils.BigIntToString(big.NewInt(10000)), + MessageProveTestScoreFee: utils.BigIntToString(big.NewInt(10000)), + MessageStakeAppFee: utils.BigIntToString(big.NewInt(10000)), + MessageEditStakeAppFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnstakeAppFee: utils.BigIntToString(big.NewInt(10000)), + MessagePauseAppFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnpauseAppFee: utils.BigIntToString(big.NewInt(10000)), + MessageStakeValidatorFee: utils.BigIntToString(big.NewInt(10000)), + MessageEditStakeValidatorFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnstakeValidatorFee: utils.BigIntToString(big.NewInt(10000)), + MessagePauseValidatorFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnpauseValidatorFee: utils.BigIntToString(big.NewInt(10000)), + MessageStakeServicerFee: utils.BigIntToString(big.NewInt(10000)), + MessageEditStakeServicerFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnstakeServicerFee: utils.BigIntToString(big.NewInt(10000)), + MessagePauseServicerFee: utils.BigIntToString(big.NewInt(10000)), + MessageUnpauseServicerFee: utils.BigIntToString(big.NewInt(10000)), + MessageChangeParameterFee: utils.BigIntToString(big.NewInt(10000)), + AclOwner: DefaultParamsOwner.Address().String(), + BlocksPerSessionOwner: DefaultParamsOwner.Address().String(), + AppMinimumStakeOwner: DefaultParamsOwner.Address().String(), + AppMaxChainsOwner: DefaultParamsOwner.Address().String(), + AppSessionTokensMultiplierOwner: DefaultParamsOwner.Address().String(), + AppUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), + AppMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), + AppMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), + ServicerMinimumStakeOwner: DefaultParamsOwner.Address().String(), + ServicerMaxChainsOwner: DefaultParamsOwner.Address().String(), + ServicerUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), + ServicerMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), + ServicerMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), + ServicersPerSessionOwner: DefaultParamsOwner.Address().String(), + WatcherMinimumStakeOwner: DefaultParamsOwner.Address().String(), + WatcherMaxChainsOwner: DefaultParamsOwner.Address().String(), + WatcherUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), + WatcherMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), + WatcherMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), + WatcherPerSessionOwner: DefaultParamsOwner.Address().String(), + ValidatorMinimumStakeOwner: DefaultParamsOwner.Address().String(), + ValidatorUnstakingBlocksOwner: DefaultParamsOwner.Address().String(), + ValidatorMinimumPauseBlocksOwner: DefaultParamsOwner.Address().String(), + ValidatorMaxPausedBlocksOwner: DefaultParamsOwner.Address().String(), + ValidatorMaximumMissedBlocksOwner: DefaultParamsOwner.Address().String(), + ValidatorMaxEvidenceAgeInBlocksOwner: DefaultParamsOwner.Address().String(), + ProposerPercentageOfFeesOwner: DefaultParamsOwner.Address().String(), + MissedBlocksBurnPercentageOwner: DefaultParamsOwner.Address().String(), + DoubleSignBurnPercentageOwner: DefaultParamsOwner.Address().String(), + MessageDoubleSignFeeOwner: DefaultParamsOwner.Address().String(), + MessageSendFeeOwner: DefaultParamsOwner.Address().String(), + MessageStakeWatcherFeeOwner: DefaultParamsOwner.Address().String(), + MessageEditStakeWatcherFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnstakeWatcherFeeOwner: DefaultParamsOwner.Address().String(), + MessagePauseWatcherFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnpauseWatcherFeeOwner: DefaultParamsOwner.Address().String(), + MessageWatcherPauseServicerFeeOwner: DefaultParamsOwner.Address().String(), + MessageTestScoreFeeOwner: DefaultParamsOwner.Address().String(), + MessageProveTestScoreFeeOwner: DefaultParamsOwner.Address().String(), + MessageStakeAppFeeOwner: DefaultParamsOwner.Address().String(), + MessageEditStakeAppFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnstakeAppFeeOwner: DefaultParamsOwner.Address().String(), + MessagePauseAppFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnpauseAppFeeOwner: DefaultParamsOwner.Address().String(), + MessageStakeValidatorFeeOwner: DefaultParamsOwner.Address().String(), + MessageEditStakeValidatorFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnstakeValidatorFeeOwner: DefaultParamsOwner.Address().String(), + MessagePauseValidatorFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnpauseValidatorFeeOwner: DefaultParamsOwner.Address().String(), + MessageStakeServicerFeeOwner: DefaultParamsOwner.Address().String(), + MessageEditStakeServicerFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnstakeServicerFeeOwner: DefaultParamsOwner.Address().String(), + MessagePauseServicerFeeOwner: DefaultParamsOwner.Address().String(), + MessageUnpauseServicerFeeOwner: DefaultParamsOwner.Address().String(), + MessageChangeParameterFeeOwner: DefaultParamsOwner.Address().String(), } } diff --git a/runtime/test_artifacts/generator.go b/runtime/test_artifacts/generator.go index 02241381e..33af2ae2b 100644 --- a/runtime/test_artifacts/generator.go +++ b/runtime/test_artifacts/generator.go @@ -22,7 +22,7 @@ func NewGenesisState( numValidators, numServicers, numApplications, - numFisherman int, + numWatcher int, genesisOpts ...GenesisOption, ) ( genesisState *genesis.GenesisState, @@ -31,9 +31,9 @@ func NewGenesisState( applications, appPrivateKeys := NewActors(coreTypes.ActorType_ACTOR_TYPE_APP, numApplications, DefaultChains) validators, validatorPrivateKeys := NewActors(coreTypes.ActorType_ACTOR_TYPE_VAL, numValidators, nil) servicers, servicerPrivateKeys := NewActors(coreTypes.ActorType_ACTOR_TYPE_SERVICER, numServicers, DefaultChains) - fishermen, fishPrivateKeys := NewActors(coreTypes.ActorType_ACTOR_TYPE_FISH, numFisherman, DefaultChains) + watchers, watcherPrivateKeys := NewActors(coreTypes.ActorType_ACTOR_TYPE_WATCHER, numWatcher, DefaultChains) - allActorsKeys := append(append(append(validatorPrivateKeys, servicerPrivateKeys...), fishPrivateKeys...), appPrivateKeys...) + allActorsKeys := append(append(append(validatorPrivateKeys, servicerPrivateKeys...), watcherPrivateKeys...), appPrivateKeys...) allActorAccounts := newAccountsWithKeys(allActorsKeys) genesisState = &genesis.GenesisState{ @@ -45,7 +45,7 @@ func NewGenesisState( Applications: applications, Validators: validators, Servicers: servicers, - Fishermen: fishermen, + Watchers: watchers, Params: DefaultParams(), } @@ -69,8 +69,8 @@ func WithActors(actors []*coreTypes.Actor, actorKeys []string) func(*genesis.Gen genesis.Validators = append(genesis.Validators, actor) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: genesis.Servicers = append(genesis.Servicers, actor) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - genesis.Fishermen = append(genesis.Fishermen, actor) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + genesis.Watchers = append(genesis.Watchers, actor) default: panic(fmt.Sprintf("invalid actor type: %s", actor.ActorType)) } diff --git a/shared/core/types/error.go b/shared/core/types/error.go index 69369cced..842a8b354 100644 --- a/shared/core/types/error.go +++ b/shared/core/types/error.go @@ -151,7 +151,7 @@ const ( CodeTransactionAlreadyCommittedError Code = 95 CodeTransactionNotCommittedError Code = 135 CodeInitGenesisParamsError Code = 96 - CodeGetAllFishermenError Code = 97 + CodeGetAllWatchersError Code = 97 CodeGetAllServicersError Code = 98 CodeGetAllAppsError Code = 99 CodeNewPersistenceContextError Code = 100 @@ -322,7 +322,7 @@ const ( ProtoNewAnyError = "an error occurred creating the protobuf any" UpdateParamError = "an error occurred updating the parameter" InitGenesisParamError = "an error occurred initializing the params in genesis" - GetAllFishermenError = "an error occurred getting all of the fishermen¬" + GetAllWatchersError = "an error occurred getting all of the watchers¬" GetAllAppsError = "an error occurred getting all of the apps" GetAllServicersError = "an error occurred getting all of the servicers" GetAllPoolsError = "an error occurred getting all of the pools" @@ -762,8 +762,8 @@ func ErrGetAllValidators(err error) Error { return NewError(CodeGetAllValidatorsError, fmt.Sprintf("%s: %s", GetAllValidatorsError, err.Error())) } -func ErrGetAllFishermen(err error) Error { - return NewError(CodeGetAllFishermenError, fmt.Sprintf("%s: %s", GetAllFishermenError, err.Error())) +func ErrGetAllWatchers(err error) Error { + return NewError(CodeGetAllWatchersError, fmt.Sprintf("%s: %s", GetAllWatchersError, err.Error())) } func ErrGetAllApps(err error) Error { diff --git a/shared/core/types/pools.go b/shared/core/types/pools.go index f6f2a0519..3b523bf53 100644 --- a/shared/core/types/pools.go +++ b/shared/core/types/pools.go @@ -12,7 +12,7 @@ func init() { Pools_POOLS_APP_STAKE: "AppStakePool", Pools_POOLS_VALIDATOR_STAKE: "ValidatorStakePool", Pools_POOLS_SERVICER_STAKE: "ServicerStakePool", - Pools_POOLS_FISHERMAN_STAKE: "FishermanStakePool", + Pools_POOLS_WATCHER_STAKE: "WatcherStakePool", } // poolAddresses is a map of pools to their addresses. This is to avoid using the hack of using the pool name as the address @@ -23,7 +23,7 @@ func init() { Pools_POOLS_APP_STAKE: []byte("4170705374616b65506f6f6c0000000000000000"), Pools_POOLS_VALIDATOR_STAKE: []byte("56616c696461746f725374616b65506f6f6c0000"), Pools_POOLS_SERVICER_STAKE: []byte("53657276696365725374616b65506f6f6c000000"), - Pools_POOLS_FISHERMAN_STAKE: []byte("4669736865726d616e5374616b65506f6f6c0000"), + Pools_POOLS_WATCHER_STAKE: []byte("576174636865725374616b65506f6f6c00000000"), } poolAddressToFriendlyName = map[string]string{ @@ -33,7 +33,7 @@ func init() { "4170705374616b65506f6f6c0000000000000000": "AppStakePool", "56616c696461746f725374616b65506f6f6c0000": "ValidatorStakePool", "53657276696365725374616b65506f6f6c000000": "ServicerStakePool", - "4669736865726d616e5374616b65506f6f6c0000": "FishermanStakePool", + "576174636865725374616b65506f6f6c00000000": "WatcherStakePool", } } diff --git a/shared/core/types/proto/actor.proto b/shared/core/types/proto/actor.proto index 28378eb45..4089c7fdb 100644 --- a/shared/core/types/proto/actor.proto +++ b/shared/core/types/proto/actor.proto @@ -8,7 +8,7 @@ enum ActorType { ACTOR_TYPE_UNSPECIFIED = 0; ACTOR_TYPE_APP = 1; ACTOR_TYPE_SERVICER = 2; - ACTOR_TYPE_FISH = 3; + ACTOR_TYPE_WATCHER = 3; ACTOR_TYPE_VAL = 4; } diff --git a/shared/core/types/proto/pools.proto b/shared/core/types/proto/pools.proto index ba9ec0997..d9f5645fa 100644 --- a/shared/core/types/proto/pools.proto +++ b/shared/core/types/proto/pools.proto @@ -11,5 +11,5 @@ enum Pools { POOLS_APP_STAKE = 3; POOLS_VALIDATOR_STAKE = 4; POOLS_SERVICER_STAKE = 5; - POOLS_FISHERMAN_STAKE = 6; + POOLS_WATCHER_STAKE = 6; } diff --git a/shared/core/types/proto/session.proto b/shared/core/types/proto/session.proto index e0e584f5e..e4e396a05 100644 --- a/shared/core/types/proto/session.proto +++ b/shared/core/types/proto/session.proto @@ -6,7 +6,7 @@ option go_package = "github.com/pokt-network/pocket/shared/core/types"; import "actor.proto"; -// A deterministic pseudo-random structure that pairs applications to a set of servicers and fishermen +// A deterministic pseudo-random structure that pairs applications to a set of servicers and watchers // using on-chain data as a source of entropy message Session { string id = 1; // a universally unique ID for the session @@ -22,5 +22,5 @@ message Session { core.Actor application = 7; // the application that is being served // IMPROVE: `map` with the address as the key can simplify and optimize the logic on the clients repeated core.Actor servicers = 8; // the set of servicers that are serving the application - repeated core.Actor fishermen = 9; // the set of fishermen that are fishing for servicers + repeated core.Actor watchers = 9; // the set of watchers that are monitoring servicers } diff --git a/shared/k8s/debug.go b/shared/k8s/debug.go index a340fcfda..69a3ddfef 100644 --- a/shared/k8s/debug.go +++ b/shared/k8s/debug.go @@ -19,7 +19,7 @@ import ( const ( privateKeysSecretResourceNameValidators = "validators-private-keys" privateKeysSecretResourceNameServicers = "servicers-private-keys" - privateKeysSecretResourceNameFishermen = "fishermen-private-keys" + privateKeysSecretResourceNameWatchers = "watchers-private-keys" privateKeysSecretResourceNameApplications = "applications-private-keys" kubernetesServiceAccountNamespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace" defaultNamespace = "default" @@ -50,10 +50,10 @@ func FetchServicerPrivateKeys(clientset *kubernetes.Clientset) (map[string]strin return fetchPrivateKeys(clientset, privateKeysSecretResourceNameServicers) } -// FetchFishermanPrivateKeys returns a map corresponding to the data section of -// the fisherman private keys Kubernetes secret. -func FetchFishermanPrivateKeys(clientset *kubernetes.Clientset) (map[string]string, error) { - return fetchPrivateKeys(clientset, privateKeysSecretResourceNameFishermen) +// FetchWatcherPrivateKeys returns a map corresponding to the data section of +// the watcher private keys Kubernetes secret. +func FetchWatcherPrivateKeys(clientset *kubernetes.Clientset) (map[string]string, error) { + return fetchPrivateKeys(clientset, privateKeysSecretResourceNameWatchers) } // FetchApplicationPrivateKeys returns a map corresponding to the data section of diff --git a/shared/modules/persistence_module.go b/shared/modules/persistence_module.go index 38c7681ba..db6a587f6 100644 --- a/shared/modules/persistence_module.go +++ b/shared/modules/persistence_module.go @@ -68,7 +68,7 @@ type PersistenceRWContext interface { } // REFACTOR: Simplify the interface -// - Add general purpose methods such as `ActorOperation(enum_actor_type, ...)` which can be use like so: `Insert(FISHERMAN, ...)` +// - Add general purpose methods such as `ActorOperation(enum_actor_type, ...)` which can be use like so: `Insert(WATCHER, ...)` // - Use general purpose parameter methods such as `Set(enum_gov_type, ...)` such as `Set(STAKING_, ...)` // - Reference: https://dave.cheney.net/practical-go/presentations/gophercon-israel.html#_prefer_single_method_interfaces @@ -125,13 +125,13 @@ type PersistenceWriteContext interface { SetServicerStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unstakingHeight int64, status int32) error SetServicerPauseHeight(address []byte, height int64) error - // Fisherman Operations - InsertFisherman(address []byte, publicKey []byte, output []byte, paused bool, status int32, serviceURL string, stakedTokens string, chains []string, pausedHeight int64, unstakingHeight int64) error - UpdateFisherman(address []byte, serviceURL string, amount string, chains []string) error - SetFishermanStakeAmount(address []byte, stakeAmount string) error - SetFishermanUnstakingHeightAndStatus(address []byte, unstakingHeight int64, status int32) error - SetFishermanStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unstakingHeight int64, status int32) error - SetFishermanPauseHeight(address []byte, height int64) error + // Watcher Operations + InsertWatcher(address []byte, publicKey []byte, output []byte, paused bool, status int32, serviceURL string, stakedTokens string, chains []string, pausedHeight int64, unstakingHeight int64) error + UpdateWatcher(address []byte, serviceURL string, amount string, chains []string) error + SetWatcherStakeAmount(address []byte, stakeAmount string) error + SetWatcherUnstakingHeightAndStatus(address []byte, unstakingHeight int64, status int32) error + SetWatcherStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unstakingHeight int64, status int32) error + SetWatcherPauseHeight(address []byte, height int64) error // Validator Operations InsertValidator(address []byte, publicKey []byte, output []byte, paused bool, status int32, serviceURL string, stakedTokens string, pausedHeight int64, unstakingHeight int64) error @@ -217,15 +217,15 @@ type PersistenceReadContext interface { GetServicerOutputAddress(operator []byte, height int64) (output []byte, err error) GetServicerCount(chain string, height int64) (int, error) - // Fisherman Queries - GetFisherman(address []byte, height int64) (*coreTypes.Actor, error) - GetAllFishermen(height int64) ([]*coreTypes.Actor, error) - GetFishermanExists(address []byte, height int64) (exists bool, err error) - GetFishermanStakeAmount(height int64, address []byte) (string, error) - GetFishermenReadyToUnstake(height int64, status int32) (fishermen []*moduleTypes.UnstakingActor, err error) - GetFishermanStatus(address []byte, height int64) (status int32, err error) - GetFishermanPauseHeightIfExists(address []byte, height int64) (int64, error) - GetFishermanOutputAddress(operator []byte, height int64) (output []byte, err error) + // Watcher Queries + GetWatcher(address []byte, height int64) (*coreTypes.Actor, error) + GetAllWatchers(height int64) ([]*coreTypes.Actor, error) + GetWatcherExists(address []byte, height int64) (exists bool, err error) + GetWatcherStakeAmount(height int64, address []byte) (string, error) + GetWatchersReadyToUnstake(height int64, status int32) (watchers []*moduleTypes.UnstakingActor, err error) + GetWatcherStatus(address []byte, height int64) (status int32, err error) + GetWatcherPauseHeightIfExists(address []byte, height int64) (int64, error) + GetWatcherOutputAddress(operator []byte, height int64) (output []byte, err error) // Validator Queries GetValidator(address []byte, height int64) (*coreTypes.Actor, error) diff --git a/shared/modules/utility_module.go b/shared/modules/utility_module.go index 720a4fa09..3e2fe9d88 100644 --- a/shared/modules/utility_module.go +++ b/shared/modules/utility_module.go @@ -48,8 +48,8 @@ type UtilityModule interface { // GetActorModules returns the utility module's actor modules GetActorModules() map[string]Module - // GetFishermanModule returns the utility module's fisherman module if enabled - GetFishermanModule() (FishermanModule, error) + // GetWatcherModule returns the utility module's watcher module if enabled + GetWatcherModule() (WatcherModule, error) // GetServicerModule returns the utility module's servicer module if enabled GetServicerModule() (ServicerModule, error) @@ -58,7 +58,7 @@ type UtilityModule interface { GetValidatorModule() (ValidatorModule, error) } -type FishermanModule interface { +type WatcherModule interface { Module } diff --git a/utility/doc/E2E_FEATURE_LIST.md b/utility/doc/E2E_FEATURE_LIST.md index 483d7e2b2..e5128d868 100644 --- a/utility/doc/E2E_FEATURE_LIST.md +++ b/utility/doc/E2E_FEATURE_LIST.md @@ -14,13 +14,13 @@ - [2. Servicer Relay Rewards - Non-Custodial 🟡](#2-servicer-relay-rewards---non-custodial-) - [3. Servicer Relay Rewards - Rev-Share 🔵](#3-servicer-relay-rewards---rev-share-) - [4. Validator - Block Rewards 🟡](#4-validator---block-rewards-) - - [5. Fisherman - QoS Submission Rewards ⭐](#5-fisherman---qos-submission-rewards-) + - [5. Watcher - QoS Submission Rewards ⭐](#5-watcher---qos-submission-rewards-) - [D. E2E Burns \& Slashes](#d-e2e-burns--slashes) - [1. Validator - Double-Sign Burn 🔴](#1-validator---double-sign-burn-) - [2. Application - Application Quota Stake Burn 🟢🔴](#2-application---application-quota-stake-burn-) - [3. Servicer - Inaccurate Challenged Response 🔵](#3-servicer---inaccurate-challenged-response-) - - [4. Fisherman - Missing Test Score Burn ⭐](#4-fisherman---missing-test-score-burn-) - - [5. Fisherman - Incomplete Test Score Burn ⭐](#5-fisherman---incomplete-test-score-burn-) + - [4. Watcher - Missing Test Score Burn ⭐](#4-watcher---missing-test-score-burn-) + - [5. Watcher - Incomplete Test Score Burn ⭐](#5-watcher---incomplete-test-score-burn-) - [E. E2E PoS Functionality](#e-e2e-pos-functionality) - [1. Actor Staking 🟡](#1-actor-staking-) - [2. Actor Unstaking 🟡](#2-actor-unstaking-) @@ -85,7 +85,7 @@ ### 4. Validator - Block Rewards 🟡 -### 5. Fisherman - QoS Submission Rewards ⭐ +### 5. Watcher - QoS Submission Rewards ⭐ ## D. E2E Burns & Slashes @@ -95,9 +95,9 @@ ### 3. Servicer - Inaccurate Challenged Response 🔵 -### 4. Fisherman - Missing Test Score Burn ⭐ +### 4. Watcher - Missing Test Score Burn ⭐ -### 5. Fisherman - Incomplete Test Score Burn ⭐ +### 5. Watcher - Incomplete Test Score Burn ⭐ ## E. E2E PoS Functionality diff --git a/utility/doc/E2E_FEATURE_PATH_TEMPLATE.md b/utility/doc/E2E_FEATURE_PATH_TEMPLATE.md index e173c3540..1ffa06354 100644 --- a/utility/doc/E2E_FEATURE_PATH_TEMPLATE.md +++ b/utility/doc/E2E_FEATURE_PATH_TEMPLATE.md @@ -118,7 +118,7 @@ Open a [new issue](https://github.com/pokt-network/pocket/issues/new?assignees=& - [ ] Validator - [ ] Application - [ ] Servicer -- [ ] Fisherman +- [ ] Watcher - [ ] Portal **Data Structures**: diff --git a/utility/doc/PROTOCOL_RELAY.md b/utility/doc/PROTOCOL_RELAY.md index 5fa9070a5..7f4e864e4 100644 --- a/utility/doc/PROTOCOL_RELAY.md +++ b/utility/doc/PROTOCOL_RELAY.md @@ -43,7 +43,7 @@ sequenceDiagram 4. Wait for `Session` end / secret key to be revealed 5. Collect Volume Applicable Relays (based on secret key) from storage -6. Report Volume Applicable Relays to the assigned `Fisherman` +6. Report Volume Applicable Relays to the assigned `Watcher` ```mermaid sequenceDiagram @@ -52,13 +52,13 @@ sequenceDiagram actor Servicer participant Internal State participant Internal Storage - actor Fisherman + actor Watcher loop Repeats Every Session End Servicer->>Internal State: GetSecretKey(sessionHeader) Internal State->>Servicer: HashCollision = SecretKey(govParams) Servicer->>Internal Storage: RelaysThatEndWith(HashCollision) Internal Storage->>Servicer: VolumeApplicableRelays - Servicer->>Fisherman: Send(VolumeApplicableRelays) + Servicer->>Watcher: Send(VolumeApplicableRelays) end ``` @@ -137,10 +137,10 @@ _See the [Session Protocol](https://github.com/pokt-network/pocket/blob/main/uti 2. This function also signifies deleting the non-volume-applicable `Relays` -### Report volume metric applicable relays to `Fisherman` +### Report volume metric applicable relays to `Watcher` -1. All volume applicable relays need to be sent to the assigned trusted `Fisherman` (selected by the [Session Protocol](https://github.com/pokt-network/pocket/blob/main/utility/doc/PROTOCOLS.md)) for a proper verification of the volume completed. -2. Send `volumeRelays` to `fishermanServiceUrl` through http. +1. All volume applicable relays need to be sent to the assigned trusted `Watcher` (selected by the [Session Protocol](https://github.com/pokt-network/pocket/blob/main/utility/doc/PROTOCOLS.md)) for a proper verification of the volume completed. +2. Send `volumeRelays` to `watcherServiceUrl` through http. ```mermaid graph TD diff --git a/utility/doc/PROTOCOL_SESSION.md b/utility/doc/PROTOCOL_SESSION.md index b9d2205e3..a5326ba24 100644 --- a/utility/doc/PROTOCOL_SESSION.md +++ b/utility/doc/PROTOCOL_SESSION.md @@ -22,11 +22,11 @@ See [session.go](../session.go) and [session_test.go](../session_test.go) for th 1. Create a session object from the seed data 2. Create a key concatenating and hashing the seed data - `sessionId = Hash(sessionHeight + blockHash + geoZone + relayChain + appPublicKey)` -3. Get an ordered list of the public keys of servicers and fishermen who are: +3. Get an ordered list of the public keys of servicers and watchers who are: - actively staked - staked within geo-zone - staked for relay-chain -4. Use a pseudo-random selection algorithm to retrieve the fishermen and servicers for for the sessionId +4. Use a pseudo-random selection algorithm to retrieve the watchers and servicers for for the sessionId ```mermaid sequenceDiagram @@ -36,17 +36,17 @@ sequenceDiagram participant S AS Session Hydrator participant WS AS WorldState - Q->>WS: Who are the servicers and fisherman ([app], [relayChain], [geoZone]) + Q->>WS: Who are the servicers and watcher ([app], [relayChain], [geoZone]) WS->>S: seedData = (height, blockHash, [geoZone], [relayChain], [app]) S->>S: sessionId = hash(concat(seedData)) WS->>S: servicerList = Ordered list of public keys of applicable servicers S->>S: sessionServicers = pseudorandomSelect(sessionKey, servicerList, max) - WS->>S: fishList = Ordered list of public keys of applicable fishermen + WS->>S: watchList = Ordered list of public keys of applicable watchers - S->>S: sessionFishermen = pseudorandomSelect(sessionKey, fishList, max) - S->>Q: SessionServicers, sessionFishermen + S->>S: sessionWatchers = pseudorandomSelect(sessionKey, fList, max) + S->>Q: SessionServicers, sessionWatchers ``` diff --git a/utility/doc/README.md b/utility/doc/README.md index 046e06d13..9feb2961a 100644 --- a/utility/doc/README.md +++ b/utility/doc/README.md @@ -14,7 +14,7 @@ The current implementation does add the fundamental Pocket Network 1.0 actors: - Accounts - Validators -- Fishermen +- Watchers - Applications - Servicers @@ -48,11 +48,11 @@ Added governance params: - ServicerMaxPauseBlocksParamName - ServicersPerSessionParamName -- FishermanMinimumStakeParamName -- FishermanMaxChainsParamName -- FishermanUnstakingBlocksParamName -- FishermanMinimumPauseBlocksParamName -- FishermanMaxPauseBlocksParamName +- WatcherMinimumStakeParamName +- WatcherMaxChainsParamName +- WatcherUnstakingBlocksParamName +- WatcherMinimumPauseBlocksParamName +- WatcherMaxPauseBlocksParamName - ValidatorMinimumStakeParamName - ValidatorUnstakingBlocksParamName @@ -67,12 +67,12 @@ Added governance params: - MessageDoubleSignFee - MessageSendFee -- MessageStakeFishermanFee -- MessageEditStakeFishermanFee -- MessageUnstakeFishermanFee -- MessagePauseFishermanFee -- MessageUnpauseFishermanFee -- MessageFishermanPauseServicerFee +- MessageStakeWatcherFee +- MessageEditStakeWatcherFee +- MessageUnstakeWatcherFee +- MessagePauseWatcherFee +- MessageUnpauseWatcherFee +- MessageWatcherPauseServicerFee - MessageTestScoreFee - MessageProveTestScoreFee - MessageStakeAppFee @@ -107,11 +107,11 @@ Added governance params: - ServicerMinimumPauseBlocksOwner - ServicerMaxPausedBlocksOwner - ServicersPerSessionOwner -- FishermanMinimumStakeOwner -- FishermanMaxChainsOwner -- FishermanUnstakingBlocksOwner -- FishermanMinimumPauseBlocksOwner -- FishermanMaxPausedBlocksOwner +- WatcherMinimumStakeOwner +- WatcherMaxChainsOwner +- WatcherUnstakingBlocksOwner +- WatcherMinimumPauseBlocksOwner +- WatcherMaxPausedBlocksOwner - ValidatorMinimumStakeOwner - ValidatorUnstakingBlocksOwner - ValidatorMinimumPauseBlocksOwner @@ -123,12 +123,12 @@ Added governance params: - DoubleSignBurnPercentageOwner - MessageDoubleSignFeeOwner - MessageSendFeeOwner -- MessageStakeFishermanFeeOwner -- MessageEditStakeFishermanFeeOwner -- MessageUnstakeFishermanFeeOwner -- MessagePauseFishermanFeeOwner -- MessageUnpauseFishermanFeeOwner -- MessageFishermanPauseServicerFeeOwner +- MessageStakeWatcherFeeOwner +- MessageEditStakeWatcherFeeOwner +- MessageUnstakeWatcherFeeOwner +- MessagePauseWatcherFeeOwner +- MessageUnpauseWatcherFeeOwner +- MessageWatcherPauseServicerFeeOwner - MessageTestScoreFeeOwner - MessageProveTestScoreFeeOwner - MessageStakeAppFeeOwner @@ -188,7 +188,7 @@ TODO(olshansky): This is outdated ```bash utility ├── account.go # utility context for accounts & pools -├── actor.go # utility context for apps, fish, nodes, and validators +├── actor.go # utility context for apps, watchers, nodes, and validators ├── block.go # utility context for blocks ├── gov.go # utility context for dao & parameters ├── module.go # module implementation and interfaces diff --git a/utility/fisherman/module.go b/utility/fisherman/module.go deleted file mode 100644 index ff2b89788..000000000 --- a/utility/fisherman/module.go +++ /dev/null @@ -1,57 +0,0 @@ -package fisherman - -import ( - "github.com/pokt-network/pocket/logger" - "github.com/pokt-network/pocket/shared/modules" - "github.com/pokt-network/pocket/shared/modules/base_modules" -) - -const ( - FishermanModuleName = "fisherman" -) - -type fisherman struct { - base_modules.IntegrableModule - logger *modules.Logger -} - -var ( - _ modules.FishermanModule = &fisherman{} -) - -func CreateFisherman(bus modules.Bus, options ...modules.ModuleOption) (modules.FishermanModule, error) { - m, err := new(fisherman).Create(bus, options...) - if err != nil { - return nil, err - } - return m.(modules.FishermanModule), nil -} - -func (*fisherman) Create(bus modules.Bus, options ...modules.ModuleOption) (modules.Module, error) { - m := &fisherman{} - - for _, option := range options { - option(m) - } - - bus.RegisterModule(m) - - m.logger = logger.Global.CreateLoggerForModule(m.GetModuleName()) - - return m, nil -} - -// TODO: implement this function -func (m *fisherman) Start() error { - m.logger.Info().Msg("🎣 Fisherman module started 🎣") - return nil -} - -func (m *fisherman) Stop() error { - m.logger.Info().Msg("🎣 Fisherman module stopped 🎣") - return nil -} - -func (m *fisherman) GetModuleName() string { - return FishermanModuleName -} diff --git a/utility/main_test.go b/utility/main_test.go index 7f3450147..0697cbffe 100644 --- a/utility/main_test.go +++ b/utility/main_test.go @@ -51,12 +51,12 @@ func prepareEnvironment( numValidators, // nolint:unparam // we are not currently modifying parameter but want to keep it modifiable in the future numServicers, numApplications, - numFisherman int, + numWatcher int, genesisOpts ...test_artifacts.GenesisOption, ) (*runtime.Manager, modules.UtilityModule, modules.PersistenceModule) { teardownDeterministicKeygen := keygen.GetInstance().SetSeed(42) - runtimeCfg := newTestRuntimeConfig(numValidators, numServicers, numApplications, numFisherman, genesisOpts...) + runtimeCfg := newTestRuntimeConfig(numValidators, numServicers, numApplications, numWatcher, genesisOpts...) bus, err := runtime.CreateBus(runtimeCfg) require.NoError(t, err) @@ -91,7 +91,7 @@ func newTestRuntimeConfig( numValidators, numServicers, numApplications, - numFisherman int, + numWatcher int, genesisOpts ...test_artifacts.GenesisOption, ) *runtime.Manager { cfg, err := configs.CreateTempConfig(&configs.Config{ @@ -119,7 +119,7 @@ func newTestRuntimeConfig( numValidators, numServicers, numApplications, - numFisherman, + numWatcher, genesisOpts..., ) runtimeCfg := runtime.NewManager(cfg, genesisState) diff --git a/utility/module.go b/utility/module.go index c8b027b9e..5775e08e6 100644 --- a/utility/module.go +++ b/utility/module.go @@ -8,10 +8,10 @@ import ( "github.com/pokt-network/pocket/shared/mempool" "github.com/pokt-network/pocket/shared/modules" "github.com/pokt-network/pocket/shared/modules/base_modules" - "github.com/pokt-network/pocket/utility/fisherman" "github.com/pokt-network/pocket/utility/servicer" "github.com/pokt-network/pocket/utility/types" "github.com/pokt-network/pocket/utility/validator" + "github.com/pokt-network/pocket/utility/watcher" ) const ( @@ -67,7 +67,7 @@ func (*utilityModule) Create(bus modules.Bus, options ...modules.ModuleOption) ( // enableActorModules enables the actor-specific modules and adds them to the utility module's actorModules to be started later. func (u *utilityModule) enableActorModules(cfg *configs.Config) error { - fishermanCfg := cfg.Fisherman + watcherCfg := cfg.Watcher servicerCfg := cfg.Servicer validatorCfg := cfg.Validator @@ -80,10 +80,10 @@ func (u *utilityModule) enableActorModules(cfg *configs.Config) error { u.actorModules[s.GetModuleName()] = s } - if fishermanCfg.Enabled { - f, err := fisherman.CreateFisherman(u.GetBus()) + if watcherCfg.Enabled { + f, err := watcher.CreateWatcher(u.GetBus()) if err != nil { - u.logger.Error().Err(err).Msg("failed to create fisherman module") + u.logger.Error().Err(err).Msg("failed to create watcher module") return err } u.actorModules[f.GetModuleName()] = f @@ -151,14 +151,14 @@ func (u *utilityModule) GetServicerModule() (modules.ServicerModule, error) { return nil, errors.New("failed to cast servicer module") } -func (u *utilityModule) GetFishermanModule() (modules.FishermanModule, error) { - if u.actorModules[fisherman.FishermanModuleName] == nil { - return nil, errors.New("fisherman module not enabled") +func (u *utilityModule) GetWatcherModule() (modules.WatcherModule, error) { + if u.actorModules[watcher.WatcherModuleName] == nil { + return nil, errors.New("watcher module not enabled") } - if m, ok := u.actorModules[fisherman.FishermanModuleName].(modules.FishermanModule); ok { + if m, ok := u.actorModules[watcher.WatcherModuleName].(modules.WatcherModule); ok { return m, nil } - return nil, errors.New("failed to cast fisherman module") + return nil, errors.New("failed to cast watcher module") } func (u *utilityModule) GetValidatorModule() (modules.ValidatorModule, error) { diff --git a/utility/module_enable_actors_test.go b/utility/module_enable_actors_test.go index eadeb8f95..e9353f480 100644 --- a/utility/module_enable_actors_test.go +++ b/utility/module_enable_actors_test.go @@ -36,11 +36,11 @@ func TestEnableActorModules(t *testing.T) { expectedNames: []string{"servicer"}, }, { - name: "fisherman only", + name: "watcher only", config: &configs.Config{ - Fisherman: &configs.FishermanConfig{Enabled: true}, + Watcher: &configs.WatcherConfig{Enabled: true}, }, - expectedNames: []string{"fisherman"}, + expectedNames: []string{"watcher"}, }, { name: "validator only", @@ -64,7 +64,7 @@ func TestEnableActorModules(t *testing.T) { name: "multiple actors not allowed", config: &configs.Config{ Validator: &configs.ValidatorConfig{Enabled: true}, - Fisherman: &configs.FishermanConfig{Enabled: true}, + Watcher: &configs.WatcherConfig{Enabled: true}, }, expectedError: ErrInvalidActorsEnabled, }, diff --git a/utility/servicer/relay.go b/utility/servicer/relay.go index d72ed96ac..d0140771c 100644 --- a/utility/servicer/relay.go +++ b/utility/servicer/relay.go @@ -121,11 +121,11 @@ func (r *relay) ReapStoreForHashCollision(sessionBlockHeight int64, hashEndWith return nil, nil } -// Report volume metric applicable relays to Fisherman -func (r *relay) ReportVolumeMetrics(fishermanServiceURL string, volumeRelays []Relay) coreTypes.Error { +// Report volume metric applicable relays to Watcher +func (r *relay) ReportVolumeMetrics(watcherServiceURL string, volumeRelays []Relay) coreTypes.Error { - // Send all volume applicable relays to the assigned trusted Fisherman for - // a proper verification of the volume completed. Send volumeRelays to fishermanServiceURL + // Send all volume applicable relays to the assigned trusted Watcher for + // a proper verification of the volume completed. Send volumeRelays to watcherServiceURL // through http. // NOTE: an alternative design is a 2 step, claim - proof lifecycle where the individual servicers diff --git a/utility/session.go b/utility/session.go index 16167e3b9..57260ec13 100644 --- a/utility/session.go +++ b/utility/session.go @@ -73,8 +73,8 @@ func (m *utilityModule) GetSession(appAddr string, height int64, relayChain, geo return nil, fmt.Errorf("failed to hydrate session servicers: %w", err) } - if err := sessionHydrator.hydrateSessionFishermen(); err != nil { - return nil, fmt.Errorf("failed to hydrate session fishermen: %w", err) + if err := sessionHydrator.hydrateSessionWatchers(); err != nil { + return nil, fmt.Errorf("failed to hydrate session watchers: %w", err) } return sessionHydrator.session, nil @@ -199,37 +199,37 @@ func (s *sessionHydrator) hydrateSessionServicers() error { return nil } -// hydrateSessionFishermen finds the fishermen that are staked at the session height and populates the session with them -func (s *sessionHydrator) hydrateSessionFishermen() error { - // number of fishermen per session at this height - numFishermen, err := s.readCtx.GetIntParam(types.FishermanPerSessionParamName, s.session.SessionHeight) +// hydrateSessionWatchers finds the watchers that are staked at the session height and populates the session with them +func (s *sessionHydrator) hydrateSessionWatchers() error { + // number of watchers per session at this height + numWatchers, err := s.readCtx.GetIntParam(types.WatcherPerSessionParamName, s.session.SessionHeight) if err != nil { return err } - // returns all the staked fishermen at this session height - fishermen, err := s.readCtx.GetAllFishermen(s.session.SessionHeight) + // returns all the staked watchers at this session height + watchers, err := s.readCtx.GetAllWatchers(s.session.SessionHeight) if err != nil { return err } // OPTIMIZE: Consider updating the persistence module so a single SQL query can retrieve all of the actors at once. - candidateFishermen := make([]*coreTypes.Actor, 0) - for _, fisher := range fishermen { - // Sanity check the fisher is not paused, jailed or unstaking - if fisher.PausedHeight != -1 || fisher.UnstakingHeight != -1 { - return fmt.Errorf("hydrateSessionFishermen should not have encountered a paused or unstaking fisherman: %s", fisher.Address) + candidateWatchers := make([]*coreTypes.Actor, 0) + for _, watcher := range watchers { + // Sanity check the watcher is not paused, jailed or unstaking + if watcher.PausedHeight != -1 || watcher.UnstakingHeight != -1 { + return fmt.Errorf("hydrateSessionWatchers should not have encountered a paused or unstaking watcher: %s", watcher.Address) } // TODO(#697): Filter by geo-zone // OPTIMIZE: If this was a map[string]struct{}, we could have avoided the loop - if slices.Contains(fisher.Chains, s.session.RelayChain) { - candidateFishermen = append(candidateFishermen, fisher) + if slices.Contains(watcher.Chains, s.session.RelayChain) { + candidateWatchers = append(candidateWatchers, watcher) } } - s.session.Fishermen = pseudoRandomSelection(candidateFishermen, numFishermen, s.sessionIdBz) + s.session.Watchers = pseudoRandomSelection(candidateWatchers, numWatchers, s.sessionIdBz) return nil } diff --git a/utility/session_test.go b/utility/session_test.go index 319af206c..e7084cb86 100644 --- a/utility/session_test.go +++ b/utility/session_test.go @@ -17,23 +17,23 @@ import ( // TECHDEBT(#697): Geozones are not current implemented, used or tested -func TestSession_GetSession_SingleFishermanSingleServicerBaseCase(t *testing.T) { +func TestSession_GetSession_SingleWatcherSingleServicerBaseCase(t *testing.T) { // Test parameters height := int64(1) relayChain := test_artifacts.DefaultChains[0] geoZone := "unused_geo" - numFishermen := 1 + numWatchers := 1 numServicers := 1 // needs to be manually updated if business logic changes - expectedSessionId := "b1e9791358aae070ac7f86fdb74e5a9d26fff025fb737a2114ccf9ad95b624bd" + expectedSessionId := "d95b27b31dd4758f1ac40f98f9eb4b75bcd15648059bc4c41259603548559ed5" - runtimeCfg, utilityMod, _ := prepareEnvironment(t, 5, numServicers, 1, numFishermen) + runtimeCfg, utilityMod, _ := prepareEnvironment(t, 5, numServicers, 1, numWatchers) // Sanity check genesis require.Len(t, runtimeCfg.GetGenesis().Applications, 1) app := runtimeCfg.GetGenesis().Applications[0] - require.Len(t, runtimeCfg.GetGenesis().Fishermen, 1) - fisher := runtimeCfg.GetGenesis().Fishermen[0] + require.Len(t, runtimeCfg.GetGenesis().Watchers, 1) + watcher := runtimeCfg.GetGenesis().Watchers[0] require.Len(t, runtimeCfg.GetGenesis().Servicers, 1) servicer := runtimeCfg.GetGenesis().Servicers[0] @@ -49,8 +49,8 @@ func TestSession_GetSession_SingleFishermanSingleServicerBaseCase(t *testing.T) require.Equal(t, app.Address, session.Application.Address) require.Len(t, session.Servicers, numServicers) require.Equal(t, servicer.Address, session.Servicers[0].Address) - require.Len(t, session.Fishermen, numFishermen) - require.Equal(t, fisher.Address, session.Fishermen[0].Address) + require.Len(t, session.Watchers, numWatchers) + require.Equal(t, watcher.Address, session.Watchers[0].Address) } func TestSession_GetSession_ApplicationInvalid(t *testing.T) { @@ -124,54 +124,54 @@ func TestSession_GetSession_InvalidFutureSession(t *testing.T) { require.Error(t, err) } -func TestSession_GetSession_ServicersAndFishermenCounts_TotalAvailability(t *testing.T) { - // Prepare an environment with a lot of servicers and fishermen +func TestSession_GetSession_ServicersAndWatchersCounts_TotalAvailability(t *testing.T) { + // Prepare an environment with a lot of servicers and watchers numStakedServicers := 100 - numStakedFishermen := 100 - runtimeCfg, utilityMod, persistenceMod := prepareEnvironment(t, 5, numStakedServicers, 1, numStakedFishermen) + numStakedWatchers := 100 + runtimeCfg, utilityMod, persistenceMod := prepareEnvironment(t, 5, numStakedServicers, 1, numStakedWatchers) // Vary the number of actors per session using gov params and check that the session is populated with the correct number of actorss tests := []struct { name string numServicersPerSession int64 - numFishermanPerSession int64 + numWatcherPerSession int64 wantServicerCount int - wantFishermanCount int + wantWatcherCount int }{ { name: "more actors per session than available in network", numServicersPerSession: int64(numStakedServicers) * 10, - numFishermanPerSession: int64(numStakedFishermen) * 10, + numWatcherPerSession: int64(numStakedWatchers) * 10, wantServicerCount: numStakedServicers, - wantFishermanCount: numStakedFishermen, + wantWatcherCount: numStakedWatchers, }, { name: "less actors per session than available in network", numServicersPerSession: int64(numStakedServicers) / 2, - numFishermanPerSession: int64(numStakedFishermen) / 2, + numWatcherPerSession: int64(numStakedWatchers) / 2, wantServicerCount: numStakedServicers / 2, - wantFishermanCount: numStakedFishermen / 2, + wantWatcherCount: numStakedWatchers / 2, }, { name: "same number of actors per session as available in network", numServicersPerSession: int64(numStakedServicers), - numFishermanPerSession: int64(numStakedFishermen), + numWatcherPerSession: int64(numStakedWatchers), wantServicerCount: numStakedServicers, - wantFishermanCount: numStakedFishermen, + wantWatcherCount: numStakedWatchers, }, { - name: "more than enough servicers but not enough fishermen", + name: "more than enough servicers but not enough watchers", numServicersPerSession: int64(numStakedServicers) / 2, - numFishermanPerSession: int64(numStakedFishermen) * 10, + numWatcherPerSession: int64(numStakedWatchers) * 10, wantServicerCount: numStakedServicers / 2, - wantFishermanCount: numStakedFishermen, + wantWatcherCount: numStakedWatchers, }, { - name: "more than enough fishermen but not enough servicers", + name: "more than enough watchers but not enough servicers", numServicersPerSession: int64(numStakedServicers) * 10, - numFishermanPerSession: int64(numStakedFishermen) / 2, + numWatcherPerSession: int64(numStakedWatchers) / 2, wantServicerCount: numStakedServicers, - wantFishermanCount: numStakedFishermen / 2, + wantWatcherCount: numStakedWatchers / 2, }, } @@ -192,14 +192,14 @@ func TestSession_GetSession_ServicersAndFishermenCounts_TotalAvailability(t *tes }) require.NoError(t, err) - // Update the number of servicers and fishermen per session gov params + // Update the number of servicers and watchers per session gov params writeCtx, err := persistenceMod.NewRWContext(updateParamsHeight) require.NoError(t, err) defer writeCtx.Release() err = writeCtx.SetParam(types.ServicersPerSessionParamName, tt.numServicersPerSession) require.NoError(t, err) - err = writeCtx.SetParam(types.FishermanPerSessionParamName, tt.numFishermanPerSession) + err = writeCtx.SetParam(types.WatcherPerSessionParamName, tt.numWatcherPerSession) require.NoError(t, err) err = writeCtx.Commit([]byte("empty_proposed_addr"), []byte("empty_quorum_cert")) require.NoError(t, err) @@ -208,58 +208,58 @@ func TestSession_GetSession_ServicersAndFishermenCounts_TotalAvailability(t *tes session, err := utilityMod.GetSession(app.Address, querySessionHeight, relayChain, geoZone) require.NoError(t, err) require.Equal(t, tt.wantServicerCount, len(session.Servicers)) - require.Equal(t, tt.wantFishermanCount, len(session.Fishermen)) + require.Equal(t, tt.wantWatcherCount, len(session.Watchers)) }) } } -func TestSession_GetSession_ServicersAndFishermenCounts_ChainAvailability(t *testing.T) { +func TestSession_GetSession_ServicersAndWatchersCounts_ChainAvailability(t *testing.T) { // Constant parameters for testing numServicersPerSession := 10 - numFishermenPerSession := 2 + numWatchersPerSession := 2 - // Make sure there are MORE THAN ENOUGH servicers and fishermen in the network for each session for chain 1 + // Make sure there are MORE THAN ENOUGH servicers and watchers in the network for each session for chain 1 servicersChain1, servicerKeysChain1 := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_SERVICER, numServicersPerSession*2, []string{"chn1"}) - fishermenChain1, fishermenKeysChain1 := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_FISH, numFishermenPerSession*2, []string{"chn1"}) + watchersChain1, watchersKeysChain1 := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_WATCHER, numWatchersPerSession*2, []string{"chn1"}) - // Make sure there are NOT ENOUGH servicers and fishermen in the network for each session for chain 2 + // Make sure there are NOT ENOUGH servicers and watchers in the network for each session for chain 2 servicersChain2, servicerKeysChain2 := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_SERVICER, numServicersPerSession/2, []string{"chn2"}) - fishermenChain2, fishermenKeysChain2 := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_FISH, numFishermenPerSession/2, []string{"chn2"}) + watchersChain2, watchersKeysChain2 := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_WATCHER, numWatchersPerSession/2, []string{"chn2"}) application, applicationKey := test_artifacts.NewActors(coreTypes.ActorType_ACTOR_TYPE_APP, 1, []string{"chn1", "chn2", "chn3"}) //nolint:gocritic // intentionally not appending result to a new slice - actors := append(application, append(servicersChain1, append(servicersChain2, append(fishermenChain1, fishermenChain2...)...)...)...) + actors := append(application, append(servicersChain1, append(servicersChain2, append(watchersChain1, watchersChain2...)...)...)...) //nolint:gocritic // intentionally not appending result to a new slice - keys := append(applicationKey, append(servicerKeysChain1, append(servicerKeysChain2, append(fishermenKeysChain1, fishermenKeysChain2...)...)...)...) + keys := append(applicationKey, append(servicerKeysChain1, append(servicerKeysChain2, append(watchersKeysChain1, watchersKeysChain2...)...)...)...) // Prepare the environment runtimeCfg, utilityMod, persistenceMod := prepareEnvironment(t, 5, 0, 0, 0, test_artifacts.WithActors(actors, keys)) - // Vary the chain and check the number of fishermen and servicers returned for each one + // Vary the chain and check the number of watchers and servicers returned for each one tests := []struct { - name string - chain string - wantServicerCount int - wantFishermanCount int + name string + chain string + wantServicerCount int + wantWatcherCount int }{ { - name: "chn1 has enough servicers and fishermen", - chain: "chn1", - wantServicerCount: numServicersPerSession, - wantFishermanCount: numFishermenPerSession, + name: "chn1 has enough servicers and watchers", + chain: "chn1", + wantServicerCount: numServicersPerSession, + wantWatcherCount: numWatchersPerSession, }, { - name: "chn2 does not have enough servicers and fishermen", - chain: "chn2", - wantServicerCount: numServicersPerSession / 2, - wantFishermanCount: numFishermenPerSession / 2, + name: "chn2 does not have enough servicers and watchers", + chain: "chn2", + wantServicerCount: numServicersPerSession / 2, + wantWatcherCount: numWatchersPerSession / 2, }, { - name: "chn3 has no servicers and fishermen", - chain: "chn3", - wantServicerCount: 0, - wantFishermanCount: 0, + name: "chn3 has no servicers and watchers", + chain: "chn3", + wantServicerCount: 0, + wantWatcherCount: 0, }, } @@ -270,12 +270,12 @@ func TestSession_GetSession_ServicersAndFishermenCounts_ChainAvailability(t *tes }) require.NoError(t, err) - // Update the number of servicers and fishermen per session gov params + // Update the number of servicers and watchers per session gov params writeCtx, err := persistenceMod.NewRWContext(1) require.NoError(t, err) err = writeCtx.SetParam(types.ServicersPerSessionParamName, numServicersPerSession) require.NoError(t, err) - err = writeCtx.SetParam(types.FishermanPerSessionParamName, numFishermenPerSession) + err = writeCtx.SetParam(types.WatcherPerSessionParamName, numWatchersPerSession) require.NoError(t, err) err = writeCtx.Commit([]byte("empty_proposed_addr"), []byte("empty_quorum_cert")) require.NoError(t, err) @@ -290,7 +290,7 @@ func TestSession_GetSession_ServicersAndFishermenCounts_ChainAvailability(t *tes session, err := utilityMod.GetSession(app.Address, 2, tt.chain, geoZone) require.NoError(t, err) require.Len(t, session.Servicers, tt.wantServicerCount) - require.Len(t, session.Fishermen, tt.wantFishermanCount) + require.Len(t, session.Watchers, tt.wantWatcherCount) }) } } @@ -369,12 +369,12 @@ func TestSession_GetSession_SessionHeightAndNumber_StaticBlocksPerSession(t *tes } } -func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { - // Prepare an environment with a lot of servicers and fishermen +func TestSession_GetSession_ServicersAndWatcherEntropy(t *testing.T) { + // Prepare an environment with a lot of servicers and watchers numServicers := 1000 - numFishermen := 1000 // make them equal for simplicity + numWatchers := 1000 // make them equal for simplicity numServicersPerSession := 10 - numFishermenPerSession := 10 // make them equal for simplicity + numWatchersPerSession := 10 // make them equal for simplicity numApplications := 3 numBlocksPerSession := 2 // expect a different every other height @@ -386,14 +386,14 @@ func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { probabilityOfOverlap := (numChoices - numChoicesRemaining) / numChoices // Prepare the environment - runtimeCfg, utilityMod, persistenceMod := prepareEnvironment(t, 5, numServicers, numApplications, numFishermen) + runtimeCfg, utilityMod, persistenceMod := prepareEnvironment(t, 5, numServicers, numApplications, numWatchers) - // Set the number of servicers and fishermen per session gov params + // Set the number of servicers and watchers per session gov params writeCtx, err := persistenceMod.NewRWContext(1) require.NoError(t, err) err = writeCtx.SetParam(types.ServicersPerSessionParamName, numServicersPerSession) require.NoError(t, err) - err = writeCtx.SetParam(types.FishermanPerSessionParamName, numFishermenPerSession) + err = writeCtx.SetParam(types.WatcherPerSessionParamName, numWatchersPerSession) require.NoError(t, err) err = writeCtx.SetParam(types.BlocksPerSessionParamName, numBlocksPerSession) require.NoError(t, err) @@ -401,7 +401,7 @@ func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { require.NoError(t, err) writeCtx.Release() - // Keep the relay chain and geoZone static, but vary the app and height to verify that the servicers and fishermen vary + // Keep the relay chain and geoZone static, but vary the app and height to verify that the servicers and watchers vary relayChain := test_artifacts.DefaultChains[0] geoZone := "unused_geo" @@ -413,9 +413,9 @@ func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { // Keep track of the actors from the session at the previous height to verify a delta var app1PrevServicers, app2PrevServicers, app3PrevServicers []*coreTypes.Actor - var app1PrevFishermen, app2PrevFishermen, app3PrevFishermen []*coreTypes.Actor + var app1PrevWatchers, app2PrevWatchers, app3PrevWatchers []*coreTypes.Actor - // The number of blocks to increase until we expect a different set of servicers and fishermen; see numBlocksPerSession + // The number of blocks to increase until we expect a different set of servicers and watchers; see numBlocksPerSession numBlocksUntilChange := 0 // Commit new blocks for all the heights that failed above @@ -432,18 +432,18 @@ func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { require.Equal(t, len(session1.Servicers), len(session2.Servicers)) require.Equal(t, len(session1.Servicers), len(session3.Servicers)) - // All the sessions have the same number of fishermen - require.Len(t, session1.Fishermen, numFishermenPerSession) - require.Equal(t, len(session1.Fishermen), len(session2.Fishermen)) - require.Equal(t, len(session1.Fishermen), len(session3.Fishermen)) + // All the sessions have the same number of watchers + require.Len(t, session1.Watchers, numWatchersPerSession) + require.Equal(t, len(session1.Watchers), len(session2.Watchers)) + require.Equal(t, len(session1.Watchers), len(session3.Watchers)) // Assert different services between apps assertActorsDifference(t, session1.Servicers, session2.Servicers, probabilityOfOverlap) assertActorsDifference(t, session1.Servicers, session3.Servicers, probabilityOfOverlap) - // Assert different fishermen between apps - assertActorsDifference(t, session1.Fishermen, session2.Fishermen, probabilityOfOverlap) - assertActorsDifference(t, session1.Fishermen, session3.Fishermen, probabilityOfOverlap) + // Assert different watchers between apps + assertActorsDifference(t, session1.Watchers, session2.Watchers, probabilityOfOverlap) + assertActorsDifference(t, session1.Watchers, session3.Watchers, probabilityOfOverlap) if numBlocksUntilChange == 0 { // Assert different servicers between heights for the same app @@ -451,20 +451,20 @@ func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { assertActorsDifference(t, app2PrevServicers, session2.Servicers, probabilityOfOverlap) assertActorsDifference(t, app3PrevServicers, session3.Servicers, probabilityOfOverlap) - // Assert different fishermen between heights for the same app - assertActorsDifference(t, app1PrevFishermen, session1.Fishermen, probabilityOfOverlap) - assertActorsDifference(t, app2PrevFishermen, session2.Fishermen, probabilityOfOverlap) - assertActorsDifference(t, app3PrevFishermen, session3.Fishermen, probabilityOfOverlap) + // Assert different watchers between heights for the same app + assertActorsDifference(t, app1PrevWatchers, session1.Watchers, probabilityOfOverlap) + assertActorsDifference(t, app2PrevWatchers, session2.Watchers, probabilityOfOverlap) + assertActorsDifference(t, app3PrevWatchers, session3.Watchers, probabilityOfOverlap) - // Store the new servicers and fishermen for the next height + // Store the new servicers and watchers for the next height app1PrevServicers = session1.Servicers app2PrevServicers = session2.Servicers app3PrevServicers = session3.Servicers - app1PrevFishermen = session1.Fishermen - app2PrevFishermen = session2.Fishermen - app3PrevFishermen = session3.Fishermen + app1PrevWatchers = session1.Watchers + app2PrevWatchers = session2.Watchers + app3PrevWatchers = session3.Watchers - // Reset the number of blocks until we expect a different set of servicers and fishermen + // Reset the number of blocks until we expect a different set of servicers and watchers numBlocksUntilChange = numBlocksPerSession - 1 } else { // Assert the same servicers between heights for the same app @@ -472,10 +472,10 @@ func TestSession_GetSession_ServicersAndFishermanEntropy(t *testing.T) { require.ElementsMatch(t, app2PrevServicers, session2.Servicers) require.ElementsMatch(t, app3PrevServicers, session3.Servicers) - // Assert the same fishermen between heights for the same app - require.ElementsMatch(t, app1PrevFishermen, session1.Fishermen) - require.ElementsMatch(t, app2PrevFishermen, session2.Fishermen) - require.ElementsMatch(t, app3PrevFishermen, session3.Fishermen) + // Assert the same watchers between heights for the same app + require.ElementsMatch(t, app1PrevWatchers, session1.Watchers) + require.ElementsMatch(t, app2PrevWatchers, session2.Watchers) + require.ElementsMatch(t, app3PrevWatchers, session3.Watchers) numBlocksUntilChange-- } @@ -493,7 +493,7 @@ func TestSession_GetSession_ApplicationUnbonds(t *testing.T) { // TODO: What if an Application unbonds (unstaking period elapses) mid session? } -func TestSession_GetSession_ServicersAndFishermenCounts_GeoZoneAvailability(t *testing.T) { +func TestSession_GetSession_ServicersAndWatchersCounts_GeoZoneAvailability(t *testing.T) { // TECHDEBT(#697): Once GeoZones are implemented, the tests need to be added as well // Cases: Invalid, unused, non-existent, empty, insufficiently complete, etc... } diff --git a/utility/types/gov.go b/utility/types/gov.go index 52501f95f..e5335a751 100644 --- a/utility/types/gov.go +++ b/utility/types/gov.go @@ -27,13 +27,13 @@ const ( ServicerMaxPauseBlocksParamName = "servicer_max_pause_blocks" ServicersPerSessionParamName = "servicers_per_session" - // Fisherman actor gov params - FishermanMinimumStakeParamName = "fisherman_minimum_stake" - FishermanMaxChainsParamName = "fisherman_max_chains" - FishermanUnstakingBlocksParamName = "fisherman_unstaking_blocks" - FishermanMinimumPauseBlocksParamName = "fisherman_minimum_pause_blocks" - FishermanMaxPauseBlocksParamName = "fisherman_max_pause_blocks" - FishermanPerSessionParamName = "fisherman_per_session" + // Watcher actor gov params + WatcherMinimumStakeParamName = "watcher_minimum_stake" + WatcherMaxChainsParamName = "watcher_max_chains" + WatcherUnstakingBlocksParamName = "watcher_unstaking_blocks" + WatcherMinimumPauseBlocksParamName = "watcher_minimum_pause_blocks" + WatcherMaxPauseBlocksParamName = "watcher_max_pause_blocks" + WatcherPerSessionParamName = "watcher_per_session" // Validator actor gov params ValidatorMinimumStakeParamName = "validator_minimum_stake" @@ -49,14 +49,14 @@ const ( DoubleSignBurnPercentageParamName = "double_sign_burn_percentage" // Pocket specific message gov params - MessageStakeFishermanFee = "message_stake_fisherman_fee" - MessageEditStakeFishermanFee = "message_edit_stake_fisherman_fee" - MessageUnstakeFishermanFee = "message_unstake_fisherman_fee" - MessagePauseFishermanFee = "message_pause_fisherman_fee" - MessageUnpauseFishermanFee = "message_unpause_fisherman_fee" - MessageFishermanPauseServicerFee = "message_fisherman_pause_servicer_fee" - MessageTestScoreFee = "message_test_score_fee" - MessageProveTestScoreFee = "message_prove_test_score_fee" + MessageStakeWatcherFee = "message_stake_watcher_fee" + MessageEditStakeWatcherFee = "message_edit_stake_watcher_fee" + MessageUnstakeWatcherFee = "message_unstake_watcher_fee" + MessagePauseWatcherFee = "message_pause_watcher_fee" + MessageUnpauseWatcherFee = "message_unpause_watcher_fee" + MessageWatcherPauseServicerFee = "message_watcher_pause_servicer_fee" + MessageTestScoreFee = "message_test_score_fee" + MessageProveTestScoreFee = "message_prove_test_score_fee" // Proof-of-stake message gov params MessageDoubleSignFee = "message_double_sign_fee" @@ -109,12 +109,12 @@ const ( ServicerMaxPausedBlocksOwner = "servicer_max_paused_blocks_owner" ServicersPerSessionOwner = "servicers_per_session_owner" - FishermanMinimumStakeOwner = "fisherman_minimum_stake_owner" - FishermanMaxChainsOwner = "fisherman_max_chains_owner" - FishermanUnstakingBlocksOwner = "fisherman_unstaking_blocks_owner" - FishermanMinimumPauseBlocksOwner = "fisherman_minimum_pause_blocks_owner" - FishermanMaxPausedBlocksOwner = "fisherman_max_paused_blocks_owner" - FishermanPerSessionOwner = "fisherman_per_session_owner" + WatcherMinimumStakeOwner = "watcher_minimum_stake_owner" + WatcherMaxChainsOwner = "watcher_max_chains_owner" + WatcherUnstakingBlocksOwner = "watcher_unstaking_blocks_owner" + WatcherMinimumPauseBlocksOwner = "watcher_minimum_pause_blocks_owner" + WatcherMaxPausedBlocksOwner = "watcher_max_paused_blocks_owner" + WatcherPerSessionOwner = "watcher_per_session_owner" ValidatorMinimumStakeOwner = "validator_minimum_stake_owner" ValidatorUnstakingBlocksOwner = "validator_unstaking_blocks_owner" @@ -129,29 +129,29 @@ const ( MessageDoubleSignFeeOwner = "message_double_sign_fee_owner" MessageSendFeeOwner = "message_send_fee_owner" - MessageStakeFishermanFeeOwner = "message_stake_fisherman_fee_owner" - MessageEditStakeFishermanFeeOwner = "message_edit_stake_fisherman_fee_owner" - MessageUnstakeFishermanFeeOwner = "message_unstake_fisherman_fee_owner" - MessagePauseFishermanFeeOwner = "message_pause_fisherman_fee_owner" - MessageUnpauseFishermanFeeOwner = "message_unpause_fisherman_fee_owner" - MessageFishermanPauseServicerFeeOwner = "message_fisherman_pause_servicer_fee_owner" - MessageTestScoreFeeOwner = "message_test_score_fee_owner" - MessageProveTestScoreFeeOwner = "message_prove_test_score_fee_owner" - MessageStakeAppFeeOwner = "message_stake_app_fee_owner" - MessageEditStakeAppFeeOwner = "message_edit_stake_app_fee_owner" - MessageUnstakeAppFeeOwner = "message_unstake_app_fee_owner" - MessagePauseAppFeeOwner = "message_pause_app_fee_owner" - MessageUnpauseAppFeeOwner = "message_unpause_app_fee_owner" - MessageStakeValidatorFeeOwner = "message_stake_validator_fee_owner" - MessageEditStakeValidatorFeeOwner = "message_edit_stake_validator_fee_owner" - MessageUnstakeValidatorFeeOwner = "message_unstake_validator_fee_owner" - MessagePauseValidatorFeeOwner = "message_pause_validator_fee_owner" - MessageUnpauseValidatorFeeOwner = "message_unpause_validator_fee_owner" - MessageStakeServicerFeeOwner = "message_stake_servicer_fee_owner" - MessageEditStakeServicerFeeOwner = "message_edit_stake_servicer_fee_owner" - MessageUnstakeServicerFeeOwner = "message_unstake_servicer_fee_owner" - MessagePauseServicerFeeOwner = "message_pause_servicer_fee_owner" - MessageUnpauseServicerFeeOwner = "message_unpause_servicer_fee_owner" + MessageStakeWatcherFeeOwner = "message_stake_watcher_fee_owner" + MessageEditStakeWatcherFeeOwner = "message_edit_stake_watcher_fee_owner" + MessageUnstakeWatcherFeeOwner = "message_unstake_watcher_fee_owner" + MessagePauseWatcherFeeOwner = "message_pause_watcher_fee_owner" + MessageUnpauseWatcherFeeOwner = "message_unpause_watcher_fee_owner" + MessageWatcherPauseServicerFeeOwner = "message_watcher_pause_servicer_fee_owner" + MessageTestScoreFeeOwner = "message_test_score_fee_owner" + MessageProveTestScoreFeeOwner = "message_prove_test_score_fee_owner" + MessageStakeAppFeeOwner = "message_stake_app_fee_owner" + MessageEditStakeAppFeeOwner = "message_edit_stake_app_fee_owner" + MessageUnstakeAppFeeOwner = "message_unstake_app_fee_owner" + MessagePauseAppFeeOwner = "message_pause_app_fee_owner" + MessageUnpauseAppFeeOwner = "message_unpause_app_fee_owner" + MessageStakeValidatorFeeOwner = "message_stake_validator_fee_owner" + MessageEditStakeValidatorFeeOwner = "message_edit_stake_validator_fee_owner" + MessageUnstakeValidatorFeeOwner = "message_unstake_validator_fee_owner" + MessagePauseValidatorFeeOwner = "message_pause_validator_fee_owner" + MessageUnpauseValidatorFeeOwner = "message_unpause_validator_fee_owner" + MessageStakeServicerFeeOwner = "message_stake_servicer_fee_owner" + MessageEditStakeServicerFeeOwner = "message_edit_stake_servicer_fee_owner" + MessageUnstakeServicerFeeOwner = "message_unstake_servicer_fee_owner" + MessagePauseServicerFeeOwner = "message_pause_servicer_fee_owner" + MessageUnpauseServicerFeeOwner = "message_unpause_servicer_fee_owner" MessageChangeParameterFeeOwner = "message_change_parameter_fee_owner" ) diff --git a/utility/unit_of_work/actor.go b/utility/unit_of_work/actor.go index 4f99a0e70..1b44b6d84 100644 --- a/utility/unit_of_work/actor.go +++ b/utility/unit_of_work/actor.go @@ -22,8 +22,8 @@ func (u *baseUtilityUnitOfWork) setActorStakeAmount(actorType coreTypes.ActorTyp switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: err = u.persistenceRWContext.SetAppStakeAmount(addr, amountStr) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - err = u.persistenceRWContext.SetFishermanStakeAmount(addr, amountStr) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + err = u.persistenceRWContext.SetWatcherStakeAmount(addr, amountStr) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: err = u.persistenceRWContext.SetServicerStakeAmount(addr, amountStr) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -43,8 +43,8 @@ func (u *baseUtilityUnitOfWork) setActorUnbondingHeight(actorType coreTypes.Acto switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: err = u.persistenceRWContext.SetAppUnstakingHeightAndStatus(addr, height, int32(coreTypes.StakeStatus_Unstaking)) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - err = u.persistenceRWContext.SetFishermanUnstakingHeightAndStatus(addr, height, int32(coreTypes.StakeStatus_Unstaking)) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + err = u.persistenceRWContext.SetWatcherUnstakingHeightAndStatus(addr, height, int32(coreTypes.StakeStatus_Unstaking)) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: err = u.persistenceRWContext.SetServicerUnstakingHeightAndStatus(addr, height, int32(coreTypes.StakeStatus_Unstaking)) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -64,8 +64,8 @@ func (u *baseUtilityUnitOfWork) setActorPausedHeight(actorType coreTypes.ActorTy switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: err = u.persistenceRWContext.SetAppPauseHeight(addr, height) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - err = u.persistenceRWContext.SetFishermanPauseHeight(addr, height) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + err = u.persistenceRWContext.SetWatcherPauseHeight(addr, height) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: err = u.persistenceRWContext.SetServicerPauseHeight(addr, height) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -89,8 +89,8 @@ func (u *baseUtilityUnitOfWork) getActorStakeAmount(actorType coreTypes.ActorTyp switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: stakeAmount, err = u.persistenceReadContext.GetAppStakeAmount(u.height, addr) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - stakeAmount, err = u.persistenceReadContext.GetFishermanStakeAmount(u.height, addr) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + stakeAmount, err = u.persistenceReadContext.GetWatcherStakeAmount(u.height, addr) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: stakeAmount, err = u.persistenceReadContext.GetServicerStakeAmount(u.height, addr) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -116,8 +116,8 @@ func (u *baseUtilityUnitOfWork) getMaxAllowedPausedBlocks(actorType coreTypes.Ac switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppMaxPauseBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanMaxPauseBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherMaxPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerMaxPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -139,8 +139,8 @@ func (u *baseUtilityUnitOfWork) getMinRequiredPausedBlocks(actorType coreTypes.A switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppMinimumPauseBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanMinimumPauseBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherMinimumPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerMinimumPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -163,8 +163,8 @@ func (u *baseUtilityUnitOfWork) getPausedHeightIfExists(actorType coreTypes.Acto switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: pauseHeight, err = u.persistenceReadContext.GetAppPauseHeightIfExists(addr, u.height) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - pauseHeight, err = u.persistenceReadContext.GetFishermanPauseHeightIfExists(addr, u.height) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + pauseHeight, err = u.persistenceReadContext.GetWatcherPauseHeightIfExists(addr, u.height) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: pauseHeight, err = u.persistenceReadContext.GetServicerPauseHeightIfExists(addr, u.height) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -187,8 +187,8 @@ func (u *baseUtilityUnitOfWork) getActorStatus(actorType coreTypes.ActorType, ad switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: status, err = u.persistenceReadContext.GetAppStatus(addr, u.height) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - status, err = u.persistenceReadContext.GetFishermanStatus(addr, u.height) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + status, err = u.persistenceReadContext.GetWatcherStatus(addr, u.height) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: status, err = u.persistenceReadContext.GetServicerStatus(addr, u.height) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -214,8 +214,8 @@ func (u *baseUtilityUnitOfWork) getMinRequiredStakeAmount(actorType coreTypes.Ac switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppMinimumStakeParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanMinimumStakeParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherMinimumStakeParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerMinimumStakeParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -242,8 +242,8 @@ func (u *baseUtilityUnitOfWork) getUnbondingHeight(actorType coreTypes.ActorType switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppUnstakingBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanUnstakingBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherUnstakingBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerUnstakingBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -265,8 +265,8 @@ func (u *baseUtilityUnitOfWork) getMaxAllowedChains(actorType coreTypes.ActorTyp switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppMaxChainsParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanMaxChainsParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherMaxChainsParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerMaxChainsParamName default: @@ -288,8 +288,8 @@ func (u *baseUtilityUnitOfWork) getActorExists(actorType coreTypes.ActorType, ad switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: exists, err = u.persistenceReadContext.GetAppExists(addr, u.height) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - exists, err = u.persistenceReadContext.GetFishermanExists(addr, u.height) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + exists, err = u.persistenceReadContext.GetWatcherExists(addr, u.height) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: exists, err = u.persistenceReadContext.GetServicerExists(addr, u.height) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -314,8 +314,8 @@ func (u *baseUtilityUnitOfWork) getActorOutputAddress(actorType coreTypes.ActorT switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: outputAddr, err = u.persistenceReadContext.GetAppOutputAddress(operator, u.height) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - outputAddr, err = u.persistenceReadContext.GetFishermanOutputAddress(operator, u.height) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + outputAddr, err = u.persistenceReadContext.GetWatcherOutputAddress(operator, u.height) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: outputAddr, err = u.persistenceReadContext.GetServicerOutputAddress(operator, u.height) case coreTypes.ActorType_ACTOR_TYPE_VAL: diff --git a/utility/unit_of_work/actor_test.go b/utility/unit_of_work/actor_test.go index b8ff336a6..07b09fdee 100644 --- a/utility/unit_of_work/actor_test.go +++ b/utility/unit_of_work/actor_test.go @@ -133,8 +133,8 @@ func TestUtilityUnitOfWork_HandleMessageUnstake(t *testing.T) { switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppUnstakingBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanUnstakingBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherUnstakingBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerUnstakingBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -184,8 +184,8 @@ func TestUtilityUnitOfWork_HandleMessageUnpause(t *testing.T) { switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppMinimumPauseBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanMinimumPauseBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherMinimumPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerMinimumPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -264,8 +264,8 @@ func TestUtilityUnitOfWork_GetUnbondingHeight(t *testing.T) { switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: unstakingBlocks, err = getGovParam[int64](uow, typesUtil.AppUnstakingBlocksParamName) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - unstakingBlocks, err = getGovParam[int64](uow, typesUtil.FishermanUnstakingBlocksParamName) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + unstakingBlocks, err = getGovParam[int64](uow, typesUtil.WatcherUnstakingBlocksParamName) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: unstakingBlocks, err = getGovParam[int64](uow, typesUtil.ServicerUnstakingBlocksParamName) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -299,8 +299,8 @@ func TestUtilityUnitOfWork_BeginUnstakingMaxPausedActors(t *testing.T) { switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: paramName = typesUtil.AppMaxPauseBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - paramName = typesUtil.FishermanMaxPauseBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + paramName = typesUtil.WatcherMaxPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: paramName = typesUtil.ServicerMaxPauseBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -384,10 +384,10 @@ func TestUtilityUnitOfWork_BeginUnstakingActorsPausedBefore_UnbondUnstakingActor poolAddress = coreTypes.Pools_POOLS_APP_STAKE.Address() paramName1 = typesUtil.AppMaxPauseBlocksParamName paramName2 = typesUtil.AppUnstakingBlocksParamName - case coreTypes.ActorType_ACTOR_TYPE_FISH: - poolAddress = coreTypes.Pools_POOLS_FISHERMAN_STAKE.Address() - paramName1 = typesUtil.FishermanMaxPauseBlocksParamName - paramName2 = typesUtil.FishermanUnstakingBlocksParamName + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + poolAddress = coreTypes.Pools_POOLS_WATCHER_STAKE.Address() + paramName1 = typesUtil.WatcherMaxPauseBlocksParamName + paramName2 = typesUtil.WatcherUnstakingBlocksParamName case coreTypes.ActorType_ACTOR_TYPE_SERVICER: poolAddress = coreTypes.Pools_POOLS_SERVICER_STAKE.Address() paramName1 = typesUtil.ServicerMaxPauseBlocksParamName @@ -659,9 +659,9 @@ func getAllTestingActors(t *testing.T, uow *baseUtilityUnitOfWork, actorType cor case coreTypes.ActorType_ACTOR_TYPE_APP: apps := getAllTestingApps(t, uow) actors = append(actors, apps...) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - fish := getAllTestingFish(t, uow) - actors = append(actors, fish...) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + watchers := getAllTestingWatchers(t, uow) + actors = append(actors, watchers...) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: nodes := getAllTestingServicers(t, uow) actors = append(actors, nodes...) @@ -700,8 +700,8 @@ func getAllTestingValidators(t *testing.T, uow *baseUtilityUnitOfWork) []*coreTy return actors } -func getAllTestingFish(t *testing.T, uow *baseUtilityUnitOfWork) []*coreTypes.Actor { - actors, err := uow.persistenceReadContext.GetAllFishermen(uow.height) +func getAllTestingWatchers(t *testing.T, uow *baseUtilityUnitOfWork) []*coreTypes.Actor { + actors, err := uow.persistenceReadContext.GetAllWatchers(uow.height) require.NoError(t, err) return actors } diff --git a/utility/unit_of_work/block.go b/utility/unit_of_work/block.go index 914cf1ac9..6c5a379d3 100644 --- a/utility/unit_of_work/block.go +++ b/utility/unit_of_work/block.go @@ -114,9 +114,9 @@ func (uow *baseUtilityUnitOfWork) unbondUnstakingActors() (err coreTypes.Error) case coreTypes.ActorType_ACTOR_TYPE_APP: readyToUnbond, er = uow.persistenceReadContext.GetAppsReadyToUnstake(uow.height, int32(coreTypes.StakeStatus_Unstaking)) poolAddress = coreTypes.Pools_POOLS_APP_STAKE.Address() - case coreTypes.ActorType_ACTOR_TYPE_FISH: - readyToUnbond, er = uow.persistenceReadContext.GetFishermenReadyToUnstake(uow.height, int32(coreTypes.StakeStatus_Unstaking)) - poolAddress = coreTypes.Pools_POOLS_FISHERMAN_STAKE.Address() + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + readyToUnbond, er = uow.persistenceReadContext.GetWatchersReadyToUnstake(uow.height, int32(coreTypes.StakeStatus_Unstaking)) + poolAddress = coreTypes.Pools_POOLS_WATCHER_STAKE.Address() case coreTypes.ActorType_ACTOR_TYPE_SERVICER: readyToUnbond, er = uow.persistenceReadContext.GetServicersReadyToUnstake(uow.height, int32(coreTypes.StakeStatus_Unstaking)) poolAddress = coreTypes.Pools_POOLS_SERVICER_STAKE.Address() @@ -190,8 +190,8 @@ func (uow *baseUtilityUnitOfWork) beginUnstakingActorsPausedBefore(pausedBeforeH switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: er = uow.persistenceRWContext.SetAppStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unbondingHeight, int32(coreTypes.StakeStatus_Unstaking)) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - er = uow.persistenceRWContext.SetFishermanStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unbondingHeight, int32(coreTypes.StakeStatus_Unstaking)) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + er = uow.persistenceRWContext.SetWatcherStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unbondingHeight, int32(coreTypes.StakeStatus_Unstaking)) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: er = uow.persistenceRWContext.SetServicerStatusAndUnstakingHeightIfPausedBefore(pausedBeforeHeight, unbondingHeight, int32(coreTypes.StakeStatus_Unstaking)) case coreTypes.ActorType_ACTOR_TYPE_VAL: diff --git a/utility/unit_of_work/gov.go b/utility/unit_of_work/gov.go index 29a561a47..a1050c616 100644 --- a/utility/unit_of_work/gov.go +++ b/utility/unit_of_work/gov.go @@ -59,20 +59,20 @@ func prepareGovParamParamTypesMap() map[string]int { typesUtil.ValidatorMaxEvidenceAgeInBlocksParamName: INT, typesUtil.DoubleSignBurnPercentageParamName: INT, typesUtil.MissedBlocksBurnPercentageParamName: INT, - typesUtil.FishermanMinimumStakeParamName: BIGINT, - typesUtil.FishermanMaxChainsParamName: INT, - typesUtil.FishermanUnstakingBlocksParamName: INT64, - typesUtil.FishermanMinimumPauseBlocksParamName: INT, - typesUtil.FishermanMaxPauseBlocksParamName: INT, - typesUtil.FishermanPerSessionParamName: INT, + typesUtil.WatcherMinimumStakeParamName: BIGINT, + typesUtil.WatcherMaxChainsParamName: INT, + typesUtil.WatcherUnstakingBlocksParamName: INT64, + typesUtil.WatcherMinimumPauseBlocksParamName: INT, + typesUtil.WatcherMaxPauseBlocksParamName: INT, + typesUtil.WatcherPerSessionParamName: INT, typesUtil.MessageDoubleSignFee: BIGINT, typesUtil.MessageSendFee: BIGINT, - typesUtil.MessageStakeFishermanFee: BIGINT, - typesUtil.MessageEditStakeFishermanFee: BIGINT, - typesUtil.MessageUnstakeFishermanFee: BIGINT, - typesUtil.MessagePauseFishermanFee: BIGINT, - typesUtil.MessageUnpauseFishermanFee: BIGINT, - typesUtil.MessageFishermanPauseServicerFee: BIGINT, + typesUtil.MessageStakeWatcherFee: BIGINT, + typesUtil.MessageEditStakeWatcherFee: BIGINT, + typesUtil.MessageUnstakeWatcherFee: BIGINT, + typesUtil.MessagePauseWatcherFee: BIGINT, + typesUtil.MessageUnpauseWatcherFee: BIGINT, + typesUtil.MessageWatcherPauseServicerFee: BIGINT, typesUtil.MessageTestScoreFee: BIGINT, typesUtil.MessageProveTestScoreFee: BIGINT, typesUtil.MessageStakeAppFee: BIGINT, @@ -157,8 +157,8 @@ func (u *baseUtilityUnitOfWork) getFee(msg typesUtil.Message, actorType coreType switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: return getGovParam[*big.Int](u, typesUtil.MessageStakeAppFee) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - return getGovParam[*big.Int](u, typesUtil.MessageStakeFishermanFee) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + return getGovParam[*big.Int](u, typesUtil.MessageStakeWatcherFee) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: return getGovParam[*big.Int](u, typesUtil.MessageStakeServicerFee) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -170,8 +170,8 @@ func (u *baseUtilityUnitOfWork) getFee(msg typesUtil.Message, actorType coreType switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: return getGovParam[*big.Int](u, typesUtil.MessageEditStakeAppFee) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - return getGovParam[*big.Int](u, typesUtil.MessageEditStakeFishermanFee) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + return getGovParam[*big.Int](u, typesUtil.MessageEditStakeWatcherFee) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: return getGovParam[*big.Int](u, typesUtil.MessageEditStakeServicerFee) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -183,8 +183,8 @@ func (u *baseUtilityUnitOfWork) getFee(msg typesUtil.Message, actorType coreType switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: return getGovParam[*big.Int](u, typesUtil.MessageUnstakeAppFee) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - return getGovParam[*big.Int](u, typesUtil.MessageUnstakeFishermanFee) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + return getGovParam[*big.Int](u, typesUtil.MessageUnstakeWatcherFee) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: return getGovParam[*big.Int](u, typesUtil.MessageUnstakeServicerFee) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -196,8 +196,8 @@ func (u *baseUtilityUnitOfWork) getFee(msg typesUtil.Message, actorType coreType switch actorType { case coreTypes.ActorType_ACTOR_TYPE_APP: return getGovParam[*big.Int](u, typesUtil.MessageUnpauseAppFee) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - return getGovParam[*big.Int](u, typesUtil.MessageUnpauseFishermanFee) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + return getGovParam[*big.Int](u, typesUtil.MessageUnpauseWatcherFee) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: return getGovParam[*big.Int](u, typesUtil.MessageUnpauseServicerFee) case coreTypes.ActorType_ACTOR_TYPE_VAL: diff --git a/utility/unit_of_work/tx_message_handler.go b/utility/unit_of_work/tx_message_handler.go index 6c696e14c..769d2a446 100644 --- a/utility/unit_of_work/tx_message_handler.go +++ b/utility/unit_of_work/tx_message_handler.go @@ -109,8 +109,8 @@ func (u *baseUtilityUnitOfWork) handleStakeMessage(message *typesUtil.MessageSta switch message.ActorType { case coreTypes.ActorType_ACTOR_TYPE_APP: er = u.persistenceRWContext.InsertApp(publicKey.Address(), publicKey.Bytes(), message.OutputAddress, false, int32(coreTypes.StakeStatus_Staked), message.Amount, message.Chains, typesUtil.HeightNotUsed, typesUtil.HeightNotUsed) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - er = u.persistenceRWContext.InsertFisherman(publicKey.Address(), publicKey.Bytes(), message.OutputAddress, false, int32(coreTypes.StakeStatus_Staked), message.ServiceUrl, message.Amount, message.Chains, typesUtil.HeightNotUsed, typesUtil.HeightNotUsed) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + er = u.persistenceRWContext.InsertWatcher(publicKey.Address(), publicKey.Bytes(), message.OutputAddress, false, int32(coreTypes.StakeStatus_Staked), message.ServiceUrl, message.Amount, message.Chains, typesUtil.HeightNotUsed, typesUtil.HeightNotUsed) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: er = u.persistenceRWContext.InsertServicer(publicKey.Address(), publicKey.Bytes(), message.OutputAddress, false, int32(coreTypes.StakeStatus_Staked), message.ServiceUrl, message.Amount, message.Chains, typesUtil.HeightNotUsed, typesUtil.HeightNotUsed) case coreTypes.ActorType_ACTOR_TYPE_VAL: @@ -166,8 +166,8 @@ func (u *baseUtilityUnitOfWork) handleEditStakeMessage(message *typesUtil.Messag switch message.ActorType { case coreTypes.ActorType_ACTOR_TYPE_APP: er = u.persistenceRWContext.UpdateApp(message.Address, message.Amount, message.Chains) - case coreTypes.ActorType_ACTOR_TYPE_FISH: - er = u.persistenceRWContext.UpdateFisherman(message.Address, message.ServiceUrl, message.Amount, message.Chains) + case coreTypes.ActorType_ACTOR_TYPE_WATCHER: + er = u.persistenceRWContext.UpdateWatcher(message.Address, message.ServiceUrl, message.Amount, message.Chains) case coreTypes.ActorType_ACTOR_TYPE_SERVICER: er = u.persistenceRWContext.UpdateServicer(message.Address, message.ServiceUrl, message.Amount, message.Chains) case coreTypes.ActorType_ACTOR_TYPE_VAL: diff --git a/utility/unit_of_work/unit_of_work_test.go b/utility/unit_of_work/unit_of_work_test.go index aa295d981..f4a353507 100644 --- a/utility/unit_of_work/unit_of_work_test.go +++ b/utility/unit_of_work/unit_of_work_test.go @@ -21,7 +21,7 @@ const ( testingValidatorCount = 5 testingServicerCount = 1 testingApplicationCount = 1 - testingFishermenCount = 1 + testingWatchersCount = 1 testNonce = "defaultNonceString" testSchema = "test_schema" @@ -118,7 +118,7 @@ func newTestRuntimeConfig(databaseURL string) *runtime.Manager { testingValidatorCount, testingServicerCount, testingApplicationCount, - testingFishermenCount, + testingWatchersCount, ) runtimeCfg := runtime.NewManager(cfg, genesisState) return runtimeCfg diff --git a/utility/unit_of_work/uow_leader_test.go b/utility/unit_of_work/uow_leader_test.go index feef2f37d..45b830907 100644 --- a/utility/unit_of_work/uow_leader_test.go +++ b/utility/unit_of_work/uow_leader_test.go @@ -110,11 +110,11 @@ func newDefaultMockRWContext(t *testing.T, ctrl *gomock.Controller) *mockModules mockrwcontext.EXPECT().GetAppsReadyToUnstake(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockrwcontext.EXPECT().GetServicersReadyToUnstake(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockrwcontext.EXPECT().GetValidatorsReadyToUnstake(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() - mockrwcontext.EXPECT().GetFishermenReadyToUnstake(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() + mockrwcontext.EXPECT().GetWatchersReadyToUnstake(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockrwcontext.EXPECT().SetServicerStatusAndUnstakingHeightIfPausedBefore(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() mockrwcontext.EXPECT().SetAppStatusAndUnstakingHeightIfPausedBefore(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() mockrwcontext.EXPECT().SetValidatorsStatusAndUnstakingHeightIfPausedBefore(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockrwcontext.EXPECT().SetFishermanStatusAndUnstakingHeightIfPausedBefore(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + mockrwcontext.EXPECT().SetWatcherStatusAndUnstakingHeightIfPausedBefore(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() return mockrwcontext } diff --git a/utility/watcher/module.go b/utility/watcher/module.go new file mode 100644 index 000000000..784695487 --- /dev/null +++ b/utility/watcher/module.go @@ -0,0 +1,57 @@ +package watcher + +import ( + "github.com/pokt-network/pocket/logger" + "github.com/pokt-network/pocket/shared/modules" + "github.com/pokt-network/pocket/shared/modules/base_modules" +) + +const ( + WatcherModuleName = "watcher" +) + +type watcher struct { + base_modules.IntegrableModule + logger *modules.Logger +} + +var ( + _ modules.WatcherModule = &watcher{} +) + +func CreateWatcher(bus modules.Bus, options ...modules.ModuleOption) (modules.WatcherModule, error) { + m, err := new(watcher).Create(bus, options...) + if err != nil { + return nil, err + } + return m.(modules.WatcherModule), nil +} + +func (*watcher) Create(bus modules.Bus, options ...modules.ModuleOption) (modules.Module, error) { + m := &watcher{} + + for _, option := range options { + option(m) + } + + bus.RegisterModule(m) + + m.logger = logger.Global.CreateLoggerForModule(m.GetModuleName()) + + return m, nil +} + +// TODO: implement this function +func (m *watcher) Start() error { + m.logger.Info().Msg("🎣 Watcher module started 🎣") + return nil +} + +func (m *watcher) Stop() error { + m.logger.Info().Msg("🎣 Watcher module stopped 🎣") + return nil +} + +func (m *watcher) GetModuleName() string { + return WatcherModuleName +}