Local hardhat chain not syncing with events to database

Iā€™m syncing to a local hardhat chain as such:

moralis-admin-cli connect-local-devchain --chain hardhat --moralisSubdomain XXXX --frpcPath ./frp/frpc

API keys are stored in a .env file, and the first time I synced for events, everything went smooth and values were loading in the Moralis database!

But when I left my project and came back, restarted my hardhat node and synced for events, the values didnā€™t show up in the table anymore. I even recreated the sync events and restarted my node, sync connection, and everything, wondering if Iā€™m doing something wrong?

For reference:

local hardhat node

deploying "NftMarketplace" (tx: 0x67e866e05cffecbc9d5c983b6059dc8c8d3b71f74999feb07dc3f7eef11039ed)...: deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3 with 1359579 gas
----------------------------------------------------
----------------------------------------------------
deploying "BasicNft" (tx: 0x484912c7b9bbcace4999e9d8baf3e9e5cd65588f7ecac6e8fa2a60a4d03c3ea7)...: deployed at 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 with 2154911 gas
----------------------------------------------------
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/

Connected:

Sync event looks good (I even remade it and double-checked the deploy address)

I emitted some events, but itā€™s still empty :frowning:

Thoughts?

Can you paste the server url? I may need to restart coresercices again.

https://c9lzx0lrsddy.usemoralis.com:2053/server

I can look in an hour, to get back to a computer.

1 Like

Can you check again now to see if it works?

Still bunked up :confused:

But I made a new one with a different user and thatā€™s working - so Iā€™m just going to test with that for nowā€¦ Quite odd though.

1 Like

Ahhh, looks like I might have found the issue. If you delete stuff from the events database, it pretty much destroys syncing (I think).

I just deleted stuff from my DB and it wonā€™t listen for events anymore.

I tried restarting the server, deleting stuff in the database, but to no avail :confused:

Both servers bunked:
https://gdlufztndolb.usemoralis.com:2053/server
https://c9lzx0lrsddy.usemoralis.com:2053/server

Hoping this wonā€™t stay a bug, makes it really hard to test locally @cryptokid

1 Like

we did an update today that should solve some of the problems

what are the steps that you do when you test?
asking because if you reset your local dev environment to block 0, then you will need to create a new dev server too

Every time I restart my hardhat node Iā€™ll have to create a new server?

And I just made two brand new accounts, and new sync events donā€™t seem to be showing up until a loooooong time later. Maybe this was just part of the update taking place, I noticed the version changing.

how long was this delay?

Maybe 15 minutesā€¦ could have been just a fluke? Every time I looked at the Sync tab it was emptyā€¦ until it finally just ā€œshowed upā€.

if by restarting it it gets a reset to block 0, and loosing the previous transactions, then yes, it is a good idea to create a new server an delete the old one

Itā€™s finally working againā€¦ but yeah knowing the limits would be nice. It seems like:

  1. If you delete anything in the events database, itā€™ll get confused.
  2. If you restart your hardhat node, itā€™ll get confused (I was pretty sure this was working for me beforeā€¦ but maybe I was wrong)
  3. You might have to wait a period of time before your new events hit the sync tab.

Hmmā€¦ Maybe thatā€™s a future improvement was can do.

Not sure if this is possible at the moment: https://ethereum.stackexchange.com/questions/123918/save-hardhat-node-state-for-later

I know that it is possible with ganache in ganache interface, I donā€™t know about hardhat

Looks like itā€™s on their TODO list- Iā€™ll have to think about thisā€¦ Thanks

Getting this issue again. Iā€™ve started a new server as well, and itā€™s not working againā€¦

Server URL is: https://mnks13pc9scu.usemoralis.com:2053/server

the problem was fixed meanwhile
only adding the update here too, it was a problem on our side with the local devchain

1 Like