Skip to content

Commit c245e6d

Browse files
authored
Merge pull request #674 from ethersphere/reserve-doubling
Add info about doubling reserve
2 parents caf7a28 + 842a68e commit c245e6d

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

docs/bee/working-with-bee/staking.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,124 @@ If there is any stake available for withdrawal, you can withdraw it using the `D
108108
curl -X DELETE http://localhost:1633/stake/withdrawable
109109
```
110110

111+
## Reserve Doubling
112+
113+
The reserve doubling feature enables nodes to store chunks from a neighboring "sister" area, effectively increasing their reserve capacity twofold. By maintaining chunks from this sister neighborhood, a node becomes eligible to join the redistribution game whenever the sister neighborhood is chosen, effectively doubling its chances of participating.
114+
115+
Although reserve doubling demands twice the disk storage and increases bandwidth usage for chunk syncing (with no additional bandwidth needed for chunk forwarding), its effect on CPU and RAM consumption remains minimal. This feature provides node operators with greater flexibility to optimize their nodes, aiming to achieve a higher reward-to-resource usage ratio.
116+
117+
### Step by Step Guide
118+
119+
In order to double a node's reserve which has previously been operating without doubling, the `reserve-capacity-doubling` option must be updated from the default of `0` to `1` and restarted. There is also an increase in the xBZZ stake requirement from the minimum of 10 xBZZ to 20 xBZZ.
120+
121+
#### **Step 1**: Stake at least 20 xBZZ
122+
123+
For doubling the reserve of a node which was previously operating which already has 10 xBZZ staked, simply stake an additional 10 xBZZ for a total of 20 xBZZ stake:
124+
125+
:::info
126+
As always, make sure that to properly convert the stake parameter to PLUR where 1 PLUR is equal to 1e-16 xBZZ. As in our example below, we have converted from 10 xBZZ to 100000000000000000 PLUR.
127+
:::
128+
129+
```bash
130+
curl -X POST localhost:1633/stake/100000000000000000
131+
```
132+
133+
Or for a new node with zero staked xBZZ, the entire 20 xBZZ can be staked at once:
134+
135+
```bash
136+
curl -X POST localhost:1633/stake/200000000000000000
137+
```
138+
139+
We can use the `GET /stake` endpoint to confirm the total stake for our node:
140+
141+
```bash
142+
curl -s http://localhost:1633/stake | jq
143+
```
144+
145+
```bash
146+
{
147+
"stakedAmount": "200000000000000000"
148+
}
149+
```
150+
#### **Step 2**: Set `reserve-capacity-doubling` to `1`.
151+
152+
The reserve doubling feature can be enabled by setting the new `reserve-capacity-doubling` config option to `1` using the [configuration method](/docs/bee/working-with-bee/configuration#configuration-methods-and-priority) of your choice.
153+
154+
#### **Step 3**: Restart node
155+
156+
After ensuring the node has at least 20 xBZZ staked and the `reserve-capacity-doubling` option has been set to `1`, restart the node.
157+
158+
After restarting your node, it should then begin syncing chunks from its sister neighborhood.
159+
160+
The `/status/neighborhoods` endpoint can be used to confirm that the node has doubled its reserve and is now syncing with its sister neighborhood:
161+
162+
```bash
163+
{
164+
"neighborhoods": [
165+
{
166+
"neighborhood": "01111101011",
167+
"reserveSizeWithinRadius": 1148351,
168+
"proximity": 10
169+
},
170+
{
171+
"neighborhood": "01111101010",
172+
"reserveSizeWithinRadius": 1147423,
173+
"proximity": 11
174+
}
175+
]
176+
}
177+
```
178+
179+
The expected output should contain two neighborhoods, the node's original neighborhood along with its sister neighborhood.
180+
181+
We can also check the `/status` endpoint to confirm our node is syncing new chunks:
182+
183+
```bash
184+
curl -s http://localhost:1633/status | jq
185+
```
186+
187+
```bash
188+
{
189+
"overlay": "be177e61b13b1caa20690311a909bd674a3c1ef5f00d60414f261856a8ad5c30",
190+
"proximity": 256,
191+
"beeMode": "full",
192+
"reserveSize": 4192792,
193+
"reserveSizeWithinRadius": 2295023,
194+
"pullsyncRate": 1.3033333333333332,
195+
"storageRadius": 10,
196+
"connectedPeers": 18,
197+
"neighborhoodSize": 1,
198+
"batchCommitment": 388104192,
199+
"isReachable": true,
200+
"lastSyncedBlock": 6982430
201+
}
202+
```
203+
204+
We can see that the `pullsyncRate` value is above zero, meaning that our node is currently syncing chunks, as expected.
205+
206+
### Reserve Doubling Reversing & Withdrawable Stake
207+
208+
Due to certain [implementation details](https://github.com/ethersphere/storage-incentives/blob/20bf3c0e3fcf1e98dedcbf16cd82fb4d337fdaf7/src/Staking.sol#L136), the order in which a node's reserve is doubled and then reversed can have an impact on the amount of withdrawable stake.
209+
210+
When doubling a node's reserve, stake should be added AFTER
211+
setting `reserve-capacity-doubling` to 1. If instead, xBZZ is first staked with `reserve-capacity-doubling` set to 0, and the reserve is then doubled by increasing from 0 to 1 without the addition of more stake, this will prevent stake from being withdrawable when the doubling is reversed.
212+
213+
In order to maximize the amount of withdrawable stake after reversing a reserve doubling, follow the step from the previous section in the exact order described when doubling.
214+
215+
#### How to free up withdrawable stake from a node with >= 20 xBZZ stake that currently has zero withdrawable stake:
216+
217+
In the case that a node with 20 xBZZ stake was doubled directly by increasing `reserve-capacity-doubling` from 0 to 1, the surplus xBZZ over the minimum required 10 xBZZ cannot be made withdrawable by simply reversing the `reserve-capacity-doubling` from 1 back to 0.
218+
219+
In this case, you will need to first send a very small staking transaction of a single PLUR while `reserve-capacity-doubling` is set to 1, and after that, change `reserve-capacity-doubling` from 1 to 0. This works because every time any amount of stake is added, it forces to staking contract to redo its calculations.
220+
221+
The detailed steps are:
222+
223+
1. Issue a staking transaction for 1 PLUR while `reserve-capacity-doubling` is set to 1.
224+
```bash
225+
curl -X POST localhost:1633/stake/1
226+
```
227+
2. Stop node and set `reserve-capacity-doubling` to 0.
228+
3. Restart node. The 10 xBZZ should now be withdrawable.
111229

112230
## Maximize rewards
113231

0 commit comments

Comments
 (0)