chore: add transaction fees for attestation requests#1247
Conversation
Data attestation queries are currently free, creating no cost barrier for cryptographic verification services. This introduces a 40 TRUF flat fee per attestation request to monetize this premium service while ensuring only serious usage of the attestation system. resolves: trufnetwork/truf-network#1316
WalkthroughAdds mandatory on-chain fee collection (fixed 40 TRUF) into the Changes
Sequence DiagramsequenceDiagram
participant Caller
participant RequestAtt as request_attestation
participant EthBridge as ethereum_bridge
participant Leader
participant AttLogic as Attestation Logic
Caller->>RequestAtt: invoke request_attestation(...)
RequestAtt->>RequestAtt: validate action_id / role checks
rect rgb(235,245,255)
Note over RequestAtt,EthBridge: FEE COLLECTION (new)
RequestAtt->>EthBridge: balance(`@caller`)
EthBridge-->>RequestAtt: balance amount
alt balance < 40 TRUF
RequestAtt-->>Caller: error "insufficient balance"
else balance >= 40 TRUF
RequestAtt->>RequestAtt: ensure `@leader_sender` NOT NULL
RequestAtt->>EthBridge: transfer(40 TRUF -> `@leader_sender`)
EthBridge->>Leader: +40 TRUF
end
end
RequestAtt->>AttLogic: continue attestation flow
AttLogic-->>Caller: attestation result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-09-12T12:03:13.782ZApplied to files:
🧬 Code graph analysis (1)tests/streams/attestation/test_helpers.go (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (3)
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. Comment |
Time Submission Status
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/migrations/024-attestation-actions.sql(1 hunks)tests/streams/attestation/request_attestation_fee_test.go(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-10T13:00:14.189Z
Learnt from: outerlook
Repo: trufnetwork/node PR: 1207
File: internal/migrations/024-attestation-actions.sql:58-76
Timestamp: 2025-10-10T13:00:14.189Z
Learning: In the attestation system for internal/migrations/024-attestation-actions.sql, the attestation_hash is computed from (version|algo|data_provider|stream_id|action_id|args) and intentionally excludes created_height. This design ensures the hash is deterministic based only on user input, not network state like block height.
Applied to files:
internal/migrations/024-attestation-actions.sql
📚 Learning: 2025-10-10T13:00:13.731Z
Learnt from: outerlook
Repo: trufnetwork/node PR: 1207
File: internal/migrations/023-attestation-schema.sql:20-21
Timestamp: 2025-10-10T13:00:13.731Z
Learning: In the attestations table (internal/migrations/023-attestation-schema.sql), the primary key is (requester, created_height, attestation_hash) because attestation_hash is computed deterministically from user input only (version|algo|data_provider|stream_id|action_id|args) and does not include created_height. This allows the same user to request the same attestation at different block heights.
Applied to files:
internal/migrations/024-attestation-actions.sql
🧬 Code graph analysis (1)
tests/streams/attestation/request_attestation_fee_test.go (8)
tests/streams/utils/runner.go (1)
RunSchemaTest(37-116)internal/migrations/migration.go (1)
GetSeedScriptStatements(60-109)tests/streams/utils/utils.go (1)
GetTestOptionsWithCache(75-88)tests/streams/utils/setup/roles.go (1)
AddMemberToRoleBypass(73-98)tests/streams/utils/setup/common.go (4)
CreateDataProvider(193-234)CreateStream(31-33)StreamInfo(21-24)ContractTypePrimitive(17-17)tests/streams/utils/erc20/inject.go (1)
InjectERC20Transfer(24-85)tests/streams/utils/erc20/helper.go (1)
GetUserBalance(49-74)extensions/tn_utils/serialization.go (1)
EncodeActionArgs(45-76)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: acceptance-test
- GitHub Check: lint
williamrusdyputra
left a comment
There was a problem hiding this comment.
coderabbit suggestion, is it unrelevant?
and also the CI failed
|
Thanks for notifying. It is valid and will push fix soon |
Data attestation queries are currently free, creating no cost barrier for cryptographic verification services. This introduces a 40 TRUF flat fee per attestation request to monetize this premium service while ensuring only serious usage of the attestation system.
resolves: https://github.com/trufnetwork/truf-network/issues/1316
Summary by CodeRabbit
New Features
Tests