Skip to content

Add support for time shifting inside the container#921

Draft
leighmcculloch wants to merge 6 commits intomainfrom
allow-fake-time
Draft

Add support for time shifting inside the container#921
leighmcculloch wants to merge 6 commits intomainfrom
allow-fake-time

Conversation

@leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Mar 25, 2026

What

Install faketime in the container image and configure libfaketime via ld.so.preload so all processes see the modified time. Expose time control through /etc/faketimerc, defaulting to +0 (no modification). Pass FAKETIME_NO_CACHE through to supervisord so changes take effect immediately. Document time manipulation via volume-mounted config, offset syntax, progressive jumps, and speed multipliers.

Why

Testing time-sensitive Stellar network behavior (e.g. ledger close times, expiry) requires advancing the clock without affecting the host or restarting the container. libfaketime intercepts time calls at the libc level, making it transparent to all services.

This probably doesn't allow for testing all time movement situations, but it's a simple way to provide some ability to do that with quickstart. Generally the soroban-sdk test framework is still the best place to codify tests that involve time changing.

Close stellar/stellar-protocol#1897

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Mar 25, 2026
@leighmcculloch leighmcculloch marked this pull request as ready for review March 25, 2026 01:30
Copilot AI review requested due to automatic review settings March 25, 2026 01:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds container-wide time shifting support for Stellar Quickstart by integrating libfaketime and documenting how to control the fake time via /etc/faketimerc.

Changes:

  • Install faketime-related packages in the image and preload libfaketime for all processes.
  • Add a default /etc/faketimerc and pass FAKETIME_NO_CACHE through to supervisord-launched services.
  • Document how to modify time in a running container via a bind-mounted faketimerc file.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
start Passes FAKETIME_NO_CACHE into the clean supervisord environment.
dependencies Adds a faketime package to the apt install list.
Dockerfile Attempts to symlink and preload libfaketime.so.1, sets FAKETIME_NO_CACHE=1, and copies /etc/faketimerc.
faketimerc Introduces the default faketime configuration file content.
README.md Documents time modification usage and examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

start Outdated
# variable name for things that the start script does, like NETWORK.
exec env -i supervisord -n -c $SUPHOME/etc/supervisord.conf \
exec env -i \
FAKETIME_NO_CACHE="$FAKETIME_NO_CACHE" \
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

FAKETIME_NO_CACHE only enables libfaketime’s no-cache mode when set to 1; if it’s unset (or set to an empty string), config changes may not take effect immediately. Since env -i rebuilds the environment, consider defaulting it here (e.g., use a ${FAKETIME_NO_CACHE:-1}-style default) so the documented “take effect immediately” behavior holds even if the variable wasn’t set upstream.

Suggested change
FAKETIME_NO_CACHE="$FAKETIME_NO_CACHE" \
FAKETIME_NO_CACHE="${FAKETIME_NO_CACHE:-1}" \

Copilot uses AI. Check for mistakes.
dependencies Outdated
sudo supervisor psmisc \
nginx rsync jq golang-github-pelletier-go-toml netcat-openbsd \
libunwind8 sqlite3 libc++abi1-20 libc++1-20'
libunwind8 sqlite3 libc++abi1-20 libc++1-20 faketime'
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

apt-get install adds faketime, but on Ubuntu 24.04 the faketime package only provides the /usr/bin/faketime wrapper; the preload library (libfaketime.so.1) comes from the libfaketime package. As written, the later Dockerfile steps that reference /usr/lib/*/faketime/libfaketime.so.1 will fail or produce a broken /etc/ld.so.preload entry. Install libfaketime (and only keep faketime if you also need the wrapper).

Suggested change
libunwind8 sqlite3 libc++abi1-20 libc++1-20 faketime'
libunwind8 sqlite3 libc++abi1-20 libc++1-20 faketime libfaketime'

Copilot uses AI. Check for mistakes.
@leighmcculloch leighmcculloch marked this pull request as draft March 25, 2026 01:54
@leighmcculloch
Copy link
Member Author

leighmcculloch commented Mar 25, 2026

Todo:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants