feat: tag orders with their source (mempool vs RPC)#934
Open
MavenRain wants to merge 1 commit into
Open
Conversation
Closes flashbots#122. The block-building algorithm needs to know whether an order arrived from the public mempool or was submitted directly to the builder's RPC server, but that origin was only inferable indirectly (the Order::Tx vs Order::Bundle shape, plus the out-of-band MempoolTxsDetector hash set). Record the origin as a first-class OrderSource on Order metadata: - add OrderSource { Mempool, RpcServer, Unknown } (default Unknown) and a `source` field on Metadata, with Order::source() / Order::set_source(); - stamp Mempool at both mempool ingresses (the IPC/WS txpool fetcher and the reth-embedded transaction-pool path) and RpcServer at the RPC ingress (send_order funnels eth_sendRawTransaction and eth_sendBundle); - Metadata is excluded from Order equality/hashing, so tagging the source never affects order identity or deduplication. The tag is deliberately not carried over the wire: it is a local record of how the order reached this builder, so a remote submitter cannot assert it. Orders reconstructed outside the live ingestion paths (backtests, tests) keep OrderSource::Unknown. Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
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.
What
Adds a first-class
OrderSource(Mempool | RpcServer | Unknown) recorded onevery order's
Metadata, so the building algorithm can distinguish orders thatcame from the public mempool from orders submitted directly to the builder's RPC
server. Closes #122.
Why
The build algorithm relies on this distinction, but today it is only inferable
indirectly — from the
Order::TxvsOrder::Bundleshape (which mislabels rawtxs submitted via
eth_sendRawTransaction, since those are alsoOrder::Tx) andfrom the out-of-band
MempoolTxsDetectorhash set. This makes the origin astored, O(1), always-correct property of the order itself.
How
OrderSource+Metadata.source(defaultUnknown), withOrder::source()and
Order::set_source().Metadatais excluded fromOrderequality andhashing (existing
derivativeignores), so the tag never changes orderidentity or dedup.
Mempoolat both mempool paths (the IPC/WS txpool fetcherand the reth-embedded pool path) and
RpcServerin thesend_orderfunnel.Mempool); backtest/test-reconstructed orders remainUnknown.This is additive and does not change block-building behavior. The stored source
can later replace the
MempoolTxsDetectorlookup where a per-order (rather thanper-child-tx) granularity is sufficient — left as a follow-up per the issue's
"To Be Discussed".
Testing
rbuilder-primitives: default isUnknown;set_sourceround-trips; tagging both
TxandBundleorders updatessource()withoutchanging
id(),Eq, orHash.reports
OrderSource::Mempool.cargo fmt,cargo clippy --all-targets -- -D warnings, and the primitiveslib tests pass.