Skip to content
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

Apparent Mutability of DB API contents #242

Open
faddat opened this issue Nov 12, 2020 · 5 comments
Open

Apparent Mutability of DB API contents #242

faddat opened this issue Nov 12, 2020 · 5 comments

Comments

@faddat
Copy link
Contributor

faddat commented Nov 12, 2020

Please note that this issue is titled apparent mutability. Database API contents are not actually mutable.

But to an outside observer, or any application calling that API, they will appear to be mutable, and state changes are not currently retrievable.

A private key or account holder can overwrite the contents of values for any key in the database API with any arbitrary content, and it is not possible to retrieve changes in state over time.

So, while historical state is stored in the blockchain, only the latest state can be retrieved.

This poses issues for:

  • Contracts that store state in the db api
  • Applications that store state in the db api
  • Verification of contracts and applications that store state in the db api
  • Content (text) stored in the db api being treated as immutable

Solutions:

  • Each key can be assigned a value exactly once, at which point it can no longer be mutated (probably easier but not as featureful)

OR

  • Values can be mutated like now, but it is possible to retrieve historical state for values by querying their key.
@speedmax
Copy link

speedmax commented Nov 12, 2020

Assume internal data structure have done a state transition, we should allow retrieval of value from previous blocks.

This would improve audibility when dapp rely on storage API to expose auditable data, config and events.

GET /database/get/{namespace}/{dbKey}?blockHeight=123412

Does this also makes sense for contract data record?

GET /contract/data/{contract}/{dbKey}?blockHeight=123412

@faddat
Copy link
Contributor Author

faddat commented Nov 12, 2020

What you propose here is a variant on my 2nd solution -- allow retrieval of historical state.

I was thinking of just returning the full historical state when a key is queried like:

GET /database/get/{namespace}/{dbKey}

Reasoning: in blockchain-land it is pretty common to return a bit too much, then truncate. Perhaps it's better to implement in this order:

FIRST
Below should return full history:

GET /database/get/{namespace}/{dbKey}

SECOND
Below should return state at a given block height:

GET /database/get/{namespace}/{dbKey}?blockHeight=123412

THIRD
Below should return state, filtered or somesuch:

GET /database/get/{namespace}/{dbKey}?filter=something

Note

The current problem is very specifically not one of mutability. All VSYS chain state is immutable.

It is a problem of apparent mutability

@speedmax
Copy link

speedmax commented Nov 12, 2020

Below should return state at a given block height

Block height makes sense, ideally response header should include HTTP ETag with TX Hash as value.

  • This way, it would be able to utilise HTTP caching and Browser's conditional-get capability with CDN, browsers when value has not change.

  • This also provides a txid, if app wants to audit previous state they can pull block height from this tx.

@faddat
Copy link
Contributor Author

faddat commented Jun 9, 2021

I've heard that we're deprecating the DB API-- @ncying could you please confirm this?

If we are deprecating that, it's safe to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants