-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the farm weight calculation #968
Comments
So let s do the maths for this guy Here is the rust code that calculates node weight extracted from TFChain ( tfchain/substrate-node/support/src/resources.rs Lines 57 to 91 in eb36aa9
const GIGABYTE: u128 = 1024 * 1024 * 1024;
const ONE_THOUSAND: u128 = 1000;
const CRU: u64 = 24;
const MRU: u64 = 202803462144;
const SRU: u64 = 512110190592;
const HRU: u64 = 9001778946048;
fn calc_cu() -> u64 {
let cru_min = CRU as u128 * 2 * GIGABYTE * ONE_THOUSAND;
let mru_min =
((MRU as u128).checked_sub(1).unwrap_or(0) * GIGABYTE) * ONE_THOUSAND / 4;
let sru_min = SRU as u128 * ONE_THOUSAND / 50;
if cru_min < mru_min && cru_min < sru_min {
cru_min as u64
} else if mru_min < cru_min && mru_min < sru_min {
mru_min as u64
} else if sru_min < cru_min && sru_min < mru_min {
sru_min as u64
} else {
0
}
}
fn get_cu() -> u64 {
let cu = calc_cu();
let calculated_cu = 2 * (cu as u128 / GIGABYTE / ONE_THOUSAND);
calculated_cu as u64
}
fn get_su() -> u64 {
let su = HRU as u128 * ONE_THOUSAND / 1200 + SRU as u128 * ONE_THOUSAND / 250;
let calculated_su = su / GIGABYTE;
let result = calculated_su as u128 / ONE_THOUSAND;
result as u64
}
fn main() {
println!("CU: {}", get_cu());
println!("SU: {}", get_su());
} Copy past previous code in rust playground https://play.rust-lang.org/ and run gives: CU: 18
SU: 8 Which gives for farm weight: Weight = 2 * (sum of CU of all nodes) + (sum of SU of all nodes)
Weight = 2 * (18+18) + (8+8)
Weight = 2 * 36 + 16
Weight = 88 |
I guess the confusion is because you are using formulas from billing capacity instead of minting/farming capacity which are different. Note: nevertheless, we already reported some incoherence related to weight calculation here #966 and need to check if it reflects what is done in minting code. |
Yeah, with Resource Units Calculation it makes sense now. Thanks for the clarification. |
Describe the bug
Is the farm weight calculated correctly?
For example, I'll calculate the weight for farm 1 in QAnet:
Farm 1 in QAnet has only 2 nodes, and both are up and have the same resource as shown below.
To calculate the CU and SU for the node, I will use the equation mentioned here.
Node resources is
CU = min( max(MRU/4, CRU/2), max(MRU/8, CRU), max(MRU/2, CRU/4) )
CU = min(max(188.875312805/4, 24/2), max(188.875312805/8, 24), max(188.875312805/2, 24/4))
CU = min(max(47.21882820125, 12), max(23.609414100625, 24), max(94.4376564025, 6))
CU = min (47.21882820125, 24, 94.4376564025)
CU = 24
SU = HRU/1200 + SRU/200
SU = 8383.559944153/1200 + 476.939781189/200
SU = 6.986299953461 + 2.384698905945
SU = 9.370998859406
The equation for the weight of a farm is: 2 * (sum of CU of all nodes) + (sum of SU of all nodes).
since both nodes have exactly the same resources,
Weight = 2 * (sum of CU of all nodes) + (sum of SU of all nodes)
Weight = 2 * (24+24) + (9.370998859406+9.370998859406)
Weight = 2 * 48 + 18.741997719
Weight = 114.741997719
So the weight for Farm 1 should be 114, but in the chain it's shown as 88.
So is the wrong calculation from me, the equation am I using, or the chain?
The text was updated successfully, but these errors were encountered: