threefoldtech / home

Starting point for the threefoldtech organization
https://threefold.io
Apache License 2.0
9 stars 4 forks source link

Standalone gateways #1515

Open muhamadazmy opened 5 months ago

muhamadazmy commented 5 months ago

Deprecates: #1472

This story discusses the requirements and some of the implementation details of a standalone gateway: A stand alone gateway can be installed as a service by any user/farmer on the public internet and allows other users to use it to expose their private services to the public internet over allocated domain names:

Operation of the gateway

All requests requires a JWT the jwt token requires the following fields:

The JWT is signed with the user key. The JWT then means it can be used to authenticate the identity of that user who initiated the request.

Once authentication is passed, the user request is then processed as follows:

Billing

traefic provides metrics for the domains that we can collect (and aggregate) every configurable period of time. The gw must then take care of calculating consumption over a certain period of time.

Then for each domain, we can then send consumption (or billing) reports to the contract. this should then allow hosts to get paid for providing the gw service.

Notes:

You can see above this has nothing to do with mycelium. This is because supporting mycelium is outside the scoop of the gw implementation. Mycelium supports comes free of charge by running a mycelium on the same node as the gw. Which allows backends then to use mycelium IPs.

sameh-farouk commented 5 months ago
sameh-farouk commented 5 months ago

Is name update something we don’t want/need to support from the beginning?

AbdelrahmanElawady commented 5 months ago

It should also be noted that the Service Contract requires both accounts to accept it and the service to set its required fees. That way one endpoint for adding a gateway entry won't be enough as the user will create the contracts, pass it to the service, the service will set the fees and accept then the user will accept and pass the gateway details. So, at least two requests will be made for two different endpoints to actually add an entry to the gateway service.

renauter commented 5 months ago
  • After deployment of the gateway workload, the gateway will bill the user over the service contract.

Indeed, a service contract would be suitable to handle such gw service billing (related to some consumption). A special attention should be given to the fees definition while setting the service contract here:

https://github.com/threefoldtech/tfchain/blob/development/substrate-node/pallets/pallet-smart-contract/service_consumer_contract_flow.md#step-2-fill-contract

Because once fees are set (base_fee and variable_fee) they cannot be modified (unless creating new contract). Such configuration, with base_fee = 0 and variable_fee = max possible amount that can be billed during 1 hour, should fit the case. Also the service contract billing rules (about billing calculation and frequency) should be considered:

https://github.com/threefoldtech/tfchain/blob/development/substrate-node/pallets/pallet-smart-contract/service_consumer_contract_flow.md#step-4-bill-for-the-service