seraphis-migration / wallet3

Info and discussions about a hypothetical full 'wallet2' rewrite from scratch
MIT License
13 stars 0 forks source link

EnoteStore serialization #54

Open DangerousFreedom1984 opened 1 year ago

DangerousFreedom1984 commented 1 year ago

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 commented 1 year ago

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.