wasm: Route clock reads through a time module - #1122
Open
benthecarman wants to merge 4 commits into
Open
benthecarman wants to merge 4 commits into
benthecarman wants to merge 4 commits into
Conversation
|
I've assigned @tnull as a reviewer! |
Keep node wall and monotonic clock reads behind one provider in the time module. Use native clocks by default and let embedding hosts supply a clock before first use. Require a provider on bare WASM and prevent replacement so monotonic measurements share one origin. Drop chrono's clock feature, as UTC timestamps now come from the provider. Ban direct platform clock reads with clippy and run the check in a dedicated CI job across the native and UniFFI feature sets, so new code stays wasm32-safe while the rest of the port lands. AI assistance: Claude Opus 5.5 and OpenAI Codex. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Supply node time to BDK scans, liquidity, invoice timestamps, gossip snapshots, and UniFFI expiry checks through existing explicit-time APIs. Preserve freshness and expiry validation, and report a pre-epoch clock as an LSPS2 invoice creation error. Disable transaction-sync's optional timing logs, which duplicate the node's own sync duration logs, so it no longer reads the clock itself. Ban the dependency APIs that read the platform clock internally, so call sites keep using the explicit-time variants. AI assistance: Claude Opus 5.5 and OpenAI Codex. Co-Authored-By: Claude Opus 5.5 <[email protected]>
LDK's std feature reads the system clock internally (channel manager, gossip, offers, payment retries, liquidity), which wasm32 can't do. Move it and liquidity's time feature behind a default ldk-std feature, so code can switch to LDK's explicit-time APIs when it is disabled. The chain sources and filesystem storage pull in LDK crates that require std, so they enable ldk-std. Native builds resolve the same LDK features as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
lightning-net-tokio enables LDK's default features, which turns std back on even when ldk-std is disabled. Move it behind a default net-tokio feature so builds without ldk-std are free of LDK's internal clock reads. Without net-tokio, a placeholder socket type stands in for the transport. It has no values, so no connection can be created with it: connecting to peers fails and listening addresses are rejected at build time. This leaves the seam for a wasm32 transport later. Restore the CI check that disabling default features leaves no LDK clock features enabled, and lint a build without net-tokio so the placeholder keeps compiling. Co-Authored-By: Claude Opus 5.5 <[email protected]>
benthecarman
force-pushed
the
wasm-time
branch
from
October 3, 2026 08:19
fa1f806 to
e3dc550
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step toward wasm32 support: stop reading the system clock directly, since
SystemTime::now()panics onwasm32-unknown-unknown.ldk_node::time. All clock reads go through it, and hosts without asystem clock can install a
TimeProvider.internally.
stdfeatures behind a defaultldk-stdfeature, andlightning-net-tokiobehind a defaultnet-tokiofeature. Both are temporaryscaffolding for the port.
std/timefeatures are off when default features are disabled.
Native behavior should be unchanged.