Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

feat: add miner.timestampIncrement option #3131

Merged
merged 12 commits into from
Jun 7, 2022

Conversation

davidmurdoch
Copy link
Member

@davidmurdoch davidmurdoch commented May 25, 2022

By default ganache uses the system clock time for automatically mined blocks. This behavior is convenient, but results in nondeterminism, invalid block timestamps*, and can cause issues with relative block timestamp dependent contracts and tests. There were workarounds for all of these issues (by manually mining via evm_mine({timestamp})) but a built in solution was clearly necessary.

Ganache now permits the use of a new --miner.timestampIncrement option which can be used to set the amount of seconds between consecutive blocks, regardless of how much system time has passed. The default value, "clock", retains the previous default behavior of using the system time for each block.

The following example will start ganache instructing it to increment each new block's timestamp by 1 second from 1649736000000:

$ ganache --time 1649736000000 --miner.timestampIncrement=1

* The Ethereum Yellowpaper defines: $H_S > P(H)_{H_S}$ where $H_S$ is the timestamp of Block $H$ and $P(H)$ is the parent block.

@davidmurdoch davidmurdoch changed the title add new miner.timestampIncrement option feat add miner.timestampIncrement option May 27, 2022
@davidmurdoch davidmurdoch marked this pull request as ready for review May 27, 2022 22:55
@jeffsmale90
Copy link
Contributor

Should we open a PR on https://github.com/mds1/convex-shutdown-simulation to use this new configuration?

@davidmurdoch
Copy link
Member Author

Should we open a PR on https://github.com/mds1/convex-shutdown-simulation to use this new configuration?

We will update it, yes.

@davidmurdoch davidmurdoch force-pushed the feat-timestampIncrement branch 2 times, most recently from af662ab to bf9cfbd Compare May 31, 2022 14:05
@davidmurdoch davidmurdoch changed the title feat add miner.timestampIncrement option feat: add miner.timestampIncrement option May 31, 2022
@davidmurdoch davidmurdoch marked this pull request as draft May 31, 2022 22:42
@davidmurdoch davidmurdoch force-pushed the feat-timestampIncrement branch 5 times, most recently from e31e0d4 to d23d2ff Compare June 2, 2022 17:33
@davidmurdoch davidmurdoch marked this pull request as ready for review June 2, 2022 19:14
src/chains/ethereum/ethereum/src/blockchain.ts Outdated Show resolved Hide resolved
src/chains/ethereum/ethereum/src/api.ts Outdated Show resolved Hide resolved
src/chains/ethereum/ethereum/tests/provider.test.ts Outdated Show resolved Hide resolved
src/chains/ethereum/ethereum/tests/provider.test.ts Outdated Show resolved Hide resolved
src/chains/ethereum/ethereum/tests/provider.test.ts Outdated Show resolved Hide resolved
src/chains/ethereum/ethereum/tests/provider.test.ts Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants