Local Single-Node Time Control for Quickstart #1897
shaoningwang-57block
started this conversation in
General Discussion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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