Repository navigation
feat(platform)!: document history system contract with per-doctype opt-in #4171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d07fc67
feat(platform)!: document history system contract with per-doctype op…
QuantumExplorer dada3b9
fix(platform): gate document history activation strictly to protocol …
QuantumExplorer d752aa7
test(drive-abci): update PV13 fee baselines for document history gene…
QuantumExplorer 8650436
fix(dpp): parse keeps*History flags only from document meta-schema v2
QuantumExplorer c94eb2e
feat(platform): provable count/sum/average aggregation on document hi…
QuantumExplorer cdb95f0
docs(dpp): correct the v2 document meta-schema freeze comment
QuantumExplorer 0753175
Merge branch 'v4.1-dev' into claude/document-history-contract
QuantumExplorer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| require: test/bootstrap.js | ||
| recursive: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [package] | ||
| name = "document-history-contract" | ||
| description = "Document history data contract schema and tools" | ||
| version.workspace = true | ||
| edition = "2021" | ||
| rust-version.workspace = true | ||
| license = "MIT" | ||
|
|
||
| [dependencies] | ||
| thiserror = "2.0.12" | ||
| platform-version = { path = "../rs-platform-version" } | ||
| serde_json = { version = "1.0" } | ||
| platform-value = { path = "../rs-platform-value" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2019 Dash Core Group, Inc. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Document History Contract | ||
|
|
||
| [](https://github.com/dashpay/platform/actions/workflows/release.yml) | ||
|
|
||
| System data contract recording document transfer, purchase, and price-change | ||
| events for document types that opt in via the `keepsTransferHistory`, | ||
| `keepsPurchaseHistory`, and `keepsPricingHistory` configuration flags. | ||
|
|
||
| History documents are written by the protocol itself during document | ||
| transfer, purchase, and price-update state transitions | ||
| (`creationRestrictionMode: 2` — they can never be created directly), and are | ||
| immutable and permanent once written. | ||
|
|
||
| The document types carry provable aggregation trees: | ||
|
|
||
| - `purchase` is doctype-averageable on `price` (O(1) provable all-time sale | ||
| count, total volume, and average sale price), and its `byContract` and | ||
| `byDocument` indices are range-averageable over `$createdAt` (provable | ||
| per-contract and per-document sale count / volume / average between dates). | ||
| - `priceUpdate` is doctype-countable, and its `byContract` and `byDocument` | ||
| indices are range-averageable over `$createdAt` (provable average asking | ||
| price between dates). These are listing-event-weighted averages, not | ||
| time-weighted prices. | ||
| - `transfer` is doctype-countable, and its `byContract` index is | ||
| range-countable over `$createdAt` (provable transfer counts per contract | ||
| and time window). | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [Contributing](#contributing) | ||
| - [License](#license) | ||
|
|
||
| ## Contributing | ||
|
|
||
| Feel free to dive in! [Open an issue](https://github.com/dashpay/platform/issues/new/choose) or submit PRs. | ||
|
|
||
| ## License | ||
|
|
||
| [MIT](LICENSE) © Dash Core Group, Inc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import baseConfig from '../../eslint/base.mjs'; | ||
| import mochaTestConfig from '../../eslint/mocha-tests.mjs'; | ||
|
|
||
| export default [ | ||
| ...baseConfig, | ||
| mochaTestConfig, | ||
| { | ||
| ignores: ['dist/**', 'node_modules/**'], | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module.exports = { | ||
| ownerId: '11111111111111111111111111111111', | ||
| contractId: '6voHRaoiPcfmMhbqCA9dixH98xcgPQ9UEcuaXjpVu3LD', | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "name": "@dashevo/document-history-contract", | ||
| "version": "4.0.0", | ||
| "description": "The document history contract", | ||
| "scripts": { | ||
| "lint": "eslint .", | ||
| "test": "yarn run test:unit", | ||
| "test:unit": "mocha 'test/unit/**/*.spec.js'" | ||
| }, | ||
| "contributors": [ | ||
| { | ||
| "name": "Samuel Westrich", | ||
| "email": "sam@dash.org", | ||
| "url": "https://github.com/quantumexplorer" | ||
| } | ||
| ], | ||
| "license": "MIT", | ||
| "devDependencies": { | ||
| "@dashevo/wasm-dpp": "workspace:*", | ||
| "chai": "^4.3.10", | ||
| "dirty-chai": "^2.0.1", | ||
| "eslint": "^9.18.0", | ||
| "mocha": "^11.1.0", | ||
| "sinon": "^18.0.1", | ||
| "sinon-chai": "^3.7.0" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Register DocumentHistory with the C/Swift trusted context provider
The new SystemDataContract::DocumentHistory variant is not propagated through the rs-sdk and rs-sdk-trusted-context-provider feature lists, and TrustedHttpContextProvider::get_data_contract has no branch that loads it. rs-sdk-ffi enables the existing system-contract features and dash_sdk_create_trusted constructs this provider without a fallback, so dash_sdk_document_fetch_by_contract_id returns "Contract ... not found in trusted context" for the document-history ID. Add a document-history-contract feature through rs-sdk, rs-sdk-trusted-context-provider, and rs-sdk-ffi, include it in all-system-contracts, and load SystemDataContract::DocumentHistory alongside TokenHistory and KeywordSearch.
source: ['codex']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 31b4f83 — added a document-history-contract feature through rs-sdk, rs-sdk-trusted-context-provider (included in its all-system-contracts umbrella and enabled by rs-sdk-ffi's provider dependency), and a DocumentHistory branch in TrustedHttpContextProvider::get_data_contract alongside TokenHistory and KeywordSearch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in this update — Register DocumentHistory with the C/Swift trusted context provider no longer present.
Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.