-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize keeper, improve tx confirmation (#76)
* use \_with\_history for confirmation otherwise txs expire after 300 blocks * Touch up keeper README * Rename keeper
- Loading branch information
Showing
32 changed files
with
154 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
keepers/validator-keeper/Cargo.toml → keepers/stakenet-keeper/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 33 additions & 16 deletions
49
keepers/validator-keeper/README.md → keepers/stakenet-keeper/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,70 @@ | ||
## Keeper State | ||
# StakeNet Keeper Bot | ||
|
||
## Overview | ||
|
||
This is a service that permissionlessly maintains the StakeNet Validator History and Steward programs. It ensures that Validator History data is kept up to date, and that the Steward program is properly moving through its regular operations to maintain the targeted stake pool. Operations, program addresses, and transaction submission details, can be configured via arguments or environment variables. | ||
|
||
## Usage | ||
|
||
See [keeper-bot-quick-start.md](../../keeper-bot-quick-start.md) for instructions on how to build and run this service. | ||
|
||
## Program Layout | ||
|
||
### Keeper State | ||
|
||
The `KeeperState` keeps track of: | ||
|
||
- current epoch data | ||
- running tally of all operations successes and failures for the given epoch | ||
- all accounts fetched from the RPC that are needed downstream | ||
|
||
Note: All maps are key'd by the `vote_account` | ||
|
||
## Program | ||
|
||
### Initialize | ||
Gather all needed arguments, and initialize the global `KeeperState`. | ||
|
||
Gather all needed arguments, and initialize the global `KeeperState`. | ||
|
||
### Loop | ||
The forever loop consists of three parts: **Fetch**, **Fire** and **Emit**. There is only ever one **Fetch** and **Emit** section, and there can be several **Fire** sections. | ||
|
||
The forever loop consists of three parts: **Fetch**, **Fire** and **Emit**. There is only ever one **Fetch** and **Emit** section, and there can be several **Fire** sections. | ||
|
||
The **Fire** sections can run on independent cadences - say we want the Validator History functions to run every 300sec and we want to emit metrics every 60sec. | ||
|
||
The **Fetch** section is run _before_ and **Fire** section. | ||
The **Emit** section is *one tick* after any **Fire** section. | ||
The **Fetch** section is run _before_ and **Fire** section. | ||
The **Emit** section is _one tick_ after any **Fire** section. | ||
|
||
#### Fetch | ||
|
||
The **Fetch** section is in charge of three operations: | ||
|
||
- Keeping track of the current epoch and resetting the runs and error counts for each operation | ||
- Creating any missing accounts needed for the downstream **Fires** to run | ||
- Fetching and updating all of the needed accounts needed downstream | ||
|
||
This is accomplished is by running three functions within the **Fetch** section | ||
|
||
- `pre_create_update` - Updates epoch, and fetches all needed accounts that are not dependant on any missing accounts. | ||
- `create_missing_accounts` - Creates the missing accounts, which can be determined by the accounts fetched in the previous step | ||
- `post_create_update` - Fetches any last accounts that needed the missing accounts | ||
- `post_create_update` - Fetches any last accounts that needed the missing accounts | ||
|
||
Since this is run before every **FIRE** section, some accounts will be fetched that are not needed. This may seem wasteful but the simplicity of having a synchronized global is worth the cost. | ||
|
||
Notes: | ||
- The **Fetch** section is the only section that will mutate the `KeeperState`. | ||
Notes: | ||
|
||
- The **Fetch** section is the only section that will mutate the `KeeperState`. | ||
- If anything in the **Fetch** section fails, no **Fires** will run | ||
|
||
#### Fire | ||
|
||
There are several **Fire** sections running at their own cadence. Before any **Fire** section is run, the **Fetch** section will be called. | ||
|
||
Each **Fire** is a call to `operations::operation_name::fire` which will fire off the operation and return the new count of runs and errors for that operation to be saved in the `KeeperState` | ||
|
||
Notes: | ||
- Each **Fire** is self contained, one should not be dependant on another. | ||
- No **Fire* will fetch any accounts, if there are needs for them, they should be added to the `KeeperState` | ||
Notes: | ||
|
||
- Each **Fire** is self contained, one should not be dependant on another. | ||
- No \*_Fire_ will fetch any accounts, if there are needs for them, they should be added to the `KeeperState` | ||
|
||
#### Emit | ||
This section emits the state of the Keeper one tick after any operation has been called. This is because we want to emit a failure of any **Fetch** operation, which on failure advances the tick. | ||
|
||
|
||
|
||
This section emits the state of the Keeper one tick after any operation has been called. This is because we want to emit a failure of any **Fetch** operation, which on failure advances the tick. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.