Skip to content

feat: refund submission fee to quorum agreement submitters - #219

Open
JayWhite2357 wants to merge 8 commits into
mainfrom
feat/indexer-quorum-refunds
Open

JayWhite2357 wants to merge 8 commits into
mainfrom
feat/indexer-quorum-refunds

Conversation

@JayWhite2357

@JayWhite2357 JayWhite2357 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

We wish for data submissions to be refunded from the table treasuries they are submitted to.

What changes are included in this PR?

  • Adds a per-table treasury account, deterministically derived from the table identifier.
  • Refunds the submission fee to each agreeing submitter from the table's treasury when a quorum is finalized. Dissents and late submissions are not refunded.
  • Fee is computed via pallet_transaction_payment::compute_fee using the real submitted extrinsic's length.

Are these changes tested?

Yes.

This defines the account id associated with a TableIdentifier.

This is a domain key: `sxt/table` that ensures this account id will not collide with any other account ids
@JayWhite2357
JayWhite2357 requested review from a team as code owners September 17, 2026 18:45
@JayWhite2357
JayWhite2357 changed the base branch from fix/rollback-prover-db-indexer to main September 17, 2026 18:49
@JayWhite2357
JayWhite2357 force-pushed the feat/indexer-quorum-refunds branch from a3ddf66 to 7cc508c Compare September 21, 2026 20:41
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

1.70.0

Bug Fixes

  • default prover-db indexer to disabled unless explicitly enabled (360803d
  • fallback to client hash when is missing (95794da
  • make on chain indexer keys saturate rather than default to (5f794de
  • rollback to git commit hash 6e668a9 (3d9b9d4
  • use finalized block in prover-db-indexer (50438ab

Features

  • add helper that queries the client for s. (4fc3952
  • add table metadata domain (12b42aa
  • add for refunding quorum submitters (67075ad
  • add helper (8fb2ff8
  • add client native interface and extenality (d9c6c4d
  • add generic config key-value store for offchain workers (117b845
  • adds (a5b581d
  • Document Snapshot Download Process (4c2608b
  • drop from prover_db_indexer (b3381c5
  • refund submission fee to quorum submitters (556fb73
  • register client externality to offchain worker (338c213
  • use client for (6679c06
  • use generic key value config for prover_db_indexing instead of storage/CLI based config (faff564

@JayWhite2357
JayWhite2357 force-pushed the feat/indexer-quorum-refunds branch from 7cc508c to 070d4a0 Compare September 22, 2026 15:13
Comment thread sxt-core/src/utils.rs Outdated
}

/// Takes a table identifier and returns the deterministic `AccountId` of its treasury.
pub fn account_id_from_table_id<T: frame_system::Config>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: this function name to me implies that there is some cannonical conversion between table identifiers and accounts, whereas this is more of a specific derivation. I'd prefer something like table_treasury_account

Comment thread sxt-core/src/utils.rs
))
.ok()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use a unit test, specifically one whose test case is generated by the UI Miguel wrote for this

Comment thread pallets/indexing/src/lib.rs Outdated
refund,
Preservation::Expendable,
) {
Pallet::<T, I>::deposit_event(Event::RefundError { recipient, error });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea of emitting an event instead of erroring that... this basically means the table is probably underfunded, and it ends up costing indexers to submit to it, but they're incentivized not to since they're not getting payed? And then we never just drop inserts in the event that, say, a system table is underfunded?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

Comment thread pallets/indexing/src/lib.rs Outdated
Comment on lines +556 to +560
/// The refund is the submission's actual extrinsic fee (computed the same way
/// `pallet_transaction_payment` does, given `weight`) scaled by the table's configured
/// submission fee refund percentage (`100` = full refund, `150` = 1.5x, etc), stored under
/// the `REFUND_PERCENTAGE_DOMAIN` table metadata entry. If no percentage is configured, or
/// its bytes fail to decode as a `u16`, no refund is made.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This is re-explained on the const docs you've added, it'd be good to have it in just one place and intra-doc-link

Comment on lines +571 to +572
.and_then(|domain| pallet_tables::TableMetadata::<T>::get(&domain, &quorum.table))
.and_then(|bytes| u16::decode(&mut bytes.as_slice()).ok())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to have events for these scenarios instead of nothing. If a table owner really doesn't want to give out refunds, they could set the percentage to 0. I guess maybe the concern is that we'd suddenly have a lot more events for inserts to the existing tables we're indexing to?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought is that if the table refund percentage is not set or invalid, that means "no refunds".
Since refunds are optional and by default off, when there are no refunds, I feel like it would be odd to have a "No refund configured" event.

This doesn't change anything since `finalize_quorum` already only uses it by reference.
…et-indexing's `Config`

Needed so the pallet can later draw on a table's treasury balance and
compute the real extrinsic fee for a submission when refunding it.
This is the `pallet_tables::TableMetadata` domain key that will store a
table's submission fee refund percentage.
In this implementation, only agreements are refunded. Late submissions and dissents are not refunded. That change is left for later.
@JayWhite2357
JayWhite2357 force-pushed the feat/indexer-quorum-refunds branch from 070d4a0 to 556fb73 Compare October 1, 2026 01:04
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.

2 participants