Repository navigation
Conversation
A BMM request (M8) commits to its previous mainchain block, so it can only be mined on top of that block. Connecting a block drops the requests seen on top of its parent, but those on top of a disconnected block stayed in the mempool after a reorg, where a served template could pick them up and make the block invalid. Disconnecting a block now drops the requests seen on top of it. The block producer tracks the M8s it accepts into the mempool: connecting a block drops every one that does not build on it, and templates never include one committing to another block than their parent. Claude-Session: https://claude.ai/code/session_01MkqNezLq2qX1jG9BCoYqRK
Collaborator
|
Thanks. I reimplemented this in #678. You retain commit authorship. The reimplementation is simpler, and has test coverage. |
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.
Branch:
block-fabric:mempool-stale-bmm. One commit, onmaster(ceb608a). It is independent of the other twoPRs. This is policy only: it does not change validity, so there is no activation height.
Motivation
A BMM request (M8) commits to its previous mainchain block. A block is valid only if each of its M8s commits to that
block's parent (
BmmRequestExpired). The enforcer's mempool (--enable-mempool) already handles two cases:It misses one case. After a reorg, the M8s seen on top of the disconnected block stay in the mempool. Nothing
removes them, and the block template server can serve them. A miner using that template, including the enforcer's
own
GenerateToAddress, then produces a block that the enforcer rejects.The change
Validator::disconnect_blocknow returns, inDisconnectBlockAction::remove_mempool_txs, the M8s it saw ontop of the disconnected block. The mempool sync drops them along with their descendants. This mirrors what
connect_blockalready does for a block's parent.mempool_payouts; the mempool replaysaccept_txon restart;remove_mempool_txs. This alsocatches any left over from a reorg;
initial_block_templateexcludes any tracked M8 that commits to another block than the template's parent.Templates can then never contain a stale request, even before the mempool catches up.
Tests
validator::cusf_enforcer::tests::connect_block_modes::disconnect_drops_bmm_requests_on_top_of_the_block: after adisconnect, the M8 seen on top of the block is in
remove_mempool_txs, and one on top of another block is not.block_producer::stale_bmm_request_tests::only_requests_on_top_of_the_tip_are_fresh: the selection used both foreviction and for template exclusion.
Results:
cargo test --workspace(208 lib + 13 app tests),cargo clippy --all-targets, nightlyfmt --checkand nightlyunqualified_local_importsclippy (which needed an explicitdropof the lock): all pass.test_bmm_bid_auctionwithinvalidate_block, would be the natural next step. It is left out because theintegration harness could not be run locally.
Betanet (v0.3.4,
2026-09-16-betanet@ 17eb2ce)It does not cherry-pick cleanly. There are 8 conflicts:
lib/block_producer/mod.rs(7): betanet lacks e08aae4'smempool_payoutstracking, which this change sits nextto;
lib/validator/cusf_enforcer.rs(1).The logic ports easily, but the hunks need to be rewritten by hand.
Open questions for maintainers
RejectTx) on disconnect, as they are onconnect? The mempool sync crate's disconnect path only removes them.
unless that transaction is itself an M8. Is that worth adding here as a follow-up?