Skip to content

chore: charge 100 TRUF per stream on stream creation#1384

Merged
MicBun merged 1 commit into
mainfrom
per-stream-create-fee
May 22, 2026
Merged

chore: charge 100 TRUF per stream on stream creation#1384
MicBun merged 1 commit into
mainfrom
per-stream-create-fee

Conversation

@MicBun
Copy link
Copy Markdown
Contributor

@MicBun MicBun commented May 22, 2026

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

Summary

  • Replace flat 1 TRUF/tx fee on create_streams with 100 TRUF × N (issue truflation/website#3971) — pricing now scales with stream count so batch dumps can't piggyback storage growth on one tx.
  • Drop the system:fee_required role gate from create_streams only; charging is now universal. insert_records / insert_taxonomy keep the phased-rollout gate, and create_data_provider's network_writer requirement is unchanged.
  • Mirror the fee + universal-charging changes into the prod eth_truf override via scripts/generate_prod_migrations.py.

Test plan

  • kwil-cli utils parse clean on both 001-common-actions.sql and .prod.sql
  • go vet -tags kwiltest ./... clean
  • TestStreamCreationFees (7 cases rewritten for per-stream math + universal charging)
  • TestInsertRecordsFees, TestTransactionEventsLedger, TestTransactionInputActions, TestTransactionIDTracking, TestAllowZerosCombinations all green
  • TestSettlementIntegration green
  • Broader auth/composed test slice green
  • Manual devnet smoke: fund wallet 250 TRUF, create 2 streams → expect 200 TRUF drained; retry with 3 streams → expect Insufficient balance for stream creation. Required: 100 TRUF per stream

Summary by CodeRabbit

  • Fee Structure Update
    • Stream creation now costs 100 TRUF per stream instead of a flat fee per transaction.
    • Fee applies universally to all users with no role-based exemptions.
    • Batch stream creation costs scale linearly with the number of streams created.

Review Change Stack

@holdex
Copy link
Copy Markdown

holdex Bot commented May 22, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h Update time May 22, 2026, 8:31 PM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

📝 Walkthrough

Walkthrough

This PR implements a universal per-stream creation fee model: all callers are charged 100 TRUF per stream created, unconditionally, replacing prior role-gated flat-fee logic. Fee constants are added, migration actions are rewritten, test helpers are updated, and comprehensive test scenarios verify the new deductions and ledger behavior.

Changes

Universal Per-Stream Creation Fees

Layer / File(s) Summary
Fee constants definition
tests/streams/utils/feefund/feefund_default.go, tests/streams/utils/feefund/feefund_kwiltest.go
Added StreamCreationFeeWei constant defining the 100 TRUF per-stream fee and updated documentation to clarify that the fee scales with the number of streams and applies to all callers regardless of role.
Core per-stream fee charging logic
internal/migrations/001-common-actions.sql, internal/migrations/001-common-actions.prod.sql
Rewrote create_streams fee collection to compute total fee as (100 TRUF per stream) × array_length($stream_ids), verify caller balance unconditionally, and transfer the total fee to the leader recipient, removing the prior system:fee_required role-gating.
Test helper and setup utilities
tests/streams/utils/setup/common.go
Updated single and batch stream creation helpers to fund operations using per-stream StreamCreationFeeWei, including big-integer multiplication for multi-stream totals.
Stream creation fee test suite
tests/streams/stream_creation_fee_test.go
Comprehensive test rewrites verifying per-stream fee deductions for single/batch scenarios, insufficient-balance failures, leader fee distribution, and no-exemption for unenrolled wallets; added testBatchChargesPerStreamFee and replaced "free write" test with testUnenrolledWalletStillCharged.
Ledger, transaction, and integration test updates
tests/streams/transaction_events_ledger_test.go, tests/streams/transaction_input_data_test.go, tests/streams/order_book/settlement_payout_test.go, tests/streams/allow_zeros_test.go, extensions/tn_settlement/settlement_integration_test.go
Updated wallet funding amounts and fee expectations across multiple test scenarios to reflect per-stream pricing: increased headroom amounts, adjusted ledger fee assertions to use multi-stream totals, and unified fee documentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • trufnetwork/node#1382: Modifies create_streams fee-collection logic in the same migration files; the retrieved PR adds system:fee_required gating while this PR removes it for unconditional per-stream charging.
  • trufnetwork/node#1371: Also removes role/whitelisting-based fee exemptions in create_streams and updates corresponding stream-fee tests.
  • trufnetwork/node#1273: Modifies settlement payout test flow including fee/balance funding and expectations in the same test file.

Suggested labels

type: chore

Suggested reviewers

  • pr-time-tracker
  • outerlook
  • williamrusdyputra

Poem

🐰 A stream flows free, but not its fee—
One hundred TRUF per stream to see,
No role exempts, no badge to wave,
All must pay, both bold and brave!
With ledgers checked and tests recast,
Fair pricing flows at last. 🪙

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 85.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately and concisely summarizes the primary change: implementing a per-stream fee of 100 TRUF for stream creation, replacing the previous flat 1 TRUF per transaction model.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 per-stream-create-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 and usage tips.

@MicBun MicBun changed the title chore: charge 100 TRUF per stream on create_streams (#3971) chore: charge 100 TRUF per stream on stream creation May 22, 2026
@MicBun MicBun self-assigned this May 22, 2026
@MicBun MicBun requested a review from pr-time-tracker May 22, 2026 20:31
@MicBun
Copy link
Copy Markdown
Contributor Author

MicBun commented May 22, 2026

@holdex pr submit-time 4h

@MicBun MicBun merged commit 2140fea into main May 22, 2026
9 of 10 checks passed
@MicBun MicBun deleted the per-stream-create-fee branch May 22, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant