Skip to content

Commit 9e17e76

Browse files
authored
Merge pull request #98 from casper-network/feat/CD-92/withdraw-bid-all
[CD-92] Update withdraw-bid guardrails info
2 parents a8d1c77 + 7ca0b2f commit 9e17e76

File tree

4 files changed

+71
-104
lines changed

4 files changed

+71
-104
lines changed

docs/developers/dapps/setup-nctl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,5 @@ $ nctl-clean
268268

269269
## Next Steps {#next-steps}
270270

271-
1. Explore the [various NCTL commands](https://github.com/casper-network/casper-node/blob/master/utils/nctl/docs/commands.md).
272-
2. Explore the [NCTL usage guide](https://github.com/casper-network/casper-node/blob/master/utils/nctl/docs/usage.md).
271+
1. Explore the [various NCTL commands](https://github.com/casper-network/casper-nctl/blob/dev/docs/commands-ctl.md).
272+
2. Explore the [NCTL usage guide](https://github.com/casper-network/casper-nctl/blob/dev/docs/usage.md).

docs/operators/becoming-a-validator/unbonding.md

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Unbonding
66

77
Once a bid is placed, it will remain in the state of the auction contract, even if the bid fails to win a slot immediately. New slots may become available if bonded validators leave the network or reduce their bond amounts. Therefore, a bid must be explicitly withdrawn to remove it from the auction.
88

9-
## Method 1: Unbonding with the System Auction Contract {#withdraw-system-auction}
9+
## Unbonding with the System Auction Contract {#withdraw-system-auction}
1010

1111
This method withdraws a bid using the system auction contract. Call the existing `withdraw_bid` entry point from the system auction contract. Using this method, you do not need to build any contracts, reducing costs and complexity.
1212

@@ -46,6 +46,39 @@ Calling the `withdraw_bid` entry point on the auction contract has a fixed cost
4646

4747
:::
4848

49+
## `withdraw-bid` Guardrails
50+
51+
There are additional guardrails in place to ensure accidental full withdrawal/unstaking of the stakes.
52+
53+
- `withdraw-bid` will check if the withdraw bid will not result in a Validator's stake dropping below the Validator minimum bid threshold. It will return an error if a Validator's staked amount will fall below the minimum bid amount for Validators when executing the transaction.
54+
- `withdraw-bid-all` is a sub-command that takes in a public key of a Validator and produces a withdraw bid transaction that will completely unbond the Validator.
55+
- A minimum-bid override flag `min-bid-override` is available for Validators to log a warning to the standard output and produce/send the withdraw bid transaction.
56+
- The withdraw-bid guardrails have been extended to `put-transaction` and `put-deploy` subcommands that invoke the entry point via stored contract by hash/name and package by hash/name.
57+
58+
**Guardrails Example :**
59+
60+
| Case | Stake Scenario | Transaction | Result |
61+
|--------------|----------------------|-------------------|--------|
62+
| **When the withdraw-bid transaction will result in remaining stake falling below the minimum bid threshold - i.e. <10,000,000,000,000 motes** | <br/>Staked: 17,536,609,871,045 motes<br/><br/>Withdraw: 17,536,609,871,045 motes <br/><br/>Remaining Stake: 0 motes | `withdraw-bid` <br/>without<br/>`--min-bid-override` | Client guardrail prevents execution with <br/>"**Attempting to withdraw bid will reduce stake below the minimum amount.**" error |
63+
| **When the withdraw-bid transaction will result in remaining stake being equal to or over the minimum bid threshold - i.e. >=10,000,000,000,000 motes** | <br/>Staked: 17,536,609,871,045 motes<br/><br/>Withdraw: 7,536,609,871,045 motes <br/><br/>Remaining Stake: 10,000,000,000,000 motes | `withdraw-bid` <br/>without<br/>`--min-bid-override` | Transaction will execute successfully |
64+
| **When the withdraw-bid transaction with min-bid-override flag will result in remaining stake being less than minimum bid threshold - i.e. <10,000,000,000,000 motes** | <br/>Before: 17,536,609,871,045 motes<br/><br/>Withdraw: 17,536,609,871,044 motes | `withdraw-bid` <br/>with<br/>`--min-bid-override` | Transaction will execute with a warning `Execution of this withdraw bid will result in unbonding of all stake` |
65+
| **When the withdraw-bid transaction with min-bid-override flag will result in remaining stake being equal to or greater than minimum bid threshold - i.e. >=10,000,000,000,000 motes** | <br/>Before: 17,536,609,871,045 motes<br/><br/>Withdraw: 7,536,609,871,044 motes | `withdraw-bid` <br/>with<br/>`--min-bid-override` | Transaction will execute successfully |
66+
67+
**How to use the `min-bid-override` flag in a transaction?**
68+
69+
Example transaction with `min-bid-override` flag:
70+
```bash
71+
casper-client put-transaction withdraw-bid \
72+
--public-key 01733fe8a5d57837e404fb994da618d8a1757c9b8290fb331db28b9df61423f038 \
73+
--transaction-amount 119999596675466 \
74+
--min-bid-override \
75+
--chain-name casper-test \
76+
--secret-key /etc/casper/validator_keys/secret_key.pem \
77+
--standard-payment true \
78+
--gas-price-tolerance 1 \
79+
--payment-amount 2500000000
80+
```
81+
4982
**Example:**
5083

5184
This example command uses the Casper Testnet to withdraw 5 CSPR from the bid:
@@ -76,55 +109,6 @@ sudo -u casper casper-client put-deploy \
76109
--session-arg "amount:U512='$[5 * 1000000000]'"
77110
```
78111

79-
## Method 2: Unbonding with Compiled Wasm {#withdraw-compiled-wasm}
80-
81-
There is a second way to withdraw a bid, using the compiled Wasm `withdraw_bid.wasm`. The process is the same as bonding but uses a different contract.
82-
83-
```bash
84-
sudo -u casper casper-client put-deploy \
85-
--node-address <HOST:PORT> \
86-
--secret-key <PATH> \
87-
--chain-name <CHAIN_NAME> \
88-
--payment-amount <PAYMENT_AMOUNT> \
89-
--session-path <PATH>/casper-node/target/wasm32-unknown-unknown/release/withdraw_bid.wasm \
90-
--session-arg="public_key:public_key='<PUBLIC_KEY_HEX>'" \
91-
--session-arg="amount:u512='<AMOUNT_TO_WITHDRAW>'"
92-
```
93-
94-
1. `node-address` - An IP address of a peer on the network. The default port of nodes' JSON-RPC servers on Mainnet and Testnet is 7777
95-
2. `secret-key` - The file name containing the secret key of the account paying for the Deploy
96-
3. `chain-name` - The chain-name to the network where you wish to send the Deploy. For Mainnet, use *casper*. For Testnet, use *casper-test*
97-
4. `payment-amount` - The payment for the Deploy in motes estimated
98-
5. `session-path` - The path to the compiled Wasm on your computer
99-
100-
The `withdraw_bid.wasm` expects two arguments, while the third one is optional:
101-
102-
6. `public key`: The hexadecimal public key of the account's purse to withdraw. This key must match the secret key that signs the deploy and has to match the public key of a bid in the auction contract
103-
7. `amount`: The amount being withdrawn
104-
105-
The command will return a deploy hash, which is needed to verify the deploy's processing results.
106-
107-
:::note
108-
109-
This method is more expensive than calling the `withdraw_bid` entrypoint in the system auction contract, which has a fixed cost of 2.5 CSPR.
110-
111-
:::
112-
113-
**Example:**
114-
115-
Here is an example request to unbond stake using the `withdraw_bid.wasm`. The payment amount specified is 4 CSPR. You must modify the payment and other values in the deploy based on the network's [chainspec.toml](../../concepts/glossary/C.md#chainspec).
116-
117-
```bash
118-
sudo -u casper casper-client put-deploy \
119-
--node-address http://65.21.75.254:7777 \
120-
--secret-key /etc/casper/validator_keys/secret_key.pem \
121-
--chain-name casper-test \
122-
--session-path $HOME/casper-node/target/wasm32-unknown-unknown/release/withdraw_bid.wasm \
123-
--payment-amount 4000000000 \
124-
--session-arg="public_key:public_key='01c297d2931fec7e22b2fb1ae3ca5afdfacc2c82ba501e8ed158eecef82b4dcdee'" \
125-
--session-arg="amount:u512='1000000000000'"
126-
```
127-
128112

129113
## Check the Auction Contract {#check-the-auction-contract}
130114

versioned_docs/version-2.0.0/developers/dapps/setup-nctl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,5 @@ $ nctl-clean
268268

269269
## Next Steps {#next-steps}
270270

271-
1. Explore the [various NCTL commands](https://github.com/casper-network/casper-node/blob/master/utils/nctl/docs/commands.md).
272-
2. Explore the [NCTL usage guide](https://github.com/casper-network/casper-node/blob/master/utils/nctl/docs/usage.md).
271+
1. Explore the [various NCTL commands](https://github.com/casper-network/casper-nctl/blob/dev/docs/commands-ctl.md).
272+
2. Explore the [NCTL usage guide](https://github.com/casper-network/casper-nctl/blob/dev/docs/usage.md).

versioned_docs/version-2.0.0/operators/becoming-a-validator/unbonding.md

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,39 @@ Calling the `withdraw_bid` entry point on the auction contract has a fixed cost
4646

4747
:::
4848

49+
## `withdraw-bid` Guardrails
50+
51+
There are additional guardrails in place to ensure accidental full withdrawal/unstaking of the stakes.
52+
53+
- `withdraw-bid` will check if the withdraw bid will not result in a Validator's stake dropping below the Validator minimum bid threshold. It will return an error if a Validator's staked amount will fall below the minimum bid amount for Validators when executing the transaction.
54+
- `withdraw-bid-all` is a sub-command that takes in a public key of a Validator and produces a withdraw bid transaction that will completely unbond the Validator.
55+
- A minimum-bid override flag `min-bid-override` is available for Validators to use it when they want to override the minimum bid staking amount check to the standard output when they produce/send the withdraw bid transaction.
56+
- The withdraw-bid guardrails have been extended to `put-transaction` and `put-deploy` subcommands that invoke the entry point via stored contract by hash/name and package by hash/name.
57+
58+
**Guardrails Example :**
59+
60+
| Case | Stake Scenario | Transaction | Result |
61+
|--------------|----------------------|-------------------|--------|
62+
| **When the withdraw-bid transaction will result in remaining stake falling below the minimum bid threshold - i.e. <10,000,000,000,000 motes** | <br/>Staked: 17,536,609,871,045 motes<br/><br/>Withdraw: 17,536,609,871,045 motes <br/><br/>Remaining Stake: 0 motes | `withdraw-bid` <br/>without<br/>`--min-bid-override` | Client guardrail prevents execution with <br/>"**Attempting to withdraw bid will reduce stake below the minimum amount.**" error |
63+
| **When the withdraw-bid transaction will result in remaining stake being equal to or over the minimum bid threshold - i.e. >=10,000,000,000,000 motes** | <br/>Staked: 17,536,609,871,045 motes<br/><br/>Withdraw: 7,536,609,871,045 motes <br/><br/>Remaining Stake: 10,000,000,000,000 motes | `withdraw-bid` <br/>without<br/>`--min-bid-override` | Transaction will execute successfully |
64+
| **When the withdraw-bid transaction with min-bid-override flag will result in remaining stake being less than minimum bid threshold - i.e. <10,000,000,000,000 motes** | <br/>Before: 17,536,609,871,045 motes<br/><br/>Withdraw: 17,536,609,871,044 motes | `withdraw-bid` <br/>with<br/>`--min-bid-override` | Transaction will execute with a warning `Execution of this withdraw bid will result in unbonding of all stake` |
65+
| **When the withdraw-bid transaction with min-bid-override flag will result in remaining stake being equal to or greater than minimum bid threshold - i.e. >=10,000,000,000,000 motes** | <br/>Before: 17,536,609,871,045 motes<br/><br/>Withdraw: 7,536,609,871,044 motes | `withdraw-bid` <br/>with<br/>`--min-bid-override` | Transaction will execute successfully |
66+
67+
**How to use the `min-bid-override` flag in a transaction?**
68+
69+
Example transaction with `min-bid-override` flag:
70+
```bash
71+
casper-client put-transaction withdraw-bid \
72+
--public-key 01733fe8a5d57837e404fb994da618d8a1757c9b8290fb331db28b9df61423f038 \
73+
--transaction-amount 119999596675466 \
74+
--min-bid-override \
75+
--chain-name casper-test \
76+
--secret-key /etc/casper/validator_keys/secret_key.pem \
77+
--standard-payment true \
78+
--gas-price-tolerance 1 \
79+
--payment-amount 2500000000
80+
```
81+
4982
**Example:**
5083

5184
This example command uses the Casper Testnet to withdraw 5 CSPR from the bid:
@@ -76,56 +109,6 @@ sudo -u casper casper-client put-deploy \
76109
--session-arg "amount:U512='$[5 * 1000000000]'"
77110
```
78111

79-
## Method 2: Unbonding with Compiled Wasm {#withdraw-compiled-wasm}
80-
81-
There is a second way to withdraw a bid, using the compiled Wasm `withdraw_bid.wasm`. The process is the same as bonding but uses a different contract.
82-
83-
```bash
84-
sudo -u casper casper-client put-deploy \
85-
--node-address <HOST:PORT> \
86-
--secret-key <PATH> \
87-
--chain-name <CHAIN_NAME> \
88-
--payment-amount <PAYMENT_AMOUNT> \
89-
--session-path <PATH>/casper-node/target/wasm32-unknown-unknown/release/withdraw_bid.wasm \
90-
--session-arg="public_key:public_key='<PUBLIC_KEY_HEX>'" \
91-
--session-arg="amount:u512='<AMOUNT_TO_WITHDRAW>'"
92-
```
93-
94-
1. `node-address` - An IP address of a peer on the network. The default port of nodes' JSON-RPC servers on Mainnet and Testnet is 7777
95-
2. `secret-key` - The file name containing the secret key of the account paying for the Deploy
96-
3. `chain-name` - The chain-name to the network where you wish to send the Deploy. For Mainnet, use *casper*. For Testnet, use *casper-test*
97-
4. `payment-amount` - The payment for the Deploy in motes estimated
98-
5. `session-path` - The path to the compiled Wasm on your computer
99-
100-
The `withdraw_bid.wasm` expects two arguments, while the third one is optional:
101-
102-
6. `public key`: The hexadecimal public key of the account's purse to withdraw. This key must match the secret key that signs the deploy and has to match the public key of a bid in the auction contract
103-
7. `amount`: The amount being withdrawn
104-
105-
The command will return a deploy hash, which is needed to verify the deploy's processing results.
106-
107-
:::note
108-
109-
This method is more expensive than calling the `withdraw_bid` entrypoint in the system auction contract, which has a fixed cost of 2.5 CSPR.
110-
111-
:::
112-
113-
**Example:**
114-
115-
Here is an example request to unbond stake using the `withdraw_bid.wasm`. The payment amount specified is 4 CSPR. You must modify the payment and other values in the deploy based on the network's [chainspec.toml](../../concepts/glossary/C.md#chainspec).
116-
117-
```bash
118-
sudo -u casper casper-client put-deploy \
119-
--node-address http://65.21.75.254:7777 \
120-
--secret-key /etc/casper/validator_keys/secret_key.pem \
121-
--chain-name casper-test \
122-
--session-path $HOME/casper-node/target/wasm32-unknown-unknown/release/withdraw_bid.wasm \
123-
--payment-amount 4000000000 \
124-
--session-arg="public_key:public_key='01c297d2931fec7e22b2fb1ae3ca5afdfacc2c82ba501e8ed158eecef82b4dcdee'" \
125-
--session-arg="amount:u512='1000000000000'"
126-
```
127-
128-
129112
## Check the Auction Contract {#check-the-auction-contract}
130113

131114
Check the auction contract for updates to the bid amounts.

0 commit comments

Comments
 (0)