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

Remove Binary from state / storage structs #17

Open
Tracked by #84
maurolacy opened this issue Jul 31, 2024 · 3 comments
Open
Tracked by #84

Remove Binary from state / storage structs #17

maurolacy opened this issue Jul 31, 2024 · 3 comments

Comments

@maurolacy
Copy link
Collaborator

maurolacy commented Jul 31, 2024

We're using Binary types as part of state / storage in smart contracts. This is not a good idea for a number of reasons:

  • Binary is base64 encoded, which is wasteful / non-efficient.
  • Base64 encoding changes depending on the data, and breaks lexicographical order of the underlying data, which is not convenient for tests, etc.

Also, since we'll be creating ancillary structs for state (which is a burden but good for flexibility / control), we should consider not using hex data in state as well. Let's just store the raw bytes, and convert to the required hex encoded data when / if needed.

Finally, let's not store unnecessary data in the state. Let's use the ancillary structs to trim the data to store to the minimum necessary for functionality.

@maurolacy
Copy link
Collaborator Author

@maurolacy commented on 2024-07-02:

Unless, smart contract data is being stored encoded as JSON, that is. Shouldn't be the case, but let's confirm this, just to err on the safe side.

I mean, I would want an ASCII / human readable format for transferring data, and for interacting with it from the CLI.

But, I wouldn't want that to save / persist data. I would want a compact, byte efficient format for storage. Let's check this, and introduce one if there isn't there.

@maurolacy
Copy link
Collaborator Author

maurolacy commented Aug 13, 2024

Unnecessary data that can be trimmed down / outright removed:

  • staking_tx and slashing_tx. Let's compute and store their hashes instead.
  • covenant_sigs.
  • unbonding_tx and slashing_tx. Let's store their hashes directly.
  • The delegator_unbonding_sig field is being used to mark the delegation as undelegated. The same can be done through a boolean though, and remove the sigs altogether (done in F/btc delegations #39).
  • ...

@maurolacy
Copy link
Collaborator Author

maurolacy commented Oct 8, 2024

Unless, smart contract data is being stored encoded as JSON, that is.

This is irrelevant here. Let's just make our state structs as compact / minimal as possible at the struct / fields level. And remove Binary from the storage for lexicographical sorting stability / data transparency.

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

No branches or pull requests

2 participants