Repository navigation
feat(drive): credit storage refunds to their recorded owners #4706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
35926bc
feat(platform)!: introduce protocol version 15 with drive table v10 f…
DCG-Claude 9ca1e39
feat(drive)!: require fee history for storage refunds and credit thei…
DCG-Claude 8860f1b
test(drive): pin fee history handling of calculate_fee v0 and v1
DCG-Claude dc166c9
test(drive): cover the recorded-owner refund credit primitive
DCG-Claude fea0e57
test(drive): close group actions through the production funnel with f…
DCG-Claude 5c07b34
test(drive): pin the protocol 12 schema strip as the recorded refund …
DCG-Claude b087724
docs(book): describe fee history and refund ownership from protocol v…
DCG-Claude 39cbdb7
test(drive): pass the fee history where tests replace epoch-flagged d…
DCG-Claude 2c8f0fc
test(drive): name the per-owner refund fixtures for clippy
DCG-Claude 6b0eeb7
fix(drive): report refund credits that repay identity debt for the pr…
DCG-Claude f6448f2
docs(book): say lifecycle refund settlement is not yet wired at proto…
DCG-Claude bc113d8
docs(book): attribute storage refunds to the recorded owner in the fe…
DCG-Claude 2fc11c1
refactor(drive): read each refund owner once when crediting its balance
DCG-Claude 346d481
test(drive): unban, unsuspend and replace suspensions through the pro…
DCG-Claude 58d6eef
fix(drive): price ephemeral TTL bytes in calculate_fee v1 as v0 does
DCG-Claude b064de5
test(drive): close the structure fixture's group action with fee hist…
DCG-Claude 1576eb4
fix(drive)!: price a batch before committing the transaction drive owns
DCG-Claude 5fb247a
test(drive): assert a rejected refund pricing leaves state untouched …
DCG-Claude 2b059a3
fix(drive)!: price document and contract writes before committing the…
DCG-Claude 11b781d
test(drive): assert rejected document and contract pricing leaves sta…
DCG-Claude 27628d9
fix(drive)!: price add_document, index-only deletes and warning repla…
DCG-Claude 8b4caed
test(drive): assert rejected add_document, index-only delete and warn…
DCG-Claude e1850c7
refactor(drive): take the repaid debt of a storage refund from the ba…
DCG-Claude 0c25a08
fix(drive): price the contract fetch when adding a document by contra…
DCG-Claude f8a73fd
fix(drive)!: price contested document inserts before committing
DCG-Claude fe715fa
test(drive): assert a rejected second contender leaves a no-locking c…
DCG-Claude 8e5f847
test(drive): give the refund regression fixtures fixed owner ids
DCG-Claude 7a6ecd0
test(drive): pass the fee history in fixtures that remove flagged byt…
DCG-Claude 5590340
fix(drive)!: price a removal of only system bytes without the fee his…
DCG-Claude 7487910
docs(drive): say why the in-place edits to shipped generations are inert
DCG-Claude 29b76e0
refactor(platform): write the protocol 15 drive tables as struct updates
DCG-Claude b561115
refactor(drive): write refund owners' negative credit through the ver…
DCG-Claude 37b525f
test(drive): strip more than the refund dust limit in the migration f…
DCG-Claude 8fbf2b2
refactor(drive): give price-before-commit its own apply contract gene…
DCG-Claude f500212
refactor(drive): reach the protocol 15 fee generation only through ca…
DCG-Claude a6b051d
refactor(drive): keep the protocol 15 fee and batch generations behin…
DCG-Claude 9768b75
docs(drive): record protocol 15 refund fee history and owner credits …
DCG-Claude 0203d33
test(drive): pin that the genesis epoch's empty fee history prices ow…
DCG-Claude eb6bf5c
fix(drive)!: reject an empty fee history after the genesis epoch
DCG-Claude b139754
docs(drive): name generation 2 as protocol 15's apply contract genera…
DCG-Claude 826ac2d
test(drive-abci): record a changed fee version where fast-forwarding …
DCG-Claude b87d6a3
refactor(drive): give price-before-commit its own apply_drive_operati…
DCG-Claude 1934b4f
docs(platform): drop a stale generation from protocol 15's drive comment
DCG-Claude a481ffd
test(drive): seed debt in the positive-balance refund credit test
DCG-Claude 81731a0
docs(drive): record the apply contract wrapper's double-counted read …
DCG-Claude af6e224
Merge branch 'v5.1-dev' into dashvm/r12-02
QuantumExplorer 851dffb
fix(drive): price an applied contract's lookup once in the protocol 1…
QuantumExplorer c2528db
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 84bbe73
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 5dd3139
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 3d896d9
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 796c051
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 3451a35
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude e58c9b1
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 0351b3b
chore: merge v5.1-dev into dashvm/r12-02
DCG-Claude 6c62f8a
chore: merge v5.1-dev into dashvm/r12-02 and narrow to recorded-owner…
DCG-Claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
84 changes: 84 additions & 0 deletions
84
...rive/src/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/mod.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| mod v0; | ||
|
|
||
| use crate::drive::identity::update::storage_refund_credit_outcome::StorageRefundCreditOutcome; | ||
| use crate::drive::Drive; | ||
| use crate::error::drive::DriveError; | ||
| use crate::error::Error; | ||
| use crate::fees::op::LowLevelDriveOperation; | ||
| use dpp::fee::fee_result::refunds::FeeRefunds; | ||
| use dpp::version::PlatformVersion; | ||
| use grovedb::TransactionArg; | ||
|
|
||
| impl Drive { | ||
| /// Credits storage refunds to their recorded owners and reports what could | ||
| /// not be routed. | ||
| /// | ||
| /// For every owner in `fee_refunds` except `skip_owner`, the owner's | ||
| /// per-epoch credits are summed with checked arithmetic. An owner with a | ||
| /// balance element is credited the way a state transition payer's own | ||
| /// refund is (one balance read feeding `add_to_previous_balance`, then the | ||
| /// balance and negative credit updates); no key, signature or permission | ||
| /// is consulted, so a frozen but existing owner receives its bookkeeping | ||
| /// refund. When that owner's balance is | ||
| /// zero the helper first clears its negative credit (identity debt), and | ||
| /// only the remainder reaches the balance; the cleared debt is reported as | ||
| /// `repaid_debt` because debt lives outside the credit sum trees and is | ||
| /// processing fee the pools were short of when it was incurred. An owner | ||
| /// without a balance element (the native proxy for a wiped owner) is not | ||
| /// credited and its amount is reported as `routed_to_processing_pool`. | ||
| /// The caller settles `processing_pool_share()` (both amounts) into the | ||
| /// current epoch's processing pool with one pool write and records the | ||
| /// pending refunds; the primitive does neither, so the block keeps a | ||
| /// single pending-refund and pool write per batch. | ||
| /// | ||
| /// # Parameters | ||
| /// | ||
| /// * `fee_refunds` - The refunds to settle, per owner and storage epoch. | ||
| /// * `skip_owner` - An owner whose refund the caller settles itself (a | ||
| /// state transition payer, whose refund folds into its balance change); | ||
| /// `None` on lifecycle paths. | ||
| /// * `transaction` - The current transaction. | ||
| /// * `drive_operations` - The accumulator the balance operations are | ||
| /// appended to; the caller applies them. | ||
| /// * `platform_version` - The platform version. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
| /// * `Ok(StorageRefundCreditOutcome)` - The owners credited, the debt the | ||
| /// refunds repaid and the amount routed to the processing pool. | ||
| /// * `Err(Error)` - On overflow, a corrupted balance element, or when the | ||
| /// method is not active for the platform version. | ||
| pub fn credit_storage_refunds_to_owners_operations( | ||
| &self, | ||
| fee_refunds: &FeeRefunds, | ||
| skip_owner: Option<[u8; 32]>, | ||
| transaction: TransactionArg, | ||
| drive_operations: &mut Vec<LowLevelDriveOperation>, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<StorageRefundCreditOutcome, Error> { | ||
| match platform_version | ||
| .drive | ||
| .methods | ||
| .identity | ||
| .update | ||
| .credit_storage_refunds_to_owners | ||
| { | ||
| Some(0) => self.credit_storage_refunds_to_owners_operations_v0( | ||
| fee_refunds, | ||
| skip_owner, | ||
| transaction, | ||
| drive_operations, | ||
| platform_version, | ||
| ), | ||
| Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { | ||
| method: "credit_storage_refunds_to_owners_operations".to_string(), | ||
| known_versions: vec![0], | ||
| received: version, | ||
| })), | ||
| None => Err(Error::Drive(DriveError::VersionNotActive { | ||
| method: "credit_storage_refunds_to_owners_operations".to_string(), | ||
| known_versions: vec![0], | ||
| })), | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.