feat(engine)!: retune the template publish fee curve - #2428
Open
sdbondi wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
-Ospass (applications/tari_walletd/src/services/wasm_optimizer.rs:43) — gives this corpus:#[template], no Componenthello_worldtariswapbasic_nftstealthaccess_rulesSo 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 fixedtemplate_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 existingFeeSource::TemplatePublishbreakdown entry, so no new fee source.Resulting curve
Totals include base storage and transaction weight, not premium alone.
Notes
crates/template_test_toolingand 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.