Skip to content

Disk billing#1841

Merged
James-Mart merged 107 commits into
mainfrom
disk-billing
Jul 21, 2026
Merged

Disk billing#1841
James-Mart merged 107 commits into
mainfrom
disk-billing

Conversation

@James-Mart

@James-Mart James-Mart commented Apr 25, 2026

Copy link
Copy Markdown
Member

Disk billing

This adds billing for "objective" disk storage to complement the existing billing for CPU and NET.
The virtual-server service now distinguishes between "rate limited" and "capacity limited" resources. Rate limited resources are those like network bandwidth and CPU, where there's a max throughput at any given time but that doesn't compound over time. Capacity limited resources are those with fixed limits over the lifetime of the entire network, like disk storage. Once disk is consumed, unless it is freed, it is permanently stored. Therefore, it deserves its own billing strategy.

Capacity limited resource billing

Capacity limited resources are, rather than billed using a satoshi-proof-of-work-style price adjustment algo as we do for rate-limited resources, billed according to an AMM style relay. More precisely, as storage is consumed, it approaches the max amount of storage available for the network, and climbs up a price curve. At full disk consumption, the area under the curve (which is the total amount of tokens that would have had to be paid into the relay to purchase the disk consumption) is equal to the total token supply of the network token.

Note
I rewrote my git history to take ~70 commits and turn it into 6 that are more sanely grouped. Probably not compileable at the intermediate commits.

@James-Mart James-Mart added the System app Related to system services and their apps/plugins label Apr 25, 2026
@James-Mart

Copy link
Copy Markdown
Member Author

One odd thing is that the cost to enable billing changes between boots, by sometimes a substantial amount. I think it's due to install order and therefore what gets written after virtual-server gets installed.
Ideally this would be more deterministic.

@James-Mart
James-Mart marked this pull request as ready for review April 27, 2026 23:23
@James-Mart
James-Mart requested a review from swatanabe April 27, 2026 23:23
@swatanabe

Copy link
Copy Markdown
Collaborator

One odd thing is that the cost to enable billing changes between boots, by sometimes a substantial amount. I think it's due to install order and therefore what gets written after virtual-server gets installed. Ideally this would be more deterministic.

The right way to solve this is to get the initial RAM usage by scanning the entire database. That way, it doesn't depend on when virtual-server is installed. The scan may need to be split into multiple actions.

Comment thread packages/system/Transact/src/Transact.cpp Outdated
Comment thread packages/system/VirtualServer/service/src/tables/capacity_limit_pricing.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tables/capacity_limit_pricing.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tables/capacity_limit_pricing.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tables/capacity_limit_pricing.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tables/capacity_limit_pricing.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tables/capacity_limit_pricing.rs Outdated
Comment thread packages/system/VirtualServer/service/src/lib.rs Outdated
Comment thread packages/user/Tokens/service/src/lib.rs Outdated
Comment thread packages/system/Transact/src/Transact.cpp Outdated
Comment thread packages/system/Transact/src/Transact.cpp Outdated
Comment thread packages/system/VirtualServer/service/src/tables.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tables.rs Outdated
Comment thread packages/system/VirtualServer/service/src/lib.rs Outdated
Comment thread packages/system/VirtualServer/service/src/lib.rs Outdated
Comment thread packages/system/VirtualServer/service/src/lib.rs Outdated
Comment thread packages/system/VirtualServer/service/src/tests/chain.rs
Comment thread packages/system/VirtualServer/service/src/tests/curve_math.rs Outdated
Comment thread rust/psibase/src/trace.rs Outdated
Comment thread rust/psibase/src/trace.rs Outdated
Comment thread rust/psibase/src/trace.rs Outdated
Comment thread rust/psibase/src/services/virtual_server.rs Outdated
swatanabe
swatanabe previously approved these changes Jul 20, 2026
Comment thread packages/system/Db/src/Db.cpp Outdated
@swatanabe
swatanabe dismissed their stale review July 20, 2026 15:38

hit the wrong button when submitting review

Comment thread packages/system/VirtualServer/service/src/lib.rs Outdated
@James-Mart
James-Mart merged commit 06e89db into main Jul 21, 2026
2 checks passed
@James-Mart
James-Mart deleted the disk-billing branch July 21, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

System app Related to system services and their apps/plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants