Sync events on local dev chain

it doesn’t seem that hardhat node offers a way to save a blockchain state.

ok, how complicated would be to start a new Moralis dev server, test there and if it works there to delete the previous one that you used?

It is not that complicated, but if I need to do this everry work session then it will be really hard :frowning:
But i’ll try to see if it fixes the problem.

Hey so I just tried out what you proposed and indeed it seems the root problem is when you restart a blockchain to block 0 once the link has been done.

After the server instance was ready i tried the event it was syncing fine but when i restarted the devchain it stopped working.

Are there any solutions ?
Please don’t tell me I have to create a new server instance on each session :pensive:

I usually use Ganache and I can keep a Ganache instance few days without restarting it, I don’t know a better solution for now other then starting a new Moralis dev server. In the future it should be a button to reset Moralis server instance, but we don’t have it yet from what I know.

Isn’t there any way to save a blockchain in local and restart from the saved state?
Do you any infos about when the fix will be available ?

To be truthful I love the product you’re building it’s amazing and I really want to purchase the pro plan but with this kind of issue it makes development really complicated…
Aren’t there any way to either save the blockchain state or tricking the system into resetting the sync with moralis?

I don’t know about saving state with Hardhat, maybe it has. Yes, we should have a button to reset a Moraris dev instance.

Do you have any deadlines/roadmap available to know when this feature will be ready ?

Oh and by the way it seems that i cannot restrict public edit/writing in sync events table but there could be an exploit as someone could write a fake event no ?

You should be able to set Class Level Permissions from Moralis Dashboard on security in top right of the page. And this way you could remove write permissions for public. You say that it doesn’t work?

It works bbut then i get logs saying that the sync events has no rights to write on the table

ok, got it, I’ll have to take a closer look on how that could be fixed

1 Like

Also you where talking about the fact that the idea was to remove beforeConsume, but right now there are no other hooks that can be triggered when an event is being synced and that is bloody useful. So please provide a ‘onEventSync’ hook then!

You have beforeSave and afterSave

Yes but beforeSave is not fired sync events saves right ?

It should be, only for original historical sync it isn’t

Yes but so you can’t define you scheme as precisely than with beforeConsume I guess

You can use a one time job to reprocess the events that were added with historical sync and for new ones you can use beforeSave

Thanks for the workaround!
It is your choice to make in the end but please consider providing a simple onEventSync trigger it would allow anyone to handle events the way they want without having a table dedicated to the event itself, it would make this whole part way more flexible than it is right now in my opinion.