Skip to content

feat(engine)!: retune the template publish fee curve - #2428

Open
sdbondi wants to merge 1 commit into
tari-project:developmentfrom
sdbondi:engine-template-publish-fee-taper
Open

feat(engine)!: retune the template publish fee curve#2428
sdbondi wants to merge 1 commit into
tari-project:developmentfrom
sdbondi:engine-template-publish-fee-taper

Conversation

@sdbondi

@sdbondi sdbondi commented Aug 14, 2026

Copy link
Copy Markdown
Member

Motivation

Publishing a mid-sized template costs around 5 tTARI, which is high for the common case.

Measuring the sizes that are actually published — the scaffolded release profile, followed by the wallet daemon's -Os pass (applications/tari_walletd/src/services/wasm_optimizer.rs:43) — gives this corpus:

template published size
bare #[template], no Component 25 KiB
hello_world 76 KiB
tariswap 136 KiB
basic_nft 151 KiB
stealth 198 KiB
access_rules 260 KiB

So the 5 tTARI case is a large-but-ordinary template at ~260 KiB, which the 30 KiB free allowance prices at 5.14 tTARI.

Change

Free allowance 30 KiB → 96 KiB. This brings 260 KiB to ~2.7 tTARI while leaving the tail where it was: at 512 KiB and beyond, 66 KiB of extra allowance is a rounding error against the excess, so oversized templates stay expensive.

New flat per_template_publish_cost, 250,000 µT. Raising the allowance alone drops a minimal template to 0.10 tTARI. That is a structural limit of a size-only model, not a tuning miss: a published binary carries ~25 KiB of fixed template_lib + CBOR machinery before any author code, and a minimal component template lands around 76 KiB — so any allowance that covers library overhead also makes a trivial publish nearly free. The flat charge separates the two concerns: the allowance decides where the premium starts to bite, the flat charge decides what the cheapest publish costs. It folds into the existing FeeSource::TemplatePublish breakdown entry, so no new fee source.

Resulting curve

published before after
minimal 25 KiB 0.03 T 0.28 T
hello_world 76 KiB 0.25 T 0.35 T
tariswap 136 KiB 1.12 T 0.52 T
basic_nft 151 KiB 1.45 T 0.66 T
stealth 198 KiB 2.75 T 1.36 T
access_rules 260 KiB 5.14 T 2.93 T
512 KiB 23.44 T 17.83 T
1 MiB 99.18 T 86.82 T

Totals include base storage and transaction weight, not premium alone.

Notes

  • Consensus-breaking: publish fees change, so execution results change.
  • crates/template_test_tooling and the network tables move together; FeeTable::zero_rated() leaves the flat charge at 0, so zero-rated tests are unaffected.

Testing

  • cargo test -p tari_engine --lib fees — includes new coverage for the flat charge below the free allowance.
  • cargo test -p tari_engine --test publish_template --test complex_fee_payment --test compute_fee_budget --test native_compute_budget — all pass.

Publishing a mid-sized template cost around 5 tTARI. Measuring the sizes
that are actually published — the scaffolded release profile followed by
the wallet daemon's `-Os` pass — puts a large real template at ~260 KiB,
which the 30 KiB free allowance priced at 5.14 tTARI.

Raise the free allowance to 96 KiB, which brings that case to ~2.7 tTARI
while leaving the tail intact: 512 KiB still costs ~17.6 tTARI and 1 MiB
~87 tTARI, because at those sizes the extra allowance is a rounding error
against the excess.

Raising the allowance alone would drop a minimal template to 0.10 tTARI.
A published binary carries ~25 KiB of fixed `template_lib` machinery
before any author code, and a minimal component template lands around
76 KiB, so a size-only model cannot separate a trivial publish from
library overhead — any allowance covering the latter also makes the
former free. Add a flat `per_template_publish_cost` to set that floor:
the allowance decides where the premium bites, the flat charge decides
what the cheapest publish costs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SKDrCT6S8UotvHaq8WLTwg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant