Commit Graph

93 Commits

Author SHA1 Message Date
Jon Cinque 14bdbdc3ac
stake-pool: Add ability to remove a validator that has deactivating transient stake (#1624)
* Add status enum

* Add ability to remove validator with transient stake

* Only account validator stake if active

* Fix merge conflicts
2021-04-27 13:24:39 +02:00
Jon Cinque 61a53abf6f
stake-pool: Add ability to withdraw from reserve if no stake available (#1627) 2021-04-23 23:55:16 +02:00
Michael Vines 1e47030549 Update SPL to Solana v1.6.6 2021-04-23 13:39:51 -07:00
Jon Cinque c149b0a46e
stake-pool: Add depositor key on init, required on deposit (#1616)
* stake-pool: Add depositor key on init, required on deposit

Some stake pools need to be private, and not allow outside depositors.

Enhance the existing deposit authority in the stake pool be configurable
on initialization, and then require its signature on deposit.

The existing deposit authority is a program address, making deposits
permissionless. This allows a pool creator to set their own deposit_authority on
initialization. In a great turn of events, almost everything else works
the same way!

Here's the current workflow for deposit, where the user calls
stake_program::authorize and stake_pool::deposit in the same
transaction:

* stake_program::authorize assigns staker and withdraw authority to the
  stake pool deposit authority
* stake_pool::deposit
    - uses the deposit authority to assign authority on the deposited
  stake account to the stake pool withdraw authority
    - uses the withdraw authority to merge the deposited stake into the validator stake

The deposit authority must "sign" the transaction in order to reassign
authority to the withdraw authority. Currently, as a program address, it
can just do that. With this change, if the deposit authority is set
during initialization, then that deposit authority must sign the
instruction.

There's also a little update for ease-of-use to always do the
stake_program::authorize in the same transaction as stake_pool::deposit.
This way, in case someone tries to deposit into a forbidden stake pool, the
whole transaction will bail and their stake will stay as theirs.

* Address review feedback

* Fix rebase issues
2021-04-22 21:34:41 +02:00
Jon Cinque 804a61e558
stake-pool: Increase lower limit for increase-validator-stake (#1620)
* stake-pool: Increase lower limit for increase-validator-stake

* Update test amounts in line with limit
2021-04-22 20:49:30 +02:00
Jon Cinque 3613ffe3b0
hotfix: ignore tests that break with tip of 1.6 (#1622) 2021-04-22 12:30:47 +00:00
Jon Cinque 08c4cb530a
stake-pool-cli: Add increase / decrease validator stake (#1619) 2021-04-22 00:20:35 +00:00
Jon Cinque fdba05714d
stake-pool: Add merging transient stakes in update (#1618)
* Add check for transient stake account activation on removal

* Add proper merging logic during update

* Format + clippy

* Add max possible validators

* Disallow removal for any transient stake state

* Reduce number of accounts for BPF instruction usage
2021-04-22 01:41:15 +02:00
Jon Cinque 53c86493e6
stake-pool: Add reserve stake and decrease / increase validator stake instruction (#1617)
* Add reserve stake account

* Add decrease validator stake instruction

* Cargo fmt

* Add increase instruction

* Add more increase tests

* Fix set fee tests

* Fix clippy in tests

* Add test-bpf feature to increase / decrease tests
2021-04-21 22:20:27 +02:00
Jon Cinque 40ebfc6917
stake-pool: Set fee (#1604)
* stake-pool: Add set_fee instruction

* Add more tests

* Add set-fee CLI instruction

* Update documentation

* Cargo fmt

* Re-format

* Fix clippy
2021-04-21 14:20:55 +02:00
Jon Cinque 30671aa5b3
stake-pool: Rework add / remove validator to not use pool tokens (#1581)
* Rework remove

* Add tests

* Transition to checked math

* Update CLI for new types / instructions

* Cargo fmt

* Rename voter_pubkey -> vote_account_address

* Remove max check

* Update validator balance test
2021-04-21 13:06:43 +02:00
Jon Cinque 71e5e556c4
stake-pool: Assess fee as a percentage of rewards (#1597)
* stake-pool: Collect fee every epoch as proportion of rewards

* Add more complete tests

* Update docs
2021-04-15 12:10:17 +02:00
Jon Cinque 2b3f71ead5
stake-pool: Add rebalancing instruction interface (#1563)
* stake-pool: Add rebalancing instruction interface

* Address feedback

* Rename again

* Ignore rustdoc code
2021-04-09 12:32:21 +02:00
Jon Cinque 7f89183c0d
stake-pool: Ensure zero pool token supply on init (#1572) 2021-04-05 20:06:40 +02:00
Michael Vines 17dd53d5e8 Break up the UpdateValidatorListBalance instructions over multiple transactions 2021-04-05 08:50:57 -07:00
Michael Vines ee52f1d499 Reimplement `spl-stake-pool list` command to use the StakePool/ValidatorList as the primary source of information 2021-04-02 16:27:42 -07:00
Jon Cinque 092432f1e1
stake-pool: Separate manager from owner (#1560)
* stake-pool: Separate manager from owner

* Add manager pubkey to stake pool
* Differentiate manager functions from owner functions
* Include a `set_manager` function to be used by the owner
* Change the term `owner` to `authority` in the CLI for clarity

* Rename manager -> staker and owner -> manager

* Split staker, manager, and token owner in CLI

* "Do not disturb the boss"
2021-04-02 10:56:12 +02:00
Michael Vines eb6cd994b8 More variable renaming 2021-04-01 07:40:18 +00:00
Michael Vines 48ab307cad Reboot program address derivation helpers 2021-03-31 23:57:44 -07:00
Michael Vines 67cb90f39c De-tangle processor/state dependencies 2021-03-31 22:00:20 -07:00
Michael Vines b97849d206 Code cleanup v2 2021-03-31 19:52:17 -07:00
Michael Vines 2cd7adbf87 Code cleanup v1 2021-03-31 15:37:50 -07:00
Michael Vines eb1bf2eb44 Code cleanup v0 2021-03-31 12:28:08 -07:00
Jack May f390e12311
Allow for fixed error mappings (#1541) 2021-03-30 17:30:44 -07:00
Jon Cinque 9f38a6f4b2
Rework create validator stake account (#1539) 2021-03-31 00:54:15 +02:00
Michael Vines 19e1161be2 Minor config -> rpc_client refactor 2021-03-30 15:29:55 -07:00
Jon Cinque 9e4f190633
stake-pool: Rename instructions / structs (#1536)
* stake-pool: Rename instructions / structs

* Cargo fmt

* Fix proptest
2021-03-30 23:54:06 +02:00
Michael Vines 024766161c Automatically update the stake pool if needed, use the `--no-update` flag to disable 2021-03-30 12:56:30 -07:00
Michael Vines 8ad223ac4e add-validator-stake now cleanly errors if non-active stake is provided 2021-03-30 11:44:24 -07:00
Michael Vines a029447484 Move to positional parameters 2021-03-30 09:40:23 -07:00
Michael Vines 448be67cfa Update to Solana 1.6.2 2021-03-30 09:38:04 -07:00
Jon Cinque d815ba9b8e
stake-pool: Add borsh support and specify size on creation (#1505)
* lending: Update JS tests to solana-test-validator

* Add solana tools install

* Fix oopsie on the path

* Move where deployed programs go

* stake-pool: Add borsh support and size on creation

We can't specify the size in the instruction unfortunately, since we'd
only have 10kb max for the validator list. At roughly 50 bytes per
validator, that only gives us 200 validators.

On the flip side, using Borsh means we can allow the validator stake list
to be any size!

* Add AccountType enum

* Remove V1 everywhere

* Add max validators as parameter and get_instance_packed_len

* Add test for adding too many validators

* Clippy
2021-03-27 13:42:29 +01:00
Jon Cinque d336b8b714
stake-pool: Use checked_ceil_div for withdraw calc (#1482)
* stake-pool: Use checked_ceil_div for withdraw calc

When a stake account is totally removed from a stake pool by the
manager, there's a chance that the operation would not take enough of
the manager's pool tokens by 1 due to truncation.

Do a ceiling division instead, and refactor ceiling division into the
math library.

* Use new function name on CLI

* Cargo fmt
2021-03-23 00:33:51 +01:00
Yuriy Savchenko d0bf7157cf
Set staking authority instruction removed (#1469)
* Set staking authority instruction removed

* Fixed fmt errors
2021-03-18 12:21:01 +01:00
Michael Vines 662f38f939 Bump Solana version to 1.6.1 2021-03-18 04:07:16 +00:00
Michael Vines af5fdb3146 Bump Rust version to 1.50.0 2021-03-16 22:22:59 -07:00
Michael Vines 686444088b Bump Solana version to 1.5.15 2021-03-16 18:33:37 -07:00
Michael Vines 1bc52c30fd Remove yelling 2021-03-16 18:33:37 -07:00
Michael Vines 995d4a029f Remove tokio dev-dependency 2021-03-16 18:33:37 -07:00
Michael Vines c63d854ac7 Switch to Instruction::new_with_bincode 2021-03-16 18:33:37 -07:00
Jon Cinque 78f7f7f5de
stake-pool-cli: Fix withdraw calc for CLI / program consistency (#1422)
* stake-pool-cli: Fix withdraw calc for CLI / program consistency

* Run cargo fmt

* Integrate review feedback
2021-03-10 13:45:42 +01:00
Jon Cinque 2217950da1
stake-pool-cli: Rename burn -> withdraw (#1423) 2021-03-10 10:38:44 +01:00
Jon Cinque 9c12b50703
Update solana-program to 1.5.11 (#1362)
* Update solana-program to 1.5.11

* Update all programs
2021-03-02 19:19:50 +01:00
Jon Cinque d536460d3f
stake-pool: Fix stake split and withdraw token calculation (#1352)
* Fix stake split and withdraw token calculation

* Cargo fmt
2021-03-01 21:39:21 +00:00
Jon Cinque 833ea9324d
stake-pool-cli: Fix update command, add verbosity (#1345)
* stake-pool-cli: Fix update command, add verbosity

The update command in the stake pool CLI was passing the validator vote
account instead of the associated stake account from the pool, causing
it to fail.  Additionally, add more verbose logging, and a dry-run mode
to get simulate transaction information, useful for debugging CLI
failures.

* Run cargo fmt
2021-02-27 00:57:38 +01:00
Jon Cinque d74b8c8f0a
stake-pool-cli: Update RPC client per TODO (#1304)
* Update deployed stake pool program id

* Add validator account takes 1 SOL instead of 1 lamport

* Fix "update" command for empty validator list

* Update dependencies

* Revert consequential changes

* Run cargo fmt

* Revert sdk

* Revert Cargo.lock
2021-02-23 00:28:06 +01:00
Jon Cinque d75fc5875c
stake-pool-cli: Fix update command for empty list (#1306) 2021-02-22 23:50:17 +01:00
Jon Cinque d31cd78a54
stake-pool: Validator stake account initialized with 1 SOL (#1305)
* stake-pool: Validator stake account initialized with 1 SOL

A validator stake account only has 1 lamport, which means that it will
gain very few rewards per epoch.  Its credits_observed is not
be reset each epoch, which makes it practically impossible to merge
into.  Get around this by instantiating them with more stake.

* Cargo fmt + fix tests
2021-02-22 23:50:05 +01:00
dependabot[bot] 1e5b376df6
build(deps): bump serde_json from 1.0.61 to 1.0.62 (#1265)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.61 to 1.0.62.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.61...v1.0.62)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-18 02:07:29 +00:00
dependabot[bot] 5b4c62ce49
build(deps): bump solana-program from 1.5.6 to 1.5.8 (#1261)
Bumps [solana-program](https://github.com/solana-labs/solana) from 1.5.6 to 1.5.8.
- [Release notes](https://github.com/solana-labs/solana/releases)
- [Changelog](https://github.com/solana-labs/solana/blob/master/RELEASE.md)
- [Commits](https://github.com/solana-labs/solana/compare/v1.5.6...v1.5.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-17 23:56:18 +00:00