Hey guys, do any one know how to keep the forked mainnet in sync with the actual mainnet using hardhat or some other means
Nov 7, 2023, 6:50 PM
You'll need to keep forking to update it to the current state...
Nov 7, 2023, 6:53 PM
Can you explain a bit more , thanks in advance
Or resources will be great
...
Nov 7, 2023, 6:53 PM
The forked instance only has data at the last block when the fork was done, so in order to have the fork in sync you'll need to run the fork command again before you execute the code you want to test...
Nov 7, 2023, 6:55 PM
But cant we write any script to the keep the node in sync
Lets say new block is added to the mainnet so it automatically reflects in the local node
Nov 7, 2023, 6:57 PM
No, the command is done from a different shell while the code you are testing is done from a different shell...
Nov 7, 2023, 6:58 PM
Lets say i have some staking contract if i deposit in 1st block i want to check after some time how can i do that using the fork?
I have to deposit and chekc the earned rewards using the fork only
Is it possible @Daphantom
Do you have any idea about it
Nov 7, 2023, 7:02 PM
Every interaction you have with the forked instance mines a new block...
Yes...
Nov 7, 2023, 7:04 PM
Both hardhat node and anvil have methods to increase block number
You don't need a fresh fork for that
Nov 7, 2023, 7:59 PM
But will this in sync with the orginal mainnet ?
Okk ,does it also reflects the mainnet transaction in the forked local net
Nov 8, 2023, 2:10 AM
no
take a look at https://book.getfoundry.sh/reference/anvil/
but getting updates into a fork from a network is something i've not seen around.
Also why would you need it? you can simulate actions or use snapshots
but getting updates into a fork from a network is something i've not seen around.
Also why would you need it? you can simulate actions or use snapshots
Nov 8, 2023, 2:18 AM
Thats a good question but imagine stimulation the various scenarios change the price locally using oracles and check the status of the various function on the defi protocols or lending and borrowing protocols and warning the platform earlier
Nov 8, 2023, 2:26 AM
you reset the fork each block and run what you need to run on it again =)
there's also anvil_dumpState & loadState, maybe those can speed up the process
Nov 8, 2023, 2:27 AM
Yehh will try and get back
As far as you remember is they any other process that we can achieve the above
Nov 8, 2023, 2:29 AM
no, when i need fresh states i reset the fork and run the scripts again.
On tests i don't pin the block in the fork
On tests i don't pin the block in the fork
uh, just tried dump&load
seems a faster way then re-launching the scripts.
Dunno about conficts or anything
seems a faster way then re-launching the scripts.
Dunno about conficts or anything
Nov 8, 2023, 2:37 AM