Repository navigation
Decide a segbuild gap by the collection watermark, and make the builder audible - #403
Merged
Merged
Conversation
Three things, all found by asking whether this node could actually turn the feature on. The startup gate asked the wrong question. It refused when the executed head was more than `--segbuild-lag` past the end of the set -- distance from the head, which is the mistake §7.3 corrects inside the builder. Distance says a range lost its protection; it does not say anything was taken. A node stopped for a week has a gap of thousands of blocks whose nodes are all present, because nothing swept while it was down. This node is exactly that case: the set ends at #9,420,000, it has executed to #9,430,703, and the collection watermark is #9,342,320 -- 77,681 blocks below the gap, so every node those blocks wrote is still in an unswept epoch. The gate now asks the store what it collected instead of inferring it from distance, and refuses only when the watermark is above the gap's first block. A buildable gap still needs closing promptly, so `cut_at` records a boundary at the executed head during startup and the catch-up becomes a range of its own. Left to the size-driven cut it would have waited a gigabyte of writes -- about a month of chain -- while its collection bound went stale after four days, and the state would have been collected out from under it. `segbuild_status` answers the question in one command. It took eight to answer by hand, because nothing printed the executed head's *number*: `height_peek` prints its hash, so it had to be bisected out of `block_info`. The question is two comparisons against values already on disk, and the tool prints all three numbers, what is pending, and whether a gap is buildable. A halt was silent, and a long build was too. `segbuild_boundaries` had no logging at all: `halt()` wrote the HALTED file and `tick()` returned `Tick::Halted(reason)`, which the caller discarded. So a reorg deeper than the lag -- the most serious event this design has a rule for -- produced no log line, at the time or ever after. It now logs at `error` the moment it happens, reminds at `warn` once an hour for as long as it lasts, naming the file to remove, and says nothing on the other ticks. A build also had nothing between "Building" and "Built", a quarter of an hour of silence for a full segment, so there is now a progress line every 10,000 blocks carrying the rate and the sealed bytes; and the seed a range starts from is `info` rather than `debug`, because that is the decision that matters for a range built after a catch-up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The watermark settles whether a gap's own writes survived, but not whether the build has anywhere to start. The seed is the state root the set's last block declares, and it was written below the watermark, so whether it survived depends on it having been live when the sweep drained. One read answers it, and that read is the whole difference between deciding from an argument and deciding from a fact -- here it is present at #9,420,000, so the 10,740-block gap can be built. A present root is the top node and not proof of the trie beneath it, which the output says. If it is ever absent the message names the recourse: that segment's own sealed store holds the verified state at its end block. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The startup boundary was recorded at the executed head, which is zero blocks settled, so `ready` held the range for another `--segbuild-lag` blocks before offering it -- eight hours at mainnet block time, spent waiting for state the node already has on disk. Cut `lag` blocks lower and the range is settled the moment it is recorded, so the catch-up builds on the first tick. The `lag` blocks left over stay in the open range and are absorbed by the next size-driven cut, which is where all of them would have gone anyway. For the mainnet node that is the difference between closing a 10,745-block gap in about two minutes and closing it tomorrow. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Follow-up to #402, found by asking whether this node could actually turn the feature on. It could not: the gate #402 shipped would refuse to start here, for the wrong reason.
The gate asked the wrong question
That is distance from the head — the same mistake §7.3 corrects inside the builder. Distance says a range lost its protection; it does not say anything was taken. A node stopped for a week has a gap of thousands of blocks whose nodes are all still present, because nothing swept while it was down.
The mainnet node is exactly that case:
The watermark is 77,681 blocks below the gap, so every node the gap's blocks wrote is still in an unswept epoch, and the seed the build starts from is there. The gap is buildable. The old gate refused it.
So the gate now asks the store what it collected (
EpochTrieStore::collected_below) and refuses only when the watermark is above the gap's first block. Same predicate the builder already uses to decide whether to attempt a range — one rule, in both places.A buildable gap still has to be closed promptly, so
SegmentBoundaries::cut_atrecords a boundary at the executed head during startup and the catch-up becomes a range of its own. Left to the size-driven cut it would have waited a gigabyte of writes — about a month of chain — while its collection bound went stale after four days, and the state would have been collected out from under it.A halt was silent
segbuild_boundarieshad no logging at all.halt()wrote theHALTEDfile;tick()returnedTick::Halted(reason)and the caller discarded it. So a reorg deeper than the lag — the most serious event this design has a rule for, the one §7 says must require a human — produced no log line, at the time or ever after. The only trace was a file nobody was told to look for.Now:
error!the moment it happens, saying the node is unaffected and keeps following the chainwarn!once an hour while it lasts, naming the file to remove, so a node halted for a week says so in today's logdebug!on the other ticks, instead of 2,880 identical lines a dayA build was silent too — nothing between
BuildingandBuilt, a quarter of an hour for a full segment, with no way to tell slow from stuck. There is now a progress line every 10,000 blocks carrying the rate and the sealed bytes, and the seed a range starts from isinforather thandebug, because that is the decision that matters for a range built after a catch-up.segbuild_statusAnswering "is there a gap, and can it be built" took eight commands by hand, because nothing printed the executed head's number:
height_peekprints its hash, so it had to be bisected out ofblock_info. It is two comparisons against values already on disk.Read-only, takes no lock (
options.read_only→ noDbLock), safe against the live node. The seed probe is the part worth having: the watermark settles whether a gap's own writes survived, but not whether the build has anywhere to start — the seed was written below the watermark, so its survival depended on being live when the sweep drained. One read instead of a 10,745-block trial replay.Verification
Storage 269, CLI bin 164 (and 164 with
--features smtp), executionsegment_build4.cargo clippy -p rustock-cli -p rustock-execution --all-targetsclean — it caught two bugs in this change on the way: a stray catch-all arm that shadowed theErrcase so "Buildability unknown" could never print, and collapsed line-continuations that put runs of spaces inside user-facing strings.🤖 Generated with Claude Code