Commit Graph

104 Commits

Author SHA1 Message Date
Michael Vines ed0389f708 Add forward compatibility with solana-client 1.6.10 2021-05-22 00:00:33 -07:00
Jon Cinque ea98e6bf73
stake-pool: Fix fee calculation (#1764)
* stake-pool: Fix fee calculation

* Remove unwraps, widen one more calc
2021-05-20 11:53:06 +00:00
Jon Cinque d4bbdf8224
stake-pool-cli: Bump version for release (#1713)
* stake-pool-cli: Bump version for release

* Update lock file
2021-05-12 13:20:48 +00:00
Jon Cinque 731bb6f57a
stake-pool: Bump version for release (#1707) 2021-05-11 21:46:49 +00:00
Jon Cinque cebb3176b2
stake-pool: Add helper instruction creators for stake pool integration (#1706)
* stake-pool: Add more instructions for easier usage

* Add extra check (shouldn't be necessary, but who knows?)
2021-05-11 20:48:58 +00:00
Jon Cinque d68608c440
stake-pool: Re-enable tests, avoid warping so much (#1687) 2021-05-10 12:33:56 +00:00
jordansexton f0b1cec4d8 stake-pool: minor typo fix 2021-05-07 13:50:35 -05:00
Trent Nelson 1f36ca301b Bump solana crates to v1.6.7 2021-05-05 04:39:49 +00:00
Jon Cinque 3dd6767297
stake-pool: Update versions for crate deployment (#1657) 2021-05-03 20:50:49 +00:00
Jon Cinque 9c63bc0b06
stake-pool-cli: All sorts of fixes (#1650)
While going back through the docs, I ended up doing a lot of the stake
pool CLI items:

* Deposit / withdraw command: Use associated token account by default
* Create command: Allow passing the stake pool and mint keypair (useful
  for testing)
* Create command: Split the transaction for pool creation (required to get under the
  transaction size limit)
* Add / remove validator command: take a validator vote account rather than stake
  account, which makes integration from outside tools a lot simpler
* Update command: add a `--force` flag to force the update
* Update command: add a `--no-merge` flag to not merge while updating
  (useful to allow the pool to work, even if the transient stake
  accounts are unmergeable)
* Withdraw: Add `--use-reserve` flag to withdraw from reserve
* Withdraw: Add `--vote-account` arg to specify which validator to
  withdraw from
2021-05-03 11:47:24 +02:00
Jon Cinque 11e207cc85
stake-pool: Add user transfer authority on withdraw (#1640)
The stake pool expects pool tokens to be delegated to the withdraw
authority before performing a withdrawal. If a user delegates too many
tokens to the withdraw authority, anyone else can take the rest of their
tokens by doing their own withdrawal.

Delegate pool tokens to an ephemeral keypair and sign with that.
2021-04-27 12:53:46 +00:00
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