Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

feat: immutibility and contracts that allow document history #79

Merged
merged 18 commits into from
Mar 10, 2022

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Feb 27, 2022

Contracts now should allow the following four fields:
keepsHistory: keep the history of all previous versions of the contract. Default False
readonly: is the contract readonly? If it is it can never be changed. Default False
documentsKeepHistoryContractDefault: should contract documents keep history by default? Default False
documentsMutableContractDefault: should contract documents be mutable by default? Default True

Document Types also have two new fields:
documentsKeepHistory: should contract documents keep history? Overrides contract default at the document type level.
documentsMutable: should contract documents be mutable? Overrides contract default at the document type level.

Querying documents at a block level is now also allowed. However for now just one document by its Id can be queried.
The query looks like this:

        "where": [
            ["$id", "==", "6A8SGgdmj2NtWCYoYDPDpbsYkq2MCbgi6Lx4ALLfF179"]
        ],
        "blockTime": 300
    }```

@QuantumExplorer QuantumExplorer changed the base branch from v0.22-dev to v0.23-dev February 28, 2022 00:27
@shumkov
Copy link
Member

shumkov commented Mar 7, 2022

@QuantumExplorer We planned to use a special JSON Schema readOnly keyword to enable immutability and actually it does nothing at the storage level. It's about validation logic which is in DPP at the moment.

As I understood there are four different changes in this PR:

  1. Proper update document
  2. Querying block time (no idea about this feature at all)
  3. Immutability (which is currently must be implemented in DPP) and using special JSON Schema keyword
  4. Document history (revisions)

Could you please split them into different PRs according to our contributing guide?

@QuantumExplorer
Copy link
Member Author

@shumkov Are you aware that this splitting will take me quite some time. Since this has not been released to production I don't see the benefit of value/time. We need to stop with the approach of everything needs to be perfect all the time or velocity will be reduced.

Regarding some comments:

  1. This is about the ability to query previous revisions. Right now you can only query as an equality. Query with "in" values should be possible but would need an update to GroveDB.

  2. Immutability (Nothing is stopping you from using both). I believe this secondary index database should be able to have immutability on its own merits.

@shumkov
Copy link
Member

shumkov commented Mar 7, 2022

@QuantumExplorer If the project is not in production it doesn't mean that our contributing guide is not valid anymore (and other best practices). I don't see why this functionality is so urgent that we should merge it with breaking our rules.

  1. I see. Thank you. I need to go to the code and I probably will have more questions.

  2. Hm... I thought it's Drive repo, so you want to incorporate some functionality to Drive which won't be used?

@QuantumExplorer
Copy link
Member Author

@shumkov My point is that before production, and with very important time constraints, we could bend the contributing guide. As a compromise could we merge this one in, but in the future I'll be sure to make my PRs more single feature focused?

  1. Well I don't see why you wouldn't use it, but if you want to do the validation on a more expensive level then I'm not going to care for now. All I want is that this functionality exists.

@shumkov
Copy link
Member

shumkov commented Mar 7, 2022

@QuantumExplorer Sounds good to me!

  1. Do you mind using a special keyword for immutability https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.4?

Copy link
Member

@shumkov shumkov left a comment

Choose a reason for hiding this comment

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

👍

@shumkov shumkov merged commit 8592f2e into v0.23-dev Mar 10, 2022
@shumkov shumkov deleted the feat/historicalContracts branch March 10, 2022 16:33
shumkov pushed a commit to dashpay/platform that referenced this pull request Nov 23, 2022
…/rs-platform#79)

* added contract and document type fields for mutability and historical data

* added in immutability

* basic contract history

* better test for import contract

* added test for mutability for DashPay contact Requests

* better updating of documents, and documents with keep history

* added in tests verifying historical contracts

* added test and fixed limit issue

* fixed some warnings

* various fixes and tests

* formatting and clippy fixes

* update to node bindings

* fixed bindings

* fixed linting

* clippy warnings

* clippy warnings

* added more fixes

* changed readonly to readOnly
shumkov pushed a commit to dashpay/platform that referenced this pull request Nov 23, 2022
…/rs-platform#79)

* added contract and document type fields for mutability and historical data

* added in immutability

* basic contract history

* better test for import contract

* added test for mutability for DashPay contact Requests

* better updating of documents, and documents with keep history

* added in tests verifying historical contracts

* added test and fixed limit issue

* fixed some warnings

* various fixes and tests

* formatting and clippy fixes

* update to node bindings

* fixed bindings

* fixed linting

* clippy warnings

* clippy warnings

* added more fixes

* changed readonly to readOnly
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants