Skip to content

chore: charge the taxonomy write fee per child stream - #1411

Merged
MicBun merged 1 commit into
mainfrom
chore/taxonomy-per-child-fee
Aug 4, 2026
Merged

chore: charge the taxonomy write fee per child stream#1411
MicBun merged 1 commit into
mainfrom
chore/taxonomy-per-child-fee

Conversation

@MicBun

@MicBun MicBun commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

resolves: https://github.com/truflation/website/issues/3972

What changes

insert_taxonomy (004) now charges 10 TRUF per child stream instead of a flat 1 TRUF per transaction. Per-transaction pricing let one caller attach an arbitrary number of children for the price of one, so the cost of a taxonomy no longer tracks what it actually adds — each child is a permanent taxonomies row that every composed read walks.

$per_child_fee NUMERIC(78, 0) := '10000000000000000000'::NUMERIC(78, 0); -- 10 TRUF (10^19)
$total_fee NUMERIC(78, 0) := $per_child_fee * $num_children::NUMERIC(78, 0);

This restores the multiplier shape that create_streams (001) already uses for its per-stream fee, at the 10 TRUF figure agreed on the issue. The literal is quoted because 10^19 exceeds int64 — the same reason 001 quotes its 10^20.

The insufficient-balance message changes from Required: 1 TRUF to Required: 10 TRUF per child stream, matching 001's Required: 100 TRUF per stream.

The dev *.sql source was edited and the mainnet override regenerated with scripts/generate_prod_migrations.py (hoodi_tteth_truf); the other 13 generator targets regenerate byte-identically, so only 004-composed-taxonomy.prod.sql changes. Both files pass kwil-cli utils parse.

No cap on $num_children is added. Pricing bounds the abuse on its own — max_req_size already caps a transaction near 40,000 children, which is 400,000 TRUF at this rate — and picking a cap value would reject legitimate large taxonomies with no migration path.

Tests

feefund.TaxonomyFeePerChildWei is the single source of the fee for the test tree, and every expectation derives from it, so the migration and the tests cannot drift apart.

  • taxonomy_fee_test.go: all five existing cases re-costed; testTaxonomyMultipleChildrenChargesFlatFee becomes ...ChargesPerChildFee and now funds exactly 100 + 300 + 30 so a regression back to a flat fee leaves 29 TRUF and fails.
  • New testTaxonomyPartialBalanceRejectsExtraChild: a wallet holding exactly one child's fee attaches two children. This is the rejection path with a non-zero balance, which the existing insufficient-balance case (which drains to zero) does not exercise, and it asserts the rejected call left the balance untouched.
  • transaction_events_ledger_test.go: the setTaxonomies ledger row and its fee distribution now assert 10 TRUF for a 1-child taxonomy.
  • utils/procedure/execute.go: SetTaxonomy — the shared helper ~40 tests fund through — now credits N × per-child instead of a flat 1 TRUF.

Suites run and passing: TestTaxonomyFees, the three transaction-ledger suites, the composed/taxonomy consumers (TestComposed, TestTaxonomyQueryActions, TestMultiLevelComposedStreams, TestGamefiIndex, TestTruflationComposedFrozen, TestComprehensivePathIndependenceWithSharedPrimitive), plus the full aggregation and auth packages.

Rollout notes (consensus-critical)

  1. Apply the regenerated 004-composed-taxonomy.prod.sql via kwil-cli exec-sql (after erc20-bridge/000-extension.prod.sql, so eth_truf exists). It is a CREATE OR REPLACE ACTION on that one action — no fleet upgrade, no restart.
  2. Impact on current traffic is small: mainnet has 9 setTaxonomies events in total, 3 of them fee-bearing, and the largest taxonomy group is 30 children — so the worst single call becomes 300 TRUF. No refill-bot threshold needs changing.
  3. insert_taxonomy has no internal on-chain callers and no SDK hardcodes the fee, so only external data providers setting taxonomies are affected.

Summary by CodeRabbit

  • New Features
    • Taxonomy creation fees now scale at 10 TRUF per child stream instead of a flat 1 TRUF fee.
    • Insufficient-balance errors now report the required per-child fee.
    • Taxonomy creation rejects partial funding without deducting funds.

@MicBun MicBun self-assigned this Aug 3, 2026
@holdex

holdex Bot commented Aug 3, 2026

Copy link
Copy Markdown

Time Submission Status

Member # Time Running Total Status Last Update
MicBun 4h ✅ Submitted Aug 3, 2026, 7:54 PM

Submit or update total time with:

@holdex pr submit-time 2h

Add time on top of previous submission with:

@holdex pr add-time 1h30m

See available commands to help comply with our Guidelines.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 74ad34a2-e4e3-43e9-a84e-7c249508fed1

📥 Commits

Reviewing files that changed from the base of the PR and between 6328d0d and a8020c0.

📒 Files selected for processing (7)
  • internal/migrations/004-composed-taxonomy.prod.sql
  • internal/migrations/004-composed-taxonomy.sql
  • tests/streams/taxonomy_fee_test.go
  • tests/streams/transaction_events_ledger_test.go
  • tests/streams/utils/feefund/feefund_default.go
  • tests/streams/utils/feefund/feefund_kwiltest.go
  • tests/streams/utils/procedure/execute.go
 _____________________________________________________
< The fifth dentist recommends we all floss our code. >
 -----------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/taxonomy-per-child-fee

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MicBun

MicBun commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@holdex pr submit-time 4h

@MicBun
MicBun merged commit 9f04efc into main Aug 4, 2026
8 checks passed
@MicBun
MicBun deleted the chore/taxonomy-per-child-fee branch August 4, 2026 03:33
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