fix(simulate): Use core ledger close time#742
Open
jia57b wants to merge 1 commit into
Open
Conversation
(cherry picked from commit c05d154b82713fd098f58962c391d33c4ca21553)
There was a problem hiding this comment.
Pull request overview
This PR updates simulation preflight to use the latest ingested ledger close time instead of the host wall clock, aligning simulated execution with the ledger context known to RPC.
Changes:
- Adds ledger close time to preflight parameter plumbing.
- Extracts bucket list size, protocol version, and close time from latest ledger metadata.
- Adds unit tests covering ledger-time propagation and metadata error paths.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
cmd/stellar-rpc/internal/preflight/preflight.go |
Uses provided ledger time when constructing C ledger info. |
cmd/stellar-rpc/internal/preflight/preflight_test.go |
Adds coverage for ledger info timestamp behavior. |
cmd/stellar-rpc/internal/preflight/pool.go |
Threads ledger time through worker pool parameters. |
cmd/stellar-rpc/internal/methods/simulate_transaction.go |
Reads latest ledger metadata and passes close time to preflight. |
cmd/stellar-rpc/internal/methods/simulate_transaction_test.go |
Adds handler tests for ledger-time propagation and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Shaptic
approved these changes
May 27, 2026
Shaptic
left a comment
Contributor
There was a problem hiding this comment.
This is great, thank you! Would you mind just adding a line under a new ### Fixed header in the Unreleased section of the changelog as a quick release note?
Member
|
In addition to the ask about by @Shaptic the lints appear to be failing and would need resolving before merging. |
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.
Summary
Use the latest ingested core ledger close time for preflight simulation instead of the local wall-clock time.
This change aligns simulateTransaction with the actual ledger timestamp observed by stellar-core, which is especially important for tests and workflows that manipulate ledger time
(for example via forceclosetime). Previously, simulation used time.Now(), which could drift from the real chain time and produce inconsistent results between simulation and on-chain execution.
What changed
Why
simulateTransaction should execute against the same time context as the latest ledger known to RPC, not the machine's current time. Using wall-clock time can make simulation:
With this change, simulation uses the same ledger-close-time source that RPC ingests from core, making simulation results deterministic and consistent with chain state.
Testing