Local Single-Node Time Control for Quickstart #1897
Replies: 3 comments 1 reply
-
|
👋 Thanks for the proposal! @shaoningwang-57block do you have a use case you could add to the proposal? This might help give context to folks reading. For contract testing alone, this can be done via the Just giving this a brief glance, it seems like a time based offset model might be a bit simpler. E.g. just tracking the cc @Shaptic for RPC feasibility |
Beta Was this translation helpful? Give feedback.
-
|
I think we might be able to satisfy the need to shift time in quickstart by modifying the actual system time. In general it's problematic if one service sees a change while another doesn't, as evidenced by the ask to also support that changing time in RPC. It's possible that Horizon, Galexie, Lab, and other services may see odd behaviour if we also don't change their time. I've thrown together a quick test to see how well changing the system time works, and from what I can see it works pretty well. The change is here: You can try it out with: View the latest close time with: Wait for the system to start up completely first, and for ☝🏻 to return a non-zero value, then run: View the latest close time and it should be 72 hours in the future with: Please try it out and provide feedback. If it's good we can look at polishing it. |
Beta Was this translation helpful? Give feedback.
-
|
Besides the system time proposal above, I wonder if it would make sense to make 24h threshold configurable instead of fudging time in the whole stack. Like just pass it as a parameter to constructor and set it to 5 minutes instead of 24 hours. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Simple Summary
This proposal adds a local-only, explicit way to move the next ledger close time forward in quickstart-like single-node environments, and aligns RPC simulation time with ledger time so time-based tests behave predictably after that jump.
Motivation
The easiest way to understand the need is with a simple example.
Suppose a contract only allows an action once every 24 hours. In a local developer environment, a test may want to perform the first action, jump forward by one day, and then perform the second action immediately.
Today that workflow is awkward for two reasons:
closeTimein a bounded way;simulateTransactioncan still use wall-clock time, so after a forced jump the simulation timestamp can drift away from the actual chain state.That mismatch makes local testing harder to reason about. A developer can move ledger time forward, but preflight and execution may still appear to live in different time contexts.
Design Principles
MAX_TIME_SLIP_SECONDSjust to support this workflow.Proposal
1)
stellar-core:/forceclosetimeadmin endpointEndpoint
GET /forceclosetime?t=<unix_timestamp>Expected behavior
tis present and numeric;t > lastClosedLedger.closeTime;tas a one-shot closeTime override for the next ledger nomination;Security gate
Reject this endpoint when
PUBLIC_HTTP_PORT=true.2) Configuration
ENABLE_FORCECLOSETIME_CHEATCODEfalsetrue/forceclosetimeadmin endpoint.FORCECLOSETIME_MAX_FUTURE_SECONDS607776000Notes
MAX_TIME_SLIP_SECONDS.3)
stellar-rpc: alignsimulateTransactionpreflight time with ledger time in localnet modeFor the
simulateTransactionpreflight path:LedgerTimeto the preflight getter parameters;LedgerTime;LedgerTimeis present, prefer it in preflight ledger info; otherwise fall back totime.Now().Unix().Result
After a forced time jump, the simulation context is aligned with the ledger
closeTimeinstead of drifting back to wall-clock time.4) Flow Overview
Flow A: force next ledger close time
Flow B: localnet simulate time alignment
Why This Proposal Stays Local and Scoped
The main design goal is to solve a developer workflow problem without changing normal network behavior. Because of that, the proposal keeps the feature narrow in four ways:
closeTimeoverride, rather than a persistent configurable offset model;Non-goals
This proposal does not try to redefine global consensus time acceptance.
This proposal does not require changing the normal meaning of
MAX_TIME_SLIP_SECONDS.This proposal does not attempt to introduce a permanent clock offset for every future ledger.
Compatibility and Default Behavior
Suggested Test Plan
stellar-core/forceclosetimewhenPUBLIC_HTTP_PORT=true;t;t <= lastCloseTime;twhen the cheatcode is disabled or the bound is exceeded;twhen the cheatcode is enabled and within the configured bound.stellar-rpcgetLedgerInfoprefersLedgerTimewhen provided.Open Questions
ENABLE_FORCECLOSETIME_CHEATCODE=trueandPUBLIC_HTTP_PORT=false?Beta Was this translation helpful? Give feedback.
All reactions