threefoldtech / tfchain

Threefold Chain.
Apache License 2.0
15 stars 11 forks source link

Difference between the deployment cost from the resource pricing calculator and the actual billing rate of the contract #871

Closed mohamedamer453 closed 4 months ago

mohamedamer453 commented 1 year ago

What happened?

There's a difference between the calculations done from the resource calculator or manual calculation and the actual billing rate of the contract.

Scenario 1

A micro vm deployment from the playground with the following specs CRU: 1, MR: 1, SRU: 15.

According to the resource calculator the cost should be 387.14 tft/month since i'm eligible for a bronze discount.

image

so the cost/hour should be = 387.14 / 30 / 24 = 0.5376944444444444 TFT/hour

and when it was calculated manually it was the same thing

1 USD -> 142.857 TFT

CRU = 1
MRU = 1
SRU = 15

CU = min( max(MRU/4, CRU/2), max(MRU/8, CRU), max(MRU/2, CRU/4) )
   = min( max(1/4, 1/2), max(1/8, 1), max(1/2, 1/4) )
   = min( 1/2, 1, 1/2)
   = 1/2

SU = 0/1200 + 15/200
   = 0.075

CU cost/hour = CU * CU pricing
             = 0.5 * 10 musd
             = 5 musd/h

SU cost/hour = SU * SU pricing    
             = 0.075 * 5
             = 0.375 musd/h

Contract cost/hour = CU cost/hour + SU cost/hour
                   = 5 musd/h + 0.375 musd/h
                   = 5.375 musd/h
                   = 0.005375 usd/h
                   = 0.005375 * 142.857
                   = 0.7678563749999999 tft/hour
                   = 0.7678563749999999 * 24 * 30
                   = 552.8565899999999 tft/month
                   = 552.8565899999999 * 0.065

Cost with 30% discount = 0.7678563749999999 * 0.7
                       = 0.5374994624999999 TFT/hour

However the actual billing rate of the contract from the playground and graphql is 0.376 tft/hour

image

image

Scenario 2

A dedicated node with the following specs CRU = 24, MRU = 188.88, SRU = 476.94, HRU = 8386.56

node 4 on qanet

image

image

According to the resource calculator the cost should be 14752.86 TFT/month since i'm not eligible for any discount levels, only the 50% discount of renting a node as dedicated.

so the cost/hour should be = 14752.86 / 30 /24 = 20.490083333333335 TFT/hour

and when it was calculated manually it was the same thing

1 USD -> 142.857 TFT

CRU = 24
MRU = 188.88
SRU = 476.94
HRU = 8386.56

CU = min( max(MRU/4, CRU/2), max(MRU/8, CRU), max(MRU/2, CRU/4) )
   = min( max(188.88/4, 24/2), max(188.88/8, 24), max(188.88/2, 24/4) )
   = min( max(188.88/4, 24/2), max(188.88/8, 24), max(188.88/2, 24/4) )
   = min( max(47.22, 12), max(11.11, 24), max(94.44, 6) )
   = min( 47.22, 24, 94.44)
   = 24

CU cost/hour = CU * CU pricing
             = 24 * 10 musd/h
             = 240 musd/h

SU = HRU/1200 + SRU/200
   = 8386.56/1200 + 476.94/200
   = 9.3735
SU cost/hour = SU * SU pricing
             = 9.3735 * 5 musd/h
             = 46.8675 musd/h

Contract cost/hour = CU cost/hour + SU cost/hour
                   = 240 + 46.8675
                   = 286.8675 musd/h
                   = 0.2868675 usd/h
                   = 0.2868675 * 142.857
                   = 40.9810304475 tft/h
                   = 40.9810304475 * 24 * 30
                   = 29506.3419222 tft/month
                   = 206.54459999999997 usd/month

Cost with 50% discount = 40.9810304475 * 0.5
                       = 20.49051522375 tft/h

However the actual billing rate of the contract from the playground and graphql is 14.343 tft/hour

image

image

image

What did you expect?

The deployment price from the Resource calculator should match the actual billing rate of the contract.

Environment

xmonader commented 11 months ago

@renauter status?

renauter commented 8 months ago

I checked and did not find why was this happening at the time. Is it still happening? @mohamedamer453

renauter commented 4 months ago

Seems outdated Closing