Repository navigation
Millisecond-resolution close times (MS_CLOSE_TIME, vnext) - #5423
Conversation
8165b71 to
7de3592
Compare
0f86bce to
e76c393
Compare
bboston7
left a comment
There was a problem hiding this comment.
I think this is largely correct. The SCP adjacent changes (signature checking, value validation, pending envelopes, etc) all look correct to me.
The only thing that stood out to me is that there's some weird behavior with sub-second ledger close times. There are parts of the code where expected close times get rounded down, and a 0 value is hard to reason about. Examples include:
getUpperBoundCloseTimeOffset. I think this might have weird impacts on determining whether transactions have expired or not, but I'm not sure.LoadGenerator::scheduleLoadGenerationtruncates sub-second close times to 0, which might break some internal accounting or checks. I'm also not sure about this one.- I think the query window calculation in
Peer::processbreaks due to a truncation to 0.
There might be more, but those are the ones I found. I think we should either:
- reject sub-second close times in the config parser. That would still allow targeted unit tests to use sub-second close times, but would prevent us from accidentally configuring supercluster to use them without fixing these issues first.
- Audit the codebase for all places where sub-second close times round down to 0 and verify whether it's OK or needs special handling.
Thanks, I've added unit tests and fixed the cases you've found. I think for this initial PR, I'm most concerned about sub-second correctness of protocol itself. As in, is the CAP spec sufficient or is there some sort of TX application/observable artifact that we need to potentially address for sub-second ledger. I think we've addressed and tested all of those features well. For non-protocol breaking changes, I'm a little less concerned. I image there are a lot of things broken with sub second ledgers beyond second assumptions, so I think we should definitely maintain the ability to test this in SSC. Production has a strict lower bound of 4 second ledgers, so we're safe even from an accidental closeTime change. For SSC, I'd rather we try our best to fix what we can spot then just let it break during the test, rather than hardcode our own minimum bound for testing. |
78788ea to
7650fb9
Compare
2f1b4fb to
9ef9b5c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 68 out of 885 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/herder/HerderSCPDriver.cpp:559
- Use “are” here: “it's possible our peers are sending us…”
src/herder/HerderImpl.cpp:2936 - The stated XDR pin,
96cbfc3, definescloseTimeMsas auint32remainder in[0, 999], but this stores the full epoch time in milliseconds. Current timestamps therefore truncate, andhasValidCloseTimeimmediately rejects the resulting value, so v29 nomination cannot work with the documented pin. Either update the submodule to the later full-uint64schema (03cbf40…) or rework the conversions, signatures, and tests to use a remainder.
Integrate PR stellar#5423 before parallel transaction validation. Carry full Unix milliseconds in consensus values while retaining whole-second application semantics for transaction time bounds, sequence age and upgrade scheduling. Enable the schema and protocol gate in normal builds. Preserve overlay-v2 early proposal preparation with precise timestamps and teach the Rust overlay to extract tx-set hashes from the new StellarValue arms. Port the upgrade replay and subsecond tests to overlay v2 and refresh protocol-28 metadata.
Integrate PR stellar#5423 before parallel transaction validation. Carry full Unix milliseconds in consensus values while retaining whole-second application semantics for transaction time bounds, sequence age and upgrade scheduling. Enable the schema and protocol gate in normal builds. Preserve overlay-v2 early proposal preparation with precise timestamps and teach the Rust overlay to extract tx-set hashes from the new StellarValue arms. Port the upgrade replay and subsecond tests to overlay v2 and refresh protocol-28 metadata.
13e889c to
aac34ce
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Production startup no longer verifies that linked C++ and Rust XDR schemas are compatible.
Review effort: Balanced
Findings: 3
Open (7)
Re-enable startup XDR identity check and resolve feature mismatch · NewcloseTimeMsin the pinned XDR is only the[0, 999]remainder, not milliseconds since epoch.… The pinned stellar-xdr commit definessignedMsValue.closeTimeMsas auint32millisecond… Include tx in the T+1 ledger to avoid duplicate close times Apply tx2 in the T+1 ledger to preserve monotonic close times This derives the future-time bound using the local LCL's protocol. A pre-upgrade node is explicitly… This sentence should say “our peers are sending us”; the repeated “our” is a grammatical typo.
aac34ce to
36fa0b7
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The implementation treats the XDR millisecond-remainder field as a full epoch timestamp, causing truncation and invalid SCP values.
5 open findings
Re-enable startup XDR identity check and resolve feature mismatchcloseTimeMsin the pinned XDR is only the[0, 999]remainder, not milliseconds since epoch.… The pinned stellar-xdr commit definessignedMsValue.closeTimeMsas auint32millisecond… This derives the future-time bound using the local LCL's protocol. A pre-upgrade node is explicitly… This sentence should say “our peers are sending us”; the repeated “our” is a grammatical typo.
2 resolved since last review
🧠 Review effort: Balanced
stellar#5423 moved it to MAX_SUPPORTED_PROTOCOL_VERSION in src/util/ProtocolVersion.h, so the check found no assignment in Config.cpp. Fall back to Config.cpp for older revisions and follow both files when looking for the last bump.
stellar#5423 moved it to MAX_SUPPORTED_PROTOCOL_VERSION in src/util/ProtocolVersion.h, so the script found no assignment in Config.cpp. Fall back to Config.cpp for older revisions and follow both files when looking for the bump commit.
Build 3640 (0e49751aa) includes stellar/stellar-core#5423, so ledgers after the protocol 30 upgrade now use the millisecond close-time StellarValue arms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build 3640 (0e49751aa) includes stellar/stellar-core#5423, so ledgers after the protocol 30 upgrade now use the millisecond close-time StellarValue arms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Shift soroban-env window to P30 with CAP-0084 pins go-stellar-sdk replaced to sisuresh/go @ 50ebbb65; -prev now 28.0.1, -curr git-pinned to rs-soroban-env#1700 head with next; stellar-xdr git-pinned with cap_0084_muxed_contract. * methods: drop EventInfo.InSuccessfulContractCall Removed from protocols/rpc in the pinned go-stellar-sdk (#5995). * Repin CAP-0084 host window to merged upstream heads -prev now tracks core's protocol-29 stand-in (rs-soroban-env cb32250d, no crates.io release exists for it); -curr moves off the rs-soroban-env fork PR to its merged commit 169890d5 (protocol 30 by default, no `next` feature needed). stellar-xdr repinned to a9c9750e to match curr's own pin. go-stellar-sdk fork pin bumped to the PR #6015 head (still unmerged upstream). * ci: add P30 integration leg, copy P28 upgrade fixtures Drops the oldest P27 leg per the one-stanza-per-protocol convention. No -vnext core artifact exists yet for CAP-0084, so the P30 leg's core image is left unset. Upgrade fixtures copied from P28 unchanged since CAP-0084 doesn't touch ConfigSettings. * ci: test protocols 29 and 30 against merged stellar-core 73f2bdd1 The host window is now 29/30, so the P28 leg becomes P29 (with p29 upgrade fixtures copied from p28, as p30's were). Both legs use stellar-core 73f2bdd1's published artifacts. Host blocks declare their versions so check-dependencies.bash can find them. * ci: add apt.stellar.org unstable for unreleased core packages stellar-core 73f2bdd1's packages are only in the unstable component. * Repin go-stellar-sdk to the go-stellar-sdk#6015 head (663a89a1) #6015 is now the single P30 SDK PR: XDR regenerated from stellar-xdr 4f524bba with CAP-0084, CAP-0087 and CAP-0088, plus ingest/ledger NodeID/Signature handling for every signed StellarValue arm. 663a89a1 is 174b61f0 with go-stellar-sdk main (6c5e720f: #6006, #6014, #6017) merged in, so the replace does not drop fixes RPC would otherwise get from main. No compile breaks beyond the EventInfo.InSuccessfulContractCall removal already in this branch: RPC uses storage.ConnectOptions but none of the cache APIs #6017 removed. go mod tidy drops hashicorp/golang-lru, which only the removed on-disk cache needed. The replace stays allow-listed in .golangci.yml until #6015 merges. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Repin the soroban host window to the real P29 host and P30 main - soroban-env-host/simulation-prev: cb32250d (core's p29 stand-in) -> rs-soroban-env v29.0.0 (a721944b), stellar-core's src/rust/soroban/p29 in v29.0.0 and master, pinned by git so it builds with the same dependency tree as core's p29 host. - soroban-env-host/simulation-curr: 169890d5 (CAP-0084 only) -> rs-soroban-env main 8abed902, with CAP-0084 and the CAP-0087 ML-DSA host functions ungated (#1737, #1744, #1745, #1746). This is the p30 host stellar-core #5478 pins; core master's p30 (fddfd567) predates ML-DSA. To be repinned to core's final p30 submodule once core #5455/#5478 merge. - stellar-xdr: a9c9750e -> 28f34cf5, curr's own pin (XDR from stellar-xdr 4f524bba, as in the Go SDK). CAP-0084, CAP-0087 and CAP-0088 are ungated there, so the cap_0084_muxed_contract feature goes away, and xdr2json can now decode CAP-0088 StellarValue arms (MS_CLOSE_TIME was a disabled feature at a9c9750e). The new ml-dsa dependency tree resolves to the versions in core's p30 dep-tree, except hybrid-array 0.4.10 (core: 0.4.15; 0.4.11+ needs typenum 1.20 and the lockfile has 1.18) and ctutils 0.4.3 (core: 0.4.2). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01J5dN6jqdJt52ve9XWyeggH * methods: test serving CAP-0088 millisecond close time ledgers Ingests a protocol 30 ledger whose StellarValue uses STELLAR_VALUE_SIGNED_MS (and, separately, STELLAR_VALUE_EMPTY_TX_SET_MS) through the writers the ingestion service uses (ledger, transactions, events, fee windows, commit) and checks what getLatestLedger, getLedgers (XDR and JSON), getTransaction, getEvents and getFeeStats serve: every close time is the whole-second closeTime (closeTimeMs / 1000), the XDR is byte-identical, and xdr2json keeps the arm and closeTimeMs. RPC never reads StellarValue.ext, lcValueSignature or the node ID, so the only real requirement is that both XDR stacks decode the new arms. The JSON check fails on the previous rs-stellar-xdr pin (a9c9750e, MS_CLOSE_TIME gated off): getLedgers returns "xdr_to_json() failed: couldn't read LedgerCloseMeta: xdr value invalid". Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: run P29 on stellar-core 29.0.0 and P30 on core master's vnext build - P29: stellar-core 29.0.0 (4eb833373), as on protocol-next. Its p29 host is rs-soroban-env v29.0.0 (a721944b), which soroban-env-host-prev now pins, instead of master 73f2bdd1 with the cb32250d stand-in. - P30: vnext build of master 88d2431d7 (merge of v29.0.0 into master), whose p30 host is fddfd567: CAP-0084 plus the v29.0.0 fixes. It differs from soroban-env-host-curr (8abed902) only by the ML-DSA commits. No core build with CAP-0087 (#5455/#5478) or CAP-0088 (#5423) is published yet. Its deb is only in the apt.stellar.org unstable component, which integration-tests.yml already adds. Co-Authored-By: Claude Opus 5.5 <[email protected]> * integrationtest: drop the P28 upgrade fixtures No CI leg runs protocol 28 any more (P29 and P30 only), and the harness picks <name>.p<protocol>.xdr for the protocol under test. Following the docker/README convention of moving the oldest fixtures to the new protocol, this leaves p29 and p30, which are identical to the old p28 ones. Co-Authored-By: Claude Opus 5.5 <[email protected]> * scripts: fix check-dependencies for the P29/P30 window and SDK replaces The dependency sanity check failed on this branch for two reasons that were not real mismatches: - It looked up `stellar-xdr@<protocol>`, assuming the crate's major version tracks the protocol. The protocol 29 and 30 hosts both use stellar-xdr 28.0.0 (crates.io for prev, git 28f34cf5 for curr), so there was no match and the Rust XDR revision came out empty. Each host's stellar-xdr now comes from that host's own dependency tree, and the comparison with core's dep-trees/p<N>-expect.txt uses the host for the same protocol rather than always the newest. - It derived the Go SDK commit from the required go-stellar-sdk version and fetched it from stellar/go-stellar-sdk, ignoring the replace directive. It now reads xdr/xdr_commit_generated.txt from the module the build actually uses (go list -m -f {{.Dir}}), which also handles tags. On this branch the check now passes: Go (#6015) and the curr host's rs-stellar-xdr both use stellar-xdr 4f524bba. It still reports, without failing, that core master's p30 uses rs-stellar-xdr a9c9750e. The updated script also passes against protocol-next's configuration. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add Protocol 30 CHANGELOG entries Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: run the P30 leg on stellar-core master after protocol 30 landed stellar/stellar-core#5478 made protocol 30 the current protocol on master, with CAP-0084 and CAP-0087, and its p30 host is rs-soroban-env 8abed902, the same as soroban-env-host-curr. Move the P30 leg from the pre-#5478 vnext build (88d2431d7) to master's ba6a4e6e3 build. In the same change, give testnet.p30 and unlimited.p30 the 95 contract cost params core now requires at protocol 30. The 9 new ML-DSA entries (86-94) are core's v30 defaults from updateCpuCostParamsEntryForV30 / updateMemCostParamsEntryForV30; every other entry is unchanged. The .xdr files are re-encoded from the .json with stellar-xdr encode --type ConfigUpgradeSet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01J5dN6jqdJt52ve9XWyeggH * Require the merged go-stellar-sdk Protocol 30 commit stellar/go-stellar-sdk#6015 merged into protocol-next as 990270d3, so drop the replace that pointed at the sisuresh/go fork (663a89a1) and require the upstream commit. This also picks up the fixes made in #6015 after 663a89a1. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Run the P30 leg on core 3640, which includes CAP-0088 Build 3640 (0e49751aa) includes stellar/stellar-core#5423, so ledgers after the protocol 30 upgrade now use the millisecond close-time StellarValue arms. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Run the P30 leg on the stellar-core 30.0.0 release candidate 30.0.0-3642.0e49751aa is built from the same commit as build 3640, so this changes the package under test, not the code. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Correct how core's p30 host differs from -curr Core's p30 host also takes stellar-xdr 30.0.0 from crates.io, not only soroban-wasmi. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Trim comments and the CHANGELOG, drop the CAP-0088 unit test The P30 integration leg runs on the stellar-core 30.0.0 release candidate, so its ledgers use the CAP-0088 arms, and the integration tests already fetch them with getLedgers and getTransaction in JSON. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: tamirms <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
#40) ## What - Bump `stellar-xdr` to 30.0.0 so headers and SCP messages carrying the protocol-30 `StellarValue` arms (`STELLAR_VALUE_SIGNED_MS`, `STELLAR_VALUE_EMPTY_TX_SET_MS`) decode. `EMPTY_TX_SET_MS` is treated as a CAP-0083 empty-tx-set ledger. - Add CAP-0088 close-time checks to `--verify`, mirroring the header checks stellar-core runs on catchup (stellar/stellar-core#5423, `ApplyCheckpointWork::getNextLedgerCloseData`): - an ms arm's `closeTime` must equal `closeTimeMs / 1000` - a ledger uses the ms format iff its predecessor closed on protocol >= 30, checked across adjacent ledgers and checkpoint boundaries - close times strictly increase at millisecond resolution on every protocol, checked across adjacent ledgers and checkpoint boundaries - Update `rustls` to 0.23.46 (RUSTSEC-2026-0346 through -0349). - README documents the new checks. ## Why Protocol 30 ships CAP-0088. Without the XDR bump the archivist cannot decode any post-upgrade ledger header. Without the format rules, a header that stellar-core would refuse to replay passes verification. Mirroring core's catchup rules keeps `--verify` aligned with what core can actually consume. ## Testing - New unit tests cover both ms arms, the 29 -> 30 upgrade boundary (whole-second upgrade ledger followed by ms ledgers), `closeTime`/`closeTimeMs` disagreement, wrong format in both directions, ms empty-tx-set ledgers, and non-advancing close times within and across checkpoints. - Real-data slices in `testdata/` (pubnet, testnet v1/v2, futurenet) still verify clean, including under the new strictly-increasing rule. - No public network is on protocol 30 yet, so the ms paths are exercised with synthetic protocol-30 headers only. Follow-up: add a real protocol-30 fixture once testnet or futurenet upgrades.
Brings overlay-v2-shared up to date with master. The previous master merge (b90d48e, stellar#5428) was recorded with master's tip 100cc38 missing from its parents, so this merge used 100cc38 as its base (temporary graft of b90d48e, removed afterwards). Notable master changes brought in: - Protocol 30: CURRENT_LEDGER_PROTOCOL_VERSION follows MAX_SUPPORTED_PROTOCOL_VERSION; CAP-0084 and CAP-0087 ungated, p29 and p30 Soroban hosts (stellar#5472, stellar#5478, stellar#5484, stellar#5483). - Millisecond-resolution close times at protocol 30 (stellar#5423): ConsensusTime/ApplyTime types, STELLAR_VALUE_SIGNED_MS and STELLAR_VALUE_EMPTY_TX_SET_MS. - Tx set validity hardening (stellar#5481), lower max message size in protocol 29 (stellar#733), sub-second ledger edge-case fixes. - Simplified ledger view hierarchy (stellar#5461); the overlay-only-mode sequence number skip now lives in TransactionFrame::checkValid. - Banned accounts deprecated (CAP-0077 is active). - Apply-path performance work (stellar#5402, stellar#5411, stellar#5414, stellar#5415, stellar#5418, stellar#5421, stellar#5436, stellar#5286), apply-load tx set construction mode (stellar#5448), --check-lcm (stellar#5435), v29.0.0 release merge. Conflict resolution: - Files overlay-v2-shared deleted and master modified (the C++ overlay, TransactionQueue, TransactionQueueTests, UpgradesTests, private/Horizon/RPC workflows): kept deleted. Master's changes to them are C++ overlay peer/flow-control logic, tx queue admission and tests for those. - Herder: kept the Rust-overlay submission path (recvTransaction returns TxSubmitStatus) and dropped the deprecated `force` parameter as master did. triggerNextLedger keeps the prepared/built tx set path from the Rust mempool, now with ConsensusTime close times and master's apply-time close-time offset. The early tx set preparation path (prepareTxSet, buildTxSet, setupTriggerNextLedger) takes ConsensusTime. Kept master's mNominatedTxSetOverride test hook (applied before the tx set is cached in the Rust overlay) and the herder.txset.build timer (now timing buildTxSet). Dropped the banned-accounts setup and tx queue maintenance. - AppConnector: dropped both ov2's maybeUpdateImmutableLedgerView and master's C++-overlay getOverlayThreadSnapshot. - LoadGenerator: master's CachedTestAccountPtr with ov2's TxSubmitStatus. - Tests: kept ov2's removal of tests that need the C++ overlay, standalone mode or the tx queue (standalone, manualclose, flooding, tx queue limits, far-future slot cleanup, herderExternalizesValuesWithProtocol, MAX_SAC_TPS, custom token, soroswap and noisy binary search apply-load tests). Added master's ms close time HerderTests and the non-canonical empty tx set test on ov2's Rust-overlay topologies. The tx set size test checks against overlay-v2's own tx set allowance. The sub-second getUpperBoundCloseTimeOffset test checks the offset directly, since there is no C++ tx queue admission. Tests that used CheckValidLedgerViewWrapper now use getLCLView(). - Cargo.lock: master's lockfile plus the overlay crate's packages, regenerated by cargo; semver-compatible duplicates take the newer version. - Build: Makefile.am keeps the Rust overlay rules and adds tracy import-chrome; ci-build.sh keeps ASAN off and takes master's -g1. - Needed to compile: PendingEnvelopes.cpp includes LedgerManager.h (master got it through the C++ OverlayManager.h); ov2's early-nomination and checkpoint-slot tests use ConsensusTime/ApplyTimeOffset; OverlayIPC tests take ledger views from the LedgerManager.
Master's stellar#5423 made ARTIFICIALLY_SET_CLOSE_TIME_FOR_TESTING a millisecond value. Two overlay v2-only tests still set it in seconds, which would now mean 2ms and 5ms ledgers: "SCP checkpoint" (2 -> 2000) and "SCP message capture from previous ledger" (5 -> 5000). Master tests the upgrade to millisecond close times in UpgradesTests, which overlay-v2-shared does not build (it needs the C++ overlay). Add overlay v2 versions of the two tests to HerderTests: - "millisecond close time upgrade boundary": a 4-node Rust-overlay network starts at protocol 29, upgrades to protocol 30 and must keep closing ledgers, switching to ms values exactly at the boundary. A fourth node is stopped before the upgrade and restarted from its database afterwards; it must resync across the boundary from relayed SCP state without catchup. The simulation runs in real time, so the upgrade is scheduled relative to now, and the node is removed and re-added since overlay v2 can't partition a single connection. - "upgrade scheduling under sub-second ledgers": upgrade scheduling reads only the whole-second close time. Also start "prepare nomination before trigger" 375ms into a second, so the early-prepared close time carries milliseconds at protocol 30.
## Update (2026-11-09) This PR is rebased onto the reworked #5453, which merges current `master` (362dbc5) into `overlay-v2-shared`. That merge brings in the final #5423 (millisecond close times, gated at protocol 30, with the protocol-30 bump). It also carries the overlay-v2 adaptations those need, including the Rust overlay moving to `stellar-xdr` 30.0.0 to decode millisecond `StellarValue`s. **The old first commit ("Enable millisecond consensus close times at protocol 28") is dropped.** The master merge in #5453 supersedes it. It was an earlier draft of #5423 behind a compile-time `MS_CLOSE_TIME` flag at protocol 28, with its own XDR pin and fixtures. The overlay-v2-specific parts needed for correctness are now in #5453. This PR is now the trigger-timing work on top of millisecond close times: 1. **Account for actual elapsed nomination time in the trigger drift allowance** (ported unchanged in substance). The next-ledger trigger is anchored on the previous externalized close time C and fires at `C + target`. It falls back to the local prepare-start anchor when the time elapsed since C exceeds the target plus an allowance for nomination. That allowance used to be the sum of nomination timeouts that had fired. Now it is the steady-clock time from the local trigger to entry into ballot. A slow round that never runs a timeout callback no longer counts as clock drift: slow tx-set fetch or validation, a busy main thread, or ballot starting before the expired timer runs. When the network is behind, the next trigger fires immediately instead of waiting out the nomination again. The extra wait a fallback can add is bounded by our clock drift plus how late we triggered relative to the winning close time. 2. **Record the nomination trigger only when nomination proceeds** (new). If a node skips nomination because its clock is behind the last close time, it no longer credits the wait for its peers to the allowance. 3. **Test the trigger anchor with sub-second close times** (new). With close times 0, 250 and 999 ms into the second, the next trigger is due exactly the target after the close time, and the fallback boundary holds to the millisecond. 4. **Add trigger timing metrics** (new). Together they show whether a 2 s ledger is bound by apply, by nomination or by event-loop delay: - `scp.timing.trigger-to-ballot` (timer): proposal construction plus nomination, which is the drift allowance. - `scp.trigger.lateness` (timer): how late the trigger callback ran after its scheduled time. - `scp.trigger.immediate` (meter): the next trigger was already due when it was scheduled. 5. **Skip a delayed nomination emit that was already sent** (new, test-only code path). With `ARTIFICIALLY_DELAY_NOMINATION_EMIT_FOR_TESTING`, a deferred nomination emit could fire after `processEnvelope` had already emitted the same statement. SCP then rejected the duplicate and threw "moved to a bad state (nomination)", which made the hidden "consensus close time trigger timer" test flaky under parallel load. The deferred emit now only sends a statement newer than our last one. A new SCP test replays the race deterministically. None of these commits change values, validation or ledger output. They only change local trigger scheduling, metrics, logs and BUILD_TESTS-only code. **Follow-up under consideration:** for proposals rebuilt at the trigger, propose the scheduled trigger time as the close time (bounded by `now` and LCL+1 ms), so a leader's trigger lateness no longer shifts the network's cadence. We'll do it if `scp.trigger.lateness` p75 exceeds about 20 ms on perfnet. Testing, at `285aa42fc92d` on top of #5453 `04fbddb7d`: - New and changed tests: `[trigger-construction]` 8/8 (the drift-allowance tests and the 3 new ones) and `[early-nomination]` 6/6 pass. - `[herder]` (partitioned `make check`): 77/77 test cases pass, including the hidden real-clock trigger-timer simulations. - At `4f577bd25`: the new SCP test passes. A copy of the test without the fix fails with the original exception, so the test reproduces the race. "consensus close time trigger timer" passes 3/3 on its own and 2/2 inside a partitioned `[herder],[scp]` `make check` (97/97 test cases, full check passes both times). - Final branch: restacked onto the final #5453 head `14de3972a` (two test-only commits on top of `04fbddb7d`); the five patches are identical (`git range-diff`). The full suite passes on the #5458 head that contains this PR (selftest 590 test cases, check-sorobans, check-rust, check-nondet). --- ## Original description > The numbers below come from an earlier simulation environment and are kept for history. The stack is now measured on perfnet (30 validators in 4 AWS regions, 3,000 SAC TPS offered, 2 s target, 150 ms simulated apply, 900 s load); the runs of the final #5458 and #5459 heads contain this PR and are reported on those PRs. # Description Merges in #5423. This change adds ms closeTime. By itself, it doesn't improve TPS or latency significantly. However, it reduces our long tail fo very slow blocks, and also allows us to target intrasecond or subsecond block times, which are not currently possible at whole second resolution. In addition to taking the change from the PR, the 2nd commit makes some minor adjustments to when we call the fallback timer. This was intentionally conservative for main net launch assuming lots of drifting clocks, but no reason we can't tighten it here. Results, measured with 10 tier 1 topology (no watchers) with 2 second block time target: ## 2000 TPS | Metric | Original overlay-v2-shared |Changes | |---|---:|---:| | Median block interval | 2.090 s | 1.993 s | | p99 block interval | 4.563 s | 4.298 s | | Maximum block interval | 6.219 s | 5.090 s | | Harness verdict | **FAIL** | **FAIL** | Rebased on #5453 so opening as a draft for now. # Checklist - [x] Reviewed the [contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#opening-a-pull-request) document - [x] Rebased on top of master (no merge commits) - [x] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio extension) - [x] Compiles - [x] Ran all tests - [ ] If change impacts performance, include supporting evidence per the [performance document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)



Description
Adds a MS component to CloseTime.
Currently, block close times must be in whole second increments, making non-whole second and subsecond block times impossible. For example, we cannot achieve a block time of 2.5 seconds, as the block time which we use for our basis of the next ledger trigger timer is rounded.
This is intended to unblock our latency experiments, but should be robust enough for a protocol release if we so choose. To keep things simple, I've left the current closeTime field that same (it still holds the whole second component of closeTime) and added an additional field for the ms component of close time. This means downstream consumers of closeTime won't be broken with the upgrade, and don't necessarily even need to ingest the ms times if they don't need it.
Additionally, for everything user-facing with a time component, I've left the interface the same and always round down the block time to the nearest whole second. Specifically,
minSeqAge, transaction time bounds, claimable balance predicates, upgrade scheduling, and soroban ledger timestamps all round down to the nearest whole number. At the protocol level, this doesn't break anything, and I've added unit tests for subsecond ledgers, where back to back ledgers round to the same whole second value. While I'm sure we have performance issues, the protocol itself supports subsecond ledgers.On the application side, I'm 99% sure we don't break anything. It's possible that an implementation of
minSeqAgeor transaction bounds could use currTime + 1 as a proxy for the next ledger, but this does not seem like a correct use case. I think from a protocol perspective, it's fine to release this as is, then add MS resolution to the transaction interface if anyone actually cares.There is one complexity around SCP values during the upgrade, which is also present in the
STELLAR_VALUE_EMPTY_TX_SETchange. Basically, whenever StellarValueType changes via a protocol upgrade, it's challenging to properly check if an SCP message is valid. You can't just look at the LCL's protocol version, as it's possible the node is slow and it's peers have already completed the upgrade and are sending valid future slot messages. The same is true in the inverse, if you're past the protocol upgrade, you still might receive/relay messages from older nodes that are actually valid for pre-upgrade slots. "millisecond close time upgrade boundary" tests this case, where a node loses sync on the upgrade boundary and needs to replay the upgrade via SCP messages.Note that there is a potential "bug" (maybe) in the current protocol 28 upgrade path. An out of sync node will drop any future slot values with
STELLAR_VALUE_EMPTY_TX_SETas invalid, preventing it from properly replaying SCP messages. This is very minor. In the P28 upgrade, we won't actually start sendingSTELLAR_VALUE_EMPTY_TX_SETmessage types. Even if we did, it only affects out of sync nodes, which would just lose sync and catchup via regular history replay without issue. This change it's a little worse, since we're guarenteed to start using the new message type immediately on the upgrade boundary, but it is still quite minor.The XDR changes (stellar/stellar-xdr#316) have merged; the submodule is pinned to the canonical commit (96cbfc3).
Checklist
clang-formatv8.0.0 (viamake formator the Visual Studio extension)