threefoldtech / tfchain

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

Billing seems off #964

Closed scottyeager closed 5 months ago

scottyeager commented 5 months ago

A user reported that they think they are being billed too much on mainnet. After investigating a bit, I found some behaviors I can't explain.

The user has 37 VMs deployed on a mix of certified and non certified nodes with the same specs, and all VMs have a public IP reserved.

Here's an example contract:

    "nodeContracts": [
      {
        "resourcesUsed": {
          "cru": "8",
          "hru": "0",
          "mru": "34359738368",
          "sru": "377957122048"
        },
        "contractID": "338060",
        "nodeID": 2014
      }
    ],

Based on the dashboard calculator, this contract should be bill as seen below. I've entered the users actual approximate balance which should qualify for the gold discount level:

image

I also double checked this calculation against another spreadsheet we use for working with the billing calculations and the figures were very close.

But when I check some recent billing reports for this contract, I see the following:

    "contractBillReports": [
      {
        "amountBilled": "60000910",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712108136"
      },
      {
        "amountBilled": "65250724",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712104536"
      },
      {
        "amountBilled": "49563869",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712100936"
      },
      {
        "amountBilled": "59312443",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712097336"
      },
      {
        "amountBilled": "55289678",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712093736"
      },
      {
        "amountBilled": "52322507",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712090136"
      },
      {
        "amountBilled": "52550164",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712086536"
      },
      {
        "amountBilled": "50999400",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712082936"
      },
      {
        "amountBilled": "44415086",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712079336"
      },
      {
        "amountBilled": "50868664",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712075736"
      }

The amounts billed seem much too high and only a silver discount is applied. These are hourly bills, so the amount should be more like:

921 TFT/month / 30 / 24 = 1.28 TFT/hour

Instead of:

60000910 / 1e7 = 6.000091 TFT/hour

Here's another example of a contract with the same specs, also on a DIY node, with rather different billing over its last ten billing reports:

    "contractBillReports": [
      {
        "amountBilled": "47836986",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712109474"
      },
      {
        "amountBilled": "45252290",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712105874"
      },
      {
        "amountBilled": "40629248",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712102274"
      },
      {
        "amountBilled": "40951972",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712098674"
      },
      {
        "amountBilled": "36341400",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712095074"
      },
      {
        "amountBilled": "33882664",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712091474"
      },
      {
        "amountBilled": "21187343",
        "contractID": "340083",
        "discountReceived": "Gold",
        "timestamp": "1712087874"
      },
      {
        "amountBilled": "52841422",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712084274"
      },
      {
        "amountBilled": "55805207",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712080674"
      },
      {
        "amountBilled": "56989307",
        "contractID": "340083",
        "discountReceived": "Silver",
        "timestamp": "1712077074"
      }

I can't find any reason to explain why these contracts should be billing at multiples times what's shown by the calculator.

LeeSmet commented 5 months ago

Public traffic is also billed

renauter commented 5 months ago

I did some maths to check these numbers including NU for last billing and nru reports. I chose 2 last reports that correspond to more or less same period of time (billing reports and nru reports are not sent at same moment even if sent at same frequency) See here:

{
  "data": {
    "contractBillReports": [
      {
        "amountBilled": "57965722",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712151336"
      },
      {
        "amountBilled": "57764807",
        "contractID": "338060",
        "discountReceived": "Silver",
        "timestamp": "1712154936"
      }
    ],
    "nruConsumptions": [
      {
        "contractID": "338060",
        "nru": "118471108134",
        "timestamp": "1712148920",
        "window": "3600"
      },
      {
        "contractID": "338060",
        "nru": "117846081049",
        "timestamp": "1712152520",
        "window": "3600"
      }
    ]
  }
}

Which corresponds to what was billed on billing report 57764807 * 10e7 = 5,77 tft for 1 hour

scottyeager commented 5 months ago

Thanks guys. Billing for network traffic indeed explains what's going on here.