diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index c9ca0511b3e..19d927be031 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -124,6 +124,7 @@ - [Ranked Index Examples](drive/ranked-index-examples.md) - [Time-Range Index TTL](drive/time-range-ttl.md) - [Index-Only Document Types](drive/index-only-document-types.md) +- [Keep-History Documents](drive/keep-history-documents.md) # Testing diff --git a/book/src/contract-keywords/deletion.md b/book/src/contract-keywords/deletion.md index ae64dd11628..fc780824b90 100644 --- a/book/src/contract-keywords/deletion.md +++ b/book/src/contract-keywords/deletion.md @@ -12,8 +12,8 @@ Whether a document's owner may delete it. Set it to `false` for records that oth | **Value** | boolean, or `"onlyWhenConsumed"` | | **Default** | the contract config's `documentsCanBeDeletedContractDefault`, which is `true` unless the contract says otherwise | | **Since** | protocol version 1; `"onlyWhenConsumed"` protocol version 14 | -| **On update** | Fixed (`DocumentTypeUpdateError`, 40212), except that a type which keeps history before and after the update may change it from `true` to `false`. Adding or removing the key without changing its value is refused too, as a schema change (`IncompatibleDocumentTypeSchemaError`, 10246). | -| **Errors** | `InvalidDocumentTransitionActionError` (10404) for a delete of a type set to `false` or `"onlyWhenConsumed"`, or, from protocol version 14, of a type that keeps history; `DocumentOwnerIdMismatchError` (40102) for a delete by anyone but the owner | +| **On update** | Fixed (`DocumentTypeUpdateError`, 40212), except that a type which keeps history before and after the update may change it from `true` to `false` when it does not allow erasure. Adding or removing the key without changing its value is refused too, as a schema change (`IncompatibleDocumentTypeSchemaError`, 10246). | +| **Errors** | `InvalidDocumentTransitionActionError` (10404) for a delete of a type set to `false` or `"onlyWhenConsumed"`, or, at protocol version 14, of a type that keeps history; `DocumentOwnerIdMismatchError` (40102) for a delete by anyone but the owner | ### Example @@ -40,14 +40,14 @@ A commenter may take a comment down at any time. Since `true` is the usual defau - An identity that is banned or suspended on a moderated contract may still delete its own documents. See [Contract Moderation](../data-model/contract-moderation.md#the-model). On a type set to `false` it can retract them instead, when the type declares [`retractedWhen`](#retractedwhen). - `false` binds only the owner. The contract's moderators, when the type allows them, and the platform, when the type has a `ttl`, still delete such documents. - `"onlyWhenConsumed"` binds the owner as `false` does, and lets a create consume the document (see [below](#deleted-only-when-consumed)). -- Drive never deletes a document whose type keeps history (`documentsKeepHistory`). From protocol version 14 a delete of such a document is refused with 10404 whatever `canBeDeleted` says; before it, the delete failed inside Drive as an internal error. +- Through protocol version 14, Drive refuses to delete a document whose type keeps history (`documentsKeepHistory`): 10404 at version 14, and an internal error before it. From version 15, an allowed owner delete removes the current pointer and indexes while retaining its revisions and a lifecycle record. Retained revision storage is refunded only when an allowed erase removes it. See [`canBeErased`](#canbeerased). - Documents of an `indexOnly` type are deleted with an index-only delete transition that carries their values, since there is no stored row to name by id. A delete by id of such a document is refused (10404). See [Index-Only Types](index-only.md). ### Rules at registration -- From protocol version 14, a type with `documentsKeepHistory: true` must set `canBeDeleted: false` (`InvalidContractStructure`, 10231). The default is `true`, so it has to be written out. A contract registered earlier with both flags on stays readable, but its next update is checked like a new contract, so that update must turn `canBeDeleted` off on the type. That is the one change to `canBeDeleted` an update may make. +- At protocol version 14, a type with `documentsKeepHistory: true` must set `canBeDeleted: false` (`InvalidContractStructure`, 10231); older types stay readable but must withdraw deletion on their next update. From version 15, deletable history is admitted, including legacy types whose flag is already true. A history type may withdraw deletion on update only when it does not allow erasure. - For references, a type whose owner may delete its documents is deletable: a `permanentDocument` reference, `inList` included, may not point at it (`ReferencedDocumentTypeDeletableError`, 40122), and a `deletableDocument` reference may. See [References](refers-to.md). -- `"onlyWhenConsumed"` is refused on a type that keeps history or is `indexOnly` (`InvalidContractStructure`, 10231): the storage layer never deletes a document that keeps history, and an `indexOnly` type has no stored row a reference finds, so nothing could consume either. +- `"onlyWhenConsumed"` is refused on a type that keeps history or is `indexOnly` (`InvalidContractStructure`, 10231): history types cannot be consumed, and an `indexOnly` type has no stored row a reference finds. ### Deleted only when consumed @@ -77,6 +77,23 @@ A preorder stays until the name registration that reveals it consumes it (the `p - Fixed on update: an update may neither set nor remove it (`DocumentTypeUpdateError`, 40212). Setting it would let documents leave state under the `permanentDocument` references made to a type that promised they never would; removing it would leave the references that consume its documents nothing to delete. - Before protocol version 14 the meta-schemas accept only a boolean, so a contract carrying the string is refused (`JsonSchemaError`, 10101). +## `canBeErased` + +Whether the retained history of a deleted document may be removed, from protocol version 15. + +| | | +|---|---| +| **Where** | document type | +| **Value** | boolean | +| **Default** | `false` | +| **Since** | protocol version 15 | +| **On update** | Fixed in both directions (`DocumentTypeUpdateError`, 40212) | +| **Requires** | `documentsKeepHistory: true` and `canBeDeleted: true` | + +Delete and erase are separate operations. Delete removes the current pointer and indexes, retaining the revisions. The document's current owner authorizes erasure with the first erase transition. Once erasure starts, any identity may pay to continue it in bounded chunks; the final chunk removes the lifecycle record and history without leaving a receipt. Each removed revision refunds its recorded storage payer. An erase carries no token payment or action fee. + +A type that allows erasure cannot withdraw deletion on update. A history type cannot carry a contested index, moderator deletion or a `ttl`. See [Keep-History Documents](../drive/keep-history-documents.md) for the complete lifecycle, temporal reads and proof behavior. + ## `retractedWhen` The replace that retracts a document: what a banned or suspended author may still do on a type whose documents it can not delete. A barred identity can write nothing new, but deleting what it wrote is never refused. On a type set to `canBeDeleted: false` there is no delete, and the author's only way to take a document back is a replace that blanks it, which a bar refuses like any other write. `retractedWhen` names that replace, and lets it through. @@ -242,7 +259,7 @@ Authors cannot retract a post, but the contract's moderators can remove one for All refusals below are `InvalidContractStructure` (10231). - The contract's config must declare `moderation`. Moderation cannot be added by a later update, so without it nobody could ever delete anything. In return the `moderation` block may keep no banlist, suspension list or warning list at all when a document type gives its moderators an ability. -- Refused on a type that keeps history (Drive never deletes those documents), on an `indexOnly` type (there is no stored row to name), on a type with `creationRestrictionMode` 1 or 2 (its documents are the contract owner's or the platform's), and on a type with a contested index (a restore could not go through the vote the index requires). +- Refused on a type that keeps history (history lifecycle deletion is owner-only), on an `indexOnly` type (there is no stored row to name), on a type with `creationRestrictionMode` 1 or 2 (its documents are the contract owner's or the platform's), and on a type with a contested index (a restore could not go through the vote the index requires). - For references, the type is no longer permanent even with `canBeDeleted: false`: a `permanentDocument` reference, `inList` included, may not point at it (40122). With `canBeDeleted: false`, no `ttl` and removal records kept (the default), its documents leave state only on a moderator's record, and a [`moderatedDocument`](refers-to.md#moderateddocument) reference is the one that points at it, resolving to the document or to its removal record; a `deletableDocument` reference is refused (40144). Otherwise a `deletableDocument` reference points at it. ## `moderatorAbilities.deleteWithin` @@ -455,6 +472,7 @@ Whether the owner of a document a moderator deletes is refunded its storage. By | Who deletes | Allowed by | Refund to the owner | |---|---|---| | The document's owner | `canBeDeleted: true`, on a type that does not keep history, when the stored document meets every `deleteConstraints` rule | Yes, except on a type with a `ttl` | +| The document's owner, retaining history from protocol version 15 | `canBeDeleted: true`, when the stored document meets every `deleteConstraints` rule | Removed pointer/index storage only; retained revisions are refunded to their payers on erase | | The contract's moderators | `moderatorAbilities.delete: true`, within `moderatorAbilities.deleteWithin` when set | Only with `moderatorAbilities.deleteRefundsOwner: true`, except on a type with a `ttl` | | The seated moderation team, together | `moderatorAbilities.deleteSettled`, once `moderatorAbilities.deleteWithin` has passed | As for the moderators | | The platform | `ttl`, once it has passed | No | @@ -466,7 +484,7 @@ Which reference may point at a type follows from which of the three it allows. A - [Deleting Documents](../data-model/contract-moderation.md#deleting-documents), [Deleting Settled Documents](../data-model/contract-moderation.md#deleting-settled-documents) and [Restoring Documents](../data-model/contract-moderation.md#restoring-documents), for the moderation transition, the approvals and the removal record - [Moderator Abilities](moderator-abilities.md), for the `moderatorAbilities` object and the fields only moderators write - [Time To Live](ttl.md), the third way a document leaves the state -- [History](history.md), for why a type that keeps history can never delete +- [History](history.md) and [Keep-History Documents](../drive/keep-history-documents.md), for retained revisions, lifecycle states and proofs - [Mutability](mutability.md), for `immutable` and the conditions `retractedWhen` shares with it, and [Creation, Transfers and Trading](ownership-and-trading.md) - [propertyConstraints](property-constraints.md), for the grammar of `deleteConstraints` and the totals its rules read - [References](refers-to.md), for `permanentDocument`, `moderatedDocument` and `deletableDocument` diff --git a/book/src/contract-keywords/history.md b/book/src/contract-keywords/history.md index 633aea129a9..25dc0bd3a07 100644 --- a/book/src/contract-keywords/history.md +++ b/book/src/contract-keywords/history.md @@ -13,7 +13,7 @@ Keeps every version of every document of the type, not only the latest. | **Default** | the contract config's `documentsKeepHistoryContractDefault`, which is `false` unless the contract says otherwise | | **Since** | protocol version 1 | | **On update** | Fixed (`DocumentTypeUpdateError`, 40212). Adding or removing the key without changing its value is refused too, as a schema change (`IncompatibleDocumentTypeSchemaError`, 10246). | -| **Errors** | `InvalidDocumentTransitionActionError` (10404) for a delete of a document of the type, from protocol version 14 | +| **Errors** | `InvalidDocumentTransitionActionError` (10404) for a delete at protocol version 14, or when `canBeDeleted` refuses it | ### Example @@ -31,15 +31,15 @@ Keeps every version of every document of the type, not only the latest. } ``` -Every edit of a profile adds a version, and every earlier version stays readable. `canBeDeleted: false` has to be written out, since a type that keeps history can never delete and the default is `true`. +Every edit of a profile adds a version. This example explicitly prevents owner deletion; the usual default is `true`. Protocol version 14 requires `canBeDeleted: false` on a history type. From version 15, a deletable history type may remove the current document while retaining its revisions, and may separately allow their erasure with [`canBeErased`](deletion.md#canbeerased). ### How it works - Through protocol version 14, each document is stored as a small tree of its own, with versions keyed by block time and a pointer to the current one. From protocol version 15, versions live in a separate history tree for the document type and retain both time and revision, including edits sharing a block time. A query by id or through an index sees the current version. - Every write that changes the document adds a version: a replace, and also a transfer, a price update or a purchase. -- Nothing is ever removed. Drive refuses to delete a document whose type keeps history, so its owner's delete is refused (10404 from protocol version 14; before it, the delete failed inside Drive as an internal error), and the type can have neither moderator deletion nor a `ttl`. +- Through protocol version 14, Drive refuses to delete a document whose type keeps history (10404 at version 14; before it, the delete failed inside Drive as an internal error). From version 15, an allowed owner delete removes the current pointer and indexes but retains every revision. Erase transitions may then remove retained revisions if the type declares `canBeErased: true`. History types still allow neither moderator deletion nor a `ttl`. - The `getDocumentHistory` query returns a document's versions from a given time on, each with the block time it was written at, at most 10 per request, and with a proof when asked. -- Every version stays stored, paid for by the write that added it. +- Each retained version is paid for by the write that added it. Erasure refunds removed storage to its recorded payer. - A doctype-level sum or average (`documentsSummable`, `documentsAverageable`) counts only each document's current version. See [Counts, Sums and Averages](aggregates.md). `getDocumentHistory` uses request and response version 0 through protocol version @@ -61,8 +61,9 @@ unsupported-query-version error; the SDK does not fall back to version 0. All refusals below are `InvalidContractStructure` (10231). -- From protocol version 14, the type must set `canBeDeleted: false`. A contract registered earlier with both flags on stays readable, and its next update must turn `canBeDeleted` off on that type. See [Deletion](deletion.md). +- At protocol version 14, the type must set `canBeDeleted: false`; an older contract with both flags on stays readable but must turn deletion off on its next update. From version 15, deletable history is admitted. Older types whose deletion flag is true become soft-deletable at activation without an update. See [Deletion](deletion.md). - Refused together with `ttl`, with `moderatorAbilities.delete` and with `indexOnly`. +- From protocol version 15, refused together with a contested index. ## `keepsTransferHistory` @@ -153,6 +154,7 @@ The document history contract is a system contract registered at protocol versio ## See also - [Creation, Transfers and Trading](ownership-and-trading.md), for the actions the three flags record -- [Deletion](deletion.md) and [Time To Live](ttl.md), for why a type that keeps history can never lose a document +- [Deletion](deletion.md) and [Time To Live](ttl.md), for owner deletion, erasure and the expiry restriction +- [Keep-History Documents](../drive/keep-history-documents.md), for lifecycle states, temporal reads and proofs - [Counts, Sums and Averages](aggregates.md), for the aggregates of the history records - [Contract-Level Keys and config](contract-config.md), for `documentsKeepHistoryContractDefault` and the contract's own `keepsHistory` diff --git a/book/src/contributing/coding-conventions.md b/book/src/contributing/coding-conventions.md index 2420ccce875..9ba21eca200 100644 --- a/book/src/contributing/coding-conventions.md +++ b/book/src/contributing/coding-conventions.md @@ -114,6 +114,75 @@ section that lists each edited generation, the protocol versions that select it, and the reason consensus cannot change there. Reviewers read that section first. +### A new input changes the signature, not the method count + +When the new generation of a method needs something its callers do not pass +yet (the block, the signer, a mode), add the parameter to the method and +update the callers. Do not add a second method beside it (`*_with_lifecycle`, +`*_with_block`), a second operation variant beside the existing one +(`DeleteDocumentWithLifecycle` next to `DeleteDocument`), or a wrapper that +fabricates the missing value on the way in. One method per directory means +one signature, the one the current generation needs. + +The shipped generation keeps its own signature. The dispatcher hands it the +part of the new input it always had and drops the rest: + +```rust +pub fn delete_document_for_contract_operations( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + block_info: &BlockInfo, // was `block_time_ms: u64` + deleter_id: Option, // new: whom the lifecycle record credits + previous_batch_operations: Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, +) -> Result, Error> { + match platform_version.drive.methods.document.delete.delete_document_for_contract_operations { + // The shipped generation never knew a deleter; it reads the time off + // the block exactly as it read `block_time_ms` before. + 0 => self.delete_document_for_contract_operations_v0( + document_id, + contract, + document_type, + previous_batch_operations, + estimated_costs_only_with_layer_info, + block_info.time_ms, + transaction, + platform_version, + ), + 1 => self.delete_document_for_contract_operations_v1( + document_id, + contract, + document_type, + block_info, + deleter_id, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { .. })), + } +} +``` + +Why: a twin method is a second name for the same behaviour with the version +decision split across two dispatchers, and callers that reach the old name +silently get the old capability at the new protocol version, or a value +somebody made up to satisfy the old signature. Changing the signature makes +the compiler find every caller, and each one then states what it passes. + +How: change the dispatcher's signature, re-point the callers, and let +generation 0 keep receiving what it received before. If a wrapper's new +generation would only forward the new parameter to the method that has the +behaviour, it is not a new generation: forward it from the wrapper's existing +body and leave the wrapper's version slot alone. The one exception is a +public client-facing API that must stay source-compatible across a release; +there, the SDK's builder pattern absorbs the new input. + ### Table versions follow protocol-version boundaries, not PRs Version-table constants (`DRIVE_ABCI_VALIDATION_VERSIONS_V10`, diff --git a/book/src/drive/keep-history-documents.md b/book/src/drive/keep-history-documents.md new file mode 100644 index 00000000000..4507f0f38bb --- /dev/null +++ b/book/src/drive/keep-history-documents.md @@ -0,0 +1,314 @@ +# Keep-History Documents + +> **Status:** implemented and gated at protocol version 15 (meta-schema v3 / +> parser generation 4). The storage layout, the delete and erase paths and +> the fee accounting are pinned against a real grovedb by +> [`lifecycle/tests.rs`](https://github.com/dashpay/platform/blob/v5.1-dev/packages/rs-drive/src/drive/document/lifecycle/tests.rs) +> in rs-drive; the full ABCI pipeline (transitions, validation, proofs, +> refunds) by the `keep_history`, `deletion`, `erase` and +> `lifecycle_contracts` modules under rs-drive-abci's batch tests; and the +> whole story against a running network by +> [`KeepHistoryDocument.spec.js`](https://github.com/dashpay/platform/blob/v5.1-dev/packages/platform-test-suite/test/functional/platform/KeepHistoryDocument.spec.js). + +A document type declared with `documentsKeepHistory: true` retains every +revision of every document instead of overwriting the previous one. This +chapter is the reference for how those revisions are stored, how a +keep-history document is deleted and later erased, what the four lifecycle +states mean, and how `getDocumentHistory` reports all of it. + +## Storage layout + +Every document type owns three reserved single-byte keys under its +document-type tree. Index trees are keyed by property names, which cannot +start below `0x30`, so no index can collide with them. + +```text +[DataContractDocuments, contract_id, 1, , 0, ] + → Reference to the current revision (the primary-key tree) + +[DataContractDocuments, contract_id, 1, , 1, ] + → Item() (the lifecycle tree) + +[DataContractDocuments, contract_id, 1, , 2, ] + → ProvableCountTree (the history tree) + [] → Item() +``` + +For a type that does not keep history the primary-key tree holds the +serialized document itself and keys `1` and `2` do not exist. For a +keep-history type: + +- **The history tree** holds every retained revision of one document, keyed + by the block time it was written at followed by its revision, both + big-endian `u64`. Two revisions written in one block therefore stay + distinct. It is a provable count tree, so how many revisions a document + retains is a single hash-bound read, and its absence is provable. +- **The primary-key entry** is a reference to the newest revision, so every + ordinary by-id read and every secondary index resolve through it. For a + summable type the reference also carries the document's sum contribution. +- **The lifecycle record** exists exactly while the document is deleted or + erasing. It is what tells a deleted document apart from an id that was + never used: both are absent from the primary-key tree. The record is + `DocumentLifecycleRecord` in `rs-dpp` (`packages/rs-dpp/src/document/lifecycle`), + a versioned enum with the ordinary platform-serialization derives, stored + with the storage flags of the identity paying for deletion, including a gas sponsor. + +The record carries the block time the document was deleted at, the revision +it carried then, how many revisions the history retained at that moment, +and, once an erasure has been authorized, the block time the erasure started +and the newest revision that was retained when it started. The revision +count matters because a history written before protocol 15 can have gaps +(two writes in one block overwrote each other's revision); a by-revision +read is only meaningful when the retained revisions number one through the +deleted revision without a gap, and the record is where that is decided. + +The lifecycle tree is per type and unflagged. The first delete creates this +shared container; each record inside it carries its payer's storage flags, +which determine who receives its removal refund. + +## Contract grammar + +Protocol 15's parser generation 4 adds two rules to keep-history types: + +| Keyword | Meaning | Constraints | +|---|---|---| +| `canBeDeleted: true` | The owner may delete a document. Previously refused on a keep-history type, since the storage layer could not remove one. | Ordinary keyword, now allowed together with `documentsKeepHistory`. | +| `canBeErased: true` | The retained revisions of a deleted document may be purged. | Requires `documentsKeepHistory` and `canBeDeleted`; defaults to `false`; immutable across contract updates. | + +Declaring `canBeErased` on a type that keeps no history, or whose documents +can never be deleted, is a contract-structure error rather than an ignored +default: a type whose declared behaviour and reachable behaviour disagree +is an authoring mistake. The check runs even without full validation, +because the flag governs an irreversible operation. + +A keep-history type may **not** carry a contested index. A contested +resource is awarded by block processing, outside transition validation, at +an id derived from the winner rather than from the contested values, and on +a keep-history type that award could land on an id whose retained history +already exists. Lifting this needs changes to the contested machinery +itself; until then the parser refuses the combination. + +The generation 3 parser still refuses registration of a deletable keep-history +type. At activation, existing historical types use the composite layout; a +legacy type whose `canBeDeleted` is true, including its default, becomes +soft-deletable without a contract update. `canBeErased` remains false unless +the type declared it when registered under protocol 15. + +## The four lifecycle states + +```text + delete erase (first chunk, erase (terminal chunk) + Active ──────────► Deleted ──────────────────────► Erasing ──────────────────────► Absent + │ by the owner) by anyone + │ + └── erase of a history that fits in one chunk goes straight to Absent +``` + +| State | Primary-key entry | Lifecycle record | History tree | +|---|---|---|---| +| **Active** | reference | none | every revision | +| **Deleted** | none | deleted-at only | every revision retained at deletion | +| **Erasing** | none | deleted-at and erasing-from | shrinking, newest revisions removed first | +| **Absent** | none | none | none; no retained state or receipt | + +`DocumentLifecycleState` in `packages/rs-drive/src/drive/document/lifecycle/fetch` +is the one read that classifies a document. It is deliberately not folded +into the by-id fetch every document action performs: only stateful +validation of an action on a keep-history type needs the extra reads, and +they are ordered by how likely they are to settle the question. The +ordinary by-id read answers for every live document; only a miss pays for +the lifecycle record; only a deleted document pays a third read, for the +newest revision it retains, which is where its owner is read from. + +## Delete + +A delete on a keep-history document removes the primary-key reference and +every index reference, and writes the lifecycle record in their place. The +revisions are untouched, so `getDocumentHistory` keeps serving them. + +Two properties follow from the design: + +- **Delete never escalates.** It has no code path that removes a revision, + so a second delete of the same document is a paid consensus error + (`DocumentNotFoundError`, exactly as for an id that holds nothing) rather + than a deeper removal. +- **A deleted document keeps its id.** Creating over it is refused in + transition validation because ids include the identity-contract nonce. A + fresh nonce derives a different id. Independently, the storage writer refuses + insertion over retained revisions: + appending to a history that still retains revisions would silently merge + a new document into a deleted one's record, and the writer's check is + what covers callers that never pass through validation. + +Every Drive delete entry point takes the block the delete belongs to and the +deleter's identity, because the record has to name both. + +## Erase + +An erase purges the retained revisions of a document that has already been +deleted. It is a separate transition kind, `DocumentTransition::Erase`, +appended to the shipped enum the same way every earlier kind was, carrying +nothing beyond the base transition. Its structure validation requires the +type to keep history and to declare `canBeErased`; its state validation +depends on the lifecycle state: + +| Lifecycle state | Result | +|---|---| +| Active | refused; deleting is a separate intent with its own permission and cost | +| Deleted | allowed only for the document's owner, read from the newest retained revision | +| Erasing | allowed for **any** identity | +| Absent | `DocumentNotFoundError` | + +**Erasure is authorized once.** The owner commits the document to erasure +with the first chunk; the record that commitment leaves in state is then the +evidence that destruction was authorized, so any identity may submit the +remaining chunks and pay for them. An owner who loses their keys, their +funds or their permission cannot strand a half-erased document. For the same +reason an erase carries no token payment: the deletion it follows was +charged when the document was deleted, and a payment on a transition anyone +may submit would let a continuation move tokens. + +**Chunks.** One transition removes at most +`max_document_revisions_erased_per_transition` revisions (100 from +`SYSTEM_LIMITS_V5`), newest first, so a partial erasure leaves the oldest +content behind and preserves any existing revision gaps. The +enumeration reads one revision more than it may remove so that it knows, +before emitting anything, whether this chunk is the last one: + +- a **non-terminal first chunk** overwrites the record with the erasure it + authorizes; +- a **terminal chunk** removes the record and the now empty history subtree, + which GroveDB accepts only because the revision deletes are in the same + batch and refuses otherwise. + +The two never happen together, so one batch never carries two operations on +the record's key. + +The eraser pays for rewriting the record on the first chunk, including any +encoded-size growth. Its retained storage flags still determine who receives +the refund when the record is removed. + +**Accounting.** Removing a revision credits whoever paid for it, through the +storage flags every revision carries, in balance updates applied after the +transition's fee result is formed. The admission estimate cannot know how +many revisions a document retains, so it prices a full chunk of the type's +largest documents plus both endings; every erase is admitted against the +same worst-case estimate and the actual fee is what it removed. GroveDB's +query surface has no key-only result shape over a range, so the enumeration +reads revision bodies it discards, and the estimate charges for that read +honestly. + +## The `getDocumentHistory` query + +The query reads a page of a keep-history document's retained revisions +together with the document's lifecycle as of the same block. + +**Request.** A contract id, document type name and document id, an optional +`limit` (at most 10, the default), and exactly one selector: + +| Selector | Meaning | +|---|---| +| `startAtMs` | inclusive lower bound on block time | +| `startAfter { timeMs, revision }` | exclusive cursor returned with the previous page; the revision is needed because several revisions can share a block time | +| `startAtRevision` | inclusive lower bound on revision; refused on a history with gaps | +| `revision` | exactly one revision; requires limit one | + +**Response.** A page of entries, each the block time, revision and +serialized document, and a `Lifecycle` message: + +| Field | Meaning | +|---|---| +| `state` | `ACTIVE`, `DELETED`, `ERASING` or `ABSENT` | +| `remaining_revisions` | how many revisions the history still retains | +| `deleted_at_ms` | zero unless the document has been deleted | +| `erasing_started_at_ms` | zero unless an authorized erasure has started | +| `erasing_from_time_ms`, `erasing_from_revision` | the newest revision retained when the erasure started | + +Unproved responses carry these entries and lifecycle fields explicitly. +Proved responses carry only the signed proof object; the verifier derives +the page and every lifecycle field from authenticated state. + +**Proof.** One merged GroveDB proof authenticates the history page, current +pointer, lifecycle record and history count against one signed root. Version 1 +has no request offset: its cursor and revision selectors are expressed in the +history branch, with pagination limits confined to that branch. A legacy +two-proof envelope is not accepted. + +## Client surfaces + +**Rust SDK.** `DocumentHistory::fetch` with a `DocumentHistoryQuery` from +`dash-platform-queries` reads a page. `DocumentEraseTransitionBuilder` and +`Sdk::document_erase` submit one chunk; the result is named for what its +proof authenticates, which is that the document is absent by id, something +that was already true before the erase ran. That is why the call takes the +affected-state wait rather than the strict one. `Sdk::document_current_lifecycle` +is the separately named read for how much history is left. + +**JavaScript.** The evo-sdk `documents` facade gains `history()`, +`historyWithProof()` and `erase()`; the WASM SDK exposes them as +`getDocumentHistory`, `getDocumentHistoryWithProofInfo` and `documentErase`. +Every history selector is an exact `u64`: a `number` is accepted only up to +`Number.MAX_SAFE_INTEGER`, anything larger must be a `bigint`. + +```typescript +// Delete, then erase in chunks until the history is gone. The first erase +// is signed by the owner; later ones may be signed by any identity. +await sdk.documents.delete({ document, identityKey: ownerKey, signer }); + +let lifecycle; +do { + await sdk.documents.erase({ + document: { id, ownerId, dataContractId, documentTypeName }, + identityKey: ownerKey, + signer, + }); + ({ lifecycle } = await sdk.documents.history({ + dataContractId, documentTypeName, documentId: id, startAtMs: 0n, limit: 1, + })); +} while (lifecycle?.state === 'ERASING'); +``` + +## Versioning + +Everything above is selected only from `PLATFORM_V15`. Released tables gain +dormant slots, and protocols 12 through 14 replay unchanged: a keep-history +delete still ends in `InvalidDeletionOfDocumentThatKeepsHistory` at 12 and +13 and in a paid rejection at 14, and an erase transition is refused at +basic-structure validation below 15 by its per-kind bounds slot. The activation +migration preserves existing revisions and moves their pointers and index +references into the composite layout before lifecycle operations run. + +## Reads at a block time + +A single-document lookup at time `T` authenticates both its lifecycle record +and the newest retained revision at or before the ordered time limit. An +active document returns that revision, or absence before its first revision. +A deleted document returns a retained revision only when `T < deleted_at`; +at the deletion time and later it returns absence, including a replacement +and deletion in the same block. This comparison uses the original requested +time, before the history query clamps it to the maximum ordered timestamp. +As soon as erasure starts, every time returns absence. After terminal erasure +the empty history proves absence without a permanent receipt. + +History v1 pages continue returning surviving revisions and lifecycle metadata +during erasure. A `DriveDocumentQuery` with a block time remains refused for +keep-history types. + +## Rules and guidelines + +**Do:** +- Read a keep-history document's state through `fetch_document_lifecycle` + whenever the difference between deleted and never-existed matters. An + ordinary by-id read cannot tell them apart. +- Pass the block and the deleter to every Drive delete entry point; the + record needs both. +- Treat an erase's proof as an observation of the affected state and read + the lifecycle separately to learn what is left. + +**Do not:** +- Declare `canBeErased` without `documentsKeepHistory` and `canBeDeleted`, + or a contested index on a keep-history type. The parser refuses both. +- Add a token cost to an erase. Any identity may submit a continuation. +- Rely on a by-revision selector over a history written before protocol 15 + without checking `remaining_revisions` against the deleted revision; a + gapped history refuses it. diff --git a/book/src/evo-sdk/state-transitions.md b/book/src/evo-sdk/state-transitions.md index 7db9d3d1fdb..6ec92749ef5 100644 --- a/book/src/evo-sdk/state-transitions.md +++ b/book/src/evo-sdk/state-transitions.md @@ -116,12 +116,15 @@ await sdk.documents.create({ }); ``` -### Replace, delete, transfer +### Replace, delete, transfer, erase The `sdk.documents` facade also provides `replace()`, `delete()`, -`transfer()`, `purchase()`, and `setPrice()` methods. See the +`transfer()`, `purchase()`, `setPrice()` and, from protocol version 15, +`erase()` for purging the retained revisions of a deleted keep-history +document, with `history()` to read what is left. See the [API reference](https://dashpay.github.io/evo-sdk-website/docs.html) for -parameters. +parameters and the [Keep-History Documents](../drive/keep-history-documents.md) +chapter for the lifecycle those calls drive. ## Token operations diff --git a/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js b/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js index 00576814bc2..84e65c3b11c 100644 --- a/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js +++ b/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js @@ -55294,6 +55294,10 @@ $root.org = (function() { * @interface ILifecycle * @property {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State|null} [state] Lifecycle state * @property {number|Long|null} [remainingRevisions] Lifecycle remainingRevisions + * @property {number|Long|null} [deletedAtMs] Lifecycle deletedAtMs + * @property {number|Long|null} [erasingStartedAtMs] Lifecycle erasingStartedAtMs + * @property {number|Long|null} [erasingFromTimeMs] Lifecycle erasingFromTimeMs + * @property {number|Long|null} [erasingFromRevision] Lifecycle erasingFromRevision */ /** @@ -55327,6 +55331,38 @@ $root.org = (function() { */ Lifecycle.prototype.remainingRevisions = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + /** + * Lifecycle deletedAtMs. + * @member {number|Long} deletedAtMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.deletedAtMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Lifecycle erasingStartedAtMs. + * @member {number|Long} erasingStartedAtMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.erasingStartedAtMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Lifecycle erasingFromTimeMs. + * @member {number|Long} erasingFromTimeMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.erasingFromTimeMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Lifecycle erasingFromRevision. + * @member {number|Long} erasingFromRevision + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.erasingFromRevision = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + /** * Creates a new Lifecycle instance using the specified properties. * @function create @@ -55355,6 +55391,14 @@ $root.org = (function() { writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); if (message.remainingRevisions != null && Object.hasOwnProperty.call(message, "remainingRevisions")) writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.remainingRevisions); + if (message.deletedAtMs != null && Object.hasOwnProperty.call(message, "deletedAtMs")) + writer.uint32(/* id 3, wireType 0 =*/24).uint64(message.deletedAtMs); + if (message.erasingStartedAtMs != null && Object.hasOwnProperty.call(message, "erasingStartedAtMs")) + writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.erasingStartedAtMs); + if (message.erasingFromTimeMs != null && Object.hasOwnProperty.call(message, "erasingFromTimeMs")) + writer.uint32(/* id 5, wireType 0 =*/40).uint64(message.erasingFromTimeMs); + if (message.erasingFromRevision != null && Object.hasOwnProperty.call(message, "erasingFromRevision")) + writer.uint32(/* id 6, wireType 0 =*/48).uint64(message.erasingFromRevision); return writer; }; @@ -55395,6 +55439,18 @@ $root.org = (function() { case 2: message.remainingRevisions = reader.uint64(); break; + case 3: + message.deletedAtMs = reader.uint64(); + break; + case 4: + message.erasingStartedAtMs = reader.uint64(); + break; + case 5: + message.erasingFromTimeMs = reader.uint64(); + break; + case 6: + message.erasingFromRevision = reader.uint64(); + break; default: reader.skipType(tag & 7); break; @@ -55436,11 +55492,25 @@ $root.org = (function() { return "state: enum value expected"; case 0: case 1: + case 2: + case 3: break; } if (message.remainingRevisions != null && message.hasOwnProperty("remainingRevisions")) if (!$util.isInteger(message.remainingRevisions) && !(message.remainingRevisions && $util.isInteger(message.remainingRevisions.low) && $util.isInteger(message.remainingRevisions.high))) return "remainingRevisions: integer|Long expected"; + if (message.deletedAtMs != null && message.hasOwnProperty("deletedAtMs")) + if (!$util.isInteger(message.deletedAtMs) && !(message.deletedAtMs && $util.isInteger(message.deletedAtMs.low) && $util.isInteger(message.deletedAtMs.high))) + return "deletedAtMs: integer|Long expected"; + if (message.erasingStartedAtMs != null && message.hasOwnProperty("erasingStartedAtMs")) + if (!$util.isInteger(message.erasingStartedAtMs) && !(message.erasingStartedAtMs && $util.isInteger(message.erasingStartedAtMs.low) && $util.isInteger(message.erasingStartedAtMs.high))) + return "erasingStartedAtMs: integer|Long expected"; + if (message.erasingFromTimeMs != null && message.hasOwnProperty("erasingFromTimeMs")) + if (!$util.isInteger(message.erasingFromTimeMs) && !(message.erasingFromTimeMs && $util.isInteger(message.erasingFromTimeMs.low) && $util.isInteger(message.erasingFromTimeMs.high))) + return "erasingFromTimeMs: integer|Long expected"; + if (message.erasingFromRevision != null && message.hasOwnProperty("erasingFromRevision")) + if (!$util.isInteger(message.erasingFromRevision) && !(message.erasingFromRevision && $util.isInteger(message.erasingFromRevision.low) && $util.isInteger(message.erasingFromRevision.high))) + return "erasingFromRevision: integer|Long expected"; return null; }; @@ -55465,6 +55535,14 @@ $root.org = (function() { case 1: message.state = 1; break; + case "DELETED": + case 2: + message.state = 2; + break; + case "ERASING": + case 3: + message.state = 3; + break; } if (object.remainingRevisions != null) if ($util.Long) @@ -55475,6 +55553,42 @@ $root.org = (function() { message.remainingRevisions = object.remainingRevisions; else if (typeof object.remainingRevisions === "object") message.remainingRevisions = new $util.LongBits(object.remainingRevisions.low >>> 0, object.remainingRevisions.high >>> 0).toNumber(true); + if (object.deletedAtMs != null) + if ($util.Long) + (message.deletedAtMs = $util.Long.fromValue(object.deletedAtMs)).unsigned = true; + else if (typeof object.deletedAtMs === "string") + message.deletedAtMs = parseInt(object.deletedAtMs, 10); + else if (typeof object.deletedAtMs === "number") + message.deletedAtMs = object.deletedAtMs; + else if (typeof object.deletedAtMs === "object") + message.deletedAtMs = new $util.LongBits(object.deletedAtMs.low >>> 0, object.deletedAtMs.high >>> 0).toNumber(true); + if (object.erasingStartedAtMs != null) + if ($util.Long) + (message.erasingStartedAtMs = $util.Long.fromValue(object.erasingStartedAtMs)).unsigned = true; + else if (typeof object.erasingStartedAtMs === "string") + message.erasingStartedAtMs = parseInt(object.erasingStartedAtMs, 10); + else if (typeof object.erasingStartedAtMs === "number") + message.erasingStartedAtMs = object.erasingStartedAtMs; + else if (typeof object.erasingStartedAtMs === "object") + message.erasingStartedAtMs = new $util.LongBits(object.erasingStartedAtMs.low >>> 0, object.erasingStartedAtMs.high >>> 0).toNumber(true); + if (object.erasingFromTimeMs != null) + if ($util.Long) + (message.erasingFromTimeMs = $util.Long.fromValue(object.erasingFromTimeMs)).unsigned = true; + else if (typeof object.erasingFromTimeMs === "string") + message.erasingFromTimeMs = parseInt(object.erasingFromTimeMs, 10); + else if (typeof object.erasingFromTimeMs === "number") + message.erasingFromTimeMs = object.erasingFromTimeMs; + else if (typeof object.erasingFromTimeMs === "object") + message.erasingFromTimeMs = new $util.LongBits(object.erasingFromTimeMs.low >>> 0, object.erasingFromTimeMs.high >>> 0).toNumber(true); + if (object.erasingFromRevision != null) + if ($util.Long) + (message.erasingFromRevision = $util.Long.fromValue(object.erasingFromRevision)).unsigned = true; + else if (typeof object.erasingFromRevision === "string") + message.erasingFromRevision = parseInt(object.erasingFromRevision, 10); + else if (typeof object.erasingFromRevision === "number") + message.erasingFromRevision = object.erasingFromRevision; + else if (typeof object.erasingFromRevision === "object") + message.erasingFromRevision = new $util.LongBits(object.erasingFromRevision.low >>> 0, object.erasingFromRevision.high >>> 0).toNumber(true); return message; }; @@ -55498,6 +55612,26 @@ $root.org = (function() { object.remainingRevisions = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.remainingRevisions = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.deletedAtMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.deletedAtMs = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.erasingStartedAtMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.erasingStartedAtMs = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.erasingFromTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.erasingFromTimeMs = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.erasingFromRevision = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.erasingFromRevision = options.longs === String ? "0" : 0; } if (message.state != null && message.hasOwnProperty("state")) object.state = options.enums === String ? $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State[message.state] : message.state; @@ -55506,6 +55640,26 @@ $root.org = (function() { object.remainingRevisions = options.longs === String ? String(message.remainingRevisions) : message.remainingRevisions; else object.remainingRevisions = options.longs === String ? $util.Long.prototype.toString.call(message.remainingRevisions) : options.longs === Number ? new $util.LongBits(message.remainingRevisions.low >>> 0, message.remainingRevisions.high >>> 0).toNumber(true) : message.remainingRevisions; + if (message.deletedAtMs != null && message.hasOwnProperty("deletedAtMs")) + if (typeof message.deletedAtMs === "number") + object.deletedAtMs = options.longs === String ? String(message.deletedAtMs) : message.deletedAtMs; + else + object.deletedAtMs = options.longs === String ? $util.Long.prototype.toString.call(message.deletedAtMs) : options.longs === Number ? new $util.LongBits(message.deletedAtMs.low >>> 0, message.deletedAtMs.high >>> 0).toNumber(true) : message.deletedAtMs; + if (message.erasingStartedAtMs != null && message.hasOwnProperty("erasingStartedAtMs")) + if (typeof message.erasingStartedAtMs === "number") + object.erasingStartedAtMs = options.longs === String ? String(message.erasingStartedAtMs) : message.erasingStartedAtMs; + else + object.erasingStartedAtMs = options.longs === String ? $util.Long.prototype.toString.call(message.erasingStartedAtMs) : options.longs === Number ? new $util.LongBits(message.erasingStartedAtMs.low >>> 0, message.erasingStartedAtMs.high >>> 0).toNumber(true) : message.erasingStartedAtMs; + if (message.erasingFromTimeMs != null && message.hasOwnProperty("erasingFromTimeMs")) + if (typeof message.erasingFromTimeMs === "number") + object.erasingFromTimeMs = options.longs === String ? String(message.erasingFromTimeMs) : message.erasingFromTimeMs; + else + object.erasingFromTimeMs = options.longs === String ? $util.Long.prototype.toString.call(message.erasingFromTimeMs) : options.longs === Number ? new $util.LongBits(message.erasingFromTimeMs.low >>> 0, message.erasingFromTimeMs.high >>> 0).toNumber(true) : message.erasingFromTimeMs; + if (message.erasingFromRevision != null && message.hasOwnProperty("erasingFromRevision")) + if (typeof message.erasingFromRevision === "number") + object.erasingFromRevision = options.longs === String ? String(message.erasingFromRevision) : message.erasingFromRevision; + else + object.erasingFromRevision = options.longs === String ? $util.Long.prototype.toString.call(message.erasingFromRevision) : options.longs === Number ? new $util.LongBits(message.erasingFromRevision.low >>> 0, message.erasingFromRevision.high >>> 0).toNumber(true) : message.erasingFromRevision; return object; }; @@ -55526,11 +55680,15 @@ $root.org = (function() { * @enum {number} * @property {number} ACTIVE=0 ACTIVE value * @property {number} ABSENT=1 ABSENT value + * @property {number} DELETED=2 DELETED value + * @property {number} ERASING=3 ERASING value */ Lifecycle.State = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "ACTIVE"] = 0; values[valuesById[1] = "ABSENT"] = 1; + values[valuesById[2] = "DELETED"] = 2; + values[valuesById[3] = "ERASING"] = 3; return values; })(); diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js index 4719f1306f4..afd34650e3a 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js @@ -54786,6 +54786,10 @@ $root.org = (function() { * @interface ILifecycle * @property {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State|null} [state] Lifecycle state * @property {number|Long|null} [remainingRevisions] Lifecycle remainingRevisions + * @property {number|Long|null} [deletedAtMs] Lifecycle deletedAtMs + * @property {number|Long|null} [erasingStartedAtMs] Lifecycle erasingStartedAtMs + * @property {number|Long|null} [erasingFromTimeMs] Lifecycle erasingFromTimeMs + * @property {number|Long|null} [erasingFromRevision] Lifecycle erasingFromRevision */ /** @@ -54819,6 +54823,38 @@ $root.org = (function() { */ Lifecycle.prototype.remainingRevisions = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + /** + * Lifecycle deletedAtMs. + * @member {number|Long} deletedAtMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.deletedAtMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Lifecycle erasingStartedAtMs. + * @member {number|Long} erasingStartedAtMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.erasingStartedAtMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Lifecycle erasingFromTimeMs. + * @member {number|Long} erasingFromTimeMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.erasingFromTimeMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Lifecycle erasingFromRevision. + * @member {number|Long} erasingFromRevision + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle + * @instance + */ + Lifecycle.prototype.erasingFromRevision = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + /** * Creates a new Lifecycle instance using the specified properties. * @function create @@ -54847,6 +54883,14 @@ $root.org = (function() { writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); if (message.remainingRevisions != null && Object.hasOwnProperty.call(message, "remainingRevisions")) writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.remainingRevisions); + if (message.deletedAtMs != null && Object.hasOwnProperty.call(message, "deletedAtMs")) + writer.uint32(/* id 3, wireType 0 =*/24).uint64(message.deletedAtMs); + if (message.erasingStartedAtMs != null && Object.hasOwnProperty.call(message, "erasingStartedAtMs")) + writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.erasingStartedAtMs); + if (message.erasingFromTimeMs != null && Object.hasOwnProperty.call(message, "erasingFromTimeMs")) + writer.uint32(/* id 5, wireType 0 =*/40).uint64(message.erasingFromTimeMs); + if (message.erasingFromRevision != null && Object.hasOwnProperty.call(message, "erasingFromRevision")) + writer.uint32(/* id 6, wireType 0 =*/48).uint64(message.erasingFromRevision); return writer; }; @@ -54887,6 +54931,18 @@ $root.org = (function() { case 2: message.remainingRevisions = reader.uint64(); break; + case 3: + message.deletedAtMs = reader.uint64(); + break; + case 4: + message.erasingStartedAtMs = reader.uint64(); + break; + case 5: + message.erasingFromTimeMs = reader.uint64(); + break; + case 6: + message.erasingFromRevision = reader.uint64(); + break; default: reader.skipType(tag & 7); break; @@ -54928,11 +54984,25 @@ $root.org = (function() { return "state: enum value expected"; case 0: case 1: + case 2: + case 3: break; } if (message.remainingRevisions != null && message.hasOwnProperty("remainingRevisions")) if (!$util.isInteger(message.remainingRevisions) && !(message.remainingRevisions && $util.isInteger(message.remainingRevisions.low) && $util.isInteger(message.remainingRevisions.high))) return "remainingRevisions: integer|Long expected"; + if (message.deletedAtMs != null && message.hasOwnProperty("deletedAtMs")) + if (!$util.isInteger(message.deletedAtMs) && !(message.deletedAtMs && $util.isInteger(message.deletedAtMs.low) && $util.isInteger(message.deletedAtMs.high))) + return "deletedAtMs: integer|Long expected"; + if (message.erasingStartedAtMs != null && message.hasOwnProperty("erasingStartedAtMs")) + if (!$util.isInteger(message.erasingStartedAtMs) && !(message.erasingStartedAtMs && $util.isInteger(message.erasingStartedAtMs.low) && $util.isInteger(message.erasingStartedAtMs.high))) + return "erasingStartedAtMs: integer|Long expected"; + if (message.erasingFromTimeMs != null && message.hasOwnProperty("erasingFromTimeMs")) + if (!$util.isInteger(message.erasingFromTimeMs) && !(message.erasingFromTimeMs && $util.isInteger(message.erasingFromTimeMs.low) && $util.isInteger(message.erasingFromTimeMs.high))) + return "erasingFromTimeMs: integer|Long expected"; + if (message.erasingFromRevision != null && message.hasOwnProperty("erasingFromRevision")) + if (!$util.isInteger(message.erasingFromRevision) && !(message.erasingFromRevision && $util.isInteger(message.erasingFromRevision.low) && $util.isInteger(message.erasingFromRevision.high))) + return "erasingFromRevision: integer|Long expected"; return null; }; @@ -54957,6 +55027,14 @@ $root.org = (function() { case 1: message.state = 1; break; + case "DELETED": + case 2: + message.state = 2; + break; + case "ERASING": + case 3: + message.state = 3; + break; } if (object.remainingRevisions != null) if ($util.Long) @@ -54967,6 +55045,42 @@ $root.org = (function() { message.remainingRevisions = object.remainingRevisions; else if (typeof object.remainingRevisions === "object") message.remainingRevisions = new $util.LongBits(object.remainingRevisions.low >>> 0, object.remainingRevisions.high >>> 0).toNumber(true); + if (object.deletedAtMs != null) + if ($util.Long) + (message.deletedAtMs = $util.Long.fromValue(object.deletedAtMs)).unsigned = true; + else if (typeof object.deletedAtMs === "string") + message.deletedAtMs = parseInt(object.deletedAtMs, 10); + else if (typeof object.deletedAtMs === "number") + message.deletedAtMs = object.deletedAtMs; + else if (typeof object.deletedAtMs === "object") + message.deletedAtMs = new $util.LongBits(object.deletedAtMs.low >>> 0, object.deletedAtMs.high >>> 0).toNumber(true); + if (object.erasingStartedAtMs != null) + if ($util.Long) + (message.erasingStartedAtMs = $util.Long.fromValue(object.erasingStartedAtMs)).unsigned = true; + else if (typeof object.erasingStartedAtMs === "string") + message.erasingStartedAtMs = parseInt(object.erasingStartedAtMs, 10); + else if (typeof object.erasingStartedAtMs === "number") + message.erasingStartedAtMs = object.erasingStartedAtMs; + else if (typeof object.erasingStartedAtMs === "object") + message.erasingStartedAtMs = new $util.LongBits(object.erasingStartedAtMs.low >>> 0, object.erasingStartedAtMs.high >>> 0).toNumber(true); + if (object.erasingFromTimeMs != null) + if ($util.Long) + (message.erasingFromTimeMs = $util.Long.fromValue(object.erasingFromTimeMs)).unsigned = true; + else if (typeof object.erasingFromTimeMs === "string") + message.erasingFromTimeMs = parseInt(object.erasingFromTimeMs, 10); + else if (typeof object.erasingFromTimeMs === "number") + message.erasingFromTimeMs = object.erasingFromTimeMs; + else if (typeof object.erasingFromTimeMs === "object") + message.erasingFromTimeMs = new $util.LongBits(object.erasingFromTimeMs.low >>> 0, object.erasingFromTimeMs.high >>> 0).toNumber(true); + if (object.erasingFromRevision != null) + if ($util.Long) + (message.erasingFromRevision = $util.Long.fromValue(object.erasingFromRevision)).unsigned = true; + else if (typeof object.erasingFromRevision === "string") + message.erasingFromRevision = parseInt(object.erasingFromRevision, 10); + else if (typeof object.erasingFromRevision === "number") + message.erasingFromRevision = object.erasingFromRevision; + else if (typeof object.erasingFromRevision === "object") + message.erasingFromRevision = new $util.LongBits(object.erasingFromRevision.low >>> 0, object.erasingFromRevision.high >>> 0).toNumber(true); return message; }; @@ -54990,6 +55104,26 @@ $root.org = (function() { object.remainingRevisions = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.remainingRevisions = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.deletedAtMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.deletedAtMs = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.erasingStartedAtMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.erasingStartedAtMs = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.erasingFromTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.erasingFromTimeMs = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.erasingFromRevision = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.erasingFromRevision = options.longs === String ? "0" : 0; } if (message.state != null && message.hasOwnProperty("state")) object.state = options.enums === String ? $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State[message.state] : message.state; @@ -54998,6 +55132,26 @@ $root.org = (function() { object.remainingRevisions = options.longs === String ? String(message.remainingRevisions) : message.remainingRevisions; else object.remainingRevisions = options.longs === String ? $util.Long.prototype.toString.call(message.remainingRevisions) : options.longs === Number ? new $util.LongBits(message.remainingRevisions.low >>> 0, message.remainingRevisions.high >>> 0).toNumber(true) : message.remainingRevisions; + if (message.deletedAtMs != null && message.hasOwnProperty("deletedAtMs")) + if (typeof message.deletedAtMs === "number") + object.deletedAtMs = options.longs === String ? String(message.deletedAtMs) : message.deletedAtMs; + else + object.deletedAtMs = options.longs === String ? $util.Long.prototype.toString.call(message.deletedAtMs) : options.longs === Number ? new $util.LongBits(message.deletedAtMs.low >>> 0, message.deletedAtMs.high >>> 0).toNumber(true) : message.deletedAtMs; + if (message.erasingStartedAtMs != null && message.hasOwnProperty("erasingStartedAtMs")) + if (typeof message.erasingStartedAtMs === "number") + object.erasingStartedAtMs = options.longs === String ? String(message.erasingStartedAtMs) : message.erasingStartedAtMs; + else + object.erasingStartedAtMs = options.longs === String ? $util.Long.prototype.toString.call(message.erasingStartedAtMs) : options.longs === Number ? new $util.LongBits(message.erasingStartedAtMs.low >>> 0, message.erasingStartedAtMs.high >>> 0).toNumber(true) : message.erasingStartedAtMs; + if (message.erasingFromTimeMs != null && message.hasOwnProperty("erasingFromTimeMs")) + if (typeof message.erasingFromTimeMs === "number") + object.erasingFromTimeMs = options.longs === String ? String(message.erasingFromTimeMs) : message.erasingFromTimeMs; + else + object.erasingFromTimeMs = options.longs === String ? $util.Long.prototype.toString.call(message.erasingFromTimeMs) : options.longs === Number ? new $util.LongBits(message.erasingFromTimeMs.low >>> 0, message.erasingFromTimeMs.high >>> 0).toNumber(true) : message.erasingFromTimeMs; + if (message.erasingFromRevision != null && message.hasOwnProperty("erasingFromRevision")) + if (typeof message.erasingFromRevision === "number") + object.erasingFromRevision = options.longs === String ? String(message.erasingFromRevision) : message.erasingFromRevision; + else + object.erasingFromRevision = options.longs === String ? $util.Long.prototype.toString.call(message.erasingFromRevision) : options.longs === Number ? new $util.LongBits(message.erasingFromRevision.low >>> 0, message.erasingFromRevision.high >>> 0).toNumber(true) : message.erasingFromRevision; return object; }; @@ -55018,11 +55172,15 @@ $root.org = (function() { * @enum {number} * @property {number} ACTIVE=0 ACTIVE value * @property {number} ABSENT=1 ABSENT value + * @property {number} DELETED=2 DELETED value + * @property {number} ERASING=3 ERASING value */ Lifecycle.State = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "ACTIVE"] = 0; values[valuesById[1] = "ABSENT"] = 1; + values[valuesById[2] = "DELETED"] = 2; + values[valuesById[3] = "ERASING"] = 3; return values; })(); diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js index b73ac6da250..127fef88698 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js @@ -60126,7 +60126,11 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.toObject = function(includeInstance, msg) { var f, obj = { state: jspb.Message.getFieldWithDefault(msg, 1, 0), - remainingRevisions: jspb.Message.getFieldWithDefault(msg, 2, "0") + remainingRevisions: jspb.Message.getFieldWithDefault(msg, 2, "0"), + deletedAtMs: jspb.Message.getFieldWithDefault(msg, 3, "0"), + erasingStartedAtMs: jspb.Message.getFieldWithDefault(msg, 4, "0"), + erasingFromTimeMs: jspb.Message.getFieldWithDefault(msg, 5, "0"), + erasingFromRevision: jspb.Message.getFieldWithDefault(msg, 6, "0") }; if (includeInstance) { @@ -60171,6 +60175,22 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes var value = /** @type {string} */ (reader.readUint64String()); msg.setRemainingRevisions(value); break; + case 3: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setDeletedAtMs(value); + break; + case 4: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setErasingStartedAtMs(value); + break; + case 5: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setErasingFromTimeMs(value); + break; + case 6: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setErasingFromRevision(value); + break; default: reader.skipField(); break; @@ -60214,6 +60234,34 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes f ); } + f = message.getDeletedAtMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 3, + f + ); + } + f = message.getErasingStartedAtMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 4, + f + ); + } + f = message.getErasingFromTimeMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 5, + f + ); + } + f = message.getErasingFromRevision(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 6, + f + ); + } }; @@ -60222,7 +60270,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes */ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State = { ACTIVE: 0, - ABSENT: 1 + ABSENT: 1, + DELETED: 2, + ERASING: 3 }; /** @@ -60261,6 +60311,78 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes }; +/** + * optional uint64 deleted_at_ms = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getDeletedAtMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setDeletedAtMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 3, value); +}; + + +/** + * optional uint64 erasing_started_at_ms = 4; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getErasingStartedAtMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setErasingStartedAtMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 4, value); +}; + + +/** + * optional uint64 erasing_from_time_ms = 5; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getErasingFromTimeMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setErasingFromTimeMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 5, value); +}; + + +/** + * optional uint64 erasing_from_revision = 6; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getErasingFromRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setErasingFromRevision = function(value) { + return jspb.Message.setProto3StringIntField(this, 6, value); +}; + + /** * List of repeated fields within this message type. diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h index 6f9904238e9..a5f36c360c8 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h @@ -789,6 +789,8 @@ typedef GPB_ENUM(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecyc GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Active = 0, GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Absent = 1, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Deleted = 2, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Erasing = 3, }; GPBEnumDescriptor *GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_EnumDescriptor(void); @@ -7481,11 +7483,15 @@ GPB_FINAL @interface GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Ent typedef GPB_ENUM(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber) { GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_State = 1, GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_RemainingRevisions = 2, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_DeletedAtMs = 3, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_ErasingStartedAtMs = 4, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_ErasingFromTimeMs = 5, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_ErasingFromRevision = 6, }; /** - * Where the historical document stands: still current, or gone with - * nothing retained. Later protocol versions add the states between. + * Whether the document is current, deleted with retained revisions, + * undergoing erasure, or absent with nothing retained. **/ GPB_FINAL @interface GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle : GPBMessage @@ -7494,6 +7500,21 @@ GPB_FINAL @interface GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lif /** Revisions the history still retains for the document. */ @property(nonatomic, readwrite) uint64_t remainingRevisions; +/** Zero unless the document has been deleted. */ +@property(nonatomic, readwrite) uint64_t deletedAtMs; + +/** Zero unless an authorized erasure has started. */ +@property(nonatomic, readwrite) uint64_t erasingStartedAtMs; + +/** Timestamp of the newest revision retained when the erasure started. */ +@property(nonatomic, readwrite) uint64_t erasingFromTimeMs; + +/** + * History sequence of the newest revision retained when the erasure + * started. + **/ +@property(nonatomic, readwrite) uint64_t erasingFromRevision; + @end /** diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m index 2a3d605b2ae..5811fa878c3 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m @@ -15045,11 +15045,19 @@ @implementation GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycl @dynamic state; @dynamic remainingRevisions; +@dynamic deletedAtMs; +@dynamic erasingStartedAtMs; +@dynamic erasingFromTimeMs; +@dynamic erasingFromRevision; typedef struct GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle__storage_ { uint32_t _has_storage_[1]; GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State state; uint64_t remainingRevisions; + uint64_t deletedAtMs; + uint64_t erasingStartedAtMs; + uint64_t erasingFromTimeMs; + uint64_t erasingFromRevision; } GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle__storage_; // This method is threadsafe because it is initially called @@ -15076,6 +15084,42 @@ + (GPBDescriptor *)descriptor { .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), .dataType = GPBDataTypeUInt64, }, + { + .name = "deletedAtMs", + .dataTypeSpecific.clazz = Nil, + .number = GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_DeletedAtMs, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle__storage_, deletedAtMs), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt64, + }, + { + .name = "erasingStartedAtMs", + .dataTypeSpecific.clazz = Nil, + .number = GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_ErasingStartedAtMs, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle__storage_, erasingStartedAtMs), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt64, + }, + { + .name = "erasingFromTimeMs", + .dataTypeSpecific.clazz = Nil, + .number = GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_ErasingFromTimeMs, + .hasIndex = 4, + .offset = (uint32_t)offsetof(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle__storage_, erasingFromTimeMs), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt64, + }, + { + .name = "erasingFromRevision", + .dataTypeSpecific.clazz = Nil, + .number = GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_FieldNumber_ErasingFromRevision, + .hasIndex = 5, + .offset = (uint32_t)offsetof(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle__storage_, erasingFromRevision), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt64, + }, }; GPBDescriptor *localDescriptor = [GPBDescriptor allocDescriptorForClass:[GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle class] @@ -15114,10 +15158,12 @@ void SetGetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_ static _Atomic(GPBEnumDescriptor*) descriptor = nil; if (!descriptor) { static const char *valueNames = - "Active\000Absent\000"; + "Active\000Absent\000Deleted\000Erasing\000"; static const int32_t values[] = { GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Active, GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Absent, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Deleted, + GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Erasing, }; GPBEnumDescriptor *worker = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State) @@ -15137,6 +15183,8 @@ BOOL GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_IsV switch (value__) { case GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Active: case GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Absent: + case GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Deleted: + case GetDocumentHistoryResponse_GetDocumentHistoryResponseV1_Lifecycle_State_Erasing: return YES; default: return NO; diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py index ddcf3317116..f9c7f659718 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py @@ -23,7 +23,7 @@ syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x98\x01\n\x10ResponseMetadata\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x13\n\x07time_ms\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc1\x01\n\x17GetIdentityNonceRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityNonceRequest.GetIdentityNonceRequestV0H\x00\x1a?\n\x19GetIdentityNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf6\x01\n\x1fGetIdentityContractNonceRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest.GetIdentityContractNonceRequestV0H\x00\x1a\\\n!GetIdentityContractNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xbc\x02\n\x18GetIdentityNonceResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetIdentityNonceResponse.GetIdentityNonceResponseV0H\x00\x1a\xb6\x01\n\x1aGetIdentityNonceResponseV0\x12\x1c\n\x0eidentity_nonce\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe5\x02\n GetIdentityContractNonceResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse.GetIdentityContractNonceResponseV0H\x00\x1a\xc7\x01\n\"GetIdentityContractNonceResponseV0\x12%\n\x17identity_contract_nonce\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x8e\x02\n&GetIdentityKeysRemainingBudgetsRequest\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsRequest.GetIdentityKeysRemainingBudgetsRequestV0H\x00\x1a_\n(GetIdentityKeysRemainingBudgetsRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x0f\n\x07key_ids\x18\x02 \x03(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\x96\x06\n\'GetIdentityKeysRemainingBudgetsResponse\x12z\n\x02v0\x18\x01 \x01(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse.GetIdentityKeysRemainingBudgetsResponseV0H\x00\x1a\xe3\x04\n)GetIdentityKeysRemainingBudgetsResponseV0\x12\xa4\x01\n\x16keys_remaining_budgets\x18\x01 \x01(\x0b\x32\x81\x01.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse.GetIdentityKeysRemainingBudgetsResponseV0.KeysRemainingBudgetsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x61\n\x17KeyRemainingBudgetEntry\x12\x0e\n\x06key_id\x18\x01 \x01(\r\x12!\n\x10remaining_budget\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x42\x13\n\x11_remaining_budget\x1a\xaf\x01\n\x14KeysRemainingBudgets\x12\x96\x01\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse.GetIdentityKeysRemainingBudgetsResponseV0.KeyRemainingBudgetEntryB\x08\n\x06resultB\t\n\x07version\"\xbd\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xb1\x01\n\x1cGetIdentityBalanceResponseV0\x12\x15\n\x07\x62\x61lance\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb1\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\x84\x03\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a?\n\x12\x42\x61lanceAndRevision\x12\x13\n\x07\x62\x61lance\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x14\n\x08revision\x18\x02 \x01(\x04\x42\x02\x30\x01\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xef\x02\n GetIdentitiesContractKeysRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest.GetIdentitiesContractKeysRequestV0H\x00\x1a\xd1\x01\n\"GetIdentitiesContractKeysRequestV0\x12\x16\n\x0eidentities_ids\x18\x01 \x03(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\x1f\n\x12\x64ocument_type_name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x37\n\x08purposes\x18\x04 \x03(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x15\n\x13_document_type_nameB\t\n\x07version\"\xdf\x06\n!GetIdentitiesContractKeysResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0H\x00\x1a\xbe\x05\n#GetIdentitiesContractKeysResponseV0\x12\x8a\x01\n\x0fidentities_keys\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentitiesKeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aY\n\x0bPurposeKeys\x12\x36\n\x07purpose\x18\x01 \x01(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\x12\n\nkeys_bytes\x18\x02 \x03(\x0c\x1a\x9f\x01\n\x0cIdentityKeys\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12z\n\x04keys\x18\x02 \x03(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.PurposeKeys\x1a\x90\x01\n\x0eIdentitiesKeys\x12~\n\x07\x65ntries\x18\x01 \x03(\x0b\x32m.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentityKeysB\x08\n\x06resultB\t\n\x07version\"\xa4\x02\n*GetEvonodesProposedEpochBlocksByIdsRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByIdsRequest.GetEvonodesProposedEpochBlocksByIdsRequestV0H\x00\x1ah\n,GetEvonodesProposedEpochBlocksByIdsRequestV0\x12\x12\n\x05\x65poch\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x0b\n\x03ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\x08\n\x06_epochB\t\n\x07version\"\x92\x06\n&GetEvonodesProposedEpochBlocksResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse.GetEvonodesProposedEpochBlocksResponseV0H\x00\x1a\xe2\x04\n(GetEvonodesProposedEpochBlocksResponseV0\x12\xb1\x01\n#evonodes_proposed_block_counts_info\x18\x01 \x01(\x0b\x32\x81\x01.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse.GetEvonodesProposedEpochBlocksResponseV0.EvonodesProposedBlocksH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a?\n\x15\x45vonodeProposedBlocks\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x11\n\x05\x63ount\x18\x02 \x01(\x04\x42\x02\x30\x01\x1a\xc4\x01\n\x16\x45vonodesProposedBlocks\x12\xa9\x01\n\x1e\x65vonodes_proposed_block_counts\x18\x01 \x03(\x0b\x32\x80\x01.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse.GetEvonodesProposedEpochBlocksResponseV0.EvonodeProposedBlocksB\x08\n\x06resultB\t\n\x07version\"\xf2\x02\n,GetEvonodesProposedEpochBlocksByRangeRequest\x12\x84\x01\n\x02v0\x18\x01 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByRangeRequest.GetEvonodesProposedEpochBlocksByRangeRequestV0H\x00\x1a\xaf\x01\n.GetEvonodesProposedEpochBlocksByRangeRequestV0\x12\x12\n\x05\x65poch\x18\x01 \x01(\rH\x01\x88\x01\x01\x12\x12\n\x05limit\x18\x02 \x01(\rH\x02\x88\x01\x01\x12\x15\n\x0bstart_after\x18\x03 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x04 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x07\n\x05startB\x08\n\x06_epochB\x08\n\x06_limitB\t\n\x07version\"\xcd\x01\n\x1cGetIdentitiesBalancesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetIdentitiesBalancesRequest.GetIdentitiesBalancesRequestV0H\x00\x1a<\n\x1eGetIdentitiesBalancesRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9f\x05\n\x1dGetIdentitiesBalancesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse.GetIdentitiesBalancesResponseV0H\x00\x1a\x8a\x04\n\x1fGetIdentitiesBalancesResponseV0\x12\x8a\x01\n\x13identities_balances\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse.GetIdentitiesBalancesResponseV0.IdentitiesBalancesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aL\n\x0fIdentityBalance\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x18\n\x07\x62\x61lance\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x42\n\n\x08_balance\x1a\x8f\x01\n\x12IdentitiesBalances\x12y\n\x07\x65ntries\x18\x01 \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse.GetIdentitiesBalancesResponseV0.IdentityBalanceB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x8c\x02\n%GetDataContractsLatestVersionsRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsRequest.GetDataContractsLatestVersionsRequestV0H\x00\x1a`\n\'GetDataContractsLatestVersionsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\x19\n\x11include_contracts\x18\x02 \x01(\x08\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xfa\x05\n&GetDataContractsLatestVersionsResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse.GetDataContractsLatestVersionsResponseV0H\x00\x1a\x84\x01\n\x1e\x44\x61taContractLatestVersionEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x14\n\x07version\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1a\n\rdata_contract\x18\x03 \x01(\x0cH\x01\x88\x01\x01\x42\n\n\x08_versionB\x10\n\x0e_data_contract\x1a\x90\x01\n\x1b\x44\x61taContractsLatestVersions\x12q\n\x07\x65ntries\x18\x01 \x03(\x0b\x32`.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse.DataContractLatestVersionEntry\x1a\xb0\x02\n(GetDataContractsLatestVersionsResponseV0\x12\x87\x01\n\x1e\x64\x61ta_contracts_latest_versions\x18\x01 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse.DataContractsLatestVersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"R\n\x1f\x43ontractGroupDocumentTypeMember\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\"G\n\x18\x43ontractGroupTokenMember\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x16\n\x0etoken_position\x18\x02 \x01(\r\"\xd7\x01\n\x1bGetContractGroupInfoRequest\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetContractGroupInfoRequest.GetContractGroupInfoRequestV0H\x00\x1aI\n\x1dGetContractGroupInfoRequestV0\x12\x19\n\x11\x63ontract_group_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x98\x04\n\x1cGetContractGroupInfoResponse\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContractGroupInfoResponse.GetContractGroupInfoResponseV0H\x00\x1a~\n\x11\x43ontractGroupInfo\x12\x10\n\x08owner_id\x18\x01 \x01(\x0c\x12\x11\n\tadmin_ids\x18\x02 \x03(\x0c\x12\x11\n\x04name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x18\n\x0b\x64\x65scription\x18\x04 \x01(\tH\x01\x88\x01\x01\x42\x07\n\x05_nameB\x0e\n\x0c_description\x1a\x86\x02\n\x1eGetContractGroupInfoResponseV0\x12h\n\x13\x63ontract_group_info\x18\x01 \x01(\x0b\x32I.org.dash.platform.dapi.v0.GetContractGroupInfoResponse.ContractGroupInfoH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf8\x06\n\x1eGetContractGroupMembersRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.GetContractGroupMembersRequestV0H\x00\x1a@\n\x14\x43ontractMembersQuery\x12\x18\n\x0bstart_after\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x42\x0e\n\x0c_start_after\x1a\x80\x01\n\x18\x44ocumentTypeMembersQuery\x12T\n\x0bstart_after\x18\x01 \x01(\x0b\x32:.org.dash.platform.dapi.v0.ContractGroupDocumentTypeMemberH\x00\x88\x01\x01\x42\x0e\n\x0c_start_after\x1ar\n\x11TokenMembersQuery\x12M\n\x0bstart_after\x18\x01 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractGroupTokenMemberH\x00\x88\x01\x01\x42\x0e\n\x0c_start_after\x1a\xa7\x03\n GetContractGroupMembersRequestV0\x12\x19\n\x11\x63ontract_group_id\x18\x01 \x01(\x0c\x12\x63\n\tcontracts\x18\x02 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.ContractMembersQueryH\x00\x12l\n\x0e\x64ocument_types\x18\x03 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.DocumentTypeMembersQueryH\x00\x12]\n\x06tokens\x18\x04 \x01(\x0b\x32K.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.TokenMembersQueryH\x00\x12\x12\n\x05limit\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x42\t\n\x07membersB\x08\n\x06_limitB\t\n\x07version\"\xc9\x06\n\x1fGetContractGroupMembersResponse\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.GetContractGroupMembersResponseV0H\x00\x1a\'\n\x0f\x43ontractMembers\x12\x14\n\x0c\x63ontract_ids\x18\x01 \x03(\x0c\x1ai\n\x13\x44ocumentTypeMembers\x12R\n\x0e\x64ocument_types\x18\x01 \x03(\x0b\x32:.org.dash.platform.dapi.v0.ContractGroupDocumentTypeMember\x1aS\n\x0cTokenMembers\x12\x43\n\x06tokens\x18\x01 \x03(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractGroupTokenMember\x1a\xc5\x03\n!GetContractGroupMembersResponseV0\x12_\n\tcontracts\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.ContractMembersH\x00\x12h\n\x0e\x64ocument_types\x18\x02 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.DocumentTypeMembersH\x00\x12Y\n\x06tokens\x18\x03 \x01(\x0b\x32G.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.TokenMembersH\x00\x12\x31\n\x05proof\x18\x04 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x05 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"M\n\x1a\x43ontractModerationDocument\x12\x1a\n\x12\x64ocument_type_name\x18\x01 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x02 \x01(\x0c\"\xc6\x01\n\x18\x43ontractModerationReason\x12\x11\n\x04\x63ode\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x0c\n\x04text\x18\x02 \x01(\t\x12H\n\tdocuments\x18\x03 \x03(\x0b\x32\x35.org.dash.platform.dapi.v0.ContractModerationDocument\x12\x1f\n\x12reason_document_id\x18\x04 \x01(\x0cH\x01\x88\x01\x01\x42\x07\n\x05_codeB\x15\n\x13_reason_document_id\"i\n\x0f\x43ontractWarning\x12\x11\n\twarned_at\x18\x01 \x01(\x04\x12\x43\n\x06reason\x18\x02 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReason\"\xc5\x02\n\"GetContractModerationStatusRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetContractModerationStatusRequest.GetContractModerationStatusRequestV0H\x00\x1a\xa1\x01\n$GetContractModerationStatusRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x13\n\x0bidentity_id\x18\x02 \x01(\x0c\x12@\n\x05lists\x18\x03 \x03(\x0e\x32\x31.org.dash.platform.dapi.v0.ContractModerationList\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\xec\x06\n#GetContractModerationStatusResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractModerationStatusResponse.GetContractModerationStatusResponseV0H\x00\x1a\xb4\x03\n\x18\x43ontractModerationStatus\x12\x13\n\x06\x62\x61nned\x18\x01 \x01(\x08H\x00\x88\x01\x01\x12\x1c\n\x0fsuspended_until\x18\x02 \x01(\x04H\x01\x88\x01\x01\x12@\n\x05lists\x18\x03 \x03(\x0e\x32\x31.org.dash.platform.dapi.v0.ContractModerationList\x12L\n\nban_reason\x18\x04 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReasonH\x02\x88\x01\x01\x12S\n\x11suspension_reason\x18\x05 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReasonH\x03\x88\x01\x01\x12<\n\x08warnings\x18\x06 \x03(\x0b\x32*.org.dash.platform.dapi.v0.ContractWarningB\t\n\x07_bannedB\x12\n\x10_suspended_untilB\r\n\x0b_ban_reasonB\x14\n\x12_suspension_reason\x1a\x8e\x02\n%GetContractModerationStatusResponseV0\x12i\n\x06status\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetContractModerationStatusResponse.ContractModerationStatusH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x02\n#GetContractModerationEntriesRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractModerationEntriesRequest.GetContractModerationEntriesRequestV0H\x00\x1a\xd4\x01\n%GetContractModerationEntriesRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12?\n\x04list\x18\x02 \x01(\x0e\x32\x31.org.dash.platform.dapi.v0.ContractModerationList\x12\x18\n\x0bstart_after\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x04 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x0e\n\x0c_start_afterB\x08\n\x06_limitB\t\n\x07version\"\x96\x06\n$GetContractModerationEntriesResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse.GetContractModerationEntriesResponseV0H\x00\x1a\xcf\x01\n\x17\x43ontractModerationEntry\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x12\n\x05until\x18\x02 \x01(\x04H\x00\x88\x01\x01\x12\x43\n\x06reason\x18\x03 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReason\x12<\n\x08warnings\x18\x04 \x03(\x0b\x32*.org.dash.platform.dapi.v0.ContractWarningB\x08\n\x06_until\x1a\x85\x01\n\x19\x43ontractModerationEntries\x12h\n\x07\x65ntries\x18\x01 \x03(\x0b\x32W.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse.ContractModerationEntry\x1a\x92\x02\n&GetContractModerationEntriesResponseV0\x12l\n\x07\x65ntries\x18\x01 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse.ContractModerationEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc3\x04\n\"GetContractDocumentRemovalsRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest.GetContractDocumentRemovalsRequestV0H\x00\x1a#\n\x0b\x44ocumentIds\x12\x14\n\x0c\x64ocument_ids\x18\x01 \x03(\x0c\x1aN\n\x04Page\x12\x18\n\x0bstart_after\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x02 \x01(\rH\x01\x88\x01\x01\x42\x0e\n\x0c_start_afterB\x08\n\x06_limit\x1a\xaa\x02\n$GetContractDocumentRemovalsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x61\n\x0c\x64ocument_ids\x18\x03 \x01(\x0b\x32I.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest.DocumentIdsH\x00\x12R\n\x04page\x18\x04 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest.PageH\x00\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x0b\n\tselectionB\t\n\x07version\"\xe0\x07\n#GetContractDocumentRemovalsResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.GetContractDocumentRemovalsResponseV0H\x00\x1aH\n\x1b\x43ontractDocumentRestoration\x12\x14\n\x0cmoderator_id\x18\x01 \x01(\x0c\x12\x13\n\x0brestored_at\x18\x02 \x01(\x04\x1a\xd5\x02\n\x17\x43ontractDocumentRemoval\x12\x13\n\x0b\x64ocument_id\x18\x01 \x01(\x0c\x12\x19\n\x11\x64ocument_owner_id\x18\x02 \x01(\x0c\x12\x14\n\x0cmoderator_id\x18\x03 \x01(\x0c\x12\x12\n\nremoved_at\x18\x04 \x01(\x04\x12\x43\n\x06reason\x18\x05 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReason\x12\x15\n\rdocument_hash\x18\x06 \x01(\x0c\x12o\n\x0brestoration\x18\x07 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRestoration\x12\x13\n\x0bkept_fields\x18\x08 \x01(\x0c\x1a\x84\x01\n\x18\x43ontractDocumentRemovals\x12h\n\x08removals\x18\x01 \x03(\x0b\x32V.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemoval\x1a\x90\x02\n%GetContractDocumentRemovalsResponseV0\x12k\n\x08removals\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemovalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc7\x04\n\x1dGetContractTeamActionsRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContractTeamActionsRequest.GetContractTeamActionsRequestV0H\x00\x1aL\n\x0fStartAtActionId\x12\x17\n\x0fstart_action_id\x18\x01 \x01(\x0c\x12 \n\x18start_action_id_included\x18\x02 \x01(\x08\x1a\xbc\x02\n\x1fGetContractTeamActionsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12U\n\x06status\x18\x02 \x01(\x0e\x32\x45.org.dash.platform.dapi.v0.GetContractTeamActionsRequest.ActionStatus\x12i\n\x12start_at_action_id\x18\x03 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetContractTeamActionsRequest.StartAtActionIdH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x04 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x15\n\x13_start_at_action_idB\x08\n\x06_count\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\xe0\x07\n\x1eGetContractTeamActionsResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.GetContractTeamActionsResponseV0H\x00\x1a\xe6\x01\n\x15\x44\x65leteSettledDocument\x12\x1a\n\x12\x64ocument_type_name\x18\x01 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x02 \x01(\x0c\x12!\n\x19\x64ocument_last_modified_at\x18\x03 \x01(\x04\x12\x1e\n\x11\x64ocument_revision\x18\x04 \x01(\x04H\x00\x88\x01\x01\x12\x43\n\x06reason\x18\x05 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReasonB\x14\n\x12_document_revision\x1a\xe6\x01\n\x12\x43ontractTeamAction\x12\x11\n\taction_id\x18\x01 \x01(\x0c\x12\x13\n\x0bproposer_id\x18\x02 \x01(\x0c\x12\x13\n\x0bproposed_at\x18\x03 \x01(\x04\x12r\n\x17\x64\x65lete_settled_document\x18\x04 \x01(\x0b\x32O.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.DeleteSettledDocumentH\x00\x12\x16\n\x0e\x61pproval_count\x18\x05 \x01(\rB\x07\n\x05\x65vent\x1at\n\x13\x43ontractTeamActions\x12]\n\x07\x61\x63tions\x18\x01 \x03(\x0b\x32L.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.ContractTeamAction\x1a\x80\x02\n GetContractTeamActionsResponseV0\x12`\n\x07\x61\x63tions\x18\x01 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.ContractTeamActionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x8a\x03\n#GetContractTeamActionSignersRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractTeamActionSignersRequest.GetContractTeamActionSignersRequestV0H\x00\x1a\xbb\x01\n%GetContractTeamActionSignersRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12[\n\x06status\x18\x02 \x01(\x0e\x32K.org.dash.platform.dapi.v0.GetContractTeamActionSignersRequest.ActionStatus\x12\x11\n\taction_id\x18\x03 \x01(\x0c\x12\r\n\x05prove\x18\x04 \x01(\x08\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\xed\x03\n$GetContractTeamActionSignersResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContractTeamActionSignersResponse.GetContractTeamActionSignersResponseV0H\x00\x1a/\n\x19\x43ontractTeamActionSigners\x12\x12\n\nsigner_ids\x18\x01 \x03(\x0c\x1a\x92\x02\n&GetContractTeamActionSignersResponseV0\x12l\n\x07signers\x18\x01 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetContractTeamActionSignersResponse.ContractTeamActionSignersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x85\x02\n(GetContractModerationActionCountsRequest\x12|\n\x02v0\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetContractModerationActionCountsRequest.GetContractModerationActionCountsRequestV0H\x00\x1aP\n*GetContractModerationActionCountsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n)GetContractModerationActionCountsResponse\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse.GetContractModerationActionCountsResponseV0H\x00\x1a\x43\n\x1d\x43ontractModerationActionCount\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x1a\x94\x01\n\x1e\x43ontractModerationActionCounts\x12r\n\x06\x63ounts\x18\x01 \x03(\x0b\x32\x62.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse.ContractModerationActionCount\x1a\xa0\x02\n+GetContractModerationActionCountsResponseV0\x12u\n\x06\x63ounts\x18\x01 \x01(\x0b\x32\x63.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse.ContractModerationActionCountsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc9\x01\n\x19GetContractFeePotsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetContractFeePotsRequest.GetContractFeePotsRequestV0H\x00\x1a\x41\n\x1bGetContractFeePotsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9f\x06\n\x1aGetContractFeePotsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetContractFeePotsResponse.GetContractFeePotsResponseV0H\x00\x1aR\n\x17\x43ontractFeePotLastClaim\x12\r\n\x05\x65poch\x18\x01 \x01(\r\x12\x13\n\x07time_ms\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x13\n\x0b\x63laimant_id\x18\x03 \x01(\x0c\x1a\x88\x01\n\x0e\x43ontractFeePot\x12\x13\n\x07\x63redits\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x61\n\nlast_claim\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePotLastClaim\x1a\xc0\x01\n\x0f\x43ontractFeePots\x12S\n\x05owner\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePot\x12X\n\nmoderators\x18\x02 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePot\x1a\xf1\x01\n\x1cGetContractFeePotsResponseV0\x12U\n\x04pots\x18\x01 \x01(\x0b\x32\x45.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePotsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf1\x01\n#GetContractGroupsForContractRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractGroupsForContractRequest.GetContractGroupsForContractRequestV0H\x00\x1aK\n%GetContractGroupsForContractRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf5\x06\n$GetContractGroupsForContractResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.GetContractGroupsForContractResponseV0H\x00\x1aQ\n\x17\x44ocumentTypeMemberships\x12\x1a\n\x12\x64ocument_type_name\x18\x01 \x01(\t\x12\x1a\n\x12\x63ontract_group_ids\x18\x02 \x03(\x0c\x1a\x46\n\x10TokenMemberships\x12\x16\n\x0etoken_position\x18\x01 \x01(\r\x12\x1a\n\x12\x63ontract_group_ids\x18\x02 \x03(\x0c\x1a\x89\x02\n\x18\x43ontractGroupMemberships\x12\x1a\n\x12\x63ontract_group_ids\x18\x01 \x03(\x0c\x12o\n\x0e\x64ocument_types\x18\x02 \x03(\x0b\x32W.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.DocumentTypeMemberships\x12`\n\x06tokens\x18\x03 \x03(\x0b\x32P.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.TokenMemberships\x1a\xa4\x02\n&GetContractGroupsForContractResponseV0\x12~\n\x1a\x63ontract_group_memberships\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.ContractGroupMembershipsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xad\x02\n\x1eGetDataContractsByRangeRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractsByRangeRequest.GetDataContractsByRangeRequestV0H\x00\x1a\x95\x01\n GetDataContractsByRangeRequestV0\x12\x12\n\x05limit\x18\x01 \x01(\rH\x01\x88\x01\x01\x12\x15\n\x0bstart_after\x18\x02 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x03 \x01(\x0cH\x00\x12\x10\n\x08ids_only\x18\x04 \x01(\x08\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x07\n\x05startB\x08\n\x06_limitB\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc5\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xb0\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0bstart_at_ms\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xb2\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x9a\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a;\n\x18\x44\x61taContractHistoryEntry\x12\x10\n\x04\x64\x61te\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xf8\"\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x12R\n\x02v1\x18\x02 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1H\x00\x1a\xfe\x02\n\x12\x44ocumentFieldValue\x12\x14\n\nbool_value\x18\x01 \x01(\x08H\x00\x12\x19\n\x0bint64_value\x18\x02 \x01(\x12\x42\x02\x30\x01H\x00\x12\x1a\n\x0cuint64_value\x18\x03 \x01(\x04\x42\x02\x30\x01H\x00\x12\x16\n\x0c\x64ouble_value\x18\x04 \x01(\x01H\x00\x12\x0e\n\x04text\x18\x05 \x01(\tH\x00\x12\x15\n\x0b\x62ytes_value\x18\x06 \x01(\x0cH\x00\x12[\n\x04list\x18\x07 \x01(\x0b\x32K.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue.ValueListH\x00\x12\x14\n\nnull_value\x18\x08 \x01(\x08H\x00\x1a^\n\tValueList\x12Q\n\x06values\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValueB\t\n\x07variant\x1a\xe2\x02\n\x12TimeRangeSelection\x12\\\n\x08selector\x18\x01 \x01(\x0e\x32J.org.dash.platform.dapi.v0.GetDocumentsRequest.TimeRangeSelection.Selector\x12\x19\n\x08start_ms\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x12T\n\x04grid\x18\x03 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsRequest.TimeRangeSelection.Grid\x1a>\n\x04Grid\x12\x11\n\x05range\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x04step\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x11\n\x05phase\x18\x03 \x01(\x04\x42\x02\x30\x01\"0\n\x08Selector\x12\n\n\x06NEWEST\x10\x00\x12\n\n\x06OLDEST\x10\x01\x12\x0c\n\x08\x42Y_START\x10\x02\x42\x0b\n\t_start_ms\x1a\x82\x02\n\x15IntegerRangeSelection\x12P\n\x05start\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue\x12W\n\x04grid\x18\x02 \x01(\x0b\x32I.org.dash.platform.dapi.v0.GetDocumentsRequest.IntegerRangeSelection.Grid\x1a>\n\x04Grid\x12\x11\n\x05range\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x04step\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x11\n\x05phase\x18\x03 \x01(\x04\x42\x02\x30\x01\x1a\xf2\x02\n\x0bWhereClause\x12\r\n\x05\x66ield\x18\x01 \x01(\t\x12N\n\x08operator\x18\x02 \x01(\x0e\x32<.org.dash.platform.dapi.v0.GetDocumentsRequest.WhereOperator\x12P\n\x05value\x18\x03 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue\x12U\n\ntime_range\x18\x04 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.TimeRangeSelection\x12[\n\rinteger_range\x18\x05 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.IntegerRangeSelection\x1a\xa4\x01\n\x0fHavingAggregate\x12Y\n\x08\x66unction\x18\x01 \x01(\x0e\x32G.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingAggregate.Function\x12\r\n\x05\x66ield\x18\x02 \x01(\t\"\'\n\x08\x46unction\x12\t\n\x05\x43OUNT\x10\x00\x12\x07\n\x03SUM\x10\x01\x12\x07\n\x03\x41VG\x10\x02\x1a\xf9\x03\n\x0cHavingClause\x12Q\n\taggregate\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingAggregate\x12V\n\x08operator\x18\x02 \x01(\x0e\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingClause.Operator\x12R\n\x05value\x18\x03 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValueH\x00\"\xe0\x01\n\x08Operator\x12\t\n\x05\x45QUAL\x10\x00\x12\r\n\tNOT_EQUAL\x10\x01\x12\x10\n\x0cGREATER_THAN\x10\x02\x12\x1a\n\x16GREATER_THAN_OR_EQUALS\x10\x03\x12\r\n\tLESS_THAN\x10\x04\x12\x17\n\x13LESS_THAN_OR_EQUALS\x10\x05\x12\x0b\n\x07\x42\x45TWEEN\x10\x06\x12\x1a\n\x16\x42\x45TWEEN_EXCLUDE_BOUNDS\x10\x07\x12\x18\n\x14\x42\x45TWEEN_EXCLUDE_LEFT\x10\x08\x12\x19\n\x15\x42\x45TWEEN_EXCLUDE_RIGHT\x10\t\x12\x06\n\x02IN\x10\nB\x07\n\x05right\x1a\x90\x01\n\x0bOrderClause\x12\x0f\n\x05\x66ield\x18\x01 \x01(\tH\x00\x12S\n\taggregate\x18\x03 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingAggregateH\x00\x12\x11\n\tascending\x18\x02 \x01(\x08\x42\x08\n\x06target\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05start\x1a\xa6\x0c\n\x15GetDocumentsRequestV1\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12Q\n\rwhere_clauses\x18\x03 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.WhereClause\x12L\n\x08order_by\x18\x04 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.OrderClause\x12\x12\n\x05limit\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x12\\\n\x07selects\x18\t \x03(\x0b\x32K.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.Select\x12\x10\n\x08group_by\x18\n \x03(\t\x12K\n\x06having\x18\x0b \x03(\x0b\x32;.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingClause\x12\x13\n\x06offset\x18\x0c \x01(\rH\x02\x88\x01\x01\x12\x61\n\x07\x63hained\x18\r \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.ChainedJoin\x12\x62\n\x0bsub_queries\x18\x0e \x03(\x0b\x32M.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.SubQuery\x1a\xc9\x01\n\x06Select\x12\x66\n\x08\x66unction\x18\x01 \x01(\x0e\x32T.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.Select.Function\x12\r\n\x05\x66ield\x18\x02 \x01(\t\"H\n\x08\x46unction\x12\r\n\tDOCUMENTS\x10\x00\x12\t\n\x05\x43OUNT\x10\x01\x12\x07\n\x03SUM\x10\x02\x12\x07\n\x03\x41VG\x10\x03\x12\x07\n\x03MIN\x10\x04\x12\x07\n\x03MAX\x10\x05\x1a\x41\n\x0b\x43hainedJoin\x12\x15\n\rjoin_property\x18\x01 \x01(\t\x12\x1b\n\x13outer_document_type\x18\x02 \x01(\t\x1a\xa6\x04\n\x08SubQuery\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12Q\n\rwhere_clauses\x18\x03 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.WhereClause\x12L\n\x08order_by\x18\x04 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.OrderClause\x12\x12\n\x05limit\x18\x05 \x01(\rH\x00\x88\x01\x01\x12`\n\x04kind\x18\x06 \x01(\x0e\x32R.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.SubQuery.Kind\x12\x63\n\x04\x62ind\x18\x07 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.SubQuery.Binding\x1a\x41\n\x07\x42inding\x12\x0e\n\x06source\x18\x01 \x01(\r\x12\x17\n\x0fsource_property\x18\x02 \x01(\t\x12\r\n\x05\x66ield\x18\x03 \x01(\t\" \n\x04Kind\x12\r\n\tDOCUMENTS\x10\x00\x12\t\n\x05\x43OUNT\x10\x01\x42\x08\n\x06_limitB\x07\n\x05startB\x08\n\x06_limitB\t\n\x07_offset\"\xb0\x02\n\rWhereOperator\x12\t\n\x05\x45QUAL\x10\x00\x12\x10\n\x0cGREATER_THAN\x10\x01\x12\x1a\n\x16GREATER_THAN_OR_EQUALS\x10\x02\x12\r\n\tLESS_THAN\x10\x03\x12\x17\n\x13LESS_THAN_OR_EQUALS\x10\x04\x12\x0b\n\x07\x42\x45TWEEN\x10\x05\x12\x1a\n\x16\x42\x45TWEEN_EXCLUDE_BOUNDS\x10\x06\x12\x18\n\x14\x42\x45TWEEN_EXCLUDE_LEFT\x10\x07\x12\x19\n\x15\x42\x45TWEEN_EXCLUDE_RIGHT\x10\x08\x12\x06\n\x02IN\x10\t\x12\x0f\n\x0bSTARTS_WITH\x10\n\x12\x11\n\rIN_TIME_RANGE\x10\x0b\x12\x14\n\x10IN_INTEGER_RANGE\x10\x0c\x12\x0c\n\x08\x43ONTAINS\x10\r\x12\x10\n\x0c\x43ONTAINS_ANY\x10\x0e\x42\t\n\x07version\"\xd5\x1d\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x12T\n\x02v1\x18\x02 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06result\x1a\xe7\x19\n\x16GetDocumentsResponseV1\x12\x61\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ResultDataH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x1aL\n\nCountEntry\x12\x13\n\x06in_key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\x11\n\x05\x63ount\x18\x03 \x01(\x04\x42\x02\x30\x01\x42\t\n\x07_in_key\x1ar\n\x0c\x43ountEntries\x12\x62\n\x07\x65ntries\x18\x01 \x03(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountEntry\x1a\xa0\x01\n\x0c\x43ountResults\x12\x1d\n\x0f\x61ggregate_count\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x66\n\x07\x65ntries\x18\x02 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountEntriesH\x00\x42\t\n\x07variant\x1aH\n\x08SumEntry\x12\x13\n\x06in_key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\x0f\n\x03sum\x18\x03 \x01(\x12\x42\x02\x30\x01\x42\t\n\x07_in_key\x1an\n\nSumEntries\x12`\n\x07\x65ntries\x18\x01 \x03(\x0b\x32O.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.SumEntry\x1a\x9a\x01\n\nSumResults\x12\x1b\n\raggregate_sum\x18\x01 \x01(\x12\x42\x02\x30\x01H\x00\x12\x64\n\x07\x65ntries\x18\x02 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.SumEntriesH\x00\x42\t\n\x07variant\x1a_\n\x0c\x41verageEntry\x12\x13\n\x06in_key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\x11\n\x05\x63ount\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\x0f\n\x03sum\x18\x04 \x01(\x12\x42\x02\x30\x01\x42\t\n\x07_in_key\x1av\n\x0e\x41verageEntries\x12\x64\n\x07\x65ntries\x18\x01 \x03(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageEntry\x1a\x36\n\x10\x41verageAggregate\x12\x11\n\x05\x63ount\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x0f\n\x03sum\x18\x02 \x01(\x12\x42\x02\x30\x01\x1a\xfb\x01\n\x0e\x41verageResults\x12t\n\x11\x61ggregate_average\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageAggregateH\x00\x12h\n\x07\x65ntries\x18\x02 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageEntriesH\x00\x42\t\n\x07variant\x1az\n\x0bRankedEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\x13\n\x05\x63ount\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12\x11\n\x03sum\x18\x03 \x01(\x12\x42\x02\x30\x01H\x00\x12\r\n\x03\x61vg\x18\x04 \x01(\x01H\x00\x12\x13\n\x06in_key\x18\x05 \x01(\x0cH\x01\x88\x01\x01\x42\x07\n\x05valueB\t\n\x07_in_key\x1a\x9a\x01\n\rRankedEntries\x12\x63\n\x07\x65ntries\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.RankedEntry\x12\x18\n\x07skipped\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x42\n\n\x08_skipped\x1a\xf7\x05\n\nResultData\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.DocumentsH\x00\x12\x65\n\x06\x63ounts\x18\x02 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountResultsH\x00\x12\x61\n\x04sums\x18\x03 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.SumResultsH\x00\x12i\n\x08\x61verages\x18\x04 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageResultsH\x00\x12\x66\n\x06ranked\x18\x05 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.RankedEntriesH\x00\x12j\n\x07\x63hained\x18\x06 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ChainedDocumentsH\x00\x12n\n\tcomposite\x18\x07 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CompositeDocumentsH\x00\x42\t\n\x07variant\x1a\xd8\x01\n\x10\x43hainedDocuments\x12\x17\n\x0finner_documents\x18\x01 \x03(\x0c\x12\x17\n\x0fouter_documents\x18\x02 \x03(\x0c\x12\x19\n\x11missing_outer_ids\x18\x03 \x03(\x0c\x12w\n\x17removed_outer_documents\x18\x04 \x03(\x0b\x32V.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemoval\x1a\x94\x04\n\x12\x43ompositeDocuments\x12\x16\n\x0epage_documents\x18\x01 \x03(\x0c\x12}\n\x0bsub_results\x18\x02 \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CompositeDocuments.SubQueryResult\x1a\xe6\x02\n\x0eSubQueryResult\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.DocumentsH\x00\x12\x65\n\x06\x63ounts\x18\x02 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountEntriesH\x00\x12\x13\n\x0bmissing_ids\x18\x03 \x03(\x0c\x12g\n\x07removed\x18\x04 \x03(\x0b\x32V.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemovalB\x08\n\x06resultB\x08\n\x06resultB\t\n\x07version\"\xfe\x06\n\x19GetDocumentHistoryRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0H\x00\x12^\n\x02v1\x18\x02 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV1H\x00\x1a\xeb\x01\n\x1bGetDocumentHistoryRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x03 \x01(\x0c\x12+\n\x05limit\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x05 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0bstart_at_ms\x18\x06 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x07 \x01(\x08\x1a\xa7\x03\n\x1bGetDocumentHistoryRequestV1\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x03 \x01(\x0c\x12+\n\x05limit\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x12\x19\n\x0bstart_at_ms\x18\x06 \x01(\x04\x42\x02\x30\x01H\x00\x12n\n\x0bstart_after\x18\x07 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV1.CursorH\x00\x12\x1f\n\x11start_at_revision\x18\x08 \x01(\x04\x42\x02\x30\x01H\x00\x12\x16\n\x08revision\x18\t \x01(\x04\x42\x02\x30\x01H\x00\x1a\x33\n\x06\x43ursor\x12\x13\n\x07time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x14\n\x08revision\x18\x02 \x01(\x04\x42\x02\x30\x01\x42\x08\n\x06\x66ilterB\t\n\x07version\"\xd6\x0b\n\x1aGetDocumentHistoryResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0H\x00\x12`\n\x02v1\x18\x02 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1H\x00\x1a\xeb\x03\n\x1cGetDocumentHistoryResponseV0\x12~\n\x10\x64ocument_history\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x14\x44ocumentHistoryEntry\x12\x10\n\x04\x64\x61te\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\x95\x01\n\x0f\x44ocumentHistory\x12\x81\x01\n\x10\x64ocument_entries\x18\x01 \x03(\x0b\x32g.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntryB\x08\n\x06result\x1a\xfa\x05\n\x1cGetDocumentHistoryResponseV1\x12m\n\x07history\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.HistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x44\n\x05\x45ntry\x12\x13\n\x07time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x14\n\x08revision\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x08\x64ocument\x18\x03 \x01(\x0c\x1a\xc0\x01\n\tLifecycle\x12q\n\x05state\x18\x01 \x01(\x0e\x32\x62.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State\x12\x1f\n\x13remaining_revisions\x18\x02 \x01(\x04\x42\x02\x30\x01\"\x1f\n\x05State\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x41\x42SENT\x10\x01\x1a\xe5\x01\n\x07History\x12i\n\x07\x65ntries\x18\x01 \x03(\x0b\x32X.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Entry\x12o\n\tlifecycle\x18\x02 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.LifecycleB\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc3\x04\n*GetIdentityByNonUniquePublicKeyHashRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashRequest.GetIdentityByNonUniquePublicKeyHashRequestV0H\x00\x12\x80\x01\n\x02v1\x18\x02 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashRequest.GetIdentityByNonUniquePublicKeyHashRequestV1H\x00\x1a\x80\x01\n,GetIdentityByNonUniquePublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\x18\n\x0bstart_after\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\x0e\n\x0c_start_after\x1a\x80\x01\n,GetIdentityByNonUniquePublicKeyHashRequestV1\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\x18\n\x0bstart_after\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\x0e\n\x0c_start_afterB\t\n\x07version\"\xe4\n\n+GetIdentityByNonUniquePublicKeyHashResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV0H\x00\x12\x82\x01\n\x02v1\x18\x02 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV1H\x00\x1a\x9c\x05\n-GetIdentityByNonUniquePublicKeyHashResponseV0\x12\x9a\x01\n\x08identity\x18\x01 \x01(\x0b\x32\x85\x01.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV0.IdentityResponseH\x00\x12\x9d\x01\n\x05proof\x18\x02 \x01(\x0b\x32\x8b\x01.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV0.IdentityProvedResponseH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x36\n\x10IdentityResponse\x12\x15\n\x08identity\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_identity\x1a\xa6\x01\n\x16IdentityProvedResponse\x12P\n&grovedb_identity_public_key_hash_proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.Proof\x12!\n\x14identity_proof_bytes\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x17\n\x15_identity_proof_bytesB\x08\n\x06resultJ\x04\x08\x04\x10\x05\x1a\x80\x03\n-GetIdentityByNonUniquePublicKeyHashResponseV1\x12\x9a\x01\n\x08identity\x18\x01 \x01(\x0b\x32\x85\x01.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV1.IdentityResponseH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x36\n\x10IdentityResponse\x12\x15\n\x08identity\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_identityB\x08\n\x06resultB\t\n\x07version\"\x99\x02\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1as\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x12\x1c\n\x14request_user_balance\x18\x03 \x01(\x08\x42\t\n\x07version\"\xce\x04\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\x34\n\x17SuccessWithOwnerBalance\x12\x19\n\rowner_balance\x18\x01 \x01(\x04\x42\x02\x30\x01\x1a\xee\x02\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12}\n\x1asuccess_with_owner_balance\x18\x04 \x01(\x0b\x32W.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.SuccessWithOwnerBalanceH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf4\x01\n%GetRecentStateTransitionStatusRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusRequest.GetRecentStateTransitionStatusRequestV0H\x00\x1aH\n\'GetRecentStateTransitionStatusRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x42\t\n\x07version\"\xbf\x06\n&GetRecentStateTransitionStatusResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0H\x00\x1a\x8f\x05\n(GetRecentStateTransitionStatusResponseV0\x12\x89\x01\n\tcommitted\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0.CommittedH\x00\x12\x85\x01\n\x07pending\x18\x02 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0.PendingH\x00\x12\x85\x01\n\x07unknown\x18\x03 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0.UnknownH\x00\x12=\n\x08metadata\x18\x04 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ah\n\tCommitted\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12G\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastError\x1a\t\n\x07Pending\x1a\t\n\x07UnknownB\x08\n\x06statusB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\x99\x05\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\x9c\x04\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\xa6\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1e\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x16\n\nstart_time\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xbf\x02\n\x1dGetFinalizedEpochInfosRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetFinalizedEpochInfosRequest.GetFinalizedEpochInfosRequestV0H\x00\x1a\xaa\x01\n\x1fGetFinalizedEpochInfosRequestV0\x12\x19\n\x11start_epoch_index\x18\x01 \x01(\r\x12\"\n\x1astart_epoch_index_included\x18\x02 \x01(\x08\x12\x17\n\x0f\x65nd_epoch_index\x18\x03 \x01(\r\x12 \n\x18\x65nd_epoch_index_included\x18\x04 \x01(\x08\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xbd\t\n\x1eGetFinalizedEpochInfosResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0H\x00\x1a\xa5\x08\n GetFinalizedEpochInfosResponseV0\x12\x80\x01\n\x06\x65pochs\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0.FinalizedEpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xa4\x01\n\x13\x46inalizedEpochInfos\x12\x8c\x01\n\x15\x66inalized_epoch_infos\x18\x01 \x03(\x0b\x32m.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0.FinalizedEpochInfo\x1a\x9f\x04\n\x12\x46inalizedEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1e\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x1c\n\x10\x66irst_block_time\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\r\x12!\n\x15total_blocks_in_epoch\x18\x07 \x01(\x04\x42\x02\x30\x01\x12*\n\"next_epoch_start_core_block_height\x18\x08 \x01(\r\x12!\n\x15total_processing_fees\x18\t \x01(\x04\x42\x02\x30\x01\x12*\n\x1etotal_distributed_storage_fees\x18\n \x01(\x04\x42\x02\x30\x01\x12&\n\x1atotal_created_storage_fees\x18\x0b \x01(\x04\x42\x02\x30\x01\x12\x1e\n\x12\x63ore_block_rewards\x18\x0c \x01(\x04\x42\x02\x30\x01\x12\x81\x01\n\x0f\x62lock_proposers\x18\r \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0.BlockProposer\x1a\x39\n\rBlockProposer\x12\x13\n\x0bproposer_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x62lock_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xde\x04\n\x1cGetContestedResourcesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0H\x00\x1a\xcc\x03\n\x1eGetContestedResourcesRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x1a\n\x12start_index_values\x18\x04 \x03(\x0c\x12\x18\n\x10\x65nd_index_values\x18\x05 \x03(\x0c\x12\x89\x01\n\x13start_at_value_info\x18\x06 \x01(\x0b\x32g.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.StartAtValueInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1a\x45\n\x10StartAtValueInfo\x12\x13\n\x0bstart_value\x18\x01 \x01(\x0c\x12\x1c\n\x14start_value_included\x18\x02 \x01(\x08\x42\x16\n\x14_start_at_value_infoB\x08\n\x06_countB\t\n\x07version\"\x88\x04\n\x1dGetContestedResourcesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0H\x00\x1a\xf3\x02\n\x1fGetContestedResourcesResponseV0\x12\x95\x01\n\x19\x63ontested_resource_values\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResourceValuesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a<\n\x17\x43ontestedResourceValues\x12!\n\x19\x63ontested_resource_values\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xd2\x05\n\x1cGetVotePollsByEndDateRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0H\x00\x1a\xc0\x04\n\x1eGetVotePollsByEndDateRequestV0\x12\x84\x01\n\x0fstart_time_info\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.StartAtTimeInfoH\x00\x88\x01\x01\x12\x80\x01\n\rend_time_info\x18\x02 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.EndAtTimeInfoH\x01\x88\x01\x01\x12\x12\n\x05limit\x18\x03 \x01(\rH\x02\x88\x01\x01\x12\x13\n\x06offset\x18\x04 \x01(\rH\x03\x88\x01\x01\x12\x11\n\tascending\x18\x05 \x01(\x08\x12\r\n\x05prove\x18\x06 \x01(\x08\x1aI\n\x0fStartAtTimeInfo\x12\x19\n\rstart_time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1b\n\x13start_time_included\x18\x02 \x01(\x08\x1a\x43\n\rEndAtTimeInfo\x12\x17\n\x0b\x65nd_time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x19\n\x11\x65nd_time_included\x18\x02 \x01(\x08\x42\x12\n\x10_start_time_infoB\x10\n\x0e_end_time_infoB\x08\n\x06_limitB\t\n\x07_offsetB\t\n\x07version\"\x83\x06\n\x1dGetVotePollsByEndDateResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0H\x00\x1a\xee\x04\n\x1fGetVotePollsByEndDateResponseV0\x12\x9c\x01\n\x18vote_polls_by_timestamps\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestampsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aV\n\x1eSerializedVotePollsByTimestamp\x12\x15\n\ttimestamp\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1d\n\x15serialized_vote_polls\x18\x02 \x03(\x0c\x1a\xd7\x01\n\x1fSerializedVotePollsByTimestamps\x12\x99\x01\n\x18vote_polls_by_timestamps\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestamp\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xd6\x01\n\x1cGetYesNoVotePollStateRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetYesNoVotePollStateRequest.GetYesNoVotePollStateRequestV0H\x00\x1a\x45\n\x1eGetYesNoVotePollStateRequestV0\x12\x14\n\x0cvote_poll_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xa8\x11\n\x1dGetYesNoVotePollStateResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0H\x00\x1a\x93\x10\n\x1fGetYesNoVotePollStateResponseV0\x12|\n\x05state\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollStateH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x61\n\x12YesNoVotePollBlock\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x13\n\x0b\x63ore_height\x18\x02 \x01(\r\x12\x13\n\x07time_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05\x65poch\x18\x04 \x01(\r\x1a\xa4\x03\n\x15\x46inishedYesNoVotePoll\x12\x0e\n\x06passed\x18\x01 \x01(\x08\x12\x18\n\x10yes_voting_power\x18\x02 \x01(\r\x12\x17\n\x0fno_voting_power\x18\x03 \x01(\r\x12\x1c\n\x14\x61\x62stain_voting_power\x18\x04 \x01(\r\x12\x1d\n\x15required_voting_power\x18\x05 \x01(\r\x12\x80\x01\n\x0bstart_block\x18\x06 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollBlock\x12\x87\x01\n\x12\x66inalization_block\x18\x07 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollBlock\x1a\xf9\x05\n\rYesNoVotePoll\x12\x94\x01\n\x11\x64\x65\x63ision_proposal\x18\x01 \x01(\x0b\x32w.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePoll.DecisionProposalH\x00\x12\x1f\n\x17supermajority_numerator\x18\x02 \x01(\r\x12!\n\x19supermajority_denominator\x18\x03 \x01(\r\x12\x12\n\x08\x61\x62solute\x18\x04 \x01(\rH\x01\x12\x93\x01\n\x11\x66raction_of_total\x18\x05 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePoll.FractionOfTotalH\x01\x1a\'\n\x10\x44\x65\x63isionProposal\x12\x13\n\x0b\x64ocument_id\x18\x01 \x01(\x0c\x1a\xc8\x01\n\x0f\x46ractionOfTotal\x12\x11\n\tnumerator\x18\x01 \x01(\r\x12\x13\n\x0b\x64\x65nominator\x18\x02 \x01(\r\x12\x8c\x01\n\x08rounding\x18\x03 \x01(\x0e\x32z.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePoll.VotingPowerRounding\"L\n\x13VotingPowerRounding\x12\x08\n\x04\x44OWN\x10\x00\x12\x06\n\x02UP\x10\x01\x12\x11\n\rDOWN_PLUS_ONE\x10\x02\x12\x10\n\x0cUP_MINUS_ONE\x10\x03\x42\t\n\x07purposeB\x16\n\x14minimum_voting_power\x1a\xef\x03\n\x12YesNoVotePollState\x12~\n\x07started\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollBlockH\x00\x12\x82\x01\n\x08\x66inished\x18\x02 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.FinishedYesNoVotePollH\x00\x12\x18\n\x10yes_voting_power\x18\x03 \x01(\r\x12\x17\n\x0fno_voting_power\x18\x04 \x01(\r\x12\x1c\n\x14\x61\x62stain_voting_power\x18\x05 \x01(\r\x12y\n\tvote_poll\x18\x06 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollB\x08\n\x06statusB\x08\n\x06resultB\t\n\x07version\"\xef\x01\n\x1dGetMasternodeYesNoVoteRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteRequest.GetMasternodeYesNoVoteRequestV0H\x00\x1a[\n\x1fGetMasternodeYesNoVoteRequestV0\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x14\n\x0cvote_poll_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xb5\x06\n\x1eGetMasternodeYesNoVoteResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0H\x00\x1a\x9d\x05\n GetMasternodeYesNoVoteResponseV0\x12\x84\x01\n\x05\x65ntry\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0.MasternodeYesNoVoteEntryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xda\x01\n\x13MasternodeYesNoVote\x12\x85\x01\n\x06\x63hoice\x18\x01 \x01(\x0e\x32u.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0.MasternodeYesNoVote.Choice\x12\x13\n\x0btimes_voted\x18\x02 \x01(\r\"&\n\x06\x43hoice\x12\x07\n\x03YES\x10\x00\x12\x06\n\x02NO\x10\x01\x12\x0b\n\x07\x41\x42STAIN\x10\x02\x1a\x98\x01\n\x18MasternodeYesNoVoteEntry\x12|\n\x04vote\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0.MasternodeYesNoVoteB\x08\n\x06resultB\t\n\x07version\"\xff\x06\n$GetContestedResourceVoteStateRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0H\x00\x1a\xd5\x05\n&GetContestedResourceVoteStateRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x86\x01\n\x0bresult_type\x18\x05 \x01(\x0e\x32q.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.ResultType\x12\x36\n.allow_include_locked_and_abstaining_vote_tally\x18\x06 \x01(\x08\x12\xa3\x01\n\x18start_at_identifier_info\x18\x07 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x08 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\"I\n\nResultType\x12\r\n\tDOCUMENTS\x10\x00\x12\x0e\n\nVOTE_TALLY\x10\x01\x12\x1c\n\x18\x44OCUMENTS_AND_VOTE_TALLY\x10\x02\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\x94\x0c\n%GetContestedResourceVoteStateResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0H\x00\x1a\xe7\n\n\'GetContestedResourceVoteStateResponseV0\x12\xae\x01\n\x1d\x63ontested_resource_contenders\x18\x01 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContendersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xda\x03\n\x10\x46inishedVoteInfo\x12\xad\x01\n\x15\x66inished_vote_outcome\x18\x01 \x01(\x0e\x32\x8d\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfo.FinishedVoteOutcome\x12\x1f\n\x12won_by_identity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12$\n\x18\x66inished_at_block_height\x18\x03 \x01(\x04\x42\x02\x30\x01\x12%\n\x1d\x66inished_at_core_block_height\x18\x04 \x01(\r\x12%\n\x19\x66inished_at_block_time_ms\x18\x05 \x01(\x04\x42\x02\x30\x01\x12\x19\n\x11\x66inished_at_epoch\x18\x06 \x01(\r\"O\n\x13\x46inishedVoteOutcome\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\n\n\x06LOCKED\x10\x01\x12\x16\n\x12NO_PREVIOUS_WINNER\x10\x02\x42\x15\n\x13_won_by_identity_id\x1a\xc4\x03\n\x1b\x43ontestedResourceContenders\x12\x86\x01\n\ncontenders\x18\x01 \x03(\x0b\x32r.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender\x12\x1f\n\x12\x61\x62stain_vote_tally\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1c\n\x0flock_vote_tally\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\x9a\x01\n\x12\x66inished_vote_info\x18\x04 \x01(\x0b\x32y.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfoH\x02\x88\x01\x01\x42\x15\n\x13_abstain_vote_tallyB\x12\n\x10_lock_vote_tallyB\x15\n\x13_finished_vote_info\x1ak\n\tContender\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x17\n\nvote_count\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x15\n\x08\x64ocument\x18\x03 \x01(\x0cH\x01\x88\x01\x01\x42\r\n\x0b_vote_countB\x0b\n\t_documentB\x08\n\x06resultB\t\n\x07version\"\xd5\x05\n,GetContestedResourceVotersForIdentityRequest\x12\x84\x01\n\x02v0\x18\x01 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0H\x00\x1a\x92\x04\n.GetContestedResourceVotersForIdentityRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x15\n\rcontestant_id\x18\x05 \x01(\x0c\x12\xb4\x01\n\x18start_at_identifier_info\x18\x06 \x01(\x0b\x32\x8c\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\xf1\x04\n-GetContestedResourceVotersForIdentityResponse\x12\x86\x01\n\x02v0\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0H\x00\x1a\xab\x03\n/GetContestedResourceVotersForIdentityResponseV0\x12\xb6\x01\n\x19\x63ontested_resource_voters\x18\x01 \x01(\x0b\x32\x90\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0.ContestedResourceVotersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x43\n\x17\x43ontestedResourceVoters\x12\x0e\n\x06voters\x18\x01 \x03(\x0c\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xad\x05\n(GetContestedResourceIdentityVotesRequest\x12|\n\x02v0\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0H\x00\x1a\xf7\x03\n*GetContestedResourceIdentityVotesRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0forder_ascending\x18\x04 \x01(\x08\x12\xae\x01\n\x1astart_at_vote_poll_id_info\x18\x05 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0.StartAtVotePollIdInfoH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x1a\x61\n\x15StartAtVotePollIdInfo\x12 \n\x18start_at_poll_identifier\x18\x01 \x01(\x0c\x12&\n\x1estart_poll_identifier_included\x18\x02 \x01(\x08\x42\x1d\n\x1b_start_at_vote_poll_id_infoB\t\n\x07version\"\xc8\n\n)GetContestedResourceIdentityVotesResponse\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0H\x00\x1a\x8f\t\n+GetContestedResourceIdentityVotesResponseV0\x12\xa1\x01\n\x05votes\x18\x01 \x01(\x0b\x32\x8f\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVotesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xf7\x01\n\x1e\x43ontestedResourceIdentityVotes\x12\xba\x01\n!contested_resource_identity_votes\x18\x01 \x03(\x0b\x32\x8e\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVote\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\xad\x02\n\x12ResourceVoteChoice\x12\xad\x01\n\x10vote_choice_type\x18\x01 \x01(\x0e\x32\x92\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoice.VoteChoiceType\x12\x18\n\x0bidentity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\"=\n\x0eVoteChoiceType\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\x0b\n\x07\x41\x42STAIN\x10\x01\x12\x08\n\x04LOCK\x10\x02\x42\x0e\n\x0c_identity_id\x1a\x95\x02\n\x1d\x43ontestedResourceIdentityVote\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\'\n\x1fserialized_index_storage_values\x18\x03 \x03(\x0c\x12\x99\x01\n\x0bvote_choice\x18\x04 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoiceB\x08\n\x06resultB\t\n\x07version\"\xf0\x01\n%GetPrefundedSpecializedBalanceRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest.GetPrefundedSpecializedBalanceRequestV0H\x00\x1a\x44\n\'GetPrefundedSpecializedBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xed\x02\n&GetPrefundedSpecializedBalanceResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0H\x00\x1a\xbd\x01\n(GetPrefundedSpecializedBalanceResponseV0\x12\x15\n\x07\x62\x61lance\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xd0\x01\n GetTotalCreditsInPlatformRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0H\x00\x1a\x33\n\"GetTotalCreditsInPlatformRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xd9\x02\n!GetTotalCreditsInPlatformResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0H\x00\x1a\xb8\x01\n#GetTotalCreditsInPlatformResponseV0\x12\x15\n\x07\x63redits\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x16GetPathElementsRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0H\x00\x1a\x45\n\x18GetPathElementsRequestV0\x12\x0c\n\x04path\x18\x01 \x03(\x0c\x12\x0c\n\x04keys\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xa3\x03\n\x17GetPathElementsResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0H\x00\x1a\xa0\x02\n\x19GetPathElementsResponseV0\x12i\n\x08\x65lements\x18\x01 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.ElementsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1c\n\x08\x45lements\x12\x10\n\x08\x65lements\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\x81\x01\n\x10GetStatusRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetStatusRequest.GetStatusRequestV0H\x00\x1a\x14\n\x12GetStatusRequestV0B\t\n\x07version\"\xe4\x10\n\x11GetStatusResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0H\x00\x1a\xf3\x0f\n\x13GetStatusResponseV0\x12Y\n\x07version\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version\x12S\n\x04node\x18\x02 \x01(\x0b\x32\x45.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Node\x12U\n\x05\x63hain\x18\x03 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Chain\x12Y\n\x07network\x18\x04 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Network\x12^\n\nstate_sync\x18\x05 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.StateSync\x12S\n\x04time\x18\x06 \x01(\x0b\x32\x45.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Time\x1a\x82\x05\n\x07Version\x12\x63\n\x08software\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Software\x12\x63\n\x08protocol\x18\x02 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Protocol\x1a^\n\x08Software\x12\x0c\n\x04\x64\x61pi\x18\x01 \x01(\t\x12\x12\n\x05\x64rive\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\x17\n\ntenderdash\x18\x03 \x01(\tH\x01\x88\x01\x01\x42\x08\n\x06_driveB\r\n\x0b_tenderdash\x1a\xcc\x02\n\x08Protocol\x12p\n\ntenderdash\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Protocol.Tenderdash\x12\x66\n\x05\x64rive\x18\x02 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Protocol.Drive\x1a(\n\nTenderdash\x12\x0b\n\x03p2p\x18\x01 \x01(\r\x12\r\n\x05\x62lock\x18\x02 \x01(\r\x1a<\n\x05\x44rive\x12\x0e\n\x06latest\x18\x03 \x01(\r\x12\x0f\n\x07\x63urrent\x18\x04 \x01(\r\x12\x12\n\nnext_epoch\x18\x05 \x01(\r\x1a\x7f\n\x04Time\x12\x11\n\x05local\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x16\n\x05\x62lock\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x12\x18\n\x07genesis\x18\x03 \x01(\x04\x42\x02\x30\x01H\x01\x88\x01\x01\x12\x12\n\x05\x65poch\x18\x04 \x01(\rH\x02\x88\x01\x01\x42\x08\n\x06_blockB\n\n\x08_genesisB\x08\n\x06_epoch\x1a<\n\x04Node\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\x18\n\x0bpro_tx_hash\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0e\n\x0c_pro_tx_hash\x1a\xb3\x02\n\x05\x43hain\x12\x13\n\x0b\x63\x61tching_up\x18\x01 \x01(\x08\x12\x19\n\x11latest_block_hash\x18\x02 \x01(\x0c\x12\x17\n\x0flatest_app_hash\x18\x03 \x01(\x0c\x12\x1f\n\x13latest_block_height\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x1b\n\x13\x65\x61rliest_block_hash\x18\x05 \x01(\x0c\x12\x19\n\x11\x65\x61rliest_app_hash\x18\x06 \x01(\x0c\x12!\n\x15\x65\x61rliest_block_height\x18\x07 \x01(\x04\x42\x02\x30\x01\x12!\n\x15max_peer_block_height\x18\t \x01(\x04\x42\x02\x30\x01\x12%\n\x18\x63ore_chain_locked_height\x18\n \x01(\rH\x00\x88\x01\x01\x42\x1b\n\x19_core_chain_locked_height\x1a\x43\n\x07Network\x12\x10\n\x08\x63hain_id\x18\x01 \x01(\t\x12\x13\n\x0bpeers_count\x18\x02 \x01(\r\x12\x11\n\tlistening\x18\x03 \x01(\x08\x1a\x85\x02\n\tStateSync\x12\x1d\n\x11total_synced_time\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1a\n\x0eremaining_time\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x17\n\x0ftotal_snapshots\x18\x03 \x01(\r\x12\"\n\x16\x63hunk_process_avg_time\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x1b\n\x0fsnapshot_height\x18\x05 \x01(\x04\x42\x02\x30\x01\x12!\n\x15snapshot_chunks_count\x18\x06 \x01(\x04\x42\x02\x30\x01\x12\x1d\n\x11\x62\x61\x63kfilled_blocks\x18\x07 \x01(\x04\x42\x02\x30\x01\x12!\n\x15\x62\x61\x63kfill_blocks_total\x18\x08 \x01(\x04\x42\x02\x30\x01\x42\t\n\x07version\"\xb1\x01\n\x1cGetCurrentQuorumsInfoRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest.GetCurrentQuorumsInfoRequestV0H\x00\x1a \n\x1eGetCurrentQuorumsInfoRequestV0B\t\n\x07version\"\xa1\x05\n\x1dGetCurrentQuorumsInfoResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.GetCurrentQuorumsInfoResponseV0H\x00\x1a\x46\n\x0bValidatorV0\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07node_ip\x18\x02 \x01(\t\x12\x11\n\tis_banned\x18\x03 \x01(\x08\x1a\xaf\x01\n\x0eValidatorSetV0\x12\x13\n\x0bquorum_hash\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ore_height\x18\x02 \x01(\r\x12U\n\x07members\x18\x03 \x03(\x0b\x32\x44.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorV0\x12\x1c\n\x14threshold_public_key\x18\x04 \x01(\x0c\x1a\x92\x02\n\x1fGetCurrentQuorumsInfoResponseV0\x12\x15\n\rquorum_hashes\x18\x01 \x03(\x0c\x12\x1b\n\x13\x63urrent_quorum_hash\x18\x02 \x01(\x0c\x12_\n\x0evalidator_sets\x18\x03 \x03(\x0b\x32G.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorSetV0\x12\x1b\n\x13last_block_proposer\x18\x04 \x01(\x0c\x12=\n\x08metadata\x18\x05 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\t\n\x07version\"\xf4\x01\n\x1fGetIdentityTokenBalancesRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityTokenBalancesRequest.GetIdentityTokenBalancesRequestV0H\x00\x1aZ\n!GetIdentityTokenBalancesRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x11\n\ttoken_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xad\x05\n GetIdentityTokenBalancesResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse.GetIdentityTokenBalancesResponseV0H\x00\x1a\x8f\x04\n\"GetIdentityTokenBalancesResponseV0\x12\x86\x01\n\x0etoken_balances\x18\x01 \x01(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse.GetIdentityTokenBalancesResponseV0.TokenBalancesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aG\n\x11TokenBalanceEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x14\n\x07\x62\x61lance\x18\x02 \x01(\x04H\x00\x88\x01\x01\x42\n\n\x08_balance\x1a\x9a\x01\n\rTokenBalances\x12\x88\x01\n\x0etoken_balances\x18\x01 \x03(\x0b\x32p.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse.GetIdentityTokenBalancesResponseV0.TokenBalanceEntryB\x08\n\x06resultB\t\n\x07version\"\xfc\x01\n!GetIdentitiesTokenBalancesRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesRequest.GetIdentitiesTokenBalancesRequestV0H\x00\x1a\\\n#GetIdentitiesTokenBalancesRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x14\n\x0cidentity_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xf2\x05\n\"GetIdentitiesTokenBalancesResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse.GetIdentitiesTokenBalancesResponseV0H\x00\x1a\xce\x04\n$GetIdentitiesTokenBalancesResponseV0\x12\x9b\x01\n\x17identity_token_balances\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse.GetIdentitiesTokenBalancesResponseV0.IdentityTokenBalancesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aR\n\x19IdentityTokenBalanceEntry\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x14\n\x07\x62\x61lance\x18\x02 \x01(\x04H\x00\x88\x01\x01\x42\n\n\x08_balance\x1a\xb7\x01\n\x15IdentityTokenBalances\x12\x9d\x01\n\x17identity_token_balances\x18\x01 \x03(\x0b\x32|.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse.GetIdentitiesTokenBalancesResponseV0.IdentityTokenBalanceEntryB\x08\n\x06resultB\t\n\x07version\"\xe8\x01\n\x1cGetIdentityTokenInfosRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetIdentityTokenInfosRequest.GetIdentityTokenInfosRequestV0H\x00\x1aW\n\x1eGetIdentityTokenInfosRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x11\n\ttoken_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\x98\x06\n\x1dGetIdentityTokenInfosResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0H\x00\x1a\x83\x05\n\x1fGetIdentityTokenInfosResponseV0\x12z\n\x0btoken_infos\x18\x01 \x01(\x0b\x32\x63.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0.TokenInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a(\n\x16TokenIdentityInfoEntry\x12\x0e\n\x06\x66rozen\x18\x01 \x01(\x08\x1a\xb0\x01\n\x0eTokenInfoEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x82\x01\n\x04info\x18\x02 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0.TokenIdentityInfoEntryH\x00\x88\x01\x01\x42\x07\n\x05_info\x1a\x8a\x01\n\nTokenInfos\x12|\n\x0btoken_infos\x18\x01 \x03(\x0b\x32g.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0.TokenInfoEntryB\x08\n\x06resultB\t\n\x07version\"\xf0\x01\n\x1eGetIdentitiesTokenInfosRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosRequest.GetIdentitiesTokenInfosRequestV0H\x00\x1aY\n GetIdentitiesTokenInfosRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x14\n\x0cidentity_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xca\x06\n\x1fGetIdentitiesTokenInfosResponse\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0H\x00\x1a\xaf\x05\n!GetIdentitiesTokenInfosResponseV0\x12\x8f\x01\n\x14identity_token_infos\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0.IdentityTokenInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a(\n\x16TokenIdentityInfoEntry\x12\x0e\n\x06\x66rozen\x18\x01 \x01(\x08\x1a\xb7\x01\n\x0eTokenInfoEntry\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x86\x01\n\x04info\x18\x02 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0.TokenIdentityInfoEntryH\x00\x88\x01\x01\x42\x07\n\x05_info\x1a\x97\x01\n\x12IdentityTokenInfos\x12\x80\x01\n\x0btoken_infos\x18\x01 \x03(\x0b\x32k.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0.TokenInfoEntryB\x08\n\x06resultB\t\n\x07version\"\xbf\x01\n\x17GetTokenStatusesRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetTokenStatusesRequest.GetTokenStatusesRequestV0H\x00\x1a=\n\x19GetTokenStatusesRequestV0\x12\x11\n\ttoken_ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xe7\x04\n\x18GetTokenStatusesResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetTokenStatusesResponse.GetTokenStatusesResponseV0H\x00\x1a\xe1\x03\n\x1aGetTokenStatusesResponseV0\x12v\n\x0etoken_statuses\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetTokenStatusesResponse.GetTokenStatusesResponseV0.TokenStatusesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x44\n\x10TokenStatusEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x13\n\x06paused\x18\x02 \x01(\x08H\x00\x88\x01\x01\x42\t\n\x07_paused\x1a\x88\x01\n\rTokenStatuses\x12w\n\x0etoken_statuses\x18\x01 \x03(\x0b\x32_.org.dash.platform.dapi.v0.GetTokenStatusesResponse.GetTokenStatusesResponseV0.TokenStatusEntryB\x08\n\x06resultB\t\n\x07version\"\xef\x01\n#GetTokenDirectPurchasePricesRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesRequest.GetTokenDirectPurchasePricesRequestV0H\x00\x1aI\n%GetTokenDirectPurchasePricesRequestV0\x12\x11\n\ttoken_ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x8b\t\n$GetTokenDirectPurchasePricesResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0H\x00\x1a\xe1\x07\n&GetTokenDirectPurchasePricesResponseV0\x12\xa9\x01\n\x1ctoken_direct_purchase_prices\x18\x01 \x01(\x0b\x32\x80\x01.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.TokenDirectPurchasePricesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x33\n\x10PriceForQuantity\x12\x10\n\x08quantity\x18\x01 \x01(\x04\x12\r\n\x05price\x18\x02 \x01(\x04\x1a\xa7\x01\n\x0fPricingSchedule\x12\x93\x01\n\x12price_for_quantity\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.PriceForQuantity\x1a\xe4\x01\n\x1dTokenDirectPurchasePriceEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x15\n\x0b\x66ixed_price\x18\x02 \x01(\x04H\x00\x12\x90\x01\n\x0evariable_price\x18\x03 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.PricingScheduleH\x00\x42\x07\n\x05price\x1a\xc8\x01\n\x19TokenDirectPurchasePrices\x12\xaa\x01\n\x1btoken_direct_purchase_price\x18\x01 \x03(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.TokenDirectPurchasePriceEntryB\x08\n\x06resultB\t\n\x07version\"\xce\x01\n\x1bGetTokenContractInfoRequest\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetTokenContractInfoRequest.GetTokenContractInfoRequestV0H\x00\x1a@\n\x1dGetTokenContractInfoRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xfb\x03\n\x1cGetTokenContractInfoResponse\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetTokenContractInfoResponse.GetTokenContractInfoResponseV0H\x00\x1a\xe9\x02\n\x1eGetTokenContractInfoResponseV0\x12|\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32l.org.dash.platform.dapi.v0.GetTokenContractInfoResponse.GetTokenContractInfoResponseV0.TokenContractInfoDataH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aM\n\x15TokenContractInfoData\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17token_contract_position\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xef\x04\n)GetTokenPreProgrammedDistributionsRequest\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsRequest.GetTokenPreProgrammedDistributionsRequestV0H\x00\x1a\xb6\x03\n+GetTokenPreProgrammedDistributionsRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x98\x01\n\rstart_at_info\x18\x02 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsRequest.GetTokenPreProgrammedDistributionsRequestV0.StartAtInfoH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x04 \x01(\x08\x1a\x9a\x01\n\x0bStartAtInfo\x12\x15\n\rstart_time_ms\x18\x01 \x01(\x04\x12\x1c\n\x0fstart_recipient\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12%\n\x18start_recipient_included\x18\x03 \x01(\x08H\x01\x88\x01\x01\x42\x12\n\x10_start_recipientB\x1b\n\x19_start_recipient_includedB\x10\n\x0e_start_at_infoB\x08\n\x06_limitB\t\n\x07version\"\xec\x07\n*GetTokenPreProgrammedDistributionsResponse\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0H\x00\x1a\xaf\x06\n,GetTokenPreProgrammedDistributionsResponseV0\x12\xa5\x01\n\x13token_distributions\x18\x01 \x01(\x0b\x32\x85\x01.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0.TokenDistributionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a>\n\x16TokenDistributionEntry\x12\x14\n\x0crecipient_id\x18\x01 \x01(\x0c\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x04\x1a\xd4\x01\n\x1bTokenTimedDistributionEntry\x12\x11\n\ttimestamp\x18\x01 \x01(\x04\x12\xa1\x01\n\rdistributions\x18\x02 \x03(\x0b\x32\x89\x01.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0.TokenDistributionEntry\x1a\xc3\x01\n\x12TokenDistributions\x12\xac\x01\n\x13token_distributions\x18\x01 \x03(\x0b\x32\x8e\x01.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0.TokenTimedDistributionEntryB\x08\n\x06resultB\t\n\x07version\"\x82\x04\n-GetTokenPerpetualDistributionLastClaimRequest\x12\x86\x01\n\x02v0\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimRequest.GetTokenPerpetualDistributionLastClaimRequestV0H\x00\x1aI\n\x11\x43ontractTokenInfo\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17token_contract_position\x18\x02 \x01(\r\x1a\xf1\x01\n/GetTokenPerpetualDistributionLastClaimRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12v\n\rcontract_info\x18\x02 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimRequest.ContractTokenInfoH\x00\x88\x01\x01\x12\x13\n\x0bidentity_id\x18\x04 \x01(\x0c\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x10\n\x0e_contract_infoB\t\n\x07version\"\x93\x05\n.GetTokenPerpetualDistributionLastClaimResponse\x12\x88\x01\n\x02v0\x18\x01 \x01(\x0b\x32z.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimResponse.GetTokenPerpetualDistributionLastClaimResponseV0H\x00\x1a\xca\x03\n0GetTokenPerpetualDistributionLastClaimResponseV0\x12\x9f\x01\n\nlast_claim\x18\x01 \x01(\x0b\x32\x88\x01.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimResponse.GetTokenPerpetualDistributionLastClaimResponseV0.LastClaimInfoH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ax\n\rLastClaimInfo\x12\x1a\n\x0ctimestamp_ms\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x1a\n\x0c\x62lock_height\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12\x0f\n\x05\x65poch\x18\x03 \x01(\rH\x00\x12\x13\n\traw_bytes\x18\x04 \x01(\x0cH\x00\x42\t\n\x07paid_atB\x08\n\x06resultB\t\n\x07version\"\xca\x01\n\x1aGetTokenTotalSupplyRequest\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetTokenTotalSupplyRequest.GetTokenTotalSupplyRequestV0H\x00\x1a?\n\x1cGetTokenTotalSupplyRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xaf\x04\n\x1bGetTokenTotalSupplyResponse\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetTokenTotalSupplyResponse.GetTokenTotalSupplyResponseV0H\x00\x1a\xa0\x03\n\x1dGetTokenTotalSupplyResponseV0\x12\x88\x01\n\x12token_total_supply\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetTokenTotalSupplyResponse.GetTokenTotalSupplyResponseV0.TokenTotalSupplyEntryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ax\n\x15TokenTotalSupplyEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x30\n(total_aggregated_amount_in_user_accounts\x18\x02 \x01(\x04\x12\x1b\n\x13total_system_amount\x18\x03 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd2\x01\n\x13GetGroupInfoRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetGroupInfoRequest.GetGroupInfoRequestV0H\x00\x1a\\\n\x15GetGroupInfoRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17group_contract_position\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xd4\x05\n\x14GetGroupInfoResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0H\x00\x1a\xda\x04\n\x16GetGroupInfoResponseV0\x12\x66\n\ngroup_info\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0.GroupInfoH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x04 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x34\n\x10GroupMemberEntry\x12\x11\n\tmember_id\x18\x01 \x01(\x0c\x12\r\n\x05power\x18\x02 \x01(\r\x1a\x98\x01\n\x0eGroupInfoEntry\x12h\n\x07members\x18\x01 \x03(\x0b\x32W.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0.GroupMemberEntry\x12\x1c\n\x14group_required_power\x18\x02 \x01(\r\x1a\x8a\x01\n\tGroupInfo\x12n\n\ngroup_info\x18\x01 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0.GroupInfoEntryH\x00\x88\x01\x01\x42\r\n\x0b_group_infoB\x08\n\x06resultB\t\n\x07version\"\xed\x03\n\x14GetGroupInfosRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetGroupInfosRequest.GetGroupInfosRequestV0H\x00\x1au\n\x1cStartAtGroupContractPosition\x12%\n\x1dstart_group_contract_position\x18\x01 \x01(\r\x12.\n&start_group_contract_position_included\x18\x02 \x01(\x08\x1a\xfc\x01\n\x16GetGroupInfosRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12{\n start_at_group_contract_position\x18\x02 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetGroupInfosRequest.StartAtGroupContractPositionH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x04 \x01(\x08\x42#\n!_start_at_group_contract_positionB\x08\n\x06_countB\t\n\x07version\"\xff\x05\n\x15GetGroupInfosResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0H\x00\x1a\x82\x05\n\x17GetGroupInfosResponseV0\x12j\n\x0bgroup_infos\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0.GroupInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x04 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x34\n\x10GroupMemberEntry\x12\x11\n\tmember_id\x18\x01 \x01(\x0c\x12\r\n\x05power\x18\x02 \x01(\r\x1a\xc3\x01\n\x16GroupPositionInfoEntry\x12\x1f\n\x17group_contract_position\x18\x01 \x01(\r\x12j\n\x07members\x18\x02 \x03(\x0b\x32Y.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0.GroupMemberEntry\x12\x1c\n\x14group_required_power\x18\x03 \x01(\r\x1a\x82\x01\n\nGroupInfos\x12t\n\x0bgroup_infos\x18\x01 \x03(\x0b\x32_.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0.GroupPositionInfoEntryB\x08\n\x06resultB\t\n\x07version\"\xbe\x04\n\x16GetGroupActionsRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetGroupActionsRequest.GetGroupActionsRequestV0H\x00\x1aL\n\x0fStartAtActionId\x12\x17\n\x0fstart_action_id\x18\x01 \x01(\x0c\x12 \n\x18start_action_id_included\x18\x02 \x01(\x08\x1a\xc8\x02\n\x18GetGroupActionsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17group_contract_position\x18\x02 \x01(\r\x12N\n\x06status\x18\x03 \x01(\x0e\x32>.org.dash.platform.dapi.v0.GetGroupActionsRequest.ActionStatus\x12\x62\n\x12start_at_action_id\x18\x04 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetGroupActionsRequest.StartAtActionIdH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x42\x15\n\x13_start_at_action_idB\x08\n\x06_count\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\x92\"\n\x17GetGroupActionsResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0H\x00\x1a\x8f!\n\x19GetGroupActionsResponseV0\x12r\n\rgroup_actions\x18\x01 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.GroupActionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a[\n\tMintEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x14\n\x0crecipient_id\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a[\n\tBurnEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x14\n\x0c\x62urn_from_id\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1aJ\n\x0b\x46reezeEvent\x12\x11\n\tfrozen_id\x18\x01 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1aL\n\rUnfreezeEvent\x12\x11\n\tfrozen_id\x18\x01 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\x66\n\x17\x44\x65stroyFrozenFundsEvent\x12\x11\n\tfrozen_id\x18\x01 \x01(\x0c\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x04\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\x64\n\x13SharedEncryptedNote\x12\x18\n\x10sender_key_index\x18\x01 \x01(\r\x12\x1b\n\x13recipient_key_index\x18\x02 \x01(\r\x12\x16\n\x0e\x65ncrypted_data\x18\x03 \x01(\x0c\x1a{\n\x15PersonalEncryptedNote\x12!\n\x19root_encryption_key_index\x18\x01 \x01(\r\x12\'\n\x1f\x64\x65rivation_encryption_key_index\x18\x02 \x01(\r\x12\x16\n\x0e\x65ncrypted_data\x18\x03 \x01(\x0c\x1a\xe9\x01\n\x14\x45mergencyActionEvent\x12\x81\x01\n\x0b\x61\x63tion_type\x18\x01 \x01(\x0e\x32l.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.EmergencyActionEvent.ActionType\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\"#\n\nActionType\x12\t\n\x05PAUSE\x10\x00\x12\n\n\x06RESUME\x10\x01\x42\x0e\n\x0c_public_note\x1a\x64\n\x16TokenConfigUpdateEvent\x12 \n\x18token_config_update_item\x18\x01 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\xe6\x03\n\x1eUpdateDirectPurchasePriceEvent\x12\x15\n\x0b\x66ixed_price\x18\x01 \x01(\x04H\x00\x12\x95\x01\n\x0evariable_price\x18\x02 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UpdateDirectPurchasePriceEvent.PricingScheduleH\x00\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x01\x88\x01\x01\x1a\x33\n\x10PriceForQuantity\x12\x10\n\x08quantity\x18\x01 \x01(\x04\x12\r\n\x05price\x18\x02 \x01(\x04\x1a\xac\x01\n\x0fPricingSchedule\x12\x98\x01\n\x12price_for_quantity\x18\x01 \x03(\x0b\x32|.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UpdateDirectPurchasePriceEvent.PriceForQuantityB\x07\n\x05priceB\x0e\n\x0c_public_note\x1a\x63\n\x0fMintToPoolEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x16\n\x0e\x61\x63tions_digest\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\x65\n\x11\x42urnFromPoolEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x16\n\x0e\x61\x63tions_digest\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\xfc\x02\n\x10GroupActionEvent\x12n\n\x0btoken_event\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.TokenEventH\x00\x12t\n\x0e\x64ocument_event\x18\x02 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.DocumentEventH\x00\x12t\n\x0e\x63ontract_event\x18\x03 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.ContractEventH\x00\x42\x0c\n\nevent_type\x1a\x8b\x01\n\rDocumentEvent\x12r\n\x06\x63reate\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.DocumentCreateEventH\x00\x42\x06\n\x04type\x1a/\n\x13\x44ocumentCreateEvent\x12\x18\n\x10\x63reated_document\x18\x01 \x01(\x0c\x1a/\n\x13\x43ontractUpdateEvent\x12\x18\n\x10updated_contract\x18\x01 \x01(\x0c\x1a\x8b\x01\n\rContractEvent\x12r\n\x06update\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.ContractUpdateEventH\x00\x42\x06\n\x04type\x1a\xc1\t\n\nTokenEvent\x12\x66\n\x04mint\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.MintEventH\x00\x12\x66\n\x04\x62urn\x18\x02 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.BurnEventH\x00\x12j\n\x06\x66reeze\x18\x03 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.FreezeEventH\x00\x12n\n\x08unfreeze\x18\x04 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UnfreezeEventH\x00\x12\x84\x01\n\x14\x64\x65stroy_frozen_funds\x18\x05 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.DestroyFrozenFundsEventH\x00\x12}\n\x10\x65mergency_action\x18\x06 \x01(\x0b\x32\x61.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.EmergencyActionEventH\x00\x12\x82\x01\n\x13token_config_update\x18\x07 \x01(\x0b\x32\x63.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.TokenConfigUpdateEventH\x00\x12\x83\x01\n\x0cupdate_price\x18\x08 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UpdateDirectPurchasePriceEventH\x00\x12t\n\x0cmint_to_pool\x18\t \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.MintToPoolEventH\x00\x12x\n\x0e\x62urn_from_pool\x18\n \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.BurnFromPoolEventH\x00\x42\x06\n\x04type\x1a\x93\x01\n\x10GroupActionEntry\x12\x11\n\taction_id\x18\x01 \x01(\x0c\x12l\n\x05\x65vent\x18\x02 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.GroupActionEvent\x1a\x84\x01\n\x0cGroupActions\x12t\n\rgroup_actions\x18\x01 \x03(\x0b\x32].org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.GroupActionEntryB\x08\n\x06resultB\t\n\x07version\"\x88\x03\n\x1cGetGroupActionSignersRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetGroupActionSignersRequest.GetGroupActionSignersRequestV0H\x00\x1a\xce\x01\n\x1eGetGroupActionSignersRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17group_contract_position\x18\x02 \x01(\r\x12T\n\x06status\x18\x03 \x01(\x0e\x32\x44.org.dash.platform.dapi.v0.GetGroupActionSignersRequest.ActionStatus\x12\x11\n\taction_id\x18\x04 \x01(\x0c\x12\r\n\x05prove\x18\x05 \x01(\x08\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\x8b\x05\n\x1dGetGroupActionSignersResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetGroupActionSignersResponse.GetGroupActionSignersResponseV0H\x00\x1a\xf6\x03\n\x1fGetGroupActionSignersResponseV0\x12\x8b\x01\n\x14group_action_signers\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetGroupActionSignersResponse.GetGroupActionSignersResponseV0.GroupActionSignersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x35\n\x11GroupActionSigner\x12\x11\n\tsigner_id\x18\x01 \x01(\x0c\x12\r\n\x05power\x18\x02 \x01(\r\x1a\x91\x01\n\x12GroupActionSigners\x12{\n\x07signers\x18\x01 \x03(\x0b\x32j.org.dash.platform.dapi.v0.GetGroupActionSignersResponse.GetGroupActionSignersResponseV0.GroupActionSignerB\x08\n\x06resultB\t\n\x07version\"\xb5\x01\n\x15GetAddressInfoRequest\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetAddressInfoRequest.GetAddressInfoRequestV0H\x00\x1a\x39\n\x17GetAddressInfoRequestV0\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x85\x01\n\x10\x41\x64\x64ressInfoEntry\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12J\n\x11\x62\x61lance_and_nonce\x18\x02 \x01(\x0b\x32*.org.dash.platform.dapi.v0.BalanceAndNonceH\x00\x88\x01\x01\x42\x14\n\x12_balance_and_nonce\"1\n\x0f\x42\x61lanceAndNonce\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\r\n\x05nonce\x18\x02 \x01(\r\"_\n\x12\x41\x64\x64ressInfoEntries\x12I\n\x14\x61\x64\x64ress_info_entries\x18\x01 \x03(\x0b\x32+.org.dash.platform.dapi.v0.AddressInfoEntry\"m\n\x14\x41\x64\x64ressBalanceChange\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12\x19\n\x0bset_balance\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12\x1c\n\x0e\x61\x64\x64_to_balance\x18\x03 \x01(\x04\x42\x02\x30\x01H\x00\x42\x0b\n\toperation\"x\n\x1a\x42lockAddressBalanceChanges\x12\x18\n\x0c\x62lock_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12@\n\x07\x63hanges\x18\x02 \x03(\x0b\x32/.org.dash.platform.dapi.v0.AddressBalanceChange\"k\n\x1b\x41\x64\x64ressBalanceUpdateEntries\x12L\n\rblock_changes\x18\x01 \x03(\x0b\x32\x35.org.dash.platform.dapi.v0.BlockAddressBalanceChanges\"\xe1\x02\n\x16GetAddressInfoResponse\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetAddressInfoResponse.GetAddressInfoResponseV0H\x00\x1a\xe1\x01\n\x18GetAddressInfoResponseV0\x12I\n\x12\x61\x64\x64ress_info_entry\x18\x01 \x01(\x0b\x32+.org.dash.platform.dapi.v0.AddressInfoEntryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc3\x01\n\x18GetAddressesInfosRequest\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetAddressesInfosRequest.GetAddressesInfosRequestV0H\x00\x1a>\n\x1aGetAddressesInfosRequestV0\x12\x11\n\taddresses\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf1\x02\n\x19GetAddressesInfosResponse\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetAddressesInfosResponse.GetAddressesInfosResponseV0H\x00\x1a\xe8\x01\n\x1bGetAddressesInfosResponseV0\x12M\n\x14\x61\x64\x64ress_info_entries\x18\x01 \x01(\x0b\x32-.org.dash.platform.dapi.v0.AddressInfoEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb5\x01\n\x1dGetAddressesTrunkStateRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetAddressesTrunkStateRequest.GetAddressesTrunkStateRequestV0H\x00\x1a!\n\x1fGetAddressesTrunkStateRequestV0B\t\n\x07version\"\xaa\x02\n\x1eGetAddressesTrunkStateResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetAddressesTrunkStateResponse.GetAddressesTrunkStateResponseV0H\x00\x1a\x92\x01\n GetAddressesTrunkStateResponseV0\x12/\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.Proof\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\t\n\x07version\"\xf0\x01\n\x1eGetAddressesBranchStateRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetAddressesBranchStateRequest.GetAddressesBranchStateRequestV0H\x00\x1aY\n GetAddressesBranchStateRequestV0\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\r\n\x05\x64\x65pth\x18\x02 \x01(\r\x12\x19\n\x11\x63heckpoint_height\x18\x03 \x01(\x04\x42\t\n\x07version\"\xd1\x01\n\x1fGetAddressesBranchStateResponse\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetAddressesBranchStateResponse.GetAddressesBranchStateResponseV0H\x00\x1a\x37\n!GetAddressesBranchStateResponseV0\x12\x12\n\nmerk_proof\x18\x02 \x01(\x0c\x42\t\n\x07version\"\x9e\x02\n%GetRecentAddressBalanceChangesRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesRequest.GetRecentAddressBalanceChangesRequestV0H\x00\x1ar\n\'GetRecentAddressBalanceChangesRequestV0\x12\x18\n\x0cstart_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x02 \x01(\x08\x12\x1e\n\x16start_height_exclusive\x18\x03 \x01(\x08\x42\t\n\x07version\"\xb8\x03\n&GetRecentAddressBalanceChangesResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesResponse.GetRecentAddressBalanceChangesResponseV0H\x00\x1a\x88\x02\n(GetRecentAddressBalanceChangesResponseV0\x12`\n\x1e\x61\x64\x64ress_balance_update_entries\x18\x01 \x01(\x0b\x32\x36.org.dash.platform.dapi.v0.AddressBalanceUpdateEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"G\n\x16\x42lockHeightCreditEntry\x12\x18\n\x0c\x62lock_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x13\n\x07\x63redits\x18\x02 \x01(\x04\x42\x02\x30\x01\"\xb0\x01\n\x1d\x43ompactedAddressBalanceChange\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12\x19\n\x0bset_credits\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12V\n\x19\x61\x64\x64_to_credits_operations\x18\x03 \x01(\x0b\x32\x31.org.dash.platform.dapi.v0.AddToCreditsOperationsH\x00\x42\x0b\n\toperation\"\\\n\x16\x41\x64\x64ToCreditsOperations\x12\x42\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x31.org.dash.platform.dapi.v0.BlockHeightCreditEntry\"\xae\x01\n#CompactedBlockAddressBalanceChanges\x12\x1e\n\x12start_block_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1c\n\x10\x65nd_block_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12I\n\x07\x63hanges\x18\x03 \x03(\x0b\x32\x38.org.dash.platform.dapi.v0.CompactedAddressBalanceChange\"\x87\x01\n$CompactedAddressBalanceUpdateEntries\x12_\n\x17\x63ompacted_block_changes\x18\x01 \x03(\x0b\x32>.org.dash.platform.dapi.v0.CompactedBlockAddressBalanceChanges\"\xa9\x02\n.GetRecentCompactedAddressBalanceChangesRequest\x12\x88\x01\n\x02v0\x18\x01 \x01(\x0b\x32z.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesRequest.GetRecentCompactedAddressBalanceChangesRequestV0H\x00\x1a\x61\n0GetRecentCompactedAddressBalanceChangesRequestV0\x12\x1e\n\x12start_block_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf0\x03\n/GetRecentCompactedAddressBalanceChangesResponse\x12\x8a\x01\n\x02v0\x18\x01 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesResponse.GetRecentCompactedAddressBalanceChangesResponseV0H\x00\x1a\xa4\x02\n1GetRecentCompactedAddressBalanceChangesResponseV0\x12s\n(compacted_address_balance_update_entries\x18\x01 \x01(\x0b\x32?.org.dash.platform.dapi.v0.CompactedAddressBalanceUpdateEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x98\x02\n GetShieldedEncryptedNotesRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesRequest.GetShieldedEncryptedNotesRequestV0H\x00\x1a{\n\"GetShieldedEncryptedNotesRequestV0\x12\x13\n\x0bstart_index\x18\x01 \x01(\x04\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x12\x15\n\x08token_id\x18\x04 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xbc\x05\n!GetShieldedEncryptedNotesResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse.GetShieldedEncryptedNotesResponseV0H\x00\x1a\x9b\x04\n#GetShieldedEncryptedNotesResponseV0\x12\x8a\x01\n\x0f\x65ncrypted_notes\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse.GetShieldedEncryptedNotesResponseV0.EncryptedNotesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aW\n\rEncryptedNote\x12\x11\n\tnullifier\x18\x01 \x01(\x0c\x12\x0b\n\x03\x63mx\x18\x02 \x01(\x0c\x12\x16\n\x0e\x65ncrypted_note\x18\x03 \x01(\x0c\x12\x0e\n\x06\x63v_net\x18\x04 \x01(\x0c\x1a\x91\x01\n\x0e\x45ncryptedNotes\x12\x7f\n\x07\x65ntries\x18\x01 \x03(\x0b\x32n.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse.GetShieldedEncryptedNotesResponseV0.EncryptedNoteB\x08\n\x06resultB\t\n\x07version\"\xd8\x01\n\x19GetShieldedAnchorsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetShieldedAnchorsRequest.GetShieldedAnchorsRequestV0H\x00\x1aP\n\x1bGetShieldedAnchorsRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xb1\x03\n\x1aGetShieldedAnchorsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetShieldedAnchorsResponse.GetShieldedAnchorsResponseV0H\x00\x1a\xa5\x02\n\x1cGetShieldedAnchorsResponseV0\x12m\n\x07\x61nchors\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetShieldedAnchorsResponse.GetShieldedAnchorsResponseV0.AnchorsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x07\x41nchors\x12\x0f\n\x07\x61nchors\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xfc\x01\n\"GetMostRecentShieldedAnchorRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorRequest.GetMostRecentShieldedAnchorRequestV0H\x00\x1aY\n$GetMostRecentShieldedAnchorRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xdc\x02\n#GetMostRecentShieldedAnchorResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorResponse.GetMostRecentShieldedAnchorResponseV0H\x00\x1a\xb5\x01\n%GetMostRecentShieldedAnchorResponseV0\x12\x10\n\x06\x61nchor\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe0\x01\n\x1bGetShieldedPoolStateRequest\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetShieldedPoolStateRequest.GetShieldedPoolStateRequestV0H\x00\x1aR\n\x1dGetShieldedPoolStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xcb\x02\n\x1cGetShieldedPoolStateResponse\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetShieldedPoolStateResponse.GetShieldedPoolStateResponseV0H\x00\x1a\xb9\x01\n\x1eGetShieldedPoolStateResponseV0\x12\x1b\n\rtotal_balance\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe4\x01\n\x1cGetShieldedNotesCountRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetShieldedNotesCountRequest.GetShieldedNotesCountRequestV0H\x00\x1aS\n\x1eGetShieldedNotesCountRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xd3\x02\n\x1dGetShieldedNotesCountResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetShieldedNotesCountResponse.GetShieldedNotesCountResponseV0H\x00\x1a\xbe\x01\n\x1fGetShieldedNotesCountResponseV0\x12\x1f\n\x11total_notes_count\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf8\x01\n\x1cGetShieldedNullifiersRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetShieldedNullifiersRequest.GetShieldedNullifiersRequestV0H\x00\x1ag\n\x1eGetShieldedNullifiersRequestV0\x12\x12\n\nnullifiers\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x12\x15\n\x08token_id\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\x86\x05\n\x1dGetShieldedNullifiersResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse.GetShieldedNullifiersResponseV0H\x00\x1a\xf1\x03\n\x1fGetShieldedNullifiersResponseV0\x12\x88\x01\n\x12nullifier_statuses\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse.GetShieldedNullifiersResponseV0.NullifierStatusesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x36\n\x0fNullifierStatus\x12\x11\n\tnullifier\x18\x01 \x01(\x0c\x12\x10\n\x08is_spent\x18\x02 \x01(\x08\x1a\x8e\x01\n\x11NullifierStatuses\x12y\n\x07\x65ntries\x18\x01 \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse.GetShieldedNullifiersResponseV0.NullifierStatusB\x08\n\x06resultB\t\n\x07version\"\xb0\x02\n GetPrivateDocumentEntriesRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesRequest.GetPrivateDocumentEntriesRequestV0H\x00\x1a\x92\x01\n\"GetPrivateDocumentEntriesRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x1a\n\x0estart_position\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x05 \x01(\x08J\x04\x08\x04\x10\x05R\x05\x63ountB\t\n\x07version\"\xfd\x05\n!GetPrivateDocumentEntriesResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse.GetPrivateDocumentEntriesResponseV0H\x00\x1a\xdc\x04\n#GetPrivateDocumentEntriesResponseV0\x12\x8a\x01\n\x07\x65ntries\x18\x01 \x01(\x0b\x32w.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse.GetPrivateDocumentEntriesResponseV0.PrivateDocumentEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ao\n\x14PrivateDocumentEntry\x12\x14\n\x08position\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x18\n\x0c\x62lock_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x19\n\rblock_time_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\x0c\n\x04\x64\x61ta\x18\x04 \x01(\x0c\x1a\xba\x01\n\x16PrivateDocumentEntries\x12\x86\x01\n\x07\x65ntries\x18\x01 \x03(\x0b\x32u.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse.GetPrivateDocumentEntriesResponseV0.PrivateDocumentEntry\x12\x17\n\x0btotal_count\x18\x02 \x01(\x04\x42\x02\x30\x01\x42\x08\n\x06resultB\t\n\x07version\"\xec\x06\n\x14TenderdashBlockProof\x12\x46\n\x06header\x18\x01 \x01(\x0b\x32\x36.org.dash.platform.dapi.v0.TenderdashBlockProof.Header\x12I\n\x08\x62lock_id\x18\x02 \x01(\x0b\x32\x37.org.dash.platform.dapi.v0.TenderdashBlockProof.BlockId\x12\r\n\x05round\x18\x03 \x01(\r\x12\x13\n\x0bquorum_hash\x18\x04 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x05 \x01(\r\x12\x11\n\tsignature\x18\x06 \x01(\x0c\x1aX\n\x07\x42lockId\x12\x0c\n\x04hash\x18\x01 \x01(\x0c\x12\x16\n\x0epart_set_total\x18\x02 \x01(\r\x12\x15\n\rpart_set_hash\x18\x03 \x01(\x0c\x12\x10\n\x08state_id\x18\x04 \x01(\x0c\x1a\x9a\x04\n\x06Header\x12\x19\n\rblock_version\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x17\n\x0b\x61pp_version\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x08\x63hain_id\x18\x03 \x01(\t\x12\x12\n\x06height\x18\x04 \x01(\x04\x42\x02\x30\x01\x12 \n\x18\x63ore_chain_locked_height\x18\x05 \x01(\r\x12\x18\n\x0ctime_seconds\x18\x06 \x01(\x03\x42\x02\x30\x01\x12\x12\n\ntime_nanos\x18\x07 \x01(\x05\x12N\n\rlast_block_id\x18\x08 \x01(\x0b\x32\x37.org.dash.platform.dapi.v0.TenderdashBlockProof.BlockId\x12\x18\n\x10last_commit_hash\x18\t \x01(\x0c\x12\x11\n\tdata_hash\x18\n \x01(\x0c\x12\x17\n\x0fvalidators_hash\x18\x0b \x01(\x0c\x12\x1c\n\x14next_validators_hash\x18\x0c \x01(\x0c\x12\x16\n\x0e\x63onsensus_hash\x18\r \x01(\x0c\x12\x1b\n\x13next_consensus_hash\x18\x0e \x01(\x0c\x12\x10\n\x08\x61pp_hash\x18\x0f \x01(\x0c\x12\x14\n\x0cresults_hash\x18\x10 \x01(\x0c\x12\x15\n\revidence_hash\x18\x11 \x01(\x0c\x12\x1c\n\x14proposer_pro_tx_hash\x18\x12 \x01(\x0c\x12 \n\x14proposed_app_version\x18\x13 \x01(\x04\x42\x02\x30\x01\"i\n\x1aTenderdashTransactionProof\x12\r\n\x05index\x18\x01 \x01(\r\x12\r\n\x05total\x18\x02 \x01(\r\x12\x18\n\x10transaction_path\x18\x03 \x03(\x0c\x12\x13\n\x0bresult_path\x18\x04 \x03(\x0c\"\xfe\x01\n\"GetOwnerTransactionsInBlockRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockRequest.GetOwnerTransactionsInBlockRequestV0H\x00\x1a[\n$GetOwnerTransactionsInBlockRequestV0\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x08owner_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xd8\x04\n#GetOwnerTransactionsInBlockResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockResponse.GetOwnerTransactionsInBlockResponseV0H\x00\x1a\xb1\x03\n%GetOwnerTransactionsInBlockResponseV0\x12\x8b\x01\n\x0ctransactions\x18\x01 \x03(\x0b\x32u.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockResponse.GetOwnerTransactionsInBlockResponseV0.OwnerTransaction\x12>\n\x05proof\x18\x02 \x01(\x0b\x32/.org.dash.platform.dapi.v0.TenderdashBlockProof\x1a\xb9\x01\n\x10OwnerTransaction\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\x12\x0c\n\x04hash\x18\x02 \x01(\x0c\x12\x0c\n\x04\x63ode\x18\x03 \x01(\r\x12\x13\n\x0bresult_data\x18\x04 \x01(\x0c\x12\x14\n\x08gas_used\x18\x05 \x01(\x03\x42\x02\x30\x01\x12\x44\n\x05proof\x18\x06 \x01(\x0b\x32\x35.org.dash.platform.dapi.v0.TenderdashTransactionProofB\t\n\x07version\"\xb9\x01\n\x10GetBlocksRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetBlocksRequest.GetBlocksRequestV0H\x00\x1aL\n\x12GetBlocksRequestV0\x12\x18\n\x0cstart_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\x85\x05\n\x11GetBlocksResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetBlocksResponse.GetBlocksResponseV0H\x00\x1a\x94\x04\n\x13GetBlocksResponseV0\x12V\n\x06\x62locks\x18\x01 \x03(\x0b\x32\x46.org.dash.platform.dapi.v0.GetBlocksResponse.GetBlocksResponseV0.Block\x1an\n\x0bTransaction\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\x12\x0c\n\x04hash\x18\x02 \x01(\x0c\x12\x0c\n\x04\x63ode\x18\x03 \x01(\r\x12\x13\n\x0bresult_data\x18\x04 \x01(\x0c\x12\x14\n\x08gas_used\x18\x05 \x01(\x03\x42\x02\x30\x01\x1a\xb4\x02\n\x05\x42lock\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x0c\n\x04hash\x18\x02 \x01(\x0c\x12\x13\n\x07time_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12 \n\x18\x63ore_chain_locked_height\x18\x04 \x01(\r\x12\x10\n\x08\x61pp_hash\x18\x05 \x01(\x0c\x12\x1c\n\x14proposer_pro_tx_hash\x18\x06 \x01(\x0c\x12\x62\n\x0ctransactions\x18\x07 \x03(\x0b\x32L.org.dash.platform.dapi.v0.GetBlocksResponse.GetBlocksResponseV0.Transaction\x12>\n\x05proof\x18\x08 \x01(\x0b\x32/.org.dash.platform.dapi.v0.TenderdashBlockProofB\t\n\x07version*Z\n\nKeyPurpose\x12\x12\n\x0e\x41UTHENTICATION\x10\x00\x12\x0e\n\nENCRYPTION\x10\x01\x12\x0e\n\nDECRYPTION\x10\x02\x12\x0c\n\x08TRANSFER\x10\x03\x12\n\n\x06VOTING\x10\x05*\xb9\x01\n\x16\x43ontractModerationList\x12(\n$CONTRACT_MODERATION_LIST_UNSPECIFIED\x10\x00\x12$\n CONTRACT_MODERATION_LIST_BANLIST\x10\x01\x12(\n$CONTRACT_MODERATION_LIST_SUSPENSIONS\x10\x02\x12%\n!CONTRACT_MODERATION_LIST_WARNINGS\x10\x03\x32\x98[\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12\x96\x01\n\x19getIdentitiesContractKeys\x12;.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest\x1a<.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse\x12{\n\x10getIdentityNonce\x12\x32.org.dash.platform.dapi.v0.GetIdentityNonceRequest\x1a\x33.org.dash.platform.dapi.v0.GetIdentityNonceResponse\x12\x93\x01\n\x18getIdentityContractNonce\x12:.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse\x12\xa8\x01\n\x1fgetIdentityKeysRemainingBudgets\x12\x41.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsRequest\x1a\x42.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\x8a\x01\n\x15getIdentitiesBalances\x12\x37.org.dash.platform.dapi.v0.GetIdentitiesBalancesRequest\x1a\x38.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\xaf\x01\n#getEvonodesProposedEpochBlocksByIds\x12\x45.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByIdsRequest\x1a\x41.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse\x12\xb3\x01\n%getEvonodesProposedEpochBlocksByRange\x12G.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByRangeRequest\x1a\x41.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12\xa5\x01\n\x1egetDataContractsLatestVersions\x12@.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsRequest\x1a\x41.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12\x89\x01\n\x17getDataContractsByRange\x12\x39.org.dash.platform.dapi.v0.GetDataContractsByRangeRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12\x87\x01\n\x14getContractGroupInfo\x12\x36.org.dash.platform.dapi.v0.GetContractGroupInfoRequest\x1a\x37.org.dash.platform.dapi.v0.GetContractGroupInfoResponse\x12\x90\x01\n\x17getContractGroupMembers\x12\x39.org.dash.platform.dapi.v0.GetContractGroupMembersRequest\x1a:.org.dash.platform.dapi.v0.GetContractGroupMembersResponse\x12\x9f\x01\n\x1cgetContractGroupsForContract\x12>.org.dash.platform.dapi.v0.GetContractGroupsForContractRequest\x1a?.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse\x12\x9c\x01\n\x1bgetContractModerationStatus\x12=.org.dash.platform.dapi.v0.GetContractModerationStatusRequest\x1a>.org.dash.platform.dapi.v0.GetContractModerationStatusResponse\x12\x9f\x01\n\x1cgetContractModerationEntries\x12>.org.dash.platform.dapi.v0.GetContractModerationEntriesRequest\x1a?.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse\x12\x9c\x01\n\x1bgetContractDocumentRemovals\x12=.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest\x1a>.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse\x12\x8d\x01\n\x16getContractTeamActions\x12\x38.org.dash.platform.dapi.v0.GetContractTeamActionsRequest\x1a\x39.org.dash.platform.dapi.v0.GetContractTeamActionsResponse\x12\x9f\x01\n\x1cgetContractTeamActionSigners\x12>.org.dash.platform.dapi.v0.GetContractTeamActionSignersRequest\x1a?.org.dash.platform.dapi.v0.GetContractTeamActionSignersResponse\x12\xae\x01\n!getContractModerationActionCounts\x12\x43.org.dash.platform.dapi.v0.GetContractModerationActionCountsRequest\x1a\x44.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse\x12\x81\x01\n\x12getContractFeePots\x12\x34.org.dash.platform.dapi.v0.GetContractFeePotsRequest\x1a\x35.org.dash.platform.dapi.v0.GetContractFeePotsResponse\x12\x81\x01\n\x12getDocumentHistory\x12\x34.org.dash.platform.dapi.v0.GetDocumentHistoryRequest\x1a\x35.org.dash.platform.dapi.v0.GetDocumentHistoryResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\xb4\x01\n#getIdentityByNonUniquePublicKeyHash\x12\x45.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashRequest\x1a\x46.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\xa5\x01\n\x1egetRecentStateTransitionStatus\x12@.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusRequest\x1a\x41.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponse\x12\x8d\x01\n\x16getFinalizedEpochInfos\x12\x38.org.dash.platform.dapi.v0.GetFinalizedEpochInfosRequest\x1a\x39.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse\x12\x8a\x01\n\x15getContestedResources\x12\x37.org.dash.platform.dapi.v0.GetContestedResourcesRequest\x1a\x38.org.dash.platform.dapi.v0.GetContestedResourcesResponse\x12\xa2\x01\n\x1dgetContestedResourceVoteState\x12?.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest\x1a@.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse\x12\xba\x01\n%getContestedResourceVotersForIdentity\x12G.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest\x1aH.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse\x12\xae\x01\n!getContestedResourceIdentityVotes\x12\x43.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest\x1a\x44.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse\x12\x8a\x01\n\x15getVotePollsByEndDate\x12\x37.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest\x1a\x38.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse\x12\x8a\x01\n\x15getYesNoVotePollState\x12\x37.org.dash.platform.dapi.v0.GetYesNoVotePollStateRequest\x1a\x38.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse\x12\x8d\x01\n\x16getMasternodeYesNoVote\x12\x38.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteRequest\x1a\x39.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse\x12\xa5\x01\n\x1egetPrefundedSpecializedBalance\x12@.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest\x1a\x41.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse\x12\x96\x01\n\x19getTotalCreditsInPlatform\x12;.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest\x1a<.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse\x12x\n\x0fgetPathElements\x12\x31.org.dash.platform.dapi.v0.GetPathElementsRequest\x1a\x32.org.dash.platform.dapi.v0.GetPathElementsResponse\x12\x66\n\tgetStatus\x12+.org.dash.platform.dapi.v0.GetStatusRequest\x1a,.org.dash.platform.dapi.v0.GetStatusResponse\x12\x8a\x01\n\x15getCurrentQuorumsInfo\x12\x37.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest\x1a\x38.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse\x12\x93\x01\n\x18getIdentityTokenBalances\x12:.org.dash.platform.dapi.v0.GetIdentityTokenBalancesRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse\x12\x99\x01\n\x1agetIdentitiesTokenBalances\x12<.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesRequest\x1a=.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse\x12\x8a\x01\n\x15getIdentityTokenInfos\x12\x37.org.dash.platform.dapi.v0.GetIdentityTokenInfosRequest\x1a\x38.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse\x12\x90\x01\n\x17getIdentitiesTokenInfos\x12\x39.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosRequest\x1a:.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse\x12{\n\x10getTokenStatuses\x12\x32.org.dash.platform.dapi.v0.GetTokenStatusesRequest\x1a\x33.org.dash.platform.dapi.v0.GetTokenStatusesResponse\x12\x9f\x01\n\x1cgetTokenDirectPurchasePrices\x12>.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesRequest\x1a?.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse\x12\x87\x01\n\x14getTokenContractInfo\x12\x36.org.dash.platform.dapi.v0.GetTokenContractInfoRequest\x1a\x37.org.dash.platform.dapi.v0.GetTokenContractInfoResponse\x12\xb1\x01\n\"getTokenPreProgrammedDistributions\x12\x44.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsRequest\x1a\x45.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse\x12\xbd\x01\n&getTokenPerpetualDistributionLastClaim\x12H.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimRequest\x1aI.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimResponse\x12\x84\x01\n\x13getTokenTotalSupply\x12\x35.org.dash.platform.dapi.v0.GetTokenTotalSupplyRequest\x1a\x36.org.dash.platform.dapi.v0.GetTokenTotalSupplyResponse\x12o\n\x0cgetGroupInfo\x12..org.dash.platform.dapi.v0.GetGroupInfoRequest\x1a/.org.dash.platform.dapi.v0.GetGroupInfoResponse\x12r\n\rgetGroupInfos\x12/.org.dash.platform.dapi.v0.GetGroupInfosRequest\x1a\x30.org.dash.platform.dapi.v0.GetGroupInfosResponse\x12x\n\x0fgetGroupActions\x12\x31.org.dash.platform.dapi.v0.GetGroupActionsRequest\x1a\x32.org.dash.platform.dapi.v0.GetGroupActionsResponse\x12\x8a\x01\n\x15getGroupActionSigners\x12\x37.org.dash.platform.dapi.v0.GetGroupActionSignersRequest\x1a\x38.org.dash.platform.dapi.v0.GetGroupActionSignersResponse\x12u\n\x0egetAddressInfo\x12\x30.org.dash.platform.dapi.v0.GetAddressInfoRequest\x1a\x31.org.dash.platform.dapi.v0.GetAddressInfoResponse\x12~\n\x11getAddressesInfos\x12\x33.org.dash.platform.dapi.v0.GetAddressesInfosRequest\x1a\x34.org.dash.platform.dapi.v0.GetAddressesInfosResponse\x12\x8d\x01\n\x16getAddressesTrunkState\x12\x38.org.dash.platform.dapi.v0.GetAddressesTrunkStateRequest\x1a\x39.org.dash.platform.dapi.v0.GetAddressesTrunkStateResponse\x12\x90\x01\n\x17getAddressesBranchState\x12\x39.org.dash.platform.dapi.v0.GetAddressesBranchStateRequest\x1a:.org.dash.platform.dapi.v0.GetAddressesBranchStateResponse\x12\xa5\x01\n\x1egetRecentAddressBalanceChanges\x12@.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesRequest\x1a\x41.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesResponse\x12\xc0\x01\n\'getRecentCompactedAddressBalanceChanges\x12I.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesRequest\x1aJ.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesResponse\x12\x96\x01\n\x19getShieldedEncryptedNotes\x12;.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesRequest\x1a<.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse\x12\x81\x01\n\x12getShieldedAnchors\x12\x34.org.dash.platform.dapi.v0.GetShieldedAnchorsRequest\x1a\x35.org.dash.platform.dapi.v0.GetShieldedAnchorsResponse\x12\x9c\x01\n\x1bgetMostRecentShieldedAnchor\x12=.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorRequest\x1a>.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorResponse\x12\x87\x01\n\x14getShieldedPoolState\x12\x36.org.dash.platform.dapi.v0.GetShieldedPoolStateRequest\x1a\x37.org.dash.platform.dapi.v0.GetShieldedPoolStateResponse\x12\x8a\x01\n\x15getShieldedNotesCount\x12\x37.org.dash.platform.dapi.v0.GetShieldedNotesCountRequest\x1a\x38.org.dash.platform.dapi.v0.GetShieldedNotesCountResponse\x12\x8a\x01\n\x15getShieldedNullifiers\x12\x37.org.dash.platform.dapi.v0.GetShieldedNullifiersRequest\x1a\x38.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse\x12\x96\x01\n\x19getPrivateDocumentEntries\x12;.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesRequest\x1a<.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse\x12\x9c\x01\n\x1bgetOwnerTransactionsInBlock\x12=.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockRequest\x1a>.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockResponse\x12\x66\n\tgetBlocks\x12+.org.dash.platform.dapi.v0.GetBlocksRequest\x1a,.org.dash.platform.dapi.v0.GetBlocksResponseb\x06proto3' + serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x98\x01\n\x10ResponseMetadata\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x13\n\x07time_ms\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc1\x01\n\x17GetIdentityNonceRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityNonceRequest.GetIdentityNonceRequestV0H\x00\x1a?\n\x19GetIdentityNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf6\x01\n\x1fGetIdentityContractNonceRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest.GetIdentityContractNonceRequestV0H\x00\x1a\\\n!GetIdentityContractNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xbc\x02\n\x18GetIdentityNonceResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetIdentityNonceResponse.GetIdentityNonceResponseV0H\x00\x1a\xb6\x01\n\x1aGetIdentityNonceResponseV0\x12\x1c\n\x0eidentity_nonce\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe5\x02\n GetIdentityContractNonceResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse.GetIdentityContractNonceResponseV0H\x00\x1a\xc7\x01\n\"GetIdentityContractNonceResponseV0\x12%\n\x17identity_contract_nonce\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x8e\x02\n&GetIdentityKeysRemainingBudgetsRequest\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsRequest.GetIdentityKeysRemainingBudgetsRequestV0H\x00\x1a_\n(GetIdentityKeysRemainingBudgetsRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x0f\n\x07key_ids\x18\x02 \x03(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\x96\x06\n\'GetIdentityKeysRemainingBudgetsResponse\x12z\n\x02v0\x18\x01 \x01(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse.GetIdentityKeysRemainingBudgetsResponseV0H\x00\x1a\xe3\x04\n)GetIdentityKeysRemainingBudgetsResponseV0\x12\xa4\x01\n\x16keys_remaining_budgets\x18\x01 \x01(\x0b\x32\x81\x01.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse.GetIdentityKeysRemainingBudgetsResponseV0.KeysRemainingBudgetsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x61\n\x17KeyRemainingBudgetEntry\x12\x0e\n\x06key_id\x18\x01 \x01(\r\x12!\n\x10remaining_budget\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x42\x13\n\x11_remaining_budget\x1a\xaf\x01\n\x14KeysRemainingBudgets\x12\x96\x01\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse.GetIdentityKeysRemainingBudgetsResponseV0.KeyRemainingBudgetEntryB\x08\n\x06resultB\t\n\x07version\"\xbd\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xb1\x01\n\x1cGetIdentityBalanceResponseV0\x12\x15\n\x07\x62\x61lance\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb1\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\x84\x03\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a?\n\x12\x42\x61lanceAndRevision\x12\x13\n\x07\x62\x61lance\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x14\n\x08revision\x18\x02 \x01(\x04\x42\x02\x30\x01\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xef\x02\n GetIdentitiesContractKeysRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest.GetIdentitiesContractKeysRequestV0H\x00\x1a\xd1\x01\n\"GetIdentitiesContractKeysRequestV0\x12\x16\n\x0eidentities_ids\x18\x01 \x03(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\x1f\n\x12\x64ocument_type_name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x37\n\x08purposes\x18\x04 \x03(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x15\n\x13_document_type_nameB\t\n\x07version\"\xdf\x06\n!GetIdentitiesContractKeysResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0H\x00\x1a\xbe\x05\n#GetIdentitiesContractKeysResponseV0\x12\x8a\x01\n\x0fidentities_keys\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentitiesKeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aY\n\x0bPurposeKeys\x12\x36\n\x07purpose\x18\x01 \x01(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\x12\n\nkeys_bytes\x18\x02 \x03(\x0c\x1a\x9f\x01\n\x0cIdentityKeys\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12z\n\x04keys\x18\x02 \x03(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.PurposeKeys\x1a\x90\x01\n\x0eIdentitiesKeys\x12~\n\x07\x65ntries\x18\x01 \x03(\x0b\x32m.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentityKeysB\x08\n\x06resultB\t\n\x07version\"\xa4\x02\n*GetEvonodesProposedEpochBlocksByIdsRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByIdsRequest.GetEvonodesProposedEpochBlocksByIdsRequestV0H\x00\x1ah\n,GetEvonodesProposedEpochBlocksByIdsRequestV0\x12\x12\n\x05\x65poch\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x0b\n\x03ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\x08\n\x06_epochB\t\n\x07version\"\x92\x06\n&GetEvonodesProposedEpochBlocksResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse.GetEvonodesProposedEpochBlocksResponseV0H\x00\x1a\xe2\x04\n(GetEvonodesProposedEpochBlocksResponseV0\x12\xb1\x01\n#evonodes_proposed_block_counts_info\x18\x01 \x01(\x0b\x32\x81\x01.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse.GetEvonodesProposedEpochBlocksResponseV0.EvonodesProposedBlocksH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a?\n\x15\x45vonodeProposedBlocks\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x11\n\x05\x63ount\x18\x02 \x01(\x04\x42\x02\x30\x01\x1a\xc4\x01\n\x16\x45vonodesProposedBlocks\x12\xa9\x01\n\x1e\x65vonodes_proposed_block_counts\x18\x01 \x03(\x0b\x32\x80\x01.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse.GetEvonodesProposedEpochBlocksResponseV0.EvonodeProposedBlocksB\x08\n\x06resultB\t\n\x07version\"\xf2\x02\n,GetEvonodesProposedEpochBlocksByRangeRequest\x12\x84\x01\n\x02v0\x18\x01 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByRangeRequest.GetEvonodesProposedEpochBlocksByRangeRequestV0H\x00\x1a\xaf\x01\n.GetEvonodesProposedEpochBlocksByRangeRequestV0\x12\x12\n\x05\x65poch\x18\x01 \x01(\rH\x01\x88\x01\x01\x12\x12\n\x05limit\x18\x02 \x01(\rH\x02\x88\x01\x01\x12\x15\n\x0bstart_after\x18\x03 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x04 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x07\n\x05startB\x08\n\x06_epochB\x08\n\x06_limitB\t\n\x07version\"\xcd\x01\n\x1cGetIdentitiesBalancesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetIdentitiesBalancesRequest.GetIdentitiesBalancesRequestV0H\x00\x1a<\n\x1eGetIdentitiesBalancesRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9f\x05\n\x1dGetIdentitiesBalancesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse.GetIdentitiesBalancesResponseV0H\x00\x1a\x8a\x04\n\x1fGetIdentitiesBalancesResponseV0\x12\x8a\x01\n\x13identities_balances\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse.GetIdentitiesBalancesResponseV0.IdentitiesBalancesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aL\n\x0fIdentityBalance\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x18\n\x07\x62\x61lance\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x42\n\n\x08_balance\x1a\x8f\x01\n\x12IdentitiesBalances\x12y\n\x07\x65ntries\x18\x01 \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse.GetIdentitiesBalancesResponseV0.IdentityBalanceB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x8c\x02\n%GetDataContractsLatestVersionsRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsRequest.GetDataContractsLatestVersionsRequestV0H\x00\x1a`\n\'GetDataContractsLatestVersionsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\x19\n\x11include_contracts\x18\x02 \x01(\x08\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xfa\x05\n&GetDataContractsLatestVersionsResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse.GetDataContractsLatestVersionsResponseV0H\x00\x1a\x84\x01\n\x1e\x44\x61taContractLatestVersionEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x14\n\x07version\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1a\n\rdata_contract\x18\x03 \x01(\x0cH\x01\x88\x01\x01\x42\n\n\x08_versionB\x10\n\x0e_data_contract\x1a\x90\x01\n\x1b\x44\x61taContractsLatestVersions\x12q\n\x07\x65ntries\x18\x01 \x03(\x0b\x32`.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse.DataContractLatestVersionEntry\x1a\xb0\x02\n(GetDataContractsLatestVersionsResponseV0\x12\x87\x01\n\x1e\x64\x61ta_contracts_latest_versions\x18\x01 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse.DataContractsLatestVersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"R\n\x1f\x43ontractGroupDocumentTypeMember\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\"G\n\x18\x43ontractGroupTokenMember\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x16\n\x0etoken_position\x18\x02 \x01(\r\"\xd7\x01\n\x1bGetContractGroupInfoRequest\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetContractGroupInfoRequest.GetContractGroupInfoRequestV0H\x00\x1aI\n\x1dGetContractGroupInfoRequestV0\x12\x19\n\x11\x63ontract_group_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x98\x04\n\x1cGetContractGroupInfoResponse\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContractGroupInfoResponse.GetContractGroupInfoResponseV0H\x00\x1a~\n\x11\x43ontractGroupInfo\x12\x10\n\x08owner_id\x18\x01 \x01(\x0c\x12\x11\n\tadmin_ids\x18\x02 \x03(\x0c\x12\x11\n\x04name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x18\n\x0b\x64\x65scription\x18\x04 \x01(\tH\x01\x88\x01\x01\x42\x07\n\x05_nameB\x0e\n\x0c_description\x1a\x86\x02\n\x1eGetContractGroupInfoResponseV0\x12h\n\x13\x63ontract_group_info\x18\x01 \x01(\x0b\x32I.org.dash.platform.dapi.v0.GetContractGroupInfoResponse.ContractGroupInfoH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf8\x06\n\x1eGetContractGroupMembersRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.GetContractGroupMembersRequestV0H\x00\x1a@\n\x14\x43ontractMembersQuery\x12\x18\n\x0bstart_after\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x42\x0e\n\x0c_start_after\x1a\x80\x01\n\x18\x44ocumentTypeMembersQuery\x12T\n\x0bstart_after\x18\x01 \x01(\x0b\x32:.org.dash.platform.dapi.v0.ContractGroupDocumentTypeMemberH\x00\x88\x01\x01\x42\x0e\n\x0c_start_after\x1ar\n\x11TokenMembersQuery\x12M\n\x0bstart_after\x18\x01 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractGroupTokenMemberH\x00\x88\x01\x01\x42\x0e\n\x0c_start_after\x1a\xa7\x03\n GetContractGroupMembersRequestV0\x12\x19\n\x11\x63ontract_group_id\x18\x01 \x01(\x0c\x12\x63\n\tcontracts\x18\x02 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.ContractMembersQueryH\x00\x12l\n\x0e\x64ocument_types\x18\x03 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.DocumentTypeMembersQueryH\x00\x12]\n\x06tokens\x18\x04 \x01(\x0b\x32K.org.dash.platform.dapi.v0.GetContractGroupMembersRequest.TokenMembersQueryH\x00\x12\x12\n\x05limit\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x42\t\n\x07membersB\x08\n\x06_limitB\t\n\x07version\"\xc9\x06\n\x1fGetContractGroupMembersResponse\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.GetContractGroupMembersResponseV0H\x00\x1a\'\n\x0f\x43ontractMembers\x12\x14\n\x0c\x63ontract_ids\x18\x01 \x03(\x0c\x1ai\n\x13\x44ocumentTypeMembers\x12R\n\x0e\x64ocument_types\x18\x01 \x03(\x0b\x32:.org.dash.platform.dapi.v0.ContractGroupDocumentTypeMember\x1aS\n\x0cTokenMembers\x12\x43\n\x06tokens\x18\x01 \x03(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractGroupTokenMember\x1a\xc5\x03\n!GetContractGroupMembersResponseV0\x12_\n\tcontracts\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.ContractMembersH\x00\x12h\n\x0e\x64ocument_types\x18\x02 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.DocumentTypeMembersH\x00\x12Y\n\x06tokens\x18\x03 \x01(\x0b\x32G.org.dash.platform.dapi.v0.GetContractGroupMembersResponse.TokenMembersH\x00\x12\x31\n\x05proof\x18\x04 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x05 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"M\n\x1a\x43ontractModerationDocument\x12\x1a\n\x12\x64ocument_type_name\x18\x01 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x02 \x01(\x0c\"\xc6\x01\n\x18\x43ontractModerationReason\x12\x11\n\x04\x63ode\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x0c\n\x04text\x18\x02 \x01(\t\x12H\n\tdocuments\x18\x03 \x03(\x0b\x32\x35.org.dash.platform.dapi.v0.ContractModerationDocument\x12\x1f\n\x12reason_document_id\x18\x04 \x01(\x0cH\x01\x88\x01\x01\x42\x07\n\x05_codeB\x15\n\x13_reason_document_id\"i\n\x0f\x43ontractWarning\x12\x11\n\twarned_at\x18\x01 \x01(\x04\x12\x43\n\x06reason\x18\x02 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReason\"\xc5\x02\n\"GetContractModerationStatusRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetContractModerationStatusRequest.GetContractModerationStatusRequestV0H\x00\x1a\xa1\x01\n$GetContractModerationStatusRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x13\n\x0bidentity_id\x18\x02 \x01(\x0c\x12@\n\x05lists\x18\x03 \x03(\x0e\x32\x31.org.dash.platform.dapi.v0.ContractModerationList\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\xec\x06\n#GetContractModerationStatusResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractModerationStatusResponse.GetContractModerationStatusResponseV0H\x00\x1a\xb4\x03\n\x18\x43ontractModerationStatus\x12\x13\n\x06\x62\x61nned\x18\x01 \x01(\x08H\x00\x88\x01\x01\x12\x1c\n\x0fsuspended_until\x18\x02 \x01(\x04H\x01\x88\x01\x01\x12@\n\x05lists\x18\x03 \x03(\x0e\x32\x31.org.dash.platform.dapi.v0.ContractModerationList\x12L\n\nban_reason\x18\x04 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReasonH\x02\x88\x01\x01\x12S\n\x11suspension_reason\x18\x05 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReasonH\x03\x88\x01\x01\x12<\n\x08warnings\x18\x06 \x03(\x0b\x32*.org.dash.platform.dapi.v0.ContractWarningB\t\n\x07_bannedB\x12\n\x10_suspended_untilB\r\n\x0b_ban_reasonB\x14\n\x12_suspension_reason\x1a\x8e\x02\n%GetContractModerationStatusResponseV0\x12i\n\x06status\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetContractModerationStatusResponse.ContractModerationStatusH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x02\n#GetContractModerationEntriesRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractModerationEntriesRequest.GetContractModerationEntriesRequestV0H\x00\x1a\xd4\x01\n%GetContractModerationEntriesRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12?\n\x04list\x18\x02 \x01(\x0e\x32\x31.org.dash.platform.dapi.v0.ContractModerationList\x12\x18\n\x0bstart_after\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x04 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x0e\n\x0c_start_afterB\x08\n\x06_limitB\t\n\x07version\"\x96\x06\n$GetContractModerationEntriesResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse.GetContractModerationEntriesResponseV0H\x00\x1a\xcf\x01\n\x17\x43ontractModerationEntry\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x12\n\x05until\x18\x02 \x01(\x04H\x00\x88\x01\x01\x12\x43\n\x06reason\x18\x03 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReason\x12<\n\x08warnings\x18\x04 \x03(\x0b\x32*.org.dash.platform.dapi.v0.ContractWarningB\x08\n\x06_until\x1a\x85\x01\n\x19\x43ontractModerationEntries\x12h\n\x07\x65ntries\x18\x01 \x03(\x0b\x32W.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse.ContractModerationEntry\x1a\x92\x02\n&GetContractModerationEntriesResponseV0\x12l\n\x07\x65ntries\x18\x01 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse.ContractModerationEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc3\x04\n\"GetContractDocumentRemovalsRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest.GetContractDocumentRemovalsRequestV0H\x00\x1a#\n\x0b\x44ocumentIds\x12\x14\n\x0c\x64ocument_ids\x18\x01 \x03(\x0c\x1aN\n\x04Page\x12\x18\n\x0bstart_after\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x02 \x01(\rH\x01\x88\x01\x01\x42\x0e\n\x0c_start_afterB\x08\n\x06_limit\x1a\xaa\x02\n$GetContractDocumentRemovalsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x61\n\x0c\x64ocument_ids\x18\x03 \x01(\x0b\x32I.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest.DocumentIdsH\x00\x12R\n\x04page\x18\x04 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest.PageH\x00\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x0b\n\tselectionB\t\n\x07version\"\xe0\x07\n#GetContractDocumentRemovalsResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.GetContractDocumentRemovalsResponseV0H\x00\x1aH\n\x1b\x43ontractDocumentRestoration\x12\x14\n\x0cmoderator_id\x18\x01 \x01(\x0c\x12\x13\n\x0brestored_at\x18\x02 \x01(\x04\x1a\xd5\x02\n\x17\x43ontractDocumentRemoval\x12\x13\n\x0b\x64ocument_id\x18\x01 \x01(\x0c\x12\x19\n\x11\x64ocument_owner_id\x18\x02 \x01(\x0c\x12\x14\n\x0cmoderator_id\x18\x03 \x01(\x0c\x12\x12\n\nremoved_at\x18\x04 \x01(\x04\x12\x43\n\x06reason\x18\x05 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReason\x12\x15\n\rdocument_hash\x18\x06 \x01(\x0c\x12o\n\x0brestoration\x18\x07 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRestoration\x12\x13\n\x0bkept_fields\x18\x08 \x01(\x0c\x1a\x84\x01\n\x18\x43ontractDocumentRemovals\x12h\n\x08removals\x18\x01 \x03(\x0b\x32V.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemoval\x1a\x90\x02\n%GetContractDocumentRemovalsResponseV0\x12k\n\x08removals\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemovalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc7\x04\n\x1dGetContractTeamActionsRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContractTeamActionsRequest.GetContractTeamActionsRequestV0H\x00\x1aL\n\x0fStartAtActionId\x12\x17\n\x0fstart_action_id\x18\x01 \x01(\x0c\x12 \n\x18start_action_id_included\x18\x02 \x01(\x08\x1a\xbc\x02\n\x1fGetContractTeamActionsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12U\n\x06status\x18\x02 \x01(\x0e\x32\x45.org.dash.platform.dapi.v0.GetContractTeamActionsRequest.ActionStatus\x12i\n\x12start_at_action_id\x18\x03 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetContractTeamActionsRequest.StartAtActionIdH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x04 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x15\n\x13_start_at_action_idB\x08\n\x06_count\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\xe0\x07\n\x1eGetContractTeamActionsResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.GetContractTeamActionsResponseV0H\x00\x1a\xe6\x01\n\x15\x44\x65leteSettledDocument\x12\x1a\n\x12\x64ocument_type_name\x18\x01 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x02 \x01(\x0c\x12!\n\x19\x64ocument_last_modified_at\x18\x03 \x01(\x04\x12\x1e\n\x11\x64ocument_revision\x18\x04 \x01(\x04H\x00\x88\x01\x01\x12\x43\n\x06reason\x18\x05 \x01(\x0b\x32\x33.org.dash.platform.dapi.v0.ContractModerationReasonB\x14\n\x12_document_revision\x1a\xe6\x01\n\x12\x43ontractTeamAction\x12\x11\n\taction_id\x18\x01 \x01(\x0c\x12\x13\n\x0bproposer_id\x18\x02 \x01(\x0c\x12\x13\n\x0bproposed_at\x18\x03 \x01(\x04\x12r\n\x17\x64\x65lete_settled_document\x18\x04 \x01(\x0b\x32O.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.DeleteSettledDocumentH\x00\x12\x16\n\x0e\x61pproval_count\x18\x05 \x01(\rB\x07\n\x05\x65vent\x1at\n\x13\x43ontractTeamActions\x12]\n\x07\x61\x63tions\x18\x01 \x03(\x0b\x32L.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.ContractTeamAction\x1a\x80\x02\n GetContractTeamActionsResponseV0\x12`\n\x07\x61\x63tions\x18\x01 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetContractTeamActionsResponse.ContractTeamActionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x8a\x03\n#GetContractTeamActionSignersRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractTeamActionSignersRequest.GetContractTeamActionSignersRequestV0H\x00\x1a\xbb\x01\n%GetContractTeamActionSignersRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12[\n\x06status\x18\x02 \x01(\x0e\x32K.org.dash.platform.dapi.v0.GetContractTeamActionSignersRequest.ActionStatus\x12\x11\n\taction_id\x18\x03 \x01(\x0c\x12\r\n\x05prove\x18\x04 \x01(\x08\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\xed\x03\n$GetContractTeamActionSignersResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContractTeamActionSignersResponse.GetContractTeamActionSignersResponseV0H\x00\x1a/\n\x19\x43ontractTeamActionSigners\x12\x12\n\nsigner_ids\x18\x01 \x03(\x0c\x1a\x92\x02\n&GetContractTeamActionSignersResponseV0\x12l\n\x07signers\x18\x01 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetContractTeamActionSignersResponse.ContractTeamActionSignersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x85\x02\n(GetContractModerationActionCountsRequest\x12|\n\x02v0\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetContractModerationActionCountsRequest.GetContractModerationActionCountsRequestV0H\x00\x1aP\n*GetContractModerationActionCountsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n)GetContractModerationActionCountsResponse\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse.GetContractModerationActionCountsResponseV0H\x00\x1a\x43\n\x1d\x43ontractModerationActionCount\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x1a\x94\x01\n\x1e\x43ontractModerationActionCounts\x12r\n\x06\x63ounts\x18\x01 \x03(\x0b\x32\x62.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse.ContractModerationActionCount\x1a\xa0\x02\n+GetContractModerationActionCountsResponseV0\x12u\n\x06\x63ounts\x18\x01 \x01(\x0b\x32\x63.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse.ContractModerationActionCountsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc9\x01\n\x19GetContractFeePotsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetContractFeePotsRequest.GetContractFeePotsRequestV0H\x00\x1a\x41\n\x1bGetContractFeePotsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9f\x06\n\x1aGetContractFeePotsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetContractFeePotsResponse.GetContractFeePotsResponseV0H\x00\x1aR\n\x17\x43ontractFeePotLastClaim\x12\r\n\x05\x65poch\x18\x01 \x01(\r\x12\x13\n\x07time_ms\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x13\n\x0b\x63laimant_id\x18\x03 \x01(\x0c\x1a\x88\x01\n\x0e\x43ontractFeePot\x12\x13\n\x07\x63redits\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x61\n\nlast_claim\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePotLastClaim\x1a\xc0\x01\n\x0f\x43ontractFeePots\x12S\n\x05owner\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePot\x12X\n\nmoderators\x18\x02 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePot\x1a\xf1\x01\n\x1cGetContractFeePotsResponseV0\x12U\n\x04pots\x18\x01 \x01(\x0b\x32\x45.org.dash.platform.dapi.v0.GetContractFeePotsResponse.ContractFeePotsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf1\x01\n#GetContractGroupsForContractRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetContractGroupsForContractRequest.GetContractGroupsForContractRequestV0H\x00\x1aK\n%GetContractGroupsForContractRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf5\x06\n$GetContractGroupsForContractResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.GetContractGroupsForContractResponseV0H\x00\x1aQ\n\x17\x44ocumentTypeMemberships\x12\x1a\n\x12\x64ocument_type_name\x18\x01 \x01(\t\x12\x1a\n\x12\x63ontract_group_ids\x18\x02 \x03(\x0c\x1a\x46\n\x10TokenMemberships\x12\x16\n\x0etoken_position\x18\x01 \x01(\r\x12\x1a\n\x12\x63ontract_group_ids\x18\x02 \x03(\x0c\x1a\x89\x02\n\x18\x43ontractGroupMemberships\x12\x1a\n\x12\x63ontract_group_ids\x18\x01 \x03(\x0c\x12o\n\x0e\x64ocument_types\x18\x02 \x03(\x0b\x32W.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.DocumentTypeMemberships\x12`\n\x06tokens\x18\x03 \x03(\x0b\x32P.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.TokenMemberships\x1a\xa4\x02\n&GetContractGroupsForContractResponseV0\x12~\n\x1a\x63ontract_group_memberships\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse.ContractGroupMembershipsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xad\x02\n\x1eGetDataContractsByRangeRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractsByRangeRequest.GetDataContractsByRangeRequestV0H\x00\x1a\x95\x01\n GetDataContractsByRangeRequestV0\x12\x12\n\x05limit\x18\x01 \x01(\rH\x01\x88\x01\x01\x12\x15\n\x0bstart_after\x18\x02 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x03 \x01(\x0cH\x00\x12\x10\n\x08ids_only\x18\x04 \x01(\x08\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x07\n\x05startB\x08\n\x06_limitB\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc5\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xb0\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0bstart_at_ms\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xb2\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x9a\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a;\n\x18\x44\x61taContractHistoryEntry\x12\x10\n\x04\x64\x61te\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xf8\"\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x12R\n\x02v1\x18\x02 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1H\x00\x1a\xfe\x02\n\x12\x44ocumentFieldValue\x12\x14\n\nbool_value\x18\x01 \x01(\x08H\x00\x12\x19\n\x0bint64_value\x18\x02 \x01(\x12\x42\x02\x30\x01H\x00\x12\x1a\n\x0cuint64_value\x18\x03 \x01(\x04\x42\x02\x30\x01H\x00\x12\x16\n\x0c\x64ouble_value\x18\x04 \x01(\x01H\x00\x12\x0e\n\x04text\x18\x05 \x01(\tH\x00\x12\x15\n\x0b\x62ytes_value\x18\x06 \x01(\x0cH\x00\x12[\n\x04list\x18\x07 \x01(\x0b\x32K.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue.ValueListH\x00\x12\x14\n\nnull_value\x18\x08 \x01(\x08H\x00\x1a^\n\tValueList\x12Q\n\x06values\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValueB\t\n\x07variant\x1a\xe2\x02\n\x12TimeRangeSelection\x12\\\n\x08selector\x18\x01 \x01(\x0e\x32J.org.dash.platform.dapi.v0.GetDocumentsRequest.TimeRangeSelection.Selector\x12\x19\n\x08start_ms\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x12T\n\x04grid\x18\x03 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsRequest.TimeRangeSelection.Grid\x1a>\n\x04Grid\x12\x11\n\x05range\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x04step\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x11\n\x05phase\x18\x03 \x01(\x04\x42\x02\x30\x01\"0\n\x08Selector\x12\n\n\x06NEWEST\x10\x00\x12\n\n\x06OLDEST\x10\x01\x12\x0c\n\x08\x42Y_START\x10\x02\x42\x0b\n\t_start_ms\x1a\x82\x02\n\x15IntegerRangeSelection\x12P\n\x05start\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue\x12W\n\x04grid\x18\x02 \x01(\x0b\x32I.org.dash.platform.dapi.v0.GetDocumentsRequest.IntegerRangeSelection.Grid\x1a>\n\x04Grid\x12\x11\n\x05range\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x04step\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x11\n\x05phase\x18\x03 \x01(\x04\x42\x02\x30\x01\x1a\xf2\x02\n\x0bWhereClause\x12\r\n\x05\x66ield\x18\x01 \x01(\t\x12N\n\x08operator\x18\x02 \x01(\x0e\x32<.org.dash.platform.dapi.v0.GetDocumentsRequest.WhereOperator\x12P\n\x05value\x18\x03 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue\x12U\n\ntime_range\x18\x04 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.TimeRangeSelection\x12[\n\rinteger_range\x18\x05 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.IntegerRangeSelection\x1a\xa4\x01\n\x0fHavingAggregate\x12Y\n\x08\x66unction\x18\x01 \x01(\x0e\x32G.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingAggregate.Function\x12\r\n\x05\x66ield\x18\x02 \x01(\t\"\'\n\x08\x46unction\x12\t\n\x05\x43OUNT\x10\x00\x12\x07\n\x03SUM\x10\x01\x12\x07\n\x03\x41VG\x10\x02\x1a\xf9\x03\n\x0cHavingClause\x12Q\n\taggregate\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingAggregate\x12V\n\x08operator\x18\x02 \x01(\x0e\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingClause.Operator\x12R\n\x05value\x18\x03 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValueH\x00\"\xe0\x01\n\x08Operator\x12\t\n\x05\x45QUAL\x10\x00\x12\r\n\tNOT_EQUAL\x10\x01\x12\x10\n\x0cGREATER_THAN\x10\x02\x12\x1a\n\x16GREATER_THAN_OR_EQUALS\x10\x03\x12\r\n\tLESS_THAN\x10\x04\x12\x17\n\x13LESS_THAN_OR_EQUALS\x10\x05\x12\x0b\n\x07\x42\x45TWEEN\x10\x06\x12\x1a\n\x16\x42\x45TWEEN_EXCLUDE_BOUNDS\x10\x07\x12\x18\n\x14\x42\x45TWEEN_EXCLUDE_LEFT\x10\x08\x12\x19\n\x15\x42\x45TWEEN_EXCLUDE_RIGHT\x10\t\x12\x06\n\x02IN\x10\nB\x07\n\x05right\x1a\x90\x01\n\x0bOrderClause\x12\x0f\n\x05\x66ield\x18\x01 \x01(\tH\x00\x12S\n\taggregate\x18\x03 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingAggregateH\x00\x12\x11\n\tascending\x18\x02 \x01(\x08\x42\x08\n\x06target\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05start\x1a\xa6\x0c\n\x15GetDocumentsRequestV1\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12Q\n\rwhere_clauses\x18\x03 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.WhereClause\x12L\n\x08order_by\x18\x04 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.OrderClause\x12\x12\n\x05limit\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x12\\\n\x07selects\x18\t \x03(\x0b\x32K.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.Select\x12\x10\n\x08group_by\x18\n \x03(\t\x12K\n\x06having\x18\x0b \x03(\x0b\x32;.org.dash.platform.dapi.v0.GetDocumentsRequest.HavingClause\x12\x13\n\x06offset\x18\x0c \x01(\rH\x02\x88\x01\x01\x12\x61\n\x07\x63hained\x18\r \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.ChainedJoin\x12\x62\n\x0bsub_queries\x18\x0e \x03(\x0b\x32M.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.SubQuery\x1a\xc9\x01\n\x06Select\x12\x66\n\x08\x66unction\x18\x01 \x01(\x0e\x32T.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.Select.Function\x12\r\n\x05\x66ield\x18\x02 \x01(\t\"H\n\x08\x46unction\x12\r\n\tDOCUMENTS\x10\x00\x12\t\n\x05\x43OUNT\x10\x01\x12\x07\n\x03SUM\x10\x02\x12\x07\n\x03\x41VG\x10\x03\x12\x07\n\x03MIN\x10\x04\x12\x07\n\x03MAX\x10\x05\x1a\x41\n\x0b\x43hainedJoin\x12\x15\n\rjoin_property\x18\x01 \x01(\t\x12\x1b\n\x13outer_document_type\x18\x02 \x01(\t\x1a\xa6\x04\n\x08SubQuery\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12Q\n\rwhere_clauses\x18\x03 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.WhereClause\x12L\n\x08order_by\x18\x04 \x03(\x0b\x32:.org.dash.platform.dapi.v0.GetDocumentsRequest.OrderClause\x12\x12\n\x05limit\x18\x05 \x01(\rH\x00\x88\x01\x01\x12`\n\x04kind\x18\x06 \x01(\x0e\x32R.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.SubQuery.Kind\x12\x63\n\x04\x62ind\x18\x07 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV1.SubQuery.Binding\x1a\x41\n\x07\x42inding\x12\x0e\n\x06source\x18\x01 \x01(\r\x12\x17\n\x0fsource_property\x18\x02 \x01(\t\x12\r\n\x05\x66ield\x18\x03 \x01(\t\" \n\x04Kind\x12\r\n\tDOCUMENTS\x10\x00\x12\t\n\x05\x43OUNT\x10\x01\x42\x08\n\x06_limitB\x07\n\x05startB\x08\n\x06_limitB\t\n\x07_offset\"\xb0\x02\n\rWhereOperator\x12\t\n\x05\x45QUAL\x10\x00\x12\x10\n\x0cGREATER_THAN\x10\x01\x12\x1a\n\x16GREATER_THAN_OR_EQUALS\x10\x02\x12\r\n\tLESS_THAN\x10\x03\x12\x17\n\x13LESS_THAN_OR_EQUALS\x10\x04\x12\x0b\n\x07\x42\x45TWEEN\x10\x05\x12\x1a\n\x16\x42\x45TWEEN_EXCLUDE_BOUNDS\x10\x06\x12\x18\n\x14\x42\x45TWEEN_EXCLUDE_LEFT\x10\x07\x12\x19\n\x15\x42\x45TWEEN_EXCLUDE_RIGHT\x10\x08\x12\x06\n\x02IN\x10\t\x12\x0f\n\x0bSTARTS_WITH\x10\n\x12\x11\n\rIN_TIME_RANGE\x10\x0b\x12\x14\n\x10IN_INTEGER_RANGE\x10\x0c\x12\x0c\n\x08\x43ONTAINS\x10\r\x12\x10\n\x0c\x43ONTAINS_ANY\x10\x0e\x42\t\n\x07version\"\xd5\x1d\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x12T\n\x02v1\x18\x02 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06result\x1a\xe7\x19\n\x16GetDocumentsResponseV1\x12\x61\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ResultDataH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x1aL\n\nCountEntry\x12\x13\n\x06in_key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\x11\n\x05\x63ount\x18\x03 \x01(\x04\x42\x02\x30\x01\x42\t\n\x07_in_key\x1ar\n\x0c\x43ountEntries\x12\x62\n\x07\x65ntries\x18\x01 \x03(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountEntry\x1a\xa0\x01\n\x0c\x43ountResults\x12\x1d\n\x0f\x61ggregate_count\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x66\n\x07\x65ntries\x18\x02 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountEntriesH\x00\x42\t\n\x07variant\x1aH\n\x08SumEntry\x12\x13\n\x06in_key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\x0f\n\x03sum\x18\x03 \x01(\x12\x42\x02\x30\x01\x42\t\n\x07_in_key\x1an\n\nSumEntries\x12`\n\x07\x65ntries\x18\x01 \x03(\x0b\x32O.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.SumEntry\x1a\x9a\x01\n\nSumResults\x12\x1b\n\raggregate_sum\x18\x01 \x01(\x12\x42\x02\x30\x01H\x00\x12\x64\n\x07\x65ntries\x18\x02 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.SumEntriesH\x00\x42\t\n\x07variant\x1a_\n\x0c\x41verageEntry\x12\x13\n\x06in_key\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\x11\n\x05\x63ount\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\x0f\n\x03sum\x18\x04 \x01(\x12\x42\x02\x30\x01\x42\t\n\x07_in_key\x1av\n\x0e\x41verageEntries\x12\x64\n\x07\x65ntries\x18\x01 \x03(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageEntry\x1a\x36\n\x10\x41verageAggregate\x12\x11\n\x05\x63ount\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x0f\n\x03sum\x18\x02 \x01(\x12\x42\x02\x30\x01\x1a\xfb\x01\n\x0e\x41verageResults\x12t\n\x11\x61ggregate_average\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageAggregateH\x00\x12h\n\x07\x65ntries\x18\x02 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageEntriesH\x00\x42\t\n\x07variant\x1az\n\x0bRankedEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\x13\n\x05\x63ount\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12\x11\n\x03sum\x18\x03 \x01(\x12\x42\x02\x30\x01H\x00\x12\r\n\x03\x61vg\x18\x04 \x01(\x01H\x00\x12\x13\n\x06in_key\x18\x05 \x01(\x0cH\x01\x88\x01\x01\x42\x07\n\x05valueB\t\n\x07_in_key\x1a\x9a\x01\n\rRankedEntries\x12\x63\n\x07\x65ntries\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.RankedEntry\x12\x18\n\x07skipped\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x42\n\n\x08_skipped\x1a\xf7\x05\n\nResultData\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.DocumentsH\x00\x12\x65\n\x06\x63ounts\x18\x02 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountResultsH\x00\x12\x61\n\x04sums\x18\x03 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.SumResultsH\x00\x12i\n\x08\x61verages\x18\x04 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.AverageResultsH\x00\x12\x66\n\x06ranked\x18\x05 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.RankedEntriesH\x00\x12j\n\x07\x63hained\x18\x06 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ChainedDocumentsH\x00\x12n\n\tcomposite\x18\x07 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CompositeDocumentsH\x00\x42\t\n\x07variant\x1a\xd8\x01\n\x10\x43hainedDocuments\x12\x17\n\x0finner_documents\x18\x01 \x03(\x0c\x12\x17\n\x0fouter_documents\x18\x02 \x03(\x0c\x12\x19\n\x11missing_outer_ids\x18\x03 \x03(\x0c\x12w\n\x17removed_outer_documents\x18\x04 \x03(\x0b\x32V.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemoval\x1a\x94\x04\n\x12\x43ompositeDocuments\x12\x16\n\x0epage_documents\x18\x01 \x03(\x0c\x12}\n\x0bsub_results\x18\x02 \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CompositeDocuments.SubQueryResult\x1a\xe6\x02\n\x0eSubQueryResult\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.DocumentsH\x00\x12\x65\n\x06\x63ounts\x18\x02 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.CountEntriesH\x00\x12\x13\n\x0bmissing_ids\x18\x03 \x03(\x0c\x12g\n\x07removed\x18\x04 \x03(\x0b\x32V.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse.ContractDocumentRemovalB\x08\n\x06resultB\x08\n\x06resultB\t\n\x07version\"\xfe\x06\n\x19GetDocumentHistoryRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0H\x00\x12^\n\x02v1\x18\x02 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV1H\x00\x1a\xeb\x01\n\x1bGetDocumentHistoryRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x03 \x01(\x0c\x12+\n\x05limit\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x05 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0bstart_at_ms\x18\x06 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x07 \x01(\x08\x1a\xa7\x03\n\x1bGetDocumentHistoryRequestV1\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64ocument_id\x18\x03 \x01(\x0c\x12+\n\x05limit\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x12\x19\n\x0bstart_at_ms\x18\x06 \x01(\x04\x42\x02\x30\x01H\x00\x12n\n\x0bstart_after\x18\x07 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV1.CursorH\x00\x12\x1f\n\x11start_at_revision\x18\x08 \x01(\x04\x42\x02\x30\x01H\x00\x12\x16\n\x08revision\x18\t \x01(\x04\x42\x02\x30\x01H\x00\x1a\x33\n\x06\x43ursor\x12\x13\n\x07time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x14\n\x08revision\x18\x02 \x01(\x04\x42\x02\x30\x01\x42\x08\n\x06\x66ilterB\t\n\x07version\"\xf3\x0c\n\x1aGetDocumentHistoryResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0H\x00\x12`\n\x02v1\x18\x02 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1H\x00\x1a\xeb\x03\n\x1cGetDocumentHistoryResponseV0\x12~\n\x10\x64ocument_history\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x14\x44ocumentHistoryEntry\x12\x10\n\x04\x64\x61te\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\x95\x01\n\x0f\x44ocumentHistory\x12\x81\x01\n\x10\x64ocument_entries\x18\x01 \x03(\x0b\x32g.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntryB\x08\n\x06result\x1a\x97\x07\n\x1cGetDocumentHistoryResponseV1\x12m\n\x07history\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.HistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x44\n\x05\x45ntry\x12\x13\n\x07time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x14\n\x08revision\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x08\x64ocument\x18\x03 \x01(\x0c\x1a\xdd\x02\n\tLifecycle\x12q\n\x05state\x18\x01 \x01(\x0e\x32\x62.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State\x12\x1f\n\x13remaining_revisions\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x19\n\rdeleted_at_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12!\n\x15\x65rasing_started_at_ms\x18\x04 \x01(\x04\x42\x02\x30\x01\x12 \n\x14\x65rasing_from_time_ms\x18\x05 \x01(\x04\x42\x02\x30\x01\x12!\n\x15\x65rasing_from_revision\x18\x06 \x01(\x04\x42\x02\x30\x01\"9\n\x05State\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x41\x42SENT\x10\x01\x12\x0b\n\x07\x44\x45LETED\x10\x02\x12\x0b\n\x07\x45RASING\x10\x03\x1a\xe5\x01\n\x07History\x12i\n\x07\x65ntries\x18\x01 \x03(\x0b\x32X.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Entry\x12o\n\tlifecycle\x18\x02 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.LifecycleB\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc3\x04\n*GetIdentityByNonUniquePublicKeyHashRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashRequest.GetIdentityByNonUniquePublicKeyHashRequestV0H\x00\x12\x80\x01\n\x02v1\x18\x02 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashRequest.GetIdentityByNonUniquePublicKeyHashRequestV1H\x00\x1a\x80\x01\n,GetIdentityByNonUniquePublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\x18\n\x0bstart_after\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\x0e\n\x0c_start_after\x1a\x80\x01\n,GetIdentityByNonUniquePublicKeyHashRequestV1\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\x18\n\x0bstart_after\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\x0e\n\x0c_start_afterB\t\n\x07version\"\xe4\n\n+GetIdentityByNonUniquePublicKeyHashResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV0H\x00\x12\x82\x01\n\x02v1\x18\x02 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV1H\x00\x1a\x9c\x05\n-GetIdentityByNonUniquePublicKeyHashResponseV0\x12\x9a\x01\n\x08identity\x18\x01 \x01(\x0b\x32\x85\x01.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV0.IdentityResponseH\x00\x12\x9d\x01\n\x05proof\x18\x02 \x01(\x0b\x32\x8b\x01.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV0.IdentityProvedResponseH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x36\n\x10IdentityResponse\x12\x15\n\x08identity\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_identity\x1a\xa6\x01\n\x16IdentityProvedResponse\x12P\n&grovedb_identity_public_key_hash_proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.Proof\x12!\n\x14identity_proof_bytes\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x17\n\x15_identity_proof_bytesB\x08\n\x06resultJ\x04\x08\x04\x10\x05\x1a\x80\x03\n-GetIdentityByNonUniquePublicKeyHashResponseV1\x12\x9a\x01\n\x08identity\x18\x01 \x01(\x0b\x32\x85\x01.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse.GetIdentityByNonUniquePublicKeyHashResponseV1.IdentityResponseH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x36\n\x10IdentityResponse\x12\x15\n\x08identity\x18\x01 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_identityB\x08\n\x06resultB\t\n\x07version\"\x99\x02\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1as\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x12\x1c\n\x14request_user_balance\x18\x03 \x01(\x08\x42\t\n\x07version\"\xce\x04\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\x34\n\x17SuccessWithOwnerBalance\x12\x19\n\rowner_balance\x18\x01 \x01(\x04\x42\x02\x30\x01\x1a\xee\x02\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12}\n\x1asuccess_with_owner_balance\x18\x04 \x01(\x0b\x32W.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.SuccessWithOwnerBalanceH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf4\x01\n%GetRecentStateTransitionStatusRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusRequest.GetRecentStateTransitionStatusRequestV0H\x00\x1aH\n\'GetRecentStateTransitionStatusRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x42\t\n\x07version\"\xbf\x06\n&GetRecentStateTransitionStatusResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0H\x00\x1a\x8f\x05\n(GetRecentStateTransitionStatusResponseV0\x12\x89\x01\n\tcommitted\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0.CommittedH\x00\x12\x85\x01\n\x07pending\x18\x02 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0.PendingH\x00\x12\x85\x01\n\x07unknown\x18\x03 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse.GetRecentStateTransitionStatusResponseV0.UnknownH\x00\x12=\n\x08metadata\x18\x04 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ah\n\tCommitted\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12G\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastError\x1a\t\n\x07Pending\x1a\t\n\x07UnknownB\x08\n\x06statusB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\x99\x05\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\x9c\x04\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\xa6\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1e\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x16\n\nstart_time\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xbf\x02\n\x1dGetFinalizedEpochInfosRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetFinalizedEpochInfosRequest.GetFinalizedEpochInfosRequestV0H\x00\x1a\xaa\x01\n\x1fGetFinalizedEpochInfosRequestV0\x12\x19\n\x11start_epoch_index\x18\x01 \x01(\r\x12\"\n\x1astart_epoch_index_included\x18\x02 \x01(\x08\x12\x17\n\x0f\x65nd_epoch_index\x18\x03 \x01(\r\x12 \n\x18\x65nd_epoch_index_included\x18\x04 \x01(\x08\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xbd\t\n\x1eGetFinalizedEpochInfosResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0H\x00\x1a\xa5\x08\n GetFinalizedEpochInfosResponseV0\x12\x80\x01\n\x06\x65pochs\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0.FinalizedEpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xa4\x01\n\x13\x46inalizedEpochInfos\x12\x8c\x01\n\x15\x66inalized_epoch_infos\x18\x01 \x03(\x0b\x32m.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0.FinalizedEpochInfo\x1a\x9f\x04\n\x12\x46inalizedEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1e\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x1c\n\x10\x66irst_block_time\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\r\x12!\n\x15total_blocks_in_epoch\x18\x07 \x01(\x04\x42\x02\x30\x01\x12*\n\"next_epoch_start_core_block_height\x18\x08 \x01(\r\x12!\n\x15total_processing_fees\x18\t \x01(\x04\x42\x02\x30\x01\x12*\n\x1etotal_distributed_storage_fees\x18\n \x01(\x04\x42\x02\x30\x01\x12&\n\x1atotal_created_storage_fees\x18\x0b \x01(\x04\x42\x02\x30\x01\x12\x1e\n\x12\x63ore_block_rewards\x18\x0c \x01(\x04\x42\x02\x30\x01\x12\x81\x01\n\x0f\x62lock_proposers\x18\r \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse.GetFinalizedEpochInfosResponseV0.BlockProposer\x1a\x39\n\rBlockProposer\x12\x13\n\x0bproposer_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x62lock_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xde\x04\n\x1cGetContestedResourcesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0H\x00\x1a\xcc\x03\n\x1eGetContestedResourcesRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x1a\n\x12start_index_values\x18\x04 \x03(\x0c\x12\x18\n\x10\x65nd_index_values\x18\x05 \x03(\x0c\x12\x89\x01\n\x13start_at_value_info\x18\x06 \x01(\x0b\x32g.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.StartAtValueInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1a\x45\n\x10StartAtValueInfo\x12\x13\n\x0bstart_value\x18\x01 \x01(\x0c\x12\x1c\n\x14start_value_included\x18\x02 \x01(\x08\x42\x16\n\x14_start_at_value_infoB\x08\n\x06_countB\t\n\x07version\"\x88\x04\n\x1dGetContestedResourcesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0H\x00\x1a\xf3\x02\n\x1fGetContestedResourcesResponseV0\x12\x95\x01\n\x19\x63ontested_resource_values\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResourceValuesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a<\n\x17\x43ontestedResourceValues\x12!\n\x19\x63ontested_resource_values\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xd2\x05\n\x1cGetVotePollsByEndDateRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0H\x00\x1a\xc0\x04\n\x1eGetVotePollsByEndDateRequestV0\x12\x84\x01\n\x0fstart_time_info\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.StartAtTimeInfoH\x00\x88\x01\x01\x12\x80\x01\n\rend_time_info\x18\x02 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.EndAtTimeInfoH\x01\x88\x01\x01\x12\x12\n\x05limit\x18\x03 \x01(\rH\x02\x88\x01\x01\x12\x13\n\x06offset\x18\x04 \x01(\rH\x03\x88\x01\x01\x12\x11\n\tascending\x18\x05 \x01(\x08\x12\r\n\x05prove\x18\x06 \x01(\x08\x1aI\n\x0fStartAtTimeInfo\x12\x19\n\rstart_time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1b\n\x13start_time_included\x18\x02 \x01(\x08\x1a\x43\n\rEndAtTimeInfo\x12\x17\n\x0b\x65nd_time_ms\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x19\n\x11\x65nd_time_included\x18\x02 \x01(\x08\x42\x12\n\x10_start_time_infoB\x10\n\x0e_end_time_infoB\x08\n\x06_limitB\t\n\x07_offsetB\t\n\x07version\"\x83\x06\n\x1dGetVotePollsByEndDateResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0H\x00\x1a\xee\x04\n\x1fGetVotePollsByEndDateResponseV0\x12\x9c\x01\n\x18vote_polls_by_timestamps\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestampsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aV\n\x1eSerializedVotePollsByTimestamp\x12\x15\n\ttimestamp\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1d\n\x15serialized_vote_polls\x18\x02 \x03(\x0c\x1a\xd7\x01\n\x1fSerializedVotePollsByTimestamps\x12\x99\x01\n\x18vote_polls_by_timestamps\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestamp\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xd6\x01\n\x1cGetYesNoVotePollStateRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetYesNoVotePollStateRequest.GetYesNoVotePollStateRequestV0H\x00\x1a\x45\n\x1eGetYesNoVotePollStateRequestV0\x12\x14\n\x0cvote_poll_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xa8\x11\n\x1dGetYesNoVotePollStateResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0H\x00\x1a\x93\x10\n\x1fGetYesNoVotePollStateResponseV0\x12|\n\x05state\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollStateH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x61\n\x12YesNoVotePollBlock\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x13\n\x0b\x63ore_height\x18\x02 \x01(\r\x12\x13\n\x07time_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05\x65poch\x18\x04 \x01(\r\x1a\xa4\x03\n\x15\x46inishedYesNoVotePoll\x12\x0e\n\x06passed\x18\x01 \x01(\x08\x12\x18\n\x10yes_voting_power\x18\x02 \x01(\r\x12\x17\n\x0fno_voting_power\x18\x03 \x01(\r\x12\x1c\n\x14\x61\x62stain_voting_power\x18\x04 \x01(\r\x12\x1d\n\x15required_voting_power\x18\x05 \x01(\r\x12\x80\x01\n\x0bstart_block\x18\x06 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollBlock\x12\x87\x01\n\x12\x66inalization_block\x18\x07 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollBlock\x1a\xf9\x05\n\rYesNoVotePoll\x12\x94\x01\n\x11\x64\x65\x63ision_proposal\x18\x01 \x01(\x0b\x32w.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePoll.DecisionProposalH\x00\x12\x1f\n\x17supermajority_numerator\x18\x02 \x01(\r\x12!\n\x19supermajority_denominator\x18\x03 \x01(\r\x12\x12\n\x08\x61\x62solute\x18\x04 \x01(\rH\x01\x12\x93\x01\n\x11\x66raction_of_total\x18\x05 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePoll.FractionOfTotalH\x01\x1a\'\n\x10\x44\x65\x63isionProposal\x12\x13\n\x0b\x64ocument_id\x18\x01 \x01(\x0c\x1a\xc8\x01\n\x0f\x46ractionOfTotal\x12\x11\n\tnumerator\x18\x01 \x01(\r\x12\x13\n\x0b\x64\x65nominator\x18\x02 \x01(\r\x12\x8c\x01\n\x08rounding\x18\x03 \x01(\x0e\x32z.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePoll.VotingPowerRounding\"L\n\x13VotingPowerRounding\x12\x08\n\x04\x44OWN\x10\x00\x12\x06\n\x02UP\x10\x01\x12\x11\n\rDOWN_PLUS_ONE\x10\x02\x12\x10\n\x0cUP_MINUS_ONE\x10\x03\x42\t\n\x07purposeB\x16\n\x14minimum_voting_power\x1a\xef\x03\n\x12YesNoVotePollState\x12~\n\x07started\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollBlockH\x00\x12\x82\x01\n\x08\x66inished\x18\x02 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.FinishedYesNoVotePollH\x00\x12\x18\n\x10yes_voting_power\x18\x03 \x01(\r\x12\x17\n\x0fno_voting_power\x18\x04 \x01(\r\x12\x1c\n\x14\x61\x62stain_voting_power\x18\x05 \x01(\r\x12y\n\tvote_poll\x18\x06 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse.GetYesNoVotePollStateResponseV0.YesNoVotePollB\x08\n\x06statusB\x08\n\x06resultB\t\n\x07version\"\xef\x01\n\x1dGetMasternodeYesNoVoteRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteRequest.GetMasternodeYesNoVoteRequestV0H\x00\x1a[\n\x1fGetMasternodeYesNoVoteRequestV0\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x14\n\x0cvote_poll_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xb5\x06\n\x1eGetMasternodeYesNoVoteResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0H\x00\x1a\x9d\x05\n GetMasternodeYesNoVoteResponseV0\x12\x84\x01\n\x05\x65ntry\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0.MasternodeYesNoVoteEntryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xda\x01\n\x13MasternodeYesNoVote\x12\x85\x01\n\x06\x63hoice\x18\x01 \x01(\x0e\x32u.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0.MasternodeYesNoVote.Choice\x12\x13\n\x0btimes_voted\x18\x02 \x01(\r\"&\n\x06\x43hoice\x12\x07\n\x03YES\x10\x00\x12\x06\n\x02NO\x10\x01\x12\x0b\n\x07\x41\x42STAIN\x10\x02\x1a\x98\x01\n\x18MasternodeYesNoVoteEntry\x12|\n\x04vote\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse.GetMasternodeYesNoVoteResponseV0.MasternodeYesNoVoteB\x08\n\x06resultB\t\n\x07version\"\xff\x06\n$GetContestedResourceVoteStateRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0H\x00\x1a\xd5\x05\n&GetContestedResourceVoteStateRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x86\x01\n\x0bresult_type\x18\x05 \x01(\x0e\x32q.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.ResultType\x12\x36\n.allow_include_locked_and_abstaining_vote_tally\x18\x06 \x01(\x08\x12\xa3\x01\n\x18start_at_identifier_info\x18\x07 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x08 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\"I\n\nResultType\x12\r\n\tDOCUMENTS\x10\x00\x12\x0e\n\nVOTE_TALLY\x10\x01\x12\x1c\n\x18\x44OCUMENTS_AND_VOTE_TALLY\x10\x02\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\x94\x0c\n%GetContestedResourceVoteStateResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0H\x00\x1a\xe7\n\n\'GetContestedResourceVoteStateResponseV0\x12\xae\x01\n\x1d\x63ontested_resource_contenders\x18\x01 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContendersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xda\x03\n\x10\x46inishedVoteInfo\x12\xad\x01\n\x15\x66inished_vote_outcome\x18\x01 \x01(\x0e\x32\x8d\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfo.FinishedVoteOutcome\x12\x1f\n\x12won_by_identity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12$\n\x18\x66inished_at_block_height\x18\x03 \x01(\x04\x42\x02\x30\x01\x12%\n\x1d\x66inished_at_core_block_height\x18\x04 \x01(\r\x12%\n\x19\x66inished_at_block_time_ms\x18\x05 \x01(\x04\x42\x02\x30\x01\x12\x19\n\x11\x66inished_at_epoch\x18\x06 \x01(\r\"O\n\x13\x46inishedVoteOutcome\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\n\n\x06LOCKED\x10\x01\x12\x16\n\x12NO_PREVIOUS_WINNER\x10\x02\x42\x15\n\x13_won_by_identity_id\x1a\xc4\x03\n\x1b\x43ontestedResourceContenders\x12\x86\x01\n\ncontenders\x18\x01 \x03(\x0b\x32r.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender\x12\x1f\n\x12\x61\x62stain_vote_tally\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1c\n\x0flock_vote_tally\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\x9a\x01\n\x12\x66inished_vote_info\x18\x04 \x01(\x0b\x32y.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfoH\x02\x88\x01\x01\x42\x15\n\x13_abstain_vote_tallyB\x12\n\x10_lock_vote_tallyB\x15\n\x13_finished_vote_info\x1ak\n\tContender\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x17\n\nvote_count\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x15\n\x08\x64ocument\x18\x03 \x01(\x0cH\x01\x88\x01\x01\x42\r\n\x0b_vote_countB\x0b\n\t_documentB\x08\n\x06resultB\t\n\x07version\"\xd5\x05\n,GetContestedResourceVotersForIdentityRequest\x12\x84\x01\n\x02v0\x18\x01 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0H\x00\x1a\x92\x04\n.GetContestedResourceVotersForIdentityRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x15\n\rcontestant_id\x18\x05 \x01(\x0c\x12\xb4\x01\n\x18start_at_identifier_info\x18\x06 \x01(\x0b\x32\x8c\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\xf1\x04\n-GetContestedResourceVotersForIdentityResponse\x12\x86\x01\n\x02v0\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0H\x00\x1a\xab\x03\n/GetContestedResourceVotersForIdentityResponseV0\x12\xb6\x01\n\x19\x63ontested_resource_voters\x18\x01 \x01(\x0b\x32\x90\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0.ContestedResourceVotersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x43\n\x17\x43ontestedResourceVoters\x12\x0e\n\x06voters\x18\x01 \x03(\x0c\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xad\x05\n(GetContestedResourceIdentityVotesRequest\x12|\n\x02v0\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0H\x00\x1a\xf7\x03\n*GetContestedResourceIdentityVotesRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0forder_ascending\x18\x04 \x01(\x08\x12\xae\x01\n\x1astart_at_vote_poll_id_info\x18\x05 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0.StartAtVotePollIdInfoH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x1a\x61\n\x15StartAtVotePollIdInfo\x12 \n\x18start_at_poll_identifier\x18\x01 \x01(\x0c\x12&\n\x1estart_poll_identifier_included\x18\x02 \x01(\x08\x42\x1d\n\x1b_start_at_vote_poll_id_infoB\t\n\x07version\"\xc8\n\n)GetContestedResourceIdentityVotesResponse\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0H\x00\x1a\x8f\t\n+GetContestedResourceIdentityVotesResponseV0\x12\xa1\x01\n\x05votes\x18\x01 \x01(\x0b\x32\x8f\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVotesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xf7\x01\n\x1e\x43ontestedResourceIdentityVotes\x12\xba\x01\n!contested_resource_identity_votes\x18\x01 \x03(\x0b\x32\x8e\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVote\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\xad\x02\n\x12ResourceVoteChoice\x12\xad\x01\n\x10vote_choice_type\x18\x01 \x01(\x0e\x32\x92\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoice.VoteChoiceType\x12\x18\n\x0bidentity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\"=\n\x0eVoteChoiceType\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\x0b\n\x07\x41\x42STAIN\x10\x01\x12\x08\n\x04LOCK\x10\x02\x42\x0e\n\x0c_identity_id\x1a\x95\x02\n\x1d\x43ontestedResourceIdentityVote\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\'\n\x1fserialized_index_storage_values\x18\x03 \x03(\x0c\x12\x99\x01\n\x0bvote_choice\x18\x04 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoiceB\x08\n\x06resultB\t\n\x07version\"\xf0\x01\n%GetPrefundedSpecializedBalanceRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest.GetPrefundedSpecializedBalanceRequestV0H\x00\x1a\x44\n\'GetPrefundedSpecializedBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xed\x02\n&GetPrefundedSpecializedBalanceResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0H\x00\x1a\xbd\x01\n(GetPrefundedSpecializedBalanceResponseV0\x12\x15\n\x07\x62\x61lance\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xd0\x01\n GetTotalCreditsInPlatformRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0H\x00\x1a\x33\n\"GetTotalCreditsInPlatformRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xd9\x02\n!GetTotalCreditsInPlatformResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0H\x00\x1a\xb8\x01\n#GetTotalCreditsInPlatformResponseV0\x12\x15\n\x07\x63redits\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x16GetPathElementsRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0H\x00\x1a\x45\n\x18GetPathElementsRequestV0\x12\x0c\n\x04path\x18\x01 \x03(\x0c\x12\x0c\n\x04keys\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xa3\x03\n\x17GetPathElementsResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0H\x00\x1a\xa0\x02\n\x19GetPathElementsResponseV0\x12i\n\x08\x65lements\x18\x01 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.ElementsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1c\n\x08\x45lements\x12\x10\n\x08\x65lements\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\x81\x01\n\x10GetStatusRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetStatusRequest.GetStatusRequestV0H\x00\x1a\x14\n\x12GetStatusRequestV0B\t\n\x07version\"\xe4\x10\n\x11GetStatusResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0H\x00\x1a\xf3\x0f\n\x13GetStatusResponseV0\x12Y\n\x07version\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version\x12S\n\x04node\x18\x02 \x01(\x0b\x32\x45.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Node\x12U\n\x05\x63hain\x18\x03 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Chain\x12Y\n\x07network\x18\x04 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Network\x12^\n\nstate_sync\x18\x05 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.StateSync\x12S\n\x04time\x18\x06 \x01(\x0b\x32\x45.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Time\x1a\x82\x05\n\x07Version\x12\x63\n\x08software\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Software\x12\x63\n\x08protocol\x18\x02 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Protocol\x1a^\n\x08Software\x12\x0c\n\x04\x64\x61pi\x18\x01 \x01(\t\x12\x12\n\x05\x64rive\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\x17\n\ntenderdash\x18\x03 \x01(\tH\x01\x88\x01\x01\x42\x08\n\x06_driveB\r\n\x0b_tenderdash\x1a\xcc\x02\n\x08Protocol\x12p\n\ntenderdash\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Protocol.Tenderdash\x12\x66\n\x05\x64rive\x18\x02 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetStatusResponse.GetStatusResponseV0.Version.Protocol.Drive\x1a(\n\nTenderdash\x12\x0b\n\x03p2p\x18\x01 \x01(\r\x12\r\n\x05\x62lock\x18\x02 \x01(\r\x1a<\n\x05\x44rive\x12\x0e\n\x06latest\x18\x03 \x01(\r\x12\x0f\n\x07\x63urrent\x18\x04 \x01(\r\x12\x12\n\nnext_epoch\x18\x05 \x01(\r\x1a\x7f\n\x04Time\x12\x11\n\x05local\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x16\n\x05\x62lock\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x88\x01\x01\x12\x18\n\x07genesis\x18\x03 \x01(\x04\x42\x02\x30\x01H\x01\x88\x01\x01\x12\x12\n\x05\x65poch\x18\x04 \x01(\rH\x02\x88\x01\x01\x42\x08\n\x06_blockB\n\n\x08_genesisB\x08\n\x06_epoch\x1a<\n\x04Node\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\x18\n\x0bpro_tx_hash\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0e\n\x0c_pro_tx_hash\x1a\xb3\x02\n\x05\x43hain\x12\x13\n\x0b\x63\x61tching_up\x18\x01 \x01(\x08\x12\x19\n\x11latest_block_hash\x18\x02 \x01(\x0c\x12\x17\n\x0flatest_app_hash\x18\x03 \x01(\x0c\x12\x1f\n\x13latest_block_height\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x1b\n\x13\x65\x61rliest_block_hash\x18\x05 \x01(\x0c\x12\x19\n\x11\x65\x61rliest_app_hash\x18\x06 \x01(\x0c\x12!\n\x15\x65\x61rliest_block_height\x18\x07 \x01(\x04\x42\x02\x30\x01\x12!\n\x15max_peer_block_height\x18\t \x01(\x04\x42\x02\x30\x01\x12%\n\x18\x63ore_chain_locked_height\x18\n \x01(\rH\x00\x88\x01\x01\x42\x1b\n\x19_core_chain_locked_height\x1a\x43\n\x07Network\x12\x10\n\x08\x63hain_id\x18\x01 \x01(\t\x12\x13\n\x0bpeers_count\x18\x02 \x01(\r\x12\x11\n\tlistening\x18\x03 \x01(\x08\x1a\x85\x02\n\tStateSync\x12\x1d\n\x11total_synced_time\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1a\n\x0eremaining_time\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x17\n\x0ftotal_snapshots\x18\x03 \x01(\r\x12\"\n\x16\x63hunk_process_avg_time\x18\x04 \x01(\x04\x42\x02\x30\x01\x12\x1b\n\x0fsnapshot_height\x18\x05 \x01(\x04\x42\x02\x30\x01\x12!\n\x15snapshot_chunks_count\x18\x06 \x01(\x04\x42\x02\x30\x01\x12\x1d\n\x11\x62\x61\x63kfilled_blocks\x18\x07 \x01(\x04\x42\x02\x30\x01\x12!\n\x15\x62\x61\x63kfill_blocks_total\x18\x08 \x01(\x04\x42\x02\x30\x01\x42\t\n\x07version\"\xb1\x01\n\x1cGetCurrentQuorumsInfoRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest.GetCurrentQuorumsInfoRequestV0H\x00\x1a \n\x1eGetCurrentQuorumsInfoRequestV0B\t\n\x07version\"\xa1\x05\n\x1dGetCurrentQuorumsInfoResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.GetCurrentQuorumsInfoResponseV0H\x00\x1a\x46\n\x0bValidatorV0\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07node_ip\x18\x02 \x01(\t\x12\x11\n\tis_banned\x18\x03 \x01(\x08\x1a\xaf\x01\n\x0eValidatorSetV0\x12\x13\n\x0bquorum_hash\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ore_height\x18\x02 \x01(\r\x12U\n\x07members\x18\x03 \x03(\x0b\x32\x44.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorV0\x12\x1c\n\x14threshold_public_key\x18\x04 \x01(\x0c\x1a\x92\x02\n\x1fGetCurrentQuorumsInfoResponseV0\x12\x15\n\rquorum_hashes\x18\x01 \x03(\x0c\x12\x1b\n\x13\x63urrent_quorum_hash\x18\x02 \x01(\x0c\x12_\n\x0evalidator_sets\x18\x03 \x03(\x0b\x32G.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorSetV0\x12\x1b\n\x13last_block_proposer\x18\x04 \x01(\x0c\x12=\n\x08metadata\x18\x05 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\t\n\x07version\"\xf4\x01\n\x1fGetIdentityTokenBalancesRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityTokenBalancesRequest.GetIdentityTokenBalancesRequestV0H\x00\x1aZ\n!GetIdentityTokenBalancesRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x11\n\ttoken_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xad\x05\n GetIdentityTokenBalancesResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse.GetIdentityTokenBalancesResponseV0H\x00\x1a\x8f\x04\n\"GetIdentityTokenBalancesResponseV0\x12\x86\x01\n\x0etoken_balances\x18\x01 \x01(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse.GetIdentityTokenBalancesResponseV0.TokenBalancesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aG\n\x11TokenBalanceEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x14\n\x07\x62\x61lance\x18\x02 \x01(\x04H\x00\x88\x01\x01\x42\n\n\x08_balance\x1a\x9a\x01\n\rTokenBalances\x12\x88\x01\n\x0etoken_balances\x18\x01 \x03(\x0b\x32p.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse.GetIdentityTokenBalancesResponseV0.TokenBalanceEntryB\x08\n\x06resultB\t\n\x07version\"\xfc\x01\n!GetIdentitiesTokenBalancesRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesRequest.GetIdentitiesTokenBalancesRequestV0H\x00\x1a\\\n#GetIdentitiesTokenBalancesRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x14\n\x0cidentity_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xf2\x05\n\"GetIdentitiesTokenBalancesResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse.GetIdentitiesTokenBalancesResponseV0H\x00\x1a\xce\x04\n$GetIdentitiesTokenBalancesResponseV0\x12\x9b\x01\n\x17identity_token_balances\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse.GetIdentitiesTokenBalancesResponseV0.IdentityTokenBalancesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aR\n\x19IdentityTokenBalanceEntry\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x14\n\x07\x62\x61lance\x18\x02 \x01(\x04H\x00\x88\x01\x01\x42\n\n\x08_balance\x1a\xb7\x01\n\x15IdentityTokenBalances\x12\x9d\x01\n\x17identity_token_balances\x18\x01 \x03(\x0b\x32|.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse.GetIdentitiesTokenBalancesResponseV0.IdentityTokenBalanceEntryB\x08\n\x06resultB\t\n\x07version\"\xe8\x01\n\x1cGetIdentityTokenInfosRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetIdentityTokenInfosRequest.GetIdentityTokenInfosRequestV0H\x00\x1aW\n\x1eGetIdentityTokenInfosRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x11\n\ttoken_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\x98\x06\n\x1dGetIdentityTokenInfosResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0H\x00\x1a\x83\x05\n\x1fGetIdentityTokenInfosResponseV0\x12z\n\x0btoken_infos\x18\x01 \x01(\x0b\x32\x63.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0.TokenInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a(\n\x16TokenIdentityInfoEntry\x12\x0e\n\x06\x66rozen\x18\x01 \x01(\x08\x1a\xb0\x01\n\x0eTokenInfoEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x82\x01\n\x04info\x18\x02 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0.TokenIdentityInfoEntryH\x00\x88\x01\x01\x42\x07\n\x05_info\x1a\x8a\x01\n\nTokenInfos\x12|\n\x0btoken_infos\x18\x01 \x03(\x0b\x32g.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse.GetIdentityTokenInfosResponseV0.TokenInfoEntryB\x08\n\x06resultB\t\n\x07version\"\xf0\x01\n\x1eGetIdentitiesTokenInfosRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosRequest.GetIdentitiesTokenInfosRequestV0H\x00\x1aY\n GetIdentitiesTokenInfosRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x14\n\x0cidentity_ids\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xca\x06\n\x1fGetIdentitiesTokenInfosResponse\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0H\x00\x1a\xaf\x05\n!GetIdentitiesTokenInfosResponseV0\x12\x8f\x01\n\x14identity_token_infos\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0.IdentityTokenInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a(\n\x16TokenIdentityInfoEntry\x12\x0e\n\x06\x66rozen\x18\x01 \x01(\x08\x1a\xb7\x01\n\x0eTokenInfoEntry\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x86\x01\n\x04info\x18\x02 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0.TokenIdentityInfoEntryH\x00\x88\x01\x01\x42\x07\n\x05_info\x1a\x97\x01\n\x12IdentityTokenInfos\x12\x80\x01\n\x0btoken_infos\x18\x01 \x03(\x0b\x32k.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse.GetIdentitiesTokenInfosResponseV0.TokenInfoEntryB\x08\n\x06resultB\t\n\x07version\"\xbf\x01\n\x17GetTokenStatusesRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetTokenStatusesRequest.GetTokenStatusesRequestV0H\x00\x1a=\n\x19GetTokenStatusesRequestV0\x12\x11\n\ttoken_ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xe7\x04\n\x18GetTokenStatusesResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetTokenStatusesResponse.GetTokenStatusesResponseV0H\x00\x1a\xe1\x03\n\x1aGetTokenStatusesResponseV0\x12v\n\x0etoken_statuses\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetTokenStatusesResponse.GetTokenStatusesResponseV0.TokenStatusesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x44\n\x10TokenStatusEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x13\n\x06paused\x18\x02 \x01(\x08H\x00\x88\x01\x01\x42\t\n\x07_paused\x1a\x88\x01\n\rTokenStatuses\x12w\n\x0etoken_statuses\x18\x01 \x03(\x0b\x32_.org.dash.platform.dapi.v0.GetTokenStatusesResponse.GetTokenStatusesResponseV0.TokenStatusEntryB\x08\n\x06resultB\t\n\x07version\"\xef\x01\n#GetTokenDirectPurchasePricesRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesRequest.GetTokenDirectPurchasePricesRequestV0H\x00\x1aI\n%GetTokenDirectPurchasePricesRequestV0\x12\x11\n\ttoken_ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x8b\t\n$GetTokenDirectPurchasePricesResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0H\x00\x1a\xe1\x07\n&GetTokenDirectPurchasePricesResponseV0\x12\xa9\x01\n\x1ctoken_direct_purchase_prices\x18\x01 \x01(\x0b\x32\x80\x01.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.TokenDirectPurchasePricesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x33\n\x10PriceForQuantity\x12\x10\n\x08quantity\x18\x01 \x01(\x04\x12\r\n\x05price\x18\x02 \x01(\x04\x1a\xa7\x01\n\x0fPricingSchedule\x12\x93\x01\n\x12price_for_quantity\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.PriceForQuantity\x1a\xe4\x01\n\x1dTokenDirectPurchasePriceEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x15\n\x0b\x66ixed_price\x18\x02 \x01(\x04H\x00\x12\x90\x01\n\x0evariable_price\x18\x03 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.PricingScheduleH\x00\x42\x07\n\x05price\x1a\xc8\x01\n\x19TokenDirectPurchasePrices\x12\xaa\x01\n\x1btoken_direct_purchase_price\x18\x01 \x03(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse.GetTokenDirectPurchasePricesResponseV0.TokenDirectPurchasePriceEntryB\x08\n\x06resultB\t\n\x07version\"\xce\x01\n\x1bGetTokenContractInfoRequest\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetTokenContractInfoRequest.GetTokenContractInfoRequestV0H\x00\x1a@\n\x1dGetTokenContractInfoRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xfb\x03\n\x1cGetTokenContractInfoResponse\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetTokenContractInfoResponse.GetTokenContractInfoResponseV0H\x00\x1a\xe9\x02\n\x1eGetTokenContractInfoResponseV0\x12|\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32l.org.dash.platform.dapi.v0.GetTokenContractInfoResponse.GetTokenContractInfoResponseV0.TokenContractInfoDataH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aM\n\x15TokenContractInfoData\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17token_contract_position\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xef\x04\n)GetTokenPreProgrammedDistributionsRequest\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsRequest.GetTokenPreProgrammedDistributionsRequestV0H\x00\x1a\xb6\x03\n+GetTokenPreProgrammedDistributionsRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x98\x01\n\rstart_at_info\x18\x02 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsRequest.GetTokenPreProgrammedDistributionsRequestV0.StartAtInfoH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x04 \x01(\x08\x1a\x9a\x01\n\x0bStartAtInfo\x12\x15\n\rstart_time_ms\x18\x01 \x01(\x04\x12\x1c\n\x0fstart_recipient\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12%\n\x18start_recipient_included\x18\x03 \x01(\x08H\x01\x88\x01\x01\x42\x12\n\x10_start_recipientB\x1b\n\x19_start_recipient_includedB\x10\n\x0e_start_at_infoB\x08\n\x06_limitB\t\n\x07version\"\xec\x07\n*GetTokenPreProgrammedDistributionsResponse\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0H\x00\x1a\xaf\x06\n,GetTokenPreProgrammedDistributionsResponseV0\x12\xa5\x01\n\x13token_distributions\x18\x01 \x01(\x0b\x32\x85\x01.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0.TokenDistributionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a>\n\x16TokenDistributionEntry\x12\x14\n\x0crecipient_id\x18\x01 \x01(\x0c\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x04\x1a\xd4\x01\n\x1bTokenTimedDistributionEntry\x12\x11\n\ttimestamp\x18\x01 \x01(\x04\x12\xa1\x01\n\rdistributions\x18\x02 \x03(\x0b\x32\x89\x01.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0.TokenDistributionEntry\x1a\xc3\x01\n\x12TokenDistributions\x12\xac\x01\n\x13token_distributions\x18\x01 \x03(\x0b\x32\x8e\x01.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse.GetTokenPreProgrammedDistributionsResponseV0.TokenTimedDistributionEntryB\x08\n\x06resultB\t\n\x07version\"\x82\x04\n-GetTokenPerpetualDistributionLastClaimRequest\x12\x86\x01\n\x02v0\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimRequest.GetTokenPerpetualDistributionLastClaimRequestV0H\x00\x1aI\n\x11\x43ontractTokenInfo\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17token_contract_position\x18\x02 \x01(\r\x1a\xf1\x01\n/GetTokenPerpetualDistributionLastClaimRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12v\n\rcontract_info\x18\x02 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimRequest.ContractTokenInfoH\x00\x88\x01\x01\x12\x13\n\x0bidentity_id\x18\x04 \x01(\x0c\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x10\n\x0e_contract_infoB\t\n\x07version\"\x93\x05\n.GetTokenPerpetualDistributionLastClaimResponse\x12\x88\x01\n\x02v0\x18\x01 \x01(\x0b\x32z.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimResponse.GetTokenPerpetualDistributionLastClaimResponseV0H\x00\x1a\xca\x03\n0GetTokenPerpetualDistributionLastClaimResponseV0\x12\x9f\x01\n\nlast_claim\x18\x01 \x01(\x0b\x32\x88\x01.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimResponse.GetTokenPerpetualDistributionLastClaimResponseV0.LastClaimInfoH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ax\n\rLastClaimInfo\x12\x1a\n\x0ctimestamp_ms\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x1a\n\x0c\x62lock_height\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12\x0f\n\x05\x65poch\x18\x03 \x01(\rH\x00\x12\x13\n\traw_bytes\x18\x04 \x01(\x0cH\x00\x42\t\n\x07paid_atB\x08\n\x06resultB\t\n\x07version\"\xca\x01\n\x1aGetTokenTotalSupplyRequest\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetTokenTotalSupplyRequest.GetTokenTotalSupplyRequestV0H\x00\x1a?\n\x1cGetTokenTotalSupplyRequestV0\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xaf\x04\n\x1bGetTokenTotalSupplyResponse\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetTokenTotalSupplyResponse.GetTokenTotalSupplyResponseV0H\x00\x1a\xa0\x03\n\x1dGetTokenTotalSupplyResponseV0\x12\x88\x01\n\x12token_total_supply\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetTokenTotalSupplyResponse.GetTokenTotalSupplyResponseV0.TokenTotalSupplyEntryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ax\n\x15TokenTotalSupplyEntry\x12\x10\n\x08token_id\x18\x01 \x01(\x0c\x12\x30\n(total_aggregated_amount_in_user_accounts\x18\x02 \x01(\x04\x12\x1b\n\x13total_system_amount\x18\x03 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd2\x01\n\x13GetGroupInfoRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetGroupInfoRequest.GetGroupInfoRequestV0H\x00\x1a\\\n\x15GetGroupInfoRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17group_contract_position\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xd4\x05\n\x14GetGroupInfoResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0H\x00\x1a\xda\x04\n\x16GetGroupInfoResponseV0\x12\x66\n\ngroup_info\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0.GroupInfoH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x04 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x34\n\x10GroupMemberEntry\x12\x11\n\tmember_id\x18\x01 \x01(\x0c\x12\r\n\x05power\x18\x02 \x01(\r\x1a\x98\x01\n\x0eGroupInfoEntry\x12h\n\x07members\x18\x01 \x03(\x0b\x32W.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0.GroupMemberEntry\x12\x1c\n\x14group_required_power\x18\x02 \x01(\r\x1a\x8a\x01\n\tGroupInfo\x12n\n\ngroup_info\x18\x01 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetGroupInfoResponse.GetGroupInfoResponseV0.GroupInfoEntryH\x00\x88\x01\x01\x42\r\n\x0b_group_infoB\x08\n\x06resultB\t\n\x07version\"\xed\x03\n\x14GetGroupInfosRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetGroupInfosRequest.GetGroupInfosRequestV0H\x00\x1au\n\x1cStartAtGroupContractPosition\x12%\n\x1dstart_group_contract_position\x18\x01 \x01(\r\x12.\n&start_group_contract_position_included\x18\x02 \x01(\x08\x1a\xfc\x01\n\x16GetGroupInfosRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12{\n start_at_group_contract_position\x18\x02 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetGroupInfosRequest.StartAtGroupContractPositionH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x04 \x01(\x08\x42#\n!_start_at_group_contract_positionB\x08\n\x06_countB\t\n\x07version\"\xff\x05\n\x15GetGroupInfosResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0H\x00\x1a\x82\x05\n\x17GetGroupInfosResponseV0\x12j\n\x0bgroup_infos\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0.GroupInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x04 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x34\n\x10GroupMemberEntry\x12\x11\n\tmember_id\x18\x01 \x01(\x0c\x12\r\n\x05power\x18\x02 \x01(\r\x1a\xc3\x01\n\x16GroupPositionInfoEntry\x12\x1f\n\x17group_contract_position\x18\x01 \x01(\r\x12j\n\x07members\x18\x02 \x03(\x0b\x32Y.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0.GroupMemberEntry\x12\x1c\n\x14group_required_power\x18\x03 \x01(\r\x1a\x82\x01\n\nGroupInfos\x12t\n\x0bgroup_infos\x18\x01 \x03(\x0b\x32_.org.dash.platform.dapi.v0.GetGroupInfosResponse.GetGroupInfosResponseV0.GroupPositionInfoEntryB\x08\n\x06resultB\t\n\x07version\"\xbe\x04\n\x16GetGroupActionsRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetGroupActionsRequest.GetGroupActionsRequestV0H\x00\x1aL\n\x0fStartAtActionId\x12\x17\n\x0fstart_action_id\x18\x01 \x01(\x0c\x12 \n\x18start_action_id_included\x18\x02 \x01(\x08\x1a\xc8\x02\n\x18GetGroupActionsRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17group_contract_position\x18\x02 \x01(\r\x12N\n\x06status\x18\x03 \x01(\x0e\x32>.org.dash.platform.dapi.v0.GetGroupActionsRequest.ActionStatus\x12\x62\n\x12start_at_action_id\x18\x04 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetGroupActionsRequest.StartAtActionIdH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x42\x15\n\x13_start_at_action_idB\x08\n\x06_count\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\x92\"\n\x17GetGroupActionsResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0H\x00\x1a\x8f!\n\x19GetGroupActionsResponseV0\x12r\n\rgroup_actions\x18\x01 \x01(\x0b\x32Y.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.GroupActionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a[\n\tMintEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x14\n\x0crecipient_id\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a[\n\tBurnEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x14\n\x0c\x62urn_from_id\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1aJ\n\x0b\x46reezeEvent\x12\x11\n\tfrozen_id\x18\x01 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1aL\n\rUnfreezeEvent\x12\x11\n\tfrozen_id\x18\x01 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\x66\n\x17\x44\x65stroyFrozenFundsEvent\x12\x11\n\tfrozen_id\x18\x01 \x01(\x0c\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x04\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\x64\n\x13SharedEncryptedNote\x12\x18\n\x10sender_key_index\x18\x01 \x01(\r\x12\x1b\n\x13recipient_key_index\x18\x02 \x01(\r\x12\x16\n\x0e\x65ncrypted_data\x18\x03 \x01(\x0c\x1a{\n\x15PersonalEncryptedNote\x12!\n\x19root_encryption_key_index\x18\x01 \x01(\r\x12\'\n\x1f\x64\x65rivation_encryption_key_index\x18\x02 \x01(\r\x12\x16\n\x0e\x65ncrypted_data\x18\x03 \x01(\x0c\x1a\xe9\x01\n\x14\x45mergencyActionEvent\x12\x81\x01\n\x0b\x61\x63tion_type\x18\x01 \x01(\x0e\x32l.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.EmergencyActionEvent.ActionType\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\"#\n\nActionType\x12\t\n\x05PAUSE\x10\x00\x12\n\n\x06RESUME\x10\x01\x42\x0e\n\x0c_public_note\x1a\x64\n\x16TokenConfigUpdateEvent\x12 \n\x18token_config_update_item\x18\x01 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\xe6\x03\n\x1eUpdateDirectPurchasePriceEvent\x12\x15\n\x0b\x66ixed_price\x18\x01 \x01(\x04H\x00\x12\x95\x01\n\x0evariable_price\x18\x02 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UpdateDirectPurchasePriceEvent.PricingScheduleH\x00\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x01\x88\x01\x01\x1a\x33\n\x10PriceForQuantity\x12\x10\n\x08quantity\x18\x01 \x01(\x04\x12\r\n\x05price\x18\x02 \x01(\x04\x1a\xac\x01\n\x0fPricingSchedule\x12\x98\x01\n\x12price_for_quantity\x18\x01 \x03(\x0b\x32|.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UpdateDirectPurchasePriceEvent.PriceForQuantityB\x07\n\x05priceB\x0e\n\x0c_public_note\x1a\x63\n\x0fMintToPoolEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x16\n\x0e\x61\x63tions_digest\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\x65\n\x11\x42urnFromPoolEvent\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x04\x12\x16\n\x0e\x61\x63tions_digest\x18\x02 \x01(\x0c\x12\x18\n\x0bpublic_note\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x0e\n\x0c_public_note\x1a\xfc\x02\n\x10GroupActionEvent\x12n\n\x0btoken_event\x18\x01 \x01(\x0b\x32W.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.TokenEventH\x00\x12t\n\x0e\x64ocument_event\x18\x02 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.DocumentEventH\x00\x12t\n\x0e\x63ontract_event\x18\x03 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.ContractEventH\x00\x42\x0c\n\nevent_type\x1a\x8b\x01\n\rDocumentEvent\x12r\n\x06\x63reate\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.DocumentCreateEventH\x00\x42\x06\n\x04type\x1a/\n\x13\x44ocumentCreateEvent\x12\x18\n\x10\x63reated_document\x18\x01 \x01(\x0c\x1a/\n\x13\x43ontractUpdateEvent\x12\x18\n\x10updated_contract\x18\x01 \x01(\x0c\x1a\x8b\x01\n\rContractEvent\x12r\n\x06update\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.ContractUpdateEventH\x00\x42\x06\n\x04type\x1a\xc1\t\n\nTokenEvent\x12\x66\n\x04mint\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.MintEventH\x00\x12\x66\n\x04\x62urn\x18\x02 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.BurnEventH\x00\x12j\n\x06\x66reeze\x18\x03 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.FreezeEventH\x00\x12n\n\x08unfreeze\x18\x04 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UnfreezeEventH\x00\x12\x84\x01\n\x14\x64\x65stroy_frozen_funds\x18\x05 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.DestroyFrozenFundsEventH\x00\x12}\n\x10\x65mergency_action\x18\x06 \x01(\x0b\x32\x61.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.EmergencyActionEventH\x00\x12\x82\x01\n\x13token_config_update\x18\x07 \x01(\x0b\x32\x63.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.TokenConfigUpdateEventH\x00\x12\x83\x01\n\x0cupdate_price\x18\x08 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.UpdateDirectPurchasePriceEventH\x00\x12t\n\x0cmint_to_pool\x18\t \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.MintToPoolEventH\x00\x12x\n\x0e\x62urn_from_pool\x18\n \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.BurnFromPoolEventH\x00\x42\x06\n\x04type\x1a\x93\x01\n\x10GroupActionEntry\x12\x11\n\taction_id\x18\x01 \x01(\x0c\x12l\n\x05\x65vent\x18\x02 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.GroupActionEvent\x1a\x84\x01\n\x0cGroupActions\x12t\n\rgroup_actions\x18\x01 \x03(\x0b\x32].org.dash.platform.dapi.v0.GetGroupActionsResponse.GetGroupActionsResponseV0.GroupActionEntryB\x08\n\x06resultB\t\n\x07version\"\x88\x03\n\x1cGetGroupActionSignersRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetGroupActionSignersRequest.GetGroupActionSignersRequestV0H\x00\x1a\xce\x01\n\x1eGetGroupActionSignersRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1f\n\x17group_contract_position\x18\x02 \x01(\r\x12T\n\x06status\x18\x03 \x01(\x0e\x32\x44.org.dash.platform.dapi.v0.GetGroupActionSignersRequest.ActionStatus\x12\x11\n\taction_id\x18\x04 \x01(\x0c\x12\r\n\x05prove\x18\x05 \x01(\x08\"&\n\x0c\x41\x63tionStatus\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\n\n\x06\x43LOSED\x10\x01\x42\t\n\x07version\"\x8b\x05\n\x1dGetGroupActionSignersResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetGroupActionSignersResponse.GetGroupActionSignersResponseV0H\x00\x1a\xf6\x03\n\x1fGetGroupActionSignersResponseV0\x12\x8b\x01\n\x14group_action_signers\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetGroupActionSignersResponse.GetGroupActionSignersResponseV0.GroupActionSignersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x35\n\x11GroupActionSigner\x12\x11\n\tsigner_id\x18\x01 \x01(\x0c\x12\r\n\x05power\x18\x02 \x01(\r\x1a\x91\x01\n\x12GroupActionSigners\x12{\n\x07signers\x18\x01 \x03(\x0b\x32j.org.dash.platform.dapi.v0.GetGroupActionSignersResponse.GetGroupActionSignersResponseV0.GroupActionSignerB\x08\n\x06resultB\t\n\x07version\"\xb5\x01\n\x15GetAddressInfoRequest\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetAddressInfoRequest.GetAddressInfoRequestV0H\x00\x1a\x39\n\x17GetAddressInfoRequestV0\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x85\x01\n\x10\x41\x64\x64ressInfoEntry\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12J\n\x11\x62\x61lance_and_nonce\x18\x02 \x01(\x0b\x32*.org.dash.platform.dapi.v0.BalanceAndNonceH\x00\x88\x01\x01\x42\x14\n\x12_balance_and_nonce\"1\n\x0f\x42\x61lanceAndNonce\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\r\n\x05nonce\x18\x02 \x01(\r\"_\n\x12\x41\x64\x64ressInfoEntries\x12I\n\x14\x61\x64\x64ress_info_entries\x18\x01 \x03(\x0b\x32+.org.dash.platform.dapi.v0.AddressInfoEntry\"m\n\x14\x41\x64\x64ressBalanceChange\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12\x19\n\x0bset_balance\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12\x1c\n\x0e\x61\x64\x64_to_balance\x18\x03 \x01(\x04\x42\x02\x30\x01H\x00\x42\x0b\n\toperation\"x\n\x1a\x42lockAddressBalanceChanges\x12\x18\n\x0c\x62lock_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12@\n\x07\x63hanges\x18\x02 \x03(\x0b\x32/.org.dash.platform.dapi.v0.AddressBalanceChange\"k\n\x1b\x41\x64\x64ressBalanceUpdateEntries\x12L\n\rblock_changes\x18\x01 \x03(\x0b\x32\x35.org.dash.platform.dapi.v0.BlockAddressBalanceChanges\"\xe1\x02\n\x16GetAddressInfoResponse\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetAddressInfoResponse.GetAddressInfoResponseV0H\x00\x1a\xe1\x01\n\x18GetAddressInfoResponseV0\x12I\n\x12\x61\x64\x64ress_info_entry\x18\x01 \x01(\x0b\x32+.org.dash.platform.dapi.v0.AddressInfoEntryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc3\x01\n\x18GetAddressesInfosRequest\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetAddressesInfosRequest.GetAddressesInfosRequestV0H\x00\x1a>\n\x1aGetAddressesInfosRequestV0\x12\x11\n\taddresses\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf1\x02\n\x19GetAddressesInfosResponse\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetAddressesInfosResponse.GetAddressesInfosResponseV0H\x00\x1a\xe8\x01\n\x1bGetAddressesInfosResponseV0\x12M\n\x14\x61\x64\x64ress_info_entries\x18\x01 \x01(\x0b\x32-.org.dash.platform.dapi.v0.AddressInfoEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb5\x01\n\x1dGetAddressesTrunkStateRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetAddressesTrunkStateRequest.GetAddressesTrunkStateRequestV0H\x00\x1a!\n\x1fGetAddressesTrunkStateRequestV0B\t\n\x07version\"\xaa\x02\n\x1eGetAddressesTrunkStateResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetAddressesTrunkStateResponse.GetAddressesTrunkStateResponseV0H\x00\x1a\x92\x01\n GetAddressesTrunkStateResponseV0\x12/\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.Proof\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\t\n\x07version\"\xf0\x01\n\x1eGetAddressesBranchStateRequest\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetAddressesBranchStateRequest.GetAddressesBranchStateRequestV0H\x00\x1aY\n GetAddressesBranchStateRequestV0\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\r\n\x05\x64\x65pth\x18\x02 \x01(\r\x12\x19\n\x11\x63heckpoint_height\x18\x03 \x01(\x04\x42\t\n\x07version\"\xd1\x01\n\x1fGetAddressesBranchStateResponse\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetAddressesBranchStateResponse.GetAddressesBranchStateResponseV0H\x00\x1a\x37\n!GetAddressesBranchStateResponseV0\x12\x12\n\nmerk_proof\x18\x02 \x01(\x0c\x42\t\n\x07version\"\x9e\x02\n%GetRecentAddressBalanceChangesRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesRequest.GetRecentAddressBalanceChangesRequestV0H\x00\x1ar\n\'GetRecentAddressBalanceChangesRequestV0\x12\x18\n\x0cstart_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x02 \x01(\x08\x12\x1e\n\x16start_height_exclusive\x18\x03 \x01(\x08\x42\t\n\x07version\"\xb8\x03\n&GetRecentAddressBalanceChangesResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesResponse.GetRecentAddressBalanceChangesResponseV0H\x00\x1a\x88\x02\n(GetRecentAddressBalanceChangesResponseV0\x12`\n\x1e\x61\x64\x64ress_balance_update_entries\x18\x01 \x01(\x0b\x32\x36.org.dash.platform.dapi.v0.AddressBalanceUpdateEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"G\n\x16\x42lockHeightCreditEntry\x12\x18\n\x0c\x62lock_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x13\n\x07\x63redits\x18\x02 \x01(\x04\x42\x02\x30\x01\"\xb0\x01\n\x1d\x43ompactedAddressBalanceChange\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x0c\x12\x19\n\x0bset_credits\x18\x02 \x01(\x04\x42\x02\x30\x01H\x00\x12V\n\x19\x61\x64\x64_to_credits_operations\x18\x03 \x01(\x0b\x32\x31.org.dash.platform.dapi.v0.AddToCreditsOperationsH\x00\x42\x0b\n\toperation\"\\\n\x16\x41\x64\x64ToCreditsOperations\x12\x42\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x31.org.dash.platform.dapi.v0.BlockHeightCreditEntry\"\xae\x01\n#CompactedBlockAddressBalanceChanges\x12\x1e\n\x12start_block_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x1c\n\x10\x65nd_block_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12I\n\x07\x63hanges\x18\x03 \x03(\x0b\x32\x38.org.dash.platform.dapi.v0.CompactedAddressBalanceChange\"\x87\x01\n$CompactedAddressBalanceUpdateEntries\x12_\n\x17\x63ompacted_block_changes\x18\x01 \x03(\x0b\x32>.org.dash.platform.dapi.v0.CompactedBlockAddressBalanceChanges\"\xa9\x02\n.GetRecentCompactedAddressBalanceChangesRequest\x12\x88\x01\n\x02v0\x18\x01 \x01(\x0b\x32z.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesRequest.GetRecentCompactedAddressBalanceChangesRequestV0H\x00\x1a\x61\n0GetRecentCompactedAddressBalanceChangesRequestV0\x12\x1e\n\x12start_block_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf0\x03\n/GetRecentCompactedAddressBalanceChangesResponse\x12\x8a\x01\n\x02v0\x18\x01 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesResponse.GetRecentCompactedAddressBalanceChangesResponseV0H\x00\x1a\xa4\x02\n1GetRecentCompactedAddressBalanceChangesResponseV0\x12s\n(compacted_address_balance_update_entries\x18\x01 \x01(\x0b\x32?.org.dash.platform.dapi.v0.CompactedAddressBalanceUpdateEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\x98\x02\n GetShieldedEncryptedNotesRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesRequest.GetShieldedEncryptedNotesRequestV0H\x00\x1a{\n\"GetShieldedEncryptedNotesRequestV0\x12\x13\n\x0bstart_index\x18\x01 \x01(\x04\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x12\x15\n\x08token_id\x18\x04 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xbc\x05\n!GetShieldedEncryptedNotesResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse.GetShieldedEncryptedNotesResponseV0H\x00\x1a\x9b\x04\n#GetShieldedEncryptedNotesResponseV0\x12\x8a\x01\n\x0f\x65ncrypted_notes\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse.GetShieldedEncryptedNotesResponseV0.EncryptedNotesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aW\n\rEncryptedNote\x12\x11\n\tnullifier\x18\x01 \x01(\x0c\x12\x0b\n\x03\x63mx\x18\x02 \x01(\x0c\x12\x16\n\x0e\x65ncrypted_note\x18\x03 \x01(\x0c\x12\x0e\n\x06\x63v_net\x18\x04 \x01(\x0c\x1a\x91\x01\n\x0e\x45ncryptedNotes\x12\x7f\n\x07\x65ntries\x18\x01 \x03(\x0b\x32n.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse.GetShieldedEncryptedNotesResponseV0.EncryptedNoteB\x08\n\x06resultB\t\n\x07version\"\xd8\x01\n\x19GetShieldedAnchorsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetShieldedAnchorsRequest.GetShieldedAnchorsRequestV0H\x00\x1aP\n\x1bGetShieldedAnchorsRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xb1\x03\n\x1aGetShieldedAnchorsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetShieldedAnchorsResponse.GetShieldedAnchorsResponseV0H\x00\x1a\xa5\x02\n\x1cGetShieldedAnchorsResponseV0\x12m\n\x07\x61nchors\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetShieldedAnchorsResponse.GetShieldedAnchorsResponseV0.AnchorsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x07\x41nchors\x12\x0f\n\x07\x61nchors\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xfc\x01\n\"GetMostRecentShieldedAnchorRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorRequest.GetMostRecentShieldedAnchorRequestV0H\x00\x1aY\n$GetMostRecentShieldedAnchorRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xdc\x02\n#GetMostRecentShieldedAnchorResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorResponse.GetMostRecentShieldedAnchorResponseV0H\x00\x1a\xb5\x01\n%GetMostRecentShieldedAnchorResponseV0\x12\x10\n\x06\x61nchor\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe0\x01\n\x1bGetShieldedPoolStateRequest\x12\x62\n\x02v0\x18\x01 \x01(\x0b\x32T.org.dash.platform.dapi.v0.GetShieldedPoolStateRequest.GetShieldedPoolStateRequestV0H\x00\x1aR\n\x1dGetShieldedPoolStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xcb\x02\n\x1cGetShieldedPoolStateResponse\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetShieldedPoolStateResponse.GetShieldedPoolStateResponseV0H\x00\x1a\xb9\x01\n\x1eGetShieldedPoolStateResponseV0\x12\x1b\n\rtotal_balance\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe4\x01\n\x1cGetShieldedNotesCountRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetShieldedNotesCountRequest.GetShieldedNotesCountRequestV0H\x00\x1aS\n\x1eGetShieldedNotesCountRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\x08token_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\xd3\x02\n\x1dGetShieldedNotesCountResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetShieldedNotesCountResponse.GetShieldedNotesCountResponseV0H\x00\x1a\xbe\x01\n\x1fGetShieldedNotesCountResponseV0\x12\x1f\n\x11total_notes_count\x18\x01 \x01(\x04\x42\x02\x30\x01H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xf8\x01\n\x1cGetShieldedNullifiersRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetShieldedNullifiersRequest.GetShieldedNullifiersRequestV0H\x00\x1ag\n\x1eGetShieldedNullifiersRequestV0\x12\x12\n\nnullifiers\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x12\x15\n\x08token_id\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x42\x0b\n\t_token_idB\t\n\x07version\"\x86\x05\n\x1dGetShieldedNullifiersResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse.GetShieldedNullifiersResponseV0H\x00\x1a\xf1\x03\n\x1fGetShieldedNullifiersResponseV0\x12\x88\x01\n\x12nullifier_statuses\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse.GetShieldedNullifiersResponseV0.NullifierStatusesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x36\n\x0fNullifierStatus\x12\x11\n\tnullifier\x18\x01 \x01(\x0c\x12\x10\n\x08is_spent\x18\x02 \x01(\x08\x1a\x8e\x01\n\x11NullifierStatuses\x12y\n\x07\x65ntries\x18\x01 \x03(\x0b\x32h.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse.GetShieldedNullifiersResponseV0.NullifierStatusB\x08\n\x06resultB\t\n\x07version\"\xb0\x02\n GetPrivateDocumentEntriesRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesRequest.GetPrivateDocumentEntriesRequestV0H\x00\x1a\x92\x01\n\"GetPrivateDocumentEntriesRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x1a\n\x0estart_position\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05prove\x18\x05 \x01(\x08J\x04\x08\x04\x10\x05R\x05\x63ountB\t\n\x07version\"\xfd\x05\n!GetPrivateDocumentEntriesResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse.GetPrivateDocumentEntriesResponseV0H\x00\x1a\xdc\x04\n#GetPrivateDocumentEntriesResponseV0\x12\x8a\x01\n\x07\x65ntries\x18\x01 \x01(\x0b\x32w.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse.GetPrivateDocumentEntriesResponseV0.PrivateDocumentEntriesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1ao\n\x14PrivateDocumentEntry\x12\x14\n\x08position\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x18\n\x0c\x62lock_height\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x19\n\rblock_time_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12\x0c\n\x04\x64\x61ta\x18\x04 \x01(\x0c\x1a\xba\x01\n\x16PrivateDocumentEntries\x12\x86\x01\n\x07\x65ntries\x18\x01 \x03(\x0b\x32u.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse.GetPrivateDocumentEntriesResponseV0.PrivateDocumentEntry\x12\x17\n\x0btotal_count\x18\x02 \x01(\x04\x42\x02\x30\x01\x42\x08\n\x06resultB\t\n\x07version\"\xec\x06\n\x14TenderdashBlockProof\x12\x46\n\x06header\x18\x01 \x01(\x0b\x32\x36.org.dash.platform.dapi.v0.TenderdashBlockProof.Header\x12I\n\x08\x62lock_id\x18\x02 \x01(\x0b\x32\x37.org.dash.platform.dapi.v0.TenderdashBlockProof.BlockId\x12\r\n\x05round\x18\x03 \x01(\r\x12\x13\n\x0bquorum_hash\x18\x04 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x05 \x01(\r\x12\x11\n\tsignature\x18\x06 \x01(\x0c\x1aX\n\x07\x42lockId\x12\x0c\n\x04hash\x18\x01 \x01(\x0c\x12\x16\n\x0epart_set_total\x18\x02 \x01(\r\x12\x15\n\rpart_set_hash\x18\x03 \x01(\x0c\x12\x10\n\x08state_id\x18\x04 \x01(\x0c\x1a\x9a\x04\n\x06Header\x12\x19\n\rblock_version\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x17\n\x0b\x61pp_version\x18\x02 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x08\x63hain_id\x18\x03 \x01(\t\x12\x12\n\x06height\x18\x04 \x01(\x04\x42\x02\x30\x01\x12 \n\x18\x63ore_chain_locked_height\x18\x05 \x01(\r\x12\x18\n\x0ctime_seconds\x18\x06 \x01(\x03\x42\x02\x30\x01\x12\x12\n\ntime_nanos\x18\x07 \x01(\x05\x12N\n\rlast_block_id\x18\x08 \x01(\x0b\x32\x37.org.dash.platform.dapi.v0.TenderdashBlockProof.BlockId\x12\x18\n\x10last_commit_hash\x18\t \x01(\x0c\x12\x11\n\tdata_hash\x18\n \x01(\x0c\x12\x17\n\x0fvalidators_hash\x18\x0b \x01(\x0c\x12\x1c\n\x14next_validators_hash\x18\x0c \x01(\x0c\x12\x16\n\x0e\x63onsensus_hash\x18\r \x01(\x0c\x12\x1b\n\x13next_consensus_hash\x18\x0e \x01(\x0c\x12\x10\n\x08\x61pp_hash\x18\x0f \x01(\x0c\x12\x14\n\x0cresults_hash\x18\x10 \x01(\x0c\x12\x15\n\revidence_hash\x18\x11 \x01(\x0c\x12\x1c\n\x14proposer_pro_tx_hash\x18\x12 \x01(\x0c\x12 \n\x14proposed_app_version\x18\x13 \x01(\x04\x42\x02\x30\x01\"i\n\x1aTenderdashTransactionProof\x12\r\n\x05index\x18\x01 \x01(\r\x12\r\n\x05total\x18\x02 \x01(\r\x12\x18\n\x10transaction_path\x18\x03 \x03(\x0c\x12\x13\n\x0bresult_path\x18\x04 \x03(\x0c\"\xfe\x01\n\"GetOwnerTransactionsInBlockRequest\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockRequest.GetOwnerTransactionsInBlockRequestV0H\x00\x1a[\n$GetOwnerTransactionsInBlockRequestV0\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x10\n\x08owner_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xd8\x04\n#GetOwnerTransactionsInBlockResponse\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockResponse.GetOwnerTransactionsInBlockResponseV0H\x00\x1a\xb1\x03\n%GetOwnerTransactionsInBlockResponseV0\x12\x8b\x01\n\x0ctransactions\x18\x01 \x03(\x0b\x32u.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockResponse.GetOwnerTransactionsInBlockResponseV0.OwnerTransaction\x12>\n\x05proof\x18\x02 \x01(\x0b\x32/.org.dash.platform.dapi.v0.TenderdashBlockProof\x1a\xb9\x01\n\x10OwnerTransaction\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\x12\x0c\n\x04hash\x18\x02 \x01(\x0c\x12\x0c\n\x04\x63ode\x18\x03 \x01(\r\x12\x13\n\x0bresult_data\x18\x04 \x01(\x0c\x12\x14\n\x08gas_used\x18\x05 \x01(\x03\x42\x02\x30\x01\x12\x44\n\x05proof\x18\x06 \x01(\x0b\x32\x35.org.dash.platform.dapi.v0.TenderdashTransactionProofB\t\n\x07version\"\xb9\x01\n\x10GetBlocksRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetBlocksRequest.GetBlocksRequestV0H\x00\x1aL\n\x12GetBlocksRequestV0\x12\x18\n\x0cstart_height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\x85\x05\n\x11GetBlocksResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetBlocksResponse.GetBlocksResponseV0H\x00\x1a\x94\x04\n\x13GetBlocksResponseV0\x12V\n\x06\x62locks\x18\x01 \x03(\x0b\x32\x46.org.dash.platform.dapi.v0.GetBlocksResponse.GetBlocksResponseV0.Block\x1an\n\x0bTransaction\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\x12\x0c\n\x04hash\x18\x02 \x01(\x0c\x12\x0c\n\x04\x63ode\x18\x03 \x01(\r\x12\x13\n\x0bresult_data\x18\x04 \x01(\x0c\x12\x14\n\x08gas_used\x18\x05 \x01(\x03\x42\x02\x30\x01\x1a\xb4\x02\n\x05\x42lock\x12\x12\n\x06height\x18\x01 \x01(\x04\x42\x02\x30\x01\x12\x0c\n\x04hash\x18\x02 \x01(\x0c\x12\x13\n\x07time_ms\x18\x03 \x01(\x04\x42\x02\x30\x01\x12 \n\x18\x63ore_chain_locked_height\x18\x04 \x01(\r\x12\x10\n\x08\x61pp_hash\x18\x05 \x01(\x0c\x12\x1c\n\x14proposer_pro_tx_hash\x18\x06 \x01(\x0c\x12\x62\n\x0ctransactions\x18\x07 \x03(\x0b\x32L.org.dash.platform.dapi.v0.GetBlocksResponse.GetBlocksResponseV0.Transaction\x12>\n\x05proof\x18\x08 \x01(\x0b\x32/.org.dash.platform.dapi.v0.TenderdashBlockProofB\t\n\x07version*Z\n\nKeyPurpose\x12\x12\n\x0e\x41UTHENTICATION\x10\x00\x12\x0e\n\nENCRYPTION\x10\x01\x12\x0e\n\nDECRYPTION\x10\x02\x12\x0c\n\x08TRANSFER\x10\x03\x12\n\n\x06VOTING\x10\x05*\xb9\x01\n\x16\x43ontractModerationList\x12(\n$CONTRACT_MODERATION_LIST_UNSPECIFIED\x10\x00\x12$\n CONTRACT_MODERATION_LIST_BANLIST\x10\x01\x12(\n$CONTRACT_MODERATION_LIST_SUSPENSIONS\x10\x02\x12%\n!CONTRACT_MODERATION_LIST_WARNINGS\x10\x03\x32\x98[\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12\x96\x01\n\x19getIdentitiesContractKeys\x12;.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest\x1a<.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse\x12{\n\x10getIdentityNonce\x12\x32.org.dash.platform.dapi.v0.GetIdentityNonceRequest\x1a\x33.org.dash.platform.dapi.v0.GetIdentityNonceResponse\x12\x93\x01\n\x18getIdentityContractNonce\x12:.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse\x12\xa8\x01\n\x1fgetIdentityKeysRemainingBudgets\x12\x41.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsRequest\x1a\x42.org.dash.platform.dapi.v0.GetIdentityKeysRemainingBudgetsResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\x8a\x01\n\x15getIdentitiesBalances\x12\x37.org.dash.platform.dapi.v0.GetIdentitiesBalancesRequest\x1a\x38.org.dash.platform.dapi.v0.GetIdentitiesBalancesResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\xaf\x01\n#getEvonodesProposedEpochBlocksByIds\x12\x45.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByIdsRequest\x1a\x41.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse\x12\xb3\x01\n%getEvonodesProposedEpochBlocksByRange\x12G.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksByRangeRequest\x1a\x41.org.dash.platform.dapi.v0.GetEvonodesProposedEpochBlocksResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12\xa5\x01\n\x1egetDataContractsLatestVersions\x12@.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsRequest\x1a\x41.org.dash.platform.dapi.v0.GetDataContractsLatestVersionsResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12\x89\x01\n\x17getDataContractsByRange\x12\x39.org.dash.platform.dapi.v0.GetDataContractsByRangeRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12\x87\x01\n\x14getContractGroupInfo\x12\x36.org.dash.platform.dapi.v0.GetContractGroupInfoRequest\x1a\x37.org.dash.platform.dapi.v0.GetContractGroupInfoResponse\x12\x90\x01\n\x17getContractGroupMembers\x12\x39.org.dash.platform.dapi.v0.GetContractGroupMembersRequest\x1a:.org.dash.platform.dapi.v0.GetContractGroupMembersResponse\x12\x9f\x01\n\x1cgetContractGroupsForContract\x12>.org.dash.platform.dapi.v0.GetContractGroupsForContractRequest\x1a?.org.dash.platform.dapi.v0.GetContractGroupsForContractResponse\x12\x9c\x01\n\x1bgetContractModerationStatus\x12=.org.dash.platform.dapi.v0.GetContractModerationStatusRequest\x1a>.org.dash.platform.dapi.v0.GetContractModerationStatusResponse\x12\x9f\x01\n\x1cgetContractModerationEntries\x12>.org.dash.platform.dapi.v0.GetContractModerationEntriesRequest\x1a?.org.dash.platform.dapi.v0.GetContractModerationEntriesResponse\x12\x9c\x01\n\x1bgetContractDocumentRemovals\x12=.org.dash.platform.dapi.v0.GetContractDocumentRemovalsRequest\x1a>.org.dash.platform.dapi.v0.GetContractDocumentRemovalsResponse\x12\x8d\x01\n\x16getContractTeamActions\x12\x38.org.dash.platform.dapi.v0.GetContractTeamActionsRequest\x1a\x39.org.dash.platform.dapi.v0.GetContractTeamActionsResponse\x12\x9f\x01\n\x1cgetContractTeamActionSigners\x12>.org.dash.platform.dapi.v0.GetContractTeamActionSignersRequest\x1a?.org.dash.platform.dapi.v0.GetContractTeamActionSignersResponse\x12\xae\x01\n!getContractModerationActionCounts\x12\x43.org.dash.platform.dapi.v0.GetContractModerationActionCountsRequest\x1a\x44.org.dash.platform.dapi.v0.GetContractModerationActionCountsResponse\x12\x81\x01\n\x12getContractFeePots\x12\x34.org.dash.platform.dapi.v0.GetContractFeePotsRequest\x1a\x35.org.dash.platform.dapi.v0.GetContractFeePotsResponse\x12\x81\x01\n\x12getDocumentHistory\x12\x34.org.dash.platform.dapi.v0.GetDocumentHistoryRequest\x1a\x35.org.dash.platform.dapi.v0.GetDocumentHistoryResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\xb4\x01\n#getIdentityByNonUniquePublicKeyHash\x12\x45.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashRequest\x1a\x46.org.dash.platform.dapi.v0.GetIdentityByNonUniquePublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\xa5\x01\n\x1egetRecentStateTransitionStatus\x12@.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusRequest\x1a\x41.org.dash.platform.dapi.v0.GetRecentStateTransitionStatusResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponse\x12\x8d\x01\n\x16getFinalizedEpochInfos\x12\x38.org.dash.platform.dapi.v0.GetFinalizedEpochInfosRequest\x1a\x39.org.dash.platform.dapi.v0.GetFinalizedEpochInfosResponse\x12\x8a\x01\n\x15getContestedResources\x12\x37.org.dash.platform.dapi.v0.GetContestedResourcesRequest\x1a\x38.org.dash.platform.dapi.v0.GetContestedResourcesResponse\x12\xa2\x01\n\x1dgetContestedResourceVoteState\x12?.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest\x1a@.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse\x12\xba\x01\n%getContestedResourceVotersForIdentity\x12G.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest\x1aH.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse\x12\xae\x01\n!getContestedResourceIdentityVotes\x12\x43.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest\x1a\x44.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse\x12\x8a\x01\n\x15getVotePollsByEndDate\x12\x37.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest\x1a\x38.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse\x12\x8a\x01\n\x15getYesNoVotePollState\x12\x37.org.dash.platform.dapi.v0.GetYesNoVotePollStateRequest\x1a\x38.org.dash.platform.dapi.v0.GetYesNoVotePollStateResponse\x12\x8d\x01\n\x16getMasternodeYesNoVote\x12\x38.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteRequest\x1a\x39.org.dash.platform.dapi.v0.GetMasternodeYesNoVoteResponse\x12\xa5\x01\n\x1egetPrefundedSpecializedBalance\x12@.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest\x1a\x41.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse\x12\x96\x01\n\x19getTotalCreditsInPlatform\x12;.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest\x1a<.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse\x12x\n\x0fgetPathElements\x12\x31.org.dash.platform.dapi.v0.GetPathElementsRequest\x1a\x32.org.dash.platform.dapi.v0.GetPathElementsResponse\x12\x66\n\tgetStatus\x12+.org.dash.platform.dapi.v0.GetStatusRequest\x1a,.org.dash.platform.dapi.v0.GetStatusResponse\x12\x8a\x01\n\x15getCurrentQuorumsInfo\x12\x37.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest\x1a\x38.org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse\x12\x93\x01\n\x18getIdentityTokenBalances\x12:.org.dash.platform.dapi.v0.GetIdentityTokenBalancesRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityTokenBalancesResponse\x12\x99\x01\n\x1agetIdentitiesTokenBalances\x12<.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesRequest\x1a=.org.dash.platform.dapi.v0.GetIdentitiesTokenBalancesResponse\x12\x8a\x01\n\x15getIdentityTokenInfos\x12\x37.org.dash.platform.dapi.v0.GetIdentityTokenInfosRequest\x1a\x38.org.dash.platform.dapi.v0.GetIdentityTokenInfosResponse\x12\x90\x01\n\x17getIdentitiesTokenInfos\x12\x39.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosRequest\x1a:.org.dash.platform.dapi.v0.GetIdentitiesTokenInfosResponse\x12{\n\x10getTokenStatuses\x12\x32.org.dash.platform.dapi.v0.GetTokenStatusesRequest\x1a\x33.org.dash.platform.dapi.v0.GetTokenStatusesResponse\x12\x9f\x01\n\x1cgetTokenDirectPurchasePrices\x12>.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesRequest\x1a?.org.dash.platform.dapi.v0.GetTokenDirectPurchasePricesResponse\x12\x87\x01\n\x14getTokenContractInfo\x12\x36.org.dash.platform.dapi.v0.GetTokenContractInfoRequest\x1a\x37.org.dash.platform.dapi.v0.GetTokenContractInfoResponse\x12\xb1\x01\n\"getTokenPreProgrammedDistributions\x12\x44.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsRequest\x1a\x45.org.dash.platform.dapi.v0.GetTokenPreProgrammedDistributionsResponse\x12\xbd\x01\n&getTokenPerpetualDistributionLastClaim\x12H.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimRequest\x1aI.org.dash.platform.dapi.v0.GetTokenPerpetualDistributionLastClaimResponse\x12\x84\x01\n\x13getTokenTotalSupply\x12\x35.org.dash.platform.dapi.v0.GetTokenTotalSupplyRequest\x1a\x36.org.dash.platform.dapi.v0.GetTokenTotalSupplyResponse\x12o\n\x0cgetGroupInfo\x12..org.dash.platform.dapi.v0.GetGroupInfoRequest\x1a/.org.dash.platform.dapi.v0.GetGroupInfoResponse\x12r\n\rgetGroupInfos\x12/.org.dash.platform.dapi.v0.GetGroupInfosRequest\x1a\x30.org.dash.platform.dapi.v0.GetGroupInfosResponse\x12x\n\x0fgetGroupActions\x12\x31.org.dash.platform.dapi.v0.GetGroupActionsRequest\x1a\x32.org.dash.platform.dapi.v0.GetGroupActionsResponse\x12\x8a\x01\n\x15getGroupActionSigners\x12\x37.org.dash.platform.dapi.v0.GetGroupActionSignersRequest\x1a\x38.org.dash.platform.dapi.v0.GetGroupActionSignersResponse\x12u\n\x0egetAddressInfo\x12\x30.org.dash.platform.dapi.v0.GetAddressInfoRequest\x1a\x31.org.dash.platform.dapi.v0.GetAddressInfoResponse\x12~\n\x11getAddressesInfos\x12\x33.org.dash.platform.dapi.v0.GetAddressesInfosRequest\x1a\x34.org.dash.platform.dapi.v0.GetAddressesInfosResponse\x12\x8d\x01\n\x16getAddressesTrunkState\x12\x38.org.dash.platform.dapi.v0.GetAddressesTrunkStateRequest\x1a\x39.org.dash.platform.dapi.v0.GetAddressesTrunkStateResponse\x12\x90\x01\n\x17getAddressesBranchState\x12\x39.org.dash.platform.dapi.v0.GetAddressesBranchStateRequest\x1a:.org.dash.platform.dapi.v0.GetAddressesBranchStateResponse\x12\xa5\x01\n\x1egetRecentAddressBalanceChanges\x12@.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesRequest\x1a\x41.org.dash.platform.dapi.v0.GetRecentAddressBalanceChangesResponse\x12\xc0\x01\n\'getRecentCompactedAddressBalanceChanges\x12I.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesRequest\x1aJ.org.dash.platform.dapi.v0.GetRecentCompactedAddressBalanceChangesResponse\x12\x96\x01\n\x19getShieldedEncryptedNotes\x12;.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesRequest\x1a<.org.dash.platform.dapi.v0.GetShieldedEncryptedNotesResponse\x12\x81\x01\n\x12getShieldedAnchors\x12\x34.org.dash.platform.dapi.v0.GetShieldedAnchorsRequest\x1a\x35.org.dash.platform.dapi.v0.GetShieldedAnchorsResponse\x12\x9c\x01\n\x1bgetMostRecentShieldedAnchor\x12=.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorRequest\x1a>.org.dash.platform.dapi.v0.GetMostRecentShieldedAnchorResponse\x12\x87\x01\n\x14getShieldedPoolState\x12\x36.org.dash.platform.dapi.v0.GetShieldedPoolStateRequest\x1a\x37.org.dash.platform.dapi.v0.GetShieldedPoolStateResponse\x12\x8a\x01\n\x15getShieldedNotesCount\x12\x37.org.dash.platform.dapi.v0.GetShieldedNotesCountRequest\x1a\x38.org.dash.platform.dapi.v0.GetShieldedNotesCountResponse\x12\x8a\x01\n\x15getShieldedNullifiers\x12\x37.org.dash.platform.dapi.v0.GetShieldedNullifiersRequest\x1a\x38.org.dash.platform.dapi.v0.GetShieldedNullifiersResponse\x12\x96\x01\n\x19getPrivateDocumentEntries\x12;.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesRequest\x1a<.org.dash.platform.dapi.v0.GetPrivateDocumentEntriesResponse\x12\x9c\x01\n\x1bgetOwnerTransactionsInBlock\x12=.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockRequest\x1a>.org.dash.platform.dapi.v0.GetOwnerTransactionsInBlockResponse\x12\x66\n\tgetBlocks\x12+.org.dash.platform.dapi.v0.GetBlocksRequest\x1a,.org.dash.platform.dapi.v0.GetBlocksResponseb\x06proto3' , dependencies=[google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) @@ -62,8 +62,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=94833, - serialized_end=94923, + serialized_start=94990, + serialized_end=95080, ) _sym_db.RegisterEnumDescriptor(_KEYPURPOSE) @@ -98,8 +98,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=94926, - serialized_end=95111, + serialized_start=95083, + serialized_end=95268, ) _sym_db.RegisterEnumDescriptor(_CONTRACTMODERATIONLIST) @@ -497,11 +497,21 @@ serialized_options=None, type=None, create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='DELETED', index=2, number=2, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='ERASING', index=3, number=3, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), ], containing_type=None, serialized_options=None, - serialized_start=36251, - serialized_end=36282, + serialized_start=36382, + serialized_end=36439, ) _sym_db.RegisterEnumDescriptor(_GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_LIFECYCLE_STATE) @@ -535,8 +545,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=50655, - serialized_end=50731, + serialized_start=50812, + serialized_end=50888, ) _sym_db.RegisterEnumDescriptor(_GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0_YESNOVOTEPOLL_VOTINGPOWERROUNDING) @@ -565,8 +575,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=52137, - serialized_end=52175, + serialized_start=52294, + serialized_end=52332, ) _sym_db.RegisterEnumDescriptor(_GETMASTERNODEYESNOVOTERESPONSE_GETMASTERNODEYESNOVOTERESPONSEV0_MASTERNODEYESNOVOTE_CHOICE) @@ -595,8 +605,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=53126, - serialized_end=53199, + serialized_start=53283, + serialized_end=53356, ) _sym_db.RegisterEnumDescriptor(_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0_RESULTTYPE) @@ -625,8 +635,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=54121, - serialized_end=54200, + serialized_start=54278, + serialized_end=54357, ) _sym_db.RegisterEnumDescriptor(_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_FINISHEDVOTEINFO_FINISHEDVOTEOUTCOME) @@ -655,8 +665,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=57829, - serialized_end=57890, + serialized_start=57986, + serialized_end=58047, ) _sym_db.RegisterEnumDescriptor(_GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSE_GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSEV0_RESOURCEVOTECHOICE_VOTECHOICETYPE) @@ -705,8 +715,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=77739, - serialized_end=77774, + serialized_start=77896, + serialized_end=77931, ) _sym_db.RegisterEnumDescriptor(_GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_EMERGENCYACTIONEVENT_ACTIONTYPE) @@ -9993,6 +10003,34 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=b'0\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='deleted_at_ms', full_name='org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.deleted_at_ms', index=2, + number=3, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'0\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='erasing_started_at_ms', full_name='org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.erasing_started_at_ms', index=3, + number=4, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'0\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='erasing_from_time_ms', full_name='org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.erasing_from_time_ms', index=4, + number=5, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'0\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='erasing_from_revision', full_name='org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.erasing_from_revision', index=5, + number=6, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'0\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -10007,7 +10045,7 @@ oneofs=[ ], serialized_start=36090, - serialized_end=36282, + serialized_end=36439, ) _GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_HISTORY = _descriptor.Descriptor( @@ -10044,8 +10082,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=36285, - serialized_end=36514, + serialized_start=36442, + serialized_end=36671, ) _GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1 = _descriptor.Descriptor( @@ -10095,7 +10133,7 @@ fields=[]), ], serialized_start=35762, - serialized_end=36524, + serialized_end=36681, ) _GETDOCUMENTHISTORYRESPONSE = _descriptor.Descriptor( @@ -10138,7 +10176,7 @@ fields=[]), ], serialized_start=35041, - serialized_end=36535, + serialized_end=36692, ) @@ -10176,8 +10214,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=36687, - serialized_end=36764, + serialized_start=36844, + serialized_end=36921, ) _GETIDENTITYBYPUBLICKEYHASHREQUEST = _descriptor.Descriptor( @@ -10212,8 +10250,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=36538, - serialized_end=36775, + serialized_start=36695, + serialized_end=36932, ) @@ -10263,8 +10301,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=36931, - serialized_end=37113, + serialized_start=37088, + serialized_end=37270, ) _GETIDENTITYBYPUBLICKEYHASHRESPONSE = _descriptor.Descriptor( @@ -10299,8 +10337,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=36778, - serialized_end=37124, + serialized_start=36935, + serialized_end=37281, ) @@ -10350,8 +10388,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=37436, - serialized_end=37564, + serialized_start=37593, + serialized_end=37721, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHREQUEST_GETIDENTITYBYNONUNIQUEPUBLICKEYHASHREQUESTV1 = _descriptor.Descriptor( @@ -10400,8 +10438,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=37567, - serialized_end=37695, + serialized_start=37724, + serialized_end=37852, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHREQUEST = _descriptor.Descriptor( @@ -10443,8 +10481,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=37127, - serialized_end=37706, + serialized_start=37284, + serialized_end=37863, ) @@ -10480,8 +10518,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=38452, - serialized_end=38506, + serialized_start=38609, + serialized_end=38663, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSE_GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSEV0_IDENTITYPROVEDRESPONSE = _descriptor.Descriptor( @@ -10523,8 +10561,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=38509, - serialized_end=38675, + serialized_start=38666, + serialized_end=38832, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSE_GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSEV0 = _descriptor.Descriptor( @@ -10573,8 +10611,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=38023, - serialized_end=38691, + serialized_start=38180, + serialized_end=38848, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSE_GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSEV1_IDENTITYRESPONSE = _descriptor.Descriptor( @@ -10609,8 +10647,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=38452, - serialized_end=38506, + serialized_start=38609, + serialized_end=38663, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSE_GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSEV1 = _descriptor.Descriptor( @@ -10659,8 +10697,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=38694, - serialized_end=39078, + serialized_start=38851, + serialized_end=39235, ) _GETIDENTITYBYNONUNIQUEPUBLICKEYHASHRESPONSE = _descriptor.Descriptor( @@ -10702,8 +10740,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=37709, - serialized_end=39089, + serialized_start=37866, + serialized_end=39246, ) @@ -10748,8 +10786,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=39247, - serialized_end=39362, + serialized_start=39404, + serialized_end=39519, ) _WAITFORSTATETRANSITIONRESULTREQUEST = _descriptor.Descriptor( @@ -10784,8 +10822,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=39092, - serialized_end=39373, + serialized_start=39249, + serialized_end=39530, ) @@ -10816,8 +10854,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=39534, - serialized_end=39586, + serialized_start=39691, + serialized_end=39743, ) _WAITFORSTATETRANSITIONRESULTRESPONSE_WAITFORSTATETRANSITIONRESULTRESPONSEV0 = _descriptor.Descriptor( @@ -10873,8 +10911,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=39589, - serialized_end=39955, + serialized_start=39746, + serialized_end=40112, ) _WAITFORSTATETRANSITIONRESULTRESPONSE = _descriptor.Descriptor( @@ -10909,8 +10947,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=39376, - serialized_end=39966, + serialized_start=39533, + serialized_end=40123, ) @@ -10941,8 +10979,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=40130, - serialized_end=40202, + serialized_start=40287, + serialized_end=40359, ) _GETRECENTSTATETRANSITIONSTATUSREQUEST = _descriptor.Descriptor( @@ -10977,8 +11015,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=39969, - serialized_end=40213, + serialized_start=40126, + serialized_end=40370, ) @@ -11016,8 +11054,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=40900, - serialized_end=41004, + serialized_start=41057, + serialized_end=41161, ) _GETRECENTSTATETRANSITIONSTATUSRESPONSE_GETRECENTSTATETRANSITIONSTATUSRESPONSEV0_PENDING = _descriptor.Descriptor( @@ -11040,8 +11078,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41006, - serialized_end=41015, + serialized_start=41163, + serialized_end=41172, ) _GETRECENTSTATETRANSITIONSTATUSRESPONSE_GETRECENTSTATETRANSITIONSTATUSRESPONSEV0_UNKNOWN = _descriptor.Descriptor( @@ -11064,8 +11102,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41017, - serialized_end=41026, + serialized_start=41174, + serialized_end=41183, ) _GETRECENTSTATETRANSITIONSTATUSRESPONSE_GETRECENTSTATETRANSITIONSTATUSRESPONSEV0 = _descriptor.Descriptor( @@ -11121,8 +11159,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=40381, - serialized_end=41036, + serialized_start=40538, + serialized_end=41193, ) _GETRECENTSTATETRANSITIONSTATUSRESPONSE = _descriptor.Descriptor( @@ -11157,8 +11195,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=40216, - serialized_end=41047, + serialized_start=40373, + serialized_end=41204, ) @@ -11196,8 +11234,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41175, - serialized_end=41235, + serialized_start=41332, + serialized_end=41392, ) _GETCONSENSUSPARAMSREQUEST = _descriptor.Descriptor( @@ -11232,8 +11270,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=41050, - serialized_end=41246, + serialized_start=41207, + serialized_end=41403, ) @@ -11278,8 +11316,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41377, - serialized_end=41457, + serialized_start=41534, + serialized_end=41614, ) _GETCONSENSUSPARAMSRESPONSE_CONSENSUSPARAMSEVIDENCE = _descriptor.Descriptor( @@ -11323,8 +11361,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41459, - serialized_end=41557, + serialized_start=41616, + serialized_end=41714, ) _GETCONSENSUSPARAMSRESPONSE_GETCONSENSUSPARAMSRESPONSEV0 = _descriptor.Descriptor( @@ -11361,8 +11399,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41560, - serialized_end=41778, + serialized_start=41717, + serialized_end=41935, ) _GETCONSENSUSPARAMSRESPONSE = _descriptor.Descriptor( @@ -11397,8 +11435,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=41249, - serialized_end=41789, + serialized_start=41406, + serialized_end=41946, ) @@ -11429,8 +11467,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=41953, - serialized_end=42009, + serialized_start=42110, + serialized_end=42166, ) _GETPROTOCOLVERSIONUPGRADESTATEREQUEST = _descriptor.Descriptor( @@ -11465,8 +11503,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=41792, - serialized_end=42020, + serialized_start=41949, + serialized_end=42177, ) @@ -11497,8 +11535,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=42485, - serialized_end=42635, + serialized_start=42642, + serialized_end=42792, ) _GETPROTOCOLVERSIONUPGRADESTATERESPONSE_GETPROTOCOLVERSIONUPGRADESTATERESPONSEV0_VERSIONENTRY = _descriptor.Descriptor( @@ -11535,8 +11573,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=42637, - serialized_end=42695, + serialized_start=42794, + serialized_end=42852, ) _GETPROTOCOLVERSIONUPGRADESTATERESPONSE_GETPROTOCOLVERSIONUPGRADESTATERESPONSEV0 = _descriptor.Descriptor( @@ -11585,8 +11623,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=42188, - serialized_end=42705, + serialized_start=42345, + serialized_end=42862, ) _GETPROTOCOLVERSIONUPGRADESTATERESPONSE = _descriptor.Descriptor( @@ -11621,8 +11659,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=42023, - serialized_end=42716, + serialized_start=42180, + serialized_end=42873, ) @@ -11667,8 +11705,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=42896, - serialized_end=42999, + serialized_start=43053, + serialized_end=43156, ) _GETPROTOCOLVERSIONUPGRADEVOTESTATUSREQUEST = _descriptor.Descriptor( @@ -11703,8 +11741,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=42719, - serialized_end=43010, + serialized_start=42876, + serialized_end=43167, ) @@ -11735,8 +11773,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=43513, - serialized_end=43688, + serialized_start=43670, + serialized_end=43845, ) _GETPROTOCOLVERSIONUPGRADEVOTESTATUSRESPONSE_GETPROTOCOLVERSIONUPGRADEVOTESTATUSRESPONSEV0_VERSIONSIGNAL = _descriptor.Descriptor( @@ -11773,8 +11811,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=43690, - serialized_end=43743, + serialized_start=43847, + serialized_end=43900, ) _GETPROTOCOLVERSIONUPGRADEVOTESTATUSRESPONSE_GETPROTOCOLVERSIONUPGRADEVOTESTATUSRESPONSEV0 = _descriptor.Descriptor( @@ -11823,8 +11861,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=43194, - serialized_end=43753, + serialized_start=43351, + serialized_end=43910, ) _GETPROTOCOLVERSIONUPGRADEVOTESTATUSRESPONSE = _descriptor.Descriptor( @@ -11859,8 +11897,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=43013, - serialized_end=43764, + serialized_start=43170, + serialized_end=43921, ) @@ -11912,8 +11950,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=43877, - serialized_end=44001, + serialized_start=44034, + serialized_end=44158, ) _GETEPOCHSINFOREQUEST = _descriptor.Descriptor( @@ -11948,8 +11986,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=43767, - serialized_end=44012, + serialized_start=43924, + serialized_end=44169, ) @@ -11980,8 +12018,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=44373, - serialized_end=44490, + serialized_start=44530, + serialized_end=44647, ) _GETEPOCHSINFORESPONSE_GETEPOCHSINFORESPONSEV0_EPOCHINFO = _descriptor.Descriptor( @@ -12046,8 +12084,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=44493, - serialized_end=44659, + serialized_start=44650, + serialized_end=44816, ) _GETEPOCHSINFORESPONSE_GETEPOCHSINFORESPONSEV0 = _descriptor.Descriptor( @@ -12096,8 +12134,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=44129, - serialized_end=44669, + serialized_start=44286, + serialized_end=44826, ) _GETEPOCHSINFORESPONSE = _descriptor.Descriptor( @@ -12132,8 +12170,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=44015, - serialized_end=44680, + serialized_start=44172, + serialized_end=44837, ) @@ -12192,8 +12230,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=44821, - serialized_end=44991, + serialized_start=44978, + serialized_end=45148, ) _GETFINALIZEDEPOCHINFOSREQUEST = _descriptor.Descriptor( @@ -12228,8 +12266,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=44683, - serialized_end=45002, + serialized_start=44840, + serialized_end=45159, ) @@ -12260,8 +12298,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=45428, - serialized_end=45592, + serialized_start=45585, + serialized_end=45749, ) _GETFINALIZEDEPOCHINFOSRESPONSE_GETFINALIZEDEPOCHINFOSRESPONSEV0_FINALIZEDEPOCHINFO = _descriptor.Descriptor( @@ -12375,8 +12413,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=45595, - serialized_end=46138, + serialized_start=45752, + serialized_end=46295, ) _GETFINALIZEDEPOCHINFOSRESPONSE_GETFINALIZEDEPOCHINFOSRESPONSEV0_BLOCKPROPOSER = _descriptor.Descriptor( @@ -12413,8 +12451,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=46140, - serialized_end=46197, + serialized_start=46297, + serialized_end=46354, ) _GETFINALIZEDEPOCHINFOSRESPONSE_GETFINALIZEDEPOCHINFOSRESPONSEV0 = _descriptor.Descriptor( @@ -12463,8 +12501,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=45146, - serialized_end=46207, + serialized_start=45303, + serialized_end=46364, ) _GETFINALIZEDEPOCHINFOSRESPONSE = _descriptor.Descriptor( @@ -12499,8 +12537,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=45005, - serialized_end=46218, + serialized_start=45162, + serialized_end=46375, ) @@ -12538,8 +12576,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=46713, - serialized_end=46782, + serialized_start=46870, + serialized_end=46939, ) _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0 = _descriptor.Descriptor( @@ -12635,8 +12673,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=46356, - serialized_end=46816, + serialized_start=46513, + serialized_end=46973, ) _GETCONTESTEDRESOURCESREQUEST = _descriptor.Descriptor( @@ -12671,8 +12709,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=46221, - serialized_end=46827, + serialized_start=46378, + serialized_end=46984, ) @@ -12703,8 +12741,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=47269, - serialized_end=47329, + serialized_start=47426, + serialized_end=47486, ) _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0 = _descriptor.Descriptor( @@ -12753,8 +12791,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=46968, - serialized_end=47339, + serialized_start=47125, + serialized_end=47496, ) _GETCONTESTEDRESOURCESRESPONSE = _descriptor.Descriptor( @@ -12789,8 +12827,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=46830, - serialized_end=47350, + serialized_start=46987, + serialized_end=47507, ) @@ -12828,8 +12866,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=47863, - serialized_end=47936, + serialized_start=48020, + serialized_end=48093, ) _GETVOTEPOLLSBYENDDATEREQUEST_GETVOTEPOLLSBYENDDATEREQUESTV0_ENDATTIMEINFO = _descriptor.Descriptor( @@ -12866,8 +12904,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=47938, - serialized_end=48005, + serialized_start=48095, + serialized_end=48162, ) _GETVOTEPOLLSBYENDDATEREQUEST_GETVOTEPOLLSBYENDDATEREQUESTV0 = _descriptor.Descriptor( @@ -12952,8 +12990,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=47488, - serialized_end=48064, + serialized_start=47645, + serialized_end=48221, ) _GETVOTEPOLLSBYENDDATEREQUEST = _descriptor.Descriptor( @@ -12988,8 +13026,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=47353, - serialized_end=48075, + serialized_start=47510, + serialized_end=48232, ) @@ -13027,8 +13065,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=48524, - serialized_end=48610, + serialized_start=48681, + serialized_end=48767, ) _GETVOTEPOLLSBYENDDATERESPONSE_GETVOTEPOLLSBYENDDATERESPONSEV0_SERIALIZEDVOTEPOLLSBYTIMESTAMPS = _descriptor.Descriptor( @@ -13065,8 +13103,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=48613, - serialized_end=48828, + serialized_start=48770, + serialized_end=48985, ) _GETVOTEPOLLSBYENDDATERESPONSE_GETVOTEPOLLSBYENDDATERESPONSEV0 = _descriptor.Descriptor( @@ -13115,8 +13153,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=48216, - serialized_end=48838, + serialized_start=48373, + serialized_end=48995, ) _GETVOTEPOLLSBYENDDATERESPONSE = _descriptor.Descriptor( @@ -13151,8 +13189,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=48078, - serialized_end=48849, + serialized_start=48235, + serialized_end=49006, ) @@ -13190,8 +13228,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=48986, - serialized_end=49055, + serialized_start=49143, + serialized_end=49212, ) _GETYESNOVOTEPOLLSTATEREQUEST = _descriptor.Descriptor( @@ -13226,8 +13264,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=48852, - serialized_end=49066, + serialized_start=49009, + serialized_end=49223, ) @@ -13279,8 +13317,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=49482, - serialized_end=49579, + serialized_start=49639, + serialized_end=49736, ) _GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0_FINISHEDYESNOVOTEPOLL = _descriptor.Descriptor( @@ -13352,8 +13390,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=49582, - serialized_end=50002, + serialized_start=49739, + serialized_end=50159, ) _GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0_YESNOVOTEPOLL_DECISIONPROPOSAL = _descriptor.Descriptor( @@ -13383,8 +13421,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=50411, - serialized_end=50450, + serialized_start=50568, + serialized_end=50607, ) _GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0_YESNOVOTEPOLL_FRACTIONOFTOTAL = _descriptor.Descriptor( @@ -13428,8 +13466,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=50453, - serialized_end=50653, + serialized_start=50610, + serialized_end=50810, ) _GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0_YESNOVOTEPOLL = _descriptor.Descriptor( @@ -13498,8 +13536,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=50005, - serialized_end=50766, + serialized_start=50162, + serialized_end=50923, ) _GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0_YESNOVOTEPOLLSTATE = _descriptor.Descriptor( @@ -13569,8 +13607,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=50769, - serialized_end=51264, + serialized_start=50926, + serialized_end=51421, ) _GETYESNOVOTEPOLLSTATERESPONSE_GETYESNOVOTEPOLLSTATERESPONSEV0 = _descriptor.Descriptor( @@ -13619,8 +13657,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=49207, - serialized_end=51274, + serialized_start=49364, + serialized_end=51431, ) _GETYESNOVOTEPOLLSTATERESPONSE = _descriptor.Descriptor( @@ -13655,8 +13693,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=49069, - serialized_end=51285, + serialized_start=49226, + serialized_end=51442, ) @@ -13701,8 +13739,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=51425, - serialized_end=51516, + serialized_start=51582, + serialized_end=51673, ) _GETMASTERNODEYESNOVOTEREQUEST = _descriptor.Descriptor( @@ -13737,8 +13775,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=51288, - serialized_end=51527, + serialized_start=51445, + serialized_end=51684, ) @@ -13777,8 +13815,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=51957, - serialized_end=52175, + serialized_start=52114, + serialized_end=52332, ) _GETMASTERNODEYESNOVOTERESPONSE_GETMASTERNODEYESNOVOTERESPONSEV0_MASTERNODEYESNOVOTEENTRY = _descriptor.Descriptor( @@ -13808,8 +13846,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=52178, - serialized_end=52330, + serialized_start=52335, + serialized_end=52487, ) _GETMASTERNODEYESNOVOTERESPONSE_GETMASTERNODEYESNOVOTERESPONSEV0 = _descriptor.Descriptor( @@ -13858,8 +13896,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=51671, - serialized_end=52340, + serialized_start=51828, + serialized_end=52497, ) _GETMASTERNODEYESNOVOTERESPONSE = _descriptor.Descriptor( @@ -13894,8 +13932,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=51530, - serialized_end=52351, + serialized_start=51687, + serialized_end=52508, ) @@ -13933,8 +13971,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=53040, - serialized_end=53124, + serialized_start=53197, + serialized_end=53281, ) _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0 = _descriptor.Descriptor( @@ -14031,8 +14069,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=52513, - serialized_end=53238, + serialized_start=52670, + serialized_end=53395, ) _GETCONTESTEDRESOURCEVOTESTATEREQUEST = _descriptor.Descriptor( @@ -14067,8 +14105,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=52354, - serialized_end=53249, + serialized_start=52511, + serialized_end=53406, ) @@ -14140,8 +14178,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=53749, - serialized_end=54223, + serialized_start=53906, + serialized_end=54380, ) _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS = _descriptor.Descriptor( @@ -14207,8 +14245,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=54226, - serialized_end=54678, + serialized_start=54383, + serialized_end=54835, ) _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTENDER = _descriptor.Descriptor( @@ -14262,8 +14300,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=54680, - serialized_end=54787, + serialized_start=54837, + serialized_end=54944, ) _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0 = _descriptor.Descriptor( @@ -14312,8 +14350,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=53414, - serialized_end=54797, + serialized_start=53571, + serialized_end=54954, ) _GETCONTESTEDRESOURCEVOTESTATERESPONSE = _descriptor.Descriptor( @@ -14348,8 +14386,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=53252, - serialized_end=54808, + serialized_start=53409, + serialized_end=54965, ) @@ -14387,8 +14425,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=53040, - serialized_end=53124, + serialized_start=53197, + serialized_end=53281, ) _GETCONTESTEDRESOURCEVOTERSFORIDENTITYREQUEST_GETCONTESTEDRESOURCEVOTERSFORIDENTITYREQUESTV0 = _descriptor.Descriptor( @@ -14484,8 +14522,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=54995, - serialized_end=55525, + serialized_start=55152, + serialized_end=55682, ) _GETCONTESTEDRESOURCEVOTERSFORIDENTITYREQUEST = _descriptor.Descriptor( @@ -14520,8 +14558,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=54811, - serialized_end=55536, + serialized_start=54968, + serialized_end=55693, ) @@ -14559,8 +14597,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=56076, - serialized_end=56143, + serialized_start=56233, + serialized_end=56300, ) _GETCONTESTEDRESOURCEVOTERSFORIDENTITYRESPONSE_GETCONTESTEDRESOURCEVOTERSFORIDENTITYRESPONSEV0 = _descriptor.Descriptor( @@ -14609,8 +14647,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=55726, - serialized_end=56153, + serialized_start=55883, + serialized_end=56310, ) _GETCONTESTEDRESOURCEVOTERSFORIDENTITYRESPONSE = _descriptor.Descriptor( @@ -14645,8 +14683,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=55539, - serialized_end=56164, + serialized_start=55696, + serialized_end=56321, ) @@ -14684,8 +14722,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=56713, - serialized_end=56810, + serialized_start=56870, + serialized_end=56967, ) _GETCONTESTEDRESOURCEIDENTITYVOTESREQUEST_GETCONTESTEDRESOURCEIDENTITYVOTESREQUESTV0 = _descriptor.Descriptor( @@ -14755,8 +14793,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=56338, - serialized_end=56841, + serialized_start=56495, + serialized_end=56998, ) _GETCONTESTEDRESOURCEIDENTITYVOTESREQUEST = _descriptor.Descriptor( @@ -14791,8 +14829,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=56167, - serialized_end=56852, + serialized_start=56324, + serialized_end=57009, ) @@ -14830,8 +14868,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=57355, - serialized_end=57602, + serialized_start=57512, + serialized_end=57759, ) _GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSE_GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSEV0_RESOURCEVOTECHOICE = _descriptor.Descriptor( @@ -14874,8 +14912,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=57605, - serialized_end=57906, + serialized_start=57762, + serialized_end=58063, ) _GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSE_GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSEV0_CONTESTEDRESOURCEIDENTITYVOTE = _descriptor.Descriptor( @@ -14926,8 +14964,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=57909, - serialized_end=58186, + serialized_start=58066, + serialized_end=58343, ) _GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSE_GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSEV0 = _descriptor.Descriptor( @@ -14976,8 +15014,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=57029, - serialized_end=58196, + serialized_start=57186, + serialized_end=58353, ) _GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSE = _descriptor.Descriptor( @@ -15012,8 +15050,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=56855, - serialized_end=58207, + serialized_start=57012, + serialized_end=58364, ) @@ -15051,8 +15089,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=58371, - serialized_end=58439, + serialized_start=58528, + serialized_end=58596, ) _GETPREFUNDEDSPECIALIZEDBALANCEREQUEST = _descriptor.Descriptor( @@ -15087,8 +15125,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=58210, - serialized_end=58450, + serialized_start=58367, + serialized_end=58607, ) @@ -15138,8 +15176,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=58618, - serialized_end=58807, + serialized_start=58775, + serialized_end=58964, ) _GETPREFUNDEDSPECIALIZEDBALANCERESPONSE = _descriptor.Descriptor( @@ -15174,8 +15212,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=58453, - serialized_end=58818, + serialized_start=58610, + serialized_end=58975, ) @@ -15206,8 +15244,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=58967, - serialized_end=59018, + serialized_start=59124, + serialized_end=59175, ) _GETTOTALCREDITSINPLATFORMREQUEST = _descriptor.Descriptor( @@ -15242,8 +15280,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=58821, - serialized_end=59029, + serialized_start=58978, + serialized_end=59186, ) @@ -15293,8 +15331,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=59182, - serialized_end=59366, + serialized_start=59339, + serialized_end=59523, ) _GETTOTALCREDITSINPLATFORMRESPONSE = _descriptor.Descriptor( @@ -15329,8 +15367,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=59032, - serialized_end=59377, + serialized_start=59189, + serialized_end=59534, ) @@ -15375,8 +15413,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=59496, - serialized_end=59565, + serialized_start=59653, + serialized_end=59722, ) _GETPATHELEMENTSREQUEST = _descriptor.Descriptor( @@ -15411,8 +15449,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=59380, - serialized_end=59576, + serialized_start=59537, + serialized_end=59733, ) @@ -15443,8 +15481,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=59949, - serialized_end=59977, + serialized_start=60106, + serialized_end=60134, ) _GETPATHELEMENTSRESPONSE_GETPATHELEMENTSRESPONSEV0 = _descriptor.Descriptor( @@ -15493,8 +15531,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=59699, - serialized_end=59987, + serialized_start=59856, + serialized_end=60144, ) _GETPATHELEMENTSRESPONSE = _descriptor.Descriptor( @@ -15529,8 +15567,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=59579, - serialized_end=59998, + serialized_start=59736, + serialized_end=60155, ) @@ -15554,8 +15592,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=60099, - serialized_end=60119, + serialized_start=60256, + serialized_end=60276, ) _GETSTATUSREQUEST = _descriptor.Descriptor( @@ -15590,8 +15628,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=60001, - serialized_end=60130, + serialized_start=60158, + serialized_end=60287, ) @@ -15646,8 +15684,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=61007, - serialized_end=61101, + serialized_start=61164, + serialized_end=61258, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_VERSION_PROTOCOL_TENDERDASH = _descriptor.Descriptor( @@ -15684,8 +15722,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=61334, - serialized_end=61374, + serialized_start=61491, + serialized_end=61531, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_VERSION_PROTOCOL_DRIVE = _descriptor.Descriptor( @@ -15729,8 +15767,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=61376, - serialized_end=61436, + serialized_start=61533, + serialized_end=61593, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_VERSION_PROTOCOL = _descriptor.Descriptor( @@ -15767,8 +15805,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=61104, - serialized_end=61436, + serialized_start=61261, + serialized_end=61593, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_VERSION = _descriptor.Descriptor( @@ -15805,8 +15843,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=60794, - serialized_end=61436, + serialized_start=60951, + serialized_end=61593, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_TIME = _descriptor.Descriptor( @@ -15872,8 +15910,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=61438, - serialized_end=61565, + serialized_start=61595, + serialized_end=61722, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_NODE = _descriptor.Descriptor( @@ -15915,8 +15953,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=61567, - serialized_end=61627, + serialized_start=61724, + serialized_end=61784, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_CHAIN = _descriptor.Descriptor( @@ -16007,8 +16045,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=61630, - serialized_end=61937, + serialized_start=61787, + serialized_end=62094, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_NETWORK = _descriptor.Descriptor( @@ -16052,8 +16090,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=61939, - serialized_end=62006, + serialized_start=62096, + serialized_end=62163, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0_STATESYNC = _descriptor.Descriptor( @@ -16132,8 +16170,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=62009, - serialized_end=62270, + serialized_start=62166, + serialized_end=62427, ) _GETSTATUSRESPONSE_GETSTATUSRESPONSEV0 = _descriptor.Descriptor( @@ -16198,8 +16236,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=60235, - serialized_end=62270, + serialized_start=60392, + serialized_end=62427, ) _GETSTATUSRESPONSE = _descriptor.Descriptor( @@ -16234,8 +16272,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=60133, - serialized_end=62281, + serialized_start=60290, + serialized_end=62438, ) @@ -16259,8 +16297,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=62418, - serialized_end=62450, + serialized_start=62575, + serialized_end=62607, ) _GETCURRENTQUORUMSINFOREQUEST = _descriptor.Descriptor( @@ -16295,8 +16333,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=62284, - serialized_end=62461, + serialized_start=62441, + serialized_end=62618, ) @@ -16341,8 +16379,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=62601, - serialized_end=62671, + serialized_start=62758, + serialized_end=62828, ) _GETCURRENTQUORUMSINFORESPONSE_VALIDATORSETV0 = _descriptor.Descriptor( @@ -16393,8 +16431,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=62674, - serialized_end=62849, + serialized_start=62831, + serialized_end=63006, ) _GETCURRENTQUORUMSINFORESPONSE_GETCURRENTQUORUMSINFORESPONSEV0 = _descriptor.Descriptor( @@ -16452,8 +16490,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=62852, - serialized_end=63126, + serialized_start=63009, + serialized_end=63283, ) _GETCURRENTQUORUMSINFORESPONSE = _descriptor.Descriptor( @@ -16488,8 +16526,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=62464, - serialized_end=63137, + serialized_start=62621, + serialized_end=63294, ) @@ -16534,8 +16572,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=63283, - serialized_end=63373, + serialized_start=63440, + serialized_end=63530, ) _GETIDENTITYTOKENBALANCESREQUEST = _descriptor.Descriptor( @@ -16570,8 +16608,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=63140, - serialized_end=63384, + serialized_start=63297, + serialized_end=63541, ) @@ -16614,8 +16652,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=63823, - serialized_end=63894, + serialized_start=63980, + serialized_end=64051, ) _GETIDENTITYTOKENBALANCESRESPONSE_GETIDENTITYTOKENBALANCESRESPONSEV0_TOKENBALANCES = _descriptor.Descriptor( @@ -16645,8 +16683,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=63897, - serialized_end=64051, + serialized_start=64054, + serialized_end=64208, ) _GETIDENTITYTOKENBALANCESRESPONSE_GETIDENTITYTOKENBALANCESRESPONSEV0 = _descriptor.Descriptor( @@ -16695,8 +16733,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=63534, - serialized_end=64061, + serialized_start=63691, + serialized_end=64218, ) _GETIDENTITYTOKENBALANCESRESPONSE = _descriptor.Descriptor( @@ -16731,8 +16769,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=63387, - serialized_end=64072, + serialized_start=63544, + serialized_end=64229, ) @@ -16777,8 +16815,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=64224, - serialized_end=64316, + serialized_start=64381, + serialized_end=64473, ) _GETIDENTITIESTOKENBALANCESREQUEST = _descriptor.Descriptor( @@ -16813,8 +16851,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=64075, - serialized_end=64327, + serialized_start=64232, + serialized_end=64484, ) @@ -16857,8 +16895,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=64795, - serialized_end=64877, + serialized_start=64952, + serialized_end=65034, ) _GETIDENTITIESTOKENBALANCESRESPONSE_GETIDENTITIESTOKENBALANCESRESPONSEV0_IDENTITYTOKENBALANCES = _descriptor.Descriptor( @@ -16888,8 +16926,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=64880, - serialized_end=65063, + serialized_start=65037, + serialized_end=65220, ) _GETIDENTITIESTOKENBALANCESRESPONSE_GETIDENTITIESTOKENBALANCESRESPONSEV0 = _descriptor.Descriptor( @@ -16938,8 +16976,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=64483, - serialized_end=65073, + serialized_start=64640, + serialized_end=65230, ) _GETIDENTITIESTOKENBALANCESRESPONSE = _descriptor.Descriptor( @@ -16974,8 +17012,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=64330, - serialized_end=65084, + serialized_start=64487, + serialized_end=65241, ) @@ -17020,8 +17058,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=65221, - serialized_end=65308, + serialized_start=65378, + serialized_end=65465, ) _GETIDENTITYTOKENINFOSREQUEST = _descriptor.Descriptor( @@ -17056,8 +17094,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=65087, - serialized_end=65319, + serialized_start=65244, + serialized_end=65476, ) @@ -17088,8 +17126,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=65733, - serialized_end=65773, + serialized_start=65890, + serialized_end=65930, ) _GETIDENTITYTOKENINFOSRESPONSE_GETIDENTITYTOKENINFOSRESPONSEV0_TOKENINFOENTRY = _descriptor.Descriptor( @@ -17131,8 +17169,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=65776, - serialized_end=65952, + serialized_start=65933, + serialized_end=66109, ) _GETIDENTITYTOKENINFOSRESPONSE_GETIDENTITYTOKENINFOSRESPONSEV0_TOKENINFOS = _descriptor.Descriptor( @@ -17162,8 +17200,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=65955, - serialized_end=66093, + serialized_start=66112, + serialized_end=66250, ) _GETIDENTITYTOKENINFOSRESPONSE_GETIDENTITYTOKENINFOSRESPONSEV0 = _descriptor.Descriptor( @@ -17212,8 +17250,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=65460, - serialized_end=66103, + serialized_start=65617, + serialized_end=66260, ) _GETIDENTITYTOKENINFOSRESPONSE = _descriptor.Descriptor( @@ -17248,8 +17286,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=65322, - serialized_end=66114, + serialized_start=65479, + serialized_end=66271, ) @@ -17294,8 +17332,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=66257, - serialized_end=66346, + serialized_start=66414, + serialized_end=66503, ) _GETIDENTITIESTOKENINFOSREQUEST = _descriptor.Descriptor( @@ -17330,8 +17368,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=66117, - serialized_end=66357, + serialized_start=66274, + serialized_end=66514, ) @@ -17362,8 +17400,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=65733, - serialized_end=65773, + serialized_start=65890, + serialized_end=65930, ) _GETIDENTITIESTOKENINFOSRESPONSE_GETIDENTITIESTOKENINFOSRESPONSEV0_TOKENINFOENTRY = _descriptor.Descriptor( @@ -17405,8 +17443,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=66844, - serialized_end=67027, + serialized_start=67001, + serialized_end=67184, ) _GETIDENTITIESTOKENINFOSRESPONSE_GETIDENTITIESTOKENINFOSRESPONSEV0_IDENTITYTOKENINFOS = _descriptor.Descriptor( @@ -17436,8 +17474,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=67030, - serialized_end=67181, + serialized_start=67187, + serialized_end=67338, ) _GETIDENTITIESTOKENINFOSRESPONSE_GETIDENTITIESTOKENINFOSRESPONSEV0 = _descriptor.Descriptor( @@ -17486,8 +17524,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=66504, - serialized_end=67191, + serialized_start=66661, + serialized_end=67348, ) _GETIDENTITIESTOKENINFOSRESPONSE = _descriptor.Descriptor( @@ -17522,8 +17560,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=66360, - serialized_end=67202, + serialized_start=66517, + serialized_end=67359, ) @@ -17561,8 +17599,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=67324, - serialized_end=67385, + serialized_start=67481, + serialized_end=67542, ) _GETTOKENSTATUSESREQUEST = _descriptor.Descriptor( @@ -17597,8 +17635,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=67205, - serialized_end=67396, + serialized_start=67362, + serialized_end=67553, ) @@ -17641,8 +17679,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=67786, - serialized_end=67854, + serialized_start=67943, + serialized_end=68011, ) _GETTOKENSTATUSESRESPONSE_GETTOKENSTATUSESRESPONSEV0_TOKENSTATUSES = _descriptor.Descriptor( @@ -17672,8 +17710,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=67857, - serialized_end=67993, + serialized_start=68014, + serialized_end=68150, ) _GETTOKENSTATUSESRESPONSE_GETTOKENSTATUSESRESPONSEV0 = _descriptor.Descriptor( @@ -17722,8 +17760,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=67522, - serialized_end=68003, + serialized_start=67679, + serialized_end=68160, ) _GETTOKENSTATUSESRESPONSE = _descriptor.Descriptor( @@ -17758,8 +17796,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=67399, - serialized_end=68014, + serialized_start=67556, + serialized_end=68171, ) @@ -17797,8 +17835,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=68172, - serialized_end=68245, + serialized_start=68329, + serialized_end=68402, ) _GETTOKENDIRECTPURCHASEPRICESREQUEST = _descriptor.Descriptor( @@ -17833,8 +17871,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=68017, - serialized_end=68256, + serialized_start=68174, + serialized_end=68413, ) @@ -17872,8 +17910,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=68746, - serialized_end=68797, + serialized_start=68903, + serialized_end=68954, ) _GETTOKENDIRECTPURCHASEPRICESRESPONSE_GETTOKENDIRECTPURCHASEPRICESRESPONSEV0_PRICINGSCHEDULE = _descriptor.Descriptor( @@ -17903,8 +17941,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=68800, - serialized_end=68967, + serialized_start=68957, + serialized_end=69124, ) _GETTOKENDIRECTPURCHASEPRICESRESPONSE_GETTOKENDIRECTPURCHASEPRICESRESPONSEV0_TOKENDIRECTPURCHASEPRICEENTRY = _descriptor.Descriptor( @@ -17953,8 +17991,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=68970, - serialized_end=69198, + serialized_start=69127, + serialized_end=69355, ) _GETTOKENDIRECTPURCHASEPRICESRESPONSE_GETTOKENDIRECTPURCHASEPRICESRESPONSEV0_TOKENDIRECTPURCHASEPRICES = _descriptor.Descriptor( @@ -17984,8 +18022,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=69201, - serialized_end=69401, + serialized_start=69358, + serialized_end=69558, ) _GETTOKENDIRECTPURCHASEPRICESRESPONSE_GETTOKENDIRECTPURCHASEPRICESRESPONSEV0 = _descriptor.Descriptor( @@ -18034,8 +18072,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=68418, - serialized_end=69411, + serialized_start=68575, + serialized_end=69568, ) _GETTOKENDIRECTPURCHASEPRICESRESPONSE = _descriptor.Descriptor( @@ -18070,8 +18108,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=68259, - serialized_end=69422, + serialized_start=68416, + serialized_end=69579, ) @@ -18109,8 +18147,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=69556, - serialized_end=69620, + serialized_start=69713, + serialized_end=69777, ) _GETTOKENCONTRACTINFOREQUEST = _descriptor.Descriptor( @@ -18145,8 +18183,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=69425, - serialized_end=69631, + serialized_start=69582, + serialized_end=69788, ) @@ -18184,8 +18222,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=70043, - serialized_end=70120, + serialized_start=70200, + serialized_end=70277, ) _GETTOKENCONTRACTINFORESPONSE_GETTOKENCONTRACTINFORESPONSEV0 = _descriptor.Descriptor( @@ -18234,8 +18272,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=69769, - serialized_end=70130, + serialized_start=69926, + serialized_end=70287, ) _GETTOKENCONTRACTINFORESPONSE = _descriptor.Descriptor( @@ -18270,8 +18308,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=69634, - serialized_end=70141, + serialized_start=69791, + serialized_end=70298, ) @@ -18326,8 +18364,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=70574, - serialized_end=70728, + serialized_start=70731, + serialized_end=70885, ) _GETTOKENPREPROGRAMMEDDISTRIBUTIONSREQUEST_GETTOKENPREPROGRAMMEDDISTRIBUTIONSREQUESTV0 = _descriptor.Descriptor( @@ -18388,8 +18426,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=70318, - serialized_end=70756, + serialized_start=70475, + serialized_end=70913, ) _GETTOKENPREPROGRAMMEDDISTRIBUTIONSREQUEST = _descriptor.Descriptor( @@ -18424,8 +18462,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=70144, - serialized_end=70767, + serialized_start=70301, + serialized_end=70924, ) @@ -18463,8 +18501,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=71278, - serialized_end=71340, + serialized_start=71435, + serialized_end=71497, ) _GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSE_GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSEV0_TOKENTIMEDDISTRIBUTIONENTRY = _descriptor.Descriptor( @@ -18501,8 +18539,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=71343, - serialized_end=71555, + serialized_start=71500, + serialized_end=71712, ) _GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSE_GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSEV0_TOKENDISTRIBUTIONS = _descriptor.Descriptor( @@ -18532,8 +18570,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=71558, - serialized_end=71753, + serialized_start=71715, + serialized_end=71910, ) _GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSE_GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSEV0 = _descriptor.Descriptor( @@ -18582,8 +18620,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=70948, - serialized_end=71763, + serialized_start=71105, + serialized_end=71920, ) _GETTOKENPREPROGRAMMEDDISTRIBUTIONSRESPONSE = _descriptor.Descriptor( @@ -18618,8 +18656,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=70770, - serialized_end=71774, + serialized_start=70927, + serialized_end=71931, ) @@ -18657,8 +18695,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=71963, - serialized_end=72036, + serialized_start=72120, + serialized_end=72193, ) _GETTOKENPERPETUALDISTRIBUTIONLASTCLAIMREQUEST_GETTOKENPERPETUALDISTRIBUTIONLASTCLAIMREQUESTV0 = _descriptor.Descriptor( @@ -18714,8 +18752,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=72039, - serialized_end=72280, + serialized_start=72196, + serialized_end=72437, ) _GETTOKENPERPETUALDISTRIBUTIONLASTCLAIMREQUEST = _descriptor.Descriptor( @@ -18750,8 +18788,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=71777, - serialized_end=72291, + serialized_start=71934, + serialized_end=72448, ) @@ -18808,8 +18846,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=72812, - serialized_end=72932, + serialized_start=72969, + serialized_end=73089, ) _GETTOKENPERPETUALDISTRIBUTIONLASTCLAIMRESPONSE_GETTOKENPERPETUALDISTRIBUTIONLASTCLAIMRESPONSEV0 = _descriptor.Descriptor( @@ -18858,8 +18896,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=72484, - serialized_end=72942, + serialized_start=72641, + serialized_end=73099, ) _GETTOKENPERPETUALDISTRIBUTIONLASTCLAIMRESPONSE = _descriptor.Descriptor( @@ -18894,8 +18932,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=72294, - serialized_end=72953, + serialized_start=72451, + serialized_end=73110, ) @@ -18933,8 +18971,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=73084, - serialized_end=73147, + serialized_start=73241, + serialized_end=73304, ) _GETTOKENTOTALSUPPLYREQUEST = _descriptor.Descriptor( @@ -18969,8 +19007,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=72956, - serialized_end=73158, + serialized_start=73113, + serialized_end=73315, ) @@ -19015,8 +19053,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=73579, - serialized_end=73699, + serialized_start=73736, + serialized_end=73856, ) _GETTOKENTOTALSUPPLYRESPONSE_GETTOKENTOTALSUPPLYRESPONSEV0 = _descriptor.Descriptor( @@ -19065,8 +19103,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=73293, - serialized_end=73709, + serialized_start=73450, + serialized_end=73866, ) _GETTOKENTOTALSUPPLYRESPONSE = _descriptor.Descriptor( @@ -19101,8 +19139,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=73161, - serialized_end=73720, + serialized_start=73318, + serialized_end=73877, ) @@ -19147,8 +19185,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=73830, - serialized_end=73922, + serialized_start=73987, + serialized_end=74079, ) _GETGROUPINFOREQUEST = _descriptor.Descriptor( @@ -19183,8 +19221,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=73723, - serialized_end=73933, + serialized_start=73880, + serialized_end=74090, ) @@ -19222,8 +19260,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=74291, - serialized_end=74343, + serialized_start=74448, + serialized_end=74500, ) _GETGROUPINFORESPONSE_GETGROUPINFORESPONSEV0_GROUPINFOENTRY = _descriptor.Descriptor( @@ -19260,8 +19298,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=74346, - serialized_end=74498, + serialized_start=74503, + serialized_end=74655, ) _GETGROUPINFORESPONSE_GETGROUPINFORESPONSEV0_GROUPINFO = _descriptor.Descriptor( @@ -19296,8 +19334,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=74501, - serialized_end=74639, + serialized_start=74658, + serialized_end=74796, ) _GETGROUPINFORESPONSE_GETGROUPINFORESPONSEV0 = _descriptor.Descriptor( @@ -19346,8 +19384,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=74047, - serialized_end=74649, + serialized_start=74204, + serialized_end=74806, ) _GETGROUPINFORESPONSE = _descriptor.Descriptor( @@ -19382,8 +19420,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=73936, - serialized_end=74660, + serialized_start=74093, + serialized_end=74817, ) @@ -19421,8 +19459,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=74773, - serialized_end=74890, + serialized_start=74930, + serialized_end=75047, ) _GETGROUPINFOSREQUEST_GETGROUPINFOSREQUESTV0 = _descriptor.Descriptor( @@ -19483,8 +19521,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=74893, - serialized_end=75145, + serialized_start=75050, + serialized_end=75302, ) _GETGROUPINFOSREQUEST = _descriptor.Descriptor( @@ -19519,8 +19557,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=74663, - serialized_end=75156, + serialized_start=74820, + serialized_end=75313, ) @@ -19558,8 +19596,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=74291, - serialized_end=74343, + serialized_start=74448, + serialized_end=74500, ) _GETGROUPINFOSRESPONSE_GETGROUPINFOSRESPONSEV0_GROUPPOSITIONINFOENTRY = _descriptor.Descriptor( @@ -19603,8 +19641,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=75577, - serialized_end=75772, + serialized_start=75734, + serialized_end=75929, ) _GETGROUPINFOSRESPONSE_GETGROUPINFOSRESPONSEV0_GROUPINFOS = _descriptor.Descriptor( @@ -19634,8 +19672,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=75775, - serialized_end=75905, + serialized_start=75932, + serialized_end=76062, ) _GETGROUPINFOSRESPONSE_GETGROUPINFOSRESPONSEV0 = _descriptor.Descriptor( @@ -19684,8 +19722,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=75273, - serialized_end=75915, + serialized_start=75430, + serialized_end=76072, ) _GETGROUPINFOSRESPONSE = _descriptor.Descriptor( @@ -19720,8 +19758,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=75159, - serialized_end=75926, + serialized_start=75316, + serialized_end=76083, ) @@ -19835,8 +19873,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=76124, - serialized_end=76452, + serialized_start=76281, + serialized_end=76609, ) _GETGROUPACTIONSREQUEST = _descriptor.Descriptor( @@ -19872,8 +19910,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=75929, - serialized_end=76503, + serialized_start=76086, + serialized_end=76660, ) @@ -19923,8 +19961,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=76885, - serialized_end=76976, + serialized_start=77042, + serialized_end=77133, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_BURNEVENT = _descriptor.Descriptor( @@ -19973,8 +20011,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=76978, - serialized_end=77069, + serialized_start=77135, + serialized_end=77226, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_FREEZEEVENT = _descriptor.Descriptor( @@ -20016,8 +20054,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=77071, - serialized_end=77145, + serialized_start=77228, + serialized_end=77302, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_UNFREEZEEVENT = _descriptor.Descriptor( @@ -20059,8 +20097,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=77147, - serialized_end=77223, + serialized_start=77304, + serialized_end=77380, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_DESTROYFROZENFUNDSEVENT = _descriptor.Descriptor( @@ -20109,8 +20147,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=77225, - serialized_end=77327, + serialized_start=77382, + serialized_end=77484, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_SHAREDENCRYPTEDNOTE = _descriptor.Descriptor( @@ -20154,8 +20192,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=77329, - serialized_end=77429, + serialized_start=77486, + serialized_end=77586, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_PERSONALENCRYPTEDNOTE = _descriptor.Descriptor( @@ -20199,8 +20237,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=77431, - serialized_end=77554, + serialized_start=77588, + serialized_end=77711, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_EMERGENCYACTIONEVENT = _descriptor.Descriptor( @@ -20243,8 +20281,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=77557, - serialized_end=77790, + serialized_start=77714, + serialized_end=77947, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_TOKENCONFIGUPDATEEVENT = _descriptor.Descriptor( @@ -20286,8 +20324,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=77792, - serialized_end=77892, + serialized_start=77949, + serialized_end=78049, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_UPDATEDIRECTPURCHASEPRICEEVENT_PRICEFORQUANTITY = _descriptor.Descriptor( @@ -20324,8 +20362,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=68746, - serialized_end=68797, + serialized_start=68903, + serialized_end=68954, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_UPDATEDIRECTPURCHASEPRICEEVENT_PRICINGSCHEDULE = _descriptor.Descriptor( @@ -20355,8 +20393,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=78184, - serialized_end=78356, + serialized_start=78341, + serialized_end=78513, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_UPDATEDIRECTPURCHASEPRICEEVENT = _descriptor.Descriptor( @@ -20410,8 +20448,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=77895, - serialized_end=78381, + serialized_start=78052, + serialized_end=78538, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_MINTTOPOOLEVENT = _descriptor.Descriptor( @@ -20460,8 +20498,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=78383, - serialized_end=78482, + serialized_start=78540, + serialized_end=78639, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_BURNFROMPOOLEVENT = _descriptor.Descriptor( @@ -20510,8 +20548,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=78484, - serialized_end=78585, + serialized_start=78641, + serialized_end=78742, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_GROUPACTIONEVENT = _descriptor.Descriptor( @@ -20560,8 +20598,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=78588, - serialized_end=78968, + serialized_start=78745, + serialized_end=79125, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_DOCUMENTEVENT = _descriptor.Descriptor( @@ -20596,8 +20634,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=78971, - serialized_end=79110, + serialized_start=79128, + serialized_end=79267, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_DOCUMENTCREATEEVENT = _descriptor.Descriptor( @@ -20627,8 +20665,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=79112, - serialized_end=79159, + serialized_start=79269, + serialized_end=79316, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_CONTRACTUPDATEEVENT = _descriptor.Descriptor( @@ -20658,8 +20696,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=79161, - serialized_end=79208, + serialized_start=79318, + serialized_end=79365, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_CONTRACTEVENT = _descriptor.Descriptor( @@ -20694,8 +20732,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=79211, - serialized_end=79350, + serialized_start=79368, + serialized_end=79507, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_TOKENEVENT = _descriptor.Descriptor( @@ -20793,8 +20831,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=79353, - serialized_end=80570, + serialized_start=79510, + serialized_end=80727, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_GROUPACTIONENTRY = _descriptor.Descriptor( @@ -20831,8 +20869,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=80573, - serialized_end=80720, + serialized_start=80730, + serialized_end=80877, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0_GROUPACTIONS = _descriptor.Descriptor( @@ -20862,8 +20900,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=80723, - serialized_end=80855, + serialized_start=80880, + serialized_end=81012, ) _GETGROUPACTIONSRESPONSE_GETGROUPACTIONSRESPONSEV0 = _descriptor.Descriptor( @@ -20912,8 +20950,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=76626, - serialized_end=80865, + serialized_start=76783, + serialized_end=81022, ) _GETGROUPACTIONSRESPONSE = _descriptor.Descriptor( @@ -20948,8 +20986,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=76506, - serialized_end=80876, + serialized_start=76663, + serialized_end=81033, ) @@ -21008,8 +21046,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=81014, - serialized_end=81220, + serialized_start=81171, + serialized_end=81377, ) _GETGROUPACTIONSIGNERSREQUEST = _descriptor.Descriptor( @@ -21045,8 +21083,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=80879, - serialized_end=81271, + serialized_start=81036, + serialized_end=81428, ) @@ -21084,8 +21122,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=81703, - serialized_end=81756, + serialized_start=81860, + serialized_end=81913, ) _GETGROUPACTIONSIGNERSRESPONSE_GETGROUPACTIONSIGNERSRESPONSEV0_GROUPACTIONSIGNERS = _descriptor.Descriptor( @@ -21115,8 +21153,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=81759, - serialized_end=81904, + serialized_start=81916, + serialized_end=82061, ) _GETGROUPACTIONSIGNERSRESPONSE_GETGROUPACTIONSIGNERSRESPONSEV0 = _descriptor.Descriptor( @@ -21165,8 +21203,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=81412, - serialized_end=81914, + serialized_start=81569, + serialized_end=82071, ) _GETGROUPACTIONSIGNERSRESPONSE = _descriptor.Descriptor( @@ -21201,8 +21239,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=81274, - serialized_end=81925, + serialized_start=81431, + serialized_end=82082, ) @@ -21240,8 +21278,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=82041, - serialized_end=82098, + serialized_start=82198, + serialized_end=82255, ) _GETADDRESSINFOREQUEST = _descriptor.Descriptor( @@ -21276,8 +21314,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=81928, - serialized_end=82109, + serialized_start=82085, + serialized_end=82266, ) @@ -21320,8 +21358,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=82112, - serialized_end=82245, + serialized_start=82269, + serialized_end=82402, ) @@ -21359,8 +21397,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=82247, - serialized_end=82296, + serialized_start=82404, + serialized_end=82453, ) @@ -21391,8 +21429,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=82298, - serialized_end=82393, + serialized_start=82455, + serialized_end=82550, ) @@ -21442,8 +21480,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=82395, - serialized_end=82504, + serialized_start=82552, + serialized_end=82661, ) @@ -21481,8 +21519,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=82506, - serialized_end=82626, + serialized_start=82663, + serialized_end=82783, ) @@ -21513,8 +21551,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=82628, - serialized_end=82735, + serialized_start=82785, + serialized_end=82892, ) @@ -21564,8 +21602,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=82855, - serialized_end=83080, + serialized_start=83012, + serialized_end=83237, ) _GETADDRESSINFORESPONSE = _descriptor.Descriptor( @@ -21600,8 +21638,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=82738, - serialized_end=83091, + serialized_start=82895, + serialized_end=83248, ) @@ -21639,8 +21677,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=83216, - serialized_end=83278, + serialized_start=83373, + serialized_end=83435, ) _GETADDRESSESINFOSREQUEST = _descriptor.Descriptor( @@ -21675,8 +21713,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=83094, - serialized_end=83289, + serialized_start=83251, + serialized_end=83446, ) @@ -21726,8 +21764,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=83418, - serialized_end=83650, + serialized_start=83575, + serialized_end=83807, ) _GETADDRESSESINFOSRESPONSE = _descriptor.Descriptor( @@ -21762,8 +21800,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=83292, - serialized_end=83661, + serialized_start=83449, + serialized_end=83818, ) @@ -21787,8 +21825,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=83801, - serialized_end=83834, + serialized_start=83958, + serialized_end=83991, ) _GETADDRESSESTRUNKSTATEREQUEST = _descriptor.Descriptor( @@ -21823,8 +21861,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=83664, - serialized_end=83845, + serialized_start=83821, + serialized_end=84002, ) @@ -21862,8 +21900,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=83989, - serialized_end=84135, + serialized_start=84146, + serialized_end=84292, ) _GETADDRESSESTRUNKSTATERESPONSE = _descriptor.Descriptor( @@ -21898,8 +21936,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=83848, - serialized_end=84146, + serialized_start=84005, + serialized_end=84303, ) @@ -21944,8 +21982,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=84289, - serialized_end=84378, + serialized_start=84446, + serialized_end=84535, ) _GETADDRESSESBRANCHSTATEREQUEST = _descriptor.Descriptor( @@ -21980,8 +22018,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=84149, - serialized_end=84389, + serialized_start=84306, + serialized_end=84546, ) @@ -22012,8 +22050,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=84535, - serialized_end=84590, + serialized_start=84692, + serialized_end=84747, ) _GETADDRESSESBRANCHSTATERESPONSE = _descriptor.Descriptor( @@ -22048,8 +22086,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=84392, - serialized_end=84601, + serialized_start=84549, + serialized_end=84758, ) @@ -22094,8 +22132,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=84765, - serialized_end=84879, + serialized_start=84922, + serialized_end=85036, ) _GETRECENTADDRESSBALANCECHANGESREQUEST = _descriptor.Descriptor( @@ -22130,8 +22168,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=84604, - serialized_end=84890, + serialized_start=84761, + serialized_end=85047, ) @@ -22181,8 +22219,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=85058, - serialized_end=85322, + serialized_start=85215, + serialized_end=85479, ) _GETRECENTADDRESSBALANCECHANGESRESPONSE = _descriptor.Descriptor( @@ -22217,8 +22255,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=84893, - serialized_end=85333, + serialized_start=85050, + serialized_end=85490, ) @@ -22256,8 +22294,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=85335, - serialized_end=85406, + serialized_start=85492, + serialized_end=85563, ) @@ -22307,8 +22345,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=85409, - serialized_end=85585, + serialized_start=85566, + serialized_end=85742, ) @@ -22339,8 +22377,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=85587, - serialized_end=85679, + serialized_start=85744, + serialized_end=85836, ) @@ -22385,8 +22423,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=85682, - serialized_end=85856, + serialized_start=85839, + serialized_end=86013, ) @@ -22417,8 +22455,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=85859, - serialized_end=85994, + serialized_start=86016, + serialized_end=86151, ) @@ -22456,8 +22494,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=86186, - serialized_end=86283, + serialized_start=86343, + serialized_end=86440, ) _GETRECENTCOMPACTEDADDRESSBALANCECHANGESREQUEST = _descriptor.Descriptor( @@ -22492,8 +22530,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=85997, - serialized_end=86294, + serialized_start=86154, + serialized_end=86451, ) @@ -22543,8 +22581,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=86490, - serialized_end=86782, + serialized_start=86647, + serialized_end=86939, ) _GETRECENTCOMPACTEDADDRESSBALANCECHANGESRESPONSE = _descriptor.Descriptor( @@ -22579,8 +22617,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=86297, - serialized_end=86793, + serialized_start=86454, + serialized_end=86950, ) @@ -22637,8 +22675,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=86942, - serialized_end=87065, + serialized_start=87099, + serialized_end=87222, ) _GETSHIELDEDENCRYPTEDNOTESREQUEST = _descriptor.Descriptor( @@ -22673,8 +22711,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=86796, - serialized_end=87076, + serialized_start=86953, + serialized_end=87233, ) @@ -22726,8 +22764,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=87523, - serialized_end=87610, + serialized_start=87680, + serialized_end=87767, ) _GETSHIELDEDENCRYPTEDNOTESRESPONSE_GETSHIELDEDENCRYPTEDNOTESRESPONSEV0_ENCRYPTEDNOTES = _descriptor.Descriptor( @@ -22757,8 +22795,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=87613, - serialized_end=87758, + serialized_start=87770, + serialized_end=87915, ) _GETSHIELDEDENCRYPTEDNOTESRESPONSE_GETSHIELDEDENCRYPTEDNOTESRESPONSEV0 = _descriptor.Descriptor( @@ -22807,8 +22845,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=87229, - serialized_end=87768, + serialized_start=87386, + serialized_end=87925, ) _GETSHIELDEDENCRYPTEDNOTESRESPONSE = _descriptor.Descriptor( @@ -22843,8 +22881,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=87079, - serialized_end=87779, + serialized_start=87236, + serialized_end=87936, ) @@ -22887,8 +22925,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=87907, - serialized_end=87987, + serialized_start=88064, + serialized_end=88144, ) _GETSHIELDEDANCHORSREQUEST = _descriptor.Descriptor( @@ -22923,8 +22961,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=87782, - serialized_end=87998, + serialized_start=87939, + serialized_end=88155, ) @@ -22955,8 +22993,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=88387, - serialized_end=88413, + serialized_start=88544, + serialized_end=88570, ) _GETSHIELDEDANCHORSRESPONSE_GETSHIELDEDANCHORSRESPONSEV0 = _descriptor.Descriptor( @@ -23005,8 +23043,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=88130, - serialized_end=88423, + serialized_start=88287, + serialized_end=88580, ) _GETSHIELDEDANCHORSRESPONSE = _descriptor.Descriptor( @@ -23041,8 +23079,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=88001, - serialized_end=88434, + serialized_start=88158, + serialized_end=88591, ) @@ -23085,8 +23123,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=88589, - serialized_end=88678, + serialized_start=88746, + serialized_end=88835, ) _GETMOSTRECENTSHIELDEDANCHORREQUEST = _descriptor.Descriptor( @@ -23121,8 +23159,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=88437, - serialized_end=88689, + serialized_start=88594, + serialized_end=88846, ) @@ -23172,8 +23210,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=88848, - serialized_end=89029, + serialized_start=89005, + serialized_end=89186, ) _GETMOSTRECENTSHIELDEDANCHORRESPONSE = _descriptor.Descriptor( @@ -23208,8 +23246,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=88692, - serialized_end=89040, + serialized_start=88849, + serialized_end=89197, ) @@ -23252,8 +23290,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89174, - serialized_end=89256, + serialized_start=89331, + serialized_end=89413, ) _GETSHIELDEDPOOLSTATEREQUEST = _descriptor.Descriptor( @@ -23288,8 +23326,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89043, - serialized_end=89267, + serialized_start=89200, + serialized_end=89424, ) @@ -23339,8 +23377,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89405, - serialized_end=89590, + serialized_start=89562, + serialized_end=89747, ) _GETSHIELDEDPOOLSTATERESPONSE = _descriptor.Descriptor( @@ -23375,8 +23413,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89270, - serialized_end=89601, + serialized_start=89427, + serialized_end=89758, ) @@ -23419,8 +23457,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89738, - serialized_end=89821, + serialized_start=89895, + serialized_end=89978, ) _GETSHIELDEDNOTESCOUNTREQUEST = _descriptor.Descriptor( @@ -23455,8 +23493,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89604, - serialized_end=89832, + serialized_start=89761, + serialized_end=89989, ) @@ -23506,8 +23544,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89973, - serialized_end=90163, + serialized_start=90130, + serialized_end=90320, ) _GETSHIELDEDNOTESCOUNTRESPONSE = _descriptor.Descriptor( @@ -23542,8 +23580,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=89835, - serialized_end=90174, + serialized_start=89992, + serialized_end=90331, ) @@ -23593,8 +23631,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=90311, - serialized_end=90414, + serialized_start=90468, + serialized_end=90571, ) _GETSHIELDEDNULLIFIERSREQUEST = _descriptor.Descriptor( @@ -23629,8 +23667,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=90177, - serialized_end=90425, + serialized_start=90334, + serialized_end=90582, ) @@ -23668,8 +23706,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=90854, - serialized_end=90908, + serialized_start=91011, + serialized_end=91065, ) _GETSHIELDEDNULLIFIERSRESPONSE_GETSHIELDEDNULLIFIERSRESPONSEV0_NULLIFIERSTATUSES = _descriptor.Descriptor( @@ -23699,8 +23737,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=90911, - serialized_end=91053, + serialized_start=91068, + serialized_end=91210, ) _GETSHIELDEDNULLIFIERSRESPONSE_GETSHIELDEDNULLIFIERSRESPONSEV0 = _descriptor.Descriptor( @@ -23749,8 +23787,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=90566, - serialized_end=91063, + serialized_start=90723, + serialized_end=91220, ) _GETSHIELDEDNULLIFIERSRESPONSE = _descriptor.Descriptor( @@ -23785,8 +23823,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=90428, - serialized_end=91074, + serialized_start=90585, + serialized_end=91231, ) @@ -23838,8 +23876,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=91224, - serialized_end=91370, + serialized_start=91381, + serialized_end=91527, ) _GETPRIVATEDOCUMENTENTRIESREQUEST = _descriptor.Descriptor( @@ -23874,8 +23912,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=91077, - serialized_end=91381, + serialized_start=91234, + serialized_end=91538, ) @@ -23927,8 +23965,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=91828, - serialized_end=91939, + serialized_start=91985, + serialized_end=92096, ) _GETPRIVATEDOCUMENTENTRIESRESPONSE_GETPRIVATEDOCUMENTENTRIESRESPONSEV0_PRIVATEDOCUMENTENTRIES = _descriptor.Descriptor( @@ -23965,8 +24003,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=91942, - serialized_end=92128, + serialized_start=92099, + serialized_end=92285, ) _GETPRIVATEDOCUMENTENTRIESRESPONSE_GETPRIVATEDOCUMENTENTRIESRESPONSEV0 = _descriptor.Descriptor( @@ -24015,8 +24053,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=91534, - serialized_end=92138, + serialized_start=91691, + serialized_end=92295, ) _GETPRIVATEDOCUMENTENTRIESRESPONSE = _descriptor.Descriptor( @@ -24051,8 +24089,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=91384, - serialized_end=92149, + serialized_start=91541, + serialized_end=92306, ) @@ -24104,8 +24142,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=92399, - serialized_end=92487, + serialized_start=92556, + serialized_end=92644, ) _TENDERDASHBLOCKPROOF_HEADER = _descriptor.Descriptor( @@ -24261,8 +24299,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=92490, - serialized_end=93028, + serialized_start=92647, + serialized_end=93185, ) _TENDERDASHBLOCKPROOF = _descriptor.Descriptor( @@ -24327,8 +24365,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=92152, - serialized_end=93028, + serialized_start=92309, + serialized_end=93185, ) @@ -24380,8 +24418,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=93030, - serialized_end=93135, + serialized_start=93187, + serialized_end=93292, ) @@ -24426,8 +24464,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=93290, - serialized_end=93381, + serialized_start=93447, + serialized_end=93538, ) _GETOWNERTRANSACTIONSINBLOCKREQUEST = _descriptor.Descriptor( @@ -24462,8 +24500,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=93138, - serialized_end=93392, + serialized_start=93295, + serialized_end=93549, ) @@ -24529,8 +24567,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=93799, - serialized_end=93984, + serialized_start=93956, + serialized_end=94141, ) _GETOWNERTRANSACTIONSINBLOCKRESPONSE_GETOWNERTRANSACTIONSINBLOCKRESPONSEV0 = _descriptor.Descriptor( @@ -24567,8 +24605,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=93551, - serialized_end=93984, + serialized_start=93708, + serialized_end=94141, ) _GETOWNERTRANSACTIONSINBLOCKRESPONSE = _descriptor.Descriptor( @@ -24603,8 +24641,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=93395, - serialized_end=93995, + serialized_start=93552, + serialized_end=94152, ) @@ -24649,8 +24687,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=94096, - serialized_end=94172, + serialized_start=94253, + serialized_end=94329, ) _GETBLOCKSREQUEST = _descriptor.Descriptor( @@ -24685,8 +24723,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=93998, - serialized_end=94183, + serialized_start=94155, + serialized_end=94340, ) @@ -24745,8 +24783,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=94399, - serialized_end=94509, + serialized_start=94556, + serialized_end=94666, ) _GETBLOCKSRESPONSE_GETBLOCKSRESPONSEV0_BLOCK = _descriptor.Descriptor( @@ -24825,8 +24863,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=94512, - serialized_end=94820, + serialized_start=94669, + serialized_end=94977, ) _GETBLOCKSRESPONSE_GETBLOCKSRESPONSEV0 = _descriptor.Descriptor( @@ -24856,8 +24894,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=94288, - serialized_end=94820, + serialized_start=94445, + serialized_end=94977, ) _GETBLOCKSRESPONSE = _descriptor.Descriptor( @@ -24892,8 +24930,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=94186, - serialized_end=94831, + serialized_start=94343, + serialized_end=94988, ) _GETIDENTITYREQUEST_GETIDENTITYREQUESTV0.containing_type = _GETIDENTITYREQUEST @@ -31798,6 +31836,10 @@ _GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_ENTRY.fields_by_name['time_ms']._options = None _GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_ENTRY.fields_by_name['revision']._options = None _GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_LIFECYCLE.fields_by_name['remaining_revisions']._options = None +_GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_LIFECYCLE.fields_by_name['deleted_at_ms']._options = None +_GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_LIFECYCLE.fields_by_name['erasing_started_at_ms']._options = None +_GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_LIFECYCLE.fields_by_name['erasing_from_time_ms']._options = None +_GETDOCUMENTHISTORYRESPONSE_GETDOCUMENTHISTORYRESPONSEV1_LIFECYCLE.fields_by_name['erasing_from_revision']._options = None _WAITFORSTATETRANSITIONRESULTRESPONSE_SUCCESSWITHOWNERBALANCE.fields_by_name['owner_balance']._options = None _GETRECENTSTATETRANSITIONSTATUSRESPONSE_GETRECENTSTATETRANSITIONSTATUSRESPONSEV0_COMMITTED.fields_by_name['height']._options = None _GETEPOCHSINFORESPONSE_GETEPOCHSINFORESPONSEV0_EPOCHINFO.fields_by_name['first_block_height']._options = None @@ -31869,8 +31911,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=95114, - serialized_end=106786, + serialized_start=95271, + serialized_end=106943, methods=[ _descriptor.MethodDescriptor( name='broadcastStateTransition', diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts index ac725f624b8..c6e7586105e 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts @@ -6934,6 +6934,18 @@ export namespace GetDocumentHistoryResponse { getRemainingRevisions(): string; setRemainingRevisions(value: string): void; + getDeletedAtMs(): string; + setDeletedAtMs(value: string): void; + + getErasingStartedAtMs(): string; + setErasingStartedAtMs(value: string): void; + + getErasingFromTimeMs(): string; + setErasingFromTimeMs(value: string): void; + + getErasingFromRevision(): string; + setErasingFromRevision(value: string): void; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Lifecycle.AsObject; static toObject(includeInstance: boolean, msg: Lifecycle): Lifecycle.AsObject; @@ -6948,11 +6960,17 @@ export namespace GetDocumentHistoryResponse { export type AsObject = { state: GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.StateMap[keyof GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.StateMap], remainingRevisions: string, + deletedAtMs: string, + erasingStartedAtMs: string, + erasingFromTimeMs: string, + erasingFromRevision: string, } export interface StateMap { ACTIVE: 0; ABSENT: 1; + DELETED: 2; + ERASING: 3; } export const State: StateMap; diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js index b73ac6da250..127fef88698 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js @@ -60126,7 +60126,11 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.toObject = function(includeInstance, msg) { var f, obj = { state: jspb.Message.getFieldWithDefault(msg, 1, 0), - remainingRevisions: jspb.Message.getFieldWithDefault(msg, 2, "0") + remainingRevisions: jspb.Message.getFieldWithDefault(msg, 2, "0"), + deletedAtMs: jspb.Message.getFieldWithDefault(msg, 3, "0"), + erasingStartedAtMs: jspb.Message.getFieldWithDefault(msg, 4, "0"), + erasingFromTimeMs: jspb.Message.getFieldWithDefault(msg, 5, "0"), + erasingFromRevision: jspb.Message.getFieldWithDefault(msg, 6, "0") }; if (includeInstance) { @@ -60171,6 +60175,22 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes var value = /** @type {string} */ (reader.readUint64String()); msg.setRemainingRevisions(value); break; + case 3: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setDeletedAtMs(value); + break; + case 4: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setErasingStartedAtMs(value); + break; + case 5: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setErasingFromTimeMs(value); + break; + case 6: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setErasingFromRevision(value); + break; default: reader.skipField(); break; @@ -60214,6 +60234,34 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes f ); } + f = message.getDeletedAtMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 3, + f + ); + } + f = message.getErasingStartedAtMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 4, + f + ); + } + f = message.getErasingFromTimeMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 5, + f + ); + } + f = message.getErasingFromRevision(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 6, + f + ); + } }; @@ -60222,7 +60270,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes */ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.State = { ACTIVE: 0, - ABSENT: 1 + ABSENT: 1, + DELETED: 2, + ERASING: 3 }; /** @@ -60261,6 +60311,78 @@ proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryRes }; +/** + * optional uint64 deleted_at_ms = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getDeletedAtMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setDeletedAtMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 3, value); +}; + + +/** + * optional uint64 erasing_started_at_ms = 4; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getErasingStartedAtMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setErasingStartedAtMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 4, value); +}; + + +/** + * optional uint64 erasing_from_time_ms = 5; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getErasingFromTimeMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setErasingFromTimeMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 5, value); +}; + + +/** + * optional uint64 erasing_from_revision = 6; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.getErasingFromRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV1.Lifecycle.prototype.setErasingFromRevision = function(value) { + return jspb.Message.setProto3StringIntField(this, 6, value); +}; + + /** * List of repeated fields within this message type. diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 7a3f2848dad..06bb181749b 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -2570,16 +2570,27 @@ message GetDocumentHistoryResponse { uint64 revision = 2 [ jstype = JS_STRING ]; bytes document = 3; } - // Where the historical document stands: still current, or gone with - // nothing retained. Later protocol versions add the states between. + // Whether the document is current, deleted with retained revisions, + // undergoing erasure, or absent with nothing retained. message Lifecycle { enum State { ACTIVE = 0; ABSENT = 1; + DELETED = 2; + ERASING = 3; } State state = 1; // Revisions the history still retains for the document. uint64 remaining_revisions = 2 [ jstype = JS_STRING ]; + // Zero unless the document has been deleted. + uint64 deleted_at_ms = 3 [ jstype = JS_STRING ]; + // Zero unless an authorized erasure has started. + uint64 erasing_started_at_ms = 4 [ jstype = JS_STRING ]; + // Timestamp of the newest revision retained when the erasure started. + uint64 erasing_from_time_ms = 5 [ jstype = JS_STRING ]; + // History sequence of the newest revision retained when the erasure + // started. + uint64 erasing_from_revision = 6 [ jstype = JS_STRING ]; } // A page of retained revisions and the document's lifecycle as of the // same block. diff --git a/packages/dapi-grpc/test/unit/documentHistoryWire.spec.js b/packages/dapi-grpc/test/unit/documentHistoryWire.spec.js index d25cee4c14d..e7dc7e3119f 100644 --- a/packages/dapi-grpc/test/unit/documentHistoryWire.spec.js +++ b/packages/dapi-grpc/test/unit/documentHistoryWire.spec.js @@ -59,4 +59,36 @@ describe('document history versioned wire format', () => { assert.deepEqual(Buffer.from(Request.encode(request).finish()), bytes); }); }); + + it('should preserve deleted and erasing lifecycle metadata across published clients', () => { + [2, 3].forEach((state) => { + const bytes = Buffer.from([ + 0x12, 16, 0x0a, 14, 0x12, 12, + 8, state, 16, 1, 24, 5, 32, 6, 40, 4, 48, 7, + ]); + [nodeMessages, webMessages].forEach((messages) => { + const response = messages.GetDocumentHistoryResponse.deserializeBinary(bytes); + const lifecycle = response.getV1().getHistory().getLifecycle(); + assert.equal(lifecycle.getState(), state); + assert.equal(lifecycle.getRemainingRevisions(), '1'); + assert.equal(lifecycle.getDeletedAtMs(), '5'); + assert.equal(lifecycle.getErasingStartedAtMs(), '6'); + assert.equal(lifecycle.getErasingFromTimeMs(), '4'); + assert.equal(lifecycle.getErasingFromRevision(), '7'); + assert.deepEqual(Buffer.from(response.serializeBinary()), bytes); + }); + [protobufMessages, driveMessages].forEach((messages) => { + const Response = messages.org.dash.platform.dapi.v0.GetDocumentHistoryResponse; + const response = Response.decode(bytes); + const { lifecycle } = response.v1.history; + assert.equal(lifecycle.state, state); + assert.equal(lifecycle.remainingRevisions.toString(), '1'); + assert.equal(lifecycle.deletedAtMs.toString(), '5'); + assert.equal(lifecycle.erasingStartedAtMs.toString(), '6'); + assert.equal(lifecycle.erasingFromTimeMs.toString(), '4'); + assert.equal(lifecycle.erasingFromRevision.toString(), '7'); + assert.deepEqual(Buffer.from(Response.encode(response).finish()), bytes); + }); + }); + }); }); diff --git a/packages/js-evo-sdk/src/documents/facade.ts b/packages/js-evo-sdk/src/documents/facade.ts index 5869c959085..b412fc30707 100644 --- a/packages/js-evo-sdk/src/documents/facade.ts +++ b/packages/js-evo-sdk/src/documents/facade.ts @@ -146,6 +146,19 @@ export class DocumentsFacade { return w.documentDelete(options); } + /** + * Erases a chunk of the retained revisions of an already deleted document. + * + * A document with more retained revisions than one transition may remove + * needs several calls. The first must be signed by the document's owner and + * commits the document to erasure; any identity may sign the ones after it. + * Read `history` to see how many revisions are left. + */ + async erase(options: wasm.DocumentEraseOptions): Promise { + const w = await this.sdk.getWasmSdkConnected(); + return w.documentErase(options); + } + async transfer(options: wasm.DocumentTransferOptions): Promise { const w = await this.sdk.getWasmSdkConnected(); return w.documentTransfer(options); diff --git a/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts b/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts index 284dbcc8f47..6cce042cc10 100644 --- a/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts +++ b/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts @@ -27,6 +27,7 @@ describe('DocumentsFacade', () => { let getContestFundToJoinStub: SinonStub; let documentReplaceStub: SinonStub; let documentDeleteStub: SinonStub; + let documentEraseStub: SinonStub; let documentTransferStub: SinonStub; let documentPurchaseStub: SinonStub; let documentSetPriceStub: SinonStub; @@ -97,6 +98,7 @@ describe('DocumentsFacade', () => { getContestFundToJoinStub = this.sinon.stub(wasmSdk, 'getContestFundToJoin').resolves(undefined); documentReplaceStub = this.sinon.stub(wasmSdk, 'documentReplace').resolves(); documentDeleteStub = this.sinon.stub(wasmSdk, 'documentDelete').resolves(); + documentEraseStub = this.sinon.stub(wasmSdk, 'documentErase').resolves(); documentTransferStub = this.sinon.stub(wasmSdk, 'documentTransfer').resolves(); documentPurchaseStub = this.sinon.stub(wasmSdk, 'documentPurchase').resolves(); documentSetPriceStub = this.sinon.stub(wasmSdk, 'documentSetPrice').resolves(); @@ -350,6 +352,37 @@ describe('DocumentsFacade', () => { }); }); + describe('erase()', () => { + it('should erase the retained revisions of a deleted document', async () => { + const options = { + document, + identityKey, + signer, + }; + + await client.documents.erase(options); + + expect(documentEraseStub).to.be.calledOnceWithExactly(options); + }); + + it('should accept document identifiers instead of a Document instance', async () => { + const options = { + document: { + id: '4mZmxva49PBb7BE7srw9o3gixvDfj1dAx1K6z4A7P9Ah', + ownerId: '5mjGWa9mruHnLBht3ntBi8CZ6sNk3hZZsQMgTvgQobjS', + dataContractId: 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', + documentTypeName: 'note', + }, + identityKey, + signer, + }; + + await client.documents.erase(options); + + expect(documentEraseStub).to.be.calledOnceWithExactly(options); + }); + }); + describe('transfer()', () => { it('should transfer document ownership to another identity', async () => { const recipientId = '6o4vL6YpPjamqnnPNpwNSspYJdhPpzYbXvAJ4PYH7Ack'; diff --git a/packages/platform-test-suite/test/functional/platform/KeepHistoryDocument.spec.js b/packages/platform-test-suite/test/functional/platform/KeepHistoryDocument.spec.js new file mode 100644 index 00000000000..9f6029adc5c --- /dev/null +++ b/packages/platform-test-suite/test/functional/platform/KeepHistoryDocument.spec.js @@ -0,0 +1,242 @@ +const Dash = require('dash'); +const { expect } = require('chai'); + +const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); +const waitForSTPropagated = require('../../../lib/waitForSTPropagated'); +const { getEvoSdkForNetwork } = require('../../../lib/test/createPlatformProofVerifier'); + +const { + Errors: { + StateTransitionBroadcastError, + }, +} = Dash; + +/** + * The identity's first key and a signer holding its private key, in the shape + * the Evo SDK's write methods expect. The legacy client owns the wallet, so the + * key has to be lifted out of it. + * + * @param {Object} evo + * @param {Object} evoSdk + * @param {Object} client + * @param {Object} identity + * @returns {Promise<{ identityKey: Object, signer: Object }>} + */ +// Key 1 is the identity's HIGH authentication key: document transitions +// require a HIGH or CRITICAL key, and key 0 is the MASTER key. +const DOCUMENT_SIGNING_KEY_ID = 1; + +async function evoSignerFor(evo, evoSdk, client, identity) { + const account = await client.getWalletAccount(); + const { privateKey } = account.identities.getIdentityHDKeyById( + identity.getId().toString(), + DOCUMENT_SIGNING_KEY_ID, + ); + + const signer = new evo.IdentitySigner(); + signer.addKeyFromWif(privateKey.toWIF()); + + const fetched = await evoSdk.identities.fetch(identity.getId().toString()); + const identityKey = fetched.getPublicKeyById(DOCUMENT_SIGNING_KEY_ID); + + return { identityKey, signer }; +} + +describe('Platform', () => { + describe('KeepHistoryDocument', function main() { + this.timeout(900000); + + let client; + let evo; + let evoSdk; + let identity; + let dataContract; + let note; + + /** + * The revision count and lifecycle metadata Platform authenticates for the + * note, read through the Evo SDK's history query. + */ + const readHistory = async () => { + const result = await evoSdk.documents.history({ + dataContractId: dataContract.getId().toString(), + documentTypeName: 'note', + documentId: note.getId().toString(), + startAtMs: 0, + limit: 10, + }); + + return result.lifecycle; + }; + + before(async () => { + client = await createClientWithFundedWallet(400000000); // 4 Dash + + identity = await client.platform.identities.register(200000000); + + // Additional wait time to mitigate testnet latency + await waitForSTPropagated(); + + ({ evo, sdk: evoSdk } = await getEvoSdkForNetwork(process.env.NETWORK)); + }); + + after(async () => { + if (client) { + await client.disconnect(); + } + }); + + it('should register a contract whose notes keep history and may be erased', async () => { + dataContract = await client.platform.contracts.create({ + note: { + type: 'object', + documentsKeepHistory: true, + documentsMutable: true, + canBeDeleted: true, + canBeErased: true, + properties: { + message: { + type: 'string', + maxLength: 256, + position: 0, + }, + }, + required: ['message'], + additionalProperties: false, + }, + }, identity); + + await client.platform.contracts.publish(dataContract, identity); + + // Additional wait time to mitigate testnet latency + await waitForSTPropagated(); + + client.getApps().set('notes', { + contractId: dataContract.getId(), + contract: dataContract, + }); + + const fetched = await client.platform.contracts.get(dataContract.getId()); + expect(fetched.toObject().documentSchemas.note.canBeErased).to.be.true(); + }); + + it('should keep every revision of a note that is edited', async () => { + note = await client.platform.documents.create( + 'notes.note', + identity, + { message: 'first' }, + ); + + await client.platform.documents.broadcast({ create: [note] }, identity); + + // Additional wait time to mitigate testnet latency + await waitForSTPropagated(); + + for (const message of ['second', 'third']) { + // The SDK signs `revision + 1` from the document it is handed but never + // bumps that local copy, so every replace starts from a fresh fetch. + const [stored] = await client.platform.documents.get( + 'notes.note', + { where: [['$id', '==', note.getId()]] }, + ); + stored.set('message', message); + await client.platform.documents.broadcast({ replace: [stored] }, identity); + + // Additional wait time to mitigate testnet latency + await waitForSTPropagated(); + } + + const lifecycle = await readHistory(); + expect(lifecycle.state).to.equal('ACTIVE'); + expect(lifecycle.remainingRevisions).to.equal(3n); + expect(lifecycle.deletedAtMs).to.equal(0n); + }); + + it('should hide a deleted note while keeping its revisions readable', async () => { + await client.platform.documents.broadcast({ delete: [note] }, identity); + + // Additional wait time to mitigate testnet latency + await waitForSTPropagated(); + + const [found] = await client.platform.documents.get( + 'notes.note', + { where: [['$id', '==', note.getId()]] }, + ); + expect(found).to.be.undefined(); + + const lifecycle = await readHistory(); + expect(lifecycle.state).to.equal('DELETED'); + expect( + lifecycle.remainingRevisions, + 'a delete removes no revision', + ).to.equal(3n); + expect(lifecycle.deletedAtMs > 0n).to.be.true(); + expect(lifecycle.erasingStartedAtMs).to.equal(0n); + }); + + it('should refuse to delete the same note twice', async () => { + let broadcastError; + + try { + await client.platform.documents.broadcast({ delete: [note] }, identity); + } catch (e) { + broadcastError = e; + } + + expect(broadcastError).to.be.an.instanceOf(StateTransitionBroadcastError); + // DocumentNotFoundError: a document nothing can read is not there to be + // deleted again, and a delete never escalates into removing a revision. + expect(broadcastError.code).to.equal(40101); + + // The refused delete still consumed a contract nonce in a block. Let every + // node commit it before the erase fetches that nonce, or a lagging node + // hands out the old value and its mempool drops the erase as a duplicate. + await waitForSTPropagated(); + }); + + it('should erase the retained revisions of a deleted note', async () => { + const { identityKey, signer } = await evoSignerFor(evo, evoSdk, client, identity); + + await evoSdk.documents.erase({ + document: { + id: note.getId().toString(), + ownerId: identity.getId().toString(), + dataContractId: dataContract.getId().toString(), + documentTypeName: 'note', + }, + identityKey, + signer, + }); + + // Additional wait time to mitigate testnet latency + await waitForSTPropagated(); + + const lifecycle = await readHistory(); + expect(lifecycle.state).to.equal('ABSENT'); + expect(lifecycle.remainingRevisions).to.equal(0n); + }); + + it('should refuse to erase a note that has already been erased', async () => { + const { identityKey, signer } = await evoSignerFor(evo, evoSdk, client, identity); + + let eraseError; + + try { + await evoSdk.documents.erase({ + document: { + id: note.getId().toString(), + ownerId: identity.getId().toString(), + dataContractId: dataContract.getId().toString(), + documentTypeName: 'note', + }, + identityKey, + signer, + }); + } catch (e) { + eraseError = e; + } + + expect(eraseError, 'an id that holds nothing is not erasable').to.exist(); + }); + }); +}); diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs index e1df28a9960..84550516449 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs @@ -964,6 +964,12 @@ static NO_PROPERTY_CONSTRAINTS: BTreeMap = BTreeMap: static NO_DERIVED_INDEX_PROPERTIES: BTreeMap = BTreeMap::new(); impl DocumentTypeV2Getters for DocumentType { + fn documents_can_be_erased(&self) -> bool { + match self { + DocumentType::V2(v2) => v2.documents_can_be_erased(), + _ => false, + } + } fn documents_countable(&self) -> bool { match self { DocumentType::V0(_) => false, @@ -1240,6 +1246,12 @@ impl DocumentTypeV2Setters for DocumentType { } impl DocumentTypeV2Getters for DocumentTypeRef<'_> { + fn documents_can_be_erased(&self) -> bool { + match self { + DocumentTypeRef::V2(v2) => v2.documents_can_be_erased(), + _ => false, + } + } fn documents_countable(&self) -> bool { match self { DocumentTypeRef::V0(_) => false, @@ -1482,6 +1494,12 @@ impl DocumentTypeV2Getters for DocumentTypeRef<'_> { } impl DocumentTypeV2Getters for DocumentTypeMutRef<'_> { + fn documents_can_be_erased(&self) -> bool { + match self { + DocumentTypeMutRef::V2(v2) => v2.documents_can_be_erased(), + _ => false, + } + } fn documents_countable(&self) -> bool { match self { DocumentTypeMutRef::V0(_) => false, diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs index c63d016d044..ac82dc5c6de 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs @@ -10,6 +10,10 @@ use std::collections::{BTreeMap, BTreeSet}; /// Trait providing getters for DocumentTypeV2-specific fields. pub trait DocumentTypeV2Getters { + /// Whether a deleted document's retained history may be erased. + fn documents_can_be_erased(&self) -> bool { + false + } /// Returns whether documents of this type are countable. /// When true, the primary key tree uses a CountTree enabling O(1) total document count queries. fn documents_countable(&self) -> bool; diff --git a/packages/rs-dpp/src/data_contract/document_type/action_fees/mod.rs b/packages/rs-dpp/src/data_contract/document_type/action_fees/mod.rs index 8809422f63d..4ffeedcb1c5 100644 --- a/packages/rs-dpp/src/data_contract/document_type/action_fees/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/action_fees/mod.rs @@ -444,6 +444,8 @@ impl DocumentActionFees { DocumentTransitionActionType::UpdatePrice => self.document_price_update_action_fee(), DocumentTransitionActionType::Purchase => self.document_purchase_action_fee(), DocumentTransitionActionType::IgnoreWhileBumpingRevision => None, + // Erase has no action-fee declaration and is unreachable before its bounds activate. + DocumentTransitionActionType::Erase => None, } } diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/common/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/common/mod.rs index 51f73974ace..be2527909d0 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/common/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/common/mod.rs @@ -43,7 +43,7 @@ use crate::data_contract::document_type::property_names::moderator_abilities::{ DELETE_REFUNDS_OWNER, DELETE_SETTLED, DELETE_WITHIN, }; use crate::data_contract::document_type::property_names::{ - CAN_BE_DELETED, CAN_BE_DELETED_ONLY_WHEN_CONSUMED, CREATION_RESTRICTION_MODE, + CAN_BE_DELETED, CAN_BE_DELETED_ONLY_WHEN_CONSUMED, CAN_BE_ERASED, CREATION_RESTRICTION_MODE, DOCUMENTS_AVERAGEABLE, DOCUMENTS_COUNTABLE, DOCUMENTS_KEEP_HISTORY, DOCUMENTS_MUTABLE, DOCUMENTS_SUMMABLE, INDEX_ONLY, KEEPS_PRICING_HISTORY, KEEPS_PURCHASE_HISTORY, KEEPS_TRANSFER_HISTORY, MODERATOR_ABILITIES, RANGE_AVERAGEABLE, RANGE_COUNTABLE, @@ -207,7 +207,9 @@ pub(super) fn no_ranked_index_structure_check( /// is exactly what a build without generation 3 does not need, so it can be /// removed as a block. See the `RANKED` markers through this module for the /// matching call sites. +#[derive(Clone, Copy)] pub(super) struct ParserGeneration { + pub admit_lifecycle: bool, // ---- present in every generation ---- /// The `document_type_schema` table value to select the document /// meta-schema with. Read by the *driver*, not down here. @@ -1146,7 +1148,7 @@ fn parse_indices( // A contested index's `resolution` is read as the platform version's // tables say (`ContestedIndexResolution::try_from_schema_value`): that // is a method version, not a property of the generation, since - // protocol versions 14 and 15 both parse generation 3 + // protocol version 14 parses generation 3 and version 15 parses generation 4. let mut index: Index = Index::try_from_value_map_for_platform_version( index_value .to_map() @@ -5816,3 +5818,103 @@ fn unrequired_ancestor(property_name: &str, required_fields: &BTreeSet) } None } + +pub(super) fn parse_can_be_erased_keyword(schema: &Value) -> Result { + let schema_map_opt = schema.to_map().ok(); + + Ok(schema_map_opt + .as_ref() + .and_then(|schema_map| { + Value::inner_optional_bool_value(schema_map, CAN_BE_ERASED) + .map_err(consensus_or_protocol_value_error) + .transpose() + }) + .transpose()? + .unwrap_or(false)) +} + +/// Write the `canBeErased` flag onto the parsed document type after checking +/// the two settings it depends on. +/// +/// Erase purges the retained revisions of a document that has already been +/// deleted, so a type that keeps no history has nothing to purge and a type +/// whose documents can never be deleted can never reach the state erase acts +/// on. Both are rejected rather than silently ignored: a document type whose +/// declared behavior and reachable behavior disagree is a contract-authoring +/// error, not a default. +/// +/// Runs regardless of `full_validation`, like [`apply_index_only`]: the flag +/// governs an irreversible operation, so a stored contract must never come +/// back out of the parser with the flag set on a type that cannot support it. +pub(super) fn apply_can_be_erased( + document_type: &mut DocumentTypeV2, + can_be_erased: bool, + name: &str, +) -> Result<(), ProtocolError> { + if !can_be_erased { + return Ok(()); + } + + // A consensus error, not a bare data-contract error: only the consensus + // variant becomes a paid rejection with a nonce bump when a signed contract + // create or update carries the combination. The bare variant would escape as + // an internal execution error and cost the submitter nothing. + let structure_error = |message: String| { + consensus_or_protocol_data_contract_error(DataContractError::InvalidContractStructure( + message, + )) + }; + + if !document_type.documents_keep_history { + return Err(structure_error(format!( + "document type \"{}\" sets `canBeErased: true` but does not keep history: erase \ + removes retained revisions, and a type without history has none", + name, + ))); + } + if !document_type.documents_can_be_deleted { + return Err(structure_error(format!( + "document type \"{}\" sets `canBeErased: true` but `canBeDeleted: false`: erase \ + applies to deleted documents only, so its documents could never be erased", + name, + ))); + } + + document_type.documents_can_be_erased = true; + Ok(()) +} + +/// Reject a keep-history document type that carries a contested index. +/// +/// A contested resource is awarded by block processing, outside state +/// transition validation, at an id derived from the winner rather than from +/// the contested values. On a keep-history type that award can land on an id +/// whose retained history already exists, which the storage guard turns into a +/// deterministic block failure on every validator. Making the combination safe +/// needs changes to the contested machinery itself, so until then the two are +/// kept apart at contract registration. +pub(super) fn reject_contested_keep_history( + document_type: &DocumentTypeV2, + name: &str, +) -> Result<(), ProtocolError> { + if !document_type.documents_keep_history { + return Ok(()); + } + if let Some((index_name, _)) = document_type + .indices + .iter() + .find(|(_, index)| index.contested_index.is_some()) + { + // Consensus error for the same reason as `apply_can_be_erased`: a + // signed contract carrying this combination must be a paid rejection. + return Err(consensus_or_protocol_data_contract_error( + DataContractError::InvalidContractStructure(format!( + "document type \"{}\" sets `documentsKeepHistory: true` and declares the \ + contested index \"{}\": a contested resource is awarded outside transition \ + validation and cannot be combined with retained history", + name, index_name, + )), + )); + } + Ok(()) +} diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs index 349b3a78e20..63398697c57 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs @@ -61,6 +61,7 @@ mod v0; mod v1; mod v2; mod v3; +mod v4; #[cfg(all(test, feature = "validation"))] pub(in crate::data_contract) use native_schema::DOCUMENT_SCHEMA_ROOT_KEYS; @@ -158,9 +159,22 @@ impl DocumentType { validation_operations, platform_version, ), + 4 => DocumentType::try_from_schema_v4( + data_contract_id, + data_contract_system_version, + contract_config_version, + name, + schema, + schema_defs, + token_configurations, + data_contact_config, + full_validation, + validation_operations, + platform_version, + ), version => Err(ProtocolError::UnknownVersionMismatch { method: "try_from_schema".to_string(), - known_versions: vec![0, 1, 2, 3], + known_versions: vec![0, 1, 2, 3, 4], received: version, }), } diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/document_type.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/document_type.rs index 28639680c36..9a8b35a02ab 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/document_type.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/document_type.rs @@ -25,8 +25,8 @@ pub(super) const DOCUMENT_SCHEMA_URI: &str = "https://github.com/dashpay/platform/blob/master/packages/rs-dpp/schema/meta_schemas/document/v1/document-meta.json"; /// The keys of a document schema: those of the document meta-schema it replaces, and -/// `private`, which no meta-schema has. -pub(in crate::data_contract) const ROOT_KEYS: [&str; 44] = [ +/// `private` and `canBeErased`, which no meta-schema has. +pub(in crate::data_contract) const ROOT_KEYS: [&str; 45] = [ "type", "$schema", "$defs", @@ -38,6 +38,7 @@ pub(in crate::data_contract) const ROOT_KEYS: [&str; 44] = [ "keepsPricingHistory", "documentsMutable", "canBeDeleted", + "canBeErased", "transferable", "tradeMode", "creationRestrictionMode", @@ -129,6 +130,7 @@ impl Checker<'_> { | "rangeSummable" | "rangeAverageable" | "indexOnly" => self.boolean(value), + "canBeErased" => self.boolean(value), "canBeDeleted" => self.one_of( value, &[json!(true), json!(false), json!("onlyWhenConsumed")], diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/tests.rs index 8849b5b8f8c..7b43282e935 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/tests.rs @@ -212,6 +212,7 @@ fn compare(case: &Case, tally: &mut Tally) -> Vec { (None, Some(native)) => differences.push(format!( "{origin}: the native checks refuse what the meta-schema accepts: {native}\n{root:#}" )), + (Some(_), None) if root.get("canBeErased").is_some_and(JsonValue::is_boolean) => {}, (Some(path), None) => differences.push(format!( "{origin}: the native checks accept what the meta-schema refuses at {path}\n{root:#}" )), @@ -228,6 +229,11 @@ fn compare(case: &Case, tally: &mut Tally) -> Vec { differences.push(format!("{origin}: the checks parse different types")); } } + (Err(_), Ok(_)) + if case + .schema + .get("canBeErased") + .is_some_and(JsonValue::is_boolean) => {} (Err(meta), Ok(_)) => differences.push(format!( "{origin}: the native check admits what the meta-schema check refuses: {meta}\n{:#}", case.schema @@ -256,7 +262,11 @@ fn compare(case: &Case, tally: &mut Tally) -> Vec { && case .validating_root(platform_version) .is_some_and(|root| meta_schema_refusal(&root).is_none())) - || json_schema_error(&native).is_some_and(is_index_property_name_cap); + || json_schema_error(&native).is_some_and(is_index_property_name_cap) + || case + .schema + .get("canBeErased") + .is_some_and(JsonValue::is_boolean); if !moved { differences.push(format!( "{origin}: the native check refuses with code {:?} ({native}) where the \ @@ -690,7 +700,7 @@ fn corpus_cases() -> Vec { /// Keys a generated schema gains: every keyword the meta-schema names somewhere, and some /// it names nowhere. -const GENERATED_KEYS: [&str; 46] = [ +const GENERATED_KEYS: [&str; 47] = [ "type", "properties", "additionalProperties", @@ -724,6 +734,7 @@ const GENERATED_KEYS: [&str; 46] = [ "description", "documentsMutable", "canBeDeleted", + "canBeErased", "documentsSummable", "rangeAverageable", "moderatorAbilities", @@ -1755,3 +1766,62 @@ fn should_admit_private_which_the_meta_schema_refuses() { ); } } + +#[test] +fn should_compile_non_lifecycle_fixtures_identically_with_parsers_three_and_four() { + use crate::data_contract::document_type::serialized_version::DocumentTypeInSerializationFormat; + use crate::serialization::PlatformSerializable; + let latest = PlatformVersion::latest(); + let mut previous = latest.clone(); + previous + .dpp + .contract_versions + .document_type_versions + .class_method_versions + .try_from_schema = 3; + let mut count = 0; + for case in written_cases().into_iter().chain(corpus_cases()) { + if case.schema.get("canBeErased").is_some() { + continue; + } + let defs = case.schema_defs().unwrap(); + let parse = |version| { + DocumentType::try_from_schema( + case.contract_id, + 1, + case.config.version(), + &case.name, + Value::from(case.schema.clone()), + defs.as_ref(), + &case.tokens, + &case.config, + false, + &mut vec![], + version, + ) + }; + match (parse(&previous), parse(latest)) { + (Ok(old), Ok(current)) => { + assert_eq!(old, current, "{}", case.origin); + let compile = |ty: &DocumentType| { + DocumentTypeInSerializationFormat::try_from_document_type( + ty.as_ref(), + defs.as_ref(), + latest, + ) + .unwrap() + .serialize_to_bytes() + .unwrap() + }; + assert_eq!(compile(&old), compile(¤t), "{}", case.origin); + count += 1; + } + (Err(_), Err(_)) => {} + (old, current) => panic!("{}: parser mismatch: {old:?} vs {current:?}", case.origin), + } + } + assert!( + count > 100, + "expected the fixture and deployed-contract corpus, got {count}" + ); +} diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs index 58df3c4e9d6..2c9887aab2e 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs @@ -96,6 +96,7 @@ impl DocumentTypeV1 { false, validation_operations, &common::ParserGeneration { + admit_lifecycle: false, document_type_schema_version, admit_history: document_type_schema_version >= 2, admit_count_indexes: platform_version.protocol_version >= 12, diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/commit_reveal_lookup_tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/commit_reveal_lookup_tests.rs index 7cf67512115..292ed520aef 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/commit_reveal_lookup_tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/commit_reveal_lookup_tests.rs @@ -1234,6 +1234,18 @@ fn should_refuse_consuming_a_type_whose_delete_costs_something_or_asks_a_stricte consuming(json!({})).expect("a plain commitment type may be consumed"); } +#[test] +fn should_refuse_registering_a_consume_of_deletable_history_at_protocol_15() { + let schema = dpns_contract_with( + dpns_salt_reveal(), + json!({}), + json!({ "documentsKeepHistory": true, "canBeDeleted": true }), + ); + contract_on(schema.clone(), false, PlatformVersion::latest()) + .expect("the stored history type is itself valid"); + assert_refused(contract(schema), "its documents keep history"); +} + #[test] fn should_list_the_types_a_create_may_consume() { let parsed = contract(dpns_contract(dpns_salt_reveal())).expect("the DPNS reveal should parse"); diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/immutable_tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/immutable_tests.rs index 71f47d4a962..17ac9452331 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/immutable_tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/immutable_tests.rs @@ -45,6 +45,7 @@ fn parse_with( &config, full_validation, &mut vec![], + &PARSER_GENERATION, platform_version, ) } diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/index_only_tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/index_only_tests.rs index f8b5983288a..78408f1a3ba 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/index_only_tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/index_only_tests.rs @@ -45,6 +45,7 @@ fn parse_with( &config, full_validation, &mut vec![], + &PARSER_GENERATION, platform_version, ) } diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs index 5ed520059f2..591268e7e8c 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs @@ -345,7 +345,7 @@ fn consensus_or_protocol_generation_3_error(error: ProtocolError) -> ProtocolErr /// records the stray keys those contracts do carry, and fails if a document /// meta-schema ever declares one of them as a keyword. #[allow(clippy::too_many_arguments)] -fn try_from_schema_generation_3( +pub(super) fn try_from_schema_generation_3( data_contract_id: Identifier, data_contract_system_version: u16, contract_config_version: u16, @@ -356,6 +356,7 @@ fn try_from_schema_generation_3( data_contact_config: &DataContractConfig, full_validation: bool, validation_operations: &mut impl Extend, + generation: &common::ParserGeneration, platform_version: &PlatformVersion, ) -> Result { let mut operations = SchemaReadBilling { @@ -374,6 +375,7 @@ fn try_from_schema_generation_3( data_contact_config, full_validation, &mut operations, + generation, platform_version, ); // A parse that ran the repeated-key walk records one schema size, at least the values the @@ -442,6 +444,7 @@ fn parse_generation_3( data_contact_config: &DataContractConfig, full_validation: bool, validation_operations: &mut SchemaReadBilling<'_, impl Extend>, + generation: &common::ParserGeneration, platform_version: &PlatformVersion, ) -> Result { // Generation 3 refuses `-` in a document type name, as meta-schema v3 @@ -543,69 +546,7 @@ fn parse_generation_3( // `apply_deleted_only_when_consumed` below records the consumption. deleted_only_when_consumed, validation_operations, - &common::ParserGeneration { - // Generation 3 exists if and only if `document_type_schema` is 3 — - // CONTRACT_VERSIONS_V6 and V7 are the only tables that select this - // parser, and the only tables naming meta-schema v3. So every constant - // here is a property of the generation, not of a platform version, - // and none of them is read out of a table. - document_type_schema_version: 3, - // Meta-schema v3 carries the `keeps*History` flags forward from v2, - // so they are unconditionally part of this generation's grammar. - // This is the conditional that was dead in the copied core: at - // schema 3 the old `document_type_schema >= 2` could only be true. - admit_history: true, - // Count indexes arrived at PV12; every version selecting this - // generation is far past that boundary. - admit_count_indexes: true, - meta_schema_method_name: "DocumentType::try_from_schema_v3 (document_type_schema)", - // RANKED / TIME RANGE: the keyword admissions that make this - // generation 3, read from the shared generation → admission - // mapping so the registration-cost re-parse can never drift - // from what this parser accepts. - admit_ranked: IndexGrammarAdmissions::for_schema_generation(3).ranked, - ranked_index_key_length_check: RANKED_INDEX_KEY_LENGTH_CHECK, - ranked_index_structure_check: validate_no_ranked_prefix_overlap, - admit_time_range: IndexGrammarAdmissions::for_schema_generation(3).time_range, - admit_integer_range: IndexGrammarAdmissions::for_schema_generation(3).integer_range, - // INDEX ONLY: the `terminal` index keyword, admitted from the - // same shared generation → admission mapping as the two above. - admit_index_terminal: IndexGrammarAdmissions::for_schema_generation(3).terminal, - // PREALLOCATED: the fourth generation-3 index keyword, from the - // same shared mapping. - admit_index_preallocated: IndexGrammarAdmissions::for_schema_generation(3).preallocated, - // OUTLIVES DELETE: from the same shared mapping. - admit_index_outlives_delete: IndexGrammarAdmissions::for_schema_generation(3) - .outlives_delete, - // SKIP IF ABSENT: the fifth generation-3 index keyword, from the - // same shared mapping. - admit_index_skip_if_absent: IndexGrammarAdmissions::for_schema_generation(3) - .skip_if_absent, - // SUMMABLE OFF COUNT INDEX: the sixth generation-3 index keyword, from the same - // shared mapping. - admit_index_summable_off_count_index: IndexGrammarAdmissions::for_schema_generation(3) - .summable_off_count_index, - // RANGE COUNTABLE IMPLIES COUNTABLE: a generation-3 desugaring rule - // rather than a keyword, read from the same shared mapping so the - // registration-cost re-parse and the validator agree on it. - admit_range_countable_implies_countable: IndexGrammarAdmissions::for_schema_generation( - 3, - ) - .range_countable_implies_countable, - // NO LOCKING RESOLUTION: a contested index resolved without a Lock - // choice, a generation-3 value from the same shared mapping. - admit_index_no_locking_resolution: IndexGrammarAdmissions::for_schema_generation(3) - .no_locking_resolution, - // MODERATION STAMPS: `$moderatedAt` and `$moderatedBy`, which only a type keeping - // fields for its moderators carries (checked by `apply_moderator_abilities`). - admit_moderation_stamp_indexes: true, - // DERIVED INDEX PROPERTIES: a value read through a same-contract permanent or - // moderated reference (`apply_derived_index_properties`). - admit_derived_index_properties: true, - // INDEXED ARRAYS: an index keyed by the elements of a typed array - // (`validate_indexed_array_index`). - admit_indexed_arrays: true, - }, + generation, platform_version, )?; @@ -778,10 +719,22 @@ fn parse_generation_3( // documents. apply_derived_index_properties(&mut v2, data_contract_id, name, full_validation)?; + if generation.admit_lifecycle { + let can_be_erased = common::parse_can_be_erased_keyword(&v2.schema)?; + common::apply_can_be_erased(&mut v2, can_be_erased, name)?; + if full_validation { + common::reject_contested_keep_history(&v2, name)?; + } + } + // The flags are read from the parsed result (not the raw schema) so // the check sees `canBeDeleted` resolved against the contract config // default (`true` when the key is omitted). - if full_validation && v2.documents_keep_history() && v2.documents_can_be_deleted() { + if !generation.admit_lifecycle + && full_validation + && v2.documents_keep_history() + && v2.documents_can_be_deleted() + { return Err(consensus_or_protocol_data_contract_error( DataContractError::InvalidContractStructure(format!( "document type \"{}\" sets both `documentsKeepHistory: true` and \ @@ -2081,6 +2034,7 @@ impl DocumentType { data_contact_config, full_validation, validation_operations, + &PARSER_GENERATION, platform_version, ) .map(DocumentType::V2) @@ -2105,6 +2059,66 @@ mod contested_summed_value_bounds_tests; mod delete_constraints_tests; #[cfg(all(test, feature = "validation"))] mod derived_index_property_tests; +/// Grammar owned by parser generation 3. +pub(super) const PARSER_GENERATION: common::ParserGeneration = common::ParserGeneration { + admit_lifecycle: false, + // CONTRACT_VERSIONS_V6 selects this parser with meta-schema v3. Parser + // generation 4 also uses that schema and extends this grammar. These + // constants belong to the parser generation rather than its version table. + document_type_schema_version: 3, + // Meta-schema v3 carries the `keeps*History` flags forward from v2, + // so they are unconditionally part of this generation's grammar. + // This is the conditional that was dead in the copied core: at + // schema 3 the old `document_type_schema >= 2` could only be true. + admit_history: true, + // Count indexes arrived at PV12; every version selecting this + // generation is far past that boundary. + admit_count_indexes: true, + meta_schema_method_name: "DocumentType::try_from_schema_v3 (document_type_schema)", + // RANKED / TIME RANGE: the keyword admissions that make this + // generation 3, read from the shared generation → admission + // mapping so the registration-cost re-parse can never drift + // from what this parser accepts. + admit_ranked: IndexGrammarAdmissions::for_schema_generation(3).ranked, + ranked_index_key_length_check: RANKED_INDEX_KEY_LENGTH_CHECK, + ranked_index_structure_check: validate_no_ranked_prefix_overlap, + admit_time_range: IndexGrammarAdmissions::for_schema_generation(3).time_range, + admit_integer_range: IndexGrammarAdmissions::for_schema_generation(3).integer_range, + // INDEX ONLY: the `terminal` index keyword, admitted from the + // same shared generation → admission mapping as the two above. + admit_index_terminal: IndexGrammarAdmissions::for_schema_generation(3).terminal, + // PREALLOCATED: the fourth generation-3 index keyword, from the + // same shared mapping. + admit_index_preallocated: IndexGrammarAdmissions::for_schema_generation(3).preallocated, + // OUTLIVES DELETE: from the same shared mapping. + admit_index_outlives_delete: IndexGrammarAdmissions::for_schema_generation(3).outlives_delete, + // SKIP IF ABSENT: the fifth generation-3 index keyword, from the + // same shared mapping. + admit_index_skip_if_absent: IndexGrammarAdmissions::for_schema_generation(3).skip_if_absent, + // SUMMABLE OFF COUNT INDEX: the sixth generation-3 index keyword, from the same + // shared mapping. + admit_index_summable_off_count_index: IndexGrammarAdmissions::for_schema_generation(3) + .summable_off_count_index, + // RANGE COUNTABLE IMPLIES COUNTABLE: a generation-3 desugaring rule + // rather than a keyword, read from the same shared mapping so the + // registration-cost re-parse and the validator agree on it. + admit_range_countable_implies_countable: IndexGrammarAdmissions::for_schema_generation(3) + .range_countable_implies_countable, + // NO LOCKING RESOLUTION: a contested index resolved without a Lock + // choice, a generation-3 value from the same shared mapping. + admit_index_no_locking_resolution: IndexGrammarAdmissions::for_schema_generation(3) + .no_locking_resolution, + // MODERATION STAMPS: `$moderatedAt` and `$moderatedBy`, which only a type keeping + // fields for its moderators carries (checked by `apply_moderator_abilities`). + admit_moderation_stamp_indexes: true, + // DERIVED INDEX PROPERTIES: a value read through a same-contract permanent or + // moderated reference (`apply_derived_index_properties`). + admit_derived_index_properties: true, + // INDEXED ARRAYS: an index keyed by the elements of a typed array + // (`validate_indexed_array_index`). + admit_indexed_arrays: true, +}; + #[cfg(test)] mod documents_ttl_tests; #[cfg(all(test, feature = "validation"))] @@ -2233,6 +2247,7 @@ mod tests { &config, full_validation, &mut vec![], + &PARSER_GENERATION, platform_version, ) } diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/outlives_delete_tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/outlives_delete_tests.rs index e7d4e352c15..b29c79a94d2 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/outlives_delete_tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/outlives_delete_tests.rs @@ -29,6 +29,7 @@ fn parse_with( &config, full_validation, &mut vec![], + &PARSER_GENERATION, platform_version, ) } diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v4/keep_history_tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v4/keep_history_tests.rs new file mode 100644 index 00000000000..5b34ad4f4a2 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v4/keep_history_tests.rs @@ -0,0 +1,530 @@ +//! The keep-history document lifecycle as generation 4 admits it: a +//! keep-history type may allow deletion, may additionally allow erasure, and +//! may not carry a contested index. +use super::*; +use crate::data_contract::document_type::accessors::{ + DocumentTypeV0Getters, DocumentTypeV2Getters, +}; +use crate::data_contract::errors::DataContractError; +use platform_value::platform_value; + +/// Parses through the public dispatcher at the given protocol version so +/// the test exercises the same `try_from_schema` version routing consensus +/// code uses (generation 4 at protocol version 15, 3 at 14, 2 at 12 and 13). +fn parse_at_version( + schema: Value, + protocol_version: u32, + full_validation: bool, +) -> Result { + let platform_version = + PlatformVersion::get(protocol_version).expect("expected platform version"); + let config = DataContractConfig::default_for_version(platform_version) + .expect("default config available"); + DocumentType::try_from_schema( + Identifier::new([1; 32]), + 1, + config.version(), + "test_doc", + schema, + None, + &BTreeMap::new(), + &config, + full_validation, + &mut vec![], + platform_version, + ) +} + +fn parse(schema: Value) -> Result { + parse_at_version(schema, PlatformVersion::latest().protocol_version, true) +} + +fn parse_without_validation(schema: Value) -> Result { + parse_at_version(schema, PlatformVersion::latest().protocol_version, false) +} + +fn keep_history_deletable_schema() -> Value { + platform_value!({ + "type": "object", + "properties": { + "label": { + "type": "string", + "maxLength": 50, + "position": 0, + }, + }, + "additionalProperties": false, + "documentsKeepHistory": true, + "canBeDeleted": true, + }) +} + +/// The two settings describe different things and no longer contradict each +/// other: history decides what is retained, deletion decides what ordinary +/// reads can still see. A delete on such a type removes the document from +/// every ordinary read and leaves its revisions readable. +#[test] +fn should_accept_a_keep_history_type_that_allows_deletion() { + let document_type = parse(keep_history_deletable_schema()) + .expect("a keep-history type may allow deletion at the latest protocol version"); + assert!(document_type.documents_keep_history()); + assert!(document_type.documents_can_be_deleted()); + assert!( + !document_type.documents_can_be_erased(), + "erasure is not implied by deletion; it has to be asked for" + ); +} + +/// The contract config defaults `canBeDeleted` to true, so a keep-history type +/// that says nothing about deletion is deletable — the same value it carried +/// before protocol 14, now with a delete that works. +#[test] +fn should_accept_a_keep_history_type_that_omits_the_delete_flag() { + let schema = platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "additionalProperties": false, + "documentsKeepHistory": true, + }); + let document_type = parse(schema).expect("the omitted flag defaults to deletable"); + assert!(document_type.documents_keep_history()); + assert!(document_type.documents_can_be_deleted()); +} + +/// A keep-history type that withholds deletion is still valid: its documents +/// are append-only and can never leave ordinary reads. +#[test] +fn should_accept_a_keep_history_type_that_withholds_deletion() { + let schema = platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "additionalProperties": false, + "documentsKeepHistory": true, + "canBeDeleted": false, + }); + let document_type = parse(schema).expect("an append-only keep-history type is valid"); + assert!(document_type.documents_keep_history()); + assert!(!document_type.documents_can_be_deleted()); +} + +/// The released parsers must keep parsing the same schemas the same way, so a +/// historical block replays identically: generation 2 never saw a rule about +/// the pair, and generation 3 refuses it under full validation. +#[test] +fn should_keep_the_released_parsers_verdict_on_a_keep_history_deletable_type() { + for protocol in [12, 13] { + let document_type = parse_at_version(keep_history_deletable_schema(), protocol, true) + .unwrap_or_else(|error| { + panic!("protocol {protocol} must still accept the schema: {error:?}") + }); + assert!(document_type.documents_keep_history()); + assert!(document_type.documents_can_be_deleted()); + } + assert!( + parse_at_version(keep_history_deletable_schema(), 14, true).is_err(), + "protocol 14 refuses a deletable keep-history type under full validation" + ); +} + +fn erasable_schema(keep_history: bool, can_be_deleted: bool, can_be_erased: bool) -> Value { + platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "additionalProperties": false, + "documentsKeepHistory": keep_history, + "canBeDeleted": can_be_deleted, + "canBeErased": can_be_erased, + }) +} + +#[test] +fn should_accept_an_erasable_keep_history_deletable_type() { + let document_type = + parse(erasable_schema(true, true, true)).expect("the admitted combination must parse"); + assert!(document_type.documents_can_be_erased()); +} + +/// Erasure purges retained revisions of a document that has already been +/// deleted, so a type with no history has nothing to purge and a type whose +/// documents can never be deleted can never reach the state erasure acts on. +/// Neither is silently ignored. +#[test] +fn should_reject_erasure_without_history_or_without_deletion() { + for (keep_history, can_be_deleted) in [(false, true), (true, false), (false, false)] { + let error = parse(erasable_schema(keep_history, can_be_deleted, true)).unwrap_err(); + let message = format!("{error:?}"); + assert!( + message.contains("canBeErased"), + "the error must name the flag the author has to change; got {message}" + ); + assert_contract_structure_consensus_error(&error); + } +} + +/// A signed contract carrying a refused combination must be a paid rejection +/// with a nonce bump, and only the consensus variant becomes one: the bare +/// data-contract variant escapes the transformation as an internal execution +/// error, which costs the submitter nothing and reports nothing useful. +#[cfg(feature = "validation")] +fn assert_contract_structure_consensus_error(error: &ProtocolError) { + use crate::consensus::basic::BasicError; + use crate::consensus::ConsensusError; + + let ProtocolError::ConsensusError(consensus) = error else { + panic!("expected a consensus error, got {error:?}"); + }; + assert!( + matches!( + consensus.as_ref(), + ConsensusError::BasicError(BasicError::ContractError( + DataContractError::InvalidContractStructure(_) + )) + ), + "expected an invalid-contract-structure basic error, got {consensus:?}" + ); +} + +#[cfg(not(feature = "validation"))] +fn assert_contract_structure_consensus_error(error: &ProtocolError) { + assert!( + matches!( + error, + ProtocolError::DataContractError(DataContractError::InvalidContractStructure(_)) + ), + "without the validation feature the structural variant is all there is, got {error:?}" + ); +} + +/// Erasure defaults to off: a type that says nothing about it cannot have its +/// revisions purged. +#[test] +fn should_default_erasure_to_off() { + let document_type = parse(keep_history_deletable_schema()).expect("parses"); + assert!(!document_type.documents_can_be_erased()); +} + +/// The keyword does not exist in the earlier meta-schemas, so a contract that +/// declares it is refused there rather than silently parsing without it. +#[test] +fn should_reject_the_erasure_keyword_at_released_protocol_versions() { + for protocol in [12, 13, 14] { + assert!( + parse_at_version(erasable_schema(true, true, true), protocol, true).is_err(), + "protocol {protocol} has no canBeErased keyword" + ); + } +} + +/// A contested resource is awarded outside transition validation, at an id +/// derived from the winner rather than from the contested values, so that award +/// can land on an id whose retained history already exists. The two are kept +/// apart at registration until the contested machinery can handle it. +#[test] +fn should_reject_a_keep_history_type_that_carries_a_contested_index() { + let schema = platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "indices": [ + { + "name": "byLabel", + "properties": [{"label": "asc"}], + "unique": true, + "contested": { + "fieldMatches": [{"field": "label", "regexPattern": "^[a-z]{3,10}$"}], + "resolution": 0, + }, + }, + ], + "required": ["label"], + "additionalProperties": false, + "documentsMutable": false, + "documentsKeepHistory": true, + "canBeDeleted": false, + }); + let error = parse(schema).expect_err("a contested keep-history type must be refused"); + let message = format!("{error:?}"); + assert!( + message.contains("contested"), + "the error must say which index is the problem; got {message}" + ); + assert_contract_structure_consensus_error(&error); +} + +/// The refusal is a registration rule. A contract that carries the combination +/// was registered under a protocol that allowed it, and every stored contract +/// is loaded through the structural parse, so that parse must keep reading it +/// or the activation that migrates its history could not even start. +#[test] +fn should_still_load_a_legacy_contested_keep_history_type_without_validation() { + let schema = platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "indices": [ + { + "name": "byLabel", + "properties": [{"label": "asc"}], + "unique": true, + "contested": { + "fieldMatches": [{"field": "label", "regexPattern": "^[a-z]{3,10}$"}], + "resolution": 0, + }, + }, + ], + "required": ["label"], + "additionalProperties": false, + "documentsMutable": false, + "documentsKeepHistory": true, + "canBeDeleted": false, + }); + let document_type = parse_without_validation(schema) + .expect("a stored contract with this combination must still load"); + assert!(document_type.documents_keep_history()); +} + +/// The same index without history is unaffected: the refusal is about the +/// combination, not about contested indexes. +#[test] +fn should_accept_a_contested_index_without_history() { + let schema = platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "indices": [ + { + "name": "byLabel", + "properties": [{"label": "asc"}], + "unique": true, + "contested": { + "fieldMatches": [{"field": "label", "regexPattern": "^[a-z]{3,10}$"}], + "resolution": 0, + }, + }, + ], + "required": ["label"], + "additionalProperties": false, + "documentsMutable": false, + }); + parse(schema).expect("a contested index alone is fine"); +} + +fn repair_schema(keep_history: bool, can_be_deleted: bool) -> Value { + platform_value!({ + "type": "object", + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "additionalProperties": false, + "documentsKeepHistory": keep_history, + "canBeDeleted": can_be_deleted, + }) +} + +/// A keep-history type may withdraw deletion, and only in that direction. +#[test] +fn should_allow_a_keep_history_type_to_withdraw_deletion() { + let old = parse_at_version(repair_schema(true, true), 13, true).unwrap(); + let new = parse(repair_schema(true, false)).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .expect("the update must reach a consensus result"); + assert!(result.is_valid(), "rejected: {:?}", result.errors); +} + +#[test] +fn should_preserve_the_immutable_delete_flag_through_protocol_13() { + for protocol in [12, 13] { + let old = parse_at_version(repair_schema(true, true), protocol, true).unwrap(); + let new = parse_at_version(repair_schema(true, false), protocol, true).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::get(protocol).unwrap()) + .unwrap(); + assert!( + !result.is_valid(), + "protocol {protocol} must still refuse the change" + ); + } +} + +#[test] +fn should_reject_other_delete_and_history_flag_changes() { + for (old_flags, new_flags) in [ + ((false, true), (false, false)), + ((false, false), (false, true)), + ((true, false), (true, true)), + ((true, true), (false, false)), + ((false, true), (true, false)), + ] { + let old = parse_at_version(repair_schema(old_flags.0, old_flags.1), 13, true).unwrap(); + // A caller may already have a parsed contract; update validation must + // enforce immutability even without the full-validation parser guard. + let new = parse_without_validation(repair_schema(new_flags.0, new_flags.1)).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .unwrap(); + assert!( + !result.is_valid(), + "unexpectedly accepted {old_flags:?} -> {new_flags:?}" + ); + } +} + +/// Erasability is immutable in both directions. Widening it hands an +/// irreversible operation to a type registered without it; narrowing it after a +/// first chunk has removed revisions strands a partially erased document. +#[test] +fn should_reject_every_change_to_the_erasure_flag() { + for (before, after) in [(false, true), (true, false)] { + let old = parse_without_validation(erasable_schema(true, true, before)).unwrap(); + let new = parse_without_validation(erasable_schema(true, true, after)).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .unwrap(); + let message = result + .errors + .first() + .unwrap_or_else(|| panic!("unexpectedly accepted canBeErased {before} -> {after}")) + .to_string(); + assert!( + message.contains("can not change whether its documents can be erased"), + "canBeErased {before} -> {after} must be refused for being immutable, got {message}" + ); + } +} + +/// An erasable type can never stop being deletable, whichever way the update is +/// spelled: erasure applies to deleted documents only, and since erasability +/// itself cannot be withdrawn, such a type could never reach a state erasure +/// acts on again. Keeping the flag makes the type unparseable; dropping it +/// changes an immutable flag. +#[test] +fn should_refuse_to_withdraw_deletion_from_an_erasable_type() { + assert!( + parse_without_validation(erasable_schema(true, false, true)).is_err(), + "an erasable type that forbids deletion is not a valid type at all" + ); + + let old = parse_without_validation(erasable_schema(true, true, true)).unwrap(); + let new = parse_without_validation(repair_schema(true, false)).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .unwrap(); + assert!(!result.is_valid(), "an erasable type kept its delete flag"); +} + +#[test] +fn should_reject_incompatible_properties_during_a_delete_flag_withdrawal() { + let old = parse_at_version(repair_schema(true, true), 13, true).unwrap(); + let new = parse(platform_value!({ + "type": "object", + "properties": { + "label": {"type": "integer", "position": 0}, + }, + "additionalProperties": false, + "documentsKeepHistory": true, + "canBeDeleted": false, + })) + .unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .unwrap(); + assert!( + !result.is_valid(), + "the withdrawal must not bypass schema compatibility" + ); +} + +#[test] +fn should_reject_mutability_change_during_a_delete_flag_withdrawal() { + let old = parse_at_version(repair_schema(true, true), 13, true).unwrap(); + let mut schema = repair_schema(true, false); + schema.set_value("documentsMutable", false.into()).unwrap(); + let new = parse(schema).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .unwrap(); + assert!( + !result.is_valid(), + "the withdrawal must not bypass other configuration checks" + ); +} + +#[test] +fn should_still_validate_a_property_named_can_be_deleted_during_a_withdrawal() { + let mut old_schema = repair_schema(true, true); + old_schema + .set_value( + "properties", + platform_value!({ + "canBeDeleted": {"type": "string", "maxLength": 50, "position": 0}, + }), + ) + .unwrap(); + let mut new_schema = old_schema.clone(); + new_schema.set_value("canBeDeleted", false.into()).unwrap(); + new_schema + .set_value( + "properties", + platform_value!({ + "canBeDeleted": {"type": "integer", "position": 0}, + }), + ) + .unwrap(); + let old = parse_at_version(old_schema, 13, true).unwrap(); + let new = parse(new_schema).unwrap(); + let result = old + .as_ref() + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) + .unwrap(); + assert!( + !result.is_valid(), + "only the top-level config flag may be stripped" + ); +} + +#[test] +fn should_round_trip_an_erasable_compiled_type_and_check_its_flag() { + use crate::data_contract::document_type::serialized_version::DocumentTypeInSerializationFormat; + use crate::serialization::{PlatformDeserializableUntrusted, PlatformSerializable}; + let version = PlatformVersion::latest(); + let mut schema = keep_history_deletable_schema(); + schema.set_value("canBeErased", true.into()).unwrap(); + let parsed = parse(schema.clone()).unwrap(); + let stored = + DocumentTypeInSerializationFormat::try_from_document_type(parsed.as_ref(), None, version) + .unwrap(); + assert!(stored + .is_compiled_from(parsed.as_ref(), None, version) + .unwrap()); + let bytes = stored.serialize_to_bytes().unwrap(); + let recovered = DocumentTypeInSerializationFormat::deserialize_from_bytes_untrusted(&bytes) + .unwrap() + .into_document_type("test_doc", Identifier::new([1; 32]), schema.clone()) + .unwrap(); + assert_eq!(parsed, recovered); + schema.set_value("canBeErased", false.into()).unwrap(); + let changed = parse(schema).unwrap(); + assert!( + !stored + .is_compiled_from(changed.as_ref(), None, version) + .unwrap(), + "a stored erasable flag must agree with the parsed schema" + ); +} diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v4/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v4/mod.rs new file mode 100644 index 00000000000..5e8ba1633fd --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v4/mod.rs @@ -0,0 +1,106 @@ +//! Document-type parser **generation 4** — protocol version 15 and later. +//! +//! Generation 4 is generation 3 plus the keep-history document lifecycle: a +//! keep-history type may allow deletion, may additionally declare +//! `canBeErased`, and may not carry a contested index. Its index grammar, the +//! ranked index-key ceilings and the prefix-overlap rule are generation 3's, +//! reused from that module rather than copied. +//! +//! The generation reuses the complete current parser body with a generation-owned +//! admission flag. Earlier generations retain their refusal of deletable history. + +use crate::data_contract::config::DataContractConfig; +use crate::data_contract::document_type::v2::DocumentTypeV2; +use crate::data_contract::document_type::DocumentType; +use crate::data_contract::{TokenConfiguration, TokenContractPosition}; +use crate::validation::operations::ProtocolValidationOperation; +use crate::version::PlatformVersion; +use crate::ProtocolError; +use platform_value::{Identifier, Value}; +use std::collections::BTreeMap; + +use super::common; + +/// Parses a document type schema through the generation-4 grammar: the whole +/// generation-3 grammar plus the keep-history document lifecycle keywords. +/// +/// This parser is only reachable from protocol version 15+ (via +/// CONTRACT_VERSIONS_V7). +/// +/// Generation 4 admits `documentsKeepHistory: true` together with +/// `canBeDeleted: true`: a delete on such a type removes the document from +/// ordinary reads while its retained revisions stay readable. It also admits +/// the `canBeErased` keyword, which additionally allows a deleted document's +/// revisions to be purged, and it refuses a keep-history type that carries a +/// contested index. +#[allow(clippy::too_many_arguments)] +fn try_from_schema_generation_4( + data_contract_id: Identifier, + data_contract_system_version: u16, + contract_config_version: u16, + name: &str, + schema: Value, + schema_defs: Option<&BTreeMap>, + token_configurations: &BTreeMap, + data_contact_config: &DataContractConfig, + full_validation: bool, + validation_operations: &mut impl Extend, + platform_version: &PlatformVersion, +) -> Result { + super::v3::try_from_schema_generation_3( + data_contract_id, + data_contract_system_version, + contract_config_version, + name, + schema, + schema_defs, + token_configurations, + data_contact_config, + full_validation, + validation_operations, + &PARSER_GENERATION, + platform_version, + ) +} + +impl DocumentType { + /// Dispatches to this module's generation-4 parser and wraps the result. + #[allow(clippy::too_many_arguments)] + pub(in crate::data_contract::document_type::class_methods) fn try_from_schema_v4( + data_contract_id: Identifier, + data_contract_system_version: u16, + contract_config_version: u16, + name: &str, + schema: Value, + schema_defs: Option<&BTreeMap>, + token_configurations: &BTreeMap, + data_contact_config: &DataContractConfig, + full_validation: bool, + validation_operations: &mut impl Extend, + platform_version: &PlatformVersion, + ) -> Result { + try_from_schema_generation_4( + data_contract_id, + data_contract_system_version, + contract_config_version, + name, + schema, + schema_defs, + token_configurations, + data_contact_config, + full_validation, + validation_operations, + platform_version, + ) + .map(DocumentType::V2) + } +} + +const PARSER_GENERATION: common::ParserGeneration = common::ParserGeneration { + admit_lifecycle: true, + meta_schema_method_name: "DocumentType::try_from_schema_v4 (document_type_schema)", + ..super::v3::PARSER_GENERATION +}; + +#[cfg(test)] +mod keep_history_tests; diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 21de8dcd6bd..31354c4d075 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -1202,7 +1202,7 @@ impl IndexGrammarAdmissions { /// flags currently move together; they stay separate fields because /// they are separate grammar admissions — a future generation may /// admit one without the other, and then only this mapping changes. - pub(crate) fn for_schema_generation(generation: u16) -> Self { + pub(crate) const fn for_schema_generation(generation: u16) -> Self { Self { ranked: generation >= 3, time_range: generation >= 3, diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/mod.rs index 6e4418eaeeb..dcf484fe480 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/mod.rs @@ -6,6 +6,7 @@ use platform_version::version::PlatformVersion; mod common; mod v0; mod v1; +mod v2; impl DocumentTypeRef<'_> { /// Verify that the update to the document type is valid. @@ -27,9 +28,10 @@ impl DocumentTypeRef<'_> { { 0 => self.validate_update_v0(new_document_type, platform_version), 1 => self.validate_update_v1(new_document_type, new_contract_version, platform_version), + 2 => self.validate_update_v2(new_document_type, new_contract_version, platform_version), version => Err(ProtocolError::UnknownVersionMismatch { method: "validate_update".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0, 1, 2], received: version, }), } diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/v2/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/v2/mod.rs new file mode 100644 index 00000000000..7332a733cc5 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/validate_update/v2/mod.rs @@ -0,0 +1,69 @@ +//! Protocol v15 generation of document type update validation. +//! +//! v2 is v1 plus the keep-history document lifecycle. Two rules are new: +//! +//! * `canBeErased` is immutable in both directions. Widening it would give an +//! operation over already-stored revisions to a type registered without it; +//! narrowing it after a first erase chunk has irreversibly removed revisions +//! would strand a partially erased, invisible document forever. +//! * A keep-history type may withdraw deletion (`canBeDeleted: true -> false`) +//! while keeping history, and only in that direction, and only while it is +//! not erasable: erase applies to deleted documents only and erasability is +//! itself immutable, so an erasable type that stopped allowing deletion could +//! never again reach a state erase acts on. +//! +//! Every other check is v1's, which v2 delegates to once the two lifecycle +//! rules above have passed. The one case where v1 alone would decide +//! differently, an erasable type withdrawing deletion, is refused here before +//! v1 sees it, so v1's option computation stays what it was. + +use crate::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError; +use crate::data_contract::document_type::accessors::{ + DocumentTypeV0Getters, DocumentTypeV2Getters, +}; +use crate::data_contract::document_type::DocumentTypeRef; +use crate::validation::SimpleConsensusValidationResult; +use crate::ProtocolError; +use platform_version::version::PlatformVersion; + +impl DocumentTypeRef<'_> { + #[inline(always)] + pub(super) fn validate_update_v2( + &self, + new_document_type: DocumentTypeRef, + new_contract_version: u32, + platform_version: &PlatformVersion, + ) -> Result { + if new_document_type.documents_can_be_erased() != self.documents_can_be_erased() { + return Ok(SimpleConsensusValidationResult::new_with_error( + DocumentTypeUpdateError::new( + self.data_contract_id(), + self.name(), + format!( + "document type can not change whether its documents can be erased: changing from {} to {}", + self.documents_can_be_erased(), + new_document_type.documents_can_be_erased() + ), + ) + .into(), + )); + } + + if self.documents_can_be_erased() + && self.documents_can_be_deleted() + && !new_document_type.documents_can_be_deleted() + { + return Ok(SimpleConsensusValidationResult::new_with_error( + DocumentTypeUpdateError::new( + self.data_contract_id(), + self.name(), + "document type whose documents can be erased can not stop allowing deletion" + .to_string(), + ) + .into(), + )); + } + + self.validate_update_v1(new_document_type, new_contract_version, platform_version) + } +} diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 9f2586bec9c..e7785e4331b 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -68,6 +68,7 @@ pub(crate) mod property_names { pub const DOCUMENTS_MUTABLE: &str = "documentsMutable"; pub const CAN_BE_DELETED: &str = "canBeDeleted"; + pub const CAN_BE_ERASED: &str = "canBeErased"; /// The `canBeDeleted` value saying a document leaves state only when a /// `refersTo` with `consume` deletes it, never by its owner's delete. /// Meta-schema v3+ (protocol version 14). diff --git a/packages/rs-dpp/src/data_contract/document_type/property/reference_lookup.rs b/packages/rs-dpp/src/data_contract/document_type/property/reference_lookup.rs index fa80bb8cb1f..ff627134c34 100644 --- a/packages/rs-dpp/src/data_contract/document_type/property/reference_lookup.rs +++ b/packages/rs-dpp/src/data_contract/document_type/property/reference_lookup.rs @@ -848,9 +848,8 @@ impl DocumentReferenceLookup { referenced.name() )); } - // The storage layer refuses to delete a document whose type keeps history. A full - // parse, the only one this check runs under, already refuses such a type that allows - // deletion; the rule is kept here too, as `ttl` and moderator deletion keep theirs + // Consume deletes through the read-delete path, which refuses a keep-history type; + // consuming would bypass the explicit delete and erase lifecycle. if self.consume && referenced.documents_keep_history() { return Some(format!( "consume deletes the found document, which the storage layer refuses for \ @@ -1689,8 +1688,8 @@ mod tests { #[test] fn should_refuse_consuming_a_type_that_keeps_history() { - // Parsed without full validation, as a type stored before protocol version 14 - // may be: a full parse refuses a deletable type that keeps history first + // A history type may be deletable, but consuming it would bypass the + // explicit delete and erase lifecycle. let keeps_history = join_request_with(platform_value!({ "canBeDeleted": true, "documentsKeepHistory": true diff --git a/packages/rs-dpp/src/data_contract/document_type/schema/validate_schema_compatibility/v1/mod.rs b/packages/rs-dpp/src/data_contract/document_type/schema/validate_schema_compatibility/v1/mod.rs index cd319cc2891..c8cf2fcb01b 100644 --- a/packages/rs-dpp/src/data_contract/document_type/schema/validate_schema_compatibility/v1/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/schema/validate_schema_compatibility/v1/mod.rs @@ -45,6 +45,10 @@ //! as incompatible instead of failing the update as an unsupported keyword. //! Generation 0 fails on a diff under any of them as an unsupported keyword. //! +//! The top-level `canBeErased` flag is frozen when present. Schemas without +//! that flag keep the original rule set, including released schemas and +//! comparisons of contract definitions. +//! //! Both schemas are compared with their property type shorthands //! (`"type": "identifier"`, `"type": "bytes"` with a `size`) rewritten into //! the long form they stand for, as the parse reads them @@ -54,11 +58,11 @@ //! shorthands exist from protocol version 14, the only version selecting it. use crate::data_contract::document_type::property_names::{ - ACTION_FEES, CONTAINS, DELETE_CONSTRAINTS, DOCUMENTS_AVERAGEABLE, DOCUMENTS_COUNTABLE, - DOCUMENTS_SUMMABLE, ENTRY_PAYLOAD, INDEX_ONLY, KEEPS_PRICING_HISTORY, KEEPS_PURCHASE_HISTORY, - KEEPS_TRANSFER_HISTORY, MAX_PROPERTIES, MIN_PROPERTIES, MODERATOR_ABILITIES, - PROPERTY_CONSTRAINTS, RANGE_AVERAGEABLE, RANGE_COUNTABLE, RANGE_SUMMABLE, RETRACTED_WHEN, - TOKEN_COST, TRANSIENT, TTL, + ACTION_FEES, CAN_BE_ERASED, CONTAINS, DELETE_CONSTRAINTS, DOCUMENTS_AVERAGEABLE, + DOCUMENTS_COUNTABLE, DOCUMENTS_SUMMABLE, ENTRY_PAYLOAD, INDEX_ONLY, KEEPS_PRICING_HISTORY, + KEEPS_PURCHASE_HISTORY, KEEPS_TRANSFER_HISTORY, MAX_PROPERTIES, MIN_PROPERTIES, + MODERATOR_ABILITIES, PROPERTY_CONSTRAINTS, RANGE_AVERAGEABLE, RANGE_COUNTABLE, RANGE_SUMMABLE, + RETRACTED_WHEN, TOKEN_COST, TRANSIENT, TTL, }; use crate::data_contract::document_type::schema::IncompatibleJsonSchemaOperation; use crate::data_contract::document_type::DocumentType; @@ -79,7 +83,7 @@ use platform_version::version::PlatformVersion; use std::borrow::Cow; use std::ops::Deref; -static OPTIONS: Lazy = Lazy::new(|| { +static LEGACY_OPTIONS: Lazy = Lazy::new(|| { let mut required_rule = KEYWORD_COMPATIBILITY_RULES .get("required") .expect("required rule must be present") @@ -136,6 +140,14 @@ static OPTIONS: Lazy = Lazy::new(|| { } }); +static OPTIONS: Lazy = Lazy::new(|| { + let mut options = LEGACY_OPTIONS.clone(); + if let Some(rule) = KEYWORD_COMPATIBILITY_RULES.get("refersTo") { + options.override_rules.insert(CAN_BE_ERASED, rule.clone()); + } + options +}); + /// The keywords the document meta-schema admits that have no rule in the /// shared rule set, which generation 0 also reads, and are not stripped by /// [`prepared_for_diff`]. Without a rule, a diff under one fails as an @@ -267,7 +279,18 @@ pub(super) fn validate_schema_compatibility_v1( let original_schema = prepared_for_diff(&original_schema); let new_schema = prepared_for_diff(&new_schema); - match validate_schemas_compatibility(&original_schema, &new_schema, OPTIONS.deref()) { + // Released grammars refuse the top-level erasure flag. Keep their rules, + // including comparisons of contract definitions, unchanged; only schemas + // declaring the lifecycle flag need its frozen rule. + let options = if [&original_schema, &new_schema] + .iter() + .any(|schema| schema.get(CAN_BE_ERASED).is_some_and(JsonValue::is_boolean)) + { + OPTIONS.deref() + } else { + LEGACY_OPTIONS.deref() + }; + match validate_schemas_compatibility(&original_schema, &new_schema, options) { Ok(result) => { let errors = result .into_changes() @@ -784,6 +807,7 @@ mod tests { ]; // Scalars, whose change is reported at the keyword itself let scalars = [ + ("/canBeErased", json!(true), json!(false)), ("/ttl", json!(86400), json!(3600)), ("/indexOnly", json!(true), json!(false)), ("/keepsTransferHistory", json!(true), json!(false)), @@ -821,7 +845,7 @@ mod tests { schema } - /// Meta-schema v3 admits these keywords, which the shared rule set has no + /// The document schema grammar admits these keywords, which the shared rule set has no /// rule for: each is frozen, so adding, removing or changing one, even to /// a value the parse reads the same, is an incompatible change and not an /// unsupported keyword. Where the parse reads a value, `validate_update` @@ -862,6 +886,27 @@ mod tests { } } + #[test] + fn should_preserve_released_updates_to_definitions_named_can_be_erased() { + let version = PlatformVersion::get(14).expect("protocol 14"); + let original = json!({ + "$defs": { + "canBeErased": { "type": "object", "properties": {} }, + }, + }); + let updated = json!({ + "$defs": { + "canBeErased": { + "type": "object", + "properties": { "name": { "type": "string" } }, + }, + }, + }); + assert!(validate_schema_compatibility(&original, &updated, version) + .expect("a definition can gain an optional property") + .is_valid()); + } + /// Every keyword the document meta-schema admits, at the top of a document /// type, in a property's schema or in a typed array's element schema, is /// judged by a rule of its own or stripped before the diff, for every diff --git a/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/mod.rs index 8447b3acf3b..c60d9a3db1f 100644 --- a/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/mod.rs @@ -62,6 +62,36 @@ fn stored_error(message: String) -> ProtocolError { ProtocolError::CorruptedSerialization(format!("stored document type: {message}")) } +/// Deletion policy encoded where earlier compiled types stored a boolean. The first two +/// variants preserve the boolean's bytes; only erasable history uses the third variant. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode, DecodeUntrusted)] +enum StoredDeletion { + NotDeletable, + Deletable, + DeletableAndErasable, +} + +impl StoredDeletion { + fn of(deletable: bool, erasable: bool) -> Result { + match (deletable, erasable) { + (false, false) => Ok(Self::NotDeletable), + (true, false) => Ok(Self::Deletable), + (true, true) => Ok(Self::DeletableAndErasable), + (false, true) => Err(stored_error("erasable type cannot be deleted".to_string())), + } + } + fn into_parts(self, keeps_history: bool) -> Result<(bool, bool), ProtocolError> { + match self { + Self::NotDeletable => Ok((false, false)), + Self::Deletable => Ok((true, false)), + Self::DeletableAndErasable if keeps_history => Ok((true, true)), + Self::DeletableAndErasable => { + Err(stored_error("erasable type keeps no history".to_string())) + } + } + } +} + /// A document type compiled, generation 0. #[derive(Debug, Clone, PartialEq, Encode, Decode, DecodeUntrusted)] pub struct DocumentTypeInSerializationFormatV0 { @@ -85,7 +115,7 @@ pub struct DocumentTypeInSerializationFormatV0 { documents_keep_purchase_history: bool, documents_keep_pricing_history: bool, documents_mutable: bool, - documents_can_be_deleted: bool, + documents_can_be_deleted: StoredDeletion, documents_deleted_only_when_consumed: bool, documents_transferable: StoredTransferable, trade_mode: StoredTradeMode, @@ -177,6 +207,7 @@ impl DocumentTypeInSerializationFormatV0 { documents_keep_pricing_history, documents_mutable, documents_can_be_deleted, + documents_can_be_erased, documents_deleted_only_when_consumed, documents_transferable, trade_mode, @@ -230,7 +261,10 @@ impl DocumentTypeInSerializationFormatV0 { documents_keep_purchase_history: *documents_keep_purchase_history, documents_keep_pricing_history: *documents_keep_pricing_history, documents_mutable: *documents_mutable, - documents_can_be_deleted: *documents_can_be_deleted, + documents_can_be_deleted: StoredDeletion::of( + *documents_can_be_deleted, + *documents_can_be_erased, + )?, documents_deleted_only_when_consumed: *documents_deleted_only_when_consumed, documents_transferable: (*documents_transferable).into(), trade_mode: (*trade_mode).into(), @@ -364,6 +398,8 @@ impl DocumentTypeInSerializationFormatV0 { } = self; let (index_only, private_document) = storage.into_parts()?; + let (documents_can_be_deleted, documents_can_be_erased) = + documents_can_be_deleted.into_parts(documents_keep_history)?; let properties = properties_from_stored(properties)?; let flattened_properties = properties_from_stored(flattened_properties)?; @@ -436,6 +472,7 @@ impl DocumentTypeInSerializationFormatV0 { documents_keep_pricing_history, documents_mutable, documents_can_be_deleted, + documents_can_be_erased, documents_deleted_only_when_consumed, documents_transferable: documents_transferable.into(), trade_mode: trade_mode.into(), diff --git a/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/tests.rs b/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/tests.rs index 1d7d0aff74a..2096c4f5218 100644 --- a/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/serialized_version/v0/tests.rs @@ -239,3 +239,21 @@ fn should_write_stored_generation_0_only_with_index_structure_builder_0() { .contract_storage_document_type_version = 1; assert!(compile(&unknown_generation).is_err()); } + +#[test] +fn should_preserve_boolean_deletion_bytes_and_refuse_erasable_storage_without_history() { + use super::StoredDeletion; + for (flag, policy) in [ + (false, StoredDeletion::NotDeletable), + (true, StoredDeletion::Deletable), + ] { + assert_eq!( + bincode::encode_to_vec(flag, PLATFORM_BINCODE_CONFIG).unwrap(), + bincode::encode_to_vec(policy, PLATFORM_BINCODE_CONFIG).unwrap() + ); + } + let policy = StoredDeletion::of(true, true).unwrap(); + assert_eq!(policy.into_parts(true).unwrap(), (true, true)); + assert!(policy.into_parts(false).is_err()); + assert!(StoredDeletion::of(false, true).is_err()); +} diff --git a/packages/rs-dpp/src/data_contract/document_type/v2/accessors.rs b/packages/rs-dpp/src/data_contract/document_type/v2/accessors.rs index e2383028874..73faf07be44 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v2/accessors.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v2/accessors.rs @@ -226,6 +226,9 @@ impl DocumentTypeV1Getters for DocumentTypeV2 { } impl DocumentTypeV2Getters for DocumentTypeV2 { + fn documents_can_be_erased(&self) -> bool { + self.documents_can_be_erased + } fn documents_countable(&self) -> bool { self.documents_countable || self.range_countable } diff --git a/packages/rs-dpp/src/data_contract/document_type/v2/mod.rs b/packages/rs-dpp/src/data_contract/document_type/v2/mod.rs index 20fe131fb1e..d3206ea07d2 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v2/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v2/mod.rs @@ -96,6 +96,8 @@ pub struct DocumentTypeV2 { pub(in crate::data_contract) documents_mutable: bool, /// Can documents of this type be deleted? pub(in crate::data_contract) documents_can_be_deleted: bool, + /// Whether a deleted document's retained revisions may be erased. + pub(in crate::data_contract) documents_can_be_erased: bool, /// Whether the documents of this type leave state only when a `refersTo` with /// `consume` deletes them (`canBeDeleted: "onlyWhenConsumed"`, protocol version 14). /// Only ever `true` beside a `false` `documents_can_be_deleted`: the owner can not @@ -364,6 +366,7 @@ impl From for DocumentTypeV2 { documents_keep_pricing_history: value.documents_keep_pricing_history, documents_mutable: value.documents_mutable, documents_can_be_deleted: value.documents_can_be_deleted, + documents_can_be_erased: false, documents_deleted_only_when_consumed: false, documents_transferable: value.documents_transferable, trade_mode: value.trade_mode, @@ -428,6 +431,7 @@ impl From for DocumentTypeV2 { documents_keep_pricing_history: value.documents_keep_pricing_history, documents_mutable: value.documents_mutable, documents_can_be_deleted: value.documents_can_be_deleted, + documents_can_be_erased: false, documents_deleted_only_when_consumed: false, documents_transferable: value.documents_transferable, trade_mode: value.trade_mode, diff --git a/packages/rs-dpp/src/document/lifecycle/mod.rs b/packages/rs-dpp/src/document/lifecycle/mod.rs new file mode 100644 index 00000000000..515ab7f2185 --- /dev/null +++ b/packages/rs-dpp/src/document/lifecycle/mod.rs @@ -0,0 +1,225 @@ +//! The lifecycle record of a keep-history document. +//! +//! A keep-history document that has been deleted keeps its retained revisions +//! but loses its current pointer and its index references, so nothing in the +//! primary-key tree distinguishes it from a document that never existed. The +//! record supplies that distinction: it exists exactly while the document is +//! deleted or erasing, names the block time it was deleted at, and, once an +//! erasure has been authorized, the block time that erasure started and the +//! revision it started from. Drive stores it beside the document's history and +//! proof verifiers decode it from a proof. + +use crate::ProtocolError; +use bincode::{Decode, DecodeUntrusted, Encode}; +use derive_more::From; +use platform_serialization_derive::{ + PlatformDeserializeTrusted, PlatformDeserializeUntrusted, PlatformSerialize, +}; +use platform_versioning::PlatformVersioned; + +pub mod v0; + +pub use v0::DocumentLifecycleRecordV0; + +/// Largest number of bytes an encoded record can occupy: the format +/// discriminant and six variable-length `u64`s at their widest. Estimates +/// that have to price a record without reading it use this bound. +pub const DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE: u32 = 1 + 6 * 9; + +/// A lifecycle record in whichever layout it was written with. +#[derive( + Debug, + Clone, + Copy, + Encode, + Decode, + DecodeUntrusted, + PlatformDeserializeTrusted, + PlatformDeserializeUntrusted, + PlatformSerialize, + PlatformVersioned, + From, + PartialEq, + Eq, +)] +#[cfg_attr( + feature = "serde-conversion", + derive(serde::Serialize, serde::Deserialize), + serde(tag = "$formatVersion") +)] +#[platform_serialize(unversioned)] +pub enum DocumentLifecycleRecord { + /// The original layout. + #[cfg_attr(feature = "serde-conversion", serde(rename = "0"))] + V0(DocumentLifecycleRecordV0), +} + +impl DocumentLifecycleRecord { + /// Builds the record a delete writes: the deletion time, what the deleted + /// document's revision was and how many revisions its history retained, + /// and no erasure. + pub fn deleted_at(deleted_at_ms: u64, latest_revision: u64, revision_count: u64) -> Self { + DocumentLifecycleRecord::V0(DocumentLifecycleRecordV0 { + deleted_at_ms, + latest_revision, + revision_count, + ..Default::default() + }) + } + + /// Block time the document was deleted at. + pub fn deleted_at_ms(&self) -> u64 { + match self { + DocumentLifecycleRecord::V0(v0) => v0.deleted_at_ms, + } + } + + /// Revision the document carried when it was deleted. + pub fn latest_revision(&self) -> u64 { + match self { + DocumentLifecycleRecord::V0(v0) => v0.latest_revision, + } + } + + /// Number of revisions the history retained when the document was deleted. + pub fn revision_count(&self) -> u64 { + match self { + DocumentLifecycleRecord::V0(v0) => v0.revision_count, + } + } + + /// Whether the revisions retained at deletion numbered one through the + /// deleted revision without a gap, which is what lets a by-revision read + /// map a revision onto a position in the history. + /// + /// A gap can only come from a history written before protocol 15, where + /// two writes in one block overwrote each other's revision; an erase + /// removes the newest revisions first and so never opens one. + pub fn revisions_are_contiguous(&self) -> bool { + self.latest_revision() == self.revision_count() + } + + /// Block time an authorized erasure started at, or zero while none has. + pub fn erasing_started_at_ms(&self) -> u64 { + match self { + DocumentLifecycleRecord::V0(v0) => v0.erasing_started_at_ms, + } + } + + /// Timestamp component of the newest revision retained at erase start. + pub fn erasing_from_time_ms(&self) -> u64 { + match self { + DocumentLifecycleRecord::V0(v0) => v0.erasing_from_time_ms, + } + } + + /// History sequence of the newest revision retained at erase start. + pub fn erasing_from_revision(&self) -> u64 { + match self { + DocumentLifecycleRecord::V0(v0) => v0.erasing_from_revision, + } + } + + /// Whether an authorized erasure has already started, which is what lets a + /// continuation run without any authorization of its own. + /// + /// Read off the revision the erasure started from rather than the time it + /// started at: a history sequence is one or more for every real revision, + /// so zero can only mean the field was never written, while a block time of + /// zero is a value a clock could in principle produce. + pub fn is_erasing(&self) -> bool { + self.erasing_from_revision() != 0 + } + + /// Whether the record describes a possible deletion and erase start. The + /// remaining count belongs to the authenticated history tree and is checked + /// by history-page decoders rather than inferred from this record. + pub fn is_coherent(&self) -> bool { + if self.revision_count() == 0 || self.latest_revision() < self.revision_count() { + return false; + } + if self.is_erasing() { + self.erasing_from_revision() == self.latest_revision() + && self.erasing_started_at_ms() >= self.deleted_at_ms() + && self.erasing_from_time_ms() <= self.deleted_at_ms() + } else { + self.erasing_started_at_ms() == 0 && self.erasing_from_time_ms() == 0 + } + } + + /// Returns the record an erase start writes over this one, keeping the + /// deletion time and recording the erasure it authorizes. + pub fn starting_erase_at( + &self, + erasing_started_at_ms: u64, + erasing_from_time_ms: u64, + erasing_from_revision: u64, + ) -> Self { + DocumentLifecycleRecord::V0(DocumentLifecycleRecordV0 { + deleted_at_ms: self.deleted_at_ms(), + latest_revision: self.latest_revision(), + revision_count: self.revision_count(), + erasing_started_at_ms, + erasing_from_time_ms, + erasing_from_revision, + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::serialization::{PlatformDeserializableUntrusted, PlatformSerializable}; + + #[test] + fn should_round_trip_every_field() { + let record = DocumentLifecycleRecord::deleted_at(7, 12, 11).starting_erase_at(8, 9, 10); + let bytes = record.serialize_to_bytes().expect("serialize"); + let recovered = + DocumentLifecycleRecord::deserialize_from_bytes_untrusted(&bytes).expect("round trip"); + assert_eq!(record, recovered); + assert!(recovered.is_erasing()); + assert_eq!(recovered.latest_revision(), 12); + assert_eq!(recovered.revision_count(), 11); + assert!(!recovered.revisions_are_contiguous()); + assert!(DocumentLifecycleRecord::deleted_at(7, 11, 11).revisions_are_contiguous()); + } + + /// The bound prices a record nobody has read yet, so it must hold for the + /// widest values every field can take. + #[test] + fn should_never_encode_past_the_size_bound() { + let widest = DocumentLifecycleRecord::deleted_at(u64::MAX, u64::MAX, u64::MAX) + .starting_erase_at(u64::MAX, u64::MAX, u64::MAX); + assert_eq!( + widest.serialize_to_bytes().expect("serialize").len(), + DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE as usize + ); + let narrowest = DocumentLifecycleRecord::deleted_at(0, 0, 0); + assert!( + narrowest.serialize_to_bytes().expect("serialize").len() + <= DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE as usize + ); + } + + #[test] + fn should_report_a_record_without_erase_fields_as_deleted_not_erasing() { + let record = DocumentLifecycleRecord::deleted_at(7, 1, 1); + assert!(!record.is_erasing()); + assert_eq!(record.erasing_from_revision(), 0); + } + + /// A block whose time is zero must not make a committed erasure look like + /// one that never started. + #[test] + fn should_report_an_erasure_started_in_a_block_at_time_zero_as_erasing() { + let record = DocumentLifecycleRecord::deleted_at(0, 1, 1).starting_erase_at(0, 0, 1); + assert!(record.is_erasing()); + } + + #[test] + fn should_reject_bytes_that_are_not_a_record() { + assert!(DocumentLifecycleRecord::deserialize_from_bytes_untrusted(&[]).is_err()); + assert!(DocumentLifecycleRecord::deserialize_from_bytes_untrusted(&[9]).is_err()); + } +} diff --git a/packages/rs-dpp/src/document/lifecycle/v0/mod.rs b/packages/rs-dpp/src/document/lifecycle/v0/mod.rs new file mode 100644 index 00000000000..c06cbdc7c26 --- /dev/null +++ b/packages/rs-dpp/src/document/lifecycle/v0/mod.rs @@ -0,0 +1,32 @@ +use bincode::{Decode, DecodeUntrusted, Encode}; +use derive_more::From; + +/// What the committed state says about one keep-history document that is no +/// longer visible to ordinary reads. +#[derive(Debug, Clone, Copy, Encode, Decode, DecodeUntrusted, From, PartialEq, Eq, Default)] +#[cfg_attr( + feature = "serde-conversion", + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "camelCase") +)] +pub struct DocumentLifecycleRecordV0 { + /// Block time the document was deleted at. + pub deleted_at_ms: u64, + /// Revision the document carried when it was deleted. + pub latest_revision: u64, + /// Number of revisions the history retained when the document was deleted. + /// + /// Together with `latest_revision` this says whether the retained history + /// was contiguous: an erase removes the newest revisions first, so what + /// survives afterwards is a prefix of what was retained here, and a + /// by-revision read stays meaningful exactly when the two are equal. + pub revision_count: u64, + /// Block time an authorized erasure started at, or zero while none has. + pub erasing_started_at_ms: u64, + /// Timestamp component of the newest revision retained when the erasure + /// started, or zero while none has. + pub erasing_from_time_ms: u64, + /// History sequence of the newest revision retained when the erasure + /// started, or zero while none has. + pub erasing_from_revision: u64, +} diff --git a/packages/rs-dpp/src/document/mod.rs b/packages/rs-dpp/src/document/mod.rs index b8eb9a068b0..27ba469e914 100644 --- a/packages/rs-dpp/src/document/mod.rs +++ b/packages/rs-dpp/src/document/mod.rs @@ -13,6 +13,7 @@ pub mod errors; pub mod extended_document; mod fields; pub mod generate_document_id; +pub mod lifecycle; pub mod serialization_traits; #[cfg(feature = "factories")] pub mod specialized_document_factory; diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index df55059a7b5..ce7e77c4195 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -1386,6 +1386,9 @@ impl StateTransition { BatchedTransitionRef::Document(DocumentTransition::Create(_)) => "Create", BatchedTransitionRef::Document(DocumentTransition::Replace(_)) => "Replace", BatchedTransitionRef::Document(DocumentTransition::Delete(_)) => "Delete", + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + BatchedTransitionRef::Document(DocumentTransition::Erase(_)) => "Erase", BatchedTransitionRef::Document(DocumentTransition::Transfer(_)) => { "Transfer" } @@ -3646,6 +3649,86 @@ mod tests { assert_eq!(recovered, version_2); } + fn sample_format_1_batch_st_with_erase() -> StateTransition { + use crate::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; + use crate::state_transition::batch_transition::batched_transition::{ + BatchedTransition, DocumentEraseTransition, + }; + use crate::state_transition::batch_transition::BatchTransitionV1; + + let base = DocumentBaseTransition::V0(DocumentBaseTransitionV0 { + id: Identifier::from([1u8; 32]), + identity_contract_nonce: 3, + document_type_name: "note".to_string(), + data_contract_id: Identifier::from([2u8; 32]), + }); + let erase = + DocumentTransition::Erase(DocumentEraseTransition::V0(DocumentEraseTransitionV0 { + base, + })); + StateTransition::Batch(BatchTransition::V1(BatchTransitionV1 { + owner_id: Identifier::from([8u8; 32]), + transitions: vec![BatchedTransition::Document(erase)], + user_fee_increase: 2, + signature_public_key_id: 7, + signature: BinaryData::new(vec![0xEE; 65]), + })) + } + + /// The erase kind rides in the shipped batch formats, so a format 1 batch + /// carrying one keeps format 1's range and decodes under protocol 14 on + /// software that knows the kind. Agreement with software that cannot + /// decode it comes one step later: the basic-structure check refuses the + /// kind wherever the active version publishes no bounds for it. + #[cfg(all(feature = "state-transitions", feature = "validation"))] + #[test] + fn test_format_1_batch_with_erase_decodes_at_protocol_14_and_is_refused_by_structure() { + use crate::consensus::basic::BasicError; + use crate::consensus::ConsensusError; + use crate::serialization::PlatformSerializable; + + let state_transition = sample_format_1_batch_st_with_erase(); + assert_eq!( + state_transition.active_version_range(), + 9..=LATEST_VERSION, + "format 1 arrived with tokens at protocol version 9; the erase kind does not move it" + ); + let bytes = PlatformSerializable::serialize_to_bytes(&state_transition) + .expect("serialize succeeds"); + + let released = PlatformVersion::get(14).expect("protocol version 14 exists"); + let decoded = + StateTransition::deserialize_from_bytes_untrusted_in_version(&bytes, released) + .expect("a format 1 batch with an erase decodes under protocol version 14"); + assert_eq!(decoded.name(), "DocumentsBatch([Erase])"); + let StateTransition::Batch(batch) = decoded else { + panic!("expected a batch, got {decoded:?}"); + }; + + let is_unsupported_version = |error: &ConsensusError| { + matches!( + error, + ConsensusError::BasicError(BasicError::UnsupportedVersionError(_)) + ) + }; + let result = batch + .validate_base_structure(released) + .expect("no protocol err"); + assert!( + result.errors.iter().any(is_unsupported_version), + "protocol version 14 must refuse the erase kind, got {:?}", + result.errors + ); + let result = batch + .validate_base_structure(PlatformVersion::latest()) + .expect("no protocol err"); + assert!( + !result.errors.iter().any(is_unsupported_version), + "the latest protocol version must admit the erase kind, got {:?}", + result.errors + ); + } + fn sample_batch_st_empty() -> StateTransition { StateTransition::Batch(BatchTransition::V0(BatchTransitionV0 { owner_id: Identifier::from([1u8; 32]), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/from_document.rs new file mode 100644 index 00000000000..3f6d676ecf3 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/from_document.rs @@ -0,0 +1,52 @@ +use crate::data_contract::document_type::DocumentTypeRef; +use crate::document::Document; +use crate::prelude::IdentityNonce; +use crate::ProtocolError; +use platform_version::version::{FeatureVersion, PlatformVersion}; + +use crate::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; +use crate::state_transition::batch_transition::batched_transition::DocumentEraseTransition; +use crate::tokens::token_payment_info::TokenPaymentInfo; + +impl DocumentEraseTransition { + #[allow(clippy::too_many_arguments)] + pub fn from_document( + document: Document, + document_type: DocumentTypeRef, + token_payment_info: Option, + identity_contract_nonce: IdentityNonce, + feature_version: Option, + base_feature_version: Option, + platform_version: &PlatformVersion, + ) -> Result { + // `None` bounds mean the kind does not exist at this platform version + // (it joined the wire at protocol version 15) — constructing one there + // could only ever produce a transition the network refuses. + let bounds = platform_version + .dpp + .state_transition_serialization_versions + .document_erase_state_transition + .as_ref() + .ok_or_else(|| { + ProtocolError::Generic( + "erase transitions do not exist at this platform version".to_string(), + ) + })?; + match feature_version.unwrap_or(bounds.bounds.default_current_version) { + 0 => Ok(DocumentEraseTransitionV0::from_document( + document, + document_type, + token_payment_info, + identity_contract_nonce, + base_feature_version, + platform_version, + )? + .into()), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "DocumentEraseTransition::from_document".to_string(), + known_versions: vec![0], + received: version, + }), + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/mod.rs new file mode 100644 index 00000000000..ae751b487cf --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/mod.rs @@ -0,0 +1,97 @@ +mod from_document; +pub mod v0; +pub mod v0_methods; + +use bincode::{Decode, DecodeUntrusted, Encode}; +use derive_more::{Display, From}; +#[cfg(feature = "serde-conversion")] +use serde::{Deserialize, Serialize}; +pub use v0::*; + +#[derive(Debug, Clone, Encode, Decode, PartialEq, Display, From, DecodeUntrusted)] +#[cfg_attr( + feature = "serde-conversion", + derive(Serialize, Deserialize), + serde(tag = "$formatVersion") +)] +pub enum DocumentEraseTransition { + #[display("V0({})", "_0")] + #[cfg_attr(feature = "serde-conversion", serde(rename = "0"))] + V0(DocumentEraseTransitionV0), +} + +#[cfg(all(feature = "json-conversion", feature = "serde-conversion"))] +impl crate::serialization::JsonConvertible for DocumentEraseTransition {} + +#[cfg(all(feature = "value-conversion", feature = "serde-conversion"))] +impl crate::serialization::ValueConvertible for DocumentEraseTransition {} + +#[cfg(all( + test, + feature = "json-conversion", + feature = "value-conversion", + feature = "serde-conversion" +))] +pub(crate) mod json_convertible_tests { + use super::*; + use crate::state_transition::batch_transition::document_base_transition::v0::DocumentBaseTransitionV0; + use crate::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; + use platform_value::{platform_value, Identifier}; + use serde_json::json; + + /// Non-default values per field so the wire-shape assertion catches any + /// silent zero-out / flip on round-trip. + pub(crate) fn fixture() -> DocumentEraseTransition { + DocumentEraseTransition::V0(DocumentEraseTransitionV0 { + base: DocumentBaseTransition::V0(DocumentBaseTransitionV0 { + id: Identifier::new([0xe3; 32]), + identity_contract_nonce: 11, + document_type_name: "note".to_string(), + data_contract_id: Identifier::new([0xf4; 32]), + }), + }) + } + + #[test] + fn json_round_trip_with_full_wire_shape() { + use crate::serialization::JsonConvertible; + let original = fixture(); + let json = original.to_json().expect("to_json"); + // Doubly-tagged externally enum: outer `V0` for + // `DocumentEraseTransition`, inner `V0` for the flattened + // `base: DocumentBaseTransition`. + assert_eq!( + json, + json!({ + "$formatVersion": "0", + "$baseFormatVersion": "0", + "$id": Identifier::new([0xe3; 32]), + "$identityContractNonce": 11, + "$type": "note", + "$dataContractId": Identifier::new([0xf4; 32]), + }) + ); + let recovered = DocumentEraseTransition::from_json(json).expect("from_json"); + assert_eq!(original, recovered); + } + + #[test] + fn value_round_trip_with_full_wire_shape() { + use crate::serialization::ValueConvertible; + let original = fixture(); + let value = original.to_object().expect("to_object"); + assert_eq!( + value, + platform_value!({ + "$formatVersion": "0", + "$baseFormatVersion": "0", + "$id": Identifier::new([0xe3; 32]), + "$identityContractNonce": 11u64, + "$type": "note", + "$dataContractId": Identifier::new([0xf4; 32]), + }) + ); + let recovered = DocumentEraseTransition::from_object(value).expect("from_object"); + assert_eq!(original, recovered); + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/from_document.rs new file mode 100644 index 00000000000..b423ad0397c --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/from_document.rs @@ -0,0 +1,30 @@ +use crate::data_contract::document_type::DocumentTypeRef; +use crate::document::Document; +use crate::prelude::IdentityNonce; +use crate::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; +use crate::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; +use crate::tokens::token_payment_info::TokenPaymentInfo; +use crate::ProtocolError; +use platform_version::version::{FeatureVersion, PlatformVersion}; + +impl DocumentEraseTransitionV0 { + pub(crate) fn from_document( + document: Document, + document_type: DocumentTypeRef, + token_payment_info: Option, + identity_contract_nonce: IdentityNonce, + base_feature_version: Option, + platform_version: &PlatformVersion, + ) -> Result { + Ok(DocumentEraseTransitionV0 { + base: DocumentBaseTransition::from_document( + &document, + document_type, + token_payment_info, + identity_contract_nonce, + platform_version, + base_feature_version, + )?, + }) + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/mod.rs new file mode 100644 index 00000000000..c86632c159e --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/mod.rs @@ -0,0 +1,32 @@ +mod from_document; +pub mod v0_methods; + +use crate::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; + +use bincode::{Decode, DecodeUntrusted, Encode}; +use derive_more::Display; + +#[cfg(feature = "json-conversion")] +use crate::serialization::json_safe_fields; +#[cfg(feature = "serde-conversion")] +use serde::{Deserialize, Serialize}; + +pub use super::super::document_base_transition::IDENTIFIER_FIELDS; + +/// Purges the retained revisions of a document that has already been deleted. +/// +/// The transition carries nothing beyond the base: which chunk it removes, and +/// whether it starts or continues an erasure, are decided from the document's +/// committed lifecycle rather than from anything the submitter signs. +#[cfg_attr(feature = "json-conversion", json_safe_fields)] +#[derive(Debug, Clone, Default, Encode, Decode, PartialEq, Display, DecodeUntrusted)] +#[cfg_attr( + feature = "serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") +)] +#[display("Base: {}", "base")] +pub struct DocumentEraseTransitionV0 { + #[cfg_attr(feature = "serde-conversion", serde(flatten))] + pub base: DocumentBaseTransition, +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/v0_methods.rs new file mode 100644 index 00000000000..6265e81d824 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0/v0_methods.rs @@ -0,0 +1,17 @@ +use crate::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; +use crate::state_transition::batch_transition::document_base_transition::document_base_transition_trait::DocumentBaseTransitionAccessors; +use crate::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; + +impl DocumentBaseTransitionAccessors for DocumentEraseTransitionV0 { + fn base(&self) -> &DocumentBaseTransition { + &self.base + } + + fn base_mut(&mut self) -> &mut DocumentBaseTransition { + &mut self.base + } + + fn set_base(&mut self, base: DocumentBaseTransition) { + self.base = base + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0_methods.rs new file mode 100644 index 00000000000..df32a5641fc --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_erase_transition/v0_methods.rs @@ -0,0 +1,23 @@ +use crate::state_transition::batch_transition::batched_transition::DocumentEraseTransition; +use crate::state_transition::batch_transition::document_base_transition::document_base_transition_trait::DocumentBaseTransitionAccessors; +use crate::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; + +impl DocumentBaseTransitionAccessors for DocumentEraseTransition { + fn base(&self) -> &DocumentBaseTransition { + match self { + DocumentEraseTransition::V0(v0) => &v0.base, + } + } + + fn base_mut(&mut self) -> &mut DocumentBaseTransition { + match self { + DocumentEraseTransition::V0(v0) => &mut v0.base, + } + } + + fn set_base(&mut self, base: DocumentBaseTransition) { + match self { + DocumentEraseTransition::V0(v0) => v0.base = base, + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition.rs index cfde3c0c46f..f14bbccf4bb 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition.rs @@ -1,3 +1,4 @@ +use crate::state_transition::batch_transition::batched_transition::DocumentEraseTransition; use platform_value::{Identifier, Value}; use std::collections::BTreeMap; use derive_more::{Display, From}; @@ -62,6 +63,13 @@ pub enum DocumentTransition { /// PV14+ (see the wire gate in `validate_base_structure_v0`). #[display("IndexOnlyDeleteDocumentTransition({})", "_0")] IndexOnlyDelete(DocumentIndexOnlyDeleteTransition), + + /// The erase kind, which removes the retained revisions of a deleted + /// keep-history document — appended at the end so every existing variant + /// keeps its bincode discriminant. Only exists at protocol version 15 and + /// later (see the wire gate in `validate_base_structure_v0`). + #[display("EraseDocumentTransition({})", "_0")] + Erase(DocumentEraseTransition), } #[cfg(all(feature = "json-conversion", feature = "serde-conversion"))] @@ -79,7 +87,7 @@ impl ValueConvertible for DocumentTransition {} pub(crate) mod json_convertible_tests { use super::*; use crate::state_transition::batch_transition::batched_transition::{ - document_create_transition, document_delete_transition, + document_create_transition, document_delete_transition, document_erase_transition, document_index_only_delete_transition, document_purchase_transition, document_replace_transition, document_transfer_transition, document_update_price_transition, @@ -188,6 +196,14 @@ pub(crate) mod json_convertible_tests { "indexOnlyDelete", ); } + + #[test] + fn umbrella_erase() { + assert_umbrella_round_trip( + DocumentTransition::Erase(document_erase_transition::json_convertible_tests::fixture()), + "erase", + ); + } } impl BatchTransitionResolversV0 for DocumentTransition { @@ -230,6 +246,14 @@ impl BatchTransitionResolversV0 for DocumentTransition { } } + fn as_transition_erase(&self) -> Option<&DocumentEraseTransition> { + if let Self::Erase(ref t) = self { + Some(t) + } else { + None + } + } + fn as_transition_token_burn(&self) -> Option<&TokenBurnTransition> { None } @@ -360,6 +384,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(t) => t.base(), DocumentTransition::Purchase(t) => t.base(), DocumentTransition::IndexOnlyDelete(t) => t.base(), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(t) => t.base(), } } @@ -372,6 +399,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(_) => None, DocumentTransition::Purchase(_) => None, DocumentTransition::IndexOnlyDelete(t) => t.data().get(path), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } @@ -392,6 +422,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(_) => None, DocumentTransition::Purchase(_) => None, DocumentTransition::IndexOnlyDelete(_) => None, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } @@ -408,6 +441,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(_) => None, DocumentTransition::Purchase(_) => None, DocumentTransition::IndexOnlyDelete(t) => Some(t.data()), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } @@ -426,6 +462,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(t) => Some(t.revision()), DocumentTransition::Purchase(t) => Some(t.revision()), DocumentTransition::IndexOnlyDelete(_) => None, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } @@ -438,6 +477,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(t) => t.base().identity_contract_nonce(), DocumentTransition::Purchase(t) => t.base().identity_contract_nonce(), DocumentTransition::IndexOnlyDelete(t) => t.base().identity_contract_nonce(), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(t) => t.base().identity_contract_nonce(), } } @@ -461,6 +503,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::IndexOnlyDelete(t) => { t.data_mut().insert(property_name, value); } + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => {} } } @@ -477,6 +522,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(t) => t.base_mut(), DocumentTransition::Purchase(t) => t.base_mut(), DocumentTransition::IndexOnlyDelete(t) => t.base_mut(), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(t) => t.base_mut(), } } @@ -489,6 +537,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(_) => None, DocumentTransition::Purchase(_) => None, DocumentTransition::IndexOnlyDelete(t) => Some(t.data_mut()), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } @@ -501,6 +552,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::UpdatePrice(ref mut t) => t.set_revision(revision), DocumentTransition::Purchase(ref mut t) => t.set_revision(revision), DocumentTransition::IndexOnlyDelete(_) => {} + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => {} } } @@ -515,6 +569,9 @@ impl DocumentTransitionV0Methods for DocumentTransition { DocumentTransition::IndexOnlyDelete(t) => { t.base_mut().set_identity_contract_nonce(nonce) } + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(t) => t.base_mut().set_identity_contract_nonce(nonce), } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs index 02b5ff95f97..0bc5e1e24a8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs @@ -12,6 +12,7 @@ pub enum DocumentTransitionActionType { UpdatePrice, IgnoreWhileBumpingRevision, IndexOnlyDelete, + Erase, } pub trait DocumentTransitionActionTypeGetter { @@ -28,6 +29,9 @@ impl DocumentTransitionActionTypeGetter for DocumentTransition { DocumentTransition::UpdatePrice(_) => DocumentTransitionActionType::UpdatePrice, DocumentTransition::Purchase(_) => DocumentTransitionActionType::Purchase, DocumentTransition::IndexOnlyDelete(_) => DocumentTransitionActionType::IndexOnlyDelete, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => DocumentTransitionActionType::Erase, } } } @@ -46,6 +50,8 @@ impl TryFrom<&str> for DocumentTransitionActionType { "indexOnlyDelete" | "index_only_delete" => { Ok(DocumentTransitionActionType::IndexOnlyDelete) } + // Naming the appended kind does not admit it; released protocol bounds reject it. + "erase" => Ok(DocumentTransitionActionType::Erase), action_type => Err(ProtocolError::Generic(format!( "unknown action type {action_type}" ))), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/mod.rs index 3f193f9b005..2bee244120a 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/mod.rs @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize}; pub mod document_base_transition; pub mod document_create_transition; pub mod document_delete_transition; +pub mod document_erase_transition; pub mod document_index_only_delete_transition; pub mod document_purchase_transition; pub mod document_replace_transition; @@ -47,6 +48,7 @@ use crate::state_transition::batch_transition::batched_transition::token_transit use derive_more::Display; pub use document_create_transition::DocumentCreateTransition; pub use document_delete_transition::DocumentDeleteTransition; +pub use document_erase_transition::DocumentEraseTransition; pub use document_index_only_delete_transition::DocumentIndexOnlyDeleteTransition; pub use document_purchase_transition::DocumentPurchaseTransition; pub use document_replace_transition::DocumentReplaceTransition; @@ -92,7 +94,7 @@ impl ValueConvertible for BatchedTransition {} pub(crate) mod json_convertible_tests { use super::*; use crate::state_transition::batch_transition::batched_transition::{ - document_create_transition, token_burn_transition, + document_create_transition, document_erase_transition, token_burn_transition, }; use document_transition::DocumentTransition; use token_transition::TokenTransition; @@ -140,6 +142,13 @@ pub(crate) mod json_convertible_tests { assert_umbrella_round_trip(BatchedTransition::Document(inner), "document"); } + #[test] + fn umbrella_document_erase() { + let inner = + DocumentTransition::Erase(document_erase_transition::json_convertible_tests::fixture()); + assert_umbrella_round_trip(BatchedTransition::Document(inner), "document"); + } + #[test] fn umbrella_token() { let inner = TokenTransition::Burn(token_burn_transition::json_convertible_tests::fixture()); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/resolvers.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/resolvers.rs index 787ef54613c..353956bf146 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/resolvers.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/resolvers.rs @@ -1,5 +1,6 @@ use crate::state_transition::batch_transition::batched_transition::{ - BatchedTransition, BatchedTransitionRef, DocumentPurchaseTransition, DocumentTransferTransition, + BatchedTransition, BatchedTransitionRef, DocumentEraseTransition, DocumentPurchaseTransition, + DocumentTransferTransition, }; use crate::state_transition::batch_transition::resolvers::v0::BatchTransitionResolversV0; use crate::state_transition::batch_transition::{ @@ -49,6 +50,13 @@ impl BatchTransitionResolversV0 for BatchedTransition { } } + fn as_transition_erase(&self) -> Option<&DocumentEraseTransition> { + match self { + BatchedTransition::Document(document) => document.as_transition_erase(), + BatchedTransition::Token(_) => None, + } + } + fn as_transition_token_burn(&self) -> Option<&TokenBurnTransition> { match self { BatchedTransition::Document(_) => None, @@ -220,6 +228,13 @@ impl BatchTransitionResolversV0 for BatchedTransitionRef<'_> { } } + fn as_transition_erase(&self) -> Option<&DocumentEraseTransition> { + match self { + BatchedTransitionRef::Document(document) => document.as_transition_erase(), + BatchedTransitionRef::Token(_) => None, + } + } + fn as_transition_token_burn(&self) -> Option<&TokenBurnTransition> { match self { BatchedTransitionRef::Document(_) => None, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs index 6e31dd1f946..53e1e188c67 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs @@ -1,3 +1,4 @@ +use crate::state_transition::batch_transition::batched_transition::DocumentEraseTransition; use derive_more::{Display, From}; #[cfg(feature = "serde-conversion")] use serde::{Deserialize, Serialize}; @@ -328,6 +329,10 @@ impl BatchTransitionResolversV0 for TokenTransition { None } + fn as_transition_erase(&self) -> Option<&DocumentEraseTransition> { + None + } + fn as_transition_token_burn(&self) -> Option<&TokenBurnTransition> { if let Self::Burn(ref t) = self { Some(t) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/mod.rs index 502e3c088ca..c49e47815fe 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/mod.rs @@ -293,6 +293,62 @@ impl DocumentsBatchTransitionMethodsV0 for BatchTransition { } #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] + async fn new_document_erase_transition_from_document>( + document: Document, + document_type: DocumentTypeRef<'_>, + identity_public_key: &IdentityPublicKey, + identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, + signer: &S, + platform_version: &PlatformVersion, + options: Option, + ) -> Result { + let resolved_options = options.unwrap_or_default(); + match resolved_options.batch_feature_version.unwrap_or( + platform_version + .dpp + .state_transition_serialization_versions + .batch_state_transition + .default_current_version, + ) { + 0 => Ok( + BatchTransitionV0::new_document_erase_transition_from_document( + document, + document_type, + identity_public_key, + identity_contract_nonce, + user_fee_increase, + signer, + platform_version, + options, + ) + .await?, + ), + 1 => Ok( + BatchTransitionV1::new_document_erase_transition_from_document( + document, + document_type, + identity_public_key, + identity_contract_nonce, + user_fee_increase, + signer, + platform_version, + options, + ) + .await?, + ), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "DocumentsBatchTransition::new_document_erase_transition_from_document" + .to_string(), + known_versions: vec![0, 1], + received: version, + }), + } + } + + #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] async fn new_document_transfer_transition_from_document>( document: Document, document_type: DocumentTypeRef<'_>, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/v0/mod.rs index 8a2848898ff..a1b1d58e2e9 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/methods/v0/mod.rs @@ -70,6 +70,25 @@ pub trait DocumentsBatchTransitionMethodsV0: DocumentsBatchTransitionAccessorsV0 options: Option, ) -> Result; + /// Builds a signed erase of one already deleted keep-history document. + /// + /// The transition carries no token payment: the deletion cost was charged + /// when the document was deleted. Whether this erase starts or continues an + /// erasure, and how many revisions it removes, are read from committed + /// state rather than signed here. + #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] + async fn new_document_erase_transition_from_document>( + document: Document, + document_type: DocumentTypeRef<'_>, + identity_public_key: &IdentityPublicKey, + identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, + signer: &S, + platform_version: &PlatformVersion, + options: Option, + ) -> Result; + #[cfg(feature = "state-transition-signing")] #[allow(clippy::too_many_arguments)] async fn new_document_transfer_transition_from_document>( diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/mod.rs index 60958bdaa11..773d5305530 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/mod.rs @@ -14,7 +14,8 @@ use crate::{identity::SecurityLevel, state_transition::StateTransitionFieldTypes pub use self::batched_transition::{ document_base_transition, document_create_transition, document_create_transition::DocumentCreateTransition, document_delete_transition, - document_delete_transition::DocumentDeleteTransition, document_index_only_delete_transition, + document_delete_transition::DocumentDeleteTransition, document_erase_transition, + document_erase_transition::DocumentEraseTransition, document_index_only_delete_transition, document_index_only_delete_transition::DocumentIndexOnlyDeleteTransition, document_replace_transition, document_replace_transition::DocumentReplaceTransition, token_base_transition, token_burn_from_pool_transition, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/resolvers/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/resolvers/v0/mod.rs index a5a91272f8a..6ccbf0376b8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/resolvers/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/resolvers/v0/mod.rs @@ -1,6 +1,6 @@ use crate::state_transition::batch_transition::batched_transition::token_unfreeze_transition::TokenUnfreezeTransition; use crate::state_transition::batch_transition::batched_transition::{ - DocumentPurchaseTransition, DocumentTransferTransition, + DocumentEraseTransition, DocumentPurchaseTransition, DocumentTransferTransition, }; use crate::state_transition::batch_transition::token_direct_purchase_transition::TokenDirectPurchaseTransition; use crate::state_transition::batch_transition::{ @@ -19,6 +19,7 @@ pub trait BatchTransitionResolversV0 { fn as_transition_delete(&self) -> Option<&DocumentDeleteTransition>; fn as_transition_transfer(&self) -> Option<&DocumentTransferTransition>; fn as_transition_purchase(&self) -> Option<&DocumentPurchaseTransition>; + fn as_transition_erase(&self) -> Option<&DocumentEraseTransition>; fn as_transition_token_burn(&self) -> Option<&TokenBurnTransition>; fn as_transition_token_mint(&self) -> Option<&TokenMintTransition>; fn as_transition_token_transfer(&self) -> Option<&TokenTransferTransition>; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/tests.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/tests.rs index 7c344386196..4824b422e8d 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/tests.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/tests.rs @@ -43,7 +43,7 @@ mod batch_transition_tests { use crate::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; use crate::state_transition::batch_transition::resolvers::v0::BatchTransitionResolversV0; use crate::state_transition::batch_transition::{ - BatchTransitionV0, BatchTransitionV1, + BatchTransition, BatchTransitionV0, BatchTransitionV1, }; use crate::state_transition::StateTransitionLike; use crate::state_transition::StateTransition; @@ -1396,4 +1396,77 @@ mod batch_transition_tests { assert!(matches!(second, BatchedTransitionRef::Token(_))); assert!(iter.next().is_none()); } + + // ----------------------------------------------------------------------- + // The erase kind on the wire + // ----------------------------------------------------------------------- + + fn make_erase_transition(nonce: u64) -> DocumentTransition { + use crate::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; + use crate::state_transition::batch_transition::batched_transition::DocumentEraseTransition; + + DocumentTransition::Erase(DocumentEraseTransition::V0(DocumentEraseTransitionV0 { + base: make_base_transition(nonce), + })) + } + + /// The erase kind is appended after every shipped kind, so its bincode + /// discriminant is the next one, 7, and every earlier kind keeps its own. + /// Pinning the byte keeps a later variant reordering from silently + /// changing what old software reads. An erase and a delete over the same + /// base encode identically except for that one byte, in both shipped + /// batch formats, and the bytes decode back to an erase. + #[test] + fn should_encode_an_erase_with_the_appended_discriminant_in_both_shipped_formats() { + use crate::serialization::{PlatformDeserializableUntrusted, PlatformSerializable}; + + let delete = make_delete_transition(1); + let erase = make_erase_transition(1); + + let format_0 = + |transition: DocumentTransition| BatchTransition::V0(make_batch_v0(vec![transition])); + let format_1 = |transition: DocumentTransition| { + BatchTransition::V1(make_batch_v1(vec![BatchedTransition::Document(transition)])) + }; + + for (make, format) in [ + ( + &format_0 as &dyn Fn(DocumentTransition) -> BatchTransition, + 0u8, + ), + (&format_1, 1u8), + ] { + let delete_bytes = make(delete.clone()) + .serialize_to_bytes() + .expect("serialize"); + let erase_batch = make(erase.clone()); + let erase_bytes = erase_batch.serialize_to_bytes().expect("serialize"); + + assert_eq!(erase_bytes[0], format, "the first byte is the batch format"); + assert_eq!(erase_bytes.len(), delete_bytes.len()); + let differing: Vec = erase_bytes + .iter() + .zip(&delete_bytes) + .enumerate() + .filter(|(_, (a, b))| a != b) + .map(|(index, _)| index) + .collect(); + assert_eq!( + differing.len(), + 1, + "an erase and a delete differ only in the kind discriminant" + ); + assert_eq!(erase_bytes[differing[0]], 7, "erase is the eighth kind"); + assert_eq!(delete_bytes[differing[0]], 2, "delete is the third kind"); + + let recovered = + BatchTransition::deserialize_from_bytes_untrusted(&erase_bytes).expect("decode"); + assert_eq!(recovered, erase_batch); + assert!(recovered + .first_transition() + .expect("one transition") + .as_transition_erase() + .is_some()); + } + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs index a1d3b12da3f..0598519b417 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs @@ -23,7 +23,8 @@ use crate::state_transition::batch_transition::methods::v0::DocumentsBatchTransi use crate::state_transition::batch_transition::BatchTransitionV0; #[cfg(feature = "state-transition-signing")] use crate::state_transition::batch_transition::{ - BatchTransition, DocumentDeleteTransition, DocumentIndexOnlyDeleteTransition, + BatchTransition, DocumentDeleteTransition, DocumentEraseTransition, + DocumentIndexOnlyDeleteTransition, }; #[cfg(feature = "state-transition-signing")] use crate::data_contract::document_type::accessors::DocumentTypeV2Getters; @@ -185,6 +186,54 @@ impl DocumentsBatchTransitionMethodsV0 for BatchTransitionV0 { } #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] + async fn new_document_erase_transition_from_document>( + document: Document, + document_type: DocumentTypeRef<'_>, + identity_public_key: &IdentityPublicKey, + identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, + signer: &S, + platform_version: &PlatformVersion, + options: Option, + ) -> Result { + let owner_id = document.owner_id(); + let resolved_options = options.unwrap_or_default(); + // Erase never carries a token payment: it acts on a document whose + // deletion cost was already charged. + let erase_transition: DocumentTransition = DocumentEraseTransition::from_document( + document, + document_type, + None, + identity_contract_nonce, + resolved_options.method_feature_version, + resolved_options.base_feature_version, + platform_version, + )? + .into(); + let documents_batch_transition: BatchTransition = BatchTransitionV0 { + owner_id, + transitions: vec![erase_transition], + user_fee_increase, + signature_public_key_id: 0, + signature: Default::default(), + } + .into(); + let mut state_transition: StateTransition = documents_batch_transition.into(); + let required_security_level = document_type.security_level_requirement(); + state_transition + .sign_external_with_options( + identity_public_key, + signer, + Some(|_, _| Ok(required_security_level)), + resolved_options.signing_options, + ) + .await?; + Ok(state_transition) + } + + #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] async fn new_document_transfer_transition_from_document>( document: Document, document_type: DocumentTypeRef<'_>, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs index a27e1eddaed..16e939df171 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs @@ -28,7 +28,8 @@ use std::slice::Iter; use crate::state_transition::batch_transition::BatchTransitionV1; #[cfg(feature = "state-transition-signing")] use crate::state_transition::batch_transition::{ - BatchTransition, DocumentDeleteTransition, DocumentIndexOnlyDeleteTransition, + BatchTransition, DocumentDeleteTransition, DocumentEraseTransition, + DocumentIndexOnlyDeleteTransition, }; #[cfg(feature = "state-transition-signing")] use crate::data_contract::document_type::accessors::DocumentTypeV2Getters; @@ -261,6 +262,54 @@ impl DocumentsBatchTransitionMethodsV0 for BatchTransitionV1 { } #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] + async fn new_document_erase_transition_from_document>( + document: Document, + document_type: DocumentTypeRef<'_>, + identity_public_key: &IdentityPublicKey, + identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, + signer: &S, + platform_version: &PlatformVersion, + options: Option, + ) -> Result { + let owner_id = document.owner_id(); + let resolved_options = options.unwrap_or_default(); + // Erase never carries a token payment: it acts on a document whose + // deletion cost was already charged. + let erase_transition: DocumentTransition = DocumentEraseTransition::from_document( + document, + document_type, + None, + identity_contract_nonce, + resolved_options.method_feature_version, + resolved_options.base_feature_version, + platform_version, + )? + .into(); + let documents_batch_transition: BatchTransition = BatchTransitionV1 { + owner_id, + transitions: vec![BatchedTransition::Document(erase_transition)], + user_fee_increase, + signature_public_key_id: 0, + signature: Default::default(), + } + .into(); + let mut state_transition: StateTransition = documents_batch_transition.into(); + let required_security_level = document_type.security_level_requirement(); + state_transition + .sign_external_with_options( + identity_public_key, + signer, + Some(|_, _| Ok(required_security_level)), + resolved_options.signing_options, + ) + .await?; + Ok(state_transition) + } + + #[cfg(feature = "state-transition-signing")] + #[allow(clippy::too_many_arguments)] async fn new_document_transfer_transition_from_document>( document: Document, document_type: DocumentTypeRef<'_>, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/validation/validate_basic_structure/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/validation/validate_basic_structure/v0/mod.rs index de098140a44..07ebce43352 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/validation/validate_basic_structure/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/validation/validate_basic_structure/v0/mod.rs @@ -4,7 +4,9 @@ use crate::consensus::basic::document::{ }; use crate::consensus::basic::unsupported_version_error::UnsupportedVersionError; use crate::consensus::basic::BasicError; -use crate::state_transition::batch_transition::batched_transition::DocumentIndexOnlyDeleteTransition; +use crate::state_transition::batch_transition::batched_transition::{ + DocumentEraseTransition, DocumentIndexOnlyDeleteTransition, +}; use crate::identity::identity_nonce::MISSING_IDENTITY_REVISIONS_FILTER; use crate::state_transition::batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; @@ -173,6 +175,43 @@ impl BatchTransition { Some(_) => {} } } + + // The erase kind joined the wire at protocol version 15. Old + // software cannot decode it at all, so no historical block can + // contain one; this check exists so that new software agrees + // with old software while an earlier protocol version is still + // active: without it, an erase submitted at protocol version 14 + // would decode fine here while being undecodable on nodes that + // predate the kind. + if let DocumentTransition::Erase(erase) = transition { + let feature_version = match erase { + DocumentEraseTransition::V0(_) => 0, + }; + match &platform_version + .dpp + .state_transition_serialization_versions + .document_erase_state_transition + { + None => { + // The kind does not exist at this protocol + // version; the empty supported range (min 1, + // max 0) states exactly that. + result.add_error(BasicError::UnsupportedVersionError( + UnsupportedVersionError::new(feature_version, 1, 0), + )); + } + Some(bounds) if !bounds.bounds.check_version(feature_version) => { + result.add_error(BasicError::UnsupportedVersionError( + UnsupportedVersionError::new( + feature_version, + bounds.bounds.min_version, + bounds.bounds.max_version, + ), + )); + } + Some(_) => {} + } + } } // Make sure we don't have duplicate transitions @@ -426,6 +465,104 @@ mod tests { }) } + // ----------------------------------------------------------------------- + // erase kind wire gate + // ----------------------------------------------------------------------- + + fn make_erase(nonce: u64, id_byte: u8) -> DocumentTransition { + use crate::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; + + DocumentTransition::Erase(DocumentEraseTransition::V0(DocumentEraseTransitionV0 { + base: DocumentBaseTransition::V0(DocumentBaseTransitionV0 { + id: Identifier::new([id_byte; 32]), + identity_contract_nonce: nonce, + document_type_name: "test_doc".to_string(), + data_contract_id: Identifier::new([0xAA; 32]), + }), + })) + } + + /// Software that predates the erase kind cannot decode one at all, so no + /// historical block can contain one. The gate exists so that new software + /// agrees with old software while protocol version 14 is still active: + /// refused there, where the kind's table entry is `None`, and admitted at + /// the latest version, whose entry publishes the kind's bounds. + #[test] + fn validate_base_structure_v0_gates_erase_by_protocol_version() { + let batch = make_batch_v0(vec![make_erase(1, 1)]); + + let released = PlatformVersion::get(14).expect("protocol version 14 exists"); + assert!( + released + .dpp + .state_transition_serialization_versions + .document_erase_state_transition + .is_none(), + "the test needs a released version that publishes no erase bounds" + ); + let result = batch + .validate_base_structure_v0(released) + .expect("no protocol err"); + assert!( + result.errors.iter().any(|error| matches!( + error, + ConsensusError::BasicError(BasicError::UnsupportedVersionError(_)) + )), + "protocol version 14 must reject an erase as an unsupported version, got {:?}", + result.errors + ); + + let result = batch + .validate_base_structure_v0(PlatformVersion::latest()) + .expect("no protocol err"); + assert!( + result.is_valid(), + "the latest protocol version must admit an erase, got {:?}", + result.errors + ); + } + + /// A batch may name one document at most once, whatever the kinds: the + /// duplicate finder the structure check runs fingerprints an erase by its + /// document type and id like every other kind, so an erase of a document + /// that another transition in the batch names is reported with it. + #[test] + fn validate_base_structure_v0_treats_an_erase_of_a_named_document_as_a_duplicate() { + let erase = make_erase(1, 7); + let delete = make_delete(2, 7); + let other_document = make_create(3); + + let transitions = vec![&erase, &delete, &other_document]; + let duplicates = find_duplicates_by_id(&transitions, PlatformVersion::latest()) + .expect("no protocol err"); + + assert_eq!( + duplicates.len(), + 2, + "the erase and the delete name the same document, got {duplicates:?}" + ); + assert!(duplicates + .iter() + .any(|t| matches!(t, DocumentTransition::Erase(_)))); + } + + /// An erase in a batch is bounded like every other transition. + #[test] + fn validate_base_structure_v0_bounds_the_nonce_of_an_erase() { + let result = make_batch_v0(vec![make_erase(u64::MAX, 1)]) + .validate_base_structure_v0(PlatformVersion::latest()) + .expect("no protocol err"); + + assert!( + result.errors.iter().any(|error| matches!( + error, + ConsensusError::BasicError(BasicError::NonceOutOfBoundsError(_)) + )), + "expected NonceOutOfBoundsError, got {:?}", + result.errors + ); + } + // ----------------------------------------------------------------------- // indexOnlyDelete (delete-by-values kind) wire gate // ----------------------------------------------------------------------- diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_document_not_expired.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_document_not_expired.rs index 0b3b5a395bd..bc394f3b896 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_document_not_expired.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_document_not_expired.rs @@ -97,7 +97,9 @@ pub(crate) fn validate_document_action_not_expired( DocumentTransitionAction::UpdatePriceAction(action) => { (action.base(), action.document().created_at()) } - DocumentTransitionAction::CreateAction(_) + // Protocols through 14 reject erase at the bounds gate; erase has no live document. + DocumentTransitionAction::EraseAction(_) + | DocumentTransitionAction::CreateAction(_) | DocumentTransitionAction::DeleteAction(_) | DocumentTransitionAction::IndexOnlyDeleteAction(_) => { return Ok(SimpleConsensusValidationResult::new()); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/advanced_structure_v2/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/advanced_structure_v2/mod.rs new file mode 100644 index 00000000000..3e51bf51a1e --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/advanced_structure_v2/mod.rs @@ -0,0 +1,84 @@ +use dpp::consensus::basic::document::{InvalidDocumentTransitionActionError, InvalidDocumentTypeError}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::{DocumentTypeV0Getters, DocumentTypeV2Getters}; +use dpp::validation::SimpleConsensusValidationResult; +use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::DocumentDeleteTransitionAction; +use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::v0::DocumentDeleteTransitionActionAccessorsV0; + +use crate::error::Error; + +pub(in crate::execution::validation::state_transition::state_transitions::batch::action_validation) trait DocumentDeleteTransitionActionStructureValidationV2 { + fn validate_structure_v2(&self) -> Result; +} +impl DocumentDeleteTransitionActionStructureValidationV2 for DocumentDeleteTransitionAction { + /// From protocol 15 a keep-history type takes part in the document + /// lifecycle: a delete removes the document from ordinary reads and leaves + /// its revisions readable, so v2 no longer refuses a delete because the + /// type keeps history. What it refuses instead is a keep-history type that + /// carries a contested index, which the parser rejects for new contracts + /// but which a contract stored before protocol 15 could still declare. A + /// contested resource is awarded outside transition validation, at an id + /// derived from the winner rather than from the contested values, so that + /// award can land on an id whose retained history already exists. + fn validate_structure_v2(&self) -> Result { + let contract_fetch_info = self.base().data_contract_fetch_info(); + let data_contract = &contract_fetch_info.contract; + let document_type_name = self.base().document_type_name(); + + // Make sure that the document type is defined in the contract + let Some(document_type) = data_contract.document_type_optional_for_name(document_type_name) + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTypeError::new(document_type_name.clone(), data_contract.id()) + .into(), + )); + }; + + if !document_type.documents_can_be_deleted() { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "documents of type {} can not be deleted", + document_type_name + )) + .into(), + )); + } + + if document_type.documents_keep_history() + && document_type + .indexes() + .values() + .any(|index| index.contested_index.is_some()) + { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "documents of keep-history type {} carry a contested index and can not take \ + part in the document lifecycle", + document_type_name + )) + .into(), + )); + } + + // Pair the delete KIND with the doctype's storage mode: an + // indexOnly document has no primary-storage row a by-id delete + // could fetch, so its deletes must come as the indexOnlyDelete + // (delete-by-values) kind — its structure validation enforces the + // mirror rule. `index_only()` can only be true on a PV14+ + // contract, so this branch is unreachable for every historical + // transition. + if document_type.index_only() { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "documents of indexOnly type {} must be deleted with an indexOnlyDelete \ + (delete-by-values) transition carrying the document's values", + document_type_name + )) + .into(), + )); + } + + Ok(SimpleConsensusValidationResult::new()) + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/mod.rs index 0d872a96c59..b97b62eb975 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_delete_transition_action/mod.rs @@ -11,10 +11,12 @@ use crate::execution::validation::state_transition::batch::action_validation::do use crate::execution::validation::state_transition::batch::action_validation::document::document_delete_transition_action::state_v1::DocumentDeleteTransitionActionStateValidationV1; use crate::execution::validation::state_transition::batch::action_validation::document::document_delete_transition_action::advanced_structure_v0::DocumentDeleteTransitionActionStructureValidationV0; use crate::execution::validation::state_transition::batch::action_validation::document::document_delete_transition_action::advanced_structure_v1::DocumentDeleteTransitionActionStructureValidationV1; +use crate::execution::validation::state_transition::batch::action_validation::document::document_delete_transition_action::advanced_structure_v2::DocumentDeleteTransitionActionStructureValidationV2; use crate::platform_types::platform::PlatformStateRef; mod advanced_structure_v0; mod advanced_structure_v1; +mod advanced_structure_v2; mod state_v0; mod state_v1; @@ -49,9 +51,10 @@ impl DocumentDeleteTransitionActionValidation for DocumentDeleteTransitionAction { 0 => self.validate_structure_v0(), 1 => self.validate_structure_v1(), + 2 => self.validate_structure_v2(), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "DocumentDeleteTransitionAction::validate_structure".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0, 1, 2], received: version, })), } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/advanced_structure_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/advanced_structure_v0/mod.rs new file mode 100644 index 00000000000..da198ba0412 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/advanced_structure_v0/mod.rs @@ -0,0 +1,78 @@ +use crate::error::Error; +use dpp::consensus::basic::document::{ + InvalidDocumentTransitionActionError, InvalidDocumentTypeError, +}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::{DocumentTypeV0Getters, DocumentTypeV2Getters}; +use dpp::validation::SimpleConsensusValidationResult; +use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; + +pub(in crate::execution::validation::state_transition::state_transitions::batch::action_validation) trait DocumentEraseTransitionActionStructureValidationV0 { + fn validate_structure_v0(&self) -> Result; +} + +impl DocumentEraseTransitionActionStructureValidationV0 for DocumentEraseTransitionAction { + /// Checks what the contract alone decides: whether this type has retained + /// revisions at all, whether it allows them to be purged, and whether it is + /// one of the types the lifecycle keeps out. Whether the particular document + /// is in a state that can be erased is a question about committed state and + /// belongs to state validation. + fn validate_structure_v0(&self) -> Result { + let contract_fetch_info = self.base().data_contract_fetch_info(); + let data_contract = &contract_fetch_info.contract; + let document_type_name = self.base().document_type_name(); + + let Some(document_type) = data_contract.document_type_optional_for_name(document_type_name) + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTypeError::new(document_type_name.clone(), data_contract.id()) + .into(), + )); + }; + + if !document_type.documents_keep_history() { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "documents of type {} do not keep history and can not be erased", + document_type_name + )) + .into(), + )); + } + + if !document_type.documents_can_be_erased() { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "documents of type {} can not be erased", + document_type_name + )) + .into(), + )); + } + + // Defensive, for a contract stored before protocol 15: the parser keeps + // the two apart for every contract registered since. + if document_type + .indexes() + .values() + .any(|index| index.contested_index.is_some()) + { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "documents of keep-history type {} carry a contested index and can not take \ + part in the document lifecycle", + document_type_name + )) + .into(), + )); + } + + // Erase has no token cost of its own: the deletion it follows was paid + // for when the document was deleted. A transition that offers to pay + // one is refused where the offer is still visible, when the transition + // becomes an action. + Ok(SimpleConsensusValidationResult::new()) + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/mod.rs new file mode 100644 index 00000000000..a98788c0d28 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/mod.rs @@ -0,0 +1,94 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use crate::execution::validation::state_transition::batch::action_validation::document::document_erase_transition_action::advanced_structure_v0::DocumentEraseTransitionActionStructureValidationV0; +use crate::execution::validation::state_transition::batch::action_validation::document::document_erase_transition_action::state_v0::DocumentEraseTransitionActionStateValidationV0; +use crate::platform_types::platform::PlatformStateRef; +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::validation::SimpleConsensusValidationResult; +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; + +mod advanced_structure_v0; +mod state_v0; + +pub trait DocumentEraseTransitionActionValidation { + fn validate_structure( + &self, + platform_version: &PlatformVersion, + ) -> Result; + + fn validate_state( + &self, + platform: &PlatformStateRef, + owner_id: Identifier, + block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl DocumentEraseTransitionActionValidation for DocumentEraseTransitionAction { + fn validate_structure( + &self, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .batch_state_transition + .document_erase_transition_structure_validation + { + Some(0) => self.validate_structure_v0(), + Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "DocumentEraseTransitionAction::validate_structure".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Execution(ExecutionError::VersionNotActive { + method: "DocumentEraseTransitionAction::validate_structure".to_string(), + known_versions: vec![0], + })), + } + } + + fn validate_state( + &self, + platform: &PlatformStateRef, + owner_id: Identifier, + block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .batch_state_transition + .document_erase_transition_state_validation + { + Some(0) => self.validate_state_v0( + platform, + owner_id, + block_info, + execution_context, + transaction, + platform_version, + ), + Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "DocumentEraseTransitionAction::validate_state".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Execution(ExecutionError::VersionNotActive { + method: "DocumentEraseTransitionAction::validate_state".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/state_v0/mod.rs new file mode 100644 index 00000000000..6285f88b77c --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_erase_transition_action/state_v0/mod.rs @@ -0,0 +1,143 @@ +use crate::error::Error; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{ + StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0, +}; +use crate::execution::validation::state_transition::batch::action_validation::document::document_base_transaction_action::DocumentBaseTransitionActionValidation; +use crate::execution::validation::state_transition::batch::state::fetch_keep_history_document_lifecycle::fetch_keep_history_document_lifecycle; +use crate::platform_types::platform::PlatformStateRef; +use dpp::block::block_info::BlockInfo; +use dpp::consensus::basic::document::{ + InvalidDocumentTransitionActionError, InvalidDocumentTypeError, +}; +use dpp::consensus::state::document::document_not_found_error::DocumentNotFoundError; +use dpp::consensus::state::document::document_owner_id_mismatch_error::DocumentOwnerIdMismatchError; +use dpp::consensus::state::state_error::StateError; +use dpp::consensus::ConsensusError; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::document::DocumentV0Getters; +use dpp::identifier::Identifier; +use dpp::validation::SimpleConsensusValidationResult; +use dpp::version::PlatformVersion; +use drive::drive::document::lifecycle::DocumentLifecycleState; +use drive::grovedb::TransactionArg; +use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; + +pub(in crate::execution::validation::state_transition::state_transitions::batch::action_validation) trait DocumentEraseTransitionActionStateValidationV0 { + fn validate_state_v0( + &self, + platform: &PlatformStateRef, + owner_id: Identifier, + block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl DocumentEraseTransitionActionStateValidationV0 for DocumentEraseTransitionAction { + /// An erasure is authorized once, when it starts. + /// + /// A document that is merely deleted may only be committed to erasure by + /// its owner. Once committed, the record left in state is itself the + /// evidence that destruction was authorized, so any identity may submit the + /// remaining chunks and pay for them: an owner who loses their keys, their + /// funds or their permission can no longer strand a half-erased document. + /// A document that is still current cannot be erased at all — deleting it + /// is a separate intent, with its own permission and its own token cost. + fn validate_state_v0( + &self, + platform: &PlatformStateRef, + owner_id: Identifier, + block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let validation_result = self.base().validate_state( + platform, + owner_id, + block_info, + "erase", + execution_context, + transaction, + platform_version, + )?; + if !validation_result.is_valid() { + return Ok(validation_result); + } + + let contract_fetch_info = self.base().data_contract_fetch_info(); + let contract = &contract_fetch_info.contract; + let document_type_name = self.base().document_type_name(); + let Some(document_type) = contract.document_type_optional_for_name(document_type_name) + else { + return Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTypeError::new(document_type_name.clone(), contract.id()).into(), + )); + }; + + let lifecycle = fetch_keep_history_document_lifecycle( + platform.drive, + contract, + document_type, + self.base().id(), + &block_info.epoch, + execution_context, + transaction, + platform_version, + )?; + + // Removing revisions credits whoever paid for each of them, and those + // balance updates are applied after this transition's fee result is + // formed, against identities that had nothing to do with it. The chunk + // bound limits how many there can be; this is what pays for them. It is + // billed on every path the erase can take, including the refusals, + // because the estimate that admits the transition is formed before the + // lifecycle is known. + execution_context.add_operation(ValidationOperation::PrecalculatedOperation( + platform + .drive + .erase_refund_recipient_cost(&block_info.epoch, platform_version) + .map_err(Error::Drive)?, + )); + + match lifecycle { + DocumentLifecycleState::Active(_) => { + Ok(SimpleConsensusValidationResult::new_with_error( + InvalidDocumentTransitionActionError::new(format!( + "document {} must be deleted before it can be erased", + self.base().id() + )) + .into(), + )) + } + // The single ownership call site for an erase. + DocumentLifecycleState::Deleted(newest) => { + if newest.owner_id() != owner_id { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::StateError(StateError::DocumentOwnerIdMismatchError( + DocumentOwnerIdMismatchError::new( + self.base().id(), + owner_id, + newest.owner_id(), + ), + )), + )); + } + Ok(SimpleConsensusValidationResult::new()) + } + // A continuation of an erasure that is already committed: nothing + // to authorize, because the committed record already carries the + // authorization. + DocumentLifecycleState::Erasing => Ok(SimpleConsensusValidationResult::new()), + DocumentLifecycleState::Absent => Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::StateError(StateError::DocumentNotFoundError( + DocumentNotFoundError::new(self.base().id()), + )), + )), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/mod.rs index da2b80350ff..dd687bc7356 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/mod.rs @@ -3,6 +3,7 @@ mod document_base_transaction_action; pub(crate) use document_base_transaction_action::DocumentBaseTransitionActionValidation; pub(crate) mod document_create_transition_action; pub(crate) mod document_delete_transition_action; +pub(crate) mod document_erase_transition_action; pub(crate) mod document_index_only_delete_transition_action; pub(crate) mod document_purchase_transition_action; pub(crate) mod document_reference_validation; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v0/mod.rs index 33b6a0aa94b..73051833991 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v0/mod.rs @@ -20,11 +20,13 @@ use dpp::version::PlatformVersion; use drive::state_transition_action::batch::BatchTransitionAction; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_replace_transition_action::DocumentReplaceTransitionActionValidation; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_delete_transition_action::DocumentDeleteTransitionActionValidation; +use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_erase_transition_action::DocumentEraseTransitionActionValidation; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_index_only_delete_transition_action::DocumentIndexOnlyDeleteTransitionActionValidation; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_create_transition_action::DocumentCreateTransitionActionValidation; use dpp::state_transition::batch_transition::document_create_transition::v0::v0_methods::DocumentCreateTransitionV0Methods; use drive::state_transition_action::batch::batched_transition::BatchedTransitionAction; use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::v0::DocumentDeleteTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_index_only_delete_transition_action::v0::DocumentIndexOnlyDeleteTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_replace_transition_action::DocumentReplaceTransitionActionAccessorsV0; @@ -220,6 +222,21 @@ impl DocumentsBatchStateTransitionStructureValidationV0 for BatchTransition { )); } } + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(erase_action) => { + let result = erase_action.validate_structure(platform_version)?; + if !result.is_valid() { + let bump_action = StateTransitionAction::BumpIdentityDataContractNonceAction( + BumpIdentityDataContractNonceAction::from_borrowed_document_base_transition_action(erase_action.base(), self.owner_id(), self.user_fee_increase()), + ); + + return Ok(ConsensusValidationResult::new_with_data_and_errors( + bump_action, + result.errors, + )); + } + } DocumentTransitionAction::IndexOnlyDeleteAction(index_only_delete_action) => { let result = index_only_delete_action.validate_structure(platform_version)?; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v1/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v1/mod.rs index f9ec37005a7..54fc667cd4b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v1/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/advanced_structure/v1/mod.rs @@ -27,6 +27,7 @@ use dpp::version::PlatformVersion; use drive::state_transition_action::batch::BatchTransitionAction; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_replace_transition_action::DocumentReplaceTransitionActionValidation; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_delete_transition_action::DocumentDeleteTransitionActionValidation; +use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_erase_transition_action::DocumentEraseTransitionActionValidation; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_index_only_delete_transition_action::DocumentIndexOnlyDeleteTransitionActionValidation; use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document::document_create_transition_action::DocumentCreateTransitionActionValidation; use dpp::state_transition::batch_transition::document_create_transition::v0::v0_methods::DocumentCreateTransitionV0Methods; @@ -34,6 +35,7 @@ use drive::state_transition_action::batch::batched_transition::BatchedTransition use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_create_transition_action::DocumentCreateTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::v0::DocumentDeleteTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_index_only_delete_transition_action::v0::DocumentIndexOnlyDeleteTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_replace_transition_action::DocumentReplaceTransitionActionAccessorsV0; @@ -448,6 +450,20 @@ impl DocumentsBatchStateTransitionStructureValidationV1 for BatchTransition { )); } } + // The transition bounds admit erase only in protocols with lifecycle handlers. + DocumentTransitionAction::EraseAction(erase_action) => { + let result = erase_action.validate_structure(platform_version)?; + if !result.is_valid() { + let bump_action = StateTransitionAction::BumpIdentityDataContractNonceAction( + BumpIdentityDataContractNonceAction::from_borrowed_document_base_transition_action(erase_action.base(), self.owner_id(), self.user_fee_increase()), + ); + + return Ok(ConsensusValidationResult::new_with_data_and_errors( + bump_action, + result.errors, + )); + } + } }, BatchedTransitionAction::TokenAction(token_transition_action) => { // token actions do advanced structure validation on the base action, and a diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/fetch_keep_history_document_lifecycle/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/fetch_keep_history_document_lifecycle/mod.rs new file mode 100644 index 00000000000..28be1183fb1 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/fetch_keep_history_document_lifecycle/mod.rs @@ -0,0 +1,38 @@ +use crate::error::Error; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{ + StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0, +}; +use dpp::block::epoch::Epoch; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; +use drive::drive::document::lifecycle::DocumentLifecycleState; +use drive::drive::Drive; +use drive::grovedb::TransactionArg; + +#[allow(clippy::too_many_arguments)] +pub(crate) fn fetch_keep_history_document_lifecycle( + drive: &Drive, + contract: &DataContract, + document_type: DocumentTypeRef, + id: Identifier, + epoch: &Epoch, + execution_context: &mut StateTransitionExecutionContext, + transaction: TransactionArg, + platform_version: &PlatformVersion, +) -> Result { + let (state, fee_result) = drive + .fetch_document_lifecycle( + contract, + document_type, + id, + Some(epoch), + transaction, + platform_version, + ) + .map_err(Error::Drive)?; + execution_context.add_operation(ValidationOperation::PrecalculatedOperation(fee_result)); + Ok(state) +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/mod.rs index 4598692d1d6..2ce48c7f6c2 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/mod.rs @@ -1,3 +1,4 @@ +pub(crate) mod fetch_keep_history_document_lifecycle; pub(crate) mod v0; pub(crate) mod v1; pub(crate) mod v2; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/accepted_token_pool_nullifiers.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/accepted_token_pool_nullifiers.rs index cf927c482b2..c76b8a7d77f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/accepted_token_pool_nullifiers.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/accepted_token_pool_nullifiers.rs @@ -4,6 +4,7 @@ use dpp::shielded::SerializedAction; use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_create_transition_action::DocumentCreateTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::v0::DocumentDeleteTransitionActionAccessorsV0; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_index_only_delete_transition_action::v0::DocumentIndexOnlyDeleteTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; use drive::state_transition_action::batch::batched_transition::document_transition::document_replace_transition_action::DocumentReplaceTransitionActionAccessorsV0; @@ -79,6 +80,8 @@ impl TokenPoolNullifiers { DocumentTransitionAction::UpdatePriceAction(action) => action.base(), DocumentTransitionAction::PurchaseAction(action) => action.base(), DocumentTransitionAction::IndexOnlyDeleteAction(action) => action.base(), + // The bounds gate keeps erases out of released protocols. + DocumentTransitionAction::EraseAction(action) => action.base(), }; match (base.token_cost(), base.shielded_token_payment()) { (Some((token_id, _, _)), Some(payment)) => { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/mod.rs index 4ba8c74a7dd..dfcd6655397 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/mod.rs @@ -18,6 +18,7 @@ use crate::execution::types::state_transition_execution_context::StateTransition use crate::execution::validation::state_transition::batch::action_validation::document::document_shielded_token_payment::validate_document_shielded_token_payment; use crate::execution::validation::state_transition::batch::action_validation::document::document_create_transition_action::DocumentCreateTransitionActionValidation; use crate::execution::validation::state_transition::batch::action_validation::document::document_delete_transition_action::DocumentDeleteTransitionActionValidation; +use crate::execution::validation::state_transition::batch::action_validation::document::document_erase_transition_action::DocumentEraseTransitionActionValidation; use crate::execution::validation::state_transition::batch::action_validation::document::document_index_only_delete_transition_action::DocumentIndexOnlyDeleteTransitionActionValidation; use crate::execution::validation::state_transition::batch::action_validation::document::document_purchase_transition_action::DocumentPurchaseTransitionActionValidation; use crate::execution::validation::state_transition::batch::action_validation::document::document_replace_transition_action::DocumentReplaceTransitionActionValidation; @@ -204,6 +205,17 @@ impl DocumentsBatchStateTransitionStateValidationV0 for BatchTransition { transaction, platform_version, )?, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(erase_action) => erase_action + .validate_state( + platform, + owner_id, + block_info, + execution_context, + transaction, + platform_version, + )?, DocumentTransitionAction::IndexOnlyDeleteAction(index_only_delete_action) => { index_only_delete_action.validate_state( platform, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs index 16f3b873359..c76768a561b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs @@ -5,6 +5,9 @@ mod deletion_tests { use crate::execution::validation::state_transition::tests::create_card_game_internal_token_contract_with_owner_identity_burn_tokens; use dpp::tokens::token_payment_info::v0::TokenPaymentInfoV0; use dpp::tokens::token_payment_info::TokenPaymentInfo; + use drive::drive::document::lifecycle::DocumentLifecycleState; + use drive::drive::document::query::QueryDocumentsOutcomeV0Methods; + use drive::query::DriveDocumentQuery; #[tokio::test] async fn test_document_delete_on_document_type_that_is_mutable_and_can_be_deleted() { @@ -407,36 +410,70 @@ mod deletion_tests { assert_eq!(processing_result.aggregated_fees().processing_fee, 445700); } - /// PROTOCOL_VERSION_14 rejects deletes against contradictory keep-history - /// document types as invalid-paid consensus errors. + /// What a delete of a keep-history document does at each protocol version. + #[derive(Clone, Copy, PartialEq, Eq, Debug)] + enum KeepHistoryDeleteOutcome { + /// The released generations before protocol 14 hit the storage guard, + /// an internal error the block loop reports as such. + InternalError, + /// Protocol 14 refuses the delete as a paid consensus error. + PaidRejection, + /// Protocol 15 carries the delete out: the document leaves every + /// ordinary read and its retained revisions stay readable. + Deleted, + } + + #[tokio::test] + async fn test_document_delete_on_document_type_that_keeps_history_succeeds_protocol_version_15() + { + run_document_delete_on_document_type_that_keeps_history_at_protocol_version( + 15, + KeepHistoryDeleteOutcome::Deleted, + ) + .await; + } + + /// PROTOCOL_VERSION_14 rejects deletes against keep-history document types + /// as invalid-paid consensus errors and must keep doing so for replay. #[tokio::test] async fn test_document_delete_on_document_type_that_keeps_history_is_rejected_protocol_version_14( ) { - run_document_delete_on_document_type_that_keeps_history_at_protocol_version(14, true).await; + run_document_delete_on_document_type_that_keeps_history_at_protocol_version( + 14, + KeepHistoryDeleteOutcome::PaidRejection, + ) + .await; } /// PROTOCOL_VERSION_12 preserves the historical InternalError result for - /// replay compatibility. The keep-history structure guard must not run. + /// replay compatibility. The keep-history delete path must not run. #[tokio::test] async fn test_document_delete_on_document_type_that_keeps_history_replays_protocol_version_12() { - run_document_delete_on_document_type_that_keeps_history_at_protocol_version(12, false) - .await; + run_document_delete_on_document_type_that_keeps_history_at_protocol_version( + 12, + KeepHistoryDeleteOutcome::InternalError, + ) + .await; } #[tokio::test] async fn test_document_delete_on_document_type_that_keeps_history_replays_protocol_version_13() { - run_document_delete_on_document_type_that_keeps_history_at_protocol_version(13, false) - .await; + run_document_delete_on_document_type_that_keeps_history_at_protocol_version( + 13, + KeepHistoryDeleteOutcome::InternalError, + ) + .await; } - /// Exercises an already-deployed contradictory contract at both sides of - /// the v14 validation-version boundary. Loading with `full_validation: - /// false` is intentional: reparsing deployed contracts must remain allowed. + /// Exercises an already-deployed keep-history contract on every side of the + /// v14 and v15 validation-version boundaries. Loading with + /// `full_validation: false` is intentional: reparsing deployed contracts + /// must remain allowed. async fn run_document_delete_on_document_type_that_keeps_history_at_protocol_version( protocol_version: dpp::version::ProtocolVersion, - expect_invalid_paid: bool, + expected_outcome: KeepHistoryDeleteOutcome, ) { let platform_version = PlatformVersion::get(protocol_version) .expect("expected platform version for the requested protocol_version"); @@ -447,9 +484,9 @@ mod deletion_tests { let contract_path = "tests/supporting_files/contract/note/note-contract-keep-history-and-can-be-deleted.json"; - // `full_validation: false` bypasses the DPP cross-flag check so the - // intentionally-contradictory fixture loads — mirrors the - // already-deployed-contract scenario this guard is meant to handle. + // `full_validation: false` so the same fixture loads at every protocol + // version under test, including the released ones whose parser + // generation predates the keep-history grammar this contract uses. let note_contract = json_document_to_contract(contract_path, false, platform_version) .expect("expected to get data contract"); platform @@ -480,7 +517,7 @@ mod deletion_tests { ); assert!( note_document_type.documents_can_be_deleted(), - "fixture sanity: doctype must advertise canBeDeleted" + "fixture sanity: doctype must allow deletion" ); let entropy = Bytes32::random_with_rng(&mut rng); @@ -501,9 +538,9 @@ mod deletion_tests { let mut altered_document = document.clone(); altered_document.set_revision(Some(1)); + let deleted_document_id = altered_document.id(); - // Create the document (must succeed — keep-history doctypes accept - // creates, the contradiction only bites at delete time). + // Create the document. let documents_batch_create_transition = BatchTransition::new_document_creation_transition_from_document( document, @@ -548,8 +585,6 @@ mod deletion_tests { .unwrap() .expect("expected to commit transaction"); - // V14 rejects during structure validation; v12 and v13 retain the - // historical InternalError classification for replay. let documents_batch_deletion_transition = BatchTransition::new_document_deletion_transition_from_document( altered_document, @@ -591,13 +626,17 @@ mod deletion_tests { .unwrap() .expect("expected to commit transaction"); + assert_eq!(processing_result.invalid_unpaid_count(), 0); assert_eq!( processing_result.invalid_paid_count(), - usize::from(expect_invalid_paid), + usize::from(expected_outcome == KeepHistoryDeleteOutcome::PaidRejection), "unexpected invalid-paid classification at protocol version {protocol_version}" ); - assert_eq!(processing_result.invalid_unpaid_count(), 0); - assert_eq!(processing_result.valid_count(), 0); + assert_eq!( + processing_result.valid_count(), + usize::from(expected_outcome == KeepHistoryDeleteOutcome::Deleted), + "unexpected success classification at protocol version {protocol_version}" + ); let internal_error_count = processing_result .execution_results() .iter() @@ -605,10 +644,11 @@ mod deletion_tests { .count(); assert_eq!( internal_error_count, - usize::from(!expect_invalid_paid), + usize::from(expected_outcome == KeepHistoryDeleteOutcome::InternalError), "unexpected InternalError classification at protocol version {protocol_version}" ); - if expect_invalid_paid { + + if expected_outcome == KeepHistoryDeleteOutcome::PaidRejection { assert_matches!( processing_result.execution_results().as_slice(), [StateTransitionExecutionResult::PaidConsensusError { @@ -619,6 +659,39 @@ mod deletion_tests { }] if error.action() == "documents of type note can not be deleted" ); } + + if expected_outcome == KeepHistoryDeleteOutcome::Deleted { + // The document is gone from ordinary reads, and its retained + // revisions are not. + let documents = platform + .drive + .query_documents( + DriveDocumentQuery::all_items_query(¬e_contract, note_document_type, None), + None, + false, + None, + Some(protocol_version), + ) + .expect("expected to query documents") + .documents_owned(); + assert!( + documents.is_empty(), + "the deleted document is still visible" + ); + + let (lifecycle, _) = platform + .drive + .fetch_document_lifecycle( + ¬e_contract, + note_document_type, + deleted_document_id, + None, + None, + platform_version, + ) + .expect("expected to read the lifecycle"); + assert_matches!(lifecycle, DocumentLifecycleState::Deleted(_)); + } } #[tokio::test] diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/erase.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/erase.rs new file mode 100644 index 00000000000..92f385774ab --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/erase.rs @@ -0,0 +1,1247 @@ +//! Deleting and erasing keep-history documents through signed transitions. +//! +//! Erasure is authorized once. The document's owner commits it, and the record +//! that commitment leaves in state is what lets any identity finish the work, +//! so an owner who loses their keys, their funds or their permission cannot +//! strand a half-erased document. + +use super::*; +use crate::rpc::core::MockCoreRPCLike; +use crate::test::helpers::setup::TempPlatform; +use dpp::consensus::basic::BasicError; +use dpp::data_contract::document_type::accessors::DocumentTypeV2Getters; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::document::Document; +use dpp::identifier::Identifier; +use dpp::identity::{Identity, IdentityPublicKey, SecurityLevel}; +use dpp::prelude::IdentityNonce; +use dpp::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; +use dpp::state_transition::StateTransition; +use dpp::tokens::token_payment_info::v0::TokenPaymentInfoV0; +use dpp::tokens::token_payment_info::TokenPaymentInfo; +use dpp::version::PlatformVersion; +use dpp::ProtocolError; +use drive::drive::document::lifecycle::DocumentLifecycleState; +use drive::query::document_history_drive_query::{ + DocumentHistoryDriveQuery, DocumentHistoryFilter, DocumentHistoryState, +}; +use drive::util::storage_flags::StorageFlags; +use rand::rngs::StdRng; +use rand::SeedableRng; +use simple_signer::signer::SimpleSigner; + +const ERASABLE_CONTRACT: &str = + "tests/supporting_files/contract/note/note-contract-keep-history-erasable.json"; + +fn process( + platform: &mut TempPlatform, + serialized: Vec, +) -> StateTransitionExecutionResult { + let state = platform.state.load(); + let version = state.current_platform_version().unwrap(); + let transaction = platform.drive.grove.start_transaction(); + let result = platform + .platform + .process_raw_state_transitions( + &[serialized], + &state, + &BlockInfo::default(), + &transaction, + version, + false, + None, + ) + .expect("expected transition processing"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + assert_eq!(result.execution_results().len(), 1); + result.into_execution_results().remove(0) +} + +fn assert_successful(result: &StateTransitionExecutionResult, context: &str) { + assert_matches!( + result, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "{context}" + ); +} + +/// A platform at protocol 15 with the erasable note contract applied, one +/// identity owning a `note` document, and a second identity that owns nothing. +struct Fixture { + platform: TempPlatform, + contract: DataContract, + owner: Identity, + owner_key: IdentityPublicKey, + owner_signer: SimpleSigner, + stranger: Identity, + stranger_key: IdentityPublicKey, + stranger_signer: SimpleSigner, + document: Document, + entropy: Bytes32, + nonce: IdentityNonce, + stranger_nonce: IdentityNonce, +} + +impl Fixture { + async fn new(document_type_name: &str) -> Self { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(platform_version.protocol_version) + .build_with_mock_rpc() + .set_initial_state_structure(); + + let contract = json_document_to_contract(ERASABLE_CONTRACT, true, platform_version) + .expect("the erasable note contract must pass full validation"); + platform + .drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + platform_version, + ) + .expect("expected to apply the contract"); + + let (owner, owner_signer, owner_key) = + setup_identity(&mut platform, 1001, dash_to_credits!(1.0)); + let (stranger, stranger_signer, stranger_key) = + setup_identity(&mut platform, 1002, dash_to_credits!(1.0)); + + let mut rng = StdRng::seed_from_u64(1291); + let document_type = contract + .document_type_for_name(document_type_name) + .expect("expected the document type"); + let entropy = Bytes32::random_with_rng(&mut rng); + let mut document = document_type + .random_document_with_identifier_and_entropy( + &mut rng, + owner.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random note"); + + document + .set_id_for_creation(document_type, &entropy.0, 1, platform_version) + .expect("expected the nonce-derived document id"); + + let mut fixture = Fixture { + platform, + contract, + owner, + owner_key, + owner_signer, + stranger, + stranger_key, + stranger_signer, + document: document.clone(), + entropy, + nonce: 1, + stranger_nonce: 1, + }; + fixture.create(document, entropy, document_type_name).await; + fixture + } + + fn document_type(&self, name: &str) -> DocumentTypeRef<'_> { + self.contract + .document_type_for_name(name) + .expect("expected the document type") + } + + async fn create(&mut self, document: Document, entropy: Bytes32, document_type_name: &str) { + let platform_version = PlatformVersion::latest(); + let transition = BatchTransition::new_document_creation_transition_from_document( + document, + self.document_type(document_type_name), + entropy.0, + &self.owner_key, + self.nonce, + 0, + None, + &self.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a create transition"); + self.nonce += 1; + let result = process( + &mut self.platform, + transition.serialize_to_bytes().expect("serialized"), + ); + assert_successful(&result, "the create must succeed"); + } + + async fn delete_as_owner( + &mut self, + document_type_name: &str, + ) -> StateTransitionExecutionResult { + let platform_version = PlatformVersion::latest(); + let mut document = self.document.clone(); + document.set_revision(Some(1)); + let transition = BatchTransition::new_document_deletion_transition_from_document( + document, + self.document_type(document_type_name), + &self.owner_key, + self.nonce, + 0, + None, + &self.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a delete transition"); + self.nonce += 1; + process( + &mut self.platform, + transition.serialize_to_bytes().expect("serialized"), + ) + } + + async fn erase( + &mut self, + document_type_name: &str, + as_owner: bool, + token_payment_info: Option, + ) -> StateTransitionExecutionResult { + let platform_version = PlatformVersion::latest(); + let mut document = self.document.clone(); + document.set_revision(Some(1)); + if !as_owner { + document.set_owner_id(self.stranger.id()); + } + let transition = if let Some(token_payment_info) = token_payment_info { + // The erase factory refuses to carry token payment information, so + // a transition that does has to be built as a delete and rewritten + // into an erase, exactly as a hostile client would. + let delete = BatchTransition::new_document_deletion_transition_from_document( + document, + self.document_type(document_type_name), + &self.owner_key, + self.nonce, + 0, + Some(token_payment_info), + &self.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a delete transition to rewrite"); + self.nonce += 1; + rewrite_delete_as_erase( + delete, + &self.owner_key, + &self.owner_signer, + self.document_type(document_type_name) + .security_level_requirement(), + ) + .await + } else if as_owner { + let transition = BatchTransition::new_document_erase_transition_from_document( + document, + self.document_type(document_type_name), + &self.owner_key, + self.nonce, + 0, + &self.owner_signer, + platform_version, + None, + ) + .await + .expect("expected an erase transition"); + self.nonce += 1; + transition + } else { + let transition = BatchTransition::new_document_erase_transition_from_document( + document, + self.document_type(document_type_name), + &self.stranger_key, + self.stranger_nonce, + 0, + &self.stranger_signer, + platform_version, + None, + ) + .await + .expect("expected an erase transition"); + self.stranger_nonce += 1; + transition + }; + process( + &mut self.platform, + transition.serialize_to_bytes().expect("serialized"), + ) + } + + /// Writes revisions straight into storage so the document retains more than + /// one erase chunk can remove. How they got there does not matter to an + /// erase: it reads what the history holds. + fn retain_revisions(&mut self, document_type_name: &str, revisions: u64) { + let platform_version = PlatformVersion::latest(); + let contract = self.contract.clone(); + let document_type = contract + .document_type_for_name(document_type_name) + .expect("expected the document type"); + // The same flags the create wrote, so overwriting the current pointer + // replaces exactly as many bytes as it holds. + let flags = Some(std::borrow::Cow::Owned(StorageFlags::new_single_epoch( + 0, + Some(self.owner.id().to_buffer()), + ))); + let mut document = self.document.clone(); + for revision in 2..=revisions { + document.set_revision(Some(revision)); + self.platform + .drive + .add_document_for_contract( + drive::util::object_size_info::DocumentAndContractInfo { + owned_document_info: drive::util::object_size_info::OwnedDocumentInfo { + document_info: + drive::util::object_size_info::DocumentInfo::DocumentRefInfo(( + &document, + flags.clone(), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + true, + BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to retain a revision"); + } + } + + /// Builds an erase without processing it, so several can share one block. + async fn erase_transition(&mut self, document_type_name: &str, as_owner: bool) -> Vec { + let platform_version = PlatformVersion::latest(); + let mut document = self.document.clone(); + document.set_revision(Some(1)); + let (key, signer, nonce) = if as_owner { + let nonce = self.nonce; + self.nonce += 1; + (&self.owner_key, &self.owner_signer, nonce) + } else { + document.set_owner_id(self.stranger.id()); + let nonce = self.stranger_nonce; + self.stranger_nonce += 1; + (&self.stranger_key, &self.stranger_signer, nonce) + }; + BatchTransition::new_document_erase_transition_from_document( + document, + self.document_type(document_type_name), + key, + nonce, + 0, + signer, + platform_version, + None, + ) + .await + .expect("expected an erase transition") + .serialize_to_bytes() + .expect("serialized") + } + + fn remaining_revisions(&self, document_type_name: &str) -> u64 { + let query = DocumentHistoryDriveQuery { + contract_id: self.contract.id().to_buffer(), + document_type_name: document_type_name.to_string(), + document_id: self.document.id().to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(1), + }; + self.platform + .drive + .fetch_document_history( + &query, + self.document_type(document_type_name), + None, + PlatformVersion::latest(), + ) + .expect("expected to read the history") + .lifecycle + .expect("history carries lifecycle metadata") + .remaining_revisions + } + + fn history_state(&self, document_type_name: &str) -> DocumentHistoryState { + let query = DocumentHistoryDriveQuery { + contract_id: self.contract.id().to_buffer(), + document_type_name: document_type_name.to_string(), + document_id: self.document.id().to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(1), + }; + self.platform + .drive + .fetch_document_history( + &query, + self.document_type(document_type_name), + None, + PlatformVersion::latest(), + ) + .expect("expected to read the history") + .lifecycle + .expect("history carries lifecycle metadata") + .state + } + + fn lifecycle(&self, document_type_name: &str) -> DocumentLifecycleState { + self.platform + .drive + .fetch_document_lifecycle( + &self.contract, + self.document_type(document_type_name), + self.document.id(), + None, + None, + PlatformVersion::latest(), + ) + .expect("expected to read the lifecycle") + .0 + } +} + +/// Signs a create that deliberately claims a previously assigned id. +async fn rewrite_create_id( + transition: StateTransition, + id: Identifier, + key: &IdentityPublicKey, + signer: &SimpleSigner, + security_level: SecurityLevel, +) -> StateTransition { + use dpp::state_transition::batch_transition::batched_transition::{BatchedTransition, DocumentTransition}; + use dpp::state_transition::batch_transition::document_base_transition::document_base_transition_trait::DocumentBaseTransitionAccessors; + use dpp::state_transition::batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods; + use dpp::state_transition::batch_transition::BatchTransition; + + let StateTransition::Batch(BatchTransition::V1(mut batch)) = transition else { + panic!("expected a format 1 batch transition"); + }; + let BatchedTransition::Document(DocumentTransition::Create(create)) = &mut batch.transitions[0] + else { + panic!("expected a document create"); + }; + create.base_mut().set_id(id); + let mut rebuilt: StateTransition = BatchTransition::V1(batch).into(); + rebuilt + .sign_external( + key, + signer, + Some(|_: Identifier, _: String| Ok(security_level)), + ) + .await + .expect("expected to sign the create with its claimed id"); + rebuilt +} + +/// Rebuilds a signed batch, swapping its single delete transition for an erase +/// carrying the same base — including the token payment information an erase +/// must refuse. +async fn rewrite_delete_as_erase( + transition: StateTransition, + key: &IdentityPublicKey, + signer: &SimpleSigner, + security_level: SecurityLevel, +) -> StateTransition { + use dpp::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; + use dpp::state_transition::batch_transition::batched_transition::{ + BatchedTransition, DocumentEraseTransition, DocumentTransition, + }; + use dpp::state_transition::batch_transition::document_base_transition::document_base_transition_trait::DocumentBaseTransitionAccessors; + use dpp::state_transition::batch_transition::BatchTransition; + + let StateTransition::Batch(BatchTransition::V1(mut batch)) = transition else { + panic!("expected a format 1 batch transition"); + }; + let BatchedTransition::Document(DocumentTransition::Delete(delete)) = + batch.transitions.remove(0) + else { + panic!("expected a single document delete"); + }; + batch + .transitions + .push(BatchedTransition::Document(DocumentTransition::Erase( + DocumentEraseTransition::V0(DocumentEraseTransitionV0 { + base: delete.base().clone(), + }), + ))); + let mut rebuilt: StateTransition = BatchTransition::V1(batch).into(); + rebuilt + .sign_external( + key, + signer, + Some(|_: Identifier, _: String| Ok(security_level)), + ) + .await + .expect("expected to re-sign the rewritten batch"); + rebuilt +} + +#[tokio::test] +async fn should_delete_then_erase_a_keep_history_document() { + let mut fixture = Fixture::new("note").await; + assert_matches!(fixture.lifecycle("note"), DocumentLifecycleState::Active(_)); + + assert_successful( + &fixture.delete_as_owner("note").await, + "the delete must succeed", + ); + assert_matches!( + fixture.lifecycle("note"), + DocumentLifecycleState::Deleted(_) + ); + + assert_successful( + &fixture.erase("note", true, None).await, + "the erase must succeed", + ); + assert_matches!(fixture.lifecycle("note"), DocumentLifecycleState::Absent); +} + +/// A delete never escalates into anything that removes a revision, so asking +/// twice is a paid error rather than a second, deeper removal. +#[tokio::test] +async fn should_reject_a_second_delete_of_the_same_document() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the first delete"); + + let result = fixture.delete_as_owner("note").await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentNotFoundError(_)), + .. + } + ); +} + +/// Reusing the deleted id fails id derivation before lifecycle state is read. +#[tokio::test] +async fn should_reject_a_create_over_a_deleted_documents_id() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + let platform_version = PlatformVersion::latest(); + let document = fixture.document.clone(); + // A fresh nonce derives a different id. Force the retained id into the + // signed transition to verify consensus rejects an attempt to reuse it. + let entropy = fixture.entropy; + let transition = BatchTransition::new_document_creation_transition_from_document( + document, + fixture.document_type("note"), + entropy.0, + &fixture.owner_key, + fixture.nonce, + 0, + None, + &fixture.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a create transition"); + let transition = rewrite_create_id( + transition, + fixture.document.id(), + &fixture.owner_key, + &fixture.owner_signer, + fixture.document_type("note").security_level_requirement(), + ) + .await; + let result = process( + &mut fixture.platform, + transition.serialize_to_bytes().expect("serialized"), + ); + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::BasicError(BasicError::InvalidDocumentTransitionIdError(_)), + .. + } + ); +} + +/// Delete and erase stay two intents. Erasing a document that is still current +/// would let one signature do the work of two. +#[tokio::test] +async fn should_reject_an_erase_of_a_document_that_has_not_been_deleted() { + let mut fixture = Fixture::new("note").await; + + let result = fixture.erase("note", true, None).await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::BasicError(BasicError::InvalidDocumentTransitionActionError(_)), + .. + } + ); + assert_matches!(fixture.lifecycle("note"), DocumentLifecycleState::Active(_)); +} + +/// A type that keeps history but never opted into erasure keeps its deleted +/// documents' revisions forever. +#[tokio::test] +async fn should_reject_an_erase_of_a_type_that_did_not_ask_for_it() { + let mut fixture = Fixture::new("permanentNote").await; + assert!(!fixture + .document_type("permanentNote") + .documents_can_be_erased()); + assert_successful( + &fixture.delete_as_owner("permanentNote").await, + "the delete must still succeed", + ); + + let result = fixture.erase("permanentNote", true, None).await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::BasicError(BasicError::InvalidDocumentTransitionActionError(_)), + .. + } + ); + assert_matches!( + fixture.lifecycle("permanentNote"), + DocumentLifecycleState::Deleted(_) + ); +} + +/// Erase has no token cost of its own. Accepting one would let a continuation, +/// which any identity may submit, move somebody else's tokens. +#[tokio::test] +async fn should_reject_an_erase_that_carries_token_payment_information() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + let token_payment_info = TokenPaymentInfo::V0(TokenPaymentInfoV0 { + payment_token_contract_id: Some(Identifier::new([5u8; 32])), + token_contract_position: 0, + minimum_token_cost: None, + maximum_token_cost: Some(10), + gas_fees_paid_by: Default::default(), + }); + let result = fixture.erase("note", true, Some(token_payment_info)).await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::BasicError(BasicError::InvalidDocumentTransitionActionError(_)), + .. + } + ); + assert_matches!( + fixture.lifecycle("note"), + DocumentLifecycleState::Deleted(_) + ); +} + +/// The first erase is the authorized act, so it must come from the owner. +#[tokio::test] +async fn should_reject_an_erase_start_by_an_identity_that_does_not_own_the_document() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + let result = fixture.erase("note", false, None).await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentOwnerIdMismatchError(_)), + .. + } + ); + assert_matches!( + fixture.lifecycle("note"), + DocumentLifecycleState::Deleted(_) + ); +} + +/// A document already invisible to every read is not there to be deleted +/// again, whether or not its erasure has begun. +#[tokio::test] +async fn should_reject_a_delete_of_a_document_that_has_already_been_deleted() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + assert_successful(&fixture.erase("note", true, None).await, "the erase"); + + let result = fixture.delete_as_owner("note").await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentNotFoundError(_)), + .. + } + ); +} + +/// An erase of an id that holds nothing is not silently accepted. +#[tokio::test] +async fn should_reject_an_erase_of_an_id_that_holds_nothing() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + assert_successful(&fixture.erase("note", true, None).await, "the erase"); + + let result = fixture.erase("note", true, None).await; + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentNotFoundError(_)), + .. + } + ); +} + +/// Once an erasure is committed, the committed record is the authorization, so +/// an identity that owns nothing can finish the work. An owner who loses their +/// keys, their funds or their permission cannot strand a half-erased document. +#[tokio::test] +async fn should_let_any_identity_finish_an_erasure_its_owner_started() { + let chunk = PlatformVersion::latest() + .system_limits + .max_document_revisions_erased_per_transition + .expect("protocol 15 bounds the chunk") as u64; + + let mut fixture = Fixture::new("note").await; + fixture.retain_revisions("note", chunk + 1); + assert_eq!( + fixture.remaining_revisions("note"), + chunk + 1, + "the fixture must retain more than one chunk can remove" + ); + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + // A stranger cannot start one. + assert_matches!( + fixture.erase("note", false, None).await, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentOwnerIdMismatchError(_)), + .. + } + ); + + assert_successful( + &fixture.erase("note", true, None).await, + "the owner commits the erasure", + ); + assert_eq!(fixture.history_state("note"), DocumentHistoryState::Erasing); + + // And now the same stranger can finish it. + assert_successful( + &fixture.erase("note", false, None).await, + "a continuation needs no authorization of its own", + ); + assert_matches!(fixture.lifecycle("note"), DocumentLifecycleState::Absent); +} + +/// A document whose erasure has begun is not there to be deleted again. +#[tokio::test] +async fn should_reject_a_delete_of_a_document_whose_erasure_has_begun() { + let chunk = PlatformVersion::latest() + .system_limits + .max_document_revisions_erased_per_transition + .expect("protocol 15 bounds the chunk") as u64; + + let mut fixture = Fixture::new("note").await; + fixture.retain_revisions("note", chunk + 1); + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + assert_successful(&fixture.erase("note", true, None).await, "the erase start"); + assert_eq!(fixture.history_state("note"), DocumentHistoryState::Erasing); + + assert_matches!( + fixture.delete_as_owner("note").await, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentNotFoundError(_)), + .. + } + ); +} + +/// Two erases in one block each see the previous one's effect, because each +/// transition is applied into the block transaction before the next is +/// validated. +#[tokio::test] +async fn should_finish_an_erasure_across_two_transitions_in_one_block() { + let chunk = PlatformVersion::latest() + .system_limits + .max_document_revisions_erased_per_transition + .expect("protocol 15 bounds the chunk") as u64; + + let mut fixture = Fixture::new("note").await; + fixture.retain_revisions("note", chunk + 1); + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + let first = fixture.erase_transition("note", true).await; + let second = fixture.erase_transition("note", false).await; + + let state = fixture.platform.state.load(); + let version = state.current_platform_version().unwrap(); + let transaction = fixture.platform.drive.grove.start_transaction(); + let result = fixture + .platform + .platform + .process_raw_state_transitions( + &[first, second], + &state, + &BlockInfo::default(), + &transaction, + version, + false, + None, + ) + .expect("expected transition processing"); + fixture + .platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + + assert_eq!(result.valid_count(), 2, "both erases must execute"); + assert_matches!(fixture.lifecycle("note"), DocumentLifecycleState::Absent); +} + +/// A delete and the erase that follows it can share a block: the erase reads +/// the lifecycle record the delete has already written into the same +/// transaction. +#[tokio::test] +async fn should_delete_and_erase_in_one_block() { + let mut fixture = Fixture::new("note").await; + + let platform_version = PlatformVersion::latest(); + let mut document = fixture.document.clone(); + document.set_revision(Some(1)); + let delete = BatchTransition::new_document_deletion_transition_from_document( + document.clone(), + fixture.document_type("note"), + &fixture.owner_key, + fixture.nonce, + 0, + None, + &fixture.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a delete transition") + .serialize_to_bytes() + .expect("serialized"); + fixture.nonce += 1; + let erase = fixture.erase_transition("note", true).await; + + let state = fixture.platform.state.load(); + let version = state.current_platform_version().unwrap(); + let transaction = fixture.platform.drive.grove.start_transaction(); + let result = fixture + .platform + .platform + .process_raw_state_transitions( + &[delete, erase], + &state, + &BlockInfo::default(), + &transaction, + version, + false, + None, + ) + .expect("expected transition processing"); + fixture + .platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + + assert_eq!( + result.valid_count(), + 2, + "the erase must see the delete that shares its block" + ); + assert_matches!(fixture.lifecycle("note"), DocumentLifecycleState::Absent); +} + +/// The balance updates an erase's refunds cause land outside its own fee +/// result, against identities that had nothing to do with it. The chunk bound +/// limits how many there can be; this pins that the submitter pays for them, +/// in the estimate that admits the transition and in the fee actually charged. +#[tokio::test] +async fn should_charge_an_erase_for_the_refund_recipients_it_can_credit() { + use dpp::block::epoch::Epoch; + + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + let platform_version = PlatformVersion::latest(); + let recipient_cost = fixture + .platform + .drive + .erase_refund_recipient_cost(&Epoch::new(0).unwrap(), platform_version) + .expect("expected the recipient work to be priced"); + assert!(recipient_cost.processing_fee > 0); + + let result = fixture.erase("note", true, None).await; + let StateTransitionExecutionResult::SuccessfulExecution { + estimated_fees, + fee_result, + .. + } = result + else { + panic!("expected the erase to succeed, got {result:?}"); + }; + let estimated_fees = estimated_fees.expect("an erase is admitted against an estimate"); + + assert!( + fee_result.processing_fee >= recipient_cost.processing_fee, + "the charged fee must include the recipient work: {} is below {}", + fee_result.processing_fee, + recipient_cost.processing_fee + ); + assert!( + estimated_fees.processing_fee >= recipient_cost.processing_fee, + "so must the estimate that admits it: {} is below {}", + estimated_fees.processing_fee, + recipient_cost.processing_fee + ); +} + +/// A paid failure has to leave its nonce bump behind, or the same rejected +/// transition can be replayed for free. The refusals the lifecycle adds are no +/// exception. +#[tokio::test] +async fn should_persist_the_nonce_bump_on_a_refused_erase() { + let mut fixture = Fixture::new("note").await; + + let nonce_after = |fixture: &Fixture| { + fixture + .platform + .drive + .fetch_identity_contract_nonce( + fixture.owner.id().to_buffer(), + fixture.contract.id().to_buffer(), + true, + None, + PlatformVersion::latest(), + ) + .expect("expected to read the identity contract nonce") + .expect("the create already wrote one") + }; + let before = nonce_after(&fixture); + + // An erase of a document that has not been deleted. + assert_matches!( + fixture.erase("note", true, None).await, + StateTransitionExecutionResult::PaidConsensusError { .. } + ); + let after_refusal = nonce_after(&fixture); + assert_eq!( + after_refusal, + before + 1, + "a refused erase must still consume its nonce" + ); + + // And an erase whose token payment is refused in the transformer, which is + // a different refusal path with its own nonce-bump action. + let token_payment_info = TokenPaymentInfo::V0(TokenPaymentInfoV0 { + payment_token_contract_id: Some(Identifier::new([5u8; 32])), + token_contract_position: 0, + minimum_token_cost: None, + maximum_token_cost: Some(10), + gas_fees_paid_by: Default::default(), + }); + assert_matches!( + fixture.erase("note", true, Some(token_payment_info)).await, + StateTransitionExecutionResult::PaidConsensusError { .. } + ); + assert_eq!( + nonce_after(&fixture), + after_refusal + 1, + "the transformer's refusal must consume its nonce too" + ); +} + +/// Reusing an id within one block fails id derivation before lifecycle state is read, +/// even when the document has just been deleted. +#[tokio::test] +async fn should_reject_a_create_that_follows_a_delete_of_the_same_id_in_one_block() { + let mut fixture = Fixture::new("note").await; + + let platform_version = PlatformVersion::latest(); + let mut document = fixture.document.clone(); + document.set_revision(Some(1)); + let delete = BatchTransition::new_document_deletion_transition_from_document( + document, + fixture.document_type("note"), + &fixture.owner_key, + fixture.nonce, + 0, + None, + &fixture.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a delete transition") + .serialize_to_bytes() + .expect("serialized"); + fixture.nonce += 1; + + let create = BatchTransition::new_document_creation_transition_from_document( + fixture.document.clone(), + fixture.document_type("note"), + fixture.entropy.0, + &fixture.owner_key, + fixture.nonce, + 0, + None, + &fixture.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a create transition"); + let create = rewrite_create_id( + create, + fixture.document.id(), + &fixture.owner_key, + &fixture.owner_signer, + fixture.document_type("note").security_level_requirement(), + ) + .await + .serialize_to_bytes() + .expect("serialized"); + fixture.nonce += 1; + + let state = fixture.platform.state.load(); + let version = state.current_platform_version().unwrap(); + let transaction = fixture.platform.drive.grove.start_transaction(); + let result = fixture + .platform + .platform + .process_raw_state_transitions( + &[delete, create], + &state, + &BlockInfo::default(), + &transaction, + version, + false, + None, + ) + .expect("expected transition processing"); + fixture + .platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + + assert_eq!(result.valid_count(), 1, "only the delete may execute"); + assert_eq!(result.invalid_paid_count(), 1, "the create must be refused"); + assert_matches!( + fixture.lifecycle("note"), + DocumentLifecycleState::Deleted(_) + ); +} + +/// Replacing a deleted document is refused for the same reason a second delete +/// is: nothing an ordinary read can see is there any more. This is the existing +/// not-found path, pinned here because the lifecycle is what makes the document +/// invisible while its revisions survive. +#[tokio::test] +async fn should_reject_a_replace_of_a_deleted_document() { + let mut fixture = Fixture::new("note").await; + assert_successful(&fixture.delete_as_owner("note").await, "the delete"); + + let platform_version = PlatformVersion::latest(); + let mut replacement = fixture.document.clone(); + replacement.set_revision(Some(2)); + let transition = BatchTransition::new_document_replacement_transition_from_document( + replacement, + fixture.document_type("note"), + &fixture.owner_key, + fixture.nonce, + 0, + None, + &fixture.owner_signer, + platform_version, + None, + ) + .await + .expect("expected a replace transition"); + fixture.nonce += 1; + + let result = process( + &mut fixture.platform, + transition.serialize_to_bytes().expect("serialized"), + ); + assert_matches!( + result, + StateTransitionExecutionResult::PaidConsensusError { + error: ConsensusError::StateError(StateError::DocumentNotFoundError(_)), + .. + } + ); + assert_matches!( + fixture.lifecycle("note"), + DocumentLifecycleState::Deleted(_) + ); +} + +/// The erase kind is appended to the shipped batch, so a node that knows it +/// decodes a format 1 batch carrying one at protocol 14 as well as at 15. +/// What keeps such a node agreeing with a node that cannot decode the kind is +/// the basic-structure gate: at protocol 14, where no bounds are published for +/// the kind, the batch is refused as an unsupported version before any state +/// is read or any fee is charged. +#[tokio::test] +async fn should_refuse_an_erase_at_protocol_14_as_an_unsupported_version() { + let released = PlatformVersion::get(14).expect("protocol version 14 exists"); + assert!( + released + .dpp + .state_transition_serialization_versions + .document_erase_state_transition + .is_none(), + "the test needs a released version that publishes no erase bounds" + ); + let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(released.protocol_version) + .build_with_mock_rpc() + .set_initial_state_structure(); + + // A deployed keep-history contract, loaded the way protocol 14 loads it. + let contract = json_document_to_contract( + "tests/supporting_files/contract/note/note-contract-keep-history-and-can-be-deleted.json", + false, + released, + ) + .expect("expected the keep-history note contract"); + platform + .drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + released, + ) + .expect("expected to apply the contract"); + let (owner, signer, key) = setup_identity(&mut platform, 1003, dash_to_credits!(1.0)); + + // The transition itself can only be built by software that knows the + // kind; a protocol 14 node receives the bytes from such software. + let latest = PlatformVersion::latest(); + let document_type = contract + .document_type_for_name("note") + .expect("expected the note document type"); + let mut rng = StdRng::seed_from_u64(1303); + let entropy = Bytes32::random_with_rng(&mut rng); + let document = document_type + .random_document_with_identifier_and_entropy( + &mut rng, + owner.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + latest, + ) + .expect("expected a random note"); + let erase = BatchTransition::new_document_erase_transition_from_document( + document, + document_type, + &key, + 1, + 0, + &signer, + latest, + None, + ) + .await + .expect("expected an erase transition"); + assert_matches!( + erase, + StateTransition::Batch(dpp::state_transition::batch_transition::BatchTransition::V1(_)), + "the erase rides in the shipped batch format" + ); + + let result = process( + &mut platform, + erase.serialize_to_bytes().expect("serialized"), + ); + + assert_matches!( + result, + StateTransitionExecutionResult::UnpaidConsensusError( + dpp::consensus::ConsensusError::BasicError(BasicError::UnsupportedVersionError(_)) + ), + "protocol 14 must refuse the erase kind by its version bounds" + ); +} + +#[tokio::test] +async fn should_allow_the_new_owner_to_delete_and_erase_a_transferred_history() { + let mut fixture = Fixture::new("transferableNote").await; + let version = PlatformVersion::latest(); + let mut transferred = fixture.document.clone(); + transferred.set_revision(Some(2)); + let transition = BatchTransition::new_document_transfer_transition_from_document( + transferred, + fixture.document_type("transferableNote"), + fixture.stranger.id(), + &fixture.owner_key, + fixture.nonce, + 0, + None, + &fixture.owner_signer, + version, + None, + ) + .await + .unwrap(); + fixture.nonce += 1; + assert_successful( + &process( + &mut fixture.platform, + transition.serialize_to_bytes().unwrap(), + ), + "transfer to the new owner", + ); + assert_matches!( + fixture.delete_as_owner("transferableNote").await, + StateTransitionExecutionResult::PaidConsensusError { .. } + ); + std::mem::swap(&mut fixture.owner, &mut fixture.stranger); + std::mem::swap(&mut fixture.owner_key, &mut fixture.stranger_key); + std::mem::swap(&mut fixture.owner_signer, &mut fixture.stranger_signer); + std::mem::swap(&mut fixture.nonce, &mut fixture.stranger_nonce); + fixture.document.set_owner_id(fixture.owner.id()); + assert_successful( + &fixture.delete_as_owner("transferableNote").await, + "the current owner deletes", + ); + assert_successful( + &fixture.erase("transferableNote", true, None).await, + "the current owner erases", + ); + assert_matches!( + fixture.lifecycle("transferableNote"), + DocumentLifecycleState::Absent + ); +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/lifecycle_contracts.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/lifecycle_contracts.rs new file mode 100644 index 00000000000..3bf38fa84ae --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/lifecycle_contracts.rs @@ -0,0 +1,306 @@ +//! Signed contracts carrying a combination the lifecycle refuses. +//! +//! The parser cannot produce a `DataContract` holding one, so these build a +//! valid contract, rewrite the schema the transition carries on the wire, and +//! re-sign — which is all a hostile client has to do. What the tests pin is the +//! error category: only a consensus error becomes a paid rejection with a nonce +//! bump, while a bare data-contract error escapes as an internal execution +//! error that costs the submitter nothing. + +use super::*; +use crate::rpc::core::MockCoreRPCLike; +use crate::test::helpers::setup::TempPlatform; +use dpp::data_contract::accessors::v0::DataContractV0Setters; +use dpp::data_contract::DataContractFactory; +use dpp::identifier::Identifier; +use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; +use dpp::identity::SecurityLevel; +use dpp::platform_value::platform_value; +use dpp::prelude::IdentityNonce; +use dpp::state_transition::data_contract_create_transition::methods::DataContractCreateTransitionMethodsV0; +use dpp::state_transition::data_contract_create_transition::DataContractCreateTransition; +use dpp::state_transition::data_contract_update_transition::methods::DataContractUpdateTransitionMethodsV0; +use dpp::state_transition::data_contract_update_transition::DataContractUpdateTransition; +use dpp::state_transition::StateTransition; +use dpp::version::PlatformVersion; +use dpp::ProtocolError; +use drive::util::storage_flags::StorageFlags; + +/// A keep-history type the parser does admit, which every test below starts +/// from before rewriting the schema on the wire. +fn admissible_schema() -> Value { + platform_value!({ + "type": "object", + "documentsKeepHistory": true, + "documentsMutable": true, + "canBeDeleted": true, + "properties": { + "message": {"type": "string", "maxLength": 64, "position": 0}, + }, + "required": ["message"], + "additionalProperties": false, + }) +} + +/// Erasure asked for by a type with no history to erase. +fn erasure_without_history() -> Value { + platform_value!({ + "type": "object", + "documentsKeepHistory": false, + "documentsMutable": true, + "canBeDeleted": true, + "canBeErased": true, + "properties": { + "message": {"type": "string", "maxLength": 64, "position": 0}, + }, + "required": ["message"], + "additionalProperties": false, + }) +} + +/// A contested resource whose type also retains history. +fn contested_keep_history() -> Value { + platform_value!({ + "type": "object", + "documentsKeepHistory": true, + "documentsMutable": false, + "canBeDeleted": true, + "indices": [ + { + "name": "byMessage", + "properties": [{"message": "asc"}], + "unique": true, + "contested": { + "fieldMatches": [{"field": "message", "regexPattern": "^[a-z]{3,10}$"}], + "resolution": 0, + }, + }, + ], + "properties": { + "message": {"type": "string", "maxLength": 64, "position": 0}, + }, + "required": ["message"], + "additionalProperties": false, + }) +} + +async fn refused_create( + schema: Value, +) -> (TempPlatform, Identifier, IdentityNonce) { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(platform_version.protocol_version) + .build_with_mock_rpc() + .set_genesis_state(); + let platform_state = platform.state.load(); + let (identity, signer, key) = setup_identity(&mut platform, 4001, dash_to_credits!(10.0)); + + let contract = DataContractFactory::new(platform_version.protocol_version) + .expect("expected a contract factory") + .create_with_value_config( + identity.id(), + 1, + platform_value!({ "note": admissible_schema() }), + None, + None, + ) + .expect("the admissible type must parse") + .data_contract_owned(); + + let mut transition = DataContractCreateTransition::new_from_data_contract( + contract, + 1, + &identity.clone().into_partial_identity_info(), + key.id(), + &signer, + platform_version, + None, + ) + .await + .expect("expected a contract create transition"); + + // Rewrite the schema the wire carries; the parser refuses to build one. + let StateTransition::DataContractCreate(create) = &mut transition else { + panic!("expected a contract create"); + }; + let contract = match create { + DataContractCreateTransition::V0(create) => &mut create.data_contract, + DataContractCreateTransition::V1(create) => &mut create.data_contract, + }; + contract + .document_schemas_mut() + .expect("expected contract schemas") + .insert("note".to_string(), schema); + transition + .sign_external( + &key, + &signer, + None:: Result>, + ) + .await + .expect("expected to re-sign the rewritten contract"); + + let transaction = platform.drive.grove.start_transaction(); + let processing_result = platform + .platform + .process_raw_state_transitions( + &[transition.serialize_to_bytes().expect("serialized")], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + false, + None, + ) + .expect("expected transition processing"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + + assert_eq!( + processing_result.invalid_paid_count(), + 1, + "a refused contract must cost its submitter, not vanish into an internal error" + ); + assert_matches!( + processing_result.execution_results().as_slice(), + [StateTransitionExecutionResult::PaidConsensusError { .. }] + ); + + let nonce = platform + .drive + .fetch_identity_nonce(identity.id().to_buffer(), true, None, platform_version) + .expect("expected to read the identity nonce") + .expect("the nonce must be persisted"); + + (platform, identity.id(), nonce) +} + +#[tokio::test] +async fn should_charge_for_a_signed_contract_asking_for_erasure_without_history() { + let (_platform, _identity, nonce) = refused_create(erasure_without_history()).await; + assert_eq!( + nonce, 1, + "the refusal must persist the nonce bump, so the same transition cannot be replayed" + ); +} + +#[tokio::test] +async fn should_charge_for_a_signed_contested_keep_history_contract() { + let (_platform, _identity, nonce) = refused_create(contested_keep_history()).await; + assert_eq!(nonce, 1, "the refusal must persist the nonce bump"); +} + +/// The same refusal on the update path, which has its own error-category split. +#[tokio::test] +async fn should_charge_for_a_signed_contract_update_asking_for_erasure_without_history() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(platform_version.protocol_version) + .build_with_mock_rpc() + .set_genesis_state(); + let platform_state = platform.state.load(); + let (identity, signer, key) = setup_identity(&mut platform, 4002, dash_to_credits!(1.0)); + + let mut contract = DataContractFactory::new(platform_version.protocol_version) + .expect("expected a contract factory") + .create_with_value_config( + identity.id(), + 1, + platform_value!({ "note": admissible_schema() }), + None, + None, + ) + .expect("the admissible type must parse") + .data_contract_owned(); + platform + .drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + platform_version, + ) + .expect("expected to apply the contract"); + + let contract_id = contract.id(); + contract.set_version(2); + let mut transition = DataContractUpdateTransition::new_from_data_contract( + contract, + &identity.clone().into_partial_identity_info(), + key.id(), + 1, + 0, + &signer, + platform_version, + None, + ) + .await + .expect("expected a contract update transition"); + + let StateTransition::DataContractUpdate(DataContractUpdateTransition::V0(update)) = + &mut transition + else { + panic!("expected a v0 contract update"); + }; + update + .data_contract + .document_schemas_mut() + .expect("expected contract schemas") + .insert("note".to_string(), erasure_without_history()); + transition + .sign_external( + &key, + &signer, + None:: Result>, + ) + .await + .expect("expected to re-sign the rewritten update"); + + let transaction = platform.drive.grove.start_transaction(); + let processing_result = platform + .platform + .process_raw_state_transitions( + &[transition.serialize_to_bytes().expect("serialized")], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + false, + None, + ) + .expect("expected transition processing"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + + assert_eq!(processing_result.invalid_paid_count(), 1); + assert_matches!( + processing_result.execution_results().as_slice(), + [StateTransitionExecutionResult::PaidConsensusError { .. }] + ); + + let nonce = platform + .drive + .fetch_identity_contract_nonce( + identity.id().to_buffer(), + contract_id.to_buffer(), + true, + None, + platform_version, + ) + .expect("expected to read the identity contract nonce"); + assert_eq!( + nonce, + Some(1), + "the refusal must persist the contract nonce bump" + ); +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/mod.rs index b150f9c22c6..ff256229b6f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/mod.rs @@ -14,6 +14,7 @@ mod dpns; mod dpns_v3; mod duplicate_keys; mod encrypted_for; +mod erase; mod gas_sponsorship; mod generated_from; mod generated_from_token; @@ -22,6 +23,7 @@ mod immutable; mod immutable_conditions; mod index_only; mod keep_history; +mod lifecycle_contracts; mod list_element_reference; mod long_string_sizing; mod lookup_reference; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs index c57557938a4..8773474ce62 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs @@ -2144,10 +2144,13 @@ async fn should_preserve_single_entry_actions_errors_operations_and_settled_stat .unwrap() .into_high_level_drive_operations(&BlockInfo::default().epoch, version) .unwrap(); + // This non-history fixture cannot erase documents. Its inactive lifecycle flag is + // incidental Debug output; keep actions, charges and operations in the original pin. let validation = format!( "{validated:?}/{:?}/{operations:?}", context.operations_slice() - ); + ) + .replace(", documents_can_be_erased: false", ""); let result = process(&pool.platform, &transition); let root_after = pool .platform diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/mod.rs index 7d384fdbb43..ab2c82c3318 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/mod.rs @@ -75,6 +75,7 @@ use dpp::state_transition::batch_transition::batched_transition::document_purcha use dpp::state_transition::{StateTransitionHasUserFeeIncrease, StateTransitionOwned}; use drive::state_transition_action::batch::batched_transition::document_transition::document_create_transition_action::DocumentCreateTransitionAction; use drive::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::DocumentDeleteTransitionAction; +use drive::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; use drive::state_transition_action::batch::batched_transition::document_transition::document_index_only_delete_transition_action::DocumentIndexOnlyDeleteTransitionAction; use drive::state_transition_action::batch::batched_transition::document_transition::document_replace_transition_action::DocumentReplaceTransitionAction; use drive::state_transition_action::batch::BatchTransitionAction; @@ -1143,6 +1144,18 @@ impl BatchTransitionInternalTransformerV0 for BatchTransition { Ok(batched_action) } + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(document_erase_transition) => { + let (batched_action, fee_result) = DocumentEraseTransitionAction::try_from_document_borrowed_erase_transition_with_contract_lookup(document_erase_transition, owner_id, user_fee_increase, |_identifier| { + Ok(data_contract_fetch_info.clone()) + })?; + + execution_context + .add_operation(ValidationOperation::PrecalculatedOperation(fee_result)); + + Ok(batched_action) + } DocumentTransition::IndexOnlyDelete(document_index_only_delete_transition) => { let (batched_action, fee_result) = DocumentIndexOnlyDeleteTransitionAction::try_from_document_borrowed_index_only_delete_transition_with_contract_lookup(document_index_only_delete_transition, owner_id, user_fee_increase, |_identifier| { Ok(data_contract_fetch_info.clone()) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/property_constraint_aggregates.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/property_constraint_aggregates.rs index dd06351613b..50ab6eea4d5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/property_constraint_aggregates.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/property_constraint_aggregates.rs @@ -181,7 +181,9 @@ pub(super) fn attach_property_constraint_reads( action.set_stored_system_values(values); } } - DocumentTransitionAction::DeleteAction(_) + // The bounds gate rejects erases through protocol 14; erases write no document. + DocumentTransitionAction::EraseAction(_) + | DocumentTransitionAction::DeleteAction(_) | DocumentTransitionAction::IndexOnlyDeleteAction(_) => {} } Ok(()) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/dynamic_document_reference.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/dynamic_document_reference.rs index 2419be157d2..72ec90d8d16 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/dynamic_document_reference.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/dynamic_document_reference.rs @@ -12,7 +12,7 @@ use dpp::data_contract::document_type::DocumentReferenceKind; use drive::drive::document::paths::document_history_path; use drive::grovedb::Element; use drive::query::document_history_drive_query::{ - DocumentHistoryDriveQuery, DocumentHistoryFilter, + DocumentHistoryDriveQuery, DocumentHistoryFilter, DocumentHistoryState, }; const NOTE: &str = "note"; @@ -30,6 +30,153 @@ const REFERENCED_DOCUMENT_TYPE_NOT_FOUND: u32 = 40121; const REFERENCED_DOCUMENT_TYPE_NOT_MODERATED: u32 = 40143; const REFERENCED_DOCUMENT_TYPE_INDEX_ONLY: u32 = 40146; const REFERENCED_DOCUMENT_TYPE_REQUIREMENT_NOT_MET: u32 = 40153; +const REFERENCED_DOCUMENT_TYPE_DELETABLE: u32 = 40122; + +/// Retained revisions never satisfy an existence reference after deletion. Both dynamic +/// kind declarations refuse the deletable type before looking for its document. +#[tokio::test] +async fn should_resolve_history_reference_targets_by_current_existence_and_kind() { + let version = PlatformVersion::latest(); + let setup = Setup::new_at_with(None, version, |contract| { + let mut target = plain_schema(); + for keyword in [ + "documentsKeepHistory", + "documentsMutable", + "canBeDeleted", + "canBeErased", + ] { + target.insert(keyword.into(), true.into()).unwrap(); + } + add_document_type(contract, POST, target); + let mut schema = note_schema(text_or_bytes()); + schema + .get_mut("properties") + .unwrap() + .unwrap() + .get_mut("descriptionId") + .unwrap() + .unwrap() + .insert( + "refersTo".into(), + platform_value!({ + "type": "deletableDocument", + "documentType": POST, + }), + ) + .unwrap(); + add_document_type(contract, NOTE, schema); + add_document_type(contract, PERMANENT_NOTE, permanent_note_schema()); + add_document_type( + contract, + EITHER_NOTE, + note_schema_of( + platform_value!(["permanentDocument", "moderatedDocument"]), + text_or_bytes(), + ), + ); + }) + .await; + let transaction = setup.platform.drive.grove.start_transaction(); + let (mut post, create_post) = + create_with(&setup, &setup.user, POST, vec![("text", "retained".into())]).await; + assert_success(&setup.process(&create_post, &transaction)); + let chunk = version + .system_limits + .max_document_revisions_erased_per_transition + .unwrap(); + for _ in 0..chunk { + let replace = replacement(&setup.user, &setup.contract, POST, &mut post).await; + assert_success(&setup.process(&replace, &transaction)); + } + let document_type = setup.contract.document_type_for_name(POST).unwrap(); + for (state, remaining) in [ + (DocumentHistoryState::Active, u64::from(chunk) + 1), + (DocumentHistoryState::Deleted, u64::from(chunk) + 1), + (DocumentHistoryState::Erasing, 1), + (DocumentHistoryState::Absent, 0), + ] { + match state { + DocumentHistoryState::Active => {} + DocumentHistoryState::Deleted => { + let deletion = BatchTransition::new_document_deletion_transition_from_document( + post.clone(), + document_type, + &setup.user.key, + setup.user.contract_nonce(), + 0, + None, + &setup.user.signer, + version, + None, + ) + .await + .unwrap(); + assert_success(&setup.process(&deletion, &transaction)); + } + DocumentHistoryState::Erasing | DocumentHistoryState::Absent => { + let erase = BatchTransition::new_document_erase_transition_from_document( + post.clone(), + document_type, + &setup.user.key, + setup.user.contract_nonce(), + 0, + &setup.user.signer, + version, + None, + ) + .await + .unwrap(); + assert_success(&setup.process(&erase, &transaction)); + } + } + let history = setup + .platform + .drive + .fetch_document_history( + &DocumentHistoryDriveQuery { + contract_id: setup.contract.id().to_buffer(), + document_type_name: POST.into(), + document_id: post.id().to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: None, + }, + document_type, + Some(&transaction), + version, + ) + .unwrap(); + let lifecycle = history.lifecycle.unwrap(); + assert_eq!(lifecycle.state, state); + assert_eq!(lifecycle.remaining_revisions, remaining); + + let (_, reference) = create_with( + &setup, + &setup.stranger, + NOTE, + note_naming(setup.contract.id(), POST, post.id()), + ) + .await; + let result = setup.process(&reference, &transaction); + if state == DocumentHistoryState::Active { + assert_success(&result); + } else { + assert_paid_with_code(&result, REFERENCED_ENTITY_NOT_FOUND); + } + for dynamic_type in [PERMANENT_NOTE, EITHER_NOTE] { + let (_, dynamic) = create_with( + &setup, + &setup.stranger, + dynamic_type, + note_naming(setup.contract.id(), POST, post.id()), + ) + .await; + assert_paid_with_code( + &setup.process(&dynamic, &transaction), + REFERENCED_DOCUMENT_TYPE_DELETABLE, + ); + } + } +} fn id_value(id: Identifier) -> Value { Value::Identifier(id.to_buffer()) diff --git a/packages/rs-drive-abci/src/query/document_history/v1/mod.rs b/packages/rs-drive-abci/src/query/document_history/v1/mod.rs index a6511221ea0..4b0aca47628 100644 --- a/packages/rs-drive-abci/src/query/document_history/v1/mod.rs +++ b/packages/rs-drive-abci/src/query/document_history/v1/mod.rs @@ -143,8 +143,14 @@ impl Platform { state: match lifecycle.state { DocumentHistoryState::Active => State::Active, DocumentHistoryState::Absent => State::Absent, + DocumentHistoryState::Deleted => State::Deleted, + DocumentHistoryState::Erasing => State::Erasing, } as i32, remaining_revisions: lifecycle.remaining_revisions, + deleted_at_ms: lifecycle.times.deleted_at_ms, + erasing_started_at_ms: lifecycle.times.erasing_started_at_ms, + erasing_from_time_ms: lifecycle.times.erasing_from_time_ms, + erasing_from_revision: lifecycle.times.erasing_from_revision, }), }) }; diff --git a/packages/rs-drive-abci/src/query/document_history/v1/tests.rs b/packages/rs-drive-abci/src/query/document_history/v1/tests.rs index f5bf584c998..d42720cb744 100644 --- a/packages/rs-drive-abci/src/query/document_history/v1/tests.rs +++ b/packages/rs-drive-abci/src/query/document_history/v1/tests.rs @@ -584,6 +584,8 @@ fn history_api_proof_round_trip(gapped: bool) { match expected_lifecycle.state { DocumentHistoryState::Active => State::Active, DocumentHistoryState::Absent => State::Absent, + DocumentHistoryState::Deleted => State::Deleted, + DocumentHistoryState::Erasing => State::Erasing, } as i32 ); let mut legacy = response.clone(); @@ -630,3 +632,239 @@ fn should_reject_missing_selectors_before_reading_state() { .unwrap() .is_valid()); } + +#[test] +fn should_derive_deleted_and_erasing_lifecycle_from_the_proof() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let mut state = state.as_ref().clone(); + let contract = json_document_to_contract( + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../rs-drive/tests/supporting_files/contract/dashpay/dashpay-contract-with-profile-history.json" + ), + false, + version, + ) + .unwrap(); + platform + .drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let document_type = contract.document_type_for_name("profile").unwrap(); + let owner = Identifier::from([8; 32]); + let mut document = json_document_to_document( + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../rs-drive/tests/supporting_files/contract/dashpay/profile0.json" + ), + Some(owner), + document_type, + version, + ) + .unwrap(); + let chunk = version + .system_limits + .max_document_revisions_erased_per_transition + .expect("protocol 15 bounds the erase chunk") as u64; + for revision in 1..=chunk + 2 { + document.set_revision(Some(revision)); + platform + .drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + revision > 1, + BlockInfo::default_with_time(1_000 + revision), + true, + None, + version, + ) + .unwrap(); + } + + let key = SecretKey::from_be_bytes(&[1; 32]).unwrap(); + let provider = Provider { + contract: Arc::new(contract.clone()), + key: key.public_key().to_bytes().try_into().unwrap(), + }; + state.last_committed_block_info = Some( + dpp::block::extended_block_info::v0::ExtendedBlockInfoV0 { + basic_info: BlockInfo { + height: 42, + core_height: 12, + time_ms: 3_000, + epoch: Default::default(), + }, + app_hash: [0; 32], + quorum_hash: [9; 32], + block_id_hash: [7; 32], + proposer_pro_tx_hash: [0; 32], + signature: [0; 96], + round: 0, + } + .into(), + ); + let wire_request = GetDocumentHistoryRequestV1 { + data_contract_id: contract.id().to_vec(), + document_type_name: "profile".into(), + document_id: document.id().to_vec(), + limit: None, + prove: true, + filter: Some(Filter::StartAtMs(0)), + }; + let request: GetDocumentHistoryRequest = wire_request.clone().into(); + + for (stage, expected_state) in [ + ("deleted", DocumentHistoryState::Deleted), + ("erasing", DocumentHistoryState::Erasing), + ] { + let operations = if stage == "deleted" { + platform + .drive + .delete_document_for_contract_operations( + document.id(), + &contract, + document_type, + &BlockInfo::default_with_time(5_000), + Some(owner), + None, + &mut None, + None, + version, + ) + .unwrap() + } else { + platform + .drive + .erase_document_for_contract_operations( + document.id(), + &contract, + document_type, + &BlockInfo::default_with_time(6_000), + &mut None, + None, + version, + ) + .unwrap() + }; + platform + .drive + .apply_batch_low_level_drive_operations( + None, + None, + operations, + &mut vec![], + &version.drive, + ) + .unwrap(); + + let root = platform + .drive + .grove + .root_hash(None, &version.drive.grove_version) + .value + .unwrap(); + let metadata = platform.response_metadata_v0(&state, CheckpointUsed::Current); + let signed = signed_proof( + vec![], + root, + &metadata, + &key, + platform.config.validator_set.quorum_type as u32, + ); + let committed = state.last_committed_block_info.as_mut().unwrap(); + committed.set_app_hash(root); + committed.set_signature(signed.signature.try_into().unwrap()); + + let response = platform + .query_document_history_v1(wire_request.clone(), &state, version) + .unwrap() + .into_data() + .unwrap(); + // A proved response carries the proof and nothing else: there are no + // lifecycle fields on the wire for a client to trust, so every value + // the verifier returns below is derived from the proof itself. + assert!( + matches!(response.result, Some(ResponseResult::Proof(_))), + "{stage}: a proved response must not carry lifecycle claims" + ); + let verify = |response: GetDocumentHistoryResponseV1| { + DocumentHistory::maybe_from_proof( + request.clone(), + GetDocumentHistoryResponse::from(response), + Network::Testnet, + version, + &provider, + ) + }; + let history = verify(response.clone()) + .unwrap_or_else(|error| panic!("{stage}: honest response must verify: {error}")) + .expect("the proof authenticates a history"); + let lifecycle = history + .lifecycle + .expect("the proof authenticates the lifecycle"); + assert_eq!(lifecycle.state, expected_state, "{stage}"); + assert_eq!(lifecycle.times.deleted_at_ms, 5_000, "{stage}"); + + assert_eq!( + lifecycle.remaining_revisions, + if stage == "deleted" { chunk + 2 } else { 2 } + ); + assert_eq!( + lifecycle.times.erasing_started_at_ms, + if stage == "erasing" { 6_000 } else { 0 } + ); + assert_eq!( + lifecycle.times.erasing_from_time_ms, + if stage == "erasing" { + 1_000 + chunk + 2 + } else { + 0 + } + ); + assert_eq!( + lifecycle.times.erasing_from_revision, + if stage == "erasing" { chunk + 2 } else { 0 } + ); + let mut plain_request = wire_request.clone(); + plain_request.prove = false; + let plain = platform + .query_document_history_v1(plain_request, &state, version) + .unwrap() + .into_data() + .unwrap(); + let Some(ResponseResult::History(plain)) = plain.result else { + panic!("an unproved response carries history"); + }; + let plain = plain.lifecycle.unwrap(); + assert_eq!(plain.remaining_revisions, lifecycle.remaining_revisions); + assert_eq!(plain.deleted_at_ms, lifecycle.times.deleted_at_ms); + assert_eq!( + plain.erasing_started_at_ms, + lifecycle.times.erasing_started_at_ms + ); + assert_eq!( + plain.erasing_from_time_ms, + lifecycle.times.erasing_from_time_ms + ); + assert_eq!( + plain.erasing_from_revision, + lifecycle.times.erasing_from_revision + ); + + let mut tampered = response; + let proof = proof_mut(&mut tampered); + let middle = proof.grovedb_proof.len() / 2; + proof.grovedb_proof[middle] ^= 1; + assert!( + verify(tampered).is_err(), + "{stage}: changing the proof that authenticates lifecycle must be rejected" + ); + } +} diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 73f294ec144..a453edaf64a 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -649,6 +649,14 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( // we expect no document assert!(document.is_none()); } + DocumentTransitionAction::EraseAction(_) => { + // An erase acts on a document that was + // already deleted, so the by-id query this + // harness proves against returns nothing + // whether or not the erase executed; + // strategies do not generate erases today. + assert!(document.is_none()); + } DocumentTransitionAction::IndexOnlyDeleteAction(_) => { // indexOnly documents never have a // primary-storage row, so the by-id query diff --git a/packages/rs-drive-abci/tests/supporting_files/contract/note/note-contract-keep-history-erasable.json b/packages/rs-drive-abci/tests/supporting_files/contract/note/note-contract-keep-history-erasable.json new file mode 100644 index 00000000000..6c5816fe4ff --- /dev/null +++ b/packages/rs-drive-abci/tests/supporting_files/contract/note/note-contract-keep-history-erasable.json @@ -0,0 +1,68 @@ +{ + "$formatVersion": "1", + "id": "5Bqs6itzfoDXzmgQibYZQABbqYsXmawVf7SKe3mKDQVf", + "ownerId": "2b994p95akyNFKtkDnDvBRUotDbkH54MHwGbhQLr5gcU", + "version": 1, + "keywords": [], + "documentSchemas": { + "note": { + "type": "object", + "documentsKeepHistory": true, + "documentsMutable": true, + "canBeDeleted": true, + "canBeErased": true, + "properties": { + "message": { + "type": "string", + "maxLength": 256, + "position": 0 + } + }, + "required": [ + "message" + ], + "additionalProperties": false, + "$comment": "A keep-history type whose deleted documents may also have their retained revisions purged. Deleting a note removes it from ordinary reads and leaves its revisions readable; erasing removes those revisions a bounded chunk at a time." + }, + "permanentNote": { + "type": "object", + "documentsKeepHistory": true, + "documentsMutable": true, + "canBeDeleted": true, + "properties": { + "message": { + "type": "string", + "maxLength": 256, + "position": 0 + } + }, + "required": [ + "message" + ], + "additionalProperties": false, + "$comment": "The same type without canBeErased: its deleted documents keep their revisions forever, which is what the erase refusal is checked against." + }, + "transferableNote": { + "type": "object", + "documentsKeepHistory": true, + "documentsMutable": true, + "canBeDeleted": true, + "canBeErased": true, + "properties": { + "message": { + "type": "string", + "maxLength": 256, + "position": 0 + } + }, + "required": [ + "message" + ], + "additionalProperties": false, + "$comment": "A keep-history type whose deleted documents may also have their retained revisions purged. Deleting a note removes it from ordinary reads and leaves its revisions readable; erasing removes those revisions a bounded chunk at a time.", + "transferable": 1 + } + }, + "groups": {}, + "tokens": {} +} diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index b0e9db5857a..9a0bc8bfad3 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -126,7 +126,8 @@ pub type RetrievedValues = IndexMap; /// Contains a map of data contract revisions to data contracts. pub type DataContractHistory = RetrievedValues; pub use drive::query::document_history_drive_query::{ - DocumentHistoryEntry, DocumentHistoryLifecycle, DocumentHistoryState, + DocumentHistoryEntry, DocumentHistoryLifecycle, DocumentHistoryLifecycleTimes, + DocumentHistoryState, }; /// Ordered document revisions with lifecycle metadata when the storage layout supports it. diff --git a/packages/rs-drive/grovedb-structure.json b/packages/rs-drive/grovedb-structure.json index 6d41d119842..3319a196895 100644 --- a/packages/rs-drive/grovedb-structure.json +++ b/packages/rs-drive/grovedb-structure.json @@ -3120,6 +3120,51 @@ } ] }, + { + "id": "contracts.contract.documents.document_type.lifecycle", + "key": { + "type": "fixed", + "hex": "01", + "label": "Lifecycle", + "constant": "DOCUMENT_LIFECYCLE_TREE_KEY" + }, + "kinds": [ + "Tree" + ], + "since": 15, + "presence": "lazy", + "source": "packages/rs-drive/src/drive/document/paths.rs", + "description": "An unflagged normal tree of lifecycle records for a type that keeps history. Created on the first delete and retained after all records are erased.", + "children": [ + { + "id": "contracts.contract.documents.document_type.lifecycle.record", + "key": { + "type": "dynamic", + "name": "document_id", + "matcher": { + "type": "len", + "len": 32 + }, + "encoding": "identifier32", + "description": "The deleted document id" + }, + "kinds": [ + "Item" + ], + "flags": [ + "EpochOwned", + "None" + ], + "flags_note": "The deletion's storage payer, including its gas sponsor when sponsored; no flags when the caller supplies no payer. Erase refunds the record's stored flag owner.", + "value": "versioned DPP DocumentLifecycleRecord", + "since": 15, + "presence": "lazy", + "source": "packages/rs-dpp/src/document/lifecycle/mod.rs", + "description": "One document's lifecycle record, present while Deleted or Erasing. The terminal erase removes it together with the remaining history.", + "children": [] + } + ] + }, { "id": "contracts.contract.documents.document_type.history", "key": { diff --git a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/batched_group_drain.rs b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/batched_group_drain.rs index f5267ce3fc1..8f985b8dead 100644 --- a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/batched_group_drain.rs +++ b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/batched_group_drain.rs @@ -177,6 +177,7 @@ fn delete_op<'a>( ) -> DriveOperation<'a> { DriveOperation::DocumentOperation(DocumentOperationType::DeleteDocument { document_id, + deleter_id: None, contract_info: DataContractInfo::BorrowedDataContract(contract), document_type_info: DocumentTypeInfo::DocumentTypeNameAsStr(doctype), }) diff --git a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/sibling_null_flags_e2e_tests.rs b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/sibling_null_flags_e2e_tests.rs index 96d601ea5e6..0cee5354537 100644 --- a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/sibling_null_flags_e2e_tests.rs +++ b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/sibling_null_flags_e2e_tests.rs @@ -103,9 +103,10 @@ fn delete_operations( contract .document_type_for_name(doctype) .expect("doctype exists"), + &BlockInfo::default(), + None, None, &mut None, - 0, None, platform_version(), ) diff --git a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/summable_off_count_index_e2e_tests.rs b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/summable_off_count_index_e2e_tests.rs index aea10881f8a..01c4678edd2 100644 --- a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/summable_off_count_index_e2e_tests.rs +++ b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/summable_off_count_index_e2e_tests.rs @@ -66,6 +66,7 @@ use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters}; use dpp::platform_value::{Identifier, Value}; use dpp::prelude::DataContract; use dpp::tests::json_document::json_document_to_json_value; +use dpp::version::PlatformVersion; use grovedb::element::indexed::compute_avg_fixed_point; use grovedb::element::IndexAxis; use grovedb::Element; @@ -1094,9 +1095,8 @@ fn should_refuse_a_batch_writing_two_likes_of_a_type_keeping_counters() { assert!(matches!(counter, Element::SumItem(1, _)), "got {counter:?}"); } -/// Both generations of the batch conversion through its dispatcher: v1 -/// (protocol version 14) refuses a batch writing two likes, while v0, every -/// earlier version's, converts it as it always has. +/// Counter-checking converters, selected from protocol version 14, refuse two +/// likes in one batch; generation 0 converts them as it always has. #[test] fn should_refuse_two_likes_only_from_the_convert_generation_that_checks_counter_moves() { let (drive, contract) = setup(true); @@ -1112,19 +1112,22 @@ fn should_refuse_two_likes_only_from_the_convert_generation_that_checks_counter_ .collect::>() }; let latest = platform_version(); - let refused = drive.convert_drive_operations_to_grove_operations( - operations(), - &BlockInfo::default(), - None, - latest, - ); - assert!( - matches!( - refused, - Err(Error::Drive(DriveError::CorruptedCodeExecution(_))) - ), - "v1 refuses the batch" - ); + for version in [PlatformVersion::get(14).unwrap(), latest] { + let refused = drive.convert_drive_operations_to_grove_operations( + operations(), + &BlockInfo::default(), + None, + version, + ); + assert!( + matches!( + refused, + Err(Error::Drive(DriveError::CorruptedCodeExecution(_))) + ), + "counter-checking converters refuse the batch at protocol {}", + version.protocol_version + ); + } let mut first_generation = latest.clone(); first_generation .drive diff --git a/packages/rs-drive/src/drive/contract/moderation/document_removal_tests.rs b/packages/rs-drive/src/drive/contract/moderation/document_removal_tests.rs index 707820cb23c..813bc4777fc 100644 --- a/packages/rs-drive/src/drive/contract/moderation/document_removal_tests.rs +++ b/packages/rs-drive/src/drive/contract/moderation/document_removal_tests.rs @@ -936,6 +936,7 @@ fn add_post( fn delete_post<'a>(contract: &'a DataContract, document_id: Identifier) -> DriveOperation<'a> { DocumentOperation(DocumentOperationType::DeleteDocument { document_id, + deleter_id: None, contract_info: DataContractInfo::BorrowedDataContract(contract), document_type_info: DocumentTypeInfo::DocumentTypeName(POST.to_string()), }) diff --git a/packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs b/packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs index 8488cac9fe0..0606bf81560 100644 --- a/packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs @@ -138,9 +138,10 @@ impl Drive { *doc_id, &contract, document_type, + block_info, + None, None, estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, platform_version, )?); diff --git a/packages/rs-drive/src/drive/document/cost/mod.rs b/packages/rs-drive/src/drive/document/cost/mod.rs index 3912f95fc35..f00fb18dcf1 100644 --- a/packages/rs-drive/src/drive/document/cost/mod.rs +++ b/packages/rs-drive/src/drive/document/cost/mod.rs @@ -363,7 +363,15 @@ pub fn document_create_cost( let refundable = if document_type.documents_ttl_seconds().is_some() { Scenarios::default() } else { - refundable_bytes(&writes, &known, &elements) + let retains_history = document_type.documents_keep_history() + && platform_version + .drive + .methods + .document + .delete + .delete_document_for_contract_operations + >= 1; + refundable_bytes(&writes, &known, &elements, retains_history) }; let refund_same_epoch = refund(document_type, refundable, credits_per_byte, 0)?; let refund_after_one_year = refund( @@ -404,7 +412,8 @@ fn check_mirrored_method_versions(platform_version: &PlatformVersion) -> Result< for (method, known, received) in [ ( "add_document_for_contract_operations", - &[1][..], + // Generation 2 reserves retained ids without adding operations to a fresh create. + &[1, 2][..], document.insert.add_document_for_contract_operations, ), ( @@ -566,11 +575,25 @@ fn written_when_values_known(writes: &[Write], document_id: &[u8]) -> Vec /// The storage bytes a delete refunds: those of the elements it removes that /// carry the owner's flags. Not refunded: elements without flags (a ranked /// tree's rows, trees an index writes without flags), ephemeral elements, -/// and preallocated trees, which a delete keeps. -fn refundable_bytes(writes: &[Write], known: &[bool], elements: &[ElementCost]) -> Scenarios { +/// and preallocated trees, which a delete keeps. A lifecycle delete also keeps +/// the retained revisions and their per-document history tree until erasure. +fn refundable_bytes( + writes: &[Write], + known: &[bool], + elements: &[ElementCost], + retains_history: bool, +) -> Scenarios { let mut total = Scenarios::default(); for ((write, known), element) in writes.iter().zip(known).zip(elements) { - if write.flagged && !write.ephemeral && write.referring_type.is_none() { + if write.flagged + && !write.ephemeral + && write.referring_type.is_none() + && !(retains_history + && matches!( + write.role, + LayoutRole::DocumentHistory | LayoutRole::RetainedRevision + )) + { total.add(Scenarios { new_values: element.bytes, known_values: if *known { element.bytes } else { 0 }, diff --git a/packages/rs-drive/src/drive/document/cost/tests.rs b/packages/rs-drive/src/drive/document/cost/tests.rs index 39b660990a6..f3f35818824 100644 --- a/packages/rs-drive/src/drive/document/cost/tests.rs +++ b/packages/rs-drive/src/drive/document/cost/tests.rs @@ -14,6 +14,7 @@ use crate::util::storage_flags::StorageFlags; use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; use crate::util::test_helpers::setup_contract; use dpp::block::block_info::BlockInfo; +use dpp::block::epoch::Epoch; use dpp::data_contract::document_type::random_document::CreateRandomDocument; use dpp::data_contract::DataContractFactory; use dpp::document::document_methods::DocumentMethodsV0; @@ -60,6 +61,24 @@ fn insert_at( document_type: DocumentTypeRef, document: &Document, time_ms: u64, +) -> Result { + insert_at_version( + drive, + contract, + document_type, + document, + time_ms, + PlatformVersion::latest(), + ) +} + +fn insert_at_version( + drive: &Drive, + contract: &DataContract, + document_type: DocumentTypeRef, + document: &Document, + time_ms: u64, + platform_version: &PlatformVersion, ) -> Result { let flags = StorageFlags::new_single_epoch(0, Some(document.owner_id().to_buffer())); drive.add_document_for_contract( @@ -75,7 +94,7 @@ fn insert_at( BlockInfo::default_with_time(time_ms), true, None, - PlatformVersion::latest(), + platform_version, ) } @@ -451,6 +470,312 @@ fn note_document(contract: &DataContract) -> Document { document } +#[test] +fn should_price_fresh_creates_with_the_lifecycle_insert_generation() { + let version = PlatformVersion::latest(); + let mut previous = version.clone(); + previous + .drive + .methods + .document + .insert + .add_document_for_contract_operations = 1; + let mut unsupported = version.clone(); + unsupported + .drive + .methods + .document + .insert + .add_document_for_contract_operations = 3; + assert!(matches!( + check_mirrored_method_versions(&unsupported), + Err(Error::Drive(DriveError::UnknownVersionMismatch { + received: 3, + .. + })) + )); + + let mut unsupported_costs = Vec::new(); + for case in ["ordinary", "history", "ttl", "derived"] { + let mut schema = note_schema(); + match case { + "history" => schema + .insert("documentsKeepHistory".into(), true.into()) + .unwrap(), + "ttl" => { + schema.insert("ttl".into(), 86_400u32.into()).unwrap(); + schema + .insert( + "required".into(), + platform_value!(["$createdAt", "tag", "code", "text"]), + ) + .unwrap(); + } + "derived" => { + schema = platform_value!({ + "type": "object", "documentsMutable": false, "canBeDeleted": true, + "properties": { + "quoteId": { + "type": "array", "byteArray": true, + "minItems": 32, "maxItems": 32, + "contentMediaType": "application/x.dash.dpp.identifier", + "refersTo": {"type": "permanentDocument", "documentType": "post"}, + "position": 0 + } + }, + "indices": [{"name": "byQuotedOwner", "properties": [{"quoteId.$ownerId": "asc"}]}], + "required": ["quoteId"], "additionalProperties": false + }); + } + _ => {} + } + let contract = contract_with(platform_value!({ + "note": schema, + "post": { + "type": "object", "documentsMutable": false, "canBeDeleted": false, + "properties": {"title": {"type": "string", "maxLength": 20, "position": 0}}, + "additionalProperties": false + } + })); + let note = contract.document_type_for_name("note").unwrap(); + let post_type = contract.document_type_for_name("post").unwrap(); + let mut post = post_type.random_document(Some(7), version).unwrap(); + post.set_id([5; 32].into()); + let mut document = note.random_document(Some(1), version).unwrap(); + document.set_revision(Some(1)); + document.set_created_at(Some(1_000)); + if case == "derived" { + document.set("quoteId", Value::Identifier(post.id().to_buffer())); + } + let mut priced_document = document.clone(); + if case == "derived" { + priced_document.properties_mut().insert( + "quoteId.$ownerId".into(), + Value::Identifier(post.owner_id().to_buffer()), + ); + } + let assumptions = CostAssumptions::new(version); + let previous_cost = + document_create_cost(&contract, note, &priced_document, &assumptions, &previous) + .unwrap(); + let current_cost = + document_create_cost(&contract, note, &priced_document, &assumptions, version); + match current_cost { + Ok(cost) => assert_eq!(cost.to_value(), previous_cost.to_value(), "{case}"), + Err(error) => unsupported_costs.push(format!("{case}: {error}")), + } + + let mut actual = Vec::new(); + for insert_version in [&previous, version] { + let drive = setup_drive_with_initial_state_structure(Some(version)); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + version, + ) + .unwrap(); + if case == "derived" { + insert(&drive, &contract, post_type, &post).unwrap(); + } + let fee = insert_at_version(&drive, &contract, note, &document, 1_000, insert_version) + .unwrap(); + assert!(element( + &drive, + &contract, + "note", + &[vec![0]], + document.id().as_slice() + ) + .is_some()); + actual.push((fee.storage_fee, fee.processing_fee)); + } + let estimated_processing = previous_cost.processing_credits().new_values; + let estimated_writes = previous_cost + .processing + .iter() + .find(|part| part.code == "writes") + .unwrap() + .credits + .new_values; + println!( + "CREATE_COST {case} estimated_storage={} estimated_processing={estimated_processing} estimated_writes={estimated_writes} actual_insert1={:?} actual_insert2={:?}", + previous_cost.storage_credits.new_values, actual[0], actual[1] + ); + assert_eq!( + actual[0], actual[1], + "{case}: fresh insert fees must be unchanged" + ); + assert_eq!( + previous_cost.storage_credits.new_values, actual[1].0, + "{case}" + ); + assert!( + estimated_processing >= actual[1].1, + "{case}: processing must not be undercounted" + ); + } + assert!( + unsupported_costs.is_empty(), + "the current insert generation must have a client cost: {unsupported_costs:?}" + ); +} + +#[test] +fn should_match_applied_delete_refunds_without_refunding_retained_history() { + let latest = PlatformVersion::latest(); + let mut mismatches = Vec::new(); + for (version, keeps_history) in [ + (PlatformVersion::get(14).unwrap(), false), + (latest, false), + (latest, true), + ] { + let mut schema = note_schema(); + schema + .insert("documentsKeepHistory".into(), keeps_history.into()) + .unwrap(); + let contract = contract_with(platform_value!({"note": schema})); + let note = contract.document_type_for_name("note").unwrap(); + let document = note_document(&contract); + let cost = document_create_cost( + &contract, + note, + &document, + &CostAssumptions::new(version), + version, + ) + .unwrap(); + println!( + "DELETE_REFUND pv={} history={keeps_history} same_epoch={:?} after_one_year={:?}", + version.protocol_version, cost.refund_same_epoch, cost.refund_after_one_year + ); + if !keeps_history { + assert_eq!( + cost.refund_same_epoch, + Some(Scenarios { + new_values: 54_929_132, + known_values: 33_976_675, + }) + ); + assert_eq!( + cost.refund_after_one_year, + Some(Scenarios { + new_values: 52_181_962, + known_values: 32_277_376, + }) + ); + } + if keeps_history { + let released = PlatformVersion::get(14).unwrap(); + let legacy_cost = document_create_cost( + &contract, + note, + &document, + &CostAssumptions::new(released), + released, + ) + .unwrap(); + assert_eq!( + legacy_cost.refund_same_epoch, + Some(Scenarios { + new_values: 53_796_789, + known_values: 32_843_893, + }) + ); + assert_eq!( + legacy_cost.refund_after_one_year, + Some(Scenarios { + new_values: 51_106_242, + known_values: 31_201_257, + }) + ); + println!( + "DELETE_REFUND legacy_history_pv14 same_epoch={:?} after_one_year={:?}", + legacy_cost.refund_same_epoch, legacy_cost.refund_after_one_year + ); + } + for (epochs_later, expected) in [ + (0, cost.refund_same_epoch.unwrap().new_values), + ( + DEFAULT_EPOCHS_PER_ERA, + cost.refund_after_one_year.unwrap().new_values, + ), + ] { + let drive = setup_drive_with_initial_state_structure(Some(version)); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + version, + ) + .unwrap(); + insert_at_version(&drive, &contract, note, &document, 0, version).unwrap(); + let block = BlockInfo { + epoch: Epoch::new(epochs_later).unwrap(), + ..BlockInfo::default_with_time(2_000) + }; + let fee = drive + .delete_document_for_contract( + document.id(), + &contract, + "note", + block, + true, + None, + version, + ) + .unwrap(); + let actual: u64 = fee + .fee_refunds + .0 + .values() + .flat_map(|epochs| epochs.values()) + .sum(); + assert!(element( + &drive, + &contract, + "note", + &[vec![0]], + document.id().as_slice() + ) + .is_none()); + if keeps_history { + assert!(element( + &drive, + &contract, + "note", + &[vec![2]], + document.id().as_slice() + ) + .is_some()); + } + println!( + "DELETE_REFUND pv={} history={keeps_history} epochs_later={epochs_later} estimated={expected} actual={actual}", + version.protocol_version + ); + if expected != actual { + mismatches.push(( + version.protocol_version, + keeps_history, + epochs_later, + expected, + actual, + )); + } + } + } + assert!( + mismatches.is_empty(), + "delete refund must match removed bytes: {mismatches:?}" + ); +} + #[test] fn should_split_the_storage_into_primary_storage_and_each_index() { let platform_version = PlatformVersion::latest(); diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract/v0/mod.rs index 20580c92f17..0c1b0e92e62 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract/v0/mod.rs @@ -30,8 +30,9 @@ impl Drive { document_id, contract, document_type_name, + &block_info, + None, estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, &mut drive_operations, platform_version, diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/mod.rs index f894eb73565..752652ff53f 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/mod.rs @@ -5,6 +5,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; use crate::util::estimated_layers::EstimatedLayers; +use dpp::block::block_info::BlockInfo; use dpp::data_contract::DataContract; use dpp::identifier::Identifier; @@ -12,17 +13,19 @@ use dpp::version::PlatformVersion; use grovedb::TransactionArg; impl Drive { - /// Deletes a document. + /// Deletes a document and adds the operations to the given list. /// /// # Parameters /// * `document_id`: The ID of the document to delete. /// * `contract`: The contract that contains the document. /// * `document_type_name`: The name of the document type. - /// * `owner_id`: The owner ID of the document. + /// * `block_info`: The block this delete belongs to. + /// * `deleter_id`: The identity credited with the lifecycle record a + /// keep-history delete writes; `None` credits nobody. /// * `estimated_costs_only_with_layer_info`: An optional `EstimatedLayers` with layer information for estimated costs. /// * `transaction`: The transaction argument. /// * `drive_operations`: A mutable vector of low level drive operations. - /// * `drive_version`: The drive version to select the correct function version to run. + /// * `platform_version`: The platform version to select the correct function version to run. /// /// # Returns /// * `Ok(())` if the operation was successful. @@ -33,8 +36,9 @@ impl Drive { document_id: Identifier, contract: &DataContract, document_type_name: &str, + block_info: &BlockInfo, + deleter_id: Option, estimated_costs_only_with_layer_info: Option, - block_time_ms: u64, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, @@ -50,8 +54,9 @@ impl Drive { document_id, contract, document_type_name, + block_info, + deleter_id, estimated_costs_only_with_layer_info, - block_time_ms, transaction, drive_operations, platform_version, diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/v0/mod.rs index 0dd3c9b5461..0252b113acc 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_apply_and_add_to_operations/v0/mod.rs @@ -2,6 +2,7 @@ use crate::drive::Drive; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; use crate::util::estimated_layers::EstimatedLayers; +use dpp::block::block_info::BlockInfo; use dpp::data_contract::DataContract; use dpp::identifier::Identifier; @@ -17,8 +18,9 @@ impl Drive { document_id: Identifier, contract: &DataContract, document_type_name: &str, + block_info: &BlockInfo, + deleter_id: Option, mut estimated_costs_only_with_layer_info: Option, - block_time_ms: u64, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, @@ -34,9 +36,10 @@ impl Drive { document_id, contract, document_type_name, + block_info, + deleter_id, None, &mut estimated_costs_only_with_layer_info, - block_time_ms, transaction, platform_version, )?; diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id/v0/mod.rs index 7963b4574b4..796d5812433 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id/v0/mod.rs @@ -48,8 +48,9 @@ impl Drive { document_id, contract, document_type_name, + &block_info, + None, estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, &mut drive_operations, platform_version, diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/mod.rs index 2b81602ce24..27edd38e6e8 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/mod.rs @@ -5,7 +5,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; use crate::util::estimated_layers::EstimatedLayers; -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::version::PlatformVersion; @@ -19,7 +19,9 @@ impl Drive { /// * `contract_id`: The ID of the contract that contains the document. /// * `document_type_name`: The name of the document type. /// * `owner_id`: The owner ID of the document. - /// * `epoch`: The epoch of the block. + /// * `block_info`: The block this delete belongs to. + /// * `deleter_id`: The identity credited with the lifecycle record a + /// keep-history delete writes; `None` credits nobody. /// * `previous_batch_operations`: Previous batch operations to include. /// * `estimated_costs_only_with_layer_info`: Estimated costs with layer info. /// * `transaction`: The transaction argument. @@ -34,10 +36,10 @@ impl Drive { document_id: Identifier, contract_id: Identifier, document_type_name: &str, - epoch: &Epoch, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -52,10 +54,10 @@ impl Drive { document_id, contract_id, document_type_name, - epoch, + block_info, + deleter_id, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/v0/mod.rs index 1fc0cfb0109..b787fadde5c 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_id_with_named_type_operations/v0/mod.rs @@ -8,7 +8,7 @@ use crate::error::document::DocumentError; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::identifier::Identifier; @@ -23,17 +23,17 @@ impl Drive { document_id: Identifier, contract_id: Identifier, document_type_name: &str, - epoch: &Epoch, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { let mut operations = vec![]; let Some(contract_fetch_info) = self.get_contract_with_fetch_info_and_add_to_operations( contract_id.to_buffer(), - Some(epoch), + Some(&block_info.epoch), true, transaction, &mut operations, @@ -49,9 +49,10 @@ impl Drive { document_id, contract, document_type, + block_info, + deleter_id, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, transaction, platform_version, ) diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs index c2dbb152c77..2eed8b5612f 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs @@ -1,4 +1,5 @@ mod v0; +mod v1; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -6,6 +7,7 @@ use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; use crate::util::estimated_layers::EstimatedLayers; +use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; use dpp::document::Document; @@ -21,23 +23,27 @@ impl Drive { /// * `document_id`: The ID of the document to delete. /// * `contract`: The contract that contains the document. /// * `document_type`: The type of the document. + /// * `block_info`: The block this delete belongs to. + /// * `deleter_id`: The identity credited with the lifecycle record a + /// keep-history delete writes; `None` credits nobody. /// * `previous_batch_operations`: Previous batch operations to include. /// * `estimated_costs_only_with_layer_info`: Estimated costs with layer info. /// * `transaction`: The transaction argument. - /// * `drive_version`: The drive version to select the correct function version to run. + /// * `platform_version`: The platform version to select the correct function version to run. /// /// # Returns /// * `Ok(Vec)` if the operation was successful. /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. #[allow(clippy::too_many_arguments)] - pub(crate) fn delete_document_for_contract_operations( + pub fn delete_document_for_contract_operations( &self, document_id: Identifier, contract: &DataContract, document_type: DocumentTypeRef, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -45,7 +51,7 @@ impl Drive { self.prepare_document_time_range_ttl( contract, document_type, - block_time_ms, + block_info.time_ms, transaction, platform_version, )?; @@ -54,9 +60,10 @@ impl Drive { document_id, contract, document_type, + block_info, + deleter_id, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, transaction, platform_version, ) @@ -70,9 +77,10 @@ impl Drive { document_id: Identifier, contract: &DataContract, document_type: DocumentTypeRef, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -89,13 +97,24 @@ impl Drive { document_type, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, + block_info.time_ms, + transaction, + platform_version, + ), + 1 => self.delete_document_for_contract_operations_v1( + document_id, + contract, + document_type, + block_info, + deleter_id, + previous_batch_operations, + estimated_costs_only_with_layer_info, transaction, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "delete_document_for_contract_operations".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } @@ -108,10 +127,13 @@ impl Drive { /// * `document_id`: The ID of the document to delete. /// * `contract`: The contract that contains the document. /// * `document_type`: The type of the document. + /// * `block_info`: The block this delete belongs to. + /// * `deleter_id`: The identity credited with the lifecycle record a + /// keep-history delete writes; `None` credits nobody. /// * `previous_batch_operations`: Previous batch operations to include. /// * `estimated_costs_only_with_layer_info`: Estimated costs with layer info. /// * `transaction`: The transaction argument. - /// * `drive_version`: The drive version to select the correct function version to run. + /// * `platform_version`: The platform version to select the correct function version to run. /// /// # Returns /// * `Ok(Vec)` if the operation was successful. @@ -122,9 +144,10 @@ impl Drive { document_id: Identifier, contract: &DataContract, document_type: DocumentTypeRef, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -141,13 +164,24 @@ impl Drive { document_type, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, + block_info.time_ms, + transaction, + platform_version, + ), + 1 => self.force_delete_document_for_contract_operations_v1( + document_id, + contract, + document_type, + block_info, + deleter_id, + previous_batch_operations, + estimated_costs_only_with_layer_info, transaction, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "force_delete_document_for_contract_operations".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } @@ -191,7 +225,7 @@ impl Drive { .delete .delete_document_for_contract_operations { - 0 => self.force_delete_read_document_for_contract_operations_v0( + 0 | 1 => self.force_delete_read_document_for_contract_operations_v0( document, contract, document_type, @@ -203,7 +237,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "force_delete_read_document_for_contract_operations".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } @@ -294,9 +328,10 @@ mod tests { document.id(), &contract, document_type, + &BlockInfo::default(), + None, None, &mut by_id_estimates, - 0, None, platform_version, ) diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v1/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v1/mod.rs new file mode 100644 index 00000000000..ce666d9eaf8 --- /dev/null +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v1/mod.rs @@ -0,0 +1,380 @@ +use crate::util::estimated_layers::EstimatedLayers; +use grovedb::batch::QualifiedGroveDbOp; +use grovedb::{Element, TransactionArg, TreeType}; + +use dpp::data_contract::document_type::DocumentTypeRef; + +use crate::drive::constants::DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE; +use crate::drive::document::paths::{ + contract_documents_primary_key_path, document_history_path, document_lifecycle_path, + DOCUMENT_LIFECYCLE_TREE_KEY, +}; +use crate::drive::document::primary_key_tree_type::DocumentTypePrimaryKeyTreeType; +use crate::util::object_size_info::DocumentInfo::{ + DocumentEstimatedAverageSize, DocumentOwnedInfo, +}; +use crate::util::storage_flags::StorageFlags; +use dpp::document::lifecycle::DocumentLifecycleRecord; +use dpp::serialization::PlatformSerializable; + +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::DataContract; +use dpp::document::{Document, DocumentV0Getters}; + +use crate::drive::Drive; +use crate::util::grove_operations::QueryTarget::{QueryTargetTree, QueryTargetValue}; +use crate::util::grove_operations::{BatchInsertTreeApplyType, DirectQueryType, QueryType}; +use crate::util::object_size_info::PathKeyInfo::PathKey; +use crate::util::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; + +use crate::error::drive::DriveError; + +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; + +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::identifier::Identifier; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Prepares the operations for deleting a document. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + pub(super) fn delete_document_for_contract_operations_v1( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + block_info: &BlockInfo, + deleter_id: Option, + previous_batch_operations: Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + if !document_type.documents_can_be_deleted() { + return Err(Error::Drive(DriveError::UpdatingReadOnlyImmutableDocument( + "this document type is not mutable and can not be deleted", + ))); + } + + self.force_delete_document_for_contract_operations_v1( + document_id, + contract, + document_type, + block_info, + deleter_id, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ) + } + + /// Prepares the operations for deleting a document. + /// + /// Deleting a keep-history document removes it from every ordinary read + /// without touching a single retained revision: the current pointer and the + /// index references that lead to it go, and a lifecycle record recording the + /// deletion time takes their place. The revisions stay where they are, and + /// only an erase can remove them. + /// + /// Every other document type is deleted exactly as v0 deletes it. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + pub(super) fn force_delete_document_for_contract_operations_v1( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + block_info: &BlockInfo, + deleter_id: Option, + previous_batch_operations: Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + if !document_type.documents_keep_history() { + return self.force_delete_document_for_contract_operations_v0( + document_id, + contract, + document_type, + previous_batch_operations, + estimated_costs_only_with_layer_info, + block_info.time_ms, + transaction, + platform_version, + ); + } + + let mut batch_operations: Vec = vec![]; + + let contract_documents_primary_key_path = contract_documents_primary_key_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ); + + let query_type = if let Some(estimated_costs_only_with_layer_info) = + estimated_costs_only_with_layer_info + { + Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + contract, + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + // The read follows the current pointer into the type's history, so + // the dry run has to pay for the reference hop as well as the + // revision it lands on. `DirectQueryType` cannot express that: its + // conversion hardcodes an empty reference-size list. + QueryType::StatelessQuery { + in_tree_type: document_type.primary_key_tree_type(platform_version)?, + query_target: QueryTargetValue( + document_type.estimated_size(platform_version)? as u32 + ), + estimated_reference_sizes: vec![DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE], + } + } else { + QueryType::StatefulQuery + }; + + // Resolves the pointer, so this is the current revision's item, whose + // flags are the ones the index references were written with. + let document_element: Option = self.grove_get( + (&contract_documents_primary_key_path).into(), + document_id.as_slice(), + query_type.clone(), + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + + let (document_info, latest_revision) = + if let QueryType::StatelessQuery { query_target, .. } = query_type { + (DocumentEstimatedAverageSize(query_target.len()), 0) + } else if let Some(document_element) = &document_element { + let Element::Item(data, element_flags) = document_element else { + return Err(Error::Drive(DriveError::CorruptedDocumentNotItem( + "the current pointer of a keep-history document did not resolve to an item", + ))); + }; + let document = + Document::from_bytes(data.as_slice(), document_type, platform_version)?; + let storage_flags = StorageFlags::map_cow_some_element_flags_ref(element_flags)?; + let latest_revision = document.revision().unwrap_or(1); + ( + DocumentOwnedInfo((document, storage_flags)), + latest_revision, + ) + } else { + return Err(Error::Drive(DriveError::DeletingDocumentThatDoesNotExist( + "document being deleted does not exist", + ))); + }; + + // The record remembers how many revisions the history retained next to + // the revision being deleted, so a later by-revision read can tell a + // contiguous history from one a pre-protocol-15 overwrite left gapped. + // That count is the history tree's own aggregate, read off its element + // in the type's history tree. + let mut history_type_path = document_history_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document_id.as_slice(), + ); + history_type_path.pop(); + let history_query_type = if estimated_costs_only_with_layer_info.is_some() { + DirectQueryType::StatelessDirectQuery { + in_tree_type: TreeType::NormalTree, + // A tree created at PV15 carries its creator's single-epoch owned flags; + // one migrated at activation carries the contract's flags, which can be larger. + // This is an average-case figure; the delete's total estimate covers the applied read. + query_target: QueryTargetTree( + StorageFlags::approximate_size(true, None), + TreeType::ProvableCountTree, + ), + } + } else { + DirectQueryType::StatefulDirectQuery + }; + let history_element = self.grove_get_raw( + history_type_path.as_slice().into(), + document_id.as_slice(), + history_query_type, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + let revision_count = match ( + estimated_costs_only_with_layer_info.is_some(), + history_element, + ) { + (true, _) => 0, + (false, Some(Element::ProvableCountTree(_, count, _))) => count, + (false, _) => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a keep-history document being deleted has no history tree".to_string(), + ))) + } + }; + + let document_info = self.document_info_with_derived_index_values( + document_info, + contract, + document_type, + estimated_costs_only_with_layer_info.is_some(), + transaction, + &mut batch_operations, + platform_version, + )?; + + // The pointer goes; the revisions it named stay in the history tree. + self.remove_document_from_primary_storage( + document_id, + document_type, + contract_documents_primary_key_path, + estimated_costs_only_with_layer_info, + transaction, + &mut batch_operations, + platform_version, + )?; + + let document_and_contract_info = DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info, + owner_id: None, + }, + contract, + document_type, + }; + + self.remove_indices_for_top_index_level_for_contract_operations( + &document_and_contract_info, + &previous_batch_operations, + estimated_costs_only_with_layer_info, + block_info.time_ms, + transaction, + &mut batch_operations, + platform_version, + )?; + + // The record is the deleter's byte, refunded to them when the terminal + // erase chunk removes it. A caller with no signer writes it unflagged, + // and it then refunds nobody, exactly as the unflagged structural bytes + // of a non-deletable contract do. + let record_flags = deleter_id + .map(|id| StorageFlags::new_single_epoch(block_info.epoch.index, Some(id.to_buffer()))); + let record = if estimated_costs_only_with_layer_info.is_some() { + DocumentLifecycleRecord::deleted_at(block_info.time_ms, u64::MAX, u64::MAX) + } else { + DocumentLifecycleRecord::deleted_at(block_info.time_ms, latest_revision, revision_count) + }; + self.add_lifecycle_record_operations( + document_id, + contract, + document_type, + record, + record_flags.as_ref(), + estimated_costs_only_with_layer_info, + transaction, + previous_batch_operations, + &mut batch_operations, + platform_version, + )?; + + Ok(batch_operations) + } + + /// Creates the document type's lifecycle tree if it does not exist yet and + /// writes one record into it. + /// + /// The tree is created on demand so that a document type whose documents are + /// never deleted never pays for one, and the record is flagged to the + /// deleter, who is refunded when the terminal erase chunk removes it. + #[allow(clippy::too_many_arguments)] + pub(crate) fn add_lifecycle_record_operations( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + record: DocumentLifecycleRecord, + storage_flags: Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + previous_batch_operations: Option<&mut Vec>, + batch_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + if !record.is_coherent() { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a lifecycle record is incoherent".to_string(), + ))); + } + let lifecycle_path = + document_lifecycle_path(contract.id_ref().as_bytes(), document_type.name().as_str()); + let element_flags = StorageFlags::map_to_some_element_flags(storage_flags); + if let Some(layers) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_lifecycle_record( + contract, + document_type, + layers, + platform_version, + )?; + } + + let tree_apply_type = if estimated_costs_only_with_layer_info.is_some() { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_type: TreeType::NormalTree, + tree_type: TreeType::NormalTree, + // The container is unflagged, so its element carries no + // beneficiary payload to size. + flags_len: 0, + } + } else { + BatchInsertTreeApplyType::StatefulBatchInsertTree + }; + + let mut document_type_path = crate::drive::document::paths::contract_document_type_path_vec( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ); + let lifecycle_tree_key = vec![DOCUMENT_LIFECYCLE_TREE_KEY]; + // The container is shared by every document of the type and outlives + // any one of them: an erase removes records and per-document history + // trees, never this. Flagging it to whoever happened to delete first + // would charge them for structure nobody refunds, and would make the + // committed encoding depend on which document went first. The record + // inside it keeps the deletion storage payer's flags, which is what an erase refunds. + // + // The running batch is consulted so that two deletes of different + // documents of the same type, prepared before either is applied, insert + // this one key once rather than twice. + let mut container_operations = Vec::new(); + self.batch_insert_empty_tree_if_not_exists::<0>( + PathKey((std::mem::take(&mut document_type_path), lifecycle_tree_key)), + TreeType::NormalTree, + None, + tree_apply_type, + transaction, + &mut Some(previous_batch_operations.unwrap_or(batch_operations)), + &mut container_operations, + &platform_version.drive, + )?; + batch_operations.append(&mut container_operations); + + // The record uses the deletion's retained counts, or their maximum + // encoded size during estimation. Refuse an existing record even if a + // caller reaches deletion from inconsistent state. + batch_operations.push(LowLevelDriveOperation::GroveOperation( + QualifiedGroveDbOp::insert_if_not_exists_op( + lifecycle_path, + document_id.to_vec(), + Element::Item(record.serialize_to_bytes()?, element_flags), + ), + )); + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/mod.rs index 6b6f32c77cb..125d5947ed0 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/mod.rs @@ -5,6 +5,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; use crate::util::estimated_layers::EstimatedLayers; +use dpp::block::block_info::BlockInfo; use dpp::data_contract::DataContract; @@ -19,10 +20,13 @@ impl Drive { /// * `document_id`: The ID of the document to delete. /// * `contract`: The contract that contains the document. /// * `document_type_name`: The name of the document type. + /// * `block_info`: The block this delete belongs to. + /// * `deleter_id`: The identity credited with the lifecycle record a + /// keep-history delete writes; `None` credits nobody. /// * `previous_batch_operations`: Previous batch operations to include. /// * `estimated_costs_only_with_layer_info`: Estimated costs with layer info. /// * `transaction`: The transaction argument. - /// * `drive_version`: The drive version to select the correct function version to run. + /// * `platform_version`: The platform version to select the correct function version to run. /// /// # Returns /// * `Ok(Vec)` if the operation was successful. @@ -33,9 +37,10 @@ impl Drive { document_id: Identifier, contract: &DataContract, document_type_name: &str, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -50,9 +55,10 @@ impl Drive { document_id, contract, document_type_name, + block_info, + deleter_id, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/v0/mod.rs index c47a3fc14e9..6108e171408 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_with_named_type_operations/v0/mod.rs @@ -2,6 +2,7 @@ use crate::util::estimated_layers::EstimatedLayers; use grovedb::TransactionArg; +use dpp::block::block_info::BlockInfo; use dpp::data_contract::DataContract; use crate::drive::Drive; @@ -23,9 +24,10 @@ impl Drive { document_id: Identifier, contract: &DataContract, document_type_name: &str, + block_info: &BlockInfo, + deleter_id: Option, previous_batch_operations: Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option, - block_time_ms: u64, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -34,9 +36,10 @@ impl Drive { document_id, contract, document_type, + block_info, + deleter_id, previous_batch_operations, estimated_costs_only_with_layer_info, - block_time_ms, transaction, platform_version, ) diff --git a/packages/rs-drive/src/drive/document/delete/erase_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/erase_document_for_contract_operations/mod.rs new file mode 100644 index 00000000000..8776cf9e1a5 --- /dev/null +++ b/packages/rs-drive/src/drive/document/delete/erase_document_for_contract_operations/mod.rs @@ -0,0 +1,71 @@ +use crate::util::estimated_layers::EstimatedLayers; +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; + +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; + +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Prepares the operations for removing a bounded chunk of the retained + /// revisions of a document that has already been deleted. + /// + /// # Parameters + /// * `document_id`: The document whose revisions are being removed. + /// * `contract`: The contract that contains the document. + /// * `document_type`: The type of the document, which must keep history. + /// * `block_info`: The block this erase belongs to. + /// * `estimated_costs_only_with_layer_info`: Estimated costs with layer info. + /// * `transaction`: The transaction argument. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(Vec)` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + #[allow(clippy::too_many_arguments)] + pub fn erase_document_for_contract_operations( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + block_info: &BlockInfo, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .document + .delete + .erase_document_for_contract_operations + { + Some(0) => self.erase_document_for_contract_operations_v0( + document_id, + contract, + document_type, + block_info, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), + Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "erase_document_for_contract_operations".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Drive(DriveError::VersionNotActive { + method: "erase_document_for_contract_operations".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/delete/erase_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/erase_document_for_contract_operations/v0/mod.rs new file mode 100644 index 00000000000..8060dd2afe6 --- /dev/null +++ b/packages/rs-drive/src/drive/document/delete/erase_document_for_contract_operations/v0/mod.rs @@ -0,0 +1,476 @@ +use crate::util::estimated_layers::EstimatedLayers; + +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::KeyInfoPath; +use grovedb::query_result_type::QueryResultType; +use grovedb::{Element, MaybeTree, PathQuery, Query, SizedQuery, TransactionArg, TreeType}; + +use crate::drive::constants::DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE; +use crate::drive::document::paths::{ + contract_documents_primary_key_path, document_history_path, document_lifecycle_path, +}; +use crate::drive::document::primary_key_tree_type::DocumentTypePrimaryKeyTreeType; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; +use crate::util::common::encode::encode_u64; +use crate::util::grove_operations::BatchDeleteApplyType::{ + StatefulBatchDelete, StatelessBatchDelete, +}; +use crate::util::grove_operations::{DirectQueryType, QueryTarget}; +use crate::util::object_size_info::PathKeyElementInfo::{PathKeyElement, PathKeyElementSize}; +use crate::util::storage_flags::StorageFlags; +use dpp::document::lifecycle::{DocumentLifecycleRecord, DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE}; +use dpp::serialization::{PlatformDeserializableTrusted, PlatformSerializable}; + +/// Length of a revision key: a block timestamp followed by a history sequence. +const REVISION_KEY_LENGTH: usize = 16; + +impl Drive { + /// Prepares the operations for removing a bounded chunk of the retained + /// revisions of an already deleted document. + /// + /// Revisions go newest first, so the remnant a partial erasure leaves behind + /// is the document's oldest content, preserving any existing revision gaps. + /// The chunk is bounded by + /// `max_document_revisions_erased_per_transition`, and the enumeration asks + /// for one revision more than it may remove so that it knows, before + /// emitting anything, whether this chunk is the last one. + /// + /// A terminal chunk also removes the lifecycle record and the now empty + /// history subtree; GroveDB establishes that the subtree is empty from the + /// deletes already in this batch and refuses the removal otherwise. A + /// non-terminal first chunk instead overwrites the record with the erasure + /// it authorizes, which is what lets any identity finish the work later. + /// The two never happen together, so one batch never carries two operations + /// on the record's key. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + pub(super) fn erase_document_for_contract_operations_v0( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + block_info: &BlockInfo, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + if !document_type.documents_keep_history() { + return Err(Error::Drive(DriveError::CorruptedCodeExecution( + "only a document type that keeps history has revisions to erase", + ))); + } + let chunk = platform_version + .system_limits + .max_document_revisions_erased_per_transition + .ok_or(Error::Drive(DriveError::NotSupported( + "erasing retained revisions is not available at this protocol version", + )))?; + + if chunk == 0 || chunk == u16::MAX { + return Err(Error::Drive(DriveError::InvalidInput( + "an erase chunk must allow at least one revision and a following probe".to_string(), + ))); + } + + let history_path = document_history_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document_id.as_slice(), + ); + let lifecycle_path = + document_lifecycle_path(contract.id_ref().as_bytes(), document_type.name().as_str()); + let primary_path = contract_documents_primary_key_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ); + // Worst-case sizing: a chunk may hold the type's largest documents, and + // the admission estimate has to cover that whatever this document + // actually stores. + let revision_size = document_type.max_size(platform_version)? as u32; + + let mut batch_operations: Vec = vec![]; + + if let Some(layers) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_erase_document( + document_id, + contract, + document_type, + layers, + platform_version, + )?; + return self.estimated_erase_document_operations( + document_id, + &history_path, + &lifecycle_path, + primary_path, + document_type.primary_key_tree_type(platform_version)?, + chunk, + revision_size, + block_info, + batch_operations, + transaction, + platform_version, + ); + } + + // The record exists exactly while a document is deleted or erasing, so + // its presence is what proves the document may lose revisions at all. + // It is read before anything is emitted: a caller that reaches this + // without a delete, or after an erasure has already finished and the + // id was reused, would otherwise strip an active document's history. + let (record, flags) = self.fetch_lifecycle_record_with_flags( + document_id, + &lifecycle_path, + &mut batch_operations, + transaction, + platform_version, + )?; + if self + .grove_get_raw_optional( + (&primary_path).into(), + document_id.as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + &mut batch_operations, + &platform_version.drive, + )? + .is_some() + { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a document has both a current pointer and a lifecycle record".to_string(), + ))); + } + + let removable = self.enumerate_newest_revision_keys( + &history_path, + chunk, + &mut batch_operations, + transaction, + platform_version, + )?; + if removable.is_empty() { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a document with a lifecycle record retains no revisions".to_string(), + ))); + } + let terminal = removable.len() <= chunk as usize; + let to_remove = if terminal { + removable.as_slice() + } else { + &removable[..chunk as usize] + }; + + // A leaf delete does not consult the batch it joins, so each one is + // generated against an empty view and appended: building the whole + // running batch once per revision would be quadratic in the chunk size. + let mut single_operation = Vec::with_capacity(2); + for key in to_remove { + single_operation.clear(); + self.batch_delete( + history_path.as_slice().into(), + key, + StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some(MaybeTree::NotTree), + }, + transaction, + &mut single_operation, + &platform_version.drive, + )?; + batch_operations.append(&mut single_operation); + } + + if terminal { + self.batch_delete( + lifecycle_path.as_slice().into(), + document_id.as_slice(), + StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some(MaybeTree::NotTree), + }, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + let mut history_root = history_path; + history_root.pop(); + // Every revision has already been deleted into this batch, which is + // how GroveDB establishes that the subtree is empty. If any survived + // it refuses the removal rather than orphaning their storage. + self.batch_delete( + history_root.as_slice().into(), + document_id.as_slice(), + StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some(MaybeTree::Tree( + TreeType::ProvableCountTree, + )), + }, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + } else { + if record.is_erasing() { + // A continuation: the record already carries the erasure this + // chunk is finishing, and nothing but an authorized first chunk + // may write those fields. + return Ok(batch_operations); + } + let (time_ms, revision) = Self::decode_revision_key(&removable[0])?; + let record = record.starting_erase_at(block_info.time_ms, time_ms, revision); + if !record.is_coherent() { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a lifecycle record is incoherent".to_string(), + ))); + } + // Preserve the record's refund beneficiary. The eraser pays for + // rewriting the record, including any encoded-size growth, while + // the retained flags still name the beneficiary of its later removal. + self.batch_insert::<0>( + PathKeyElement(( + lifecycle_path, + document_id.to_vec(), + Element::Item(record.serialize_to_bytes()?, flags), + )), + &mut batch_operations, + &platform_version.drive, + )?; + } + + Ok(batch_operations) + } + + /// Reads the revision keys of one document newest first, one more than a + /// chunk may remove so the caller can tell a terminal chunk from a partial + /// one before it emits anything. + /// + /// The keys are what this needs, but GroveDB's query surface has no + /// key-only result shape over a range: every result type it exposes carries + /// elements. The revision bodies therefore come back and are dropped, and + /// the estimate below prices that read for what it is. What this does avoid + /// is the running-batch snapshot the general delete-by-query helper rebuilds + /// for every element, which is quadratic in the chunk size. + fn enumerate_newest_revision_keys( + &self, + history_path: &[Vec], + chunk: u16, + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let mut query = Query::new_with_direction(false); + // Exactly the revision key space: the current pointer lives in the + // primary-key tree and is not in this subtree at all. + query.insert_all(); + let path_query = PathQuery::new( + history_path.to_vec(), + SizedQuery::new(query, Some(chunk + 1), None), + ); + let (results, _) = self.grove_get_raw_path_query( + &path_query, + transaction, + QueryResultType::QueryKeyElementPairResultType, + batch_operations, + &platform_version.drive, + )?; + Ok(results + .to_key_elements() + .into_iter() + .map(|(key, _)| key) + .collect()) + } + + /// Reads one lifecycle record together with the flags naming the identity + /// its bytes were charged to. + fn fetch_lifecycle_record_with_flags( + &self, + document_id: Identifier, + lifecycle_path: &[Vec], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(DocumentLifecycleRecord, Option>), Error> { + // A type nothing has been deleted under has no lifecycle tree at all; + // that reads as no record, the same as an id without one. + let element = self + .grove_get_raw_optional( + lifecycle_path.into(), + document_id.as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + batch_operations, + &platform_version.drive, + )? + .ok_or(Error::Drive(DriveError::InvalidInput( + "only a deleted document can be erased: it has no lifecycle record".to_string(), + )))?; + let Element::Item(bytes, flags) = element else { + return Err(Error::Drive(DriveError::CorruptedElementType( + "a lifecycle record is not an item", + ))); + }; + let record = DocumentLifecycleRecord::deserialize_from_bytes_trusted(&bytes)?; + if !record.is_coherent() { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a lifecycle record is incoherent".to_string(), + ))); + } + Ok((record, flags)) + } + + /// Splits a revision key into the block time and history sequence it + /// carries. + fn decode_revision_key(key: &[u8]) -> Result<(u64, u64), Error> { + if key.len() != REVISION_KEY_LENGTH { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a retained revision key does not carry a time and a sequence".to_string(), + ))); + } + let decode = |bytes: &[u8]| -> u64 { + let mut buffer = [0u8; 8]; + buffer.copy_from_slice(bytes); + // The encoder flips the sign bit so that the ordering of the keys + // matches the ordering of the values. + u64::from_be_bytes(buffer) ^ (1 << 63) + }; + Ok((decode(&key[..8]), decode(&key[8..]))) + } + + /// Prices a full chunk without reading any state. + /// + /// The dry run cannot know how many revisions a document retains, so it + /// charges for a whole chunk of the type's largest documents plus both + /// endings: the record write of a first chunk and the subtree removal of a + /// terminal one. Every erase is therefore admitted against the same + /// worst-case estimate whatever the document's actual history length. + /// + /// The enumeration is priced at one revision more than a chunk removes, + /// because that is what it reads, and at the full body size, because the + /// query surface returns bodies whether or not the caller wants them. The + /// record read every chunk performs first is priced too. + #[allow(clippy::too_many_arguments)] + fn estimated_erase_document_operations( + &self, + document_id: Identifier, + history_path: &[Vec], + lifecycle_path: &[Vec], + primary_path: [&[u8]; 5], + primary_tree_type: TreeType, + chunk: u16, + revision_size: u32, + block_info: &BlockInfo, + mut batch_operations: Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + self.grove_get_raw( + (&primary_path).into(), + document_id.as_slice(), + DirectQueryType::StatelessDirectQuery { + in_tree_type: primary_tree_type, + query_target: QueryTarget::QueryTargetValue( + DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE, + ), + }, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + // The enumeration reads one revision more than the chunk removes, and + // reads each of them whole. + for sequence in 1..=chunk as u64 + 1 { + let mut key = encode_u64(block_info.time_ms); + key.extend(encode_u64(sequence)); + self.grove_get_raw( + history_path.into(), + &key, + DirectQueryType::StatelessDirectQuery { + in_tree_type: TreeType::ProvableCountTree, + query_target: QueryTarget::QueryTargetValue(revision_size), + }, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + } + + // Every chunk reads the record first; a non-terminal one overwrites it. + self.grove_get_raw( + lifecycle_path.into(), + document_id.as_slice(), + DirectQueryType::StatelessDirectQuery { + in_tree_type: TreeType::NormalTree, + query_target: QueryTarget::QueryTargetValue(DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE), + }, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + + let mut single_operation = Vec::with_capacity(2); + for sequence in 1..=chunk as u64 { + // Distinct synthetic keys of the real shape: the dry run's batch is + // checked for consistency like any other, so a repeated key would be + // rejected rather than priced. + let mut key = encode_u64(block_info.time_ms); + key.extend(encode_u64(sequence)); + single_operation.clear(); + self.batch_delete( + history_path.into(), + &key, + StatelessBatchDelete { + in_tree_type: TreeType::ProvableCountTree, + estimated_key_size: REVISION_KEY_LENGTH as u32, + estimated_value_size: revision_size, + }, + transaction, + &mut single_operation, + &platform_version.drive, + )?; + batch_operations.append(&mut single_operation); + } + + // A record of the right shape rather than the real one: the dry run + // cannot know the deletion time it carries or the identity it is + // flagged to, only that both are there and how many bytes they take. + let flags_len = StorageFlags::approximate_size(true, None) as usize; + self.batch_insert::<0>( + PathKeyElementSize(( + KeyInfoPath::from_known_owned_path(lifecycle_path.to_vec()), + KeyInfo::KnownKey(document_id.to_vec()), + Element::Item( + vec![0u8; DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE as usize], + Some(vec![0u8; flags_len]), + ), + )), + &mut batch_operations, + &platform_version.drive, + )?; + + let mut history_root = history_path.to_vec(); + history_root.pop(); + self.batch_delete( + history_root.as_slice().into(), + document_id.as_slice(), + StatelessBatchDelete { + in_tree_type: TreeType::NormalTree, + estimated_key_size: 32, + estimated_value_size: TreeType::ProvableCountTree.inner_node_type().cost() + 3, + }, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + + Ok(batch_operations) + } +} diff --git a/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/mod.rs index 3ca0b30cfb7..d914b043a76 100644 --- a/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/mod.rs @@ -1,4 +1,5 @@ mod v0; +mod v1; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -39,9 +40,15 @@ impl Drive { estimated_costs_only_with_layer_info, platform_version, ), + 1 => Self::add_estimation_costs_for_remove_document_to_primary_storage_v1( + primary_key_path, + document_type, + estimated_costs_only_with_layer_info, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_estimation_costs_for_remove_document_to_primary_storage".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } diff --git a/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/v1/mod.rs b/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/v1/mod.rs new file mode 100644 index 00000000000..f05a17b9969 --- /dev/null +++ b/packages/rs-drive/src/drive/document/delete/internal/add_estimation_costs_for_remove_document_to_primary_storage/v1/mod.rs @@ -0,0 +1,82 @@ +use crate::util::estimated_layers::EstimatedLayers; + +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; +use grovedb::EstimatedLayerInformation; +use grovedb::EstimatedLayerSizes::{AllReference, Mix}; + +use dpp::data_contract::document_type::DocumentTypeRef; + +use crate::drive::constants::{ + AVERAGE_NUMBER_OF_UPDATES, AVERAGE_UPDATE_BYTE_COUNT_REQUIRED_SIZE, + DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE, +}; +use crate::drive::document::primary_key_tree_type::DocumentTypePrimaryKeyTreeType; +use crate::drive::Drive; +use crate::error::Error; +use crate::util::storage_flags::StorageFlags; + +use dpp::data_contract::document_type::accessors::{DocumentTypeV0Getters, DocumentTypeV2Getters}; +use dpp::version::PlatformVersion; + +impl Drive { + /// Adds the estimation layer for removing one entry from a document type's + /// primary-key tree. + /// + /// A keep-history type stores current pointers there rather than document + /// items, so its layer is sized from the reference shape the writer + /// installs; a summable type's pointers additionally carry the document's + /// contribution. Every other document type is estimated exactly as v0 does. + #[inline(always)] + pub(super) fn add_estimation_costs_for_remove_document_to_primary_storage_v1( + primary_key_path: [&[u8]; 5], + document_type: DocumentTypeRef, + estimated_costs_only_with_layer_info: &mut EstimatedLayers, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + if !document_type.documents_keep_history() { + return Self::add_estimation_costs_for_remove_document_to_primary_storage_v0( + primary_key_path, + document_type, + estimated_costs_only_with_layer_info, + platform_version, + ); + } + + let approximate_size = if document_type.documents_mutable() { + Some(( + AVERAGE_NUMBER_OF_UPDATES as u16, + AVERAGE_UPDATE_BYTE_COUNT_REQUIRED_SIZE, + )) + } else { + None + }; + let flags_size = Some(StorageFlags::approximate_size(true, approximate_size)); + let references = if document_type.documents_summable().is_some() { + Mix { + subtrees_size: None, + items_size: None, + references_size: None, + items_with_sum_item_size: None, + references_with_sum_item_size: Some(( + 32, + DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE, + flags_size, + 1, + )), + } + } else { + AllReference(32, DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE, flags_size) + }; + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(primary_key_path), + EstimatedLayerInformation { + tree_type: document_type.primary_key_tree_type(platform_version)?, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: references, + }, + ); + + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/delete/mod.rs b/packages/rs-drive/src/drive/document/delete/mod.rs index cbd0bc726aa..96e886caa5f 100644 --- a/packages/rs-drive/src/drive/document/delete/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/mod.rs @@ -44,6 +44,7 @@ mod delete_document_for_contract_with_named_type_operations; // This module contains functionality to delete a document for contract operations mod delete_document_for_contract_operations; mod delete_index_only_document_for_contract_operations; +mod erase_document_for_contract_operations; mod internal; @@ -60,6 +61,7 @@ mod tests { use crate::config::DriveConfig; use crate::drive::document::tests::setup_dashpay; + use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::util::object_size_info::DocumentInfo::DocumentRefInfo; @@ -1110,6 +1112,7 @@ mod tests { .apply_drive_operations( vec![DocumentOperation(DocumentOperationType::DeleteDocument { document_id: tip.id(), + deleter_id: None, contract_info: DataContractInfo::BorrowedDataContract(&contract), document_type_info: DocumentTypeInfo::DocumentTypeName("tip".to_string()), })], @@ -1327,13 +1330,29 @@ mod tests { ); } + /// Protocol 14 refuses the delete outright, and protocol 15 carries it out: + /// the document leaves every ordinary read while its revisions stay where + /// they are. #[test] - fn test_delete_document_keeps_history_returns_error() { + fn test_delete_document_keeps_history_returns_error_at_protocol_14() { + run_keep_history_delete_at_protocol_version(14); + } + + #[test] + fn should_delete_a_keep_history_document_without_touching_its_revisions_at_protocol_15() { + run_keep_history_delete_at_protocol_version(15); + } + + fn run_keep_history_delete_at_protocol_version(protocol_version: u32) { + use crate::drive::document::lifecycle::DocumentLifecycleState; + use dpp::document::DocumentV0Getters; + let drive = setup_drive_with_initial_state_structure(None); let db_transaction = drive.grove.start_transaction(); - let platform_version = PlatformVersion::latest(); + let platform_version = + PlatformVersion::get(protocol_version).expect("expected a known protocol version"); let contract = setup_contract( &drive, @@ -1392,23 +1411,224 @@ mod tests { .try_into() .expect("this be 32 bytes"); - // Attempting to delete a document that keeps history should return an error - let err = drive - .delete_document_for_contract( + let outcome = drive.delete_document_for_contract( + document_id, + &contract, + "person", + BlockInfo::default(), + true, + None, + platform_version, + ); + + if protocol_version < 15 { + assert!(matches!( + outcome.expect_err("expected deleting a history-keeping document to fail"), + Error::Drive(DriveError::InvalidDeletionOfDocumentThatKeepsHistory(_)) + )); + return; + } + + outcome.expect("expected the delete to succeed"); + + let (state, _) = drive + .fetch_document_lifecycle( + &contract, + document_type, + document_id, + None, + None, + platform_version, + ) + .expect("expected to read the lifecycle"); + let DocumentLifecycleState::Deleted(retained) = state else { + panic!("expected the document to be deleted, got {state:?}"); + }; + assert_eq!( + retained.id(), + document_id, + "the retained revision must still be readable" + ); + + let query = DriveDocumentQuery::all_items_query(&contract, document_type, None); + let (documents, _, _) = query + .execute_raw_results_no_proof(&drive, None, None, platform_version) + .expect("expected to query documents"); + assert!( + documents.is_empty(), + "a deleted document must be absent from every ordinary read" + ); + } + + /// A delete entry point that carries only the block time still records the + /// lifecycle entry of a keep-history document at the lifecycle generation: + /// the entry needs the deletion time, which every entry point carries, and + /// a deleter only to credit the record's bytes, which these carry no more + /// than the fee-applying wrappers do. + #[test] + fn should_record_a_keep_history_delete_through_entry_points_without_a_deleter() { + use crate::drive::document::lifecycle::DocumentLifecycleState; + use dpp::document::DocumentV0Getters; + + let platform_version = PlatformVersion::latest(); + let setup = || { + let drive = setup_drive_with_initial_state_structure(None); + let contract = setup_contract( + &drive, + "tests/supporting_files/contract/family/family-contract-with-history.json", + None, + None, + None::, + None, + None, + ); + let document_type = contract + .document_type_for_name("person") + .expect("expected to get document type"); + let owner_id = rand::thread_rng().gen::<[u8; 32]>(); + let person_document = json_document_to_document( + "tests/supporting_files/contract/family/person0.json", + Some(owner_id.into()), + document_type, + platform_version, + ) + .expect("expected to get document"); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo(( + &person_document, + Some(Cow::Owned(StorageFlags::SingleEpoch(0))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to insert a document successfully"); + (drive, contract, person_document.id()) + }; + let assert_deleted_at = |drive: &Drive, contract: &DataContract, document_id| { + let document_type = contract + .document_type_for_name("person") + .expect("expected to get document type"); + assert!( + matches!( + drive + .fetch_document_lifecycle( + contract, + document_type, + document_id, + None, + None, + platform_version, + ) + .expect("expected to read the lifecycle") + .0, + DocumentLifecycleState::Deleted(_) + ), + "the delete must record the lifecycle entry" + ); + let (_, record) = drive + .fetch_document_history( + &crate::query::document_history_drive_query::DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".to_string(), + document_id: document_id.to_buffer(), + filter: crate::query::document_history_drive_query::DocumentHistoryFilter::StartAtTime(0), + limit: Some(1), + }, + document_type, + None, + platform_version, + ) + .map(|history| (history.entries.len(), history.lifecycle)) + .expect("expected to read the history"); + assert_eq!( + record + .expect("the lifecycle is authenticated") + .times + .deleted_at_ms, + 1_000, + "the entry carries the deletion time the entry point was given" + ); + }; + + let (drive, contract, document_id) = setup(); + let document_type = contract + .document_type_for_name("person") + .expect("expected to get document type"); + let operations = drive + .delete_document_for_contract_operations( + document_id, + &contract, + document_type, + &BlockInfo::default_with_time(1_000), + None, + None, + &mut None, + None, + platform_version, + ) + .expect("expected the delete to build"); + drive + .apply_batch_low_level_drive_operations( + None, + None, + operations, + &mut vec![], + &platform_version.drive, + ) + .expect("expected the delete to apply"); + assert_deleted_at(&drive, &contract, document_id); + + let (drive, contract, document_id) = setup(); + let operations = drive + .delete_document_for_contract_with_named_type_operations( document_id, &contract, "person", - BlockInfo::default(), - true, + &BlockInfo::default_with_time(1_000), + None, + None, + &mut None, None, platform_version, ) - .expect_err("expected deleting a history-keeping document to fail"); + .expect("expected the delete to build"); + drive + .apply_batch_low_level_drive_operations( + None, + None, + operations, + &mut vec![], + &platform_version.drive, + ) + .expect("expected the delete to apply"); + assert_deleted_at(&drive, &contract, document_id); - assert!(matches!( - err, - Error::Drive(DriveError::InvalidDeletionOfDocumentThatKeepsHistory(_)) - )); + let (drive, contract, document_id) = setup(); + drive + .delete_document_for_contract_apply_and_add_to_operations( + document_id, + &contract, + "person", + &BlockInfo::default_with_time(1_000), + None, + None, + None, + &mut vec![], + platform_version, + ) + .expect("expected the delete to apply"); + assert_deleted_at(&drive, &contract, document_id); } // ---------- Error-path tests (added for coverage) ---------- @@ -1498,10 +1718,10 @@ mod tests { random_document_id, nonexistent_contract_id, "profile", - &epoch, + &BlockInfo::default_with_epoch(epoch), + None, None, &mut estimated_costs_only_with_layer_info, - 0, None, platform_version, ) diff --git a/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/mod.rs index 92a7f67d2aa..6d1773d5d94 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/mod.rs @@ -1,4 +1,5 @@ mod v0; +mod v1; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -53,9 +54,18 @@ impl Drive { batch_operations, platform_version, ), + 1 => self.remove_document_from_primary_storage_v1( + document_id, + document_type, + contract_documents_primary_key_path, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "remove_document_from_primary_storage".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } diff --git a/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/v1/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/v1/mod.rs new file mode 100644 index 00000000000..75ede4dfd10 --- /dev/null +++ b/packages/rs-drive/src/drive/document/delete/remove_document_from_primary_storage/v1/mod.rs @@ -0,0 +1,96 @@ +use crate::drive::document::primary_key_tree_type::DocumentTypePrimaryKeyTreeType; +use crate::util::estimated_layers::EstimatedLayers; + +use grovedb::{MaybeTree, TransactionArg}; + +use dpp::data_contract::document_type::DocumentTypeRef; + +use crate::util::grove_operations::BatchDeleteApplyType::{ + StatefulBatchDelete, StatelessBatchDelete, +}; + +use crate::drive::constants::DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE; +use crate::drive::document::uses_current_document_history_layout; +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; + +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::identifier::Identifier; + +use crate::util::type_constants::DEFAULT_HASH_SIZE_U32; +use dpp::version::PlatformVersion; + +impl Drive { + /// Removes one entry from a document type's primary-key tree. + /// + /// A keep-history type's entry is the document's current pointer, a + /// reference rather than an item, so the stateless size the dry run + /// charges comes from the reference shape. Removing it is still removing a + /// leaf: the revisions the pointer names live in the type's history tree, + /// which this never touches. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + pub(super) fn remove_document_from_primary_storage_v1( + &self, + document_id: Identifier, + document_type: DocumentTypeRef, + contract_documents_primary_key_path: [&[u8]; 5], + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + batch_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let keeps_history = document_type.documents_keep_history(); + if keeps_history && !uses_current_document_history_layout(platform_version)? { + // The legacy primary entry is the subtree holding its revisions. + // Only the composite layout stores a leaf pointer that can be + // removed without unlinking retained revisions. + return Err(Error::Drive(DriveError::CorruptedCodeExecution( + "a keep-history primary entry can only be removed where the current pointer \ + layout is in use", + ))); + } + + let primary_key_tree_type = document_type.primary_key_tree_type(platform_version)?; + + let apply_type = if estimated_costs_only_with_layer_info.is_some() { + StatelessBatchDelete { + in_tree_type: primary_key_tree_type, + estimated_key_size: DEFAULT_HASH_SIZE_U32, + estimated_value_size: if keeps_history { + DOCUMENT_HISTORY_CURRENT_REFERENCE_PATH_SIZE + } else { + document_type.estimated_size(platform_version)? as u32 + }, + } + } else { + // The entry is a document item, or a current pointer to one; never + // a tree. + StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some(MaybeTree::NotTree), + } + }; + self.batch_delete( + (&contract_documents_primary_key_path).into(), + document_id.as_slice(), + apply_type, + transaction, + batch_operations, + &platform_version.drive, + )?; + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_remove_document_to_primary_storage( + contract_documents_primary_key_path, + document_type, + estimated_costs_only_with_layer_info, + platform_version, + )?; + } + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/derived_index_values.rs b/packages/rs-drive/src/drive/document/derived_index_values.rs index c9a823228ff..e42e92e1e16 100644 --- a/packages/rs-drive/src/drive/document/derived_index_values.rs +++ b/packages/rs-drive/src/drive/document/derived_index_values.rs @@ -909,6 +909,131 @@ mod tests { assert!(replies_on(&drive, &contract, "rust").is_empty()); } + fn assert_current_insert_operations_preserved( + drive: &Drive, + contract: &DataContract, + type_name: &str, + document: &Document, + ) { + use crate::util::estimated_layers::EstimatedLayers; + for estimate in [false, true] { + let operations = |generation| { + let mut version = PlatformVersion::latest().clone(); + version + .drive + .methods + .document + .insert + .add_document_for_contract_operations = generation; + let mut layers = estimate.then(EstimatedLayers::new); + let operations = drive + .add_document_for_contract_operations( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo(( + document, + StorageFlags::optional_default_as_cow(), + )), + owner_id: Some(OWNER), + }, + contract, + document_type: contract.document_type_for_name(type_name).unwrap(), + }, + false, + &BlockInfo::default_with_time(CREATED_AT), + &mut None, + &mut layers, + None, + &version, + ) + .unwrap(); + if estimate { + let mut costs = vec![]; + drive + .apply_batch_low_level_drive_operations( + layers, + None, + operations, + &mut costs, + &version.drive, + ) + .unwrap(); + costs + } else { + operations + } + }; + assert_eq!( + operations(1), + operations(2), + "insert operations and priced estimates must remain equal, estimate={estimate}" + ); + } + } + + #[test] + fn should_preserve_current_insert_operations_for_derived_indices_and_ttl() { + let contract = contract(); + let drive = setup(&contract); + add(&drive, &contract, "post", &post(), true); + assert_current_insert_operations_preserved(&drive, &contract, "reply", &reply(2)); + + let contract = dpp::tests::json_document::json_document_to_contract( + "tests/supporting_files/contract/skip-if-absent/skip-memos-contract.json", + false, + PlatformVersion::latest(), + ) + .unwrap(); + let drive = setup(&contract); + let mut memo = document( + [3; 32], + BTreeMap::from([ + ("a".into(), Value::Text("a".into())), + ("b".into(), Value::Text("b".into())), + ("c".into(), Value::Text("c".into())), + ("d".into(), Value::Text("d".into())), + ]), + ); + memo.set_created_at(Some(CREATED_AT)); + assert_current_insert_operations_preserved(&drive, &contract, "memo", &memo); + } + + #[test] + fn should_remove_a_deleted_history_document_from_its_derived_index() { + let contract = contract_with( + Value::Null, + platform_value!([{ "postId.topic": "asc" }]), + platform_value!({ "documentsKeepHistory": true }), + ); + let drive = setup(&contract); + add(&drive, &contract, "post", &post(), true); + add(&drive, &contract, "reply", &reply(2), true); + assert_eq!( + replies_on(&drive, &contract, "rust"), + vec![Identifier::from([2; 32])] + ); + let price = |apply| { + drive + .delete_document_for_contract( + [2; 32].into(), + &contract, + "reply", + BlockInfo::default_with_time(CREATED_AT + 1), + apply, + None, + PlatformVersion::latest(), + ) + .unwrap() + }; + // Processing has wide headroom; storage is the tight side of this fee matrix. + let estimated = price(false); + let actual = price(true); + println!("delete derived-index: estimated storage={} processing={}, actual storage={} processing={}", estimated.storage_fee, estimated.processing_fee, actual.storage_fee, actual.processing_fee); + assert!(estimated.storage_fee >= actual.storage_fee); + assert!(estimated.processing_fee >= actual.processing_fee); + assert!(replies_on(&drive, &contract, "rust").is_empty()); + } + /// A document carrying its derived values, as a create does from its reference /// validation, is keyed by them without reading the referenced document: here there is /// none to read, and a read would find the state corrupted. diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_erase_document/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_erase_document/mod.rs new file mode 100644 index 00000000000..a41aae85f4a --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_erase_document/mod.rs @@ -0,0 +1,58 @@ +use crate::util::estimated_layers::EstimatedLayers; +mod v0; + +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +impl Drive { + /// Registers the layers an erase chunk touches. + /// + /// # Parameters + /// * `document_id`: The document whose revisions are being removed. + /// * `contract`: The contract that contains the document. + /// * `document_type`: The type of the document, which must keep history. + /// * `layers`: The estimated layer information the dry run builds. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(())` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub(crate) fn add_estimation_costs_for_erase_document( + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + layers: &mut EstimatedLayers, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .delete + .add_estimation_costs_for_erase_document + { + Some(0) => Self::add_estimation_costs_for_erase_document_v0( + document_id, + contract, + document_type, + layers, + platform_version, + ), + Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_estimation_costs_for_erase_document".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Drive(DriveError::VersionNotActive { + method: "add_estimation_costs_for_erase_document".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_erase_document/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_erase_document/v0/mod.rs new file mode 100644 index 00000000000..a4b8c9a01ec --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_erase_document/v0/mod.rs @@ -0,0 +1,93 @@ +use crate::util::estimated_layers::EstimatedLayers; + +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; +use grovedb::EstimatedLayerInformation; +use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; +use grovedb::EstimatedSumTrees::AllProvableCountTrees; +use grovedb::TreeType; + +use crate::drive::document::paths::{ + contract_document_type_path_vec, contract_documents_primary_key_path, DOCUMENT_HISTORY_TREE_KEY, +}; +use crate::drive::Drive; +use crate::error::Error; +use crate::util::storage_flags::StorageFlags; + +impl Drive { + /// Registers the layers an erase chunk touches: the type's history tree, + /// the document's own revision tree, and the lifecycle tree the record is + /// written to or removed from. + /// + /// The revision tree is sized for a document that may retain far more + /// revisions than a chunk removes, so its height is bounded rather than + /// derived from the chunk size; an estimate keyed to the chunk would + /// understate the merk path of a long history. + #[inline(always)] + pub(super) fn add_estimation_costs_for_erase_document_v0( + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + layers: &mut EstimatedLayers, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + contract, + layers, + &platform_version.drive, + )?; + Self::add_estimation_costs_for_lifecycle_record( + contract, + document_type, + layers, + platform_version, + )?; + Self::add_estimation_costs_for_remove_document_to_primary_storage( + contract_documents_primary_key_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ), + document_type, + layers, + platform_version, + )?; + + let flags_size = Some(StorageFlags::approximate_size(true, None)); + let mut history_root = contract_document_type_path_vec( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ); + history_root.push(vec![DOCUMENT_HISTORY_TREE_KEY]); + layers.insert( + KeyInfoPath::from_known_owned_path(history_root.clone()), + EstimatedLayerInformation { + tree_type: TreeType::NormalTree, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees(32, AllProvableCountTrees, flags_size), + }, + ); + + let mut history_path = history_root; + history_path.push(document_id.to_vec()); + layers.insert( + KeyInfoPath::from_known_owned_path(history_path), + EstimatedLayerInformation { + tree_type: TreeType::ProvableCountTree, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllItems( + 16, + document_type.max_size(platform_version)? as u32, + flags_size, + ), + }, + ); + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_lifecycle_record/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_lifecycle_record/mod.rs new file mode 100644 index 00000000000..4aed24e1fac --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_lifecycle_record/mod.rs @@ -0,0 +1,57 @@ +use crate::util::estimated_layers::EstimatedLayers; +mod v0; + +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::version::PlatformVersion; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +impl Drive { + /// Registers the layers a lifecycle record write or removal touches. + /// + /// The record is written by a delete of a keep-history document and + /// removed by the terminal erase chunk, so both estimate through this one + /// entry point; its own version slot keeps a later change to the layer + /// counts or record size from moving the estimates of the generations + /// that already rely on it. + /// + /// # Parameters + /// * `contract`: The contract that contains the document type. + /// * `document_type`: The type whose lifecycle tree holds the record. + /// * `layers`: The estimated layer information the dry run builds. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(())` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub(crate) fn add_estimation_costs_for_lifecycle_record( + contract: &DataContract, + document_type: DocumentTypeRef, + layers: &mut EstimatedLayers, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .delete + .add_estimation_costs_for_lifecycle_record + { + Some(0) => { + Self::add_estimation_costs_for_lifecycle_record_v0(contract, document_type, layers) + } + Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_estimation_costs_for_lifecycle_record".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Drive(DriveError::VersionNotActive { + method: "add_estimation_costs_for_lifecycle_record".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_lifecycle_record/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_lifecycle_record/v0/mod.rs new file mode 100644 index 00000000000..eb26c512935 --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_lifecycle_record/v0/mod.rs @@ -0,0 +1,61 @@ +use crate::util::estimated_layers::EstimatedLayers; + +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerInformation; +use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; +use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::TreeType; + +use crate::drive::document::paths::{contract_document_type_path_vec, document_lifecycle_path}; +use crate::drive::Drive; +use crate::error::Error; +use crate::util::storage_flags::StorageFlags; +use dpp::document::lifecycle::DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE; + +impl Drive { + /// Registers the layers a lifecycle record write or removal touches: the + /// document type itself, whose lifecycle tree may have to be created, and + /// the lifecycle tree holding one fixed-size record per deleted document. + /// + /// A dry run that leaves either layer unregistered fails outright, so both + /// are always registered even when the tree already exists. + pub(super) fn add_estimation_costs_for_lifecycle_record_v0( + contract: &DataContract, + document_type: DocumentTypeRef, + layers: &mut EstimatedLayers, + ) -> Result<(), Error> { + let flags_size = Some(StorageFlags::approximate_size(true, None)); + layers.insert( + KeyInfoPath::from_known_owned_path(contract_document_type_path_vec( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + )), + EstimatedLayerInformation { + tree_type: TreeType::NormalTree, + // The primary-key tree, the lifecycle tree, the history tree + // and one tree per index. + estimated_layer_count: ApproximateElements( + document_type.indexes().len() as u32 + 3, + ), + estimated_layer_sizes: AllSubtrees(1, NoSumTrees, flags_size), + }, + ); + layers.insert( + KeyInfoPath::from_known_owned_path(document_lifecycle_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + )), + EstimatedLayerInformation { + tree_type: TreeType::NormalTree, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllItems(32, DOCUMENT_LIFECYCLE_RECORD_MAX_SIZE, flags_size), + }, + ); + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs index 4a3acee1aed..d8e89847f8a 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs @@ -4,4 +4,8 @@ mod add_estimation_costs_for_add_document_to_primary_storage; mod add_estimation_costs_for_add_contested_document_to_primary_storage; +mod add_estimation_costs_for_lifecycle_record; + +mod add_estimation_costs_for_erase_document; + pub(crate) mod estimated_sum_trees_for_value_tree_type; diff --git a/packages/rs-drive/src/drive/document/insert/add_document_for_contract/time_range_index_e2e_tests.rs b/packages/rs-drive/src/drive/document/insert/add_document_for_contract/time_range_index_e2e_tests.rs index 7aa70a9d905..d3dedd231ce 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_for_contract/time_range_index_e2e_tests.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_for_contract/time_range_index_e2e_tests.rs @@ -501,6 +501,7 @@ fn assert_ttl_document_batch(case: TtlBatchCase, ttl: bool) { .map(|i| { DriveOperation::DocumentOperation(DocumentOperationType::DeleteDocument { document_id: docs[i].id(), + deleter_id: None, contract_info: DataContractInfo::BorrowedDataContract(&contract), document_type_info: DocumentTypeInfo::DocumentTypeRef(dt), }) @@ -673,10 +674,15 @@ fn should_apply_time_range_batches_through_raw_conversion_without_ttl() { /// without the caller's transaction. Neither refusal may leave a trace. #[test] fn raw_conversion_refuses_ttl_operations_and_requires_a_transaction() { + for pv in [PlatformVersion::get(14).unwrap(), PlatformVersion::latest()] { + assert_raw_conversion_refusals(pv); + } +} + +fn assert_raw_conversion_refusals(pv: &PlatformVersion) { use crate::error::drive::DriveError; use crate::util::batch::drive_op_batch::{DocumentOperationType, DriveOperation}; use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; - let pv = PlatformVersion::latest(); let drive = setup_drive_with_initial_state_structure(Some(pv)); let contract = build_ttl_contract_with_index_keys(230, vec![]); drive @@ -731,6 +737,7 @@ fn raw_conversion_refuses_ttl_operations_and_requires_a_transaction() { vec![DriveOperation::DocumentOperation( DocumentOperationType::DeleteDocument { document_id: doc.id(), + deleter_id: None, contract_info: DataContractInfo::BorrowedDataContract(&contract), document_type_info: DocumentTypeInfo::DocumentTypeRef(dt), }, @@ -3817,9 +3824,10 @@ fn ttl_budget_boundary_after_zero_tree_keeps_deletes_exact() { document.id(), &contract, document_type, + &BlockInfo::default_with_time(after_expiry_ms), + None, None, &mut None, - after_expiry_ms, None, platform_version, ) @@ -4873,6 +4881,7 @@ fn apply_drive_operations_rolls_back_ttl_preparation_when_conversion_fails_witho vec![DriveOperation::DocumentOperation( DocumentOperationType::DeleteDocument { document_id: missing, + deleter_id: None, contract_info: DataContractInfo::BorrowedDataContract(&contract), document_type_info: DocumentTypeInfo::DocumentTypeRef(document_type), }, diff --git a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/mod.rs index 66f5cfb1072..2981f99c4ce 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/mod.rs @@ -1,5 +1,6 @@ mod v0; mod v1; +mod v2; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -86,9 +87,21 @@ impl Drive { transaction, platform_version, ), + // v2: a fresh insert of a keep-history document never lets the + // caller's override skip the primary-storage checks, so a deleted + // document's retained revisions cannot be written over. + 2 => self.add_document_for_contract_operations_v2( + document_and_contract_info, + override_document, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_document_for_contract_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0, 1, 2], received: version, })), } diff --git a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v1/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v1/mod.rs index 7918056f35d..a3137b1a4e0 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v1/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v1/mod.rs @@ -313,7 +313,7 @@ impl Drive { /// the entry and the deletion its creation prepaid, and prices them the same way when it /// executes (`update_document_for_contract_operations` v1). #[allow(clippy::too_many_arguments)] - fn add_document_ttl_operations( + pub(super) fn add_document_ttl_operations( &self, document_and_contract_info: &DocumentAndContractInfo, ttl_seconds: u32, diff --git a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v2/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v2/mod.rs new file mode 100644 index 00000000000..162ca45fb00 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v2/mod.rs @@ -0,0 +1,272 @@ +use crate::drive::document::paths::contract_documents_primary_key_path; +use crate::drive::document::primary_key_tree_type::DocumentTypePrimaryKeyTreeType; +use crate::drive::Drive; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; +use crate::util::estimated_layers::EstimatedLayers; +use crate::util::grove_operations::DirectQueryType::{StatefulDirectQuery, StatelessDirectQuery}; +use crate::util::grove_operations::QueryTarget::QueryTargetValue; +use crate::util::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::{DocumentTypeV0Getters, DocumentTypeV2Getters}; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Gathers the operations to add a document to a contract. + /// + /// Uses the current insert operations, but reserves a retained history's id even + /// when the caller allows overwriting an existing document. Other types delegate + /// to generation 1, including its expiration and derived-index handling. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + pub(super) fn add_document_for_contract_operations_v2( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: &BlockInfo, + previous_batch_operations: &mut Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + if !document_and_contract_info + .document_type + .documents_keep_history() + { + return self.add_document_for_contract_operations_v1( + document_and_contract_info, + override_document, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ); + } + self.add_document_or_estimate_change_operations_v2( + document_and_contract_info, + override_document, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + false, + platform_version, + ) + } + + /// Prepares the insert, including its derived index values and expiration costs. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + fn add_document_or_estimate_change_operations_v2( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: &BlockInfo, + previous_batch_operations: &mut Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option, + transaction: TransactionArg, + estimates_a_change: bool, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut batch_operations: Vec = vec![]; + + // A document whose type declares a `ttl` is stored without storage flags. + let document_and_contract_info = + document_and_contract_info.without_storage_flags_if_expiring(); + + // indexOnly document types have no primary-storage row and no + // primary-key tree at all — the index entries are the rows, and + // updates are impossible by construction (immutable, no revision). + // `index_only()` can only be true on a PV14+ contract (the grammar + // rejects the keyword below meta-schema v3), so this branch is + // unreachable for every historical document. + if document_and_contract_info.document_type.index_only() { + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + document_and_contract_info.contract, + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + } + + self.add_indices_for_top_index_level_for_contract_operations( + &document_and_contract_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + block_info.time_ms, + transaction, + &mut batch_operations, + platform_version, + )?; + + self.add_preallocated_index_tree_operations_for_referring_types( + &document_and_contract_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + &mut batch_operations, + platform_version, + )?; + + return Ok(batch_operations); + } + + let primary_key_path = contract_documents_primary_key_path( + document_and_contract_info.contract.id_ref().as_bytes(), + document_and_contract_info.document_type.name().as_str(), + ); + + let primary_key_tree_type = document_and_contract_info + .document_type + .primary_key_tree_type(platform_version)?; + + // Apply means stateful query + let query_type = if estimated_costs_only_with_layer_info.is_none() { + StatefulDirectQuery + } else { + StatelessDirectQuery { + in_tree_type: primary_key_tree_type, + query_target: QueryTargetValue( + document_and_contract_info + .document_type + .estimated_size(platform_version)? as u32, + ), + } + }; + + // To update but not create: + + // 1. Override should be allowed + let could_be_update = override_document; + + // 2. Is not a dry run + let could_be_update = could_be_update + && !document_and_contract_info + .owned_document_info + .document_info + .is_document_size(); + + // 3. Document exists in storage + let is_update = could_be_update + && self.grove_has_raw( + primary_key_path.as_ref().into(), + document_and_contract_info + .owned_document_info + .document_info + .id_key_value_info() + .as_key_ref_request()?, + query_type, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + + if is_update { + let update_operations = self + .update_document_for_contract_operations_without_ttl_drain( + document_and_contract_info, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + + batch_operations.extend(update_operations); + + return Ok(batch_operations); + } + + // A type with derived index properties (protocol version 14) keys its documents by + // values read from the documents its references point at, which the document does not + // store: they are read here, before anything is keyed. Every other type passes through + // unchanged. + let document_and_contract_info = self.with_derived_index_values( + document_and_contract_info, + estimated_costs_only_with_layer_info.is_some(), + transaction, + &mut batch_operations, + platform_version, + )?; + + // if we are trying to get estimated costs we need to add the upper levels + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + document_and_contract_info.contract, + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + } + + // if we have override_document set that means we already checked if it exists + self.add_document_to_primary_storage( + &document_and_contract_info, + block_info, + override_document + && !document_and_contract_info + .document_type + .documents_keep_history(), + estimated_costs_only_with_layer_info, + transaction, + &mut batch_operations, + platform_version, + )?; + + self.add_indices_for_top_index_level_for_contract_operations( + &document_and_contract_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + block_info.time_ms, + transaction, + &mut batch_operations, + platform_version, + )?; + + // A document whose type declares a `ttl` also gets its expirations tree entry, pays + // for its bytes by the time it will live, and prepays its deletion. + if let Some(ttl_seconds) = document_and_contract_info + .document_type + .documents_ttl_seconds() + { + batch_operations = self.add_document_ttl_operations( + &document_and_contract_info, + ttl_seconds, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + estimates_a_change, + platform_version, + )?; + } + + // If any indexOnly document type of this contract carries a + // `preallocated` index bound to this document type through a + // refersTo declaration, create that index's trees for entries + // referencing this document now — see + // `add_preallocated_index_tree_operations`. A no-op for every + // contract without the (PV14+, indexOnly-only) flag. A change of + // the document preallocates nothing (its trees came with its + // creation, and an applied replace walks no preallocation), so its + // dry run leaves them out and still bounds what the change writes. + if !estimates_a_change { + self.add_preallocated_index_tree_operations_for_referring_types( + &document_and_contract_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + &mut batch_operations, + platform_version, + )?; + } + + Ok(batch_operations) + } +} diff --git a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v1/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v1/mod.rs index 5f06939e921..7b76dae5b9b 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v1/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v1/mod.rs @@ -100,7 +100,7 @@ impl Drive { BatchInsertTreeApplyType::StatefulBatchInsertTree }; if let Some(document) = document { - self.batch_insert_empty_tree_if_not_exists::<0>( + let created = self.batch_insert_empty_tree_if_not_exists::<0>( PathKey((history_root, document.id().to_vec())), TreeType::ProvableCountTree, flags, @@ -110,6 +110,21 @@ impl Drive { operations, version, )?; + // An id whose revisions are still retained is taken, even though + // nothing in the primary-key tree says so. Appending to that + // history would silently merge a new document into a deleted one's + // record, so it is refused here rather than only in transition + // validation: this is the guard that covers writers outside it. + // Only the update path asks to write without checks, and its + // document holds the id already, so its history is meant to exist; + // the insert path always lets this check run. + // A dry run skips the probe, which reports the tree as absent, and + // pays for it as a fixed cost so estimation and execution agree. + if !created && !insert_without_check { + return Err(Error::Drive(DriveError::CorruptedDocumentAlreadyExists( + "a document of this id still retains revisions and can not be created until they are erased", + ))); + } } else { operations.push( LowLevelDriveOperation::for_estimated_path_key_empty_provable_count_tree( diff --git a/packages/rs-drive/src/drive/document/insert/add_preallocated_index_tree_operations/tests.rs b/packages/rs-drive/src/drive/document/insert/add_preallocated_index_tree_operations/tests.rs index 40345dc8db6..6aa476bfc11 100644 --- a/packages/rs-drive/src/drive/document/insert/add_preallocated_index_tree_operations/tests.rs +++ b/packages/rs-drive/src/drive/document/insert/add_preallocated_index_tree_operations/tests.rs @@ -7,6 +7,7 @@ use dpp::document::{DocumentV0Getters, DocumentV0Setters}; use dpp::platform_value::Value; use dpp::prelude::DataContract; use dpp::tests::json_document::json_document_to_json_value; +use grovedb::batch::KeyInfoPath; use serde_json::json; #[test] diff --git a/packages/rs-drive/src/drive/document/lifecycle/erase_refund_recipient_cost/mod.rs b/packages/rs-drive/src/drive/document/lifecycle/erase_refund_recipient_cost/mod.rs new file mode 100644 index 00000000000..5f6b803b2b4 --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/erase_refund_recipient_cost/mod.rs @@ -0,0 +1,45 @@ +//! Version selection for pricing the balance work an erase causes. + +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::block::epoch::Epoch; +use dpp::fee::fee_result::FeeResult; +use dpp::version::PlatformVersion; + +impl Drive { + /// Prices the worst-case third-party balance updates caused by one erase. + /// + /// # Parameters + /// * `epoch`: The epoch whose fee schedule prices the recipient work. + /// * `platform_version`: Selects the method and the erase chunk bound. + /// + /// # Returns + /// The recipient-work fee without mutating balances, or an inactive/unknown version error. + pub fn erase_refund_recipient_cost( + &self, + epoch: &Epoch, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive + .methods + .document + .delete + .erase_refund_recipient_cost + { + Some(0) => self.erase_refund_recipient_cost_v0(epoch, platform_version), + Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "erase_refund_recipient_cost".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Drive(DriveError::VersionNotActive { + method: "erase_refund_recipient_cost".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/lifecycle/erase_refund_recipient_cost/v0/mod.rs b/packages/rs-drive/src/drive/document/lifecycle/erase_refund_recipient_cost/v0/mod.rs new file mode 100644 index 00000000000..110e2d25310 --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/erase_refund_recipient_cost/v0/mod.rs @@ -0,0 +1,75 @@ +//! Pricing for the balance work an erase's refunds cause outside its own fee. +//! +//! Refund credits are applied after the fee result is formed, as separate +//! balance operations against identities that had nothing to do with the +//! transition. A bound on how many revisions one erase removes limits that work +//! but does not pay for it, so it is priced here and billed to the submitter +//! through the execution context, which feeds both the admission estimate and +//! the fee actually charged. + +use crate::util::estimated_layers::EstimatedLayers; +use dpp::block::epoch::Epoch; +use dpp::fee::fee_result::FeeResult; +use dpp::version::PlatformVersion; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; + +/// Beneficiaries an erase can credit beyond the revisions themselves: the +/// lifecycle record's writer and the per-document history subtree's creator, +/// both of which a terminal chunk removes. Delete already removed the current +/// pointer, so erase cannot refund it again. +const STRUCTURAL_REFUND_RECIPIENTS: u64 = 2; + +impl Drive { + /// Prices the worst-case number of third-party balance updates one erase + /// can cause. + /// + /// Every recipient does the same shape of work — read the balance, read the + /// debt, write one or both — so the cost of one is measured through the + /// ordinary estimation path and multiplied by how many there can be. The + /// measurement performs no balance mutation and touches no real identity: + /// it runs the balance update in estimation mode, where the reads are + /// average-case costs rather than state. + pub(super) fn erase_refund_recipient_cost_v0( + &self, + epoch: &Epoch, + platform_version: &PlatformVersion, + ) -> Result { + let chunk = platform_version + .system_limits + .max_document_revisions_erased_per_transition + .ok_or(Error::Drive(DriveError::NotSupported( + "erasing retained revisions is not available at this protocol version", + )))?; + let recipients = chunk as u64 + STRUCTURAL_REFUND_RECIPIENTS; + + let mut layers: Option = Some(EstimatedLayers::new()); + let batch = self.add_to_identity_balance_operations( + [0u8; 32], + 1, + &mut layers, + None, + platform_version, + )?; + let mut operations: Vec = vec![]; + self.apply_batch_low_level_drive_operations( + layers, + None, + batch, + &mut operations, + &platform_version.drive, + )?; + let one = self.calculate_fee(None, Some(operations), epoch, platform_version)?; + + Ok(FeeResult { + storage_fee: one.storage_fee.saturating_mul(recipients), + processing_fee: one.processing_fee.saturating_mul(recipients), + fee_refunds: Default::default(), + removed_bytes_from_system: 0, + lifetime_storage_fees: Default::default(), + }) + } +} diff --git a/packages/rs-drive/src/drive/document/lifecycle/fetch/mod.rs b/packages/rs-drive/src/drive/document/lifecycle/fetch/mod.rs new file mode 100644 index 00000000000..3dce314e1a3 --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/fetch/mod.rs @@ -0,0 +1,91 @@ +mod v0; + +use dpp::block::epoch::Epoch; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::document::Document; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +/// Where one keep-history document stands in its lifecycle. +/// +/// Ordinary reads cannot tell a deleted document from one that never existed — +/// both are absent from the primary-key tree — so every check that must +/// distinguish them goes through this. +#[derive(Debug, Clone, PartialEq)] +pub enum DocumentLifecycleState { + /// The document is current and visible to ordinary reads. + Active(Box), + /// The document has been deleted and its revisions are retained. Carries + /// the newest of them, which is where a deleted document's owner is read + /// from. + Deleted(Box), + /// An authorized erasure has started and has not finished. Anyone may + /// continue it, so nothing about the document's owner is needed here. + Erasing, + /// No document, no retained revisions and no record: the id is free. + Absent, +} + +impl DocumentLifecycleState { + /// Whether the id is taken, which is what a create has to know. + pub fn is_present(&self) -> bool { + !matches!(self, DocumentLifecycleState::Absent) + } +} + +impl Drive { + /// Classifies one keep-history document as active, deleted, erasing or + /// absent, and returns the fee for the reads it performed. + /// + /// The reads are ordered by how likely they are to settle the question: the + /// ordinary by-id read answers it for every live document, and only a miss + /// pays for the lifecycle record. A deleted document costs one read more, + /// for the newest revision it retains. + /// + /// This is deliberately not folded into the by-id fetch every document + /// action already performs: only stateful validation of an action on a + /// keep-history type needs the extra reads, and every other document fetch + /// would otherwise pay for them. + pub fn fetch_document_lifecycle( + &self, + contract: &DataContract, + document_type: DocumentTypeRef, + document_id: Identifier, + epoch: Option<&Epoch>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(DocumentLifecycleState, FeeResult), Error> { + match platform_version + .drive + .methods + .document + .query + .fetch_document_lifecycle + { + Some(0) => self.fetch_document_lifecycle_v0( + contract, + document_type, + document_id, + epoch, + transaction, + platform_version, + ), + Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_document_lifecycle".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Drive(DriveError::VersionNotActive { + method: "fetch_document_lifecycle".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/lifecycle/fetch/v0/mod.rs b/packages/rs-drive/src/drive/document/lifecycle/fetch/v0/mod.rs new file mode 100644 index 00000000000..0dbc313e01c --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/fetch/v0/mod.rs @@ -0,0 +1,161 @@ +use dpp::block::epoch::Epoch; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::Document; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; +use grovedb::query_result_type::QueryResultType; +use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; + +use crate::drive::document::lifecycle::fetch::DocumentLifecycleState; +use crate::drive::document::paths::{ + contract_documents_primary_key_path, document_history_path, document_lifecycle_path, +}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; +use crate::util::grove_operations::{DirectQueryType, QueryType}; +use dpp::document::lifecycle::DocumentLifecycleRecord; +use dpp::serialization::PlatformDeserializableTrusted; + +impl Drive { + #[inline(always)] + pub(super) fn fetch_document_lifecycle_v0( + &self, + contract: &DataContract, + document_type: DocumentTypeRef, + document_id: Identifier, + epoch: Option<&Epoch>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(DocumentLifecycleState, FeeResult), Error> { + if !document_type.documents_keep_history() { + return Err(Error::Drive(DriveError::CorruptedCodeExecution( + "only a document type that keeps history has a lifecycle to fetch", + ))); + } + let mut operations: Vec = vec![]; + let state = self.read_document_lifecycle( + contract, + document_type, + document_id, + &mut operations, + transaction, + platform_version, + )?; + let fee = match epoch { + Some(epoch) => self.calculate_fee(None, Some(operations), epoch, platform_version)?, + None => FeeResult::default(), + }; + Ok((state, fee)) + } + + fn read_document_lifecycle( + &self, + contract: &DataContract, + document_type: DocumentTypeRef, + document_id: Identifier, + operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let primary_path = contract_documents_primary_key_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ); + let pointer = self.grove_get_raw_optional( + (&primary_path).into(), + document_id.as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + operations, + &platform_version.drive, + )?; + let lifecycle_path = + document_lifecycle_path(contract.id_ref().as_bytes(), document_type.name().as_str()); + // The lazily created lifecycle container may not exist yet. + let record_bytes = self.grove_get_raw_optional_item( + lifecycle_path.as_slice().into(), + document_id.as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + operations, + &platform_version.drive, + )?; + if pointer.is_some() && record_bytes.is_some() { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a document has both a current pointer and a lifecycle record".to_string(), + ))); + } + if pointer.is_some() { + let element = self + .grove_get( + (&primary_path).into(), + document_id.as_slice(), + QueryType::StatefulQuery, + transaction, + operations, + &platform_version.drive, + )? + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "a current pointer resolved to nothing".to_string(), + )))?; + let Element::Item(bytes, _) = element else { + return Err(Error::Drive(DriveError::CorruptedElementType( + "a current pointer did not resolve to a document", + ))); + }; + return Ok(DocumentLifecycleState::Active(Box::new( + Document::from_bytes(&bytes, document_type, platform_version)?, + ))); + } + + let Some(record_bytes) = record_bytes else { + return Ok(DocumentLifecycleState::Absent); + }; + let record = DocumentLifecycleRecord::deserialize_from_bytes_trusted(&record_bytes)?; + if !record.is_coherent() { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a lifecycle record is incoherent".to_string(), + ))); + } + if record.is_erasing() { + return Ok(DocumentLifecycleState::Erasing); + } + + // A deleted document's owner is read from the newest revision it still + // retains: a plain reverse range over the revision key space, immune to + // the composite-key bounds a time selector has to get right. + let mut query = Query::new_with_direction(false); + query.insert_all(); + let path_query = PathQuery::new( + document_history_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document_id.as_slice(), + ), + SizedQuery::new(query, Some(1), None), + ); + let (results, _) = self.grove_get_raw_path_query( + &path_query, + transaction, + QueryResultType::QueryKeyElementPairResultType, + operations, + &platform_version.drive, + )?; + let Some((_, Element::Item(bytes, _))) = results.to_key_elements().into_iter().next() + else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "a deleted document retains no revision to read its owner from".to_string(), + ))); + }; + Ok(DocumentLifecycleState::Deleted(Box::new( + Document::from_bytes(&bytes, document_type, platform_version)?, + ))) + } +} diff --git a/packages/rs-drive/src/drive/document/lifecycle/mod.rs b/packages/rs-drive/src/drive/document/lifecycle/mod.rs new file mode 100644 index 00000000000..e828af07420 --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/mod.rs @@ -0,0 +1,19 @@ +//! The per-type tree that holds the lifecycle records of keep-history +//! documents, and the reads over it. +//! +//! The record itself is `dpp::document::lifecycle::DocumentLifecycleRecord`. +//! It lives in its own tree under the document type rather than inside the +//! document's history, so every key in the history stays in the revision +//! domain and deleted documents stay enumerable per type. + +#[cfg(feature = "server")] +mod fetch; + +#[cfg(feature = "server")] +mod erase_refund_recipient_cost; + +#[cfg(all(test, feature = "server", feature = "verify"))] +mod tests; + +#[cfg(feature = "server")] +pub use fetch::DocumentLifecycleState; diff --git a/packages/rs-drive/src/drive/document/lifecycle/tests.rs b/packages/rs-drive/src/drive/document/lifecycle/tests.rs new file mode 100644 index 00000000000..d3945440d4d --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/tests.rs @@ -0,0 +1,3379 @@ +//! The storage side of the keep-history document lifecycle: what a delete +//! leaves behind, what an erase removes, and what a chunked erasure looks like +//! from one transition to the next. + +use super::fetch::DocumentLifecycleState; +use crate::drive::document::paths::{document_history_path, document_lifecycle_path}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::query::document_history_drive_query::{ + DocumentHistoryDriveQuery, DocumentHistoryFilter, DocumentHistoryLifecycle, + DocumentHistoryState, +}; +use crate::query::{ + DriveDocumentQuery, SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus, +}; +use crate::util::estimated_layers::EstimatedLayers; +use crate::util::grove_operations::BatchDeleteApplyType::StatefulBatchDelete; +use crate::util::object_size_info::{DocumentAndContractInfo, DocumentInfo, OwnedDocumentInfo}; +use crate::util::storage_flags::StorageFlags; +use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; +use dpp::block::block_info::BlockInfo; +use dpp::block::epoch::Epoch; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use dpp::document::lifecycle::DocumentLifecycleRecord; +use dpp::document::{DocumentV0Getters, DocumentV0Setters}; +use dpp::identifier::Identifier; +use dpp::serialization::PlatformDeserializableUntrusted; +use dpp::tests::json_document::{json_document_to_contract, json_document_to_document}; +use dpp::version::PlatformVersion; +use grovedb::{MaybeTree, TransactionArg, TreeType}; +use std::borrow::Cow; + +const FAMILY_HISTORY_CONTRACT: &str = + "tests/supporting_files/contract/family/family-contract-with-history.json"; +const PERSON: &str = "tests/supporting_files/contract/family/person0.json"; + +fn latest() -> &'static PlatformVersion { + PlatformVersion::latest() +} + +fn chunk_size() -> u64 { + latest() + .system_limits + .max_document_revisions_erased_per_transition + .expect("protocol 15 bounds the erase chunk") as u64 +} + +/// Applies the family contract and writes `revisions` revisions of one person, +/// each at its own block time so every revision key is distinct. +fn setup_history(revisions: u64, owner: [u8; 32]) -> (Drive, DataContract, Identifier) { + let version = latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract(FAMILY_HISTORY_CONTRACT, false, version) + .expect("expected the family history contract"); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .expect("expected to apply the contract"); + let document_type = contract + .document_type_for_name("person") + .expect("expected the person type"); + let mut document = + json_document_to_document(PERSON, Some(owner.into()), document_type, version) + .expect("expected a person document"); + let flags = Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))); + for revision in 1..=revisions { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, flags.clone())), + owner_id: None, + }, + contract: &contract, + document_type, + }, + revision > 1, + BlockInfo::default_with_time(1_000 + revision), + true, + None, + version, + ) + .expect("expected to write a revision"); + } + let id = document.id(); + (drive, contract, id) +} + +fn document_type_of(contract: &DataContract) -> DocumentTypeRef<'_> { + contract + .document_type_for_name("person") + .expect("expected the person type") +} + +fn lifecycle_of(drive: &Drive, contract: &DataContract, id: Identifier) -> DocumentLifecycleState { + drive + .fetch_document_lifecycle( + contract, + document_type_of(contract), + id, + None, + None, + latest(), + ) + .expect("expected to read the lifecycle") + .0 +} + +fn record_of( + drive: &Drive, + contract: &DataContract, + id: Identifier, +) -> Option { + let path = document_lifecycle_path(contract.id_ref().as_bytes(), "person"); + drive + .grove_get_raw_optional_item( + path.as_slice().into(), + id.as_slice(), + crate::util::grove_operations::DirectQueryType::StatefulDirectQuery, + None, + &mut vec![], + &latest().drive, + ) + .expect("expected to read the lifecycle tree") + .map(|bytes| { + DocumentLifecycleRecord::deserialize_from_bytes_untrusted(&bytes) + .expect("expected a valid record") + }) +} + +fn visible_document_count(drive: &Drive, contract: &DataContract) -> usize { + let query = DriveDocumentQuery::all_items_query(contract, document_type_of(contract), None); + query + .execute_raw_results_no_proof(drive, None, None, latest()) + .expect("expected to query documents") + .0 + .len() +} + +fn history_metadata( + drive: &Drive, + contract: &DataContract, + id: Identifier, +) -> DocumentHistoryLifecycle { + let query = DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(10), + }; + let page = drive + .fetch_document_history(&query, document_type_of(contract), None, latest()) + .expect("expected to fetch history"); + let proof = drive + .prove_document_history(&query, document_type_of(contract), None, latest()) + .expect("expected to prove history"); + let (_, verified) = + Drive::verify_document_history(&query, &proof, document_type_of(contract), latest()) + .expect("expected the proof to verify"); + assert_eq!( + verified, page, + "the proved history must match the read history" + ); + verified + .lifecycle + .expect("the latest protocol authenticates lifecycle metadata") +} + +fn delete( + drive: &Drive, + contract: &DataContract, + id: Identifier, + deleter: Identifier, + time_ms: u64, +) -> dpp::fee::fee_result::FeeResult { + let mut operations = vec![]; + let block_info = BlockInfo::default_with_time(time_ms); + let batch = drive + .delete_document_for_contract_operations( + id, + contract, + document_type_of(contract), + &block_info, + Some(deleter), + None, + &mut None, + None, + latest(), + ) + .expect("expected to build the delete operations"); + drive + .apply_batch_low_level_drive_operations(None, None, batch, &mut operations, &latest().drive) + .expect("expected to apply the delete"); + drive + .calculate_fee(None, Some(operations), &block_info.epoch, latest()) + .expect("expected a fee") +} + +fn erase( + drive: &Drive, + contract: &DataContract, + id: Identifier, + time_ms: u64, +) -> dpp::fee::fee_result::FeeResult { + let mut operations = vec![]; + let block_info = BlockInfo::default_with_time(time_ms); + let batch = drive + .erase_document_for_contract_operations( + id, + contract, + document_type_of(contract), + &block_info, + &mut None, + None, + latest(), + ) + .expect("expected to build the erase operations"); + drive + .apply_batch_low_level_drive_operations(None, None, batch, &mut operations, &latest().drive) + .expect("expected to apply the erase"); + drive + .calculate_fee(None, Some(operations), &block_info.epoch, latest()) + .expect("expected a fee") +} + +/// The admission estimate of an erase, which knows nothing about the document +/// it will act on. +fn estimated_erase_fee( + drive: &Drive, + contract: &DataContract, + id: Identifier, +) -> dpp::fee::fee_result::FeeResult { + let mut operations = vec![]; + let mut layers = Some(EstimatedLayers::new()); + let block_info = BlockInfo::default_with_time(9_000); + let batch = drive + .erase_document_for_contract_operations( + id, + contract, + document_type_of(contract), + &block_info, + &mut layers, + None, + latest(), + ) + .expect("expected to build the estimated erase operations"); + drive + .apply_batch_low_level_drive_operations( + layers, + None, + batch, + &mut operations, + &latest().drive, + ) + .expect("expected to price the erase"); + drive + .calculate_fee(None, Some(operations), &block_info.epoch, latest()) + .expect("expected a fee") +} + +#[test] +fn should_hide_a_deleted_document_while_keeping_every_revision_readable() { + let owner = [7u8; 32]; + let (drive, contract, id) = setup_history(3, owner); + assert_eq!(visible_document_count(&drive, &contract), 1); + + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + assert_eq!( + visible_document_count(&drive, &contract), + 0, + "a deleted document must be absent from every ordinary read" + ); + let record = record_of(&drive, &contract, id).expect("a delete writes a lifecycle record"); + assert_eq!(record.deleted_at_ms(), 5_000); + assert!(!record.is_erasing()); + + let lifecycle = history_metadata(&drive, &contract, id); + assert_eq!(lifecycle.state, DocumentHistoryState::Deleted); + assert_eq!( + lifecycle.remaining_revisions, 3, + "a delete removes no revision" + ); + assert_eq!(lifecycle.times.deleted_at_ms, 5_000); + assert_eq!(lifecycle.times.erasing_started_at_ms, 0); + + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Deleted(_) + )); +} + +#[test] +fn should_erase_a_history_shorter_than_a_chunk_in_one_transition() { + let owner = [8u8; 32]; + let (drive, contract, id) = setup_history(1, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + erase(&drive, &contract, id, 6_000); + + assert!( + record_of(&drive, &contract, id).is_none(), + "the terminal chunk removes the record" + ); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Absent + )); + let lifecycle = history_metadata(&drive, &contract, id); + assert_eq!(lifecycle.state, DocumentHistoryState::Absent); + assert_eq!(lifecycle.remaining_revisions, 0); +} + +#[test] +fn should_erase_a_history_of_exactly_one_chunk_in_one_transition() { + let chunk = chunk_size(); + let owner = [9u8; 32]; + let (drive, contract, id) = setup_history(chunk, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + erase(&drive, &contract, id, 6_000); + + assert!(record_of(&drive, &contract, id).is_none()); + assert_eq!( + history_metadata(&drive, &contract, id).state, + DocumentHistoryState::Absent + ); +} + +#[test] +fn should_commit_a_longer_history_to_erasure_and_finish_it_in_the_next_chunk() { + let chunk = chunk_size(); + let owner = [10u8; 32]; + let (drive, contract, id) = setup_history(chunk + 1, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + erase(&drive, &contract, id, 6_000); + + let record = record_of(&drive, &contract, id).expect("a partial chunk keeps the record"); + assert!(record.is_erasing(), "the first chunk commits the erasure"); + assert_eq!(record.deleted_at_ms(), 5_000, "the deletion time survives"); + assert_eq!(record.erasing_started_at_ms(), 6_000); + assert_eq!( + record.erasing_from_revision(), + chunk + 1, + "the erasure started from the newest revision" + ); + assert_eq!(record.erasing_from_time_ms(), 1_000 + chunk + 1); + + let lifecycle = history_metadata(&drive, &contract, id); + assert_eq!(lifecycle.state, DocumentHistoryState::Erasing); + assert_eq!( + lifecycle.remaining_revisions, 1, + "the oldest revision is what a partial erasure leaves behind" + ); + assert_eq!(lifecycle.times.erasing_from_revision, chunk + 1); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Erasing + )); + + erase(&drive, &contract, id, 7_000); + + assert!(record_of(&drive, &contract, id).is_none()); + assert_eq!( + history_metadata(&drive, &contract, id).state, + DocumentHistoryState::Absent + ); +} + +#[test] +fn should_leave_the_record_untouched_across_a_continuation() { + let chunk = chunk_size(); + let owner = [11u8; 32]; + let (drive, contract, id) = setup_history(chunk * 2 + 1, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + erase(&drive, &contract, id, 6_000); + let after_start = record_of(&drive, &contract, id).expect("the erasure is committed"); + + erase(&drive, &contract, id, 7_000); + let after_continuation = + record_of(&drive, &contract, id).expect("the erasure is not finished yet"); + + assert_eq!( + after_start, after_continuation, + "a continuation carries no authorization of its own and writes nothing to the record" + ); + assert_eq!( + history_metadata(&drive, &contract, id).remaining_revisions, + 1 + ); + + erase(&drive, &contract, id, 8_000); + assert_eq!( + history_metadata(&drive, &contract, id).state, + DocumentHistoryState::Absent + ); +} + +#[test] +fn should_refuse_to_create_a_document_whose_revisions_are_still_retained() { + let owner = [12u8; 32]; + let (drive, contract, id) = setup_history(2, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let version = latest(); + let document_type = document_type_of(&contract); + let mut document = + json_document_to_document(PERSON, Some(owner.into()), document_type, version).unwrap(); + document.set_revision(Some(1)); + + let error = drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + // The contested award path reaches the writer this way: nothing + // above it has checked whether the id is free. + false, + BlockInfo::default_with_time(6_000), + true, + None, + version, + ) + .expect_err("a reserved id must not be creatable"); + assert!(matches!( + error, + Error::Drive(DriveError::CorruptedDocumentAlreadyExists(_)) + )); + + // Once the revisions are gone the id is free again. + erase(&drive, &contract, id, 7_000); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(8_000), + true, + None, + version, + ) + .expect("an erased id is reusable"); + assert_eq!(visible_document_count(&drive, &contract), 1); +} + +/// `override_document` tells the writer the caller has already checked the +/// primary-key entry, so it may skip that check on the current pointer. A +/// deleted document has no current pointer but still retains its revisions, +/// and nothing the caller checked says so; the retained-history refusal must +/// therefore hold whatever the caller claims about the pointer. +#[test] +fn should_refuse_to_create_over_retained_revisions_even_when_the_caller_overrides() { + let owner = [14u8; 32]; + let (drive, contract, id) = setup_history(2, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let version = latest(); + let document_type = document_type_of(&contract); + let mut document = + json_document_to_document(PERSON, Some(owner.into()), document_type, version).unwrap(); + document.set_revision(Some(1)); + + let error = drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + true, + BlockInfo::default_with_time(6_000), + true, + None, + version, + ) + .expect_err("an override must not merge a new document into a deleted one's history"); + assert!(matches!( + error, + Error::Drive(DriveError::CorruptedDocumentAlreadyExists(_)) + )); + assert_eq!( + history_metadata(&drive, &contract, id).remaining_revisions, + 2, + "the refused write must leave the retained history untouched" + ); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Deleted(_) + )); +} + +#[test] +fn should_refuse_to_drop_a_history_subtree_while_a_revision_survives() { + let owner = [13u8; 32]; + let (drive, contract, id) = setup_history(2, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + // The removal of the subtree on its own, without the revision deletes an + // erase puts in the same batch. GroveDB has nothing to conclude emptiness + // from and must refuse rather than orphan the revisions' storage. + let mut history_root = document_history_path(contract.id_ref().as_bytes(), "person", &[]); + history_root.pop(); + let mut operations = vec![]; + let batch_result = drive.batch_delete( + history_root.as_slice().into(), + id.as_slice(), + StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some(MaybeTree::Tree(TreeType::ProvableCountTree)), + }, + None, + &mut operations, + &latest().drive, + ); + assert!( + batch_result.is_err(), + "a populated history subtree must not be removable" + ); +} + +#[test] +fn should_refund_each_removed_revision_to_the_identity_that_wrote_it() { + let owner = [14u8; 32]; + let deleter = [80u8; 32]; + let (drive, contract, id) = setup_history(3, owner); + delete(&drive, &contract, id, Identifier::new(deleter), 5_000); + let record_refunds = isolated_record_removal_refunds(&drive, &contract, id); + + let fee = erase(&drive, &contract, id, 6_000); + + let refunded: u64 = fee + .fee_refunds + .0 + .get(&owner) + .map(|per_epoch| per_epoch.values().sum()) + .unwrap_or_default(); + assert!( + refunded > 0, + "the revisions' writer must be credited for the bytes the erase removed" + ); + assert_eq!( + fee.fee_refunds.0.get(&deleter), + record_refunds.0.get(&deleter) + ); + assert!(record_refunds.0.contains_key(&deleter)); +} + +fn isolated_record_removal_refunds( + drive: &Drive, + contract: &DataContract, + id: Identifier, +) -> dpp::fee::fee_result::refunds::FeeRefunds { + let transaction = drive.grove.start_transaction(); + let mut batch = vec![]; + drive + .batch_delete( + document_lifecycle_path(contract.id_ref().as_bytes(), "person") + .as_slice() + .into(), + id.as_slice(), + StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some(MaybeTree::NotTree), + }, + Some(&transaction), + &mut batch, + &latest().drive, + ) + .unwrap(); + let mut operations = vec![]; + drive + .apply_batch_low_level_drive_operations( + None, + Some(&transaction), + batch, + &mut operations, + &latest().drive, + ) + .unwrap(); + drive + .calculate_fee( + None, + Some(operations), + &BlockInfo::default_with_time(6_000).epoch, + latest(), + ) + .unwrap() + .fee_refunds +} + +#[test] +fn should_price_an_erase_for_a_full_chunk_whatever_the_document_retains() { + let chunk = chunk_size(); + for revisions in [1, chunk, chunk + 1] { + let owner = [15u8; 32]; + let (drive, contract, id) = setup_history(revisions, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let estimated = estimated_erase_fee(&drive, &contract, id); + let actual = erase(&drive, &contract, id, 6_000); + + assert!( + estimated.storage_fee >= actual.storage_fee, + "the storage estimate under-charged a {revisions}-revision erase: {} < {}", + estimated.storage_fee, + actual.storage_fee + ); + assert!( + estimated.processing_fee >= actual.processing_fee, + "the admission estimate under-charged a {revisions}-revision erase: {} < {}", + estimated.processing_fee, + actual.processing_fee + ); + } +} + +/// The history a delete leaves behind is still fully readable, page by page and +/// with a proof, including the page that runs past its end. +#[test] +fn should_page_and_prove_the_history_of_a_deleted_document() { + let owner = [16u8; 32]; + let (drive, contract, id) = setup_history(12, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let mut selector = DocumentHistoryFilter::StartAtTime(0); + let mut seen = vec![]; + loop { + let query = DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + filter: selector, + limit: Some(10), + }; + let page = drive + .fetch_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to fetch a page"); + let proof = drive + .prove_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to prove a page"); + let (_, verified) = + Drive::verify_document_history(&query, &proof, document_type_of(&contract), latest()) + .expect("expected the page proof to verify"); + let lifecycle = verified + .lifecycle + .expect("the latest protocol authenticates lifecycle metadata"); + assert_eq!(lifecycle.state, DocumentHistoryState::Deleted); + assert_eq!(lifecycle.remaining_revisions, 12); + assert_eq!(lifecycle.times.deleted_at_ms, 5_000); + seen.extend(page.entries.iter().map(|entry| entry.revision)); + let Some(last) = page.entries.last() else { + break; + }; + selector = DocumentHistoryFilter::StartAfter { + time_ms: last.time_ms, + revision: last.revision, + }; + } + assert_eq!(seen, (1..=12).collect::>()); +} + +/// Every document type parsed by an earlier grammar has no lifecycle tree, so +/// the read has to treat a missing tree the same as a missing key. +#[test] +fn should_report_a_document_with_no_lifecycle_tree_as_absent() { + let owner = [17u8; 32]; + let (drive, contract, _) = setup_history(1, owner); + let unknown = Identifier::new([99u8; 32]); + assert!(matches!( + lifecycle_of(&drive, &contract, unknown), + DocumentLifecycleState::Absent + )); +} + +#[test] +fn should_reject_an_erase_of_a_document_that_retains_nothing() { + let owner = [18u8; 32]; + let (drive, contract, id) = setup_history(1, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + erase(&drive, &contract, id, 6_000); + + let error = drive + .erase_document_for_contract_operations( + id, + &contract, + document_type_of(&contract), + &BlockInfo::default_with_time(7_000), + &mut None, + None as TransactionArg, + latest(), + ) + .expect_err("there is nothing left to erase"); + // The terminal chunk removed the record along with the revisions, so the + // id reads as never deleted and the refusal is the not-deleted one. + assert!(matches!(error, Error::Drive(DriveError::InvalidInput(_)))); +} + +/// The two record shapes must occupy the same number of bytes: an erase start +/// overwrites the record in place, and a different size would re-price its +/// storage and drop the deleter's flags. +#[test] +fn should_keep_the_deleter_as_the_records_beneficiary_across_an_erase_start() { + let chunk = chunk_size(); + let owner = [19u8; 32]; + let deleter = Identifier::new([20u8; 32]); + let (drive, contract, id) = setup_history(chunk + 1, owner); + delete(&drive, &contract, id, deleter, 5_000); + + let path = document_lifecycle_path(contract.id_ref().as_bytes(), "person"); + let flags_before = drive + .grove + .get_raw( + path.as_slice().into(), + id.as_slice(), + None, + &latest().drive.grove_version, + ) + .unwrap() + .expect("the record exists"); + + erase(&drive, &contract, id, 6_000); + + let flags_after = drive + .grove + .get_raw( + path.as_slice().into(), + id.as_slice(), + None, + &latest().drive.grove_version, + ) + .unwrap() + .expect("the record survives a partial erasure"); + let (grovedb::Element::Item(before, before_flags), grovedb::Element::Item(after, after_flags)) = + (flags_before, flags_after) + else { + panic!("a lifecycle record is an item"); + }; + assert_ne!(before, after, "the erase start rewrote the record"); + assert_eq!( + before_flags, after_flags, + "the deleter must stay the beneficiary of the record's bytes" + ); +} + +/// A revision written by one identity and a revision written by another are +/// refunded separately, so an erasure credits whoever paid for each byte. +#[test] +fn should_refund_distinct_writers_separately() { + let first = [21u8; 32]; + let second = [22u8; 32]; + let deleter = [81u8; 32]; + let version = latest(); + let (drive, contract, id) = setup_history(1, first); + let document_type = document_type_of(&contract); + let mut document = + json_document_to_document(PERSON, Some(first.into()), document_type, version).unwrap(); + document.set_revision(Some(2)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(second)))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + true, + BlockInfo::default_with_time(2_000), + true, + None, + version, + ) + .expect("expected a second writer's revision"); + + delete(&drive, &contract, id, Identifier::new(deleter), 5_000); + let record_refunds = isolated_record_removal_refunds(&drive, &contract, id); + let fee = erase(&drive, &contract, id, 6_000); + + assert!( + fee.fee_refunds.0.contains_key(&first) && fee.fee_refunds.0.contains_key(&second), + "each writer must be credited for the revision they paid for; got {:?}", + fee.fee_refunds.0.keys().collect::>() + ); + assert_eq!( + fee.fee_refunds.0.get(&deleter), + record_refunds.0.get(&deleter) + ); + assert!(record_refunds.0.contains_key(&deleter)); +} + +#[test] +fn should_read_the_newest_retained_revision_of_a_deleted_document() { + let owner = [23u8; 32]; + let (drive, contract, id) = setup_history(4, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let DocumentLifecycleState::Deleted(newest) = lifecycle_of(&drive, &contract, id) else { + panic!("expected a deleted document"); + }; + assert_eq!( + newest.revision(), + Some(4), + "an erase start is authorized against the newest revision that survives" + ); + assert_eq!(newest.owner_id().to_buffer(), owner); +} + +/// A `Document` is only ever written under a keep-history type through the +/// history tree, so a deleted document's revisions must not be reachable by id. +#[test] +fn should_not_resolve_a_deleted_document_by_id() { + let owner = [24u8; 32]; + let (drive, contract, id) = setup_history(2, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let query = SingleDocumentDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_type_keeps_history: true, + document_id: id.to_buffer(), + block_time_ms: None, + contested_status: SingleDocumentDriveQueryContestedStatus::NotContested, + }; + let path_query = query + .construct_path_query(latest()) + .expect("expected a by-id path query"); + let (results, _) = drive + .grove_get_raw_path_query( + &path_query, + None, + grovedb::query_result_type::QueryResultType::QueryKeyElementPairResultType, + &mut vec![], + &latest().drive, + ) + .expect("expected the by-id read to run"); + assert!( + results.to_key_elements().is_empty(), + "a deleted document is not fetchable by id" + ); +} + +/// The counted and summed entry of a keep-history type is its current pointer, +/// so removing it decrements both aggregates by construction and a deleted +/// document stops contributing without any bookkeeping of its own. +#[test] +fn should_decrement_the_count_and_the_sum_when_a_keep_history_document_is_deleted() { + use crate::drive::document::paths::contract_document_type_path_vec; + use dpp::data_contract::document_type::accessors::DocumentTypeV2Getters; + use dpp::data_contract::DataContractFactory; + use dpp::document::document_factory::DocumentFactory; + use dpp::platform_value::platform_value; + use grovedb::Element; + + let version = latest(); + let schema = platform_value!({ + "type": "object", + "documentsKeepHistory": true, + "canBeDeleted": true, + "documentsCountable": true, + "documentsSummable": "amount", + "properties": { + "amount": {"type": "integer", "minimum": 0, "maximum": 4294967295i64, "position": 0}, + }, + "required": ["amount"], + "additionalProperties": false, + "indices": [{"name": "amount", "properties": [{"amount": "asc"}]}], + }); + let contract = DataContractFactory::new(version.protocol_version) + .expect("expected a contract factory") + .create_with_value_config( + [7; 32].into(), + 0, + platform_value!({ "tip": schema }), + None, + None, + ) + .expect("a countable summable keep-history type must parse") + .data_contract_owned(); + + let drive = setup_drive_with_initial_state_structure(None); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .expect("expected to apply the contract"); + let document_type = contract + .document_type_for_name("tip") + .expect("expected the tip type"); + assert!(document_type.documents_countable()); + + let mut document = DocumentFactory::new(version.protocol_version) + .expect("expected a document factory") + .create_document( + &contract, + [7; 32].into(), + "tip".into(), + platform_value!({"amount": 5}), + ) + .expect("expected a tip"); + document.set_id([9; 32].into()); + for revision in 1..=3u64 { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + revision > 1, + BlockInfo::default_with_time(1_000 + revision), + true, + None, + version, + ) + .expect("expected to write a revision"); + } + + let type_path = contract_document_type_path_vec(contract.id_ref().as_bytes(), "tip"); + let aggregates = || { + let element = drive + .grove + .get_raw( + type_path.as_slice().into(), + &[0], + None, + &latest().drive.grove_version, + ) + .value + .expect("expected the primary-key tree"); + let Element::CountSumTree(_, count, sum, _) = element else { + panic!("a countable summable type stores its documents in a count-sum tree"); + }; + (count, sum) + }; + assert_eq!( + aggregates(), + (1, 5), + "one live document contributing its amount, whatever its history holds" + ); + + let batch = drive + .delete_document_for_contract_operations( + document.id(), + &contract, + document_type, + &BlockInfo::default_with_time(5_000), + Some(Identifier::new([7; 32])), + None, + &mut None, + None, + version, + ) + .expect("expected to delete"); + drive + .apply_batch_low_level_drive_operations(None, None, batch, &mut vec![], &version.drive) + .expect("expected to apply the delete"); + + assert_eq!( + aggregates(), + (0, 0), + "a deleted document contributes to neither aggregate, though its revisions remain" + ); + + // Its index entries are gone too, so the value it held is free for another + // document to take. + let mut index_path = type_path.clone(); + index_path.push(b"amount".to_vec()); + let mut query = grovedb::Query::new(); + query.insert_all(); + let (results, _) = drive + .grove_get_raw_path_query( + &grovedb::PathQuery::new(index_path, grovedb::SizedQuery::new(query, Some(10), None)), + None, + grovedb::query_result_type::QueryResultType::QueryKeyElementPairResultType, + &mut vec![], + &version.drive, + ) + .expect("expected to read the index"); + assert!( + results.to_key_elements().is_empty(), + "a delete removes every index reference that led to the document" + ); +} + +/// The per-type container is shared by every document of the type and outlives +/// any one of them, so it belongs to nobody: an erase removes records and +/// per-document history trees, never this. The record inside it is the byte an +/// erase does refund, and that one names the deleter. +#[test] +fn should_leave_the_lifecycle_container_unflagged_while_the_record_names_the_deleter() { + use crate::drive::document::paths::contract_document_type_path_vec; + + let owner = [25u8; 32]; + let deleter = Identifier::new([26u8; 32]); + let (drive, contract, id) = setup_history(2, owner); + delete(&drive, &contract, id, deleter, 5_000); + + let mut type_path = contract_document_type_path_vec(contract.id_ref().as_bytes(), "person"); + let container = drive + .grove + .get_raw( + type_path.as_slice().into(), + &[crate::drive::document::paths::DOCUMENT_LIFECYCLE_TREE_KEY], + None, + &latest().drive.grove_version, + ) + .value + .expect("the first delete creates the container"); + assert_eq!( + container.get_flags(), + &None, + "the shared container must belong to nobody" + ); + + type_path.push(vec![ + crate::drive::document::paths::DOCUMENT_LIFECYCLE_TREE_KEY, + ]); + let record = drive + .grove + .get_raw( + type_path.as_slice().into(), + id.as_slice(), + None, + &latest().drive.grove_version, + ) + .value + .expect("the record exists"); + let flags = StorageFlags::map_cow_some_element_flags_ref(record.get_flags()) + .expect("the record's flags must decode") + .expect("the record names its deleter"); + assert_eq!( + flags.owner_id(), + Some(&deleter.to_buffer()), + "the record is the byte an erase refunds, and it belongs to the deleter" + ); +} + +/// Only the first delete of a type pays for the container. A second one finds +/// it already there and pays for its record alone, so the storage difference +/// between the two is exactly the container. +#[test] +fn should_charge_the_container_to_the_first_delete_of_a_type_only() { + let owner = [27u8; 32]; + let version = latest(); + let (drive, contract, first_id) = setup_history(1, owner); + let document_type = document_type_of(&contract); + + // A second document of the same type, so the second delete finds the + // container already in place. + let mut second = + json_document_to_document(PERSON, Some(owner.into()), document_type, version).unwrap(); + second.set_id(Identifier::new([28u8; 32])); + second.set_revision(Some(1)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &second, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(2_000), + true, + None, + version, + ) + .expect("expected a second document"); + + let deleter = Identifier::new([29u8; 32]); + let first = delete(&drive, &contract, first_id, deleter, 5_000); + let later = delete(&drive, &contract, second.id(), deleter, 6_000); + + assert!( + first.storage_fee > later.storage_fee, + "the first delete pays for the container as well as its record: {} vs {}", + first.storage_fee, + later.storage_fee + ); +} + +/// The declared feature slot has to actually route: a table that selects a +/// version this code does not implement must fail loudly rather than silently +/// keep using the old estimate. +#[test] +fn should_reject_an_unsupported_erase_estimation_version() { + use crate::util::estimated_layers::EstimatedLayers; + + let owner = [30u8; 32]; + let (_drive, contract, id) = setup_history(1, owner); + let mut version = latest().clone(); + assert_eq!( + version + .drive + .methods + .document + .delete + .add_estimation_costs_for_erase_document, + Some(0), + "protocol 15 selects the only implementation there is" + ); + version + .drive + .methods + .document + .delete + .add_estimation_costs_for_erase_document = Some(1); + + let error = Drive::add_estimation_costs_for_erase_document( + id, + &contract, + document_type_of(&contract), + &mut EstimatedLayers::new(), + &version, + ) + .expect_err("an unimplemented version must be refused"); + assert!(matches!( + error, + Error::Drive(DriveError::UnknownVersionMismatch { .. }) + )); +} + +/// The recipient work is priced from the ordinary balance-update path and +/// scales with the number of beneficiaries one erase can credit, without +/// touching any identity's balance. +#[test] +fn should_price_the_refund_recipients_an_erase_can_credit() { + use dpp::block::epoch::Epoch; + + let drive = setup_drive_with_initial_state_structure(None); + let epoch = Epoch::new(0).unwrap(); + let version = latest(); + + let priced = drive + .erase_refund_recipient_cost(&epoch, version) + .expect("expected a price for the recipient work"); + assert!( + priced.processing_fee > 0, + "crediting a beneficiary is work somebody has to pay for" + ); + assert!( + priced.fee_refunds.0.is_empty() && priced.storage_fee == 0, + "pricing must not invent a refund or a storage charge of its own" + ); + + let mut no_revisions = version.clone(); + no_revisions + .system_limits + .max_document_revisions_erased_per_transition = Some(0); + let structural = drive + .erase_refund_recipient_cost(&epoch, &no_revisions) + .expect("expected the structural-recipient price"); + let mut one_revision = no_revisions.clone(); + one_revision + .system_limits + .max_document_revisions_erased_per_transition = Some(1); + let with_one_revision = drive + .erase_refund_recipient_cost(&epoch, &one_revision) + .expect("expected the one-revision price"); + let one_recipient = with_one_revision + .processing_fee + .checked_sub(structural.processing_fee) + .expect("one additional recipient increases the price"); + assert_eq!( + structural.processing_fee, + one_recipient * 2, + "terminal erase refunds only the lifecycle record and history subtree" + ); + assert_eq!( + priced.processing_fee, + one_recipient * (chunk_size() + 2), + "the full estimate prices every revision plus two structural recipients" + ); + + // Every balance in the drive is untouched: this is a measurement, not a + // mutation. + assert!( + drive + .fetch_identity_balance(default_owner_id(), None, version) + .expect("expected the balance read to run") + .is_none(), + "pricing must not create the identity it measures against" + ); +} + +/// The synthetic identity the price is measured against. +fn default_owner_id() -> [u8; 32] { + [0u8; 32] +} + +/// Revisions written in different epochs are refunded under the epoch each was +/// written in, and the payout tail decides the amount: a byte written recently +/// has more of its one-time charge still unspent than one written long ago, so +/// it refunds more. +#[test] +fn should_refund_each_writer_under_the_epoch_they_wrote_in() { + use dpp::block::epoch::Epoch; + + let early_writer = [40u8; 32]; + let late_writer = [41u8; 32]; + let version = latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract(FAMILY_HISTORY_CONTRACT, false, version).unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .expect("expected to apply the contract"); + let document_type = document_type_of(&contract); + let mut document = + json_document_to_document(PERSON, Some(early_writer.into()), document_type, version) + .unwrap(); + + let write = |revision: u64, writer: [u8; 32], epoch_index: u16, first: bool| { + let mut document = document.clone(); + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + Some(Cow::Owned(StorageFlags::new_single_epoch( + epoch_index, + Some(writer), + ))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + !first, + BlockInfo { + epoch: Epoch::new(epoch_index).unwrap(), + ..BlockInfo::default_with_time(1_000 + revision) + }, + true, + None, + version, + ) + .expect("expected to write a revision"); + }; + // The first revision also creates the document's history subtree and its + // index references, so it is not the same amount of storage as an appended + // one. A third identity pays for it, leaving the two compared below as one + // appended revision each and differing only in the epoch they landed in. + write(1, [39u8; 32], 0, true); + write(2, early_writer, 0, false); + write(3, late_writer, 6, false); + document.set_revision(Some(3)); + let id = document.id(); + + let block_info = BlockInfo { + epoch: Epoch::new(6).unwrap(), + ..BlockInfo::default_with_time(5_000) + }; + let batch = drive + .delete_document_for_contract_operations( + id, + &contract, + document_type, + &block_info, + Some(Identifier::new(early_writer)), + None, + &mut None, + None, + version, + ) + .expect("expected to delete"); + drive + .apply_batch_low_level_drive_operations(None, None, batch, &mut vec![], &version.drive) + .expect("expected to apply the delete"); + + let fee = erase_at(&drive, &contract, id, &block_info); + + let early = fee + .fee_refunds + .0 + .get(&early_writer) + .expect("the first writer must be credited"); + let late = fee + .fee_refunds + .0 + .get(&late_writer) + .expect("the second writer must be credited"); + // Every byte is refunded under the epoch it was written in, so the first + // writer appears twice: once for the revision it wrote in epoch 0, and once + // for the lifecycle record it wrote as the deleter in epoch 6. + assert_eq!( + early.keys().copied().collect::>(), + vec![0, 6], + "the first writer's revision and the record it wrote as deleter" + ); + assert_eq!( + late.keys().copied().collect::>(), + vec![6], + "the second writer wrote only its revision, in epoch 6" + ); + + let early_revision = early[&0]; + let late_revision = late[&6]; + assert!( + late_revision > early_revision, + "the same revision written six epochs later has more of its one-time \ + charge still unspent, so it refunds more: {late_revision} is not above {early_revision}" + ); +} + +/// Erases at a caller-chosen block, so a test can put the write and the erase +/// in different epochs. +fn erase_at( + drive: &Drive, + contract: &DataContract, + id: Identifier, + block_info: &BlockInfo, +) -> dpp::fee::fee_result::FeeResult { + let mut operations = vec![]; + let batch = drive + .erase_document_for_contract_operations( + id, + contract, + document_type_of(contract), + block_info, + &mut None, + None, + latest(), + ) + .expect("expected to build the erase operations"); + drive + .apply_batch_low_level_drive_operations(None, None, batch, &mut operations, &latest().drive) + .expect("expected to apply the erase"); + drive + .calculate_fee(None, Some(operations), &block_info.epoch, latest()) + .expect("expected a fee") +} + +/// A refund is a credit to a real identity, not just a map entry: the amount +/// the fee result names is the amount the beneficiary's balance gains. +#[test] +fn should_credit_a_refund_to_the_beneficiarys_balance() { + let owner = [42u8; 32]; + let version = latest(); + let (drive, contract, id) = setup_history(3, owner); + drive + .add_new_identity( + dpp::identity::Identity::create_basic_identity(Identifier::new(owner), version) + .expect("expected a basic identity"), + false, + &BlockInfo::default(), + true, + None, + version, + ) + .expect("expected to create the beneficiary"); + let before = drive + .fetch_identity_balance(owner, None, version) + .expect("expected to read the balance") + .expect("the beneficiary exists"); + + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + let fee = erase(&drive, &contract, id, 6_000); + let refunded: u64 = fee + .fee_refunds + .0 + .get(&owner) + .map(|per_epoch| per_epoch.values().sum()) + .expect("the writer must be credited"); + + drive + .add_to_identity_balance(owner, refunded, &BlockInfo::default(), true, None, version) + .expect("expected to credit the refund"); + let after = drive + .fetch_identity_balance(owner, None, version) + .expect("expected to read the balance") + .expect("the beneficiary exists"); + assert_eq!( + after - before, + refunded, + "the credited amount is exactly what the fee result named" + ); +} + +/// The estimate an erase is admitted against is sized for a full chunk, so a +/// one-revision erase needs the same balance as a hundred-revision one. That is +/// the point of the bound: it is what an erase can cost, not what this one will. +#[test] +fn should_admit_a_one_revision_erase_only_against_the_full_chunk_estimate() { + let owner = [43u8; 32]; + let (drive, contract, id) = setup_history(1, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + + let estimated = estimated_erase_fee(&drive, &contract, id); + let actual = erase(&drive, &contract, id, 6_000); + assert!( + estimated.processing_fee > actual.processing_fee * 4, + "the estimate must be sized for the bound, not for the one revision this document holds: {} against {}", + estimated.processing_fee, + actual.processing_fee + ); +} + +/// GroveDB's batch consistency checking is off by default and on in some +/// deployments. A lifecycle batch has to produce the same state and the same +/// fees either way, or the two disagree about consensus. +#[test] +fn should_erase_identically_with_batch_consistency_checking_on() { + let chunk = chunk_size(); + let mut roots = vec![]; + let mut fees = vec![]; + for verify in [false, true] { + let owner = [44u8; 32]; + let version = latest(); + let directory = tempfile::TempDir::new().unwrap(); + let (drive, _) = Drive::open( + directory.path(), + Some(crate::config::DriveConfig { + batching_consistency_verification: verify, + ..Default::default() + }), + ) + .unwrap(); + drive.create_initial_state_structure(None, version).unwrap(); + let contract = json_document_to_contract(FAMILY_HISTORY_CONTRACT, false, version).unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .expect("expected to apply the contract"); + let document_type = document_type_of(&contract); + let mut document = + json_document_to_document(PERSON, Some(owner.into()), document_type, version).unwrap(); + let flags = Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))); + for revision in 1..=chunk { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + flags.clone(), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + revision > 1, + BlockInfo::default_with_time(1_000 + revision), + true, + None, + version, + ) + .expect("expected to write a revision"); + } + let id = document.id(); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + fees.push(erase(&drive, &contract, id, 6_000).processing_fee); + roots.push( + drive + .grove + .root_hash(None, &version.drive.grove_version) + .value + .unwrap(), + ); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Absent + )); + } + assert_eq!( + roots[0], roots[1], + "consistency checking must not change the state a lifecycle batch commits" + ); + assert_eq!(fees[0], fees[1], "nor what it costs"); +} + +/// Sibling deletes share the per-type lifecycle container even before it is committed. +#[test] +fn should_apply_two_deletes_sharing_a_new_container() { + assert_eq!( + latest().system_limits.max_transitions_in_documents_batch, + 1, + "the cap is what keeps consensus away from this shape" + ); + use crate::util::batch::{DocumentOperationType, DriveOperation}; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + + let owner = [45u8; 32]; + let version = latest(); + let (drive, contract, first_id) = setup_history(1, owner); + let document_type = document_type_of(&contract); + let mut second = + json_document_to_document(PERSON, Some(owner.into()), document_type, version).unwrap(); + second.set_id(Identifier::new([46u8; 32])); + second.set_revision(Some(1)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &second, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(2_000), + true, + None, + version, + ) + .expect("expected a second document"); + + let delete_operation = |id: Identifier| { + DriveOperation::DocumentOperation(DocumentOperationType::DeleteDocument { + document_id: id, + deleter_id: Some(Identifier::new(owner)), + contract_info: DataContractInfo::BorrowedDataContract(&contract), + document_type_info: DocumentTypeInfo::DocumentTypeName("person".to_string()), + }) + }; + drive + .apply_drive_operations( + vec![delete_operation(first_id), delete_operation(second.id())], + true, + &BlockInfo::default_with_time(5_000), + None, + version, + ) + .expect("sibling deletes create their shared lifecycle container once"); + + for id in [first_id, second.id()] { + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Deleted(_) + )); + } +} + +#[test] +fn should_keep_sibling_lifecycle_containers_separate_and_reuse_existing_containers() { + use crate::util::batch::{DocumentOperationType, DriveOperation}; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + use dpp::data_contract::schema::DataContractSchemaMethodsV0; + + let version = latest(); + let owner = Identifier::from([48; 32]); + for existing in [false, true] { + let drive = setup_drive_with_initial_state_structure(None); + let mut contract = + json_document_to_contract(FAMILY_HISTORY_CONTRACT, false, version).unwrap(); + let schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + contract + .set_document_schema("otherPerson", schema, false, &mut vec![], version) + .unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let insert = |name: &str, id: Identifier| { + let document_type = contract.document_type_for_name(name).unwrap(); + let mut document = + json_document_to_document(PERSON, Some(owner), document_type, version).unwrap(); + document.set_id(id); + document.set_revision(Some(1)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(1000), + true, + None, + version, + ) + .unwrap(); + }; + let documents: [(&str, Identifier); 2] = [ + ("person", [49; 32].into()), + ("otherPerson", [50; 32].into()), + ]; + for (name, id) in documents { + if existing { + let seed_id = Identifier::from([id.as_slice()[0] + 10; 32]); + insert(name, seed_id); + drive + .delete_document_for_contract( + seed_id, + &contract, + name, + BlockInfo::default_with_time(2000), + true, + None, + version, + ) + .unwrap(); + } + insert(name, id); + } + let operations = || { + documents + .iter() + .map(|(name, id)| { + DriveOperation::DocumentOperation(DocumentOperationType::DeleteDocument { + document_id: *id, + deleter_id: Some(owner), + contract_info: DataContractInfo::BorrowedDataContract(&contract), + document_type_info: DocumentTypeInfo::DocumentTypeName((*name).to_string()), + }) + }) + .collect() + }; + for apply in [false, true] { + drive + .apply_drive_operations( + operations(), + apply, + &BlockInfo::default_with_time(3000), + None, + version, + ) + .expect("each type has its own lifecycle container in estimation and application"); + } + for (name, id) in documents { + assert!(matches!( + drive + .fetch_document_lifecycle( + &contract, + contract.document_type_for_name(name).unwrap(), + id, + None, + None, + version, + ) + .unwrap() + .0, + DocumentLifecycleState::Deleted(_) + )); + } + } +} + +/// Every state the lifecycle can be in has to survive the proof round trip, and +/// corrupting the lifecycle proof must fail verification rather than return +/// unauthenticated metadata. +#[test] +fn should_prove_the_erasing_state_and_reject_a_tampered_proof() { + let chunk = chunk_size(); + let owner = [47u8; 32]; + let (drive, contract, id) = setup_history(chunk + 2, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + erase(&drive, &contract, id, 6_000); + + let query = |filter| DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + // A single-revision read is capped at one entry by the selector's own + // rule; the page selectors take the full page. + limit: Some(match filter { + DocumentHistoryFilter::Revision(_) => 1, + _ => 10, + }), + filter, + }; + + // A populated page, and a page whose lower bound is past the end of what + // survives. Both must authenticate the same erasing metadata. + for selector in [ + DocumentHistoryFilter::StartAtTime(0), + DocumentHistoryFilter::StartAtTime(u64::MAX / 2), + DocumentHistoryFilter::Revision(1), + ] { + let query = query(selector); + let page = drive + .fetch_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to fetch the page"); + let proof = drive + .prove_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to prove the page"); + let (_, verified) = + Drive::verify_document_history(&query, &proof, document_type_of(&contract), latest()) + .expect("expected the proof to verify"); + assert_eq!(verified, page); + let lifecycle = verified + .lifecycle + .expect("the latest protocol authenticates lifecycle metadata"); + assert_eq!(lifecycle.state, DocumentHistoryState::Erasing); + assert_eq!(lifecycle.remaining_revisions, 2); + assert_eq!(lifecycle.times.deleted_at_ms, 5_000); + assert_eq!(lifecycle.times.erasing_started_at_ms, 6_000); + assert_eq!(lifecycle.times.erasing_from_revision, chunk + 2); + + let mut tampered = proof.clone(); + tampered.push(0xff); + Drive::verify_document_history(&query, &tampered, document_type_of(&contract), latest()) + .expect_err("tampering with the lifecycle proof must fail verification"); + } + + // And the terminal state after the erasure finishes. + erase(&drive, &contract, id, 7_000); + let query = query(DocumentHistoryFilter::StartAtTime(0)); + let page = drive + .fetch_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to fetch the absent id"); + let proof = drive + .prove_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to prove the absent id"); + let (_, verified) = + Drive::verify_document_history(&query, &proof, document_type_of(&contract), latest()) + .expect("expected the absence proof to verify"); + assert_eq!(verified, page); + let lifecycle = verified + .lifecycle + .expect("the latest protocol authenticates lifecycle metadata"); + assert_eq!(lifecycle.state, DocumentHistoryState::Absent); + assert_eq!(lifecycle.remaining_revisions, 0); + assert_eq!(lifecycle.times, Default::default()); + assert!( + verified.entries.is_empty(), + "no revisions survive the terminal erase" + ); +} + +/// After a partial erasure the surviving revisions are the oldest ones and +/// still number from one, so a by-revision read lands on the revision it asks +/// for rather than on whatever is now at that offset. +#[test] +fn should_read_revisions_by_position_after_a_partial_erasure() { + let chunk = chunk_size(); + let owner = [48u8; 32]; + let (drive, contract, id) = setup_history(chunk + 3, owner); + delete(&drive, &contract, id, Identifier::new(owner), 5_000); + erase(&drive, &contract, id, 6_000); + + for revision in 1..=3u64 { + let query = DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + filter: DocumentHistoryFilter::Revision(revision), + limit: Some(1), + }; + let page = drive + .fetch_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected to read a surviving revision"); + assert_eq!( + page.entries.len(), + 1, + "revision {revision} survives a partial erasure" + ); + assert_eq!(page.entries[0].revision, revision); + } + + // The revisions the chunk removed are gone, not silently answered with a + // neighbour. + let query = DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + filter: DocumentHistoryFilter::Revision(4), + limit: Some(1), + }; + let page = drive + .fetch_document_history(&query, document_type_of(&contract), None, latest()) + .expect("expected the read to run"); + assert!( + page.entries.is_empty(), + "a removed revision must not be answered with the one that took its place" + ); +} + +/// A history that the legacy layout left gapped keeps refusing by-revision +/// reads after the document is deleted: a revision no longer maps onto a +/// position, and an empty page for a revision that exists would otherwise +/// verify as an authenticated absence. +#[test] +fn should_keep_refusing_by_revision_reads_of_a_gapped_history_after_deletion() { + let old = PlatformVersion::get(14).unwrap(); + let mut version = latest().clone(); + version + .system_limits + .max_document_revisions_erased_per_transition = Some(1); + let new = &version; + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract( + "tests/supporting_files/contract/dashpay/dashpay-contract-with-profile-history.json", + false, + old, + ) + .unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, old) + .unwrap(); + let document_type = contract.document_type_for_name("profile").unwrap(); + let owner = [9u8; 32]; + let mut document = json_document_to_document( + "tests/supporting_files/contract/dashpay/profile0.json", + Some(owner.into()), + document_type, + old, + ) + .unwrap(); + // Two writes in one block under the legacy layout overwrite each other's + // revision, so revision 2 is lost and the retained history is [1, 3]. + for (revision, time) in [(1, 1_000), (2, 2_000), (3, 2_000)] { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + true, + BlockInfo::default_with_time(time), + true, + None, + old, + ) + .unwrap(); + } + let transaction = drive.grove.start_transaction(); + drive + .migrate_document_history_storage(&transaction, new) + .expect("expected the migration to run"); + drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected the migration to commit"); + let id = document.id(); + + let query = |filter| DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "profile".into(), + document_id: id.to_buffer(), + // A single-revision read is capped at one entry by the selector's + // own rule; the page selectors take the full page. + limit: Some(match filter { + DocumentHistoryFilter::Revision(_) => 1, + _ => 10, + }), + filter, + }; + let by_revision = [ + DocumentHistoryFilter::Revision(3), + DocumentHistoryFilter::StartAtRevision(3), + DocumentHistoryFilter::Revision(2), + ]; + let is_gap_refusal = |error: Error| { + let message = error.to_string(); + assert!( + message.contains("revision gap"), + "expected the gap refusal, got {message}" + ); + }; + + // While the document is current the gap already refuses both selectors. + for selector in by_revision.clone() { + is_gap_refusal( + drive + .fetch_document_history(&query(selector), document_type, None, new) + .expect_err("a gapped history refuses by-revision reads"), + ); + } + + let apply = |batch: Vec| { + drive + .apply_batch_low_level_drive_operations(None, None, batch, &mut vec![], &new.drive) + .expect("expected to apply the operations"); + }; + apply( + drive + .delete_document_for_contract_operations( + id, + &contract, + document_type, + &BlockInfo::default_with_time(5_000), + Some(Identifier::new(owner)), + None, + &mut None, + None, + new, + ) + .expect("expected to build the delete"), + ); + let page = drive + .fetch_document_history( + &query(DocumentHistoryFilter::StartAtTime(0)), + document_type, + None, + new, + ) + .expect("time pagination still reads a deleted gapped history"); + let lifecycle = page + .lifecycle + .expect("protocol 15 authenticates lifecycle metadata"); + assert_eq!(lifecycle.state, DocumentHistoryState::Deleted); + assert_eq!(lifecycle.remaining_revisions, 2); + assert_eq!( + page.entries + .iter() + .map(|entry| entry.revision) + .collect::>(), + vec![1, 3] + ); + for selector in by_revision.clone() { + let query = query(selector.clone()); + is_gap_refusal( + drive + .fetch_document_history(&query, document_type, None, new) + .expect_err("a deleted gapped history refuses by-revision reads"), + ); + is_gap_refusal( + drive + .prove_document_history(&query, document_type, None, new) + .expect_err("a deleted gapped history cannot be proved by revision"), + ); + } + + // A one-revision chunk leaves the oldest revision of the migrated history. + apply( + drive + .erase_document_for_contract_operations( + id, + &contract, + document_type, + &BlockInfo::default_with_time(6_000), + &mut None, + None, + new, + ) + .expect("expected to build the erase"), + ); + let history_query = query(DocumentHistoryFilter::StartAtTime(0)); + let page = drive + .fetch_document_history(&history_query, document_type, None, new) + .unwrap(); + let proof = drive + .prove_document_history(&history_query, document_type, None, new) + .unwrap(); + let (_, verified) = + Drive::verify_document_history(&history_query, &proof, document_type, new).unwrap(); + assert_eq!(verified, page); + let lifecycle = page.lifecycle.unwrap(); + assert_eq!(lifecycle.state, DocumentHistoryState::Erasing); + assert_eq!(lifecycle.remaining_revisions, 1); + assert_eq!( + page.entries + .iter() + .map(|entry| entry.revision) + .collect::>(), + vec![1] + ); + for selector in by_revision.clone() { + is_gap_refusal( + drive + .fetch_document_history(&query(selector.clone()), document_type, None, new) + .unwrap_err(), + ); + is_gap_refusal( + drive + .prove_document_history(&query(selector), document_type, None, new) + .unwrap_err(), + ); + } + for time in [0, 999, 1_000, 2_000, 4_999, 5_000, 6_000, u64::MAX] { + let timed = SingleDocumentDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "profile".into(), + document_type_keeps_history: true, + document_id: id.to_buffer(), + block_time_ms: Some(time), + contested_status: SingleDocumentDriveQueryContestedStatus::NotContested, + }; + let path_query = timed.construct_path_query(new).unwrap(); + let proof = drive + .grove_get_proved_path_query(&path_query, None, &mut vec![], &new.drive) + .unwrap(); + for subset in [false, true] { + let (_, returned) = timed + .verify_proof(subset, &proof, document_type, new) + .unwrap(); + assert!(returned.is_none(), "erasing is absent at time {time}"); + } + } + apply( + drive + .erase_document_for_contract_operations( + id, + &contract, + document_type, + &BlockInfo::default_with_time(7_000), + &mut None, + None, + new, + ) + .unwrap(), + ); + for selector in by_revision { + let page = drive + .fetch_document_history(&query(selector), document_type, None, new) + .expect("an unused id reads as an authenticated absence"); + assert_eq!( + page.lifecycle + .expect("protocol 15 authenticates lifecycle metadata") + .state, + DocumentHistoryState::Absent + ); + assert!(page.entries.is_empty()); + } +} + +/// A lifecycle delete given only the contract's id has to fetch the contract, +/// and that fetch is billed: its operation must come back with the delete's +/// operations, as an erase also preserves its contract fetch. +#[test] +fn should_keep_the_contract_fetch_cost_of_a_lifecycle_delete_by_contract_id() { + use crate::fees::op::LowLevelDriveOperation; + use crate::util::batch::drive_op_batch::DriveLowLevelOperationConverter; + use crate::util::batch::DocumentOperationType; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + + let owner = [48u8; 32]; + let version = latest(); + let (drive, contract, id) = setup_history(1, owner); + let block_info = BlockInfo::default_with_time(5_000); + + let delete_with = |contract_info: DataContractInfo| { + DocumentOperationType::DeleteDocument { + document_id: id, + deleter_id: Some(Identifier::new(owner)), + contract_info, + document_type_info: DocumentTypeInfo::DocumentTypeName("person".to_string()), + } + .into_low_level_drive_operations(&drive, &mut None, &block_info, None, version) + .expect("expected the delete to convert") + }; + + // The delete bills its own reads too, so the comparison is against the + // borrowed-contract path, which performs no fetch. + let borrowed = delete_with(DataContractInfo::BorrowedDataContract(&contract)); + assert!(!borrowed.is_empty(), "the delete itself emits operations"); + + let by_id = delete_with(DataContractInfo::DataContractId(contract.id())); + assert!( + matches!( + by_id.first(), + Some(LowLevelDriveOperation::PreCalculatedFeeResult(_)) + ), + "the contract fetch is billed first, got {:?}", + by_id.first() + ); + assert_eq!( + by_id[1..], + borrowed[..], + "after the fetch cost, the by-id path emits exactly the delete's operations" + ); +} + +#[test] +fn should_preserve_released_non_history_delete_operations_by_contract_id() { + use crate::fees::op::LowLevelDriveOperation; + use crate::util::batch::drive_op_batch::DriveLowLevelOperationConverter; + use crate::util::batch::DocumentOperationType; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + + for protocol in [12, 13, 14, 15] { + let version = PlatformVersion::get(protocol).unwrap(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract( + "tests/supporting_files/contract/family/family-contract.json", + false, + version, + ) + .unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let document_type = document_type_of(&contract); + let document = json_document_to_document( + PERSON, + Some(Identifier::new([82; 32])), + document_type, + version, + ) + .unwrap(); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default(), + true, + None, + version, + ) + .unwrap(); + let block = BlockInfo::default_with_time(5_000); + let lower = |contract_info| { + DocumentOperationType::DeleteDocument { + document_id: document.id(), + deleter_id: None, + contract_info, + document_type_info: DocumentTypeInfo::DocumentTypeName("person".into()), + } + .into_low_level_drive_operations(&drive, &mut None, &block, None, version) + .unwrap() + }; + let by_id = lower(DataContractInfo::DataContractId(contract.id())); + let borrowed = lower(DataContractInfo::BorrowedDataContract(&contract)); + if protocol == 15 { + assert!(matches!( + by_id.first(), + Some(LowLevelDriveOperation::PreCalculatedFeeResult(_)) + )); + assert_eq!(&by_id[1..], borrowed); + } else { + assert_eq!( + by_id, borrowed, + "protocol {protocol} retains its original delete operations" + ); + } + } +} + +#[test] +fn should_keep_non_history_delete_independent_of_pending_lifecycle_operations() { + use crate::util::batch::DocumentOperationType; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + let version = latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract( + "tests/supporting_files/contract/family/family-contract-only-first-name-index.json", + false, + version, + ) + .unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let document_type = document_type_of(&contract); + let first = json_document_to_document( + PERSON, + Some(Identifier::new([82; 32])), + document_type, + version, + ) + .unwrap(); + let mut second = first.clone(); + second.set_id(Identifier::new([84; 32])); + for document in [&first, &second] { + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default(), + true, + None, + version, + ) + .unwrap(); + } + let block = BlockInfo::default_with_time(5_000); + let build = |id, previous| { + DocumentOperationType::DeleteDocument { + document_id: id, + deleter_id: None, + contract_info: DataContractInfo::BorrowedDataContract(&contract), + document_type_info: DocumentTypeInfo::DocumentTypeRef(document_type), + } + .into_low_level_drive_operations_after_ttl_drain( + &drive, &mut None, previous, &block, None, version, + ) + .unwrap() + }; + let mut previous = build(first.id(), None); + assert_eq!( + build(second.id(), Some(&mut previous)), + build(second.id(), None) + ); +} + +fn install_lifecycle_record(drive: &Drive, contract: &DataContract, id: Identifier) { + let mut operations = vec![]; + drive + .add_lifecycle_record_operations( + id, + contract, + document_type_of(contract), + DocumentLifecycleRecord::deleted_at(5_000, 2, 2), + None, + &mut None, + None, + None, + &mut operations, + latest(), + ) + .unwrap(); + drive + .apply_batch_low_level_drive_operations( + None, + None, + operations, + &mut vec![], + &latest().drive, + ) + .unwrap(); +} + +#[test] +fn should_refuse_a_current_pointer_and_lifecycle_record_when_fetching_lifecycle() { + let (drive, contract, id) = setup_history(2, [74; 32]); + install_lifecycle_record(&drive, &contract, id); + assert!(matches!( + drive.fetch_document_lifecycle( + &contract, + document_type_of(&contract), + id, + None, + None, + latest() + ), + Err(Error::Drive(DriveError::CorruptedDriveState(_))) + )); +} + +#[test] +fn should_refuse_a_current_pointer_and_lifecycle_record_when_erasing() { + let (drive, contract, id) = setup_history(2, [75; 32]); + install_lifecycle_record(&drive, &contract, id); + assert!(matches!( + drive.erase_document_for_contract_operations( + id, + &contract, + document_type_of(&contract), + &BlockInfo::default_with_time(6_000), + &mut None, + None, + latest(), + ), + Err(Error::Drive(DriveError::CorruptedDriveState(_))) + )); +} + +#[test] +fn should_refuse_to_replace_an_existing_deletion_record() { + let (drive, contract, id) = setup_history(2, [76; 32]); + install_lifecycle_record(&drive, &contract, id); + let batch = drive.delete_document_for_contract_operations( + id, + &contract, + document_type_of(&contract), + &BlockInfo::default_with_time(6_000), + None, + None, + &mut None, + None, + latest(), + ); + let result = batch.and_then(|batch| { + drive.apply_batch_low_level_drive_operations( + None, + None, + batch, + &mut vec![], + &latest().drive, + ) + }); + assert!( + result.is_err(), + "a deletion must not overwrite an existing lifecycle record" + ); +} + +#[test] +fn should_refuse_to_write_an_incoherent_deletion_record() { + let (drive, contract, id) = setup_history(2, [77; 32]); + let result = drive.add_lifecycle_record_operations( + id, + &contract, + document_type_of(&contract), + DocumentLifecycleRecord::deleted_at(5_000, 0, 2), + None, + &mut None, + None, + None, + &mut vec![], + latest(), + ); + assert!(matches!( + result, + Err(Error::Drive(DriveError::CorruptedDriveState(_))) + )); +} + +#[test] +fn should_refuse_to_start_erasing_before_the_deletion_time() { + let (drive, contract, id) = setup_history(2, [78; 32]); + delete(&drive, &contract, id, Identifier::new([79; 32]), 5_000); + let mut version = latest().clone(); + version + .system_limits + .max_document_revisions_erased_per_transition = Some(1); + let result = drive.erase_document_for_contract_operations( + id, + &contract, + document_type_of(&contract), + &BlockInfo::default_with_time(4_000), + &mut None, + None, + &version, + ); + assert!(matches!( + result, + Err(Error::Drive(DriveError::CorruptedDriveState(_))) + )); +} + +/// The erase operation is a public Drive method, reachable without the +/// transition validation that checks the lifecycle. It has to refuse a +/// document that is not deleted on its own: a document that was never deleted, +/// and one whose id was reused after an earlier erasure finished, both keep +/// every revision. +#[test] +fn should_refuse_to_erase_a_document_that_is_not_deleted() { + let owner = [49u8; 32]; + let version = latest(); + let (drive, contract, id) = setup_history(2, owner); + let document_type = document_type_of(&contract); + let block_info = BlockInfo::default_with_time(5_000); + let attempt = |drive: &Drive| { + drive.erase_document_for_contract_operations( + id, + &contract, + document_type, + &block_info, + &mut None, + None, + version, + ) + }; + let revisions_retained = |drive: &Drive| { + drive + .fetch_document_history( + &DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(10), + }, + document_type, + None, + version, + ) + .expect("expected to read the history") + .entries + .len() + }; + + // Never deleted. + let error = attempt(&drive).expect_err("an active document must not be erasable"); + assert!( + matches!(error, Error::Drive(DriveError::InvalidInput(_))), + "got {error:?}" + ); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Active(_) + )); + assert_eq!(revisions_retained(&drive), 2); + + // Deleted, fully erased, then the id reused by a fresh document: the + // earlier erasure left the per-type lifecycle container behind, and that + // must not stand in for a record of this document. + delete(&drive, &contract, id, Identifier::new(owner), 6_000); + erase(&drive, &contract, id, 7_000); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Absent + )); + let mut recreated = + json_document_to_document(PERSON, Some(owner.into()), document_type, version) + .expect("expected a person document"); + recreated.set_revision(Some(1)); + assert_eq!(recreated.id(), id, "the fixture reproduces the same id"); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &recreated, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(8_000), + true, + None, + version, + ) + .expect("expected the id to be free again"); + + let error = attempt(&drive).expect_err("a recreated document must not be erasable"); + assert!( + matches!(error, Error::Drive(DriveError::InvalidInput(_))), + "got {error:?}" + ); + assert!(matches!( + lifecycle_of(&drive, &contract, id), + DocumentLifecycleState::Active(_) + )); + assert_eq!(revisions_retained(&drive), 1); +} + +#[test] +fn should_refuse_an_erase_limit_that_cannot_probe_a_following_revision() { + let owner = [7; 32]; + let (drive, contract, id) = setup_history(1, owner); + delete(&drive, &contract, id, owner.into(), 9000); + for limit in [0, u16::MAX] { + let mut version = latest().clone(); + version + .system_limits + .max_document_revisions_erased_per_transition = Some(limit); + assert!( + drive + .erase_document_for_contract_operations( + id, + &contract, + document_type_of(&contract), + &BlockInfo::default_with_time(9001), + &mut None, + None, + &version + ) + .is_err(), + "limit {limit} cannot bound a chunk plus its probe" + ); + } +} + +#[test] +fn should_select_history_pointer_removal_by_the_storage_layout() { + use crate::drive::document::paths::contract_documents_primary_key_path; + + let (drive, contract, id) = setup_history(1, [7; 32]); + let document_type = document_type_of(&contract); + let path = contract_documents_primary_key_path(contract.id_ref().as_bytes(), "person"); + for layout in [0, 2] { + let mut version = latest().clone(); + version + .drive + .methods + .document + .document_history_storage_layout = layout; + let result = drive.remove_document_from_primary_storage( + id, + document_type, + path, + &mut None, + None, + &mut vec![], + &version, + ); + assert!( + result.is_err(), + "layout {layout} cannot remove a history pointer" + ); + } + + let mut version = latest().clone(); + version + .drive + .methods + .document + .insert + .add_document_to_primary_storage = 0; + drive + .remove_document_from_primary_storage( + id, + document_type, + path, + &mut None, + None, + &mut vec![], + &version, + ) + .expect( + "the layout slot, independently of the writer selector, describes the stored pointer", + ); +} + +#[test] +fn should_refuse_erasure_from_an_incoherent_lifecycle_record() { + use dpp::serialization::PlatformSerializable; + + let (drive, contract, id) = setup_history(1, [7; 32]); + delete(&drive, &contract, id, [7; 32].into(), 9000); + let path = document_lifecycle_path(contract.id_ref().as_bytes(), "person"); + drive + .grove + .insert( + path.as_slice(), + id.as_slice(), + grovedb::Element::new_item( + DocumentLifecycleRecord::deleted_at(9000, 1, 0) + .serialize_to_bytes() + .unwrap(), + ), + None, + None, + &latest().drive.grove_version, + ) + .value + .unwrap(); + assert!( + drive + .erase_document_for_contract_operations( + id, + &contract, + document_type_of(&contract), + &BlockInfo::default_with_time(9001), + &mut None, + None, + latest(), + ) + .is_err(), + "only a coherent deletion may authorize removing retained revisions" + ); +} + +#[test] +fn should_cover_distinct_storing_epoch_reads_in_a_minimal_document_erase_estimate() { + use crate::drive::credit_pools::epochs::operations_factory::EpochOperations; + use crate::util::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; + use crate::util::batch::GroveDbOpBatch; + use dpp::block::epoch::Epoch; + use dpp::data_contract::DataContractFactory; + use dpp::document::document_factory::DocumentFactory; + use dpp::platform_value::platform_value; + let mut version = latest().clone(); + version + .system_limits + .max_document_revisions_erased_per_transition = Some(4); + let drive = setup_drive_with_initial_state_structure(Some(&version)); + let contract = DataContractFactory::new(version.protocol_version).unwrap() + .create_with_value_config([7; 32].into(), 0, platform_value!({"person": { + "type": "object", "documentsKeepHistory": true, "canBeDeleted": true, "canBeErased": true, + "properties": {"a": {"type": "boolean", "position": 0}}, "additionalProperties": false + }}), None, None).unwrap().data_contract_owned(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, &version) + .unwrap(); + let mut epoch_records = GroveDbOpBatch::new(); + for epoch in 2..=6 { + epoch_records.push( + Epoch::new(epoch) + .unwrap() + .update_protocol_version_operation(version.protocol_version), + ); + } + drive + .grove_apply_batch(epoch_records, false, None, &version.drive) + .unwrap(); + let document_type = document_type_of(&contract); + let mut document = DocumentFactory::new(version.protocol_version) + .unwrap() + .create_document( + &contract, + [7; 32].into(), + "person".into(), + platform_value!({}), + ) + .unwrap(); + for revision in 1..=4 { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + Some(Cow::Owned(StorageFlags::new_single_epoch( + revision as u16 + 1, + Some([7; 32]), + ))), + )), + owner_id: Some([7; 32]), + }, + contract: &contract, + document_type, + }, + revision > 1, + BlockInfo { + epoch: Epoch::new(revision as u16 + 1).unwrap(), + ..BlockInfo::default_with_time(revision * 1000) + }, + true, + None, + &version, + ) + .unwrap(); + } + let block = BlockInfo { + epoch: Epoch::new(6).unwrap(), + ..BlockInfo::default_with_time(5000) + }; + let deletes = drive + .delete_document_for_contract_operations( + document.id(), + &contract, + document_type, + &block, + Some([7; 32].into()), + None, + &mut None, + None, + &version, + ) + .unwrap(); + drive + .apply_batch_low_level_drive_operations(None, None, deletes, &mut vec![], &version.drive) + .unwrap(); + let block = BlockInfo { + epoch: Epoch::new(7).unwrap(), + ..BlockInfo::default_with_time(6000) + }; + let mut layers = Some(EstimatedLayers::new()); + let estimate = drive + .erase_document_for_contract_operations( + document.id(), + &contract, + document_type, + &block, + &mut layers, + None, + &version, + ) + .unwrap(); + let mut costs = vec![]; + drive + .apply_batch_low_level_drive_operations(layers, None, estimate, &mut costs, &version.drive) + .unwrap(); + let estimated = drive + .calculate_fee(None, Some(costs), &block.epoch, &version) + .unwrap(); + let actual = drive + .erase_document_for_contract_operations( + document.id(), + &contract, + document_type, + &block, + &mut None, + None, + &version, + ) + .unwrap(); + let mut costs = vec![]; + drive + .apply_batch_low_level_drive_operations(None, None, actual, &mut costs, &version.drive) + .unwrap(); + let actual = drive + .calculate_fee(None, Some(costs), &block.epoch, &version) + .unwrap(); + assert!( + actual.processing_fee <= estimated.processing_fee, + "distinct storing epochs must fit the erase estimate: actual {}, estimated {}", + actual.processing_fee, + estimated.processing_fee + ); + assert!(actual.storage_fee <= estimated.storage_fee); +} + +#[test] +fn should_retry_and_resume_the_lifecycle_after_rollback_and_reopening() { + let version = latest(); + let owner = [74; 32]; + let (mut drive, contract, id) = setup_history(chunk_size() + 1, owner); + let directory = drive + .temp_dir + .take() + .expect("the database must outlive Drive"); + let document_type = document_type_of(&contract); + let query = DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: id.to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(10), + }; + + for (step, (state, remaining)) in [ + (DocumentHistoryState::Deleted, chunk_size() + 1), + (DocumentHistoryState::Erasing, 1), + (DocumentHistoryState::Absent, 0), + ] + .into_iter() + .enumerate() + { + let before = history_metadata(&drive, &contract, id); + let before_root = drive + .grove + .root_hash(None, &version.drive.grove_version) + .unwrap() + .unwrap(); + let block = BlockInfo::default_with_time(5_000 + step as u64 * 1_000); + let mut staged_root = None; + for commit in [false, true] { + let transaction = drive.grove.start_transaction(); + let batch = if step == 0 { + drive + .delete_document_for_contract_operations( + id, + &contract, + document_type, + &block, + Some(owner.into()), + None, + &mut None, + Some(&transaction), + version, + ) + .unwrap() + } else { + drive + .erase_document_for_contract_operations( + id, + &contract, + document_type, + &block, + &mut None, + Some(&transaction), + version, + ) + .unwrap() + }; + drive + .apply_batch_low_level_drive_operations( + None, + Some(&transaction), + batch, + &mut vec![], + &version.drive, + ) + .unwrap(); + let page = drive + .fetch_document_history(&query, document_type, Some(&transaction), version) + .unwrap(); + let lifecycle = page.lifecycle.unwrap(); + assert_eq!(lifecycle.state, state); + assert_eq!(lifecycle.remaining_revisions, remaining); + assert_eq!(history_metadata(&drive, &contract, id), before); + let root = drive + .grove + .root_hash(Some(&transaction), &version.drive.grove_version) + .unwrap() + .unwrap(); + if commit { + assert_eq!(Some(root), staged_root, "retry must produce the same state"); + drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + } else { + staged_root = Some(root); + drive.grove.rollback_transaction(&transaction).unwrap(); + drop(transaction); + assert_eq!( + drive + .grove + .root_hash(None, &version.drive.grove_version) + .unwrap() + .unwrap(), + before_root + ); + assert_eq!(history_metadata(&drive, &contract, id), before); + } + } + let config = drive.config.clone(); + drop(drive); + (drive, _) = Drive::open(directory.path(), Some(config)).unwrap(); + assert_eq!( + drive + .grove + .root_hash(None, &version.drive.grove_version) + .unwrap() + .unwrap(), + staged_root.unwrap() + ); + let persisted = history_metadata(&drive, &contract, id); + assert_eq!(persisted.state, state); + assert_eq!(persisted.remaining_revisions, remaining); + } + assert!(record_of(&drive, &contract, id).is_none()); + drop(drive); +} + +#[test] +fn should_preserve_pending_operations_when_force_deleting_a_non_history_document() { + let version = latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract( + "tests/supporting_files/contract/family/family-contract-only-first-name-index.json", + false, + version, + ) + .unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let document_type = document_type_of(&contract); + let first = json_document_to_document( + PERSON, + Some(Identifier::new([82; 32])), + document_type, + version, + ) + .unwrap(); + let mut second = first.clone(); + second.set_id(Identifier::new([84; 32])); + for document in [&first, &second] { + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default(), + true, + None, + version, + ) + .unwrap(); + } + let block = BlockInfo::default_with_time(5_000); + let mut parent_version = version.clone(); + parent_version + .drive + .methods + .document + .delete + .delete_document_for_contract_operations = 0; + let build = |id, previous, version| { + drive + .force_delete_document_for_contract_operations( + id, + &contract, + document_type, + &block, + None, + previous, + &mut None, + None, + version, + ) + .unwrap() + }; + let mut pending = build(first.id(), None, &parent_version); + let expected = build(second.id(), Some(&mut pending), &parent_version); + let mut pending = build(first.id(), None, &parent_version); + assert_ne!( + expected, + build(second.id(), None, &parent_version), + "the pending deletion changes the shared index subtree" + ); + assert_eq!(build(second.id(), Some(&mut pending), version), expected); + + let mut unknown = version.clone(); + unknown + .drive + .methods + .document + .delete + .delete_document_for_contract_operations = 3; + let error = drive + .force_delete_read_document_for_contract_operations( + first, + &contract, + document_type, + None, + &mut None, + block.time_ms, + None, + &unknown, + ) + .unwrap_err(); + assert!( + matches!(error, Error::Drive(DriveError::UnknownVersionMismatch { + known_versions, received: 3, .. + }) if known_versions == vec![0, 1]) + ); +} + +#[test] +fn should_cover_applied_lifecycle_delete_fees_in_the_admission_estimate() { + use crate::drive::document::paths::contract_document_type_path_vec; + use crate::state_transition_action::batch::record_gas_sponsor_as_storage_owner; + use crate::util::batch::drive_op_batch::DriveLowLevelOperationConverter; + use crate::util::batch::{DocumentOperationType, DriveOperation}; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + use dpp::data_contract::DataContractFactory; + use dpp::document::document_factory::DocumentFactory; + use dpp::platform_value::platform_value; + use grovedb::Element; + + let version = latest(); + // Processing has wide headroom; storage is the tight side of this fee matrix. + let mut underestimates = vec![]; + for case in ["first-container", "summable-countable", "sponsored"] { + let drive = setup_drive_with_initial_state_structure(None); + let schema = if case == "summable-countable" { + platform_value!({ + "type": "object", "documentsKeepHistory": true, "canBeDeleted": true, + "documentsMutable": false, "documentsCountable": true, "documentsSummable": "amount", + "properties": {"amount": {"type": "integer", "minimum": 5, "maximum": 5, "position": 0}}, + "required": ["amount"], "additionalProperties": false, + "indices": [{"name": "amount", "properties": [{"amount": "asc"}]}] + }) + } else { + platform_value!({ + "type": "object", "documentsKeepHistory": true, "canBeDeleted": true, + "documentsMutable": false, + "properties": {"amount": {"type": "integer", "minimum": 5, "maximum": 5, "position": 0}}, + "required": ["amount"], "additionalProperties": false + }) + }; + let contract = DataContractFactory::new(version.protocol_version) + .unwrap() + .create_with_value_config( + [7; 32].into(), + 0, + platform_value!({"person": schema}), + None, + None, + ) + .unwrap() + .data_contract_owned(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let document_type = document_type_of(&contract); + let properties = platform_value!({"amount": 5}); + let document = DocumentFactory::new(version.protocol_version) + .unwrap() + .create_document(&contract, [7; 32].into(), "person".into(), properties) + .unwrap(); + let flags = Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some([7; 32])))); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, flags)), + owner_id: Some([7; 32]), + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(1000), + true, + None, + version, + ) + .unwrap(); + let type_path = contract_document_type_path_vec(contract.id_ref().as_bytes(), "person"); + assert!(drive + .grove + .get_raw_optional( + type_path.as_slice().into(), + &[1], + None, + &version.drive.grove_version + ) + .value + .unwrap() + .is_none()); + let block = BlockInfo::default_with_time(5000); + let price = |estimate: bool| { + let mut high_level = vec![DriveOperation::DocumentOperation( + DocumentOperationType::DeleteDocument { + document_id: document.id(), + deleter_id: Some([8; 32].into()), + contract_info: DataContractInfo::BorrowedDataContract(&contract), + document_type_info: DocumentTypeInfo::DocumentTypeRef(document_type), + }, + )]; + if case == "sponsored" { + record_gas_sponsor_as_storage_owner(&mut high_level, [9; 32].into()); + } + let mut layers = estimate.then(EstimatedLayers::new); + let operations = high_level + .pop() + .unwrap() + .into_low_level_drive_operations(&drive, &mut layers, &block, None, version) + .unwrap(); + let mut costs = vec![]; + drive + .apply_batch_low_level_drive_operations( + layers, + None, + operations, + &mut costs, + &version.drive, + ) + .unwrap(); + drive + .calculate_fee(None, Some(costs), &block.epoch, version) + .unwrap() + }; + let estimated = price(true); + let actual = price(false); + println!( + "delete {case}: estimated storage={} processing={}, actual storage={} processing={}", + estimated.storage_fee, + estimated.processing_fee, + actual.storage_fee, + actual.processing_fee + ); + if estimated.storage_fee < actual.storage_fee + || estimated.processing_fee < actual.processing_fee + { + underestimates.push(case); + } + let record = drive + .grove + .get_raw( + document_lifecycle_path(contract.id_ref().as_bytes(), "person") + .as_slice() + .into(), + document.id().as_bytes(), + None, + &version.drive.grove_version, + ) + .value + .unwrap(); + assert!(matches!(record, Element::Item(..))); + let flags = StorageFlags::map_cow_some_element_flags_ref(record.get_flags()) + .unwrap() + .unwrap(); + assert_eq!( + flags.owner_id(), + Some(&if case == "sponsored" { + [9; 32] + } else { + [8; 32] + }) + ); + } + assert!( + underestimates.is_empty(), + "lifecycle delete estimates must cover applied fees: {underestimates:?}" + ); +} + +fn assert_delete_estimate_covers_applied( + drive: &Drive, + contract: &DataContract, + id: Identifier, + block: BlockInfo, + fixture: &str, +) { + let price = |apply| { + drive + .delete_document_for_contract(id, contract, "person", block, apply, None, latest()) + .unwrap() + }; + let estimated = price(false); + let applied = price(true); + println!( + "delete {fixture}: estimated storage={} processing={}, applied storage={} processing={}", + estimated.storage_fee, + estimated.processing_fee, + applied.storage_fee, + applied.processing_fee + ); + // Processing has wide headroom; storage is the tight side of this estimate. + assert!(estimated.storage_fee >= applied.storage_fee); + assert!(estimated.processing_fee >= applied.processing_fee); +} + +#[test] +fn should_cover_applied_delete_fees_for_a_history_tree_node_with_two_children() { + use crate::drive::document::paths::contract_document_type_path_vec; + use grovedb::Element; + + let version = latest(); + let drive = setup_drive_with_initial_state_structure(None); + let contract = json_document_to_contract(FAMILY_HISTORY_CONTRACT, false, version).unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let document_type = document_type_of(&contract); + let owner = [7; 32]; + let mut document = + json_document_to_document(PERSON, Some(owner.into()), document_type, version).unwrap(); + for id in [1, 2, 3] { + document.set_id([id; 32].into()); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + )), + owner_id: Some(owner), + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(1000), + true, + None, + version, + ) + .unwrap(); + } + let type_path = contract_document_type_path_vec(contract.id_ref().as_bytes(), "person"); + let history_root = drive + .grove + .get_raw( + type_path.as_slice().into(), + &[2], + None, + &version.drive.grove_version, + ) + .value + .unwrap(); + // With exactly three document ids, the middle root has both a left and a right child. + assert!(matches!(history_root, Element::Tree(Some(key), _) if key == vec![2; 32])); + assert_delete_estimate_covers_applied( + &drive, + &contract, + [2; 32].into(), + BlockInfo::default_with_time(5000), + "two-children-history-node", + ); +} + +#[test] +fn should_cover_applied_delete_fees_for_migrated_history_with_multi_epoch_contract_flags() { + use dpp::block::epoch::Epoch; + use dpp::data_contract::conversion::json::DataContractJsonConversionMethodsV0; + use dpp::tests::json_document::json_document_to_json_value; + + let old = PlatformVersion::get(14).unwrap(); + let version = latest(); + let drive = setup_drive_with_initial_state_structure(None); + let owner = [7; 32]; + let mut schema = json_document_to_json_value(FAMILY_HISTORY_CONTRACT).unwrap(); + let contract = DataContract::from_json(schema.clone(), false, old).unwrap(); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + None, + old, + ) + .unwrap(); + let document_type = document_type_of(&contract); + let document = + json_document_to_document(PERSON, Some(owner.into()), document_type, old).unwrap(); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document, + Some(Cow::Owned(StorageFlags::new_single_epoch(0, Some(owner)))), + )), + owner_id: Some(owner), + }, + contract: &contract, + document_type, + }, + false, + BlockInfo::default_with_time(1000), + true, + None, + old, + ) + .unwrap(); + + // Growing the stored contract in a later epoch gives it multiple storing epochs. + schema["version"] = 2.into(); + schema["documentSchemas"]["person"]["properties"]["extra"] = serde_json::json!({ + "type": "string", "maxLength": 64, "position": 5 + }); + let contract = DataContract::from_json(schema, false, old).unwrap(); + drive + .apply_contract( + &contract, + BlockInfo { + epoch: Epoch::new(1).unwrap(), + ..BlockInfo::default_with_time(2000) + }, + true, + Some(Cow::Owned(StorageFlags::new_single_epoch(1, Some(owner)))), + None, + old, + ) + .unwrap(); + let transaction = drive.grove.start_transaction(); + drive + .migrate_document_history_storage(&transaction, version) + .unwrap(); + drive + .grove + .commit_transaction(transaction) + .unwrap() + .unwrap(); + let mut history_type_path = document_history_path( + contract.id_ref().as_bytes(), + "person", + document.id().as_bytes(), + ); + history_type_path.pop(); + let tree = drive + .grove + .get_raw( + history_type_path.as_slice().into(), + document.id().as_bytes(), + None, + &version.drive.grove_version, + ) + .value + .unwrap(); + let flags = StorageFlags::map_cow_some_element_flags_ref(tree.get_flags()) + .unwrap() + .unwrap(); + assert!(matches!(flags.as_ref(), StorageFlags::MultiEpochOwned(..))); + assert!( + tree.get_flags().as_ref().unwrap().len() + > StorageFlags::approximate_size(true, None) as usize + ); + assert_delete_estimate_covers_applied( + &drive, + &contract, + document.id(), + BlockInfo { + epoch: Epoch::new(2).unwrap(), + ..BlockInfo::default_with_time(5000) + }, + "migrated-multi-epoch-contract-flags", + ); +} + +#[cfg(test)] +mod raw_conversion_tests; + +#[test] +fn should_refuse_erase_refund_cost_before_lifecycle_activation_even_with_a_chunk_limit() { + let drive = setup_drive_with_initial_state_structure(None); + let epoch = Epoch::new(0).unwrap(); + let mut released = PlatformVersion::get(14).unwrap().clone(); + released + .system_limits + .max_document_revisions_erased_per_transition = Some(100); + let result = drive.erase_refund_recipient_cost(&epoch, &released); + assert!( + matches!(result, Err(Error::Drive(DriveError::VersionNotActive { method, .. })) + if method == "erase_refund_recipient_cost"), + "an erase limit cannot activate an inactive fee method" + ); +} + +#[test] +fn should_refuse_inactive_and_unknown_erase_refund_cost_versions() { + let drive = setup_drive_with_initial_state_structure(None); + let epoch = Epoch::new(0).unwrap(); + let mut version = latest().clone(); + version + .drive + .methods + .document + .delete + .erase_refund_recipient_cost = None; + assert!(matches!( + drive.erase_refund_recipient_cost(&epoch, &version), + Err(Error::Drive(DriveError::VersionNotActive { method, known_versions })) + if method == "erase_refund_recipient_cost" && known_versions == vec![0] + )); + version + .drive + .methods + .document + .delete + .erase_refund_recipient_cost = Some(1); + assert!(matches!( + drive.erase_refund_recipient_cost(&epoch, &version), + Err(Error::Drive(DriveError::UnknownVersionMismatch { method, known_versions, received: 1 })) + if method == "erase_refund_recipient_cost" && known_versions == vec![0] + )); + version + .drive + .methods + .document + .delete + .erase_refund_recipient_cost = Some(0); + assert_eq!( + drive.erase_refund_recipient_cost(&epoch, &version).unwrap(), + drive.erase_refund_recipient_cost(&epoch, latest()).unwrap() + ); +} diff --git a/packages/rs-drive/src/drive/document/lifecycle/tests/raw_conversion_tests.rs b/packages/rs-drive/src/drive/document/lifecycle/tests/raw_conversion_tests.rs new file mode 100644 index 00000000000..39d1a653d2c --- /dev/null +++ b/packages/rs-drive/src/drive/document/lifecycle/tests/raw_conversion_tests.rs @@ -0,0 +1,322 @@ +//! Raw conversion and application must agree on pending lifecycle containers. + +use super::*; +use crate::config::DriveConfig; +use crate::drive::document::paths::contract_document_type_path_vec; +use crate::state_transition_action::batch::batched_transition::document_transition::document_create_transition_action::ConsumedDocument; +use crate::util::batch::{DocumentOperationType, DriveOperation, GroveDbOpBatch}; +use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; +use dpp::data_contract::DataContractFactory; +use dpp::document::document_factory::DocumentFactory; +use dpp::platform_value::{platform_value, Value}; +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::KeyInfoPath; + +#[derive(Clone, Copy, Debug)] +enum DeleteKind { + Delete, + Force, + ReadWithoutDocument, +} + +struct DeleteFixture { + drive: Drive, + contract: DataContract, + ids: [Identifier; 2], + _directory: tempfile::TempDir, +} + +impl DeleteFixture { + fn new(history: bool, indexed: bool, verify: bool) -> Self { + let version = latest(); + let directory = tempfile::TempDir::new().unwrap(); + let (drive, _) = Drive::open( + directory.path(), + Some(DriveConfig { + batching_consistency_verification: verify, + ..Default::default() + }), + ) + .unwrap(); + drive.create_initial_state_structure(None, version).unwrap(); + let indices = if indexed { + vec![platform_value!({"name": "amount", "properties": [{"amount": "asc"}]})] + } else { + vec![] + }; + let mut schema = platform_value!({ + "type": "object", "documentsKeepHistory": history, + "canBeDeleted": true, + "properties": {"amount": {"type": "integer", "minimum": 5, "maximum": 5, "position": 0}}, + "required": ["amount"], "additionalProperties": false, + "indices": indices + }); + if !indexed { + schema + .as_map_mut() + .unwrap() + .retain(|(key, _)| key != &Value::Text("indices".into())); + } + let contract = DataContractFactory::new(version.protocol_version) + .unwrap() + .create_with_value_config( + [7; 32].into(), + 0, + platform_value!({"person": schema}), + None, + None, + ) + .unwrap() + .data_contract_owned(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + let ids = [[70; 32].into(), [71; 32].into()]; + for id in ids { + let mut document = DocumentFactory::new(version.protocol_version) + .unwrap() + .create_document( + &contract, + [7; 32].into(), + "person".into(), + platform_value!({"amount": 5}), + ) + .unwrap(); + document.set_id(id); + document.set_revision(Some(1)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type: document_type_of(&contract), + }, + false, + BlockInfo::default_with_time(1000), + true, + None, + version, + ) + .unwrap(); + } + Self { + drive, + contract, + ids, + _directory: directory, + } + } + + fn operations(&self, kind: DeleteKind) -> Vec> { + self.ids + .iter() + .map(|id| { + let contract_info = DataContractInfo::BorrowedDataContract(&self.contract); + let document_type_info = DocumentTypeInfo::DocumentTypeNameAsStr("person"); + let operation = match kind { + DeleteKind::Delete => DocumentOperationType::DeleteDocument { + document_id: *id, + deleter_id: Some([7; 32].into()), + contract_info, + document_type_info, + }, + DeleteKind::Force => DocumentOperationType::ForceDeleteDocument { + document_id: *id, + contract_info, + document_type_info, + }, + DeleteKind::ReadWithoutDocument => { + DocumentOperationType::ForceDeleteReadDocument { + consumed_document: ConsumedDocument { + document_id: *id, + document_type_name: "person".into(), + read: None, + }, + contract_info, + } + } + }; + DriveOperation::DocumentOperation(operation) + }) + .collect() + } + + fn container_inserts(&self, batch: &GroveDbOpBatch) -> usize { + let path = KeyInfoPath::from_known_owned_path(contract_document_type_path_vec( + self.contract.id_ref().as_bytes(), + "person", + )); + batch + .operations + .iter() + .filter(|operation| { + operation.path == path && operation.key == Some(KeyInfo::KnownKey(vec![1])) + }) + .count() + } + + fn assert_deleted(&self) { + for id in self.ids { + assert!(matches!( + lifecycle_of(&self.drive, &self.contract, id), + DocumentLifecycleState::Deleted(_) + )); + assert_eq!( + record_of(&self.drive, &self.contract, id) + .unwrap() + .revision_count(), + 1 + ); + } + } +} + +#[test] +fn should_convert_sibling_history_deletes_without_duplicate_lifecycle_containers() { + let version = latest(); + for verify in [false, true] { + for kind in [ + DeleteKind::Delete, + DeleteKind::Force, + DeleteKind::ReadWithoutDocument, + ] { + let fixture = DeleteFixture::new(true, false, verify); + let batch = fixture + .drive + .convert_drive_operations_to_grove_operations( + fixture.operations(kind), + &BlockInfo::default_with_time(2000), + None, + version, + ) + .unwrap(); + assert_eq!( + fixture.container_inserts(&batch), + 1, + "{kind:?}: one lifecycle container regardless of batch verification" + ); + fixture + .drive + .grove_apply_batch(batch, false, None, &version.drive) + .unwrap(); + fixture.assert_deleted(); + } + } +} + +#[test] +fn should_apply_sibling_history_force_deletes_without_duplicate_lifecycle_containers() { + let version = latest(); + for kind in [DeleteKind::Force, DeleteKind::ReadWithoutDocument] { + let fixture = DeleteFixture::new(true, false, true); + fixture + .drive + .apply_drive_operations( + fixture.operations(kind), + true, + &BlockInfo::default_with_time(2000), + None, + version, + ) + .unwrap(); + fixture.assert_deleted(); + } +} + +#[test] +fn should_match_raw_conversion_with_application_for_shared_history_index() { + let version = latest(); + for kind in [ + DeleteKind::Delete, + DeleteKind::Force, + DeleteKind::ReadWithoutDocument, + ] { + let converted = DeleteFixture::new(true, true, true); + let applied = DeleteFixture::new(true, true, true); + let block = BlockInfo::default_with_time(2000); + let batch = converted + .drive + .convert_drive_operations_to_grove_operations( + converted.operations(kind), + &block, + None, + version, + ) + .unwrap(); + converted + .drive + .grove_apply_batch(batch, false, None, &version.drive) + .unwrap(); + applied + .drive + .apply_drive_operations(applied.operations(kind), true, &block, None, version) + .unwrap(); + assert_eq!( + converted + .drive + .grove + .root_hash(None, &version.drive.grove_version) + .value + .unwrap(), + applied + .drive + .grove + .root_hash(None, &version.drive.grove_version) + .value + .unwrap(), + "{kind:?}: the public converter and application settle the same tree", + ); + converted.assert_deleted(); + applied.assert_deleted(); + } +} + +#[test] +fn should_keep_non_history_raw_delete_operations_independent_of_pending_deletes() { + let fixture = DeleteFixture::new(false, true, true); + let version = latest(); + let mut released_converter = version.clone(); + released_converter + .drive + .methods + .batch_operations + .convert_drive_operations_to_grove_operations = 1; + let block = BlockInfo::default_with_time(2000); + let convert = |version, kind| { + fixture + .drive + .convert_drive_operations_to_grove_operations( + fixture.operations(kind), + &block, + None, + version, + ) + .unwrap() + }; + for kind in [ + DeleteKind::Delete, + DeleteKind::Force, + DeleteKind::ReadWithoutDocument, + ] { + assert_eq!( + convert(&released_converter, kind).operations, + convert(version, kind).operations, + "{kind:?}: pending siblings must not change non-history deletion" + ); + } + + let mut unknown = version.clone(); + unknown + .drive + .methods + .batch_operations + .convert_drive_operations_to_grove_operations = 3; + assert!(matches!( + fixture.drive.convert_drive_operations_to_grove_operations(vec![], &block, None, &unknown), + Err(Error::Drive(DriveError::UnknownVersionMismatch { method, known_versions, received: 3 })) + if method == "convert_drive_operations_to_grove_operations" && known_versions == vec![0, 1, 2] + )); +} diff --git a/packages/rs-drive/src/drive/document/migration/index_tests.rs b/packages/rs-drive/src/drive/document/migration/index_tests.rs index ac6736cb57f..32b1aa91ce0 100644 --- a/packages/rs-drive/src/drive/document/migration/index_tests.rs +++ b/packages/rs-drive/src/drive/document/migration/index_tests.rs @@ -85,7 +85,9 @@ fn read_and_prove_index_matrix(countable: bool) { "required":["topic"], "additionalProperties":false } }); - let contract = DataContractFactory::new(old.protocol_version) + // Contested keep-history types can only originate before lifecycle admission. + // Keep covering their persisted contracts under both storage layouts. + let contract = DataContractFactory::new(14) .unwrap() .create_with_value_config([7; 32].into(), 0, schemas, None, None) .unwrap() diff --git a/packages/rs-drive/src/drive/document/migration/tests.rs b/packages/rs-drive/src/drive/document/migration/tests.rs index 2deae4768a8..300dbc4554a 100644 --- a/packages/rs-drive/src/drive/document/migration/tests.rs +++ b/packages/rs-drive/src/drive/document/migration/tests.rs @@ -641,3 +641,89 @@ fn should_halt_migration_when_an_inventoried_index_reference_was_not_rewritten() .unwrap(); assert_eq!(stats.rewritten_index_entries, references.len() as u64); } + +/// A keep-history type with a contested index could be registered before +/// protocol 15. Activation loads every stored contract through the structural +/// parse, which must keep reading that combination, or the migration would +/// abort on the first such contract before touching any history. +#[test] +fn should_migrate_a_legacy_contested_keep_history_contract() { + use dpp::data_contract::DataContractFactory; + use dpp::document::document_factory::DocumentFactory; + use dpp::platform_value::platform_value; + + let old = PlatformVersion::get(14).unwrap(); + let new = PlatformVersion::get(15).unwrap(); + let schema = platform_value!({ + "type": "object", + "documentsKeepHistory": true, + "canBeDeleted": false, + "documentsMutable": false, + "properties": { + "label": {"type": "string", "maxLength": 50, "position": 0}, + }, + "required": ["label"], + "additionalProperties": false, + "indices": [{ + "name": "byLabel", + "properties": [{"label": "asc"}], + "unique": true, + "contested": { + "fieldMatches": [{"field": "label", "regexPattern": "^[a-z]{3,10}$"}], + "resolution": 0, + }, + }], + }); + let contract = DataContractFactory::new(14) + .unwrap() + .create_with_value_config( + [7; 32].into(), + 0, + platform_value!({"name": schema}), + None, + None, + ) + .expect("protocol 14 admits a contested keep-history type") + .data_contract_owned(); + let drive = setup_drive_with_initial_state_structure(None); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, old) + .unwrap(); + let document_type = contract.document_type_for_name("name").unwrap(); + let mut document = DocumentFactory::new(14) + .unwrap() + .create_document( + &contract, + [7; 32].into(), + "name".into(), + platform_value!({"label": "alice"}), + ) + .unwrap(); + // An immutable type carries no revision; its history is keyed by time. + document.set_id([9; 32].into()); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + true, + BlockInfo::default_with_time(1_000), + true, + None, + old, + ) + .unwrap(); + + let transaction = drive.grove.start_transaction(); + let stats = drive + .migrate_document_history_storage(&transaction, new) + .expect("a stored contested keep-history contract must load and migrate"); + assert_eq!(stats.contracts, 1); + assert_eq!(stats.types, 1); + assert_eq!(stats.migrated_documents, 1); +} diff --git a/packages/rs-drive/src/drive/document/mod.rs b/packages/rs-drive/src/drive/document/mod.rs index b3cf823942c..7f9c4096efd 100644 --- a/packages/rs-drive/src/drive/document/mod.rs +++ b/packages/rs-drive/src/drive/document/mod.rs @@ -90,6 +90,9 @@ mod index_uniqueness; mod insert; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] mod insert_contested; +/// The lifecycle record of a deleted keep-history document. +#[cfg(any(feature = "server", feature = "verify"))] +pub mod lifecycle; /// Activation migration and its inventory. #[cfg(feature = "server")] pub mod migration; diff --git a/packages/rs-drive/src/drive/document/paths.rs b/packages/rs-drive/src/drive/document/paths.rs index 893fd219d85..8ec6e70e7a9 100644 --- a/packages/rs-drive/src/drive/document/paths.rs +++ b/packages/rs-drive/src/drive/document/paths.rs @@ -12,9 +12,24 @@ use grovedb::batch::key_info::KeyInfo; #[cfg(feature = "server")] use grovedb::batch::KeyInfoPath; +/// Reserved document-type key containing the lifecycle records of documents +/// that have been deleted but whose revisions are still retained. +/// +/// Sits between the primary-key tree at 0 and the history tree at 2. Index +/// trees are keyed by property names, which cannot start below `0x30`, so no +/// index can collide with a reserved single-byte key. +pub const DOCUMENT_LIFECYCLE_TREE_KEY: u8 = 1; + /// Reserved document-type key containing the revision trees. pub const DOCUMENT_HISTORY_TREE_KEY: u8 = 2; +/// Path to the lifecycle records of one document type. +pub fn document_lifecycle_path(contract_id: &[u8], document_type_name: &str) -> Vec> { + let mut path = contract_document_type_path_vec(contract_id, document_type_name); + path.push(vec![DOCUMENT_LIFECYCLE_TREE_KEY]); + path +} + /// Path to all retained revisions of one document. pub fn document_history_path( contract_id: &[u8], diff --git a/packages/rs-drive/src/drive/document/structure.rs b/packages/rs-drive/src/drive/document/structure.rs index 3c2cf25a0db..1f46a9fc459 100644 --- a/packages/rs-drive/src/drive/document/structure.rs +++ b/packages/rs-drive/src/drive/document/structure.rs @@ -1,4 +1,5 @@ use crate::drive::contract::structure::CONTRACT_FLAGS; +use crate::drive::document::paths::DOCUMENT_LIFECYCLE_TREE_KEY; use crate::structure::{ElementKind, FlagsKind, KeyEncoding, KeyMatcher, StructureNode}; const SOURCE: &str = "packages/rs-drive/src/drive/document/paths.rs"; @@ -130,6 +131,36 @@ pub(crate) fn document_type() -> StructureNode { .describe("The document as it was at that time."), ]), ), + StructureNode::fixed( + "lifecycle", + &[DOCUMENT_LIFECYCLE_TREE_KEY], + "Lifecycle", + "DOCUMENT_LIFECYCLE_TREE_KEY", + ) + .kind(ElementKind::Tree) + .since(15) + .lazy() + .describe( + "An unflagged normal tree of lifecycle records for a type that keeps history. \ + Created on the first delete and retained after all records are erased.", + ) + .child( + StructureNode::identifier("record", "document_id", "The deleted document id") + .kind(ElementKind::Item) + .flags( + &[FlagsKind::EpochOwned, FlagsKind::None], + "The deletion's storage payer, including its gas sponsor when sponsored; \ + no flags when the caller supplies no payer. Erase refunds the record's \ + stored flag owner.", + ) + .value("versioned DPP DocumentLifecycleRecord") + .source("packages/rs-dpp/src/document/lifecycle/mod.rs") + .lazy() + .describe( + "One document's lifecycle record, present while Deleted or Erasing. \ + The terminal erase removes it together with the remaining history.", + ), + ), StructureNode::fixed("history", &[2], "History", "DOCUMENT_HISTORY_TREE_KEY") .kind(ElementKind::Tree) .flags(&[FlagsKind::EpochOwned, FlagsKind::None], CONTRACT_FLAGS) diff --git a/packages/rs-drive/src/drive/identity/update/methods/add_to_identity_balance/v1/mod.rs b/packages/rs-drive/src/drive/identity/update/methods/add_to_identity_balance/v1/mod.rs index bb2cce92e21..1ca7e604e55 100644 --- a/packages/rs-drive/src/drive/identity/update/methods/add_to_identity_balance/v1/mod.rs +++ b/packages/rs-drive/src/drive/identity/update/methods/add_to_identity_balance/v1/mod.rs @@ -321,26 +321,27 @@ mod tests { #[test] fn should_refuse_to_convert_a_debt_repaying_credit_into_a_plain_batch() { - let platform_version = PlatformVersion::latest(); - let drive = setup_drive_with_initial_state_structure(None); - let identity_id = indebted_identity(&drive, [1; 32], 100, platform_version); - - let result = drive.convert_drive_operations_to_grove_operations( - vec![DriveOperation::IdentityOperation( - IdentityOperationType::AddToIdentityBalance { - identity_id, - added_balance: 300, - }, - )], - &block_info(), - None, - platform_version, - ); + for platform_version in [PlatformVersion::get(14).unwrap(), PlatformVersion::latest()] { + let drive = setup_drive_with_initial_state_structure(None); + let identity_id = indebted_identity(&drive, [1; 32], 100, platform_version); + + let result = drive.convert_drive_operations_to_grove_operations( + vec![DriveOperation::IdentityOperation( + IdentityOperationType::AddToIdentityBalance { + identity_id, + added_balance: 300, + }, + )], + &block_info(), + None, + platform_version, + ); - assert!(matches!( - result, - Err(Error::Drive(DriveError::CorruptedCodeExecution(_))) - )); + assert!(matches!( + result, + Err(Error::Drive(DriveError::CorruptedCodeExecution(_))) + )); + } } #[test] diff --git a/packages/rs-drive/src/query/document_history_drive_query.rs b/packages/rs-drive/src/query/document_history_drive_query.rs index 889f79c5b6f..1c7726538a2 100644 --- a/packages/rs-drive/src/query/document_history_drive_query.rs +++ b/packages/rs-drive/src/query/document_history_drive_query.rs @@ -1,7 +1,9 @@ //! A page of a document's retained revisions with its lifecycle, read from //! the per-type composite-keyed history tree. -use crate::drive::document::paths::{contract_document_type_path_vec, DOCUMENT_HISTORY_TREE_KEY}; +use crate::drive::document::paths::{ + contract_document_type_path_vec, DOCUMENT_HISTORY_TREE_KEY, DOCUMENT_LIFECYCLE_TREE_KEY, +}; use crate::drive::document::MAX_DOCUMENT_HISTORY_FETCH_LIMIT; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -9,8 +11,10 @@ use crate::error::query::QuerySyntaxError; use crate::error::Error; use crate::verify::RootHash; use dpp::data_contract::document_type::{DocumentPropertyType, DocumentTypeRef}; +use dpp::document::lifecycle::DocumentLifecycleRecord; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::{Document, DocumentV0Getters}; +use dpp::serialization::PlatformDeserializableUntrusted; use dpp::version::PlatformVersion; #[cfg(feature = "server")] use grovedb::TransactionArg; @@ -62,6 +66,24 @@ pub enum DocumentHistoryState { Active, /// Neither a current document nor a retained history exists. Absent, + /// The document has been deleted; its revisions are still retained. + Deleted, + /// An authorized erasure has started and has not finished. + Erasing, +} + +/// Authenticated lifecycle timestamps independent of the requested page. +#[derive(Debug, Clone, PartialEq, Eq, Default)] +pub struct DocumentHistoryLifecycleTimes { + /// Block time the document was deleted at, zero while it is active. + pub deleted_at_ms: u64, + /// Block time an authorized erasure started at, zero while none has. + pub erasing_started_at_ms: u64, + /// Timestamp of the newest revision retained when the erasure started. + pub erasing_from_time_ms: u64, + /// History sequence of the newest revision retained when the erasure + /// started. + pub erasing_from_revision: u64, } /// Authenticated history metadata independent of the requested page. @@ -71,6 +93,8 @@ pub struct DocumentHistoryLifecycle { pub state: DocumentHistoryState, /// Count authenticated by the per-document count-tree element. pub remaining_revisions: u64, + /// Times recorded by the lifecycle record, all zero unless one exists. + pub times: DocumentHistoryLifecycleTimes, } /// One retained edit, including its complete pagination cursor. @@ -205,7 +229,7 @@ impl DocumentHistoryDriveQuery { metadata.push((path, key, element)); } } - let lifecycle = self.lifecycle(metadata, document_type, version)?; + let (lifecycle, record) = self.lifecycle(metadata, document_type, version)?; let limit = if matches!(self.filter, DocumentHistoryFilter::Revision(_)) { 1 } else { @@ -229,6 +253,15 @@ impl DocumentHistoryDriveQuery { return Err(corrupt("history page exceeds its limit or revision count")); } let entries = self.decode_entries(entries, document_type, version)?; + if let Some(record) = record { + if entries.iter().any(|entry| { + entry.time_ms > record.deleted_at_ms() || entry.revision > record.latest_revision() + }) { + return Err(corrupt( + "retained revision is newer than its deletion record", + )); + } + } Ok(DocumentHistoryDriveQueryExecutionResult { entries, lifecycle: Some(lifecycle), @@ -240,22 +273,37 @@ impl DocumentHistoryDriveQuery { metadata: Vec, document_type: DocumentTypeRef, version: &PlatformVersion, - ) -> Result { + ) -> Result<(DocumentHistoryLifecycle, Option), Error> { let mut primary = contract_document_type_path_vec(&self.contract_id, &self.document_type_name); primary.push(vec![0]); let mut history = primary.clone(); history[4] = vec![DOCUMENT_HISTORY_TREE_KEY]; + let mut lifecycle = primary.clone(); + lifecycle[4] = vec![DOCUMENT_LIFECYCLE_TREE_KEY]; let mut active = false; let mut latest_revision = None; let mut count = None; + let mut record = None; for (path, key, element) in metadata { let element = element.ok_or_else(|| corrupt("history metadata contains an absent element"))?; if key != self.document_id { return Err(corrupt("history metadata key does not match the document")); } - if path == primary { + if path == lifecycle { + let Element::Item(bytes, _) = element else { + return Err(corrupt("a lifecycle record is not an item")); + }; + if record + .replace(DocumentLifecycleRecord::deserialize_from_bytes_untrusted( + &bytes, + )?) + .is_some() + { + return Err(corrupt("duplicate lifecycle record")); + } + } else if path == primary { let bytes = match element { Element::Item(bytes, _) | Element::ItemWithSumItem(bytes, _, _) => bytes, _ => { @@ -288,27 +336,81 @@ impl DocumentHistoryDriveQuery { )); } } - if active && count.unwrap_or_default() == 0 || !active && count.unwrap_or_default() > 0 { + if active && record.is_some() { + return Err(corrupt( + "a current document cannot also carry a lifecycle record", + )); + } + if active && count.unwrap_or_default() == 0 + || !active && record.is_none() && count.unwrap_or_default() > 0 + { return Err(corrupt("current document and retained history disagree")); } + if record.is_some() && count == Some(0) { + return Err(corrupt("an empty history tree must not remain in storage")); + } + if record.is_some() && count.unwrap_or_default() == 0 { + return Err(corrupt("a lifecycle record survives its retained history")); + } + if let Some(record) = record { + let remaining = count.unwrap_or_default(); + if !record.is_coherent() + || if record.is_erasing() { + remaining >= record.revision_count() + } else { + remaining != record.revision_count() + } + { + return Err(corrupt( + "lifecycle record disagrees with its retained history", + )); + } + } + // A by-revision read maps the revision onto a position, which only + // holds while the retained revisions number one through the latest + // without a gap. A current document says so through its revision; a + // deleted one through what its record kept from the moment of + // deletion, since an erase only ever removes the newest revisions and + // so cannot open a gap afterwards. if matches!( self.filter, DocumentHistoryFilter::Revision(_) | DocumentHistoryFilter::StartAtRevision(_) - ) && active - && latest_revision != count - { - return Err(invalid( - "retained history contains a revision gap; use time pagination", - )); + ) { + let gapped = match (active, &record) { + (true, _) => latest_revision != count, + (false, Some(record)) => !record.revisions_are_contiguous(), + (false, None) => false, + }; + if gapped { + return Err(invalid( + "retained history contains a revision gap; use time pagination", + )); + } } - Ok(DocumentHistoryLifecycle { - state: if active { - DocumentHistoryState::Active - } else { - DocumentHistoryState::Absent + let state = match (active, &record) { + (true, _) => DocumentHistoryState::Active, + (false, Some(record)) if record.is_erasing() => DocumentHistoryState::Erasing, + (false, Some(_)) => DocumentHistoryState::Deleted, + // Retained history with no record and no pointer was rejected as + // inconsistent above, so nothing is left here but an unused id. + (false, None) => DocumentHistoryState::Absent, + }; + let times = record + .map(|record| DocumentHistoryLifecycleTimes { + deleted_at_ms: record.deleted_at_ms(), + erasing_started_at_ms: record.erasing_started_at_ms(), + erasing_from_time_ms: record.erasing_from_time_ms(), + erasing_from_revision: record.erasing_from_revision(), + }) + .unwrap_or_default(); + Ok(( + DocumentHistoryLifecycle { + state, + remaining_revisions: count.unwrap_or_default(), + times, }, - remaining_revisions: count.unwrap_or_default(), - }) + record, + )) } pub(crate) fn decode_entries( diff --git a/packages/rs-drive/src/query/document_history_drive_query_tests.rs b/packages/rs-drive/src/query/document_history_drive_query_tests.rs index e390f1f6960..2a9659e086f 100644 --- a/packages/rs-drive/src/query/document_history_drive_query_tests.rs +++ b/packages/rs-drive/src/query/document_history_drive_query_tests.rs @@ -306,14 +306,26 @@ fn should_reject_a_current_pointer_that_is_not_an_item() { } #[test] -fn should_reject_a_present_reserved_lifecycle_record() { +fn should_reject_lifecycle_metadata_for_an_active_document() { + use dpp::document::lifecycle::DocumentLifecycleRecord; + use dpp::serialization::PlatformSerializable; + let fixture = Fixture::new(); let query = fixture.query(DocumentHistoryFilter::StartAtTime(0), None); let mut rows = fixture.rows(&[1, 2, 3]); - rows.push(fixture.metadata_row(1, Some(Element::new_item(vec![1])))); + rows.push( + fixture.metadata_row( + 1, + Some(Element::new_item( + DocumentLifecycleRecord::deleted_at(2000, 3, 3) + .serialize_to_bytes() + .unwrap(), + )), + ), + ); assert_corrupt( fixture.decode(&query, rows), - "unexpected lifecycle record or history metadata path", + "a current document cannot also carry a lifecycle record", ); } @@ -387,3 +399,156 @@ fn should_reject_a_v1_history_query_before_the_history_tree_is_active() { }) if method == "DocumentHistoryDriveQuery::construct_path_query" && known_versions == vec![1]) ); } + +#[test] +fn should_refuse_lifecycle_metadata_that_disagrees_with_retained_history() { + use dpp::document::lifecycle::{DocumentLifecycleRecord, DocumentLifecycleRecordV0}; + use dpp::serialization::PlatformSerializable; + + let fixture = Fixture::new(); + let deleted = DocumentLifecycleRecord::deleted_at(2000, 3, 3); + let cases = [ + ( + DocumentLifecycleRecord::deleted_at(2000, 3, 2), + 3, + "deleted count", + ), + ( + DocumentLifecycleRecord::V0(DocumentLifecycleRecordV0 { + erasing_started_at_ms: 2001, + ..match deleted { + DocumentLifecycleRecord::V0(record) => record, + } + }), + 3, + "deleted erase fields", + ), + ( + DocumentLifecycleRecord::V0(DocumentLifecycleRecordV0 { + erasing_from_time_ms: 2000, + ..match deleted { + DocumentLifecycleRecord::V0(record) => record, + } + }), + 3, + "deleted erase revision time", + ), + ( + deleted.starting_erase_at(2001, 2000, 3), + 3, + "erasing count must shrink", + ), + ( + deleted.starting_erase_at(2001, 2000, 2), + 2, + "erase start revision", + ), + ( + deleted.starting_erase_at(1999, 2000, 3), + 2, + "erase before delete", + ), + ( + deleted.starting_erase_at(2001, 2001, 3), + 2, + "erase revision time", + ), + ( + DocumentLifecycleRecord::deleted_at(1999, 3, 3), + 3, + "entry after delete", + ), + ( + DocumentLifecycleRecord::deleted_at(2000, 2, 2), + 2, + "entry revision after delete", + ), + ]; + for (record, count, reason) in cases { + let rows = vec![ + fixture.metadata_row( + 1, + Some(Element::new_item(record.serialize_to_bytes().unwrap())), + ), + fixture.metadata_row( + 2, + Some(Element::ProvableCountTree(Some(vec![1]), count, None)), + ), + fixture.entry_row(3), + ]; + let error = fixture + .decode( + &fixture.query(DocumentHistoryFilter::StartAtTime(0), Some(10)), + rows, + ) + .expect_err(reason); + let expected = if reason == "entry after delete" || reason == "entry revision after delete" + { + "retained revision is newer than its deletion record" + } else { + "lifecycle record disagrees with its retained history" + }; + assert!( + matches!(error, Error::Drive(DriveError::CorruptedDocumentPath(message)) if message == expected), + "{reason}: {error:?}" + ); + } +} + +#[test] +fn should_report_an_empty_history_tree_without_a_record_as_absent() { + use super::{DocumentHistoryLifecycleTimes, DocumentHistoryState}; + + let fixture = Fixture::new(); + for filter in [ + DocumentHistoryFilter::StartAtTime(0), + DocumentHistoryFilter::Revision(1), + DocumentHistoryFilter::StartAtRevision(1), + ] { + let result = fixture + .decode( + &fixture.query(filter, None), + vec![fixture.metadata_row( + DOCUMENT_HISTORY_TREE_KEY, + Some(Element::ProvableCountTree(None, 0, None)), + )], + ) + .expect("an empty history tree without a lifecycle record is absent"); + assert!(result.entries.is_empty()); + let lifecycle = result.lifecycle.expect("authenticated absence metadata"); + assert_eq!(lifecycle.state, DocumentHistoryState::Absent); + assert_eq!(lifecycle.remaining_revisions, 0); + assert_eq!(lifecycle.times, DocumentHistoryLifecycleTimes::default()); + } +} + +#[test] +fn should_reject_a_lifecycle_record_without_retained_history() { + use dpp::document::lifecycle::DocumentLifecycleRecord; + use dpp::serialization::PlatformSerializable; + + let fixture = Fixture::new(); + let query = fixture.query(DocumentHistoryFilter::StartAtTime(0), None); + let deleted = DocumentLifecycleRecord::deleted_at(2000, 3, 3); + for record in [deleted, deleted.starting_erase_at(3000, 2000, 3)] { + for count in [None, Some(0)] { + let mut rows = vec![fixture.metadata_row( + 1, + Some(Element::new_item(record.serialize_to_bytes().unwrap())), + )]; + if let Some(count) = count { + rows.push( + fixture.metadata_row(2, Some(Element::ProvableCountTree(None, count, None))), + ); + } + assert_corrupt( + fixture.decode(&query, rows), + if count.is_some() { + "an empty history tree must not remain in storage" + } else { + "a lifecycle record survives its retained history" + }, + ); + } + } +} diff --git a/packages/rs-drive/src/query/filter.rs b/packages/rs-drive/src/query/filter.rs index abbe939ad2a..63b1b881178 100644 --- a/packages/rs-drive/src/query/filter.rs +++ b/packages/rs-drive/src/query/filter.rs @@ -389,6 +389,12 @@ impl DriveDocumentQueryFilter<'_> { TransitionCheckResult::Fail } } + // An erase carries no document values and acts on a document that + // is already invisible to every document query, so no + // content-based subscription filter can describe it. + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => TransitionCheckResult::Fail, DocumentTransition::IndexOnlyDelete(index_only_delete) => { if let DocumentActionMatchClauses::Delete { original_document_clauses, diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index c2448e8c291..283f1fa02b9 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -221,7 +221,8 @@ pub mod document_history_drive_query; #[cfg(any(feature = "server", feature = "verify"))] pub use document_history_drive_query::{ DocumentHistoryDriveQuery, DocumentHistoryDriveQueryExecutionResult, DocumentHistoryEntry, - DocumentHistoryFilter, DocumentHistoryLifecycle, DocumentHistoryState, + DocumentHistoryFilter, DocumentHistoryLifecycle, DocumentHistoryLifecycleTimes, + DocumentHistoryState, }; #[cfg(any(feature = "server", feature = "verify"))] diff --git a/packages/rs-drive/src/query/single_document_drive_query.rs b/packages/rs-drive/src/query/single_document_drive_query.rs index 3dd80be43a0..2fcccd5207d 100644 --- a/packages/rs-drive/src/query/single_document_drive_query.rs +++ b/packages/rs-drive/src/query/single_document_drive_query.rs @@ -117,6 +117,10 @@ impl SingleDocumentDriveQuery { /// 15 a document with history that may be contested is refused at a block time, as a /// contest's area keeps no history. /// + /// On the composite layout, the timed query includes a lifecycle record as well as the + /// revision. Its raw results must be interpreted by the single-document verifier: + /// deletion makes times at or after deletion absent, and erasure makes every time absent. + /// /// # Parameters /// /// - `platform_version`: The platform version, whose @@ -184,7 +188,7 @@ mod tests { use dpp::state_transition::batch_transition::document_base_transition::document_base_transition_trait::DocumentBaseTransitionAccessors; use dpp::state_transition::batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods; use dpp::state_transition::batch_transition::document_create_transition::DocumentCreateTransition; - use grovedb::SizedQuery; + use grovedb::{QueryItem, SizedQuery}; fn keep_history_query(block_time_ms: Option) -> SingleDocumentDriveQuery { SingleDocumentDriveQuery { @@ -663,9 +667,18 @@ mod tests { upper.extend([0xff; 8]); let mut versions = Query::new_with_direction(false); versions.insert_range_inclusive(encode_u64(0)..=upper); - let mut expected = history_lookup(versions); - expected.path[4] = vec![2]; - assert!(!expected.query.query.add_parent_tree_on_subquery); + versions.limit = Some(1); + let lifecycle = Query::new_single_key(vec![9; 32]); + let mut history = Query::new_single_key(vec![9; 32]); + history.set_subquery(versions); + let mut branches = Query::new(); + branches.insert_keys(vec![vec![1], vec![2]]); + branches.add_conditional_subquery(QueryItem::Key(vec![1]), None, Some(lifecycle)); + branches.add_conditional_subquery(QueryItem::Key(vec![2]), None, Some(history)); + let expected = PathQuery::new( + contract_document_type_path_vec(&[7; 32], "card"), + SizedQuery::new(branches, None, None), + ); assert_eq!( single_document( SingleDocumentDriveQueryContestedStatus::NotContested, diff --git a/packages/rs-drive/src/query/single_document_drive_query/v1/mod.rs b/packages/rs-drive/src/query/single_document_drive_query/v1/mod.rs index 4cf88887c70..c3a65718d73 100644 --- a/packages/rs-drive/src/query/single_document_drive_query/v1/mod.rs +++ b/packages/rs-drive/src/query/single_document_drive_query/v1/mod.rs @@ -1,4 +1,6 @@ -use crate::drive::document::paths::{contract_document_type_path_vec, DOCUMENT_HISTORY_TREE_KEY}; +use crate::drive::document::paths::{ + contract_document_type_path_vec, DOCUMENT_HISTORY_TREE_KEY, DOCUMENT_LIFECYCLE_TREE_KEY, +}; use crate::error::query::QuerySyntaxError; use crate::error::Error; use crate::query::primary_key_path_query::{ @@ -6,7 +8,7 @@ use crate::query::primary_key_path_query::{ }; use crate::query::{Query, SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus}; use crate::util::common::encode::encode_u64; -use grovedb::PathQuery; +use grovedb::{PathQuery, SizedQuery}; use platform_version::version::PlatformVersion; /// The last time a document's history can order. A time is stored with its top bit flipped, so @@ -89,33 +91,46 @@ impl SingleDocumentDriveQuery { &self, platform_version: &PlatformVersion, ) -> Result { + if self.is_lifecycle_temporal_query(platform_version)? { + let mut lifecycle_path = + contract_document_type_path_vec(&self.contract_id, &self.document_type_name); + lifecycle_path.push(vec![DOCUMENT_LIFECYCLE_TREE_KEY]); + let mut lifecycle = Query::new(); + lifecycle.insert_key(self.document_id.to_vec()); + let lifecycle = PathQuery::new(lifecycle_path, SizedQuery::new(lifecycle, None, None)); + + let mut history_path = + contract_document_type_path_vec(&self.contract_id, &self.document_type_name); + history_path.push(vec![DOCUMENT_HISTORY_TREE_KEY]); + let mut document = Query::new(); + document.insert_key(self.document_id.to_vec()); + let mut revisions = Query::new_with_direction(false); + let mut upper = encode_u64( + self.block_time_ms + .unwrap_or_default() + .min(LAST_ORDERED_TIME_MS), + ); + upper.extend([0xff; 8]); + revisions.insert_range_inclusive(encode_u64(0)..=upper); + // The cap belongs to the history leaf. Ancestor caps would also limit + // the lifecycle evidence when this query joins a larger proof. + revisions.limit = Some(1); + document.set_subquery(revisions); + let history = PathQuery::new(history_path, SizedQuery::new(document, None, None)); + return PathQuery::merge( + vec![&lifecycle, &history], + &platform_version.drive.grove_version, + ) + .map_err(Error::from); + } let mut path_query = self.construct_non_contested_path_query(true, platform_version)?; if self.document_type_keeps_history { if let Some(block_time_ms) = self.block_time_ms { let mut versions_up_to_block_time = Query::new_with_direction(false); - let mut upper = encode_u64(block_time_ms.min(LAST_ORDERED_TIME_MS)); - if primary_key_path_query_target(platform_version)? - == PrimaryKeyPathQueryTarget::CurrentDocument - { - // Revisions start at one and advance by one per accepted write; - // crossing the encoding's sign bit would require over 2^63-2 - // writes to one document. Migration preserves that sequence, as - // do history pages, so descending keys select the latest revision. - // FF is the largest encoded suffix, not encode_u64(u64::MAX). - upper.extend([0xff; 8]); - versions_up_to_block_time.insert_range_inclusive(encode_u64(0)..=upper); - path_query.path = contract_document_type_path_vec( - &self.contract_id, - &self.document_type_name, - ); - path_query.path.push(vec![DOCUMENT_HISTORY_TREE_KEY]); - // History types cannot be deleted. A lifecycle-aware lookup is - // required when deletion of retained histories is supported. - } else { - // Stop above the legacy latest-version pointer, which must not - // answer a time before the first retained version. - versions_up_to_block_time.insert_range_after_to_inclusive(vec![0]..=upper); - } + let upper = encode_u64(block_time_ms.min(LAST_ORDERED_TIME_MS)); + // Stop above the legacy latest-version pointer, which must not + // answer a time before the first retained version. + versions_up_to_block_time.insert_range_after_to_inclusive(vec![0]..=upper); path_query .query .query @@ -124,4 +139,17 @@ impl SingleDocumentDriveQuery { } Ok(path_query) } + /// Whether this lookup needs authenticated lifecycle evidence as well as a revision. + pub(crate) fn is_lifecycle_temporal_query( + &self, + platform_version: &PlatformVersion, + ) -> Result { + Ok( + self.contested_status == SingleDocumentDriveQueryContestedStatus::NotContested + && self.document_type_keeps_history + && self.block_time_ms.is_some() + && primary_key_path_query_target(platform_version)? + == PrimaryKeyPathQueryTarget::CurrentDocument, + ) + } } diff --git a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_delete_transition.rs b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_delete_transition.rs index b30d322f416..32faf12e616 100644 --- a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_delete_transition.rs +++ b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_delete_transition.rs @@ -44,6 +44,38 @@ impl DriveHighLevelBatchOperationConverter for DocumentDeleteTransitionAction { }), DocumentOperation(DocumentOperationType::DeleteDocument { document_id: base.id(), + deleter_id: None, + contract_info: DataContractInfo::DataContractFetchInfo( + base.data_contract_fetch_info(), + ), + document_type_info: DocumentTypeInfo::DocumentTypeName( + base.document_type_name_owned(), + ), + }), + ]; + + ops.extend(document_deletion_token_cost_operations); + + Ok(ops) + } + 1 => { + let base = self.base_owned(); + + let data_contract_id = base.data_contract_id(); + + let identity_contract_nonce = base.identity_contract_nonce(); + + let document_deletion_token_cost_operations = base.token_cost_operations(owner_id); + + let mut ops = vec![ + IdentityOperation(IdentityOperationType::UpdateIdentityContractNonce { + identity_id: owner_id.into_buffer(), + contract_id: data_contract_id.into_buffer(), + nonce: identity_contract_nonce, + }), + DocumentOperation(DocumentOperationType::DeleteDocument { + document_id: base.id(), + deleter_id: Some(owner_id), contract_info: DataContractInfo::DataContractFetchInfo( base.data_contract_fetch_info(), ), @@ -60,7 +92,7 @@ impl DriveHighLevelBatchOperationConverter for DocumentDeleteTransitionAction { version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "DocumentDeleteTransitionAction::into_high_level_document_drive_operations" .to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } diff --git a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_erase_transition.rs b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_erase_transition.rs new file mode 100644 index 00000000000..0ef738b3131 --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_erase_transition.rs @@ -0,0 +1,68 @@ +use crate::state_transition_action::action_convert_to_operations::batch::DriveHighLevelBatchOperationConverter; + +use crate::util::batch::DriveOperation::{DocumentOperation, IdentityOperation}; +use crate::util::batch::{DocumentOperationType, DriveOperation, IdentityOperationType}; + +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; +use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; +use dpp::block::epoch::Epoch; +use dpp::identifier::Identifier; +use dpp::version::PlatformVersion; + +impl DriveHighLevelBatchOperationConverter for DocumentEraseTransitionAction { + fn into_high_level_batch_drive_operations<'b>( + self, + _epoch: &Epoch, + owner_id: Identifier, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + match platform_version + .drive + .methods + .state_transitions + .convert_to_high_level_operations + .document_erase_transition + { + Some(0) => { + let base = self.base_owned(); + let data_contract_id = base.data_contract_id(); + let identity_contract_nonce = base.identity_contract_nonce(); + + // No token operation: erase carries no token cost, and a + // transition that offers to pay one is refused where the offer + // is still visible, when the transition becomes an action. + Ok(vec![ + IdentityOperation(IdentityOperationType::UpdateIdentityContractNonce { + identity_id: owner_id.into_buffer(), + contract_id: data_contract_id.into_buffer(), + nonce: identity_contract_nonce, + }), + DocumentOperation(DocumentOperationType::EraseDocument { + document_id: base.id(), + contract_info: DataContractInfo::DataContractFetchInfo( + base.data_contract_fetch_info(), + ), + document_type_info: DocumentTypeInfo::DocumentTypeName( + base.document_type_name_owned(), + ), + }), + ]) + } + Some(version) => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "DocumentEraseTransitionAction::into_high_level_document_drive_operations" + .to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Drive(DriveError::VersionNotActive { + method: "DocumentEraseTransitionAction::into_high_level_document_drive_operations" + .to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_transition.rs b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_transition.rs index 6a6deca3152..60764a591ef 100644 --- a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_transition.rs +++ b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/document_transition.rs @@ -56,6 +56,15 @@ impl DriveHighLevelBatchOperationConverter for DocumentTransitionAction { platform_version, ) } + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(document_erase_transition) => { + document_erase_transition.into_high_level_batch_drive_operations( + epoch, + owner_id, + platform_version, + ) + } DocumentTransitionAction::IndexOnlyDeleteAction( document_index_only_delete_transition, ) => document_index_only_delete_transition.into_high_level_batch_drive_operations( diff --git a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/mod.rs b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/mod.rs index e18cf20ed34..b8c70bd80c2 100644 --- a/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/mod.rs +++ b/packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/document/mod.rs @@ -1,5 +1,6 @@ mod document_create_transition; mod document_delete_transition; +mod document_erase_transition; mod document_index_only_delete_transition; mod document_purchase_transition; mod document_replace_transition; diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/mod.rs new file mode 100644 index 00000000000..31de99fc39b --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/mod.rs @@ -0,0 +1,31 @@ +use derive_more::From; + +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::{DocumentEraseTransitionActionAccessorsV0, DocumentEraseTransitionActionV0}; + +/// transformer +pub mod transformer; +/// v0 +pub mod v0; + +use crate::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionAction; + +/// document erase transition action +#[derive(Debug, Clone, From)] +pub enum DocumentEraseTransitionAction { + /// v0 + V0(DocumentEraseTransitionActionV0), +} + +impl DocumentEraseTransitionActionAccessorsV0 for DocumentEraseTransitionAction { + fn base(&self) -> &DocumentBaseTransitionAction { + match self { + DocumentEraseTransitionAction::V0(v0) => &v0.base, + } + } + + fn base_owned(self) -> DocumentBaseTransitionAction { + match self { + DocumentEraseTransitionAction::V0(v0) => v0.base, + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/transformer.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/transformer.rs new file mode 100644 index 00000000000..d603791944a --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/transformer.rs @@ -0,0 +1,37 @@ +use crate::drive::contract::DataContractFetchInfo; +use crate::error::Error; +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::{DocumentEraseTransitionAction, DocumentEraseTransitionActionV0}; +use crate::state_transition_action::batch::batched_transition::BatchedTransitionAction; +use dpp::fee::fee_result::FeeResult; +use dpp::platform_value::Identifier; +use dpp::prelude::{ConsensusValidationResult, UserFeeIncrease}; +use dpp::state_transition::batch_transition::batched_transition::DocumentEraseTransition; +use dpp::ProtocolError; +use std::sync::Arc; + +impl DocumentEraseTransitionAction { + /// from borrowed + pub fn try_from_document_borrowed_erase_transition_with_contract_lookup( + value: &DocumentEraseTransition, + owner_id: Identifier, + user_fee_increase: UserFeeIncrease, + get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, + ) -> Result< + ( + ConsensusValidationResult, + FeeResult, + ), + Error, + > { + match value { + DocumentEraseTransition::V0(v0) => { + DocumentEraseTransitionActionV0::try_from_borrowed_document_erase_transition_with_contract_lookup( + v0, + owner_id, + user_fee_increase, + get_data_contract, + ) + } + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/v0/mod.rs new file mode 100644 index 00000000000..6b9805f40c1 --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/v0/mod.rs @@ -0,0 +1,19 @@ +/// transformer +pub mod transformer; + +use crate::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionAction; + +#[derive(Debug, Clone)] +/// document erase transition action v0 +pub struct DocumentEraseTransitionActionV0 { + /// base + pub base: DocumentBaseTransitionAction, +} + +/// document erase transition action accessors v0 +pub trait DocumentEraseTransitionActionAccessorsV0 { + /// base + fn base(&self) -> &DocumentBaseTransitionAction; + /// base owned + fn base_owned(self) -> DocumentBaseTransitionAction; +} diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/v0/transformer.rs new file mode 100644 index 00000000000..095ab771145 --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_erase_transition_action/v0/transformer.rs @@ -0,0 +1,106 @@ +use crate::drive::contract::DataContractFetchInfo; +use crate::error::Error; +use crate::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionAction; +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionV0; +use crate::state_transition_action::batch::batched_transition::document_transition::DocumentTransitionAction; +use crate::state_transition_action::batch::batched_transition::BatchedTransitionAction; +use crate::state_transition_action::system::bump_identity_data_contract_nonce_action::BumpIdentityDataContractNonceAction; +use dpp::consensus::basic::document::InvalidDocumentTransitionActionError; +use dpp::consensus::basic::BasicError; +use dpp::consensus::ConsensusError; +use dpp::fee::fee_result::FeeResult; +use dpp::state_transition::batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods; +use dpp::state_transition::batch_transition::document_base_transition::v1::v1_methods::DocumentBaseTransitionV1Methods; +use dpp::platform_value::Identifier; +use dpp::prelude::{ConsensusValidationResult, UserFeeIncrease}; +use dpp::state_transition::batch_transition::batched_transition::document_erase_transition::DocumentEraseTransitionV0; +use dpp::ProtocolError; +use std::sync::Arc; + +impl DocumentEraseTransitionActionV0 { + /// try from borrowed + pub fn try_from_borrowed_document_erase_transition_with_contract_lookup( + value: &DocumentEraseTransitionV0, + owner_id: Identifier, + user_fee_increase: UserFeeIncrease, + get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, + ) -> Result< + ( + ConsensusValidationResult, + FeeResult, + ), + Error, + > { + let DocumentEraseTransitionV0 { base, .. } = value; + + // Erase carries no token cost, so an offer to pay one has nothing to + // buy. Refused here rather than in structure validation because the + // base action keeps only the cost the contract sets, not the payment + // the submitter offered: by then there is nothing left to see. + // Accepting it would let a continuation, which any identity may submit, + // move somebody else's tokens. + if base.token_payment_info_ref().is_some() { + let bump_action = + BumpIdentityDataContractNonceAction::from_borrowed_document_base_transition( + base, + owner_id, + user_fee_increase, + ); + return Ok(( + ConsensusValidationResult::new_with_data_and_errors( + BatchedTransitionAction::BumpIdentityDataContractNonce(bump_action), + vec![ConsensusError::BasicError( + BasicError::InvalidDocumentTransitionActionError( + InvalidDocumentTransitionActionError::new(format!( + "an erase of document {} must not carry token payment information", + base.id() + )), + ), + )], + ), + FeeResult::default(), + )); + } + + let base_action_validation_result = + DocumentBaseTransitionAction::try_from_borrowed_base_transition_with_contract_lookup( + base, + get_data_contract, + // Erase carries no token cost: the deletion it follows was + // charged when the document was deleted. + |_document_type| None, + |_action_fees| None, + "erase", + )?; + + let base = match base_action_validation_result.is_valid() { + true => base_action_validation_result.into_data()?, + false => { + let bump_action = + BumpIdentityDataContractNonceAction::from_borrowed_document_base_transition( + base, + owner_id, + user_fee_increase, + ); + let batched_action = + BatchedTransitionAction::BumpIdentityDataContractNonce(bump_action); + + return Ok(( + ConsensusValidationResult::new_with_data_and_errors( + batched_action, + base_action_validation_result.errors, + ), + FeeResult::default(), + )); + } + }; + + Ok(( + BatchedTransitionAction::DocumentAction(DocumentTransitionAction::EraseAction( + DocumentEraseTransitionActionV0 { base }.into(), + )) + .into(), + FeeResult::default(), + )) + } +} diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_transition_action_type.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_transition_action_type.rs index 4a36b30372a..eb8197d8520 100644 --- a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_transition_action_type.rs +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/document_transition_action_type.rs @@ -8,6 +8,9 @@ impl DocumentTransitionActionTypeGetter for DocumentTransitionAction { match self { DocumentTransitionAction::CreateAction(_) => DocumentTransitionActionType::Create, DocumentTransitionAction::DeleteAction(_) => DocumentTransitionActionType::Delete, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(_) => DocumentTransitionActionType::Erase, DocumentTransitionAction::ReplaceAction(_) => DocumentTransitionActionType::Replace, DocumentTransitionAction::TransferAction(_) => DocumentTransitionActionType::Transfer, DocumentTransitionAction::PurchaseAction(_) => DocumentTransitionActionType::Purchase, diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/mod.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/mod.rs index a9340b394ca..1a110d2e922 100644 --- a/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/mod.rs +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/document_transition/mod.rs @@ -4,6 +4,8 @@ pub mod document_base_transition_action; pub mod document_create_transition_action; /// document_delete_transition_action pub mod document_delete_transition_action; +/// document_erase_transition_action +pub mod document_erase_transition_action; /// document_index_only_delete_transition_action pub mod document_index_only_delete_transition_action; /// document_purchase_transition_action @@ -31,6 +33,8 @@ use crate::state_transition_action::batch::batched_transition::document_transiti use crate::state_transition_action::batch::batched_transition::document_transition::document_delete_transition_action::v0::DocumentDeleteTransitionActionAccessorsV0; use crate::state_transition_action::batch::batched_transition::document_transition::document_index_only_delete_transition_action::v0::DocumentIndexOnlyDeleteTransitionActionAccessorsV0; use crate::state_transition_action::batch::batched_transition::document_transition::document_index_only_delete_transition_action::DocumentIndexOnlyDeleteTransitionAction; +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionAccessorsV0; +use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; use crate::state_transition_action::batch::batched_transition::document_transition::document_purchase_transition_action::{DocumentPurchaseTransitionAction, DocumentPurchaseTransitionActionAccessorsV0}; use crate::state_transition_action::batch::batched_transition::document_transition::document_transfer_transition_action::{DocumentTransferTransitionAction, DocumentTransferTransitionActionAccessorsV0}; use crate::state_transition_action::batch::batched_transition::document_transition::document_update_price_transition_action::{DocumentUpdatePriceTransitionAction, DocumentUpdatePriceTransitionActionAccessorsV0}; @@ -57,6 +61,9 @@ pub enum DocumentTransitionAction { /// indexOnly delete-by-values — carries the document's property /// values, since there is no primary-storage row to fetch them from IndexOnlyDeleteAction(DocumentIndexOnlyDeleteTransitionAction), + /// Removes the retained revisions of an already deleted keep-history + /// document, a chunk at a time. + EraseAction(DocumentEraseTransitionAction), } impl DocumentTransitionAction { @@ -70,6 +77,9 @@ impl DocumentTransitionAction { DocumentTransitionAction::PurchaseAction(d) => d.base(), DocumentTransitionAction::UpdatePriceAction(d) => d.base(), DocumentTransitionAction::IndexOnlyDeleteAction(d) => d.base(), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(d) => d.base(), } } @@ -83,6 +93,9 @@ impl DocumentTransitionAction { DocumentTransitionAction::TransferAction(_) => "transfer", DocumentTransitionAction::PurchaseAction(_) => "purchase", DocumentTransitionAction::UpdatePriceAction(_) => "update_price", + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(_) => "erase", } } @@ -96,6 +109,9 @@ impl DocumentTransitionAction { DocumentTransitionAction::PurchaseAction(d) => d.base_owned(), DocumentTransitionAction::UpdatePriceAction(d) => d.base_owned(), DocumentTransitionAction::IndexOnlyDeleteAction(d) => d.base_owned(), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransitionAction::EraseAction(d) => d.base_owned(), } } } diff --git a/packages/rs-drive/src/state_transition_action/batch/mod.rs b/packages/rs-drive/src/state_transition_action/batch/mod.rs index 5c925b57cca..3add0c72050 100644 --- a/packages/rs-drive/src/state_transition_action/batch/mod.rs +++ b/packages/rs-drive/src/state_transition_action/batch/mod.rs @@ -184,10 +184,10 @@ pub fn action_fee_operations( /// paid for the storage, and a document's would otherwise go to its owner, who could delete it /// and keep what the sponsor paid. /// -/// Deletes name no owner (their refunds go to the owners recorded on what they remove), history -/// entries, which are never deleted, refund nobody, and the withdrawal and multi-document -/// operations are never part of a batch. A document of a type with a `ttl` is stored without -/// flags and refunds nobody. +/// A history delete names the sponsor on its lifecycle record; refunds for the +/// removed pointer and index entries still go to their recorded owners. An erase +/// preserves those owners too. Withdrawal and multi-document operations are never +/// part of a batch. A type with a `ttl` is stored without flags and refunds nobody. /// /// The estimate needs no owner, and an owner takes no more bytes than any other, so this /// changes no fee. @@ -223,7 +223,11 @@ pub fn record_gas_sponsor_as_storage_owner( } => owned_document_info .document_info .set_storage_flags_owner(gas_sponsor), - DocumentOperationType::DeleteDocument { .. } + // Only delete operation generation 1 reads this owner, for the lifecycle record. + DocumentOperationType::DeleteDocument { deleter_id, .. } => { + *deleter_id = Some(gas_sponsor_id); + } + DocumentOperationType::EraseDocument { .. } | DocumentOperationType::ForceDeleteDocument { .. } | DocumentOperationType::ForceDeleteReadDocument { .. } | DocumentOperationType::DeleteIndexOnlyDocument { .. } diff --git a/packages/rs-drive/src/state_transition_action/batch/tests.rs b/packages/rs-drive/src/state_transition_action/batch/tests.rs index 5137621e45e..87678ffe412 100644 --- a/packages/rs-drive/src/state_transition_action/batch/tests.rs +++ b/packages/rs-drive/src/state_transition_action/batch/tests.rs @@ -3441,3 +3441,206 @@ mod action_fees { assert_eq!(removed, Some((id(5), MAX_CREDITS))); } } + +mod erase_action { + use super::*; + use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::v0::DocumentEraseTransitionActionV0; + use crate::state_transition_action::batch::batched_transition::document_transition::document_erase_transition_action::DocumentEraseTransitionAction; + use crate::state_transition_action::batch::v0::BatchTransitionActionV0; + use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + use dpp::identity::SecurityLevel; + + fn erase() -> BatchedTransitionAction { + BatchedTransitionAction::DocumentAction(DocumentTransitionAction::EraseAction( + DocumentEraseTransitionAction::V0(DocumentEraseTransitionActionV0 { + base: test_document_base(), + }), + )) + } + + fn delete() -> BatchedTransitionAction { + BatchedTransitionAction::DocumentAction(DocumentTransitionAction::DeleteAction( + DocumentDeleteTransitionAction::V0(DocumentDeleteTransitionActionV0 { + base: test_document_base(), + }), + )) + } + + fn batch(transitions: Vec) -> BatchTransitionAction { + BatchTransitionAction::V0(BatchTransitionActionV0 { + owner_id: Identifier::from([0x11; 32]), + transitions, + user_fee_increase: 10, + ..Default::default() + }) + } + + /// An erase is signed like any other action on its document type: the + /// key it demands is the one the type demands, exactly as for a delete. + #[test] + fn should_require_the_erased_types_security_level() { + let domain_level = test_dpns_contract_info() + .contract + .document_type_for_name("domain") + .expect("the DPNS contract has a domain type") + .security_level_requirement(); + assert_ne!( + domain_level, + SecurityLevel::MASTER, + "the test needs a type whose requirement spans more than one level" + ); + + let expected: Vec = (SecurityLevel::CRITICAL as u8..=domain_level as u8) + .map(|level| SecurityLevel::try_from(level).unwrap()) + .collect(); + assert_eq!( + batch(vec![erase()]) + .combined_security_level_requirement() + .unwrap(), + expected + ); + assert_eq!( + batch(vec![erase()]) + .combined_security_level_requirement() + .unwrap(), + batch(vec![delete()]) + .combined_security_level_requirement() + .unwrap(), + "an erase and a delete of the same type demand the same key" + ); + } + + /// The credits a batch commits up front decide whether the signer can + /// afford it; an erase commits none, so its presence changes no sum. + #[test] + fn should_commit_no_credits_up_front() { + let erase_only = batch(vec![erase()]); + assert_eq!(erase_only.all_purchases_amount().unwrap(), None); + assert_eq!( + erase_only + .all_conflicting_index_collateral_voting_funds() + .unwrap(), + None + ); + assert_eq!(erase_only.all_used_balances().unwrap(), None); + + let purchases = || { + vec![ + BatchedTransitionAction::DocumentAction(make_purchase().into()), + BatchedTransitionAction::TokenAction(make_direct_purchase().into()), + ] + }; + let without_erase = batch(purchases()); + let mut with_erase_transitions = vec![erase()]; + with_erase_transitions.extend(purchases()); + let with_erase = batch(with_erase_transitions); + assert_eq!( + with_erase.all_purchases_amount().unwrap(), + without_erase.all_purchases_amount().unwrap() + ); + assert_eq!(with_erase.all_purchases_amount().unwrap(), Some(15_000)); + assert_eq!( + with_erase.all_used_balances().unwrap(), + without_erase.all_used_balances().unwrap() + ); + } +} + +#[test] +fn should_credit_a_sponsored_history_delete_record_to_the_sponsor() { + use crate::state_transition_action::batch::record_gas_sponsor_as_storage_owner; + use crate::util::batch::{DocumentOperationType, DriveOperation}; + use crate::util::object_size_info::{DataContractInfo, DocumentTypeInfo}; + let sponsor = Identifier::from([8; 32]); + let mut operations = vec![DriveOperation::DocumentOperation( + DocumentOperationType::DeleteDocument { + document_id: [1; 32].into(), + deleter_id: Some([7; 32].into()), + contract_info: DataContractInfo::DataContractId([2; 32].into()), + document_type_info: DocumentTypeInfo::DocumentTypeName("person".into()), + }, + )]; + record_gas_sponsor_as_storage_owner(&mut operations, sponsor); + let DriveOperation::DocumentOperation(DocumentOperationType::DeleteDocument { + deleter_id, .. + }) = &operations[0] + else { + panic!("expected the delete operation"); + }; + assert_eq!( + *deleter_id, + Some(sponsor), + "the identity paying for the lifecycle record owns its refund" + ); +} + +#[test] +fn should_preserve_shielded_token_payment_when_deleting_with_lifecycle_conversion() { + use crate::state_transition_action::action_convert_to_operations::DriveHighLevelOperationConverter; + use crate::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentShieldedTokenPayment; + use crate::util::batch::drive_op_batch::TokenOperationType; + use crate::util::batch::{DocumentOperationType, DriveOperation}; + use dpp::tokens::token_amount_on_contract_token::DocumentActionTokenEffect; + use dpp::tokens::token_payment_info::v1::TokenShieldedPayment; + + let owner = Identifier::from([7; 32]); + for effect in [ + DocumentActionTokenEffect::TransferTokenToContractOwner, + DocumentActionTokenEffect::BurnToken, + ] { + let mut base = test_document_base_v0(); + base.token_cost = Some(([8; 32].into(), effect, 9)); + base.shielded_token_payment = Some(Box::new(DocumentShieldedTokenPayment { + payment: TokenShieldedPayment { + amount: 9, + ..Default::default() + }, + token_contract_id: [10; 32].into(), + token_contract_position: 0, + })); + let action = DocumentDeleteTransitionAction::V0(DocumentDeleteTransitionActionV0 { + base: base.into(), + }); + for generation in [0, 1] { + let mut version = PlatformVersion::latest().clone(); + version + .drive + .methods + .state_transitions + .convert_to_high_level_operations + .document_delete_transition = generation; + let batch = BatchTransitionAction::V0(BatchTransitionActionV0 { + owner_id: owner, + transitions: vec![BatchedTransitionAction::DocumentAction( + DocumentTransitionAction::DeleteAction(action.clone()), + )], + ..Default::default() + }); + let operations = batch + .into_high_level_drive_operations(&BlockInfo::default().epoch, &version) + .unwrap(); + assert!( + matches!(&operations[1], DriveOperation::DocumentOperation(DocumentOperationType::DeleteDocument { deleter_id, .. }) if *deleter_id == (generation == 1).then_some(owner)) + ); + match (&operations[2], effect) { + ( + DriveOperation::TokenOperation(TokenOperationType::TokenUnshield { + amount, + .. + }), + DocumentActionTokenEffect::TransferTokenToContractOwner, + ) + | ( + DriveOperation::TokenOperation(TokenOperationType::TokenBurnFromPool { + amount, + .. + }), + DocumentActionTokenEffect::BurnToken, + ) => assert_eq!(*amount, 9), + (operation, _) => { + panic!("the shielded token payment must survive conversion: {operation:?}") + } + } + } + } +} diff --git a/packages/rs-drive/src/structure/tests.rs b/packages/rs-drive/src/structure/tests.rs index b8635dbfbc5..c84105bb2e2 100644 --- a/packages/rs-drive/src/structure/tests.rs +++ b/packages/rs-drive/src/structure/tests.rs @@ -279,6 +279,7 @@ mod fixtures { use super::*; use crate::drive::credit_pools::epochs::operations_factory::EpochOperations; use crate::drive::credit_pools::operations::update_lifetime_storage_fee_pool_operation; + use crate::drive::document::lifecycle::DocumentLifecycleState; use crate::drive::system::core_fork_activations::CoreFork; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; @@ -730,6 +731,121 @@ mod fixtures { conformance_of_at_version(&drive, "legacy_document_histories", run, version); } + fn deleted_and_erasing_histories(run: &mut FixtureRun) { + let mut version = PlatformVersion::latest().clone(); + version + .system_limits + .max_document_revisions_erased_per_transition = Some(1); + let drive = setup_drive_with_initial_state_structure(Some(&version)); + let contract = setup_contract( + &drive, + "tests/supporting_files/contract/family/family-contract-with-history.json", + Some([78; 32]), + None, + Some(|contract: &mut DataContract| { + contract + .set_document_schema( + "person", + platform_value!({ + "type": "object", + "documentsKeepHistory": true, + "canBeDeleted": true, + "canBeErased": true, + "properties": { + "name": { "type": "string", "maxLength": 50, "position": 0 }, + }, + "additionalProperties": false, + }), + true, + &mut vec![], + PlatformVersion::latest(), + ) + .expect("expected an erasable history type"); + }), + None, + Some(&version), + ); + let person = contract.document_type_for_name("person").expect("person"); + for seed in 1..=2 { + let mut document = person + .random_document(Some(seed), &version) + .expect("fixture document"); + let flags = Some(Cow::Owned(StorageFlags::new_single_epoch( + 0, + Some(document.owner_id().to_buffer()), + ))); + for revision in 1..=seed { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo((&document, flags.clone())), + owner_id: None, + }, + contract: &contract, + document_type: person, + }, + revision > 1, + BlockInfo::default_with_time(1_000 + revision), + true, + None, + &version, + ) + .expect("expected to retain a revision"); + } + drive + .delete_document_for_contract_apply_and_add_to_operations( + document.id(), + &contract, + "person", + &BlockInfo::default_with_time(2_000), + (seed == 2).then(|| document.owner_id()), + None, + None, + &mut vec![], + &version, + ) + .expect("expected to delete the document"); + if seed == 2 { + let batch = drive + .erase_document_for_contract_operations( + document.id(), + &contract, + person, + &BlockInfo::default_with_time(3_000), + &mut None, + None, + &version, + ) + .expect("expected to start erasure"); + drive + .apply_batch_low_level_drive_operations( + None, + None, + batch, + &mut vec![], + &version.drive, + ) + .expect("expected to apply the first erase chunk"); + } + let state = drive + .fetch_document_lifecycle(&contract, person, document.id(), None, None, &version) + .expect("expected to read the lifecycle") + .0; + assert!(match seed { + 1 => matches!(state, DocumentLifecycleState::Deleted(_)), + _ => matches!(state, DocumentLifecycleState::Erasing), + }); + } + conformance_of_at_version(&drive, "deleted_and_erasing_histories", run, &version); + } + + #[test] + fn should_describe_deleted_and_erasing_history_records() { + deleted_and_erasing_histories(&mut FixtureRun::default()); + } + /// A contract whose moderators only delete documents: no list, one document type they can /// delete from, one removal record. Kept apart from the contract with both lists, whose /// other tree is the fullest one and the one whose shape is recorded. @@ -1964,6 +2080,7 @@ mod fixtures { identities(&mut run); contracts_with_documents(&mut run); legacy_document_histories(&mut run); + deleted_and_erasing_histories(&mut run); expiring_documents(&mut run); moderated_contract(&mut run); warned_contract(&mut run); diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/document.rs b/packages/rs-drive/src/util/batch/drive_op_batch/document.rs index 9e6b351761e..84e5ddc2e9a 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/document.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/document.rs @@ -12,6 +12,7 @@ use crate::util::object_size_info::{ use crate::util::storage_flags::StorageFlags; use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; use dpp::document::document_event::DocumentEvent; @@ -128,6 +129,22 @@ pub enum DocumentOperationType<'a> { }, /// Deletes a document DeleteDocument { + /// The document id + document_id: Identifier, + /// The identity credited with the lifecycle record a keep-history + /// delete writes; `None` credits nobody. + deleter_id: Option, + /// Data Contract info to potentially be resolved if needed + contract_info: DataContractInfo<'a>, + /// Document type + document_type_info: DocumentTypeInfo<'a>, + }, + /// Removes a bounded chunk of the retained revisions of an already deleted + /// keep-history document, dropping the history subtree and the lifecycle + /// record with the terminal chunk. Whether the type allows erasure and who + /// may start one are decided in transition validation, like a delete's + /// ownership; this operation assumes both. + EraseDocument { /// The document id document_id: Identifier, /// Data Contract info to potentially be resolved if needed @@ -238,9 +255,10 @@ fn force_delete_consumed_document_operations( consumed_document.document_id, contract, document_type, + block_info, + None, previous_batch_operations, estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, platform_version, ), @@ -262,6 +280,7 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { self.into_low_level_drive_operations_after_ttl_drain( drive, estimated_costs_only_with_layer_info, + None, block_info, transaction, platform_version, @@ -533,6 +552,9 @@ impl DocumentOperationType<'_> { } // These write to system contracts. Self::AddWithdrawalDocument { .. } | Self::DocumentHistory { .. } => Ok(()), + // An erase acts on a document whose delete already removed every + // index reference, so there is nothing left to drain. + Self::EraseDocument { .. } => Ok(()), } } @@ -540,6 +562,7 @@ impl DocumentOperationType<'_> { self, drive: &Drive, estimated_costs_only_with_layer_info: &mut Option, + previous_batch_operations: Option<&mut Vec>, block_info: &BlockInfo, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -743,9 +766,10 @@ impl DocumentOperationType<'_> { document_id, contract, consumed_document_type, + block_info, + None, Some(&mut drive_operations), estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, platform_version, )?; @@ -808,6 +832,55 @@ impl DocumentOperationType<'_> { Ok(drive_operations) } DocumentOperationType::DeleteDocument { + document_id, + deleter_id, + contract_info, + document_type_info, + } => { + let mut drive_operations: Vec = vec![]; + let contract_resolved_info = contract_info.resolve( + drive, + block_info, + transaction, + &mut drive_operations, + platform_version, + )?; + let contract = contract_resolved_info.as_ref(); + let document_type = document_type_info.resolve(contract)?; + let previous_batch_operations = if document_type.documents_keep_history() { + previous_batch_operations + } else { + None + }; + + let mut operations = drive + .delete_document_for_contract_operations_without_ttl_drain( + document_id, + contract, + document_type, + block_info, + deleter_id, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + // Protocols through 14 return only the delete's operations. + // Generation 1 deletes retain the contract fetch they bill. + if platform_version + .drive + .methods + .document + .delete + .delete_document_for_contract_operations + == 0 + { + return Ok(operations); + } + drive_operations.append(&mut operations); + Ok(drive_operations) + } + DocumentOperationType::EraseDocument { document_id, contract_info, document_type_info, @@ -823,16 +896,17 @@ impl DocumentOperationType<'_> { let contract = contract_resolved_info.as_ref(); let document_type = document_type_info.resolve(contract)?; - drive.delete_document_for_contract_operations_without_ttl_drain( + let mut operations = drive.erase_document_for_contract_operations( document_id, contract, document_type, - None, + block_info, estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, platform_version, - ) + )?; + drive_operations.append(&mut operations); + Ok(drive_operations) } DocumentOperationType::ForceDeleteDocument { document_id, @@ -850,15 +924,24 @@ impl DocumentOperationType<'_> { let contract = contract_resolved_info.as_ref(); let document_type = document_type_info.resolve(contract)?; + // Only history deletes use pending siblings to share the lazy lifecycle container. + // Released force-delete handlers refuse history types. + let previous_batch_operations = if document_type.documents_keep_history() { + previous_batch_operations + } else { + None + }; + // The deletion a document's own owner runs, without its `canBeDeleted` guard; // it removes the expirations tree entry of a type with a `ttl` itself. drive.force_delete_document_for_contract_operations( document_id, contract, document_type, + block_info, None, + previous_batch_operations, estimated_costs_only_with_layer_info, - block_info.time_ms, transaction, platform_version, ) @@ -881,12 +964,20 @@ impl DocumentOperationType<'_> { ) .resolve(contract)?; + // Only history deletes use pending siblings to share the lazy lifecycle container. + // Released force-delete handlers refuse history types. + let previous_batch_operations = if document_type.documents_keep_history() { + previous_batch_operations + } else { + None + }; + force_delete_consumed_document_operations( drive, consumed_document, contract, document_type, - None, + previous_batch_operations, estimated_costs_only_with_layer_info, block_info, transaction, diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v0/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v0/mod.rs index 10b22a78657..0f368ed2806 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v0/mod.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v0/mod.rs @@ -75,6 +75,7 @@ impl Drive { &mut drive_op.into_low_level_drive_operations_after_ttl_drain( self, &mut estimated_costs_only_with_layer_info, + None, block_info, transaction, platform_version, diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v1/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v1/mod.rs index a0172c299ca..c1688989d30 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v1/mod.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v1/mod.rs @@ -156,6 +156,7 @@ impl Drive { let mut converted = drive_op.into_low_level_drive_operations_after_ttl_drain( self, &mut estimated_costs_only_with_layer_info, + None, block_info, transaction, platform_version, @@ -683,7 +684,7 @@ mod tests { Err(Error::Drive(DriveError::NotSupported(_))) )); } - for version in [legacy, platform_version] { + for version in [legacy, PlatformVersion::get(14).unwrap(), platform_version] { assert!(matches!( drive.convert_drive_operations_to_grove_operations( vec![pool_credit(amount)], diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs index 3a133d50792..cf65de051c2 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs @@ -180,6 +180,7 @@ impl Drive { let mut converted = drive_op.into_low_level_drive_operations_after_ttl_drain( self, &mut estimated_costs_only_with_layer_info, + Some(&mut low_level_operations), block_info, transaction, platform_version, @@ -358,6 +359,7 @@ mod tests { .into_low_level_drive_operations_after_ttl_drain( drive, &mut estimate, + None, &BlockInfo::default(), None, platform_version, diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/mod.rs index 8835e4cd5d1..186de63c687 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/mod.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/mod.rs @@ -1,5 +1,6 @@ mod v0; mod v1; +mod v2; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; @@ -55,9 +56,15 @@ impl Drive { transaction, platform_version, ), + 2 => self.convert_drive_operations_to_grove_operations_v2( + drive_batch_operations, + block_info, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "convert_drive_operations_to_grove_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0, 1, 2], received: version, })), } diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v0/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v0/mod.rs index 9894c9d666f..ab92d7e7d3e 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v0/mod.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v0/mod.rs @@ -57,6 +57,7 @@ impl Drive { .into_low_level_drive_operations_after_ttl_drain( self, &mut None, + None, block_info, transaction, platform_version, diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs new file mode 100644 index 00000000000..05a9d1f4652 --- /dev/null +++ b/packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs @@ -0,0 +1,69 @@ +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; +use crate::util::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; +use crate::util::batch::{DriveOperation, GroveDbOpBatch}; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Converts a plain batch while keeping sibling operations available to history deletes. + /// Each type's lazy lifecycle container is therefore inserted only once in the batch. + #[inline(always)] + pub(super) fn convert_drive_operations_to_grove_operations_v2( + &self, + drive_batch_operations: Vec, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + self.refuse_repeated_counter_moves( + &drive_batch_operations, + block_info, + transaction, + platform_version, + )?; + self.prepare_drive_operations_time_range_ttl( + &drive_batch_operations, + block_info, + transaction, + platform_version, + )?; + let mut operations = vec![]; + for drive_op in drive_batch_operations { + let mut converted = drive_op.into_low_level_drive_operations_after_ttl_drain( + self, + &mut None, + Some(&mut operations), + block_info, + transaction, + platform_version, + )?; + if LowLevelDriveOperation::holds_repaid_identity_debt(&converted) { + return Err(Error::Drive(DriveError::CorruptedCodeExecution( + "convert_drive_operations_to_grove_operations cannot carry credits that \ + repaid an identity's debt; apply them through apply_drive_operations", + ))); + } + if converted.iter().any(|operation| { + matches!( + operation, + LowLevelDriveOperation::EphemeralGroveOperation(..) + ) + }) { + return Err(Error::Drive(DriveError::NotSupported( + "convert_drive_operations_to_grove_operations returns one plain batch \ + and cannot carry ephemeral operations (a TTL'd subtree's, or a \ + document's with a time to live), whose bytes are priced separately; \ + apply them through apply_drive_operations", + ))); + } + operations.append(&mut converted); + } + Ok(GroveDbOpBatch::from_operations( + LowLevelDriveOperation::grovedb_operations_consume(operations), + )) + } +} diff --git a/packages/rs-drive/src/util/batch/drive_op_batch/mod.rs b/packages/rs-drive/src/util/batch/drive_op_batch/mod.rs index abf7b5cb89c..aefcf0ee153 100644 --- a/packages/rs-drive/src/util/batch/drive_op_batch/mod.rs +++ b/packages/rs-drive/src/util/batch/drive_op_batch/mod.rs @@ -346,6 +346,7 @@ impl DriveOperation<'_> { self, drive: &Drive, estimated_costs_only_with_layer_info: &mut Option, + previous_batch_operations: Option<&mut Vec>, block_info: &BlockInfo, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -355,6 +356,7 @@ impl DriveOperation<'_> { .into_low_level_drive_operations_after_ttl_drain( drive, estimated_costs_only_with_layer_info, + previous_batch_operations, block_info, transaction, platform_version, diff --git a/packages/rs-drive/src/verify/single_document/verify_proof/mod.rs b/packages/rs-drive/src/verify/single_document/verify_proof/mod.rs index d0124a4a437..29ed593d808 100644 --- a/packages/rs-drive/src/verify/single_document/verify_proof/mod.rs +++ b/packages/rs-drive/src/verify/single_document/verify_proof/mod.rs @@ -1,4 +1,5 @@ mod v0; +mod v1; use crate::verify::RootHash; @@ -49,9 +50,10 @@ impl SingleDocumentDriveQuery { .verify_proof { 0 => self.verify_proof_v0(is_subset, proof, document_type, platform_version), + 1 => self.verify_proof_v1(is_subset, proof, document_type, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "SingleDocumentDriveQuery::verify_proof".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } @@ -97,7 +99,7 @@ mod tests { assert!( matches!(result, Err(Error::Drive(DriveError::UnknownVersionMismatch { method, known_versions, received })) - if method == "SingleDocumentDriveQuery::verify_proof" && known_versions == vec![0] && received == 255 + if method == "SingleDocumentDriveQuery::verify_proof" && known_versions == vec![0, 1] && received == 255 ) ); } diff --git a/packages/rs-drive/src/verify/single_document/verify_proof/v1/mod.rs b/packages/rs-drive/src/verify/single_document/verify_proof/v1/mod.rs new file mode 100644 index 00000000000..d3b00683a12 --- /dev/null +++ b/packages/rs-drive/src/verify/single_document/verify_proof/v1/mod.rs @@ -0,0 +1,42 @@ +use crate::error::proof::ProofError; +use crate::error::Error; +use crate::query::SingleDocumentDriveQuery; +use crate::verify::RootHash; +use dpp::data_contract::document_type::methods::DocumentTypeBasicMethods; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::{Document, DocumentV0Getters}; +use dpp::version::PlatformVersion; + +impl SingleDocumentDriveQuery { + pub(super) fn verify_proof_v1( + &self, + is_subset: bool, + proof: &[u8], + document_type: DocumentTypeRef, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + if !self.is_lifecycle_temporal_query(platform_version)? { + return self.verify_proof_v0(is_subset, proof, document_type, platform_version); + } + let (root, retained) = + self.verify_lifecycle_temporal_proof(is_subset, proof, platform_version)?; + let document = retained + .map(|retained| { + let document = + Document::from_bytes(&retained.bytes, document_type, platform_version)?; + if document.id().as_slice() != self.document_id + || document_type.requires_revision() + && document.revision() != Some(retained.revision) + { + return Err(Error::Proof(ProofError::CorruptedProof( + "the returned document does not match its retained revision key" + .to_string(), + ))); + } + Ok(document) + }) + .transpose()?; + Ok((root, document)) + } +} diff --git a/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/mod.rs b/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/mod.rs index 105d1ec7a4a..88ba7b67d2f 100644 --- a/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/mod.rs +++ b/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/mod.rs @@ -5,6 +5,20 @@ use crate::verify::RootHash; use grovedb::GroveDb; use platform_version::version::PlatformVersion; +use crate::drive::document::paths::{ + contract_document_type_path_vec, document_history_path, DOCUMENT_LIFECYCLE_TREE_KEY, +}; +use crate::util::common::decode::decode_u64; +use dpp::document::lifecycle::DocumentLifecycleRecord; +use dpp::serialization::PlatformDeserializableUntrusted; +use grovedb::query_result_type::PathKeyOptionalElementTrio; +use grovedb::Element; + +pub(crate) struct RetainedDocument { + pub(crate) bytes: Vec, + pub(crate) revision: u64, +} + impl SingleDocumentDriveQuery { /// Generation 0, except that two kinds of lookup it refused are verified: a document that /// may be contested, and a document outside a contest at a block time in a type that keeps @@ -25,6 +39,11 @@ impl SingleDocumentDriveQuery { proof: &[u8], platform_version: &PlatformVersion, ) -> Result<(RootHash, Option>), Error> { + if self.is_lifecycle_temporal_query(platform_version)? { + return self + .verify_lifecycle_temporal_proof(is_subset, proof, platform_version) + .map(|(root, document)| (root, document.map(|document| document.bytes))); + } let verified_by_generation_0 = match self.contested_status { SingleDocumentDriveQueryContestedStatus::NotContested => { !(self.document_type_keeps_history && self.block_time_ms.is_some()) @@ -60,6 +79,99 @@ impl SingleDocumentDriveQuery { Ok((root_hash, serialized)) } + + /// Authenticates both branches before interpreting the deletion cutoff. The raw + /// API is type-agnostic: discarded revisions need no document-body decoding. + pub(crate) fn verify_lifecycle_temporal_proof( + &self, + is_subset: bool, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + let query = self.construct_path_query(platform_version)?; + let (root, rows) = if is_subset { + GroveDb::verify_subset_query(proof, &query, &platform_version.drive.grove_version)? + } else { + GroveDb::verify_query(proof, &query, &platform_version.drive.grove_version)? + }; + Ok((root, self.decode_lifecycle_temporal_rows(rows)?)) + } + + fn decode_lifecycle_temporal_rows( + &self, + rows: Vec, + ) -> Result, Error> { + let corrupt = |message: &str| Error::Proof(ProofError::CorruptedProof(message.to_string())); + let history_path = document_history_path( + &self.contract_id, + &self.document_type_name, + &self.document_id, + ); + let mut lifecycle_path = + contract_document_type_path_vec(&self.contract_id, &self.document_type_name); + lifecycle_path.push(vec![DOCUMENT_LIFECYCLE_TREE_KEY]); + let mut record = None; + let mut document = None; + let mut history_time = None; + let mut seen_lifecycle = false; + let time = self + .block_time_ms + .ok_or_else(|| corrupt("a temporal query needs a block time"))?; + for (path, key, element) in rows { + if path == lifecycle_path { + if key != self.document_id || seen_lifecycle { + return Err(corrupt("unexpected or duplicate lifecycle key")); + } + seen_lifecycle = true; + if let Some(element) = element { + let Element::Item(bytes, _) = element else { + return Err(corrupt("a lifecycle record must be an item")); + }; + let decoded = + DocumentLifecycleRecord::deserialize_from_bytes_untrusted(&bytes)?; + if !decoded.is_coherent() { + return Err(corrupt("a lifecycle record is incoherent")); + } + record = Some(decoded); + } + } else if path == history_path { + if document.is_some() || key.len() != 16 { + return Err(corrupt("unexpected or duplicate retained revision key")); + } + let revision = + decode_u64(&key[8..]).map_err(|_| corrupt("invalid retained revision"))?; + let stored_at = + decode_u64(&key[..8]).map_err(|_| corrupt("invalid retained time"))?; + if revision == 0 || stored_at > time.min(i64::MAX as u64) { + return Err(corrupt("retained revision is outside the temporal query")); + } + let Some(Element::Item(bytes, _)) = element else { + return Err(corrupt("a retained revision must be an item")); + }; + history_time = Some(stored_at); + document = Some(RetainedDocument { bytes, revision }); + } else { + return Err(corrupt("unexpected path in a temporal document proof")); + } + } + if let Some(record) = record { + if document + .as_ref() + .is_some_and(|document| document.revision > record.latest_revision()) + || history_time.is_some_and(|stored_at| stored_at > record.deleted_at_ms()) + { + return Err(corrupt( + "retained revision is newer than its deletion record", + )); + } + // Compare the requested time before clamping it for the ordered key space. + // Erasure immediately makes every historical lookup absent. + if record.is_erasing() || time >= record.deleted_at_ms() { + return Ok(None); + } + } + Ok(document) + } } #[cfg(test)] diff --git a/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/tests/temporal.rs b/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/tests/temporal.rs index bd353f8207f..6a231e50fe5 100644 --- a/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/tests/temporal.rs +++ b/packages/rs-drive/src/verify/single_document/verify_proof_keep_serialized/v1/tests/temporal.rs @@ -181,10 +181,22 @@ fn should_match_history_pages_at_every_temporal_boundary_before_and_after_migrat assert_eq!(found, direct_read(&drive, &temporal, current)); assert!(found.is_some()); - let mut bare_bound_query = path_query; let mut bare_bound = Query::new_with_direction(false); bare_bound.insert_range_to_inclusive(..=encode_u64(4000)); - bare_bound_query.query.query.set_subquery(bare_bound); + bare_bound.limit = Some(1); + let mut selection = Query::new(); + selection.insert_key(temporal.document_id.to_vec()); + selection.set_subquery(bare_bound); + let mut history_path = + crate::drive::document::paths::contract_document_type_path_vec( + &temporal.contract_id, + &temporal.document_type_name, + ); + history_path.push(vec![2]); + let bare_bound_query = PathQuery::new( + history_path, + grovedb::SizedQuery::new(selection, None, None), + ); let bare_bound_proof = drive .grove_get_proved_path_query( &bare_bound_query, @@ -242,18 +254,7 @@ fn should_match_history_pages_at_every_temporal_boundary_before_and_after_migrat } } } - let mut document_query = temporal.construct_path_query(current).unwrap(); - document_query.query.limit = None; - // A merged proof keeps the temporal cap on the history walk itself. - // Execution-proof helpers clear document caps because their reads are untimed. - document_query - .query - .query - .default_subquery_branch - .subquery - .as_mut() - .unwrap() - .limit = Some(1); + let document_query = temporal.construct_path_query(current).unwrap(); let identity_query = Drive::identity_balance_query(&[3; 32]); let merged = PathQuery::merge( vec![&document_query, &identity_query], @@ -345,3 +346,502 @@ fn should_find_a_document_created_at_zero_at_time_zero() { serialized(&document, &contract) ); } + +#[test] +fn should_hide_a_deleted_document_at_and_after_its_delete_time() { + let version = PlatformVersion::latest(); + let (drive, mut contract, mut document) = temporal_fixture(version, false); + let mut schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + schema.set_value("canBeDeleted", true.into()).unwrap(); + schema.set_value("canBeErased", false.into()).unwrap(); + contract + .set_document_schema("person", schema, true, &mut vec![], version) + .unwrap(); + drive + .apply_contract(&contract, BlockInfo::default(), true, None, None, version) + .unwrap(); + document.set_revision(Some(1)); + write_revision(&drive, &contract, &document, 1000, true, version); + document.set_revision(Some(2)); + document.set("age", Value::U64(2)); + write_revision(&drive, &contract, &document, 2000, false, version); + drive + .delete_document_for_contract( + document.id(), + &contract, + "person", + BlockInfo::default_with_time(2000), + true, + None, + version, + ) + .unwrap(); + for (time, revision) in [ + (0, None), + (999, None), + (1000, Some(1)), + (1999, Some(1)), + (2000, None), + (2001, None), + (u64::MAX, None), + ] { + let query = person_at_block_time(&contract, document.id().to_buffer(), time); + let found = prove_and_verify_at(&drive, &contract, &query, version); + assert_eq!( + found.and_then(|doc| doc.revision()), + revision, + "delete takes effect at {time}" + ); + } + let mut schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + schema.set_value("canBeDeleted", false.into()).unwrap(); + contract + .set_document_schema("person", schema, true, &mut vec![], version) + .unwrap(); + drive + .apply_contract( + &contract, + BlockInfo::default_with_time(3000), + true, + None, + None, + version, + ) + .unwrap(); + let query = person_at_block_time(&contract, document.id().to_buffer(), u64::MAX); + assert_eq!( + prove_and_verify_at(&drive, &contract, &query, version), + None, + "narrowing deletion permission cannot remove lifecycle evidence from a timed lookup" + ); +} + +fn overwrite_retained_bytes( + drive: &Drive, + contract: &DataContract, + document: &Document, + bytes: Vec, +) { + use crate::drive::document::paths::document_history_path; + let version = PlatformVersion::latest(); + let path = document_history_path( + contract.id_ref().as_bytes(), + "person", + document.id().as_slice(), + ); + drive + .grove + .insert( + path.as_slice(), + &[encode_u64(1000), encode_u64(1)].concat(), + grovedb::Element::new_item(bytes), + None, + None, + &version.drive.grove_version, + ) + .value + .unwrap(); +} + +#[test] +fn should_reject_a_returned_document_body_that_does_not_match_its_history_key() { + let version = PlatformVersion::latest(); + for mismatch_id in [true, false] { + let (drive, contract, mut document) = temporal_fixture(version, false); + document.set_revision(Some(1)); + write_revision(&drive, &contract, &document, 1000, true, version); + let query = person_at_block_time(&contract, document.id().to_buffer(), 1000); + let original = document.clone(); + if mismatch_id { + document.set_id([9; 32].into()); + } else { + document.set_revision(Some(2)); + } + overwrite_retained_bytes( + &drive, + &contract, + &original, + serialized(&document, &contract), + ); + let proof = drive + .grove_get_proved_path_query( + &query.construct_path_query(version).unwrap(), + None, + &mut vec![], + &version.drive, + ) + .unwrap(); + for subset in [false, true] { + assert!( + query + .verify_proof( + subset, + &proof, + contract.document_type_for_name("person").unwrap(), + version + ) + .is_err(), + "the returned document must match its authenticated path and revision" + ); + } + } +} + +#[test] +fn should_discard_a_deleted_revision_without_decoding_its_body() { + let version = PlatformVersion::latest(); + let (drive, mut contract, mut document) = temporal_fixture(version, false); + let mut schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + schema.set_value("canBeDeleted", true.into()).unwrap(); + contract + .set_document_schema("person", schema, true, &mut vec![], version) + .unwrap(); + document.set_revision(Some(1)); + write_revision(&drive, &contract, &document, 1000, true, version); + drive + .delete_document_for_contract( + document.id(), + &contract, + "person", + BlockInfo::default_with_time(2000), + true, + None, + version, + ) + .unwrap(); + overwrite_retained_bytes(&drive, &contract, &document, vec![0xff]); + let query = person_at_block_time(&contract, document.id().to_buffer(), 2000); + let proof = drive + .grove_get_proved_path_query( + &query.construct_path_query(version).unwrap(), + None, + &mut vec![], + &version.drive, + ) + .unwrap(); + for subset in [false, true] { + assert_eq!( + query + .verify_proof_keep_serialized(subset, &proof, version) + .unwrap() + .1, + None + ); + assert_eq!( + query + .verify_proof( + subset, + &proof, + contract.document_type_for_name("person").unwrap(), + version + ) + .unwrap() + .1, + None + ); + } +} + +#[test] +fn should_prove_absence_for_every_time_once_erasing_starts_and_after_it_finishes() { + let mut version = PlatformVersion::latest().clone(); + version + .system_limits + .max_document_revisions_erased_per_transition = Some(2); + let (drive, mut contract, mut document) = temporal_fixture(&version, false); + let mut schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + schema.set_value("canBeDeleted", true.into()).unwrap(); + schema.set_value("canBeErased", true.into()).unwrap(); + contract + .set_document_schema("person", schema, true, &mut vec![], &version) + .unwrap(); + for revision in 1..=3 { + document.set_revision(Some(revision)); + document.set("age", Value::U64(revision)); + write_revision( + &drive, + &contract, + &document, + revision * 1000, + revision == 1, + &version, + ); + } + drive + .delete_document_for_contract( + document.id(), + &contract, + "person", + BlockInfo::default_with_time(3000), + true, + None, + &version, + ) + .unwrap(); + for terminal in [false, true] { + let operations = drive + .erase_document_for_contract_operations( + document.id(), + &contract, + contract.document_type_for_name("person").unwrap(), + &BlockInfo::default_with_time(4000), + &mut None, + None, + &version, + ) + .unwrap(); + drive + .apply_batch_low_level_drive_operations( + None, + None, + operations, + &mut vec![], + &version.drive, + ) + .unwrap(); + let page = drive + .fetch_document_history( + &DocumentHistoryDriveQuery { + contract_id: contract.id().to_buffer(), + document_type_name: "person".into(), + document_id: document.id().to_buffer(), + filter: DocumentHistoryFilter::StartAtTime(0), + limit: None, + }, + contract.document_type_for_name("person").unwrap(), + None, + &version, + ) + .unwrap(); + assert_eq!(page.entries.len(), if terminal { 0 } else { 1 }); + for time in [0, 999, 1000, 2000, 2999, 3000, 4000, u64::MAX] { + let query = person_at_block_time(&contract, document.id().to_buffer(), time); + assert_eq!( + prove_and_verify_at(&drive, &contract, &query, &version), + None, + "erase hides every time {time}, terminal {terminal}" + ); + } + let latest = SingleDocumentDriveQuery { + block_time_ms: None, + ..person_at_block_time(&contract, document.id().to_buffer(), u64::MAX) + }; + assert_eq!( + prove_and_verify_at(&drive, &contract, &latest, &version), + None + ); + } +} + +#[test] +fn should_not_decode_a_record_only_result_as_a_document_and_should_ignore_other_ids() { + use crate::drive::document::paths::contract_document_type_path_vec; + use dpp::document::lifecycle::DocumentLifecycleRecord; + use dpp::serialization::PlatformSerializable; + let version = PlatformVersion::latest(); + let (drive, contract, mut document) = temporal_fixture(version, false); + let type_path = contract_document_type_path_vec(contract.id_ref().as_bytes(), "person"); + drive + .grove + .insert( + type_path.as_slice(), + &[1], + grovedb::Element::empty_tree(), + None, + None, + &version.drive.grove_version, + ) + .value + .unwrap(); + let mut record_path = type_path; + record_path.push(vec![1]); + let absent_id = [9; 32]; + let only_record = person_at_block_time(&contract, absent_id, 0); + // The existing empty lifecycle container proves absence for an unrelated id. + assert_eq!( + prove_and_verify_at(&drive, &contract, &only_record, version), + None + ); + drive + .grove + .insert( + record_path.as_slice(), + &absent_id, + grovedb::Element::new_item( + DocumentLifecycleRecord::deleted_at(0, 1, 1) + .serialize_to_bytes() + .unwrap(), + ), + None, + None, + &version.drive.grove_version, + ) + .value + .unwrap(); + for time in [0, u64::MAX] { + let query = person_at_block_time(&contract, absent_id, time); + let proof = drive + .grove_get_proved_path_query( + &query.construct_path_query(version).unwrap(), + None, + &mut vec![], + &version.drive, + ) + .unwrap(); + for subset in [false, true] { + assert_eq!( + query + .verify_proof_keep_serialized(subset, &proof, version) + .unwrap() + .1, + None + ); + assert_eq!( + query + .verify_proof( + subset, + &proof, + contract.document_type_for_name("person").unwrap(), + version + ) + .unwrap() + .1, + None + ); + } + } + document.set_revision(Some(1)); + write_revision(&drive, &contract, &document, 1000, true, version); + let found = prove_and_verify_at( + &drive, + &contract, + &person_at_block_time(&contract, document.id().to_buffer(), 1000), + version, + ) + .unwrap(); + assert_eq!( + serialized(&found, &contract), + serialized(&document, &contract) + ); +} + +#[test] +fn should_reject_a_history_only_proof_that_omits_an_existing_deletion_record() { + let version = PlatformVersion::latest(); + let (drive, mut contract, mut document) = temporal_fixture(version, false); + let mut schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + schema.set_value("canBeDeleted", true.into()).unwrap(); + contract + .set_document_schema("person", schema, true, &mut vec![], version) + .unwrap(); + document.set_revision(Some(1)); + write_revision(&drive, &contract, &document, 1000, true, version); + drive + .delete_document_for_contract( + document.id(), + &contract, + "person", + BlockInfo::default_with_time(2000), + true, + None, + version, + ) + .unwrap(); + let query = person_at_block_time(&contract, document.id().to_buffer(), 2000); + let mut history_path = crate::drive::document::paths::contract_document_type_path_vec( + &query.contract_id, + &query.document_type_name, + ); + history_path.push(vec![2]); + let mut selection = Query::new(); + selection.insert_key(query.document_id.to_vec()); + let mut revisions = Query::new_with_direction(false); + revisions.insert_range_inclusive(encode_u64(0)..=[encode_u64(2000), vec![0xff; 8]].concat()); + revisions.limit = Some(1); + selection.set_subquery(revisions); + let old_query = PathQuery::new( + history_path, + grovedb::SizedQuery::new(selection, None, None), + ); + let old_proof = drive + .grove_get_proved_path_query(&old_query, None, &mut vec![], &version.drive) + .unwrap(); + let (_, rows) = + GroveDb::verify_query(&old_proof, &old_query, &version.drive.grove_version).unwrap(); + assert_eq!( + rows.len(), + 1, + "the history-only proof authenticates the stale retained revision" + ); + for subset in [false, true] { + assert!( + query + .verify_proof_keep_serialized(subset, &old_proof, version) + .is_err(), + "the lifecycle-aware query must also authenticate the existing record" + ); + } +} + +#[test] +fn should_compare_the_unclamped_delete_time_and_allow_deletion_at_zero() { + let version = PlatformVersion::latest(); + for (created_at, deleted_at) in [(0, 0), (1000, u64::MAX)] { + let (drive, mut contract, mut document) = temporal_fixture(version, false); + let mut schema = contract + .document_type_for_name("person") + .unwrap() + .schema() + .clone(); + schema.set_value("canBeDeleted", true.into()).unwrap(); + contract + .set_document_schema("person", schema, true, &mut vec![], version) + .unwrap(); + document.set_revision(Some(1)); + write_revision(&drive, &contract, &document, created_at, true, version); + drive + .delete_document_for_contract( + document.id(), + &contract, + "person", + BlockInfo::default_with_time(deleted_at), + true, + None, + version, + ) + .unwrap(); + for time in [0, 1000, i64::MAX as u64, u64::MAX - 1, u64::MAX] { + let found = prove_and_verify_at( + &drive, + &contract, + &person_at_block_time(&contract, document.id().to_buffer(), time), + version, + ); + assert_eq!( + found.is_some(), + time >= created_at && time < deleted_at, + "created {created_at}, deleted {deleted_at}, requested {time}" + ); + } + } +} diff --git a/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index 90e383617f5..4e4a60c8155 100644 --- a/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -609,6 +609,23 @@ impl Drive { .to_string(), ))) } + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(erase_transition) => { + // An erase acts on a document that was already + // deleted, so the by-id proof shows it absent + // both before and after. The absence is the + // state the transition affected, not evidence + // that this erase ran; the classifier below + // reports it as such. + if document.is_some() { + return Err(Error::Proof(ProofError::IncorrectProof(format!("proof of state transition execution contained a current document for erased id {}", erase_transition.base().id())))); + } + Ok(( + root_hash, + BTreeMap::from([(erase_transition.base().id(), None)]), + )) + } }?; document_owner_balance = owner_balance; Ok((root_hash, VerifiedDocuments(documents))) @@ -3108,11 +3125,10 @@ impl Drive { /// the state the transition affects at the committed block /// (`AffectedState`). /// - /// This classifier is deliberately an exhaustive `match` over every - /// transition family — and, for tokens, over the contract's keeps-history - /// configuration and group usage — so adding a new variant fails to - /// compile until it is classified here: no transition can silently - /// inherit the stronger `ExecutionProved` guarantee. + /// Transition families and token kinds are matched exhaustively. Ordinary + /// document transitions bind their document or deletion outcome, except for + /// erase, index-only storage, and shielded token payments, whose affected + /// state does not identify the specific request that produced it. fn state_transition_proof_binds_execution( state_transition: &StateTransition, known_contracts_provider_fn: &ContractLookupFn, @@ -3137,31 +3153,40 @@ impl Drive { // neither id, entropy nor nonce and so cannot bind one // specific transition's execution. Some(BatchedTransitionRef::Document(document_transition)) => { - use dpp::data_contract::document_type::accessors::DocumentTypeV2Getters; + match document_transition { + // Protocols through 14 reject erase. Its by-id absence + // already held after delete, so it cannot prove this erase ran. + DocumentTransition::Erase(_) => false, + _ => { + use dpp::data_contract::document_type::accessors::DocumentTypeV2Getters; use dpp::state_transition::batch_transition::document_base_transition::v1::v1_methods::DocumentBaseTransitionV1Methods; use dpp::tokens::token_payment_info::v1::v1_accessors::TokenPaymentInfoAccessorsV1; - let data_contract_id = document_transition.data_contract_id(); - let contract = known_contracts_provider_fn(&data_contract_id)?.ok_or( - Error::Proof(ProofError::UnknownContract(format!( - "unknown contract with id {} in document verification", - data_contract_id - ))), - )?; - let index_only = contract - .document_type_for_name(document_transition.document_type_name()) - .map_err(|e| Error::Proof(ProofError::UnknownContract(e.to_string())))? - .index_only(); - // A document whose token cost is paid from a shielded pool is proven by the - // document and, where one is read, the owner's balance — neither of which - // names the bundle that paid. Two different payments leave the same document - // behind, so a proof of the document is not a proof of the payment the - // request carried, and only the state it affects is proven. - let paid_from_a_shielded_pool = document_transition - .base() - .token_payment_info_ref() - .as_ref() - .is_some_and(|info| info.shielded_payment().is_some()); - !index_only && !paid_from_a_shielded_pool + let data_contract_id = document_transition.data_contract_id(); + let contract = known_contracts_provider_fn(&data_contract_id)?.ok_or( + Error::Proof(ProofError::UnknownContract(format!( + "unknown contract with id {} in document verification", + data_contract_id + ))), + )?; + let index_only = contract + .document_type_for_name(document_transition.document_type_name()) + .map_err(|e| { + Error::Proof(ProofError::UnknownContract(e.to_string())) + })? + .index_only(); + // A document whose token cost is paid from a shielded pool is proven by the + // document and, where one is read, the owner's balance — neither of which + // names the bundle that paid. Two different payments leave the same document + // behind, so a proof of the document is not a proof of the payment the + // request carried, and only the state it affects is proven. + let paid_from_a_shielded_pool = document_transition + .base() + .token_payment_info_ref() + .as_ref() + .is_some_and(|info| info.shielded_payment().is_some()); + !index_only && !paid_from_a_shielded_pool + } + } } Some(BatchedTransitionRef::Token(token_transition)) => { let data_contract_id = token_transition.data_contract_id(); @@ -4717,6 +4742,148 @@ mod tests { } } + /// An erase acts on a document that was already deleted, so the by-id + /// proof shows the same absence whether or not it ran. The classifier must + /// report that as affected state, while a delete over the very same proof + /// stays execution-proved: a document's absence by id is read as the + /// delete's outcome, which is what the SDK's strict wait relies on. + #[test] + fn verify_batch_document_erase_is_affected_state_not_execution_proved() { + use dpp::document::DocumentV0Setters; + use dpp::state_transition::batch_transition::batched_transition::document_erase_transition::{ + DocumentEraseTransition, DocumentEraseTransitionV0, + }; + use dpp::state_transition::batch_transition::batched_transition::document_transition::DocumentTransition; + use dpp::state_transition::batch_transition::document_base_transition::v0::DocumentBaseTransitionV0; + use dpp::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; + use dpp::state_transition::batch_transition::document_delete_transition::{ + DocumentDeleteTransition, DocumentDeleteTransitionV0, + }; + use dpp::state_transition::batch_transition::{BatchTransition, BatchTransitionV0}; + use dpp::tests::json_document::{json_document_to_contract, json_document_to_document}; + + let platform_version = PlatformVersion::latest(); + let drive = setup_drive_with_initial_state_structure(None); + let owner = add_batch_owner(&drive, 17, platform_version); + let contract = json_document_to_contract( + "tests/supporting_files/contract/family/family-contract-with-history.json", + false, + platform_version, + ) + .expect("expected the family history contract"); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + None, + None, + platform_version, + ) + .expect("expected to apply the contract"); + let document_type = contract + .document_type_for_name("person") + .expect("expected the person type"); + let mut document = json_document_to_document( + "tests/supporting_files/contract/family/person0.json", + Some([4u8; 32].into()), + document_type, + platform_version, + ) + .expect("expected a person"); + for revision in 1..=2u64 { + document.set_revision(Some(revision)); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo((&document, None)), + owner_id: None, + }, + contract: &contract, + document_type, + }, + revision > 1, + BlockInfo::default_with_time(1_000 + revision), + true, + None, + platform_version, + ) + .expect("expected to write a revision"); + } + let doc_id = document.id(); + drive + .delete_document_for_contract( + doc_id, + &contract, + "person", + BlockInfo::default_with_time(5_000), + true, + None, + platform_version, + ) + .expect("expected the delete to succeed"); + + let base = || { + DocumentBaseTransition::V0(DocumentBaseTransitionV0 { + id: doc_id, + identity_contract_nonce: 1, + document_type_name: "person".to_string(), + data_contract_id: contract.id(), + }) + }; + let batch = |transition: DocumentTransition| { + StateTransition::Batch(BatchTransition::V0(BatchTransitionV0 { + owner_id: owner.id(), + transitions: vec![transition], + ..Default::default() + })) + }; + let contract_arc = Arc::new(contract.clone()); + let known_contracts_provider_fn: &ContractLookupFn = &|_id| Ok(Some(contract_arc.clone())); + let verify = |state_transition: StateTransition| { + let proof = drive + .prove_state_transition(&state_transition, None, platform_version) + .expect("expected to prove the transition's affected state") + .into_data() + .expect("expected proof bytes"); + Drive::verify_state_transition_was_executed_with_proof( + &state_transition, + &BlockInfo::default(), + &proof, + known_contracts_provider_fn, + platform_version, + ) + .expect("expected verification to succeed") + .1 + }; + + let erase_outcome = verify(batch(DocumentTransition::Erase( + DocumentEraseTransition::V0(DocumentEraseTransitionV0 { base: base() }), + ))); + assert!( + !erase_outcome.is_execution_proved(), + "erase authenticates affected state only" + ); + match erase_outcome.into_result() { + StateTransitionProofResult::VerifiedDocuments(documents) => { + assert_eq!(documents.len(), 1); + let (id, found) = documents.into_iter().next().unwrap(); + assert_eq!(id, doc_id); + assert!(found.is_none(), "the document is absent by id"); + } + other => panic!("an erase must be classified as affected state, got {other:?}"), + } + + let delete_outcome = verify(batch(DocumentTransition::Delete( + DocumentDeleteTransition::V0(DocumentDeleteTransitionV0 { base: base() }), + ))); + assert!( + delete_outcome.is_execution_proved(), + "a delete over the same proof stays execution-proved, got {delete_outcome:?}" + ); + } + // ----------------------------------------------------------------------- // Batch: before protocol version 14 the proof carries no balance // ----------------------------------------------------------------------- diff --git a/packages/rs-drive/tests/drive_storage_ops_coverage.rs b/packages/rs-drive/tests/drive_storage_ops_coverage.rs index 33a8fc3d5cc..1b1671bd290 100644 --- a/packages/rs-drive/tests/drive_storage_ops_coverage.rs +++ b/packages/rs-drive/tests/drive_storage_ops_coverage.rs @@ -871,6 +871,7 @@ mod document_operation_tests { let id = dpp::prelude::Identifier::new([2u8; 32]); let _op = DocumentOperationType::DeleteDocument { document_id: id, + deleter_id: None, contract_info: drive::util::object_size_info::DataContractInfo::DataContractId( dpp::prelude::Identifier::new([3u8; 32]), ), diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs index 7c68c209d79..b8058bc425f 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/v7.rs @@ -1,10 +1,12 @@ use crate::version::dpp_versions::dpp_contract_versions::v6::CONTRACT_VERSIONS_V6; use crate::version::dpp_versions::dpp_contract_versions::{ - DPPContractVersions, DataContractMethodVersions, DocumentTypeMethodVersions, - DocumentTypeSchemaVersions, DocumentTypeVersions, + DPPContractVersions, DataContractMethodVersions, DocumentTypeClassMethodVersions, + DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeVersions, }; /// Introduced in protocol version 15. Differs from v6 in: +/// - `try_from_schema`, 4 rather than 3: parses `canBeErased` and admits deletable +/// keep-history types, while preserving generation 3's non-lifecycle parsing; /// - `parse_property_constraints`, 1 rather than 0: a `countOf` or `sumOf` of a /// `propertyConstraints` or `deleteConstraints` rule may match its documents by a byte array /// key, bound to a byte array property of the document written (or deleted), as it matches @@ -16,6 +18,8 @@ use crate::version::dpp_versions::dpp_contract_versions::{ /// - `check_document_type_schema`, 1 rather than 0: a schema is checked at registration /// natively instead of against the document meta-schema through the `jsonschema` crate, and /// every new document type must have a validation schema; +/// - `validate_max_depth`, 2 rather than 1: the depth and cycle check resolves `$ref` +/// pointers by RFC 6901, as the native validator does; /// - `validation_schema`, `Some(0)` rather than `None`: builds that typed validation schema /// and the native validator; /// - `parse_private_document`, `Some(0)` rather than `None`: the `private` keyword declares a @@ -42,12 +46,18 @@ use crate::version::dpp_versions::dpp_contract_versions::{ pub const CONTRACT_VERSIONS_V7: DPPContractVersions = DPPContractVersions { methods: DataContractMethodVersions { // changed: the document type's native validator checks the schema in place of the - // `jsonschema` crate, reaching the same verdicts but for one rule of its own: in a - // `uniqueItems` list, `0.0` and `-0.0` are one value however long the list + // `jsonschema` crate: uniqueItems treats signed zeros as one value, and a + // format:regex value is checked for syntax rather than compilation validate_document: 2, ..CONTRACT_VERSIONS_V6.methods }, document_type_versions: DocumentTypeVersions { + class_method_versions: DocumentTypeClassMethodVersions { + try_from_schema: 4, // lifecycle flags extend the schema-v3 grammar (note 41) + ..CONTRACT_VERSIONS_V6 + .document_type_versions + .class_method_versions + }, schema: DocumentTypeSchemaVersions { // changed: checks a schema natively at registration and requires a validation schema check_document_type_schema: 1, diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/mod.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/mod.rs index 93461710789..6d4fb11da4d 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/mod.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/mod.rs @@ -3,6 +3,7 @@ use versioned_feature_core::FeatureVersionBounds; pub mod v1; pub mod v2; pub mod v3; +pub mod v4; #[derive(Clone, Debug, Default)] pub struct DPPStateTransitionSerializationVersions { @@ -35,6 +36,11 @@ pub struct DPPStateTransitionSerializationVersions { /// as `OptionalFeatureVersion`), and the batch basic-structure wire /// gate rejects the variant wherever this is `None`. pub document_index_only_delete_state_transition: Option, + /// The erase kind, which purges the retained revisions of a deleted + /// keep-history document. `None` below protocol version 15 — the kind does + /// not exist on the wire there, and the batch basic-structure wire gate + /// rejects the variant wherever this is `None`. + pub document_erase_state_transition: Option, pub document_transfer_state_transition: DocumentFeatureVersionBounds, pub document_update_price_state_transition: DocumentFeatureVersionBounds, pub document_purchase_state_transition: DocumentFeatureVersionBounds, diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v1.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v1.rs index a0dbfb79fc9..72badd7e04f 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v1.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v1.rs @@ -113,6 +113,8 @@ pub const STATE_TRANSITION_SERIALIZATION_VERSIONS_V1: DPPStateTransitionSerializ }, // The indexOnly delete kind joins the wire at PV14. document_index_only_delete_state_transition: None, + // The erase kind joins the wire at protocol version 15. + document_erase_state_transition: None, document_transfer_state_transition: DocumentFeatureVersionBounds { bounds: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v2.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v2.rs index 0b2dbb148e2..bf35af2f2f2 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v2.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v2.rs @@ -113,6 +113,8 @@ pub const STATE_TRANSITION_SERIALIZATION_VERSIONS_V2: DPPStateTransitionSerializ }, // The indexOnly delete kind joins the wire at PV14. document_index_only_delete_state_transition: None, + // The erase kind joins the wire at protocol version 15. + document_erase_state_transition: None, document_transfer_state_transition: DocumentFeatureVersionBounds { bounds: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v3.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v3.rs index f96754f6579..ff16dbf8066 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v3.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v3.rs @@ -132,6 +132,8 @@ pub const STATE_TRANSITION_SERIALIZATION_VERSIONS_V3: DPPStateTransitionSerializ default_current_version: 0, }, }), + // The erase kind joins the wire at protocol version 15. + document_erase_state_transition: None, document_transfer_state_transition: DocumentFeatureVersionBounds { bounds: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v4.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v4.rs new file mode 100644 index 00000000000..51392436e0d --- /dev/null +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_serialization_versions/v4.rs @@ -0,0 +1,25 @@ +//! V4 (PV15): V3 plus the erase kind. +//! +//! `DocumentEraseTransition` purges the retained revisions of a deleted +//! keep-history document. The kind is appended to the batch's document +//! transition enum; `document_erase_state_transition` bounds its generation +//! and stays `None` in every earlier table, where the batch basic-structure +//! gate refuses the kind. + +use crate::version::dpp_versions::dpp_state_transition_serialization_versions::v3::STATE_TRANSITION_SERIALIZATION_VERSIONS_V3; +use crate::version::dpp_versions::dpp_state_transition_serialization_versions::{ + DPPStateTransitionSerializationVersions, DocumentFeatureVersionBounds, +}; +use versioned_feature_core::FeatureVersionBounds; + +pub const STATE_TRANSITION_SERIALIZATION_VERSIONS_V4: DPPStateTransitionSerializationVersions = + DPPStateTransitionSerializationVersions { + document_erase_state_transition: Some(DocumentFeatureVersionBounds { + bounds: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }), + ..STATE_TRANSITION_SERIALIZATION_VERSIONS_V3 + }; diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/mod.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/mod.rs index 52c521e4309..c16174c22a6 100644 --- a/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/mod.rs +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/mod.rs @@ -5,6 +5,7 @@ pub mod v2; pub mod v3; pub mod v4; pub mod v5; +pub mod v6; #[derive(Clone, Debug, Default)] pub struct DPPValidationVersions { diff --git a/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v6.rs b/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v6.rs new file mode 100644 index 00000000000..dbb8ce60616 --- /dev/null +++ b/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v6.rs @@ -0,0 +1,18 @@ +use crate::version::dpp_versions::dpp_validation_versions::{ + DPPValidationVersions, DocumentTypeValidationVersions, +}; + +use super::v5::DPP_VALIDATION_VERSIONS_V5; + +/// Protocol v15 validation versions. +/// +/// v2 document-type update validation knows the `canBeErased` keyword: it +/// keeps erasability immutable in both directions and lets a keep-history +/// type withdraw deletion only while it is not erasable. +pub const DPP_VALIDATION_VERSIONS_V6: DPPValidationVersions = DPPValidationVersions { + document_type: DocumentTypeValidationVersions { + validate_update: 2, + ..DPP_VALIDATION_VERSIONS_V5.document_type + }, + ..DPP_VALIDATION_VERSIONS_V5 +}; diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs index 3f2a0e083c2..b9837817644 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs @@ -263,6 +263,8 @@ pub struct DriveAbciDocumentsStateTransitionValidationVersions { /// The indexOnly delete-by-values kind (PV14+); 0 in every earlier /// version table, where the kind cannot appear. pub document_index_only_delete_transition_structure_validation: FeatureVersion, + /// The erase kind, active from protocol version 15. + pub document_erase_transition_structure_validation: OptionalFeatureVersion, pub document_replace_transition_structure_validation: FeatureVersion, pub document_transfer_transition_structure_validation: FeatureVersion, pub document_purchase_transition_structure_validation: FeatureVersion, @@ -273,6 +275,8 @@ pub struct DriveAbciDocumentsStateTransitionValidationVersions { /// The indexOnly delete-by-values kind (PV14+); 0 in every earlier /// version table, where the kind cannot appear. pub document_index_only_delete_transition_state_validation: FeatureVersion, + /// The erase kind, active from protocol version 15. + pub document_erase_transition_state_validation: OptionalFeatureVersion, pub document_replace_transition_state_validation: FeatureVersion, pub document_transfer_transition_state_validation: FeatureVersion, pub document_purchase_transition_state_validation: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v1.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v1.rs index 48d526658a3..6f091caba9a 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v1.rs @@ -154,6 +154,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V1: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -162,6 +163,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V1: DriveAbciValidationVersions = document_create_transition_state_validation: 0, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs index ae45ad2be05..154595ba277 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs @@ -255,6 +255,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V10: DriveAbciValidationVersions = // Protocols through 13 retain the original internal-error outcome. document_delete_transition_structure_validation: 1, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, // unchanged: v0 gained the `distinctFrom` refusal in place, inert before this version document_transfer_transition_structure_validation: 0, // unchanged: v0 gained the `distinctFrom: $ownerId` judgement in place, inert before this version document_purchase_transition_structure_validation: 0, // unchanged: v0 gained the `distinctFrom: $ownerId` judgement in place, inert before this version @@ -263,6 +264,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V10: DriveAbciValidationVersions = document_create_transition_state_validation: 2, document_delete_transition_state_validation: 1, // changed: v1 judges the document type's `deleteConstraints` on the stored document document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 1, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs index 597d4537f22..6f990d7d0ad 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs @@ -70,6 +70,11 @@ use super::{ /// `DataContractUpdate` (`PublicKeyWithLimitsCannotSignDataContractTransitionError`, 20018): a /// data contract commits its owner beyond the transition that sets it up or changes it. /// +/// - document delete `structure_validation` 2 admits a deletable keep-history type; +/// `document_erase_transition_structure_validation` and +/// `document_erase_transition_state_validation` are `Some(0)`: an erase must name an +/// erasable type and a deleted document, with its owner's authorization to begin. +/// /// v10 remains unchanged for `PROTOCOL_VERSION_14` chain replay. pub const DRIVE_ABCI_VALIDATION_VERSIONS_V11: DriveAbciValidationVersions = DriveAbciValidationVersions { @@ -112,6 +117,10 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V11: DriveAbciValidationVersions = .contract_update_state_transition }, batch_state_transition: DriveAbciDocumentsStateTransitionValidationVersions { + document_delete_transition_structure_validation: 2, // a keep-history type may be deleted when its deletion flag permits it + document_delete_transition_state_validation: 1, // the upstream owner, nonce and constraint checks also cover a history delete + document_erase_transition_structure_validation: Some(0), // an erase requires a permanent erasable history type + document_erase_transition_state_validation: Some(0), // a deleted document needs owner authorization to start erasure advanced_structure: 2, // a tradeable token must be transferable, checked in check_tx too document_reference_validation: 1, // a consumed commitment keeps what its lookup read document_create_transition_structure_validation: 2, // a decision proposal states its fund, a rule within the limits and an end date one to four weeks away; the poll a contested create names is compared with the expected one by what names the index diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v2.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v2.rs index 8b05b02e8aa..58c1e4d9f70 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v2.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v2.rs @@ -154,6 +154,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V2: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -162,6 +163,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V2: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v3.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v3.rs index 6fa1e0b8ff3..99e94a8b6ce 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v3.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v3.rs @@ -154,6 +154,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V3: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -162,6 +163,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V3: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v4.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v4.rs index 18de98b3f8b..0779288ce53 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v4.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v4.rs @@ -157,6 +157,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V4: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -165,6 +166,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V4: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs index b51550463b0..59e0857cea5 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs @@ -158,6 +158,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V5: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -166,6 +167,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V5: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v6.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v6.rs index baf9dea15d5..d70998a9bf5 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v6.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v6.rs @@ -161,6 +161,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V6: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -169,6 +170,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V6: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v7.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v7.rs index 96ea9ba6999..7acf630291f 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v7.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v7.rs @@ -155,6 +155,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V7: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -163,6 +164,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V7: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs index 30c6b50ea64..595832441fe 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs @@ -209,6 +209,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V8: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -217,6 +218,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V8: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v9.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v9.rs index 39725f600a3..9018d4f1524 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v9.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v9.rs @@ -205,6 +205,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V9: DriveAbciValidationVersions = document_create_transition_structure_validation: 0, document_delete_transition_structure_validation: 0, document_index_only_delete_transition_structure_validation: 0, + document_erase_transition_structure_validation: None, document_replace_transition_structure_validation: 0, document_transfer_transition_structure_validation: 0, document_purchase_transition_structure_validation: 0, @@ -213,6 +214,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V9: DriveAbciValidationVersions = document_create_transition_state_validation: 1, document_delete_transition_state_validation: 0, document_index_only_delete_transition_state_validation: 0, + document_erase_transition_state_validation: None, document_replace_transition_state_validation: 0, document_transfer_transition_state_validation: 0, document_purchase_transition_state_validation: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs index bcc6ae4b848..f1615e0ef98 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs @@ -65,6 +65,8 @@ pub struct DriveDocumentExpirationMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveDocumentQueryMethodVersions { + pub fetch_document_lifecycle: OptionalFeatureVersion, + pub query_documents: FeatureVersion, /// Chained document queries (provable semi-join): the version slot /// shared by the no-proof and the two-proof execution paths. @@ -206,6 +208,12 @@ pub struct DriveDocumentUpdateMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveDocumentDeleteMethodVersions { + /// Prices the third-party balance updates caused by an erase; inactive before protocol 15. + pub erase_refund_recipient_cost: OptionalFeatureVersion, + pub erase_document_for_contract_operations: OptionalFeatureVersion, + pub add_estimation_costs_for_erase_document: OptionalFeatureVersion, + pub add_estimation_costs_for_lifecycle_record: OptionalFeatureVersion, + pub add_estimation_costs_for_remove_document_to_primary_storage: FeatureVersion, pub delete_document_for_contract: FeatureVersion, pub delete_document_for_contract_id: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs index 77a2bdaa2c5..5397b6e1680 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs @@ -9,6 +9,8 @@ use crate::version::drive_versions::drive_document_method_versions::{ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V1: DriveDocumentMethodVersions = DriveDocumentMethodVersions { query: DriveDocumentQueryMethodVersions { + fetch_document_lifecycle: None, + query_documents: 0, query_chained_documents: 0, query_composite_documents: 0, @@ -30,6 +32,11 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V1: DriveDocumentMethodVersions = single_document_path_query: 0, }, delete: DriveDocumentDeleteMethodVersions { + erase_refund_recipient_cost: None, + erase_document_for_contract_operations: None, + add_estimation_costs_for_erase_document: None, + add_estimation_costs_for_lifecycle_record: None, + add_estimation_costs_for_remove_document_to_primary_storage: 0, delete_document_for_contract: 0, delete_document_for_contract_id: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs index e9039a9fd7d..bc0493a50be 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs @@ -11,6 +11,8 @@ use crate::version::drive_versions::drive_document_method_versions::{ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V2: DriveDocumentMethodVersions = DriveDocumentMethodVersions { query: DriveDocumentQueryMethodVersions { + fetch_document_lifecycle: None, + query_documents: 0, query_chained_documents: 0, query_composite_documents: 0, @@ -32,6 +34,11 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V2: DriveDocumentMethodVersions = single_document_path_query: 0, }, delete: DriveDocumentDeleteMethodVersions { + erase_refund_recipient_cost: None, + erase_document_for_contract_operations: None, + add_estimation_costs_for_erase_document: None, + add_estimation_costs_for_lifecycle_record: None, + add_estimation_costs_for_remove_document_to_primary_storage: 0, delete_document_for_contract: 0, delete_document_for_contract_id: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs index bfe5d4757c2..83f1fc767bc 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs @@ -21,6 +21,8 @@ use crate::version::drive_versions::drive_document_method_versions::{ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V3: DriveDocumentMethodVersions = DriveDocumentMethodVersions { query: DriveDocumentQueryMethodVersions { + fetch_document_lifecycle: None, + query_documents: 0, query_chained_documents: 0, query_composite_documents: 0, @@ -42,6 +44,11 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V3: DriveDocumentMethodVersions = single_document_path_query: 0, }, delete: DriveDocumentDeleteMethodVersions { + erase_refund_recipient_cost: None, + erase_document_for_contract_operations: None, + add_estimation_costs_for_erase_document: None, + add_estimation_costs_for_lifecycle_record: None, + add_estimation_costs_for_remove_document_to_primary_storage: 0, delete_document_for_contract: 0, delete_document_for_contract_id: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v4.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v4.rs index d88785e81c7..07cde9c452e 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v4.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v4.rs @@ -92,6 +92,8 @@ use crate::version::drive_versions::drive_document_method_versions::{ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V4: DriveDocumentMethodVersions = DriveDocumentMethodVersions { query: DriveDocumentQueryMethodVersions { + fetch_document_lifecycle: None, + query_documents: 0, query_chained_documents: 0, query_composite_documents: 0, @@ -116,6 +118,11 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V4: DriveDocumentMethodVersions = single_document_path_query: 0, }, delete: DriveDocumentDeleteMethodVersions { + erase_refund_recipient_cost: None, + erase_document_for_contract_operations: None, + add_estimation_costs_for_erase_document: None, + add_estimation_costs_for_lifecycle_record: None, + add_estimation_costs_for_remove_document_to_primary_storage: 0, delete_document_for_contract: 0, delete_document_for_contract_id: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v5.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v5.rs index ed78d15f4a5..4521d1e31af 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v5.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v5.rs @@ -25,6 +25,15 @@ use crate::version::drive_versions::drive_document_method_versions::{ /// * `estimation_costs.stateless_delete_of_non_tree_for_costs` is 1: a delete's estimate prices /// each height of the climb with the layer GroveDB deletes in there, not the one above it. /// * Retained-history writers, readers and estimators use the per-type revision layout. +/// `insert.add_document_for_contract_operations` is 2: a retained id cannot be recreated. +/// * `delete.delete_document_for_contract_operations` is 1: deleting a history document +/// removes its current pointer and indices and writes a lifecycle record. Its primary +/// removal and removal estimate selectors are 1, describing the composite pointer. +/// * `query.fetch_document_lifecycle` is `Some(0)`: reads the current document or its record. +/// `delete.erase_document_for_contract_operations`, `add_estimation_costs_for_erase_document` +/// and `add_estimation_costs_for_lifecycle_record` are `Some(0)`: bounded erasure removes +/// retained revisions and prices the chunk and its lifecycle metadata. +/// `delete.erase_refund_recipient_cost` is `Some(0)`: prices the balance updates caused by erase refunds. /// * `update.update_document_for_contract_operations` is 2: when an update names a new owner, /// the references of the indexes it leaves unchanged are rewritten with that owner. /// * `update.update_document_for_contract_apply_and_add_to_operations` is 1: an update applied @@ -42,6 +51,7 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V5: DriveDocumentMethodVersions = DriveDocumentMethodVersions { document_history_storage_layout: 1, query: DriveDocumentQueryMethodVersions { + fetch_document_lifecycle: Some(0), // changed: reads the current document or lifecycle record single_document_path_query: 1, // changed: a temporal lookup selects the latest retained revision fetch_document_history_query: 1, fetch_document_history: 1, @@ -49,6 +59,7 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V5: DriveDocumentMethodVersions = ..DRIVE_DOCUMENT_METHOD_VERSIONS_V4.query }, insert: DriveDocumentInsertMethodVersions { + add_document_for_contract_operations: 2, // changed: refuses reusing a retained document id add_document_to_primary_storage: 1, add_indices_for_top_index_level_for_contract_operations: 3, // changed: no entry in an expired time range bucket add_reference_for_index_level_for_contract_operations: 1, // changed: a summable index's entries layer is described as references with sum items @@ -59,6 +70,13 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V5: DriveDocumentMethodVersions = prove_private_document_entries: Some(0), // changed: and proved append_private_document_entries_operations: Some(0), // changed: a PrivateDocumentCreateFromShieldedPool appends entries to a store delete: DriveDocumentDeleteMethodVersions { + erase_refund_recipient_cost: Some(0), // changed: prices third-party balance work caused by erasure + add_estimation_costs_for_remove_document_to_primary_storage: 1, // changed: estimates removal of the composite current pointer + remove_document_from_primary_storage: 1, // changed: removes only the current history pointer + delete_document_for_contract_operations: 1, // changed: retains history and records deletion + erase_document_for_contract_operations: Some(0), // changed: erases one bounded chunk of retained revisions + add_estimation_costs_for_erase_document: Some(0), // changed: describes the retained revision layers for erasure + add_estimation_costs_for_lifecycle_record: Some(0), // changed: describes lifecycle metadata layers remove_reference_for_index_level_for_contract_operations: 2, // changed: the entries layer is described as references, with sum items under a summable index ..DRIVE_DOCUMENT_METHOD_VERSIONS_V4.delete }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/mod.rs index 24d185ca160..422982a0c5b 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/mod.rs @@ -5,7 +5,7 @@ pub mod v4; pub mod v5; use crate::version::drive_versions::DriveDataContractOperationMethodVersions; -use versioned_feature_core::FeatureVersion; +use versioned_feature_core::{FeatureVersion, OptionalFeatureVersion}; #[derive(Clone, Debug, Default)] pub struct DriveStateTransitionMethodVersions { @@ -33,6 +33,8 @@ pub struct DriveStateTransitionActionConvertToHighLevelOperationsMethodVersions pub document_create_transition: FeatureVersion, pub document_delete_transition: FeatureVersion, pub document_index_only_delete_transition: FeatureVersion, + /// The erase kind, absent before protocol version 15. + pub document_erase_transition: OptionalFeatureVersion, pub document_purchase_transition: FeatureVersion, pub document_replace_transition: FeatureVersion, pub document_transfer_transition: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v1.rs index 0a0bab12866..a2bb098496b 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v1.rs @@ -20,6 +20,7 @@ pub const DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V1: DriveStateTransitionMethodV document_create_transition: 0, document_delete_transition: 0, document_index_only_delete_transition: 0, + document_erase_transition: None, document_purchase_transition: 0, document_replace_transition: 0, document_transfer_transition: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v2.rs b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v2.rs index 5af37c28480..e43630086d9 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v2.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v2.rs @@ -21,6 +21,7 @@ pub const DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V2: DriveStateTransitionMethodV document_create_transition: 0, document_delete_transition: 0, document_index_only_delete_transition: 0, + document_erase_transition: None, document_purchase_transition: 0, document_replace_transition: 0, document_transfer_transition: 0, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v3.rs b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v3.rs index 8dbd1d13b93..94cb3e4719c 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v3.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v3.rs @@ -21,6 +21,7 @@ pub const DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V3: DriveStateTransitionMethodV document_create_transition: 0, document_delete_transition: 0, document_index_only_delete_transition: 0, + document_erase_transition: None, // PROTOCOL_VERSION_13: v1 rewrites a transferred or purchased // DPNS domain document's `records.identity` to the new owner // so the username resolves to the buyer. v0 stays for diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v4.rs b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v4.rs index 78aa8efd67d..15c87faed30 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v4.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v4.rs @@ -21,6 +21,7 @@ pub const DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V4: DriveStateTransitionMethodV document_create_transition: 0, document_delete_transition: 0, document_index_only_delete_transition: 0, + document_erase_transition: None, // PROTOCOL_VERSION_13: v1 rewrites a transferred or purchased // DPNS domain document's `records.identity` to the new owner // so the username resolves to the buyer. v0 stays for diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v5.rs b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v5.rs index e04c3e615e5..6512c8fd12f 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v5.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_state_transition_method_versions/v5.rs @@ -6,11 +6,15 @@ use crate::version::drive_versions::drive_state_transition_method_versions::{ /// Introduced in protocol v15: `document_create_transition` 1 deletes each document a create /// consumes from what document reference validation 1 read of it, without reading it again. -/// Everything else is v4's. +/// `document_delete_transition` 1 carries the deleter for a retained-history lifecycle +/// record. `document_erase_transition` is `Some(0)`, converting bounded erasures into Drive +/// operations. Every other selector matches v4. pub const DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V5: DriveStateTransitionMethodVersions = DriveStateTransitionMethodVersions { convert_to_high_level_operations: DriveStateTransitionActionConvertToHighLevelOperationsMethodVersions { + document_delete_transition: 1, // changed: carries the lifecycle record owner + document_erase_transition: Some(0), // changed: converts a bounded retained-history erase document_create_transition: 1, // changed: a consume deletes what its lookup read ..DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V4.convert_to_high_level_operations }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v4.rs b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v4.rs index 71186cf540b..d564537f6d2 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v4.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v4.rs @@ -12,7 +12,10 @@ use crate::version::drive_versions::drive_verify_method_versions::{ /// `single_document.verify_proof_keep_serialized` is 1: a document that may be contested is /// verified, and so is a document outside a contest at a block time in a type that keeps /// history, including time-and-revision keys in the composite layout, where generation 0 -/// refused every timed query. Everything else matches +/// refused every timed query. Both timed paths authenticate the lifecycle record and apply +/// deletion and erasure visibility. `single_document.verify_proof` is 1 too: a returned +/// document's id and required revision must match its authenticated path and key. +/// Everything else matches /// `DRIVE_VERIFY_METHOD_VERSIONS_V3`, except the retained-history and cursor verifiers /// selecting generation 1 for the per-type revision layout. pub const DRIVE_VERIFY_METHOD_VERSIONS_V4: DriveVerifyMethodVersions = DriveVerifyMethodVersions { @@ -29,8 +32,8 @@ pub const DRIVE_VERIFY_METHOD_VERSIONS_V4: DriveVerifyMethodVersions = DriveVeri ..DRIVE_VERIFY_METHOD_VERSIONS_V3.document }, single_document: DriveVerifySingleDocumentMethodVersions { + verify_proof: 1, // validates the returned document against its authenticated history key verify_proof_keep_serialized: 1, // changed: verifies maybe-contested documents and time-bounded retained revisions outside a contest - ..DRIVE_VERIFY_METHOD_VERSIONS_V3.single_document }, ..DRIVE_VERIFY_METHOD_VERSIONS_V3 }; diff --git a/packages/rs-platform-version/src/version/drive_versions/v10.rs b/packages/rs-platform-version/src/version/drive_versions/v10.rs index ae0ad4a9a15..9a274e09b99 100644 --- a/packages/rs-platform-version/src/version/drive_versions/v10.rs +++ b/packages/rs-platform-version/src/version/drive_versions/v10.rs @@ -153,8 +153,8 @@ pub const DRIVE_VERSION_V10: DriveVersion = DriveVersion { }, document: DRIVE_DOCUMENT_METHOD_VERSIONS_V5, // changed in v10: private document type stores, delete and summable index estimates; a single document at a block time; no insert into an expired time range bucket batch_operations: DriveBatchOperationsMethodVersion { + convert_drive_operations_to_grove_operations: 2, // changed: sibling history deletes share their pending lifecycle container (note 41) apply_drive_operations: 2, // changed in v10: a batch's estimate is resolved (note 14) - ..DRIVE_VERSION_V9.methods.batch_operations }, prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { estimated_cost_for_prefunded_specialized_balance_update: 2, // changed in v10: keeps a deeper prefunded balances layer description diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 925289a1397..9160f53fd68 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -598,6 +598,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V1, fee_version: FEE_VERSION1, system_limits: SystemLimits { + max_document_revisions_erased_per_transition: None, credit_pool_nullifier_backfill_page_size: 0, credit_pool_nullifier_backfill_batch_size: 0, estimated_contract_max_serialized_size: 16384, diff --git a/packages/rs-platform-version/src/version/system_limits/mod.rs b/packages/rs-platform-version/src/version/system_limits/mod.rs index 232b84cff7e..198206481fc 100644 --- a/packages/rs-platform-version/src/version/system_limits/mod.rs +++ b/packages/rs-platform-version/src/version/system_limits/mod.rs @@ -6,6 +6,9 @@ pub mod v5; #[derive(Clone, Debug, Default)] pub struct SystemLimits { + /// Maximum retained revisions removed by one erase, read by + /// `erase_document_for_contract_operations` 0; absent before lifecycle activation. + pub max_document_revisions_erased_per_transition: Option, /// Maximum ordered note page read by the CREDIT nullifier activation migration. pub credit_pool_nullifier_backfill_page_size: u16, /// Maximum insert operations per batch in the CREDIT nullifier activation migration. diff --git a/packages/rs-platform-version/src/version/system_limits/v1.rs b/packages/rs-platform-version/src/version/system_limits/v1.rs index 21ea8f34f47..5f6bc24a3ea 100644 --- a/packages/rs-platform-version/src/version/system_limits/v1.rs +++ b/packages/rs-platform-version/src/version/system_limits/v1.rs @@ -1,6 +1,7 @@ use crate::version::system_limits::SystemLimits; pub const SYSTEM_LIMITS_V1: SystemLimits = SystemLimits { + max_document_revisions_erased_per_transition: None, credit_pool_nullifier_backfill_page_size: 0, credit_pool_nullifier_backfill_batch_size: 0, estimated_contract_max_serialized_size: 16384, diff --git a/packages/rs-platform-version/src/version/system_limits/v2.rs b/packages/rs-platform-version/src/version/system_limits/v2.rs index 7d338ff17f1..b4269f213ab 100644 --- a/packages/rs-platform-version/src/version/system_limits/v2.rs +++ b/packages/rs-platform-version/src/version/system_limits/v2.rs @@ -6,6 +6,7 @@ use crate::version::system_limits::SystemLimits; /// from 190,000 credits (190 duffs) to 1,000,000 credits (1000 duffs): the previous floor was /// the bare asset-unlock transaction fee and too low a minimum for a Core `TxOut`. pub const SYSTEM_LIMITS_V2: SystemLimits = SystemLimits { + max_document_revisions_erased_per_transition: None, credit_pool_nullifier_backfill_page_size: 0, credit_pool_nullifier_backfill_batch_size: 0, estimated_contract_max_serialized_size: 16384, diff --git a/packages/rs-platform-version/src/version/system_limits/v3.rs b/packages/rs-platform-version/src/version/system_limits/v3.rs index f4253a89817..dbb9017d491 100644 --- a/packages/rs-platform-version/src/version/system_limits/v3.rs +++ b/packages/rs-platform-version/src/version/system_limits/v3.rs @@ -7,6 +7,7 @@ use crate::version::system_limits::SystemLimits; /// and mirrored by document validation. The rule cannot activate in v12 because v12 is already /// live on networks without it. pub const SYSTEM_LIMITS_V3: SystemLimits = SystemLimits { + max_document_revisions_erased_per_transition: None, credit_pool_nullifier_backfill_page_size: 0, credit_pool_nullifier_backfill_batch_size: 0, estimated_contract_max_serialized_size: 16384, diff --git a/packages/rs-platform-version/src/version/system_limits/v4.rs b/packages/rs-platform-version/src/version/system_limits/v4.rs index 94b0194bfaa..e7e4e40c143 100644 --- a/packages/rs-platform-version/src/version/system_limits/v4.rs +++ b/packages/rs-platform-version/src/version/system_limits/v4.rs @@ -126,6 +126,7 @@ use crate::version::system_limits::SystemLimits; /// the keys of unsigned integer index values, applying its moves in batches of 10,000 moves /// (`max_rekey_batch_moves`). `None` in the earlier tables, which never run the rewrite. pub const SYSTEM_LIMITS_V4: SystemLimits = SystemLimits { + max_document_revisions_erased_per_transition: None, // The page matches one notes-tree chunk (2^11). A batch holds at most that // page's missing rhos; GroveDB accepts a Vec of operations with no smaller API cap. credit_pool_nullifier_backfill_page_size: 2048, diff --git a/packages/rs-platform-version/src/version/system_limits/v5.rs b/packages/rs-platform-version/src/version/system_limits/v5.rs index aab0cca9966..358e38a8141 100644 --- a/packages/rs-platform-version/src/version/system_limits/v5.rs +++ b/packages/rs-platform-version/src/version/system_limits/v5.rs @@ -15,7 +15,11 @@ use crate::version::system_limits::SystemLimits; /// (`private_document_store_min_chunk_power`, `private_document_store_max_chunk_power`), all /// `None` before. A `PrivateDocumentCreateFromShieldedPool` appends at most 16 entries /// (`max_private_document_entries_per_transition`, `None` before). +/// * Retained-history erasure: one transition removes at most 100 revisions +/// (`max_document_revisions_erased_per_transition`, `None` before), as enforced by +/// `erase_document_for_contract_operations` 0. pub const SYSTEM_LIMITS_V5: SystemLimits = SystemLimits { + max_document_revisions_erased_per_transition: Some(100), // one bounded lifecycle erasure chunk (note 41) max_compiled_contract_size: Some(1_048_576), // changed: contracts stored compiled take at most 1 MiB max_private_document_entry_size: Some(4096), // changed: a private document type's entries take at most 4096 bytes private_document_store_target_chunk_bytes: Some(1024 * 1024), // changed: a private type's store keeps a compacted chunk near 1 MiB diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index 9b4388d0db1..b4b3733f502 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -8,10 +8,10 @@ use crate::version::dpp_versions::dpp_identity_versions::v1::IDENTITY_VERSIONS_V use crate::version::dpp_versions::dpp_method_versions::v3::DPP_METHOD_VERSIONS_V3; use crate::version::dpp_versions::dpp_state_transition_conversion_versions::v2::STATE_TRANSITION_CONVERSION_VERSIONS_V2; use crate::version::dpp_versions::dpp_state_transition_method_versions::v2::STATE_TRANSITION_METHOD_VERSIONS_V2; -use crate::version::dpp_versions::dpp_state_transition_serialization_versions::v3::STATE_TRANSITION_SERIALIZATION_VERSIONS_V3; +use crate::version::dpp_versions::dpp_state_transition_serialization_versions::v4::STATE_TRANSITION_SERIALIZATION_VERSIONS_V4; use crate::version::dpp_versions::dpp_state_transition_versions::v5::STATE_TRANSITION_VERSIONS_V5; use crate::version::dpp_versions::dpp_token_versions::v3::TOKEN_VERSIONS_V3; -use crate::version::dpp_versions::dpp_validation_versions::v5::DPP_VALIDATION_VERSIONS_V5; +use crate::version::dpp_versions::dpp_validation_versions::v6::DPP_VALIDATION_VERSIONS_V6; use crate::version::dpp_versions::dpp_voting_versions::v3::VOTING_VERSION_V3; use crate::version::dpp_versions::DPPVersion; use crate::version::drive_abci_versions::drive_abci_checkpoint_parameters::v1::DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1; @@ -199,8 +199,8 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// maps, so a schema whose array nesting alone exceeds the maximum depth, /// such as a deeply nested `const` or `enum` value, is now refused at /// registration and update (`DataContractMaxDepthExceedError`). The parser -/// is generation 3 at both versions, and loading a stored contract runs no -/// schema check. +/// is generation 4 at protocol v15 (note 41) and 3 at v14; loading a stored +/// contract runs no schema check. /// Protocol v14 and earlier keep `check_document_type_schema` 0 and /// `validate_max_depth` 1. /// @@ -818,6 +818,7 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// at the block time, so an expired bucket is never written again after its drop. Its /// estimates keep every bucket, as generation 2's do. Protocol v14 keeps /// `add_indices_for_top_index_level_for_contract_operations` 2, which writes every bucket. +/// /// 37. **A contest among documents**: `CONTRACT_VERSIONS_V7` selects /// `parse_contested_documents_resolution` 0: a contested index may declare /// `"resolution": 2` (`ContestedIndexResolution::MasternodeVoteOnDocuments`), which the @@ -878,25 +879,39 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// it, and a payer whose balance does not cover it is refused /// (`IdentityInsufficientBalanceError`). The fee schedules of protocol v14 and earlier /// carry 0, and the contract does not exist there, so nothing is charged. +/// +/// 41. **Retained-history lifecycle**: a deletable history document loses its current +/// pointer and index entries on delete, retaining its revisions and a lifecycle record. +/// Converting several history deletes of one type in one batch inserts its lifecycle +/// container once. +/// An erasable type admits bounded erase transitions, newest revisions first; the first +/// chunk requires the current owner's authorization and continuations finish the same +/// erasure. Terminal erasure removes the record and retained history without a receipt. +/// History V1 authenticates deleted and erasing states. Timed single-document reads +/// authenticate the lifecycle beside the history: a deletion is absent from its original +/// deletion time, and an erasing or erased document is absent at every requested time. +/// Parser 4 admits `canBeErased` with meta-schema 3; compiled type storage keeps generation +/// 0 and its existing non-lifecycle bytes. Protocols through 14 retain their handlers, +/// limits and wire bounds, and cannot admit an erase. pub const PLATFORM_V15: PlatformVersion = PlatformVersion { protocol_version: PROTOCOL_VERSION_15, - drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); create_initial_state_structure 5 adds the token marketplace escrow trees; calculate_total_tokens_balance 2 counts escrowed tokens; the escrow primitives; the identity balance, token balance, prefunded specialized balance and contract fee pot estimations (for_balances 1, for_token_balances 1, estimated_cost_for_prefunded_specialized_balance_update 2, add_estimation_costs_for_contract_fee_pot_update 1) keep a deeper layer description (note 17); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) + drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); create_initial_state_structure 5 adds the token marketplace escrow trees; calculate_total_tokens_balance 2 counts escrowed tokens; the escrow primitives; the identity balance, token balance, prefunded specialized balance and contract fee pot estimations (for_balances 1, for_token_balances 1, estimated_cost_for_prefunded_specialized_balance_update 2, add_estimation_costs_for_contract_fee_pot_update 1) keep a deeper layer description (note 17); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: insert.add_document_for_contract_operations 2, delete.delete_document_for_contract_operations 1, delete.remove_document_from_primary_storage 1 and its estimate 1, query.fetch_document_lifecycle Some(0), and the erase/lifecycle estimate and erase_refund_recipient_cost selectors Some(0); batch_operations.convert_drive_operations_to_grove_operations 2; state transition method versions v5: document_delete_transition 1 and document_erase_transition Some(0); verify methods v4: single_document.verify_proof 1 extend retained history (note 41); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) drive_abci: DriveAbciVersion { structs: DRIVE_ABCI_STRUCTURE_VERSIONS_V2, methods: DRIVE_ABCI_METHOD_VERSIONS_V11, // changed: perform_events_on_first_block_of_protocol_change 3 migrates retained history after operator-payout reconciliation and other activation work (note 35); the yes/no poll's tally, record, clean-up and finish hook are Some(0) (note 10); verify_chain_lock_locally 1 rejects a chain lock locally only when Platform holds the quorums active at its signing height, and verify_chain_lock_through_core 1 has Core's verifychainlock check the others before submitchainlock; consensus_params_update 2 installs the full evidence policy (note 16); update_core_info 1 records the chain locked height at which Core's V24 is first seen active (note 18); build_untied_withdrawal_transactions_from_documents 1 emits asset unlock payload version 2 once V24 is recorded as active (note 20); update_voter_identity 1 re-enables the voter key of the address a masternode returns to (note 22); update_masternode_list 2 and update_operator_identity 1 make operator payouts and the operator identities' TRANSFER keys follow Core's diffs (note 32) - validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V11, // changed: identity update advanced_structure 1 refuses unpaid an identity update whose added key's proof of possession does not verify (note 2); create_domain_data_trigger 2 (note 3); contract update transform_into_action 1 holds an update to the compiled size cap in check_tx (note 8); batch advanced_structure 2 refuses a token config update on a read-only contract (note 9); masternode vote transform_into_action 1 looks up a masternode's previous answer on a yes/no poll (note 10); document_reference_validation 1 keeps what a consumed commitment's lookup read (note 11); document create structure_validation 2 holds a decision proposal to its fund, rule and end date (note 12); data trigger bindings 3 refuse a replace or a delete of a token market order (note 17) and drop the DashPay bindings (note 24); document create state_validation 3 keeps a create outside a contest off the values of a live one its index values do not decide (note 19); identity create basic_structure 1 checks the identity id before the asset lock proof and advanced_structure 2 no longer does (note 23); contract user moderation transform_into_action 1 writes a moderator's field change in the name of whoever holds the document's storage (note 28); validate_state_transition_identity_signed 2 refuses a contract create or update signed by a key with a budget or an expiry (note 34) + validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V11, // changed: identity update advanced_structure 1 refuses unpaid an identity update whose added key's proof of possession does not verify (note 2); create_domain_data_trigger 2 (note 3); contract update transform_into_action 1 holds an update to the compiled size cap in check_tx (note 8); batch advanced_structure 2 refuses a token config update on a read-only contract (note 9); masternode vote transform_into_action 1 looks up a masternode's previous answer on a yes/no poll (note 10); document_reference_validation 1 keeps what a consumed commitment's lookup read (note 11); document create structure_validation 2 holds a decision proposal to its fund, rule and end date (note 12); data trigger bindings 3 refuse a replace or a delete of a token market order (note 17) and drop the DashPay bindings (note 24); document create state_validation 3 keeps a create outside a contest off the values of a live one its index values do not decide (note 19); identity create basic_structure 1 checks the identity id before the asset lock proof and advanced_structure 2 no longer does (note 23); contract user moderation transform_into_action 1 writes a moderator's field change in the name of whoever holds the document's storage (note 28); validate_state_transition_identity_signed 2 refuses a contract create or update signed by a key with a budget or an expiry (note 34); batch_state_transition.document_delete_transition_structure_validation 2 and document_erase_transition_structure_validation/document_erase_transition_state_validation Some(0) admit the lifecycle (note 41) withdrawal_constants: DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V3, query: DRIVE_ABCI_QUERY_VERSIONS_V3, // changed: getDocumentHistory accepts V1 only checkpoints: DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1, }, dpp: DPPVersion { costs: DPP_COSTS_VERSIONS_V1, - validation: DPP_VALIDATION_VERSIONS_V5, - state_transition_serialization_versions: STATE_TRANSITION_SERIALIZATION_VERSIONS_V3, + validation: DPP_VALIDATION_VERSIONS_V6, // changed: document type update 2 preserves erasure constraints (note 41) + state_transition_serialization_versions: STATE_TRANSITION_SERIALIZATION_VERSIONS_V4, // changed: document erase bounds Some(0) admit the appended kind (note 41) state_transition_conversion_versions: STATE_TRANSITION_CONVERSION_VERSIONS_V2, state_transition_method_versions: STATE_TRANSITION_METHOD_VERSIONS_V2, state_transitions: STATE_TRANSITION_VERSIONS_V5, // changed: validate_asset_lock_transaction_structure 1 drops the input cap and validate_instant_asset_lock_proof_structure 1 applies it to instant proofs only, so a chain proof redeems a lock of more than 100 inputs (note 30) - contract_versions: CONTRACT_VERSIONS_V7, // changed: parse_property_constraints 1 lets countOf and sumOf match byte array keys (note 4); validate_document 2 checks documents natively (note 6); check_document_type_schema 1 checks schemas natively at registration (note 7); contract_storage_serialization_version 2 stores contracts compiled (note 8); parse_private_document 0 parses private document types (note 13); apply_generated_from 1 admits sys.tokens.decimals (note 15) + contract_versions: CONTRACT_VERSIONS_V7, // changed: parse_property_constraints 1 lets countOf and sumOf match byte array keys (note 4); validate_document 2 checks documents natively (note 6); check_document_type_schema 1 checks schemas natively at registration (note 7); contract_storage_serialization_version 2 stores contracts compiled (note 8); parse_private_document 0 parses private document types (note 13); apply_generated_from 1 admits sys.tokens.decimals (note 15); try_from_schema 4 parses lifecycle flags (note 41) document_versions: DOCUMENT_VERSIONS_V4, identity_versions: IDENTITY_VERSIONS_V1, voting_versions: VOTING_VERSION_V3, // changed: the yes/no poll's stored info, id, parameter rules and decision rules are active (note 10), and the decision proposal's poll (note 12) @@ -907,7 +922,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { }, system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V4, // changed: DPNS v3 checks a name's create with keywords (note 3); the decision proposals contract (note 12); the token market contract is selected (note 17); DashPay v3 states what its data triggers checked (note 24) fee_version: FEE_VERSION4, // changed: decision proposals prefund their poll with 0.5 Dash (note 12); a private document entry pays its storage and 10,000,000 credits (note 25); a multiple choice proposal pays a 0.2 Dash processing fee on create (note 40) - system_limits: SYSTEM_LIMITS_V5, // changed: max_compiled_contract_size caps a contract stored compiled at 1 MiB (note 8); max_private_document_entry_size caps a private type's entries at 4096 bytes, and the private document store limits size its store (note 13); max_private_document_entries_per_transition caps a private document create at 16 entries (note 25) + system_limits: SYSTEM_LIMITS_V5, // changed: max_compiled_contract_size caps a contract stored compiled at 1 MiB (note 8); max_private_document_entry_size caps a private type's entries at 4096 bytes, and the private document store limits size its store (note 13); max_private_document_entries_per_transition caps a private document create at 16 entries (note 25); max_document_revisions_erased_per_transition caps an erase at 100 revisions (note 41) consensus: ConsensusVersions { tenderdash_consensus_version: 1, evidence: Some(ConsensusEvidenceParams { diff --git a/packages/rs-platform-version/tests/keep_history_delete_versions.rs b/packages/rs-platform-version/tests/keep_history_delete_versions.rs index 81491b87f87..a6db4914572 100644 --- a/packages/rs-platform-version/tests/keep_history_delete_versions.rs +++ b/packages/rs-platform-version/tests/keep_history_delete_versions.rs @@ -1,4 +1,117 @@ -use platform_version::version::PlatformVersion; +//! The lifecycle's admission, storage, and bounds must activate together. + +use platform_version::version::{PlatformVersion, PLATFORM_VERSIONS}; + +#[test] +fn should_activate_lifecycle_handlers_and_limits_only_with_erase_wire_bounds() { + for version in PLATFORM_VERSIONS { + let protocol = version.protocol_version; + let expected = (protocol >= 15).then_some(0); + let document = &version.drive.methods.document; + let batch = &version + .drive_abci + .validation_and_processing + .state_transitions + .batch_state_transition; + let conversion = &version + .drive + .methods + .state_transitions + .convert_to_high_level_operations; + let bounds = &version + .dpp + .state_transition_serialization_versions + .document_erase_state_transition; + assert_eq!( + bounds + .as_ref() + .map(|bounds| bounds.bounds.default_current_version), + expected, + "erase wire at {protocol}" + ); + for slot in [ + document.query.fetch_document_lifecycle, + document.delete.erase_document_for_contract_operations, + document.delete.add_estimation_costs_for_erase_document, + document.delete.add_estimation_costs_for_lifecycle_record, + document.delete.erase_refund_recipient_cost, + conversion.document_erase_transition, + batch.document_erase_transition_structure_validation, + batch.document_erase_transition_state_validation, + ] { + assert_eq!(slot, expected, "lifecycle handler at {protocol}"); + } + assert_eq!( + version + .system_limits + .max_document_revisions_erased_per_transition, + (protocol >= 15).then_some(100), + "erase bound at {protocol}" + ); + assert_eq!( + version + .drive + .methods + .batch_operations + .convert_drive_operations_to_grove_operations, + if protocol >= 15 { + 2 + } else if protocol >= 14 { + 1 + } else { + 0 + }, + "raw converter at {protocol}" + ); + if protocol <= 14 { + assert_eq!(document.delete.delete_document_for_contract_operations, 0); + assert_eq!(conversion.document_delete_transition, 0); + } + } +} + +#[test] +fn should_extend_the_current_protocol_fifteen_tables_for_lifecycle() { + let version = PlatformVersion::latest(); + assert_eq!(version.protocol_version, 15); + let contract = &version.dpp.contract_versions; + assert_eq!( + contract + .document_type_versions + .class_method_versions + .try_from_schema, + 4 + ); + assert_eq!( + contract.document_type_versions.schema.document_type_schema, + 3 + ); + assert_eq!(contract.contract_storage_document_type_version, 0); + let document = &version.drive.methods.document; + assert_eq!(document.insert.add_document_for_contract_operations, 2); + assert_eq!(document.update.update_document_for_contract_operations, 2); + assert_eq!(document.delete.delete_document_for_contract_operations, 1); + assert_eq!(document.delete.remove_document_from_primary_storage, 1); + let batch = &version + .drive_abci + .validation_and_processing + .state_transitions + .batch_state_transition; + assert_eq!(batch.document_create_transition_state_validation, 3); + assert_eq!(batch.document_delete_transition_state_validation, 1); + assert_eq!(batch.document_delete_transition_structure_validation, 2); + let serialization = &version.dpp.state_transition_serialization_versions; + assert_eq!( + serialization + .document_base_state_transition + .default_current_version, + 2 + ); + assert_eq!( + serialization.batch_state_transition.default_current_version, + 1 + ); +} #[test] fn should_preserve_released_keep_history_validation_versions() { diff --git a/packages/rs-platform-wallet/src/wallet/identity/network/state_transition_summary.rs b/packages/rs-platform-wallet/src/wallet/identity/network/state_transition_summary.rs index be0e36d27c8..47dc00fbf2d 100644 --- a/packages/rs-platform-wallet/src/wallet/identity/network/state_transition_summary.rs +++ b/packages/rs-platform-wallet/src/wallet/identity/network/state_transition_summary.rs @@ -490,6 +490,8 @@ fn summarize_document_transition( DocumentTransition::Transfer(t) => (None, Some(t.recipient_owner_id())), DocumentTransition::Purchase(t) => (Some(t.price()), None), DocumentTransition::UpdatePrice(t) => (Some(t.price()), None), + // Protocols through 14 cannot admit an erase. It carries no transfer amount or recipient. + DocumentTransition::Erase(_) => (None, None), DocumentTransition::Create(_) | DocumentTransition::Replace(_) | DocumentTransition::Delete(_) @@ -662,6 +664,8 @@ mod tests { use dpp::state_transition::batch_transition::document_base_transition::v0::DocumentBaseTransitionV0; use dpp::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; use dpp::state_transition::batch_transition::document_create_transition::v0::DocumentCreateTransitionV0; + use dpp::state_transition::batch_transition::document_erase_transition::v0::DocumentEraseTransitionV0; + use dpp::state_transition::batch_transition::DocumentEraseTransition; use dpp::state_transition::batch_transition::token_base_transition::v0::TokenBaseTransitionV0; use dpp::state_transition::batch_transition::token_base_transition::TokenBaseTransition; use dpp::state_transition::batch_transition::token_claim_transition::v0::TokenClaimTransitionV0; @@ -745,6 +749,37 @@ mod tests { summarize_state_transition(&transition.serialize_to_bytes().unwrap()).expect("summarizes") } + #[test] + fn should_identify_an_erase_and_its_document_without_a_transfer() { + let transition = batch(vec![BatchedTransition::Document( + DocumentTransition::Erase(DocumentEraseTransition::V0(DocumentEraseTransitionV0 { + base: document_base("post"), + })), + )]); + let summary = summarize_bytes(&transition); + assert_eq!(summary.kind_name, "DocumentsBatch([Erase])"); + assert_eq!(summary.serialized, transition.serialize_to_bytes().unwrap()); + let StateTransitionSummaryKind::Batch { transitions, .. } = summary.kind else { + panic!("expected a batch"); + }; + let [erase] = transitions.as_slice() else { + panic!("expected one document operation"); + }; + assert_eq!(erase.action, "Erase"); + assert_eq!(erase.data_contract_id, Identifier::from(CONTRACT)); + assert_eq!( + erase.target, + BatchedTransitionTarget::Document { + document_type: "post".to_string(), + document_id: Identifier::from([0x0D; 32]), + } + ); + assert_eq!(erase.amount, None); + assert_eq!(erase.recipient_id, None); + assert_eq!(erase.token_count, None); + assert_eq!(erase.details, None); + } + #[test] fn a_mixed_batch_summarizes_one_row_per_transition() { let transition = batch(vec![ diff --git a/packages/rs-sdk/src/mock/requests.rs b/packages/rs-sdk/src/mock/requests.rs index 85593c78cd0..c9f240694b0 100644 --- a/packages/rs-sdk/src/mock/requests.rs +++ b/packages/rs-sdk/src/mock/requests.rs @@ -252,7 +252,13 @@ impl MockResponse for Document { } } -type MockDocumentHistory = (Vec<(u64, u64, Vec)>, Option<(bool, u64)>); +/// Entries as (time, revision, document bytes); the lifecycle as its state +/// discriminant, the remaining revision count and the four lifecycle times, +/// so a mocked deleted or erasing history round-trips with its metadata. +type MockDocumentHistory = ( + Vec<(u64, u64, Vec)>, + Option<(u8, u64, u64, u64, u64, u64)>, +); impl MockResponse for drive_proof_verifier::types::DocumentHistoryProofInfo { fn mock_serialize(&self, sdk: &MockDashPlatformSdk) -> Vec { @@ -295,9 +301,19 @@ impl MockResponse for drive_proof_verifier::types::DocumentHistory { }) .collect::>(); let lifecycle = self.lifecycle.as_ref().map(|lifecycle| { + let state = match lifecycle.state { + DocumentHistoryState::Active => 0u8, + DocumentHistoryState::Deleted => 1, + DocumentHistoryState::Erasing => 2, + DocumentHistoryState::Absent => 3, + }; ( - lifecycle.state == DocumentHistoryState::Active, + state, lifecycle.remaining_revisions, + lifecycle.times.deleted_at_ms, + lifecycle.times.erasing_started_at_ms, + lifecycle.times.erasing_from_time_ms, + lifecycle.times.erasing_from_revision, ) }); bincode::encode_to_vec((entries, lifecycle), BINCODE_CONFIG) @@ -306,7 +322,8 @@ impl MockResponse for drive_proof_verifier::types::DocumentHistory { fn mock_deserialize(sdk: &MockDashPlatformSdk, buf: &[u8]) -> Self { use drive_proof_verifier::types::{ - DocumentHistoryEntry, DocumentHistoryLifecycle, DocumentHistoryState, + DocumentHistoryEntry, DocumentHistoryLifecycle, DocumentHistoryLifecycleTimes, + DocumentHistoryState, }; let ((entries, lifecycle), _): (MockDocumentHistory, _) = bincode::decode_from_slice(buf, BINCODE_CONFIG).expect("decode document history"); @@ -319,15 +336,83 @@ impl MockResponse for drive_proof_verifier::types::DocumentHistory { document: Document::mock_deserialize(sdk, &bytes), }) .collect(), - lifecycle: lifecycle.map(|(active, remaining_revisions)| DocumentHistoryLifecycle { - state: if active { - DocumentHistoryState::Active - } else { - DocumentHistoryState::Absent + lifecycle: lifecycle.map( + |( + state, + remaining_revisions, + deleted_at_ms, + erasing_started_at_ms, + erasing_from_time_ms, + erasing_from_revision, + )| DocumentHistoryLifecycle { + state: match state { + 0 => DocumentHistoryState::Active, + 1 => DocumentHistoryState::Deleted, + 2 => DocumentHistoryState::Erasing, + _ => DocumentHistoryState::Absent, + }, + remaining_revisions, + times: DocumentHistoryLifecycleTimes { + deleted_at_ms, + erasing_started_at_ms, + erasing_from_time_ms, + erasing_from_revision, + }, }, - remaining_revisions, - }), + ), + } + } +} + +#[cfg(test)] +mod document_history_mock_tests { + use super::*; + use drive_proof_verifier::types::{ + DocumentHistory, DocumentHistoryLifecycle, DocumentHistoryLifecycleTimes, + DocumentHistoryState, + }; + + /// Every lifecycle state and every lifecycle time survives the mock + /// round trip, so a mocked deleted or erasing history looks to the caller + /// exactly as the verified one would. + #[test] + fn should_round_trip_every_lifecycle_state_with_its_times() { + let mut sdk = crate::SdkBuilder::default() + .with_version(dpp::version::PlatformVersion::latest()) + .build() + .unwrap(); + let mock = sdk.mock(); + let sdk: &MockDashPlatformSdk = &mock; + for (state, remaining_revisions) in [ + (DocumentHistoryState::Active, 3), + (DocumentHistoryState::Deleted, 3), + (DocumentHistoryState::Erasing, 1), + (DocumentHistoryState::Absent, 0), + ] { + let history = DocumentHistory { + entries: vec![], + lifecycle: Some(DocumentHistoryLifecycle { + state, + remaining_revisions, + times: DocumentHistoryLifecycleTimes { + deleted_at_ms: 5_000, + erasing_started_at_ms: 6_000, + erasing_from_time_ms: 4_000, + erasing_from_revision: 3, + }, + }), + }; + let recovered = DocumentHistory::mock_deserialize(sdk, &history.mock_serialize(sdk)); + assert_eq!(recovered, history, "{state:?} did not round-trip"); } + let without_lifecycle = DocumentHistory { + entries: vec![], + lifecycle: None, + }; + assert_eq!( + DocumentHistory::mock_deserialize(sdk, &without_lifecycle.mock_serialize(sdk)), + without_lifecycle + ); } } diff --git a/packages/rs-sdk/src/platform/documents/transitions/erase.rs b/packages/rs-sdk/src/platform/documents/transitions/erase.rs new file mode 100644 index 00000000000..318fddea59e --- /dev/null +++ b/packages/rs-sdk/src/platform/documents/transitions/erase.rs @@ -0,0 +1,528 @@ +use crate::platform::transition::broadcast::BroadcastStateTransition; +use crate::platform::transition::put_settings::PutSettings; +use crate::platform::{Fetch, Identifier}; +use crate::{Error, Sdk}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::DataContract; +use dpp::document::{Document, INITIAL_REVISION}; +use dpp::identity::signer::Signer; +use dpp::identity::IdentityPublicKey; +use dpp::prelude::UserFeeIncrease; +use dpp::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; +use dpp::state_transition::batch_transition::methods::StateTransitionCreationOptions; +use dpp::state_transition::batch_transition::BatchTransition; +use dpp::state_transition::proof_result::StateTransitionProofResult; +use dpp::state_transition::StateTransition; +use dpp::version::PlatformVersion; +use dpp::ProtocolError; +use drive::query::document_history_drive_query::{DocumentHistoryFilter, DocumentHistoryLifecycle}; +use std::sync::Arc; + +/// A builder to configure and broadcast document erase transitions. +/// +/// Erasing purges the retained revisions of a document that has already been +/// deleted. The first erase must come from the document's owner and commits the +/// document to erasure; every erase after that may come from any identity, +/// because the committed state already carries the authorization. +pub struct DocumentEraseTransitionBuilder { + /// The data contract. + pub data_contract: Arc, + /// The name of the document type whose revisions are being erased. + pub document_type_name: String, + /// The document whose revisions are being erased. + pub document_id: Identifier, + /// The identity submitting and paying for this erase, which need not own + /// the document once its erasure has begun. + pub owner_id: Identifier, + /// Settings for broadcasting. + pub settings: Option, + /// A user fee increase. + pub user_fee_increase: Option, + /// State transition creation options. + pub state_transition_creation_options: Option, +} + +impl DocumentEraseTransitionBuilder { + /// Start building an erase request for the provided data contract. + /// + /// There is no token payment: the deletion this erase follows was charged + /// when the document was deleted, and an erase that carried one would let a + /// continuation, which anyone may submit, move tokens. + pub fn new( + data_contract: Arc, + document_type_name: String, + document_id: Identifier, + owner_id: Identifier, + ) -> Self { + Self { + data_contract, + document_type_name, + document_id, + owner_id, + settings: None, + user_fee_increase: None, + state_transition_creation_options: None, + } + } + + /// Adds a user fee increase to the erase transition. + pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { + self.user_fee_increase = Some(user_fee_increase); + self + } + + /// Adds settings to the erase transition. + pub fn with_settings(mut self, settings: PutSettings) -> Self { + self.settings = Some(settings); + self + } + + /// Adds creation options to the erase transition. + pub fn with_state_transition_creation_options( + mut self, + creation_options: StateTransitionCreationOptions, + ) -> Self { + self.state_transition_creation_options = Some(creation_options); + self + } + + /// Signs the erase transition. + pub async fn sign( + &self, + sdk: &Sdk, + identity_public_key: &IdentityPublicKey, + signer: &impl Signer, + platform_version: &PlatformVersion, + ) -> Result { + // Validate the target before the nonce fetch below bumps the SDK's + // cached contract nonce: no transition is broadcast on an error path, + // so a rejection after it would leak an increment per failed call. + let document_type = self + .data_contract + .document_type_for_name(&self.document_type_name) + .map_err(|e| Error::Protocol(e.into()))?; + let (user_fee_increase, creation_options) = self.signing_parameters(); + Self::check_erase_is_constructible(creation_options.as_ref(), platform_version)?; + + // The transition carries only the base, so an id is all the builder + // needs; the values of a document that is no longer visible are not + // available to a client anyway. + let document = Document::V0(dpp::document::DocumentV0 { + contract_version: None, + id: self.document_id, + owner_id: self.owner_id, + properties: Default::default(), + revision: Some(INITIAL_REVISION), + created_at: None, + updated_at: None, + transferred_at: None, + created_at_block_height: None, + updated_at_block_height: None, + transferred_at_block_height: None, + created_at_core_block_height: None, + updated_at_core_block_height: None, + transferred_at_core_block_height: None, + creator_id: None, + moderated_at: None, + moderated_by: None, + }); + + let identity_contract_nonce = sdk + .get_identity_contract_nonce( + self.owner_id, + self.data_contract.id(), + true, + self.settings, + ) + .await?; + + let state_transition = BatchTransition::new_document_erase_transition_from_document( + document, + document_type, + identity_public_key, + identity_contract_nonce, + user_fee_increase, + signer, + platform_version, + creation_options, + ) + .await?; + + Ok(state_transition) + } + + /// The fee increase and creation options the transition is signed with. + /// + /// An explicitly set value wins; otherwise the ones carried by the put + /// settings apply, so a caller that only hands over settings (the wasm and + /// FFI wrappers do) still signs with what it asked for. + fn signing_parameters(&self) -> (UserFeeIncrease, Option) { + let settings = self.settings.as_ref(); + ( + self.user_fee_increase + .or(settings.and_then(|settings| settings.user_fee_increase)) + .unwrap_or_default(), + self.state_transition_creation_options + .or(settings.and_then(|settings| settings.state_transition_creation_options)), + ) + } + + /// Refuses, before any nonce is reserved, an erase the platform version + /// cannot construct: the transition kind joined the wire at protocol + /// version 15, and the batch may only be built at a version it knows. + /// + /// The same rejection happens inside the transition constructor, but by + /// then the SDK has already advanced its cached contract nonce for a + /// transition that is never broadcast. + fn check_erase_is_constructible( + creation_options: Option<&StateTransitionCreationOptions>, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let serialization = &platform_version.dpp.state_transition_serialization_versions; + let Some(erase_bounds) = serialization.document_erase_state_transition.as_ref() else { + return Err(Error::Protocol(ProtocolError::Generic( + "erase transitions do not exist at this platform version".to_string(), + ))); + }; + let batch_feature_version = creation_options + .and_then(|options| options.batch_feature_version) + .unwrap_or(serialization.batch_state_transition.default_current_version); + if !matches!(batch_feature_version, 0 | 1) { + return Err(Error::Protocol(ProtocolError::UnknownVersionMismatch { + method: "DocumentEraseTransitionBuilder::sign".to_string(), + known_versions: vec![0, 1], + received: batch_feature_version, + })); + } + let method_feature_version = creation_options + .and_then(|options| options.method_feature_version) + .unwrap_or(erase_bounds.bounds.default_current_version); + if method_feature_version != 0 { + return Err(Error::Protocol(ProtocolError::UnknownVersionMismatch { + method: "DocumentEraseTransitionBuilder::sign".to_string(), + known_versions: vec![0], + received: method_feature_version, + })); + } + let base_feature_version = creation_options + .and_then(|options| options.base_feature_version) + .unwrap_or( + serialization + .document_base_state_transition + .default_current_version, + ); + if !matches!(base_feature_version, 0..=2) { + return Err(Error::Protocol(ProtocolError::UnknownVersionMismatch { + method: "DocumentEraseTransitionBuilder::sign".to_string(), + known_versions: vec![0, 1, 2], + received: base_feature_version, + })); + } + Ok(()) + } +} + +/// What one erase transition left behind. +#[derive(Debug)] +pub enum DocumentEraseResult { + /// The document is absent by id as of the proof's block. It already was + /// before the erase ran, so this is an observation of the state the erase + /// affected, not evidence that this erase executed — read the current + /// lifecycle with [`Sdk::document_current_lifecycle`] to find out how much + /// history is left. + AbsentAsOfProof(Identifier), +} + +/// Reads the observation an erase leaves behind out of the verified result. +/// +/// Its own function so a test can drive it with the outcome an erase actually +/// produces: the proof classifier reports an erase as affected state, which the +/// strict wait refuses, so the erase has to take the affected-state wait and +/// this has to accept what that wait returns. +fn erase_observation(result: StateTransitionProofResult) -> Result { + match result { + StateTransitionProofResult::VerifiedDocuments(documents) => { + if let Some((erased_id, None)) = documents.into_iter().next() { + Ok(DocumentEraseResult::AbsentAsOfProof(erased_id)) + } else { + Err(Error::DriveProofError( + drive::error::proof::ProofError::UnexpectedResultProof( + "expected an absent document in the VerifiedDocuments result for an \ + erase transition" + .to_string(), + ), + vec![], + Default::default(), + )) + } + } + _ => Err(Error::DriveProofError( + drive::error::proof::ProofError::UnexpectedResultProof( + "expected VerifiedDocuments for a document erase transition".to_string(), + ), + vec![], + Default::default(), + )), + } +} + +fn lifecycle_from_history( + history: Option, +) -> Option { + history.and_then(|history| history.lifecycle) +} + +impl Sdk { + /// Erases a chunk of the retained revisions of an already deleted document. + /// + /// The first erase must be signed by the document's owner; any identity may + /// submit the ones after it. A document with more retained revisions than + /// one transition may remove needs several, and this method broadcasts one. + /// + /// The proof this returns authenticates that the document is absent by id, + /// which it already was before the erase ran, so it is an observation of + /// the state the erase affected rather than evidence that this erase + /// executed. That is why it takes the affected-state wait: the strict wait + /// refuses exactly this classification. Use + /// [`Sdk::document_current_lifecycle`] to observe how much history is left. + pub async fn document_erase>( + &self, + erase_document_transition_builder: DocumentEraseTransitionBuilder, + signing_key: &IdentityPublicKey, + signer: &S, + ) -> Result { + let platform_version = self.version(); + let put_settings = erase_document_transition_builder.settings; + + let state_transition = erase_document_transition_builder + .sign(self, signing_key, signer, platform_version) + .await?; + + let proof_result = state_transition + .broadcast_and_wait_for_affected_state::(self, put_settings) + .await?; + + erase_observation(proof_result) + } + + /// Reads where a document stands in its lifecycle right now. + /// + /// Deliberately named apart from the erase and delete calls: the answer + /// describes committed state at the moment of the read, not the outcome of + /// any particular transition. A later erase may commit between a transition + /// and this read. `None` means the queried + /// storage/proof generation does not authenticate lifecycle metadata; it + /// must not be interpreted as an authenticated absent state. + pub async fn document_current_lifecycle( + &self, + data_contract_id: Identifier, + document_type_name: String, + document_id: Identifier, + ) -> Result, Error> { + use dash_platform_queries::documents::document_history_query::DocumentHistoryQuery; + use drive_proof_verifier::types::DocumentHistory; + + let history = DocumentHistory::fetch( + self, + DocumentHistoryQuery { + data_contract_id, + document_type_name, + document_id, + // The oldest retained revision, if any: the page is not the + // point, the metadata alongside it is. + filter: DocumentHistoryFilter::StartAtTime(0), + limit: Some(1), + }, + ) + .await?; + + Ok(lifecycle_from_history(history)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use drive::query::document_history_drive_query::DocumentHistoryState; + use std::collections::BTreeMap; + + /// The erase reads its observation out of exactly the result the + /// affected-state wait hands back, and refuses anything else. + #[test] + fn should_read_an_absent_document_as_the_erases_observation() { + let id = Identifier::from([9u8; 32]); + let observation = erase_observation(StateTransitionProofResult::VerifiedDocuments( + BTreeMap::from([(id, None)]), + )) + .expect("an absent document is what an erase leaves behind"); + assert!(matches!( + observation, + DocumentEraseResult::AbsentAsOfProof(seen) if seen == id + )); + + let document = dpp::document::Document::V0(Default::default()); + erase_observation(StateTransitionProofResult::VerifiedDocuments( + BTreeMap::from([(id, Some(document))]), + )) + .expect_err("a document that is still there did not survive an erase"); + + erase_observation(StateTransitionProofResult::VerifiedTokenBalanceAbsence(id)) + .expect_err("only a document result can describe an erase"); + } + + #[test] + fn should_not_turn_unavailable_lifecycle_into_absent() { + use drive_proof_verifier::types::DocumentHistory; + + assert_eq!(lifecycle_from_history(None), None); + assert_eq!( + lifecycle_from_history(Some(DocumentHistory { + entries: vec![], + lifecycle: None, + })), + None + ); + let absent = DocumentHistoryLifecycle { + state: DocumentHistoryState::Absent, + remaining_revisions: 0, + times: Default::default(), + }; + assert_eq!( + lifecycle_from_history(Some(DocumentHistory { + entries: vec![], + lifecycle: Some(absent.clone()), + })), + Some(absent) + ); + } + + #[cfg(feature = "mocks")] + fn builder_with(settings: Option) -> DocumentEraseTransitionBuilder { + let contract = dpp::tests::fixtures::get_dashpay_contract_fixture( + None, + 0, + PlatformVersion::latest().protocol_version, + ) + .data_contract_owned(); + let builder = DocumentEraseTransitionBuilder::new( + Arc::new(contract), + "profile".to_string(), + Identifier::from([1u8; 32]), + Identifier::from([2u8; 32]), + ); + match settings { + Some(settings) => builder.with_settings(settings), + None => builder, + } + } + + /// A fee increase or creation options handed over inside the put settings + /// reach the signing step, and an explicit builder value still wins. + #[cfg(feature = "mocks")] + #[test] + fn should_sign_with_the_settings_fee_increase_unless_set_explicitly() { + let options = StateTransitionCreationOptions { + batch_feature_version: Some(1), + ..Default::default() + }; + let settings = PutSettings { + user_fee_increase: Some(250), + state_transition_creation_options: Some(options), + ..Default::default() + }; + assert_eq!(builder_with(None).signing_parameters(), (0, None)); + assert_eq!( + builder_with(Some(settings)).signing_parameters(), + (250, Some(options)) + ); + assert_eq!( + builder_with(Some(settings)) + .with_user_fee_increase(7) + .with_state_transition_creation_options(Default::default()) + .signing_parameters(), + (7, Some(Default::default())) + ); + } + + /// The version gate runs before the nonce fetch, so a platform version + /// that cannot construct an erase is refused without reserving a nonce. + #[test] + fn should_refuse_an_erase_the_platform_version_cannot_construct() { + let too_old = PlatformVersion::get(14).unwrap(); + let error = DocumentEraseTransitionBuilder::check_erase_is_constructible(None, too_old) + .expect_err("protocol 14 has no erase transition"); + assert!(error + .to_string() + .contains("erase transitions do not exist at this platform version")); + let current = PlatformVersion::latest(); + DocumentEraseTransitionBuilder::check_erase_is_constructible(None, current) + .expect("protocol 15 constructs erases"); + for shipped in [0, 1] { + let options = StateTransitionCreationOptions { + batch_feature_version: Some(shipped), + ..Default::default() + }; + DocumentEraseTransitionBuilder::check_erase_is_constructible(Some(&options), current) + .expect("both shipped batch wire formats carry an erase"); + } + let unknown_batch = StateTransitionCreationOptions { + batch_feature_version: Some(9), + ..Default::default() + }; + DocumentEraseTransitionBuilder::check_erase_is_constructible(Some(&unknown_batch), current) + .expect_err("an unknown batch version is refused before any nonce is reserved"); + let unknown_method = StateTransitionCreationOptions { + method_feature_version: Some(1), + ..Default::default() + }; + DocumentEraseTransitionBuilder::check_erase_is_constructible( + Some(&unknown_method), + current, + ) + .expect_err("an unknown erase method version is refused before any nonce is reserved"); + let unknown_base = StateTransitionCreationOptions { + base_feature_version: Some(9), + ..Default::default() + }; + DocumentEraseTransitionBuilder::check_erase_is_constructible(Some(&unknown_base), current) + .expect_err("an unknown erase base version is refused before any nonce is reserved"); + } + + #[cfg(feature = "mocks")] + #[tokio::test] + async fn should_sign_an_erase_with_the_latest_default_base() { + use crate::sdk::put_test_support::PutFixture; + use dpp::document::DocumentV0Getters; + use dpp::state_transition::batch_transition::batched_transition::BatchedTransition; + use dpp::state_transition::batch_transition::batched_transition::document_transition::DocumentTransition; + use dpp::state_transition::batch_transition::document_base_transition::document_base_transition_trait::DocumentBaseTransitionAccessors; + use dpp::state_transition::batch_transition::document_base_transition::DocumentBaseTransition; + use std::sync::atomic::Ordering; + + let fixture = PutFixture::new().await; + let transition = DocumentEraseTransitionBuilder::new( + Arc::new(fixture.contract.clone()), + "preorder".to_string(), + fixture.document.id(), + fixture.document.owner_id(), + ) + .sign( + &fixture.sdk, + &fixture.key, + &fixture.signer, + PlatformVersion::latest(), + ) + .await + .expect("default options must construct and sign an erase"); + assert_eq!(fixture.signer.0.load(Ordering::SeqCst), 1); + assert!(!transition.signature().unwrap().is_empty()); + let StateTransition::Batch(BatchTransition::V1(batch)) = transition else { + panic!("expected current batch"); + }; + let BatchedTransition::Document(DocumentTransition::Erase(erase)) = &batch.transitions[0] + else { + panic!("expected erase"); + }; + assert!(matches!(erase.base(), DocumentBaseTransition::V2(_))); + } +} diff --git a/packages/rs-sdk/src/platform/documents/transitions/mod.rs b/packages/rs-sdk/src/platform/documents/transitions/mod.rs index d8ae4c87cbc..9c9698665c7 100644 --- a/packages/rs-sdk/src/platform/documents/transitions/mod.rs +++ b/packages/rs-sdk/src/platform/documents/transitions/mod.rs @@ -1,5 +1,6 @@ pub mod create; pub mod delete; +pub mod erase; pub mod purchase; pub mod replace; pub mod set_price; @@ -9,6 +10,7 @@ pub use create::{DocumentCreateResult, DocumentCreateTransitionBuilder}; pub use delete::{ index_only_delete_document, DocumentDeleteResult, DocumentDeleteTransitionBuilder, }; +pub use erase::{DocumentEraseResult, DocumentEraseTransitionBuilder}; pub use purchase::{DocumentPurchaseResult, DocumentPurchaseTransitionBuilder}; pub use replace::{DocumentReplaceResult, DocumentReplaceTransitionBuilder}; pub use set_price::{DocumentSetPriceResult, DocumentSetPriceTransitionBuilder}; diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 828ce8674d8..74d24fc11e0 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -1814,6 +1814,7 @@ mod history_query_tests { lifecycle: Some(DocumentHistoryLifecycle { state: DocumentHistoryState::Active, remaining_revisions: 2, + times: Default::default(), }), }; sdk.mock() diff --git a/packages/rs-sdk/src/platform/transition/broadcast.rs b/packages/rs-sdk/src/platform/transition/broadcast.rs index 387989b8ae2..55664a70a74 100644 --- a/packages/rs-sdk/src/platform/transition/broadcast.rs +++ b/packages/rs-sdk/src/platform/transition/broadcast.rs @@ -218,9 +218,7 @@ impl BroadcastStateTransition for StateTransition { settings: Option, ) -> Result<(T, ResponseMetadata), Error> { let (outcome, metadata) = self.wait_for_outcome_with_metadata(sdk, settings).await?; - // An execution-proved outcome carries a strictly stronger guarantee - // than the requested snapshot, so both tags are accepted here. - convert_proof_result::(outcome.into_result()).map(|converted| (converted, metadata)) + convert_proof_result::(accept_affected_state(outcome)).map(|c| (c, metadata)) } async fn broadcast_and_wait_for_affected_state< @@ -448,6 +446,12 @@ pub fn require_execution_proved( } } +/// Accept either tag for the affected-state wait APIs: an execution-proved +/// outcome carries a strictly stronger guarantee than the snapshot requested. +fn accept_affected_state(outcome: StateTransitionProofOutcome) -> StateTransitionProofResult { + outcome.into_result() +} + /// Convert the verified inner result into the caller's expected type. pub fn convert_proof_result>( result: StateTransitionProofResult, @@ -1078,4 +1082,30 @@ mod tests { require_execution_proved(StateTransitionProofOutcome::execution_proved(proved)) .expect("execution-proved outcomes must pass the strict wait"); } + + /// The outcome an erase produces, run through both gates. A transition + /// family the classifier reports as affected state cannot use the strict + /// wait: its own valid proof would come back as an error. + #[test] + fn should_accept_affected_state_while_the_strict_wait_refuses_it() { + use std::collections::BTreeMap; + + let erased = || { + StateTransitionProofResult::VerifiedDocuments(BTreeMap::from([( + Identifier::from([9u8; 32]), + None, + )])) + }; + + let err = require_execution_proved(StateTransitionProofOutcome::affected_state(erased())) + .expect_err("the strict wait must refuse an erase's own outcome"); + assert!(matches!(err, Error::ExecutionNotProved(_))); + + let result = accept_affected_state(StateTransitionProofOutcome::affected_state(erased())); + let StateTransitionProofResult::VerifiedDocuments(documents) = result else { + panic!("the affected-state wait must return the document observation"); + }; + assert_eq!(documents.len(), 1); + assert_eq!(documents.get(&Identifier::from([9u8; 32])), Some(&None)); + } } diff --git a/packages/wasm-dpp/src/document/state_transition/batch_transition/document_transition/mod.rs b/packages/wasm-dpp/src/document/state_transition/batch_transition/document_transition/mod.rs index 89e0e5df571..8ead3f9bcfc 100644 --- a/packages/wasm-dpp/src/document/state_transition/batch_transition/document_transition/mod.rs +++ b/packages/wasm-dpp/src/document/state_transition/batch_transition/document_transition/mod.rs @@ -68,6 +68,9 @@ impl DocumentTransitionWasm { DocumentTransition::Transfer(_) => JsValue::null(), DocumentTransition::UpdatePrice(_) => JsValue::null(), DocumentTransition::Purchase(_) => JsValue::null(), + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => JsValue::null(), DocumentTransition::IndexOnlyDelete(index_only_delete) => { let json_value = index_only_delete.data().to_json_value().unwrap(); json_value @@ -118,6 +121,9 @@ impl DocumentTransitionWasm { DocumentTransition::UpdatePrice(update_price) => Some(update_price.price()), DocumentTransition::Purchase(purchase) => Some(purchase.price()), DocumentTransition::IndexOnlyDelete(_) => None, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } @@ -131,6 +137,9 @@ impl DocumentTransitionWasm { DocumentTransition::UpdatePrice(_) => None, DocumentTransition::Purchase(_) => None, DocumentTransition::IndexOnlyDelete(_) => None, + // Protocols through 14 publish no erase bounds, so their accepted batches + // never reach this arm. + DocumentTransition::Erase(_) => None, } } diff --git a/packages/wasm-dpp2/src/enums/batch/batch_enum.rs b/packages/wasm-dpp2/src/enums/batch/batch_enum.rs index 5454ded2665..57b53e19f5e 100644 --- a/packages/wasm-dpp2/src/enums/batch/batch_enum.rs +++ b/packages/wasm-dpp2/src/enums/batch/batch_enum.rs @@ -13,6 +13,7 @@ pub enum BatchTypeWasm { UpdatePrice, IgnoreWhileBumpingRevision, IndexOnlyDelete, + Erase, } impl TryFrom<&JsValue> for BatchTypeWasm { @@ -33,6 +34,8 @@ impl TryFrom<&JsValue> for BatchTypeWasm { "updateprice" => Ok(BatchTypeWasm::UpdatePrice), "ignorewhilebumpingrevision" => Ok(BatchTypeWasm::IgnoreWhileBumpingRevision), "indexonlydelete" => Ok(BatchTypeWasm::IndexOnlyDelete), + // Naming the appended kind does not admit it; released protocol bounds reject it. + "erase" => Ok(BatchTypeWasm::Erase), _ => Err(WasmDppError::invalid_argument(format!( "unknown batch type value: {}", enum_val @@ -60,6 +63,8 @@ impl TryFrom<&JsValue> for BatchTypeWasm { 5 => Ok(BatchTypeWasm::UpdatePrice), 6 => Ok(BatchTypeWasm::IgnoreWhileBumpingRevision), 7 => Ok(BatchTypeWasm::IndexOnlyDelete), + // The appended value preserves old discriminants; released protocol bounds reject it. + 8 => Ok(BatchTypeWasm::Erase), _ => Err(WasmDppError::invalid_argument(format!( "unknown batch type value: {}", enum_val @@ -89,6 +94,8 @@ impl From for String { BatchTypeWasm::UpdatePrice => String::from("updatePrice"), BatchTypeWasm::IgnoreWhileBumpingRevision => String::from("ignoreWhileBumpingRevision"), BatchTypeWasm::IndexOnlyDelete => String::from("indexOnlyDelete"), + // This labels the appended kind; released protocol bounds still reject it. + BatchTypeWasm::Erase => String::from("erase"), } } } @@ -106,6 +113,8 @@ impl From for DocumentTransitionActionType { DocumentTransitionActionType::IgnoreWhileBumpingRevision } BatchTypeWasm::IndexOnlyDelete => DocumentTransitionActionType::IndexOnlyDelete, + // Conversion preserves the kind; released protocol bounds still reject it. + BatchTypeWasm::Erase => DocumentTransitionActionType::Erase, } } } @@ -123,6 +132,8 @@ impl From for BatchTypeWasm { BatchTypeWasm::IgnoreWhileBumpingRevision } DocumentTransitionActionType::IndexOnlyDelete => BatchTypeWasm::IndexOnlyDelete, + // Conversion preserves the kind; released protocol bounds still reject it. + DocumentTransitionActionType::Erase => BatchTypeWasm::Erase, } } } diff --git a/packages/wasm-dpp2/src/state_transitions/batch/document_transition.rs b/packages/wasm-dpp2/src/state_transitions/batch/document_transition.rs index 5b022185001..793390099c5 100644 --- a/packages/wasm-dpp2/src/state_transitions/batch/document_transition.rs +++ b/packages/wasm-dpp2/src/state_transitions/batch/document_transition.rs @@ -53,6 +53,8 @@ impl DocumentTransitionWasm { DocumentTransitionActionType::UpdatePrice => 5, DocumentTransitionActionType::IgnoreWhileBumpingRevision => 6, DocumentTransitionActionType::IndexOnlyDelete => 7, + // The appended value preserves old discriminants; released protocol bounds reject it. + DocumentTransitionActionType::Erase => 8, } } diff --git a/packages/wasm-sdk/src/queries/document.rs b/packages/wasm-sdk/src/queries/document.rs index 48d7bccbcb8..a4012eca317 100644 --- a/packages/wasm-sdk/src/queries/document.rs +++ b/packages/wasm-sdk/src/queries/document.rs @@ -213,7 +213,13 @@ export interface DocumentHistoryQuery { */ documentId: IdentifierLike - /** Inclusive lower time bound. Supply exactly one selector. */ + /** + * Inclusive lower time bound. Supply exactly one selector. + * + * Every selector is an exact u64: a `number` is accepted only up to + * `Number.MAX_SAFE_INTEGER`, and anything larger must be a `bigint`, since + * JavaScript would have rounded it before the query is built. + */ startAtMs?: bigint | number; /** Complete exclusive cursor returned by a previous page. */ startAfter?: { timeMs: bigint | number; revision: bigint | number } | DocumentHistoryEntry; @@ -406,6 +412,10 @@ impl DocumentHistoryEntryWasm { pub struct DocumentHistoryLifecycleWasm { state: String, remaining_revisions: u64, + deleted_at_ms: u64, + erasing_started_at_ms: u64, + erasing_from_time_ms: u64, + erasing_from_revision: u64, } #[derive(Serialize)] @@ -413,11 +423,21 @@ pub struct DocumentHistoryLifecycleWasm { struct DocumentHistoryLifecycleSerde { state: String, remaining_revisions: String, + deleted_at_ms: String, + erasing_started_at_ms: String, + erasing_from_time_ms: String, + erasing_from_revision: String, } #[wasm_bindgen(js_class = DocumentHistoryLifecycle)] impl DocumentHistoryLifecycleWasm { - #[wasm_bindgen(getter)] + /// `ACTIVE` while the document is visible to ordinary reads, `DELETED` + /// once it has been deleted and its revisions are retained, `ERASING` once + /// an authorized erasure has begun, `ABSENT` when nothing is left. + #[wasm_bindgen( + getter, + unchecked_return_type = "\"ACTIVE\" | \"DELETED\" | \"ERASING\" | \"ABSENT\"" + )] pub fn state(&self) -> String { self.state.clone() } @@ -427,6 +447,30 @@ impl DocumentHistoryLifecycleWasm { BigInt::from(self.remaining_revisions) } + /// Zero unless the document has been deleted. + #[wasm_bindgen(getter = "deletedAtMs")] + pub fn deleted_at_ms(&self) -> BigInt { + BigInt::from(self.deleted_at_ms) + } + + /// Zero unless an authorized erasure has begun. + #[wasm_bindgen(getter = "erasingStartedAtMs")] + pub fn erasing_started_at_ms(&self) -> BigInt { + BigInt::from(self.erasing_started_at_ms) + } + + /// Timestamp of the newest revision retained when the erasure began. + #[wasm_bindgen(getter = "erasingFromTimeMs")] + pub fn erasing_from_time_ms(&self) -> BigInt { + BigInt::from(self.erasing_from_time_ms) + } + + /// History sequence of the newest revision retained when the erasure began. + #[wasm_bindgen(getter = "erasingFromRevision")] + pub fn erasing_from_revision(&self) -> BigInt { + BigInt::from(self.erasing_from_revision) + } + #[wasm_bindgen(js_name = toJSON)] pub fn to_json(&self) -> Result { serialization::to_json(&self.to_serde()).map_err(WasmSdkError::from) @@ -438,6 +482,10 @@ impl DocumentHistoryLifecycleWasm { DocumentHistoryLifecycleSerde { state: self.state.clone(), remaining_revisions: self.remaining_revisions.to_string(), + deleted_at_ms: self.deleted_at_ms.to_string(), + erasing_started_at_ms: self.erasing_started_at_ms.to_string(), + erasing_from_time_ms: self.erasing_from_time_ms.to_string(), + erasing_from_revision: self.erasing_from_revision.to_string(), } } } @@ -464,6 +512,8 @@ impl DocumentHistoryResultWasm { self.entries.clone() } + /// Missing when the legacy storage generation cannot authenticate lifecycle + /// metadata. #[wasm_bindgen(getter)] pub fn lifecycle(&self) -> Option { self.lifecycle.clone() @@ -518,10 +568,16 @@ impl DocumentHistoryResultWasm { .map(|lifecycle| DocumentHistoryLifecycleWasm { state: match lifecycle.state { DocumentHistoryState::Active => "ACTIVE", + DocumentHistoryState::Deleted => "DELETED", + DocumentHistoryState::Erasing => "ERASING", DocumentHistoryState::Absent => "ABSENT", } .to_owned(), remaining_revisions: lifecycle.remaining_revisions, + deleted_at_ms: lifecycle.times.deleted_at_ms, + erasing_started_at_ms: lifecycle.times.erasing_started_at_ms, + erasing_from_time_ms: lifecycle.times.erasing_from_time_ms, + erasing_from_revision: lifecycle.times.erasing_from_revision, }), }) } @@ -1778,7 +1834,8 @@ mod history_wasm_tests { use crate::error::WasmSdkErrorKind; use dash_sdk::platform::proto::get_document_history_response::GetDocumentHistoryResponseV1; use drive_proof_verifier::types::{ - DocumentHistoryEntry, DocumentHistoryLifecycle, DocumentHistoryState, + DocumentHistoryEntry, DocumentHistoryLifecycle, DocumentHistoryLifecycleTimes, + DocumentHistoryState, }; use js_sys::{Array, Reflect}; use wasm_bindgen::JsCast; @@ -1951,6 +2008,37 @@ mod history_wasm_tests { ); } + /// A `u64` selector crosses from JavaScript exactly or not at all: the + /// deserializer takes a `number` only while it is a safe integer, since a + /// larger one was rounded before it reached Rust, and takes a `bigint` at + /// any `u64`. Nothing in this crate adds to that; this pins that it holds. + #[wasm_bindgen_test] + fn should_take_history_selectors_as_exact_integers_only() { + let query = |start_at_ms: JsValue| { + let object = js_sys::Object::new(); + let id = IdentifierWasm::from([1u8; 32]).to_base58(); + Reflect::set(&object, &"dataContractId".into(), &id.clone().into()).unwrap(); + Reflect::set(&object, &"documentTypeName".into(), &"note".into()).unwrap(); + Reflect::set(&object, &"documentId".into(), &id.into()).unwrap(); + Reflect::set(&object, &"startAtMs".into(), &start_at_ms).unwrap(); + parse_document_history_query(JsValue::from(object).unchecked_into()) + }; + let past_safe = (1u64 << 53) + 1; + + let parsed = query(JsValue::from(js_sys::BigInt::from(past_safe))) + .expect("a bigint carries the exact value"); + assert_eq!( + parsed.filter, + DocumentHistoryFilter::StartAtTime(past_safe), + "the selector must be the value the caller passed" + ); + + query(JsValue::from(past_safe as f64)) + .expect_err("a number past Number.MAX_SAFE_INTEGER was already rounded and is refused"); + query(JsValue::from(-1.0)).expect_err("a negative number is refused"); + query(JsValue::from(1.5)).expect_err("a fractional number is refused"); + } + #[wasm_bindgen_test] fn should_preserve_same_time_revisions_and_exact_lifecycle_counts_in_javascript() { let count = (1u64 << 53) + 1; @@ -1966,6 +2054,7 @@ mod history_wasm_tests { lifecycle: Some(DocumentHistoryLifecycle { state: DocumentHistoryState::Active, remaining_revisions: count, + times: Default::default(), }), }; let result = JsValue::from( @@ -1990,6 +2079,47 @@ mod history_wasm_tests { ); } + /// Every lifecycle time crosses into JavaScript as an exact BigInt, like + /// the counts and revisions beside them: a millisecond timestamp does not + /// survive a JavaScript number. + #[wasm_bindgen_test] + fn should_report_the_erasing_state_and_its_times_exactly_in_javascript() { + let started_at = (1u64 << 53) + 3; + let history = DocumentHistory { + entries: vec![], + lifecycle: Some(DocumentHistoryLifecycle { + state: DocumentHistoryState::Erasing, + remaining_revisions: 7, + times: DocumentHistoryLifecycleTimes { + deleted_at_ms: 1_700_000_000_001, + erasing_started_at_ms: started_at, + erasing_from_time_ms: 1_700_000_000_002, + erasing_from_revision: 42, + }, + }), + }; + let result = JsValue::from( + DocumentHistoryResultWasm::from_history(history, [1; 32].into(), "note").unwrap(), + ); + let lifecycle = Reflect::get(&result, &"lifecycle".into()).unwrap(); + assert_eq!( + Reflect::get(&lifecycle, &"state".into()).unwrap(), + JsValue::from_str("ERASING") + ); + for (key, expected) in [ + ("deletedAtMs", 1_700_000_000_001u64), + ("erasingStartedAtMs", started_at), + ("erasingFromTimeMs", 1_700_000_000_002), + ("erasingFromRevision", 42), + ] { + assert_eq!( + Reflect::get(&lifecycle, &key.into()).unwrap(), + JsValue::from(expected), + "{key} must survive as an exact BigInt" + ); + } + } + #[wasm_bindgen_test] fn should_serialize_history_data_in_a_proof_metadata_response() { let history = DocumentHistory { @@ -2001,6 +2131,7 @@ mod history_wasm_tests { lifecycle: Some(DocumentHistoryLifecycle { state: DocumentHistoryState::Active, remaining_revisions: (1u64 << 53) + 1, + times: Default::default(), }), }; let response = document_history_proof_response( diff --git a/packages/wasm-sdk/src/state_transitions/document.rs b/packages/wasm-sdk/src/state_transitions/document.rs index 129ad0303aa..8687249ff8b 100644 --- a/packages/wasm-sdk/src/state_transitions/document.rs +++ b/packages/wasm-sdk/src/state_transitions/document.rs @@ -13,7 +13,9 @@ use dash_sdk::dpp::identity::IdentityPublicKey; use dash_sdk::dpp::platform_value::Identifier; use dash_sdk::dpp::state_transition::batch_transition::methods::StateTransitionCreationOptions; use dash_sdk::dpp::tokens::token_payment_info::TokenPaymentInfo; -use dash_sdk::platform::documents::transitions::DocumentDeleteTransitionBuilder; +use dash_sdk::platform::documents::transitions::{ + DocumentDeleteTransitionBuilder, DocumentEraseTransitionBuilder, +}; use dash_sdk::platform::transition::purchase_document::PurchaseDocument; use dash_sdk::platform::transition::put_document::PutDocument; use dash_sdk::platform::transition::put_settings::PutSettings; @@ -701,6 +703,157 @@ fn delete_transition_builder( } } +// ============================================================================ +// Document Erase +// ============================================================================ + +/// TypeScript interface for document erase options +#[wasm_bindgen(typescript_custom_section)] +const DOCUMENT_ERASE_OPTIONS_TS: &'static str = r#" +/** + * Options for erasing the retained revisions of an already deleted document. + */ +export interface DocumentEraseOptions { + /** + * The document to erase, or the identifiers that name it. The document is + * already invisible to ordinary reads, so its identifiers are all that is + * needed. + */ + document: Document | { + id: IdentifierLike; + ownerId: IdentifierLike; + dataContractId: IdentifierLike; + documentTypeName: string; + }; + + /** + * The identity submitting and paying for this erase. It is the identity the + * key and signer below belong to, and its contract nonce is consumed. + * Defaults to the document's owner, which is who the first erase must come + * from; the erases after it may come from any identity, which then names + * itself here. + */ + identityId?: IdentifierLike; + + /** + * The identity public key to use for signing the transition. + * The first erase must be signed by the document's owner; any identity may + * sign the ones after it. + */ + identityKey: IdentityPublicKey; + + /** + * Signer containing the private key that corresponds to the identity key. + * Use IdentitySigner to add the private key before calling. + */ + signer: IdentitySigner; + + /** + * Optional settings for the broadcast operation. + * Includes retries, timeouts, userFeeIncrease, etc. + */ + settings?: PutSettings; +} +"#; + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(typescript_type = "DocumentEraseOptions")] + pub type DocumentEraseOptionsJs; +} + +#[wasm_bindgen] +impl WasmSdk { + /// Erase a chunk of the retained revisions of an already deleted document. + /// + /// A document with more retained revisions than one transition may remove + /// needs several calls. The first must come from the document's owner and + /// commits the document to erasure; any identity may make the ones after + /// it. Read the document's history to see how much is left. + /// + /// @param options - Erase options including the document identifiers, identity key, and signer + /// @returns Promise that resolves after an affected-state proof authenticates + /// that the document is absent by id. This does not prove that this erase + /// executed or was accepted; query document history to observe the lifecycle + /// and remaining revisions. + #[wasm_bindgen(js_name = "documentErase")] + pub async fn document_erase( + &self, + options: DocumentEraseOptionsJs, + ) -> Result<(), WasmSdkError> { + let document_js = js_sys::Reflect::get(&options, &JsValue::from_str("document")) + .map_err(|_| WasmSdkError::invalid_argument("document is required"))?; + + if document_js.is_undefined() || document_js.is_null() { + return Err(WasmSdkError::invalid_argument("document is required")); + } + + // The transition carries only the base, so the values of a Document + // instance are not needed and a plain object of identifiers works for + // every document type. + let (document_id, owner_id, contract_id, document_type_name): ( + Identifier, + Identifier, + Identifier, + String, + ) = if get_class_type(&document_js).ok().as_deref() == Some("Document") { + let doc: DocumentWasm = document_js + .to_wasm::("Document") + .map(|boxed| (*boxed).clone())?; + let doc_inner: Document = doc.clone().into(); + ( + doc.id().into(), + doc_inner.owner_id(), + doc.data_contract_id().into(), + doc.document_type_name(), + ) + } else { + ( + IdentifierWasm::try_from_options(&document_js, "id")?.into(), + IdentifierWasm::try_from_options(&document_js, "ownerId")?.into(), + IdentifierWasm::try_from_options(&document_js, "dataContractId")?.into(), + try_from_options_with(&document_js, "documentTypeName", |v| { + try_to_string(v, "documentTypeName") + })?, + ) + }; + + // The builder's owner is the identity that submits and pays; only the + // first erase has to be the document's owner, so a continuation names + // its own identity here and keeps the document owner as metadata. + let submitter_id: Identifier = + match try_from_options_optional::(&options, "identityId")? { + Some(identity_id) => identity_id.into(), + None => owner_id, + }; + + let identity_key_wasm = IdentityPublicKeyWasm::try_from_options(&options, "identityKey")?; + let identity_key: IdentityPublicKey = identity_key_wasm.into(); + let signer = IdentitySignerWasm::try_from_options(&options, "signer")?; + let data_contract = self.get_or_fetch_contract(contract_id).await?; + let settings = + try_from_options_optional::(&options, "settings")?.map(Into::into); + + let builder = DocumentEraseTransitionBuilder::new( + Arc::new(data_contract), + document_type_name, + document_id, + submitter_id, + ); + let builder = if let Some(s) = settings { + builder.with_settings(s) + } else { + builder + }; + + self.inner_sdk() + .document_erase(builder, &identity_key, &signer) + .await?; + + Ok(()) + } +} + // ============================================================================ // Document Transfer // ============================================================================