Repository navigation
Conversation
Entry time lived only in the hub's RAM maps, filled on admit. Hub open loaded the live set but never indexed it, so after a restart getmempoolentry.time was 0 and -mempoolexpiry never removed a loaded entry. The mempool sidecar is schema 4: each packed record stores its accept time after sigops. The mempool stamps it from the hub's mock clock (now shared, so setmocktime still reaches it), AcceptResult carries it, and the hub indexes admits with that same value. At open the hub indexes loaded entries with their stored time, without queueing an INV. Schema 1-3 records migrate on open with the migrate's wall-clock second. Refs reardencode#1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The addr token bucket gated only relay: on_addrv2 learned every row first, and the bucket started full at 1000. One peer could replace every never-connected address with nine 1000-entry messages. IBD peers' addresses were not limited at all. AddrTokenBucket follows Core v31.1: one token at connect, 0.1 per second up to 1000. Tokens are taken before learn_addrv2, and only the admitted prefix is learned and relayed. IBD peers spend a bucket of their own. A peer with the addr permission is not limited. getpeerinfo reports addr_processed and addr_rate_limited. Core credits 1000 tokens when it sends getaddr. Here only addr-fetch peers get getaddr, and their multi-address reply is dropped before learning, so there is no credit to add. Refs reardencode#1030 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Loaded entries were indexed with relay sequence 0. A new peer starts at last_inv_sequence 1, so is_relay_servable let it getdata a restored tx before any INV; before the reload fix such a tx had no sequence and was not servable. Core's load assigns a fresh sequence; do the same. Refs reardencode#1029 Co-Authored-By: Claude Opus 5.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.
Fixes #1029. Fixes #1030. One commit each.
Mempool entries keep their accept time across a restart (#1029)
Schema bump: this moves the mempool sidecar from schema 3 to 4.
docs/ORIENT.mdlists a schema bump under "Ask first", so please weigh in on that part in particular. The main store (SCHEMA_VERSION26) is untouched.accept_secsaftersigops(fee‖weight‖sigops‖accept_secs‖txid‖wtxid‖tx‖vin aux).SIGOP_COST_OFFis unchanged.finish_commitfrom the hub's mock clock. Themock_nowatomic is now anArcshared withActiveMempool, sosetmocktimereaches it without another step added to the fan-out clock: one mockable node-time source instead of per-subsystem mock clocks #821 describes.AcceptResult.accept_secscarries the value, and the hub indexes admits with it, so RAM and disk agree.(txid, wtxid, accept_secs)and indexes each entry still live. Loaded entries are not added toage_inv, so a restart queues no INVs, as before.mempool/torn-<unix>/and starts with an empty mempool. Class A is not affected.Tests:
reopen_keeps_accept_time_and_expiry(hub): admit under mocktime, reopen, then checkaccept_time_txidand that the entry expires on schedule. It fails on master, where the time after reopen isNone.schema3_converts_on_open_with_migrate_accept_time: sigops are kept, the time is stamped once and stays durable.Addresses are rate limited before AddrMan (#1030)
AddrTokenBucketfollows Core v31.1ProcessMessageADDR:on_addrv2takes tokens beforelearn_addrv2. Only the admitted prefix is learned and relayed; the rest are dropped.connected_at.IbdWorkState::addr_buckets, dropped on peer death).addrwhitelist permission is not limited (p2p_addrv2_relay.pyruns with-whitelist=addr@127.0.0.1).getpeerinfogainsaddr_processedandaddr_rate_limited.Not included: Core credits 1000 tokens when it sends
getaddr. Here only addr-fetch peers getgetaddr, andon_addrv2drops their multi-address reply before learning, so the credit would be dead code. If outbound full-relay peers start getting agetaddr(Core sends one at handshake), the credit belongs with that change. Core also shuffles the list before spending tokens; this takes the prefix.Tests:
addrv2_flood_is_rate_limited_before_addrman: a fresh inbound peer's 1000-entryaddrv2teaches one address, and the counters are (1, 999). Withaddr@all 1000 are learned. It fails on master, where 1000 addresses reach AddrMan.ibd_peer_addr_flood_takes_one_token.Checks
-D warnings, deny,ast-grep.sh,cargo test --workspaceandci-os-smoke.shall pass.mempool_expiry,mempool_limit,mempool_unbroadcast,p2p_tx_privacy,p2p_addrv2_relay,p2p_addrfetchandp2p_addr_selfannouncementall pass.🤖 Generated with Claude Code