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

EnoteStore serialization #54

Open
DangerousFreedom1984 opened this issue May 29, 2023 · 1 comment
Open

EnoteStore serialization #54

DangerousFreedom1984 opened this issue May 29, 2023 · 1 comment

Comments

@DangerousFreedom1984
Copy link

Hello,
I would like to ask some questions to make sure we agree about the way to serialize the SpEnoteStore class.

First, the motivation to do it is pretty simple. The SpEnoteStore is the object that keeps track of the spent enotes and therefore we should be able to load/save it from the disk instead of scanning the whole blockchain each time the wallet is loaded.

So, there must be a way to interact from the stored enotes (I will call this file wallet.enotes from now on but later it could also contain the transaction history and more stuff) and the SpEnoteStore class itself.

The idea is simple but there may be some points worth discussing so will be nice if we are in the same wavelength.

So the work is basically:

  1. Serialize the SpEnoteStore
  2. Store on disk
  3. Load from disk
  4. Load serialized struct to SpEnoteStore

So for example if I want to use the m_sp_contextual_enote_records, I would create serializables for:
SpEnoteStore -> SpContextualEnoteRecordV1 -> SpEnoteRecordV1 under the seraphis_wallet/serialization_types.* in the same way that I'm doing for the TransactionStore since almost all the infrastructure required is already available at serialization/containers.h (or it can be added like I did for the serializable_multimap).

I'm pretty sure I can do that so my specific questions are:

  1. Is it okay creating the serializables of the structs SpContextualEnoteRecordV1, SpEnoteRecordV1 and etc (all that is needed to serialize the EnoteStore class) under seraphis_wallet/serialization_types or would it be better to let under seraphis_impl somewhere?

  2. Is the serialization scheme appropriate using the BEGIN_SERIALIZE() ... END_SERIALIZE() now and in view of possible changes of the serialization methods?

  3. One of the first things that the wallet will do when it is loaded is to load the SpEnoteStore from the wallet.enotes. The 'jurisdiction' of the wallet stops there, right? If the cached blockheight does not match with the current blockchain height then the 'seraphis_engine' will handle that and update the SpEnoteStore, which will be later used to update the wallet.enotes file, right?

@UkoeHB
Copy link

UkoeHB commented May 29, 2023

Is it okay creating the serializables of the structs SpContextualEnoteRecordV1, SpEnoteRecordV1 and etc (all that is needed to serialize the EnoteStore class) under seraphis_wallet/serialization_types

Yes this should be fine for now. We can rearrange things later if needed.

Is the serialization scheme appropriate using the BEGIN_SERIALIZE() ... END_SERIALIZE() now and in view of possible changes of the serialization methods?

Yes just use this. It can be changed later if needed.

If the cached blockheight does not match with the current blockchain height then the 'seraphis_engine' will handle that and update the SpEnoteStore, which will be later used to update the wallet.enotes file, right?

Yes.

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

2 participants