Skip to content

Commit c12a619

Browse files
authored
Merge pull request #810 from ethersphere/fix/calculator-depth-cap
fix: cap postage stamp calculator depth at 34
2 parents 16895a0 + c3880be commit c12a619

2 files changed

Lines changed: 18 additions & 98 deletions

File tree

src/components/AmountAndDepthCalc.js

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function FetchPriceComponent() {
1818
const [timeError, setTimeError] = useState('');
1919
const [volumeError, setVolumeError] = useState('');
2020

21-
// Effective volume tables from Gyuri's simulations (ν=16, logBucketSize 1-25, i.e. depth 17-41)
21+
// Effective volume tables from Gyuri's simulations (ν=16, logBucketSize 1-18, i.e. depth 17-34)
2222
// These account for batch utilization (0.1% failure quantile), PAC overhead, and erasure coding overhead.
2323
// label: human-readable effective volume, gb: value in GB for comparison
2424
const depthToEffectiveVolume = {
@@ -42,13 +42,6 @@ function FetchPriceComponent() {
4242
32: { label: "17.07 TB", gb: 17479.68 },
4343
33: { label: "34.36 TB", gb: 35184.64 },
4444
34: { label: "69.04 TB", gb: 70696.96 },
45-
35: { label: "138.54 TB", gb: 141864.96 },
46-
36: { label: "277.72 TB", gb: 284385.28 },
47-
37: { label: "556.35 TB", gb: 569702.40 },
48-
38: { label: "1.11 PB", gb: 1163919.36 },
49-
39: { label: "2.23 PB", gb: 2338324.48 },
50-
40: { label: "4.46 PB", gb: 4676648.96 },
51-
41: { label: "8.93 PB", gb: 9363783.68 },
5245
},
5346
medium: {
5447
17: { label: "41.56 kB", gb: 0.000040 },
@@ -69,13 +62,6 @@ function FetchPriceComponent() {
6962
32: { label: "15.87 TB", gb: 16250.88 },
7063
33: { label: "31.94 TB", gb: 32706.56 },
7164
34: { label: "64.19 TB", gb: 65730.56 },
72-
35: { label: "128.80 TB", gb: 131891.20 },
73-
36: { label: "258.19 TB", gb: 264386.56 },
74-
37: { label: "517.23 TB", gb: 529643.52 },
75-
38: { label: "1.04 PB", gb: 1090519.04 },
76-
39: { label: "2.07 PB", gb: 2170552.32 },
77-
40: { label: "4.15 PB", gb: 4351590.40 },
78-
41: { label: "8.30 PB", gb: 8703180.80 },
7965
},
8066
strong: {
8167
17: { label: "37.37 kB", gb: 0.000036 },
@@ -96,13 +82,6 @@ function FetchPriceComponent() {
9682
32: { label: "14.27 TB", gb: 14612.48 },
9783
33: { label: "28.72 TB", gb: 29409.28 },
9884
34: { label: "57.71 TB", gb: 59095.04 },
99-
35: { label: "115.81 TB", gb: 118589.44 },
100-
36: { label: "232.16 TB", gb: 237731.84 },
101-
37: { label: "465.07 TB", gb: 476231.68 },
102-
38: { label: "931.23 TB", gb: 953579.52 },
103-
39: { label: "1.86 PB", gb: 1950351.36 },
104-
40: { label: "3.73 PB", gb: 3911188.48 },
105-
41: { label: "7.46 PB", gb: 7822376.96 },
10685
},
10786
insane: {
10887
17: { label: "33.88 kB", gb: 0.000032 },
@@ -123,13 +102,6 @@ function FetchPriceComponent() {
123102
32: { label: "12.93 TB", gb: 13240.32 },
124103
33: { label: "26.04 TB", gb: 26664.96 },
125104
34: { label: "52.32 TB", gb: 53575.68 },
126-
35: { label: "104.99 TB", gb: 107509.76 },
127-
36: { label: "210.46 TB", gb: 215511.04 },
128-
37: { label: "421.61 TB", gb: 431728.64 },
129-
38: { label: "844.20 TB", gb: 864460.80 },
130-
39: { label: "1.69 PB", gb: 1772093.44 },
131-
40: { label: "3.38 PB", gb: 3544186.88 },
132-
41: { label: "6.77 PB", gb: 7098859.52 },
133105
},
134106
paranoid: {
135107
17: { label: "13.27 kB", gb: 0.000013 },
@@ -150,13 +122,6 @@ function FetchPriceComponent() {
150122
32: { label: "5.07 TB", gb: 5191.68 },
151123
33: { label: "10.20 TB", gb: 10444.80 },
152124
34: { label: "20.50 TB", gb: 20992.00 },
153-
35: { label: "41.13 TB", gb: 42117.12 },
154-
36: { label: "82.45 TB", gb: 84428.80 },
155-
37: { label: "165.17 TB", gb: 169134.08 },
156-
38: { label: "330.72 TB", gb: 338657.28 },
157-
39: { label: "661.97 TB", gb: 677857.28 },
158-
40: { label: "1.32 PB", gb: 1384120.32 },
159-
41: { label: "2.65 PB", gb: 2778726.40 },
160125
},
161126
},
162127
encrypted: {
@@ -179,13 +144,6 @@ function FetchPriceComponent() {
179144
32: { label: "16.93 TB", gb: 17336.32 },
180145
33: { label: "34.09 TB", gb: 34908.16 },
181146
34: { label: "68.50 TB", gb: 70144.00 },
182-
35: { label: "137.45 TB", gb: 140748.80 },
183-
36: { label: "275.53 TB", gb: 282142.72 },
184-
37: { label: "551.97 TB", gb: 565217.28 },
185-
38: { label: "1.11 PB", gb: 1163919.36 },
186-
39: { label: "2.21 PB", gb: 2317352.96 },
187-
40: { label: "4.43 PB", gb: 4645191.68 },
188-
41: { label: "8.86 PB", gb: 9290383.36 },
189147
},
190148
medium: {
191149
17: { label: "40.89 kB", gb: 0.000039 },
@@ -206,13 +164,6 @@ function FetchPriceComponent() {
206164
32: { label: "15.61 TB", gb: 15984.64 },
207165
33: { label: "31.43 TB", gb: 32184.32 },
208166
34: { label: "63.15 TB", gb: 64665.60 },
209-
35: { label: "126.71 TB", gb: 129751.04 },
210-
36: { label: "254.01 TB", gb: 260106.24 },
211-
37: { label: "508.85 TB", gb: 521062.40 },
212-
38: { label: "1.02 PB", gb: 1069547.52 },
213-
39: { label: "2.04 PB", gb: 2139095.04 },
214-
40: { label: "4.08 PB", gb: 4278190.08 },
215-
41: { label: "8.17 PB", gb: 8566865.92 },
216167
},
217168
strong: {
218169
17: { label: "36.73 kB", gb: 0.000035 },
@@ -233,13 +184,6 @@ function FetchPriceComponent() {
233184
32: { label: "14.02 TB", gb: 14356.48 },
234185
33: { label: "28.23 TB", gb: 28907.52 },
235186
34: { label: "56.72 TB", gb: 58081.28 },
236-
35: { label: "113.82 TB", gb: 116551.68 },
237-
36: { label: "228.18 TB", gb: 233656.32 },
238-
37: { label: "457.10 TB", gb: 468070.40 },
239-
38: { label: "915.26 TB", gb: 937226.24 },
240-
39: { label: "1.83 PB", gb: 1918894.08 },
241-
40: { label: "3.67 PB", gb: 3848273.92 },
242-
41: { label: "7.34 PB", gb: 7696547.84 },
243187
},
244188
insane: {
245189
17: { label: "33.26 kB", gb: 0.000032 },
@@ -260,13 +204,6 @@ function FetchPriceComponent() {
260204
32: { label: "12.70 TB", gb: 13004.80 },
261205
33: { label: "25.57 TB", gb: 26183.68 },
262206
34: { label: "51.37 TB", gb: 52602.88 },
263-
35: { label: "103.08 TB", gb: 105553.92 },
264-
36: { label: "206.65 TB", gb: 211609.60 },
265-
37: { label: "413.98 TB", gb: 423915.52 },
266-
38: { label: "828.91 TB", gb: 848803.84 },
267-
39: { label: "1.66 PB", gb: 1740636.16 },
268-
40: { label: "3.32 PB", gb: 3481272.32 },
269-
41: { label: "6.64 PB", gb: 6962544.64 },
270207
},
271208
paranoid: {
272209
17: { label: "13.17 kB", gb: 0.000013 },
@@ -287,13 +224,6 @@ function FetchPriceComponent() {
287224
32: { label: "5.03 TB", gb: 5150.72 },
288225
33: { label: "10.12 TB", gb: 10362.88 },
289226
34: { label: "20.34 TB", gb: 20828.16 },
290-
35: { label: "40.80 TB", gb: 41779.20 },
291-
36: { label: "81.80 TB", gb: 83763.20 },
292-
37: { label: "163.87 TB", gb: 167802.88 },
293-
38: { label: "328.11 TB", gb: 335984.64 },
294-
39: { label: "656.76 TB", gb: 672522.24 },
295-
40: { label: "1.31 PB", gb: 1373634.56 },
296-
41: { label: "2.63 PB", gb: 2757754.88 },
297227
},
298228
},
299229
};
@@ -370,7 +300,7 @@ function FetchPriceComponent() {
370300

371301
// Find the smallest depth whose effective volume (in GB) >= requested volume
372302
let foundDepth = null;
373-
for (let d = 17; d <= 41; d++) {
303+
for (let d = 17; d <= 34; d++) {
374304
if (table[d] && table[d].gb >= gigabytes) {
375305
foundDepth = d;
376306
break;
@@ -397,7 +327,7 @@ function FetchPriceComponent() {
397327
};
398328

399329
const calculateMinimumDepth = (gigabytes) => {
400-
for (let d = 17; d <= 41; d++) {
330+
for (let d = 17; d <= 34; d++) {
401331
if (gigabytes <= Math.pow(2, 12 + d) / (1024 ** 3)) {
402332
return d;
403333
}
@@ -447,9 +377,9 @@ function FetchPriceComponent() {
447377

448378
// Check against max effective volume for the selected settings
449379
const table = getEffectiveVolumeTable();
450-
const maxGb = table[41].gb;
380+
const maxGb = table[34].gb;
451381
if (gigabytes > maxGb) {
452-
setVolumeError(`Volume exceeds maximum effective volume (${table[41].label}) for the selected encryption and erasure settings.`);
382+
setVolumeError(`Volume exceeds maximum effective volume (${table[34].label}) for the selected encryption and erasure settings.`);
453383
return 0;
454384
}
455385
return gigabytes;

src/components/VolumeAndDurationCalc.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,35 @@ export default function DepthCalc() {
2020
21: "2.60 GB", 22: "7.73 GB", 23: "19.94 GB", 24: "47.06 GB",
2121
25: "105.51 GB", 26: "227.98 GB", 27: "476.68 GB", 28: "993.65 GB",
2222
29: "2.04 TB", 30: "4.17 TB", 31: "8.45 TB", 32: "17.07 TB",
23-
33: "34.36 TB", 34: "69.04 TB", 35: "138.54 TB", 36: "277.72 TB",
24-
37: "556.35 TB", 38: "1.11 PB", 39: "2.23 PB", 40: "4.46 PB", 41: "8.93 PB",
23+
33: "34.36 TB", 34: "69.04 TB",
2524
},
2625
medium: {
2726
17: "41.56 kB", 18: "6.19 MB", 19: "104.18 MB", 20: "639.27 MB",
2827
21: "2.41 GB", 22: "7.18 GB", 23: "18.54 GB", 24: "43.75 GB",
2928
25: "98.09 GB", 26: "211.95 GB", 27: "443.16 GB", 28: "923.78 GB",
3029
29: "1.90 TB", 30: "3.88 TB", 31: "7.86 TB", 32: "15.87 TB",
31-
33: "31.94 TB", 34: "64.19 TB", 35: "128.80 TB", 36: "258.19 TB",
32-
37: "517.23 TB", 38: "1.04 PB", 39: "2.07 PB", 40: "4.15 PB", 41: "8.30 PB",
30+
33: "31.94 TB", 34: "64.19 TB",
3331
},
3432
strong: {
3533
17: "37.37 kB", 18: "5.57 MB", 19: "93.68 MB", 20: "574.81 MB",
3634
21: "2.17 GB", 22: "6.46 GB", 23: "16.67 GB", 24: "39.34 GB",
3735
25: "88.20 GB", 26: "190.58 GB", 27: "398.47 GB", 28: "830.63 GB",
3836
29: "1.71 TB", 30: "3.49 TB", 31: "7.07 TB", 32: "14.27 TB",
39-
33: "28.72 TB", 34: "57.71 TB", 35: "115.81 TB", 36: "232.16 TB",
40-
37: "465.07 TB", 38: "931.23 TB", 39: "1.86 PB", 40: "3.73 PB", 41: "7.46 PB",
37+
33: "28.72 TB", 34: "57.71 TB",
4138
},
4239
insane: {
4340
17: "33.88 kB", 18: "5.05 MB", 19: "84.92 MB", 20: "521.09 MB",
4441
21: "1.97 GB", 22: "5.86 GB", 23: "15.11 GB", 24: "35.66 GB",
4542
25: "79.96 GB", 26: "172.77 GB", 27: "361.23 GB", 28: "753.00 GB",
4643
29: "1.55 TB", 30: "3.16 TB", 31: "6.41 TB", 32: "12.93 TB",
47-
33: "26.04 TB", 34: "52.32 TB", 35: "104.99 TB", 36: "210.46 TB",
48-
37: "421.61 TB", 38: "844.20 TB", 39: "1.69 PB", 40: "3.38 PB", 41: "6.77 PB",
44+
33: "26.04 TB", 34: "52.32 TB",
4945
},
5046
paranoid: {
5147
17: "13.27 kB", 18: "1.98 MB", 19: "33.27 MB", 20: "204.14 MB",
5248
21: "771.13 MB", 22: "2.29 GB", 23: "5.92 GB", 24: "13.97 GB",
5349
25: "31.32 GB", 26: "67.68 GB", 27: "141.51 GB", 28: "294.99 GB",
5450
29: "606.90 GB", 30: "1.24 TB", 31: "2.51 TB", 32: "5.07 TB",
55-
33: "10.20 TB", 34: "20.50 TB", 35: "41.13 TB", 36: "82.45 TB",
56-
37: "165.17 TB", 38: "330.72 TB", 39: "661.97 TB", 40: "1.32 PB", 41: "2.65 PB",
51+
33: "10.20 TB", 34: "20.50 TB",
5752
},
5853
},
5954
encrypted: {
@@ -62,40 +57,35 @@ export default function DepthCalc() {
6257
21: "2.58 GB", 22: "7.67 GB", 23: "19.78 GB", 24: "46.69 GB",
6358
25: "104.68 GB", 26: "226.19 GB", 27: "472.93 GB", 28: "985.83 GB",
6459
29: "2.03 TB", 30: "4.14 TB", 31: "8.39 TB", 32: "16.93 TB",
65-
33: "34.09 TB", 34: "68.50 TB", 35: "137.45 TB", 36: "275.53 TB",
66-
37: "551.97 TB", 38: "1.11 PB", 39: "2.21 PB", 40: "4.43 PB", 41: "8.86 PB",
60+
33: "34.09 TB", 34: "68.50 TB",
6761
},
6862
medium: {
6963
17: "40.89 kB", 18: "6.09 MB", 19: "102.49 MB", 20: "628.91 MB",
7064
21: "2.38 GB", 22: "7.07 GB", 23: "18.24 GB", 24: "43.04 GB",
7165
25: "96.50 GB", 26: "208.52 GB", 27: "435.98 GB", 28: "908.81 GB",
7266
29: "1.87 TB", 30: "3.81 TB", 31: "7.73 TB", 32: "15.61 TB",
73-
33: "31.43 TB", 34: "63.15 TB", 35: "126.71 TB", 36: "254.01 TB",
74-
37: "508.85 TB", 38: "1.02 PB", 39: "2.04 PB", 40: "4.08 PB", 41: "8.17 PB",
67+
33: "31.43 TB", 34: "63.15 TB",
7568
},
7669
strong: {
7770
17: "36.73 kB", 18: "5.47 MB", 19: "92.07 MB", 20: "564.95 MB",
7871
21: "2.13 GB", 22: "6.35 GB", 23: "16.38 GB", 24: "38.66 GB",
7972
25: "86.69 GB", 26: "187.31 GB", 27: "391.64 GB", 28: "816.39 GB",
8073
29: "1.68 TB", 30: "3.43 TB", 31: "6.94 TB", 32: "14.02 TB",
81-
33: "28.23 TB", 34: "56.72 TB", 35: "113.82 TB", 36: "228.18 TB",
82-
37: "457.10 TB", 38: "915.26 TB", 39: "1.83 PB", 40: "3.67 PB", 41: "7.34 PB",
74+
33: "28.23 TB", 34: "56.72 TB",
8375
},
8476
insane: {
8577
17: "33.26 kB", 18: "4.96 MB", 19: "83.38 MB", 20: "511.65 MB",
8678
21: "1.93 GB", 22: "5.75 GB", 23: "14.84 GB", 24: "35.02 GB",
8779
25: "78.51 GB", 26: "169.64 GB", 27: "354.69 GB", 28: "739.37 GB",
8880
29: "1.52 TB", 30: "3.10 TB", 31: "6.29 TB", 32: "12.70 TB",
89-
33: "25.57 TB", 34: "51.37 TB", 35: "103.08 TB", 36: "206.65 TB",
90-
37: "413.98 TB", 38: "828.91 TB", 39: "1.66 PB", 40: "3.32 PB", 41: "6.64 PB",
81+
33: "25.57 TB", 34: "51.37 TB",
9182
},
9283
paranoid: {
9384
17: "13.17 kB", 18: "1.96 MB", 19: "33.01 MB", 20: "202.53 MB",
9485
21: "765.05 MB", 22: "2.28 GB", 23: "5.87 GB", 24: "13.86 GB",
9586
25: "31.08 GB", 26: "67.15 GB", 27: "140.40 GB", 28: "292.67 GB",
9687
29: "602.12 GB", 30: "1.23 TB", 31: "2.49 TB", 32: "5.03 TB",
97-
33: "10.12 TB", 34: "20.34 TB", 35: "40.80 TB", 36: "81.80 TB",
98-
37: "163.87 TB", 38: "328.11 TB", 39: "656.76 TB", 40: "1.31 PB", 41: "2.63 PB",
88+
33: "10.12 TB", 34: "20.34 TB",
9989
},
10090
},
10191
};
@@ -169,8 +159,8 @@ export default function DepthCalc() {
169159
const amountValue = Number(cleanedAmount);
170160
const minAmount = latestPrice * 17280;
171161

172-
if (!Number.isInteger(depthValue) || depthValue < 17 || depthValue > 41) {
173-
localErrors.depth = "Depth must be an integer greater or equal to 17 and less than or equal to 41.";
162+
if (!Number.isInteger(depthValue) || depthValue < 17 || depthValue > 34) {
163+
localErrors.depth = "Depth must be an integer greater or equal to 17 and less than or equal to 34.";
174164
}
175165
if (!Number.isInteger(amountValue) || amountValue < minAmount) {
176166
localErrors.amount = `Amount must be a positive whole number and at least ${minAmount} PLUR given the current storage price of ${latestPrice} PLUR/chunk/block.`;
@@ -227,7 +217,7 @@ export default function DepthCalc() {
227217
</label>
228218
<input
229219
id="depthInput"
230-
placeholder="Input batch depth (17 to 41)"
220+
placeholder="Input batch depth (17 to 34)"
231221
value={depth}
232222
onChange={e => setDepth(e.target.value)}
233223
style={{ display: 'block', marginBottom: '5px', padding: '8px' }}

0 commit comments

Comments
 (0)