Skip to content

Conversation

@shotes
Copy link
Contributor

@shotes shotes commented Mar 29, 2025

This PR allows the e2e tests (and anything running the devnet chain spec) to have deterministic fork times. The timestamps for each block will ignore comet timestamps and always increase by exactly TargetSecondsPerEth1Block.

This is not the cleanest solution because we have to add special cases to the production code to support testing. However, I found that it is the most deterministic and simplest solution.

I have explored other alternatives that will not work or are far too complex:

  • Using a clock interface that can be mocked for tests. This doesn't work because the time.Now() call happens in the cometBFT library.
  • Configuring chain spec file (using feat(cli): Chain Spec as a Config File #2638) at test startup to set fork time as offset of test startup time. This isn't sufficient as there is a non-deterministic amount of time between each step during devnet tests - kurtosis startup, beacond binary startup, and when the chain starts producing blocks. This results in a completely non-deterministic time in which a fork would happen during the test, and can result in the fork happening before the chain begins producing blocks.
  • Modifying the result from time.Now() by using LD_PRELOAD to load libfaketime, which will allow us to arbitrarily control the outcome of time.Now() for the binary. This has the same non-deterministic fork time problem, as well as being extra complex because our containers for beacond are running alpine instead of any form of debian, making it harder to install required packages.
  • Modifying the container time at test startup. This is more complex as the containers need to agree on time with other containers. This also has the same non-deterministic fork time problem.

@shotes shotes requested a review from a team as a code owner April 1, 2025 00:57
@shotes shotes changed the title fix(e2e): Timestamp based forking dynamic e2e fix(e2e): Timestamp based forking deterministic e2e Apr 1, 2025
shotes added 2 commits April 1, 2025 13:30
…chain/beacon-kit into timestamp-based-forking-dynamic-e2e
@rezbera rezbera changed the title fix(e2e): Timestamp based forking deterministic e2e fix(e2e): Timestamp based forking deterministic e2e (1/n) Apr 1, 2025
@rezbera rezbera changed the title fix(e2e): Timestamp based forking deterministic e2e (1/n) fix(e2e): Timestamp based forking deterministic e2e (2/n) Apr 1, 2025
s.depositFetcher(ctx, blockNum)

// Store the finalized block in the KVStore.
//
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete some empty lines to appease funlen

@shotes shotes marked this pull request as draft April 2, 2025 21:52
@shotes
Copy link
Contributor Author

shotes commented Apr 2, 2025

Converting to draft for now in favor of the more simple immediate unlock for testing e2e with pectra: #2644.

We may revisit this later.

Base automatically changed from timestamp-based-forking to main April 3, 2025 11:40
@rezbera rezbera changed the title fix(e2e): Timestamp based forking deterministic e2e (2/n) fix(e2e): Timestamp based forking deterministic e2e Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants