-
Notifications
You must be signed in to change notification settings - Fork 45
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
Simulate on user provided timestamp #27
Simulate on user provided timestamp #27
Conversation
Is it possible to supply a block number that is in the future (ie latest + 1)? It seems to be possible for bundle simulation (temper seem to keep incrementing block number if the second tx in the bundle is on a different block), but I'm not sure if it works for single order simulation. |
A strategy to deal with that could be to fetch the state of the user provided block and if it can't be found simply use the state of the latest block and only overwrite the block number. My impression is that patching in exactly what CoW Protocol needs would be easy but making that work consistently for any use case is not straight forward. |
Thanks for your contribution @MartinquaXD, looks great! Regarding your specific use case, I do like the idea of doing so automatically if the user provides a block number which is in the future. In the case you mentioned where state is missing, we could avoid this by checking the latest block number on the node and only setting the EVM to a "future" block Let me know your thoughts. Will merge this anyway as it's also a great addition. |
Sounds good to me. We already brainstormed ideas how to override the block number in case we couldn't implement it directly in |
Hey guys, |
# Description When we simulate a transaction in the driver we only care whether it would work on the `pending` block and not on the `latest` block. Of course we can't magically predict the entire state of the blockchain on the next block but at least we could catch problems that arise of the next block number, timestamp and basefee. This is pretty easy to do with `tenderly` and `web3` but unfortunately the `enso` simulator does not really support simulating on the `pending` block. To get closer to the desired behavior I opened a [PR](EnsoFinance/temper#27) (not yet merged) on the enso simulator which allows users to provide the timestamp they want to simulate on and changed our code to produce the needed timestamp in the `enso` simulator. # Changes - added `block_timestamp` to the `enso` dto - added `current_block_stream` and `network_block_interval` to `enso` simulator to get the needed timestamp - added plumbing to configure `network_block_interval` in a config file - extended `FetchBlock.sol` to also return the blocks timestamp ## How to test Did a manual test locally. Created a test order and checked that the enso simulator can handle the timestamp. Unfortunately the `enso` team did not build a new docker image so I also tested that our code doesn't break with the old `temper` version so we should be able to merge this PR without any issues. Will contact the team to request a new build from them. Fixes #2174
CI builds on whenever a PR is merged into main, so you could pin our release to this sha hash and should be able to get the latest code: https://github.com/EnsoFinance/temper/actions/runs/7281198410/job/19841226414 |
Looks like we don't even have to pin it. This repo publishes 2 packages ( |
At CoW Protocol there are circumstances where we actually want to know whether a given transaction would simulate on the
pending
block rather than thelatest
block (temper
's default). (see cowprotocol/services#2174 to get more context)Ideally
temper
would provide an option to also provide bock settings likelatest
andpending
that takes care of that but that seems like a way bigger change.One way to get closer to simulating on the
pending
block would be to allow users to overwrite the used block timestamp. That way we could at least catch reverts that depend on the timestamp.Unfortunately this is still not enough to catch reverts caused by code depending on the actual block number or base fee which would be caught by an actual simulation on
pending
, though.Changes
blockTimestamp
to the API request