Add extranonce_manager module in channels_sv2#2098
Add extranonce_manager module in channels_sv2#2098plebhash merged 4 commits intostratum-mining:mainfrom
extranonce_manager module in channels_sv2#2098Conversation
b33c8be to
834b6ce
Compare
834b6ce to
7394b40
Compare
7394b40 to
6038120
Compare
39adc06 to
eb4f941
Compare
|
@pavlenex had some issues while trying to connect rented hashrate from Nicehash to a tProxy (exposed over internet)
while reviewing/testing this PR, we should make sure nicehash use-case is not blocked |
|
the suffix for example:
we should establish terminology that clearly separates concerns. I suggest we rename variables to something like:
on the suggestion above, I'm leaving what's currently described as IMO this would bring more consistency to how the new concepts map into the code, and make the code easier to reason about and maintain on the long term. |
|
aside from the suggestion above, I think I got a much better understanding of this new approach I'll make another round of review tomorrow (my clanker found some potential edge cases that could cause problems, but I need to sanity-check them before posting here) |
9d90704 to
e590b32
Compare
|
@plebhash I included all your suggestions and now we have:
|
02e4ebc to
efb3a27
Compare
efb3a27 to
4395233
Compare
9b29dc7 to
462f595
Compare
cb6d989 to
51f8d80
Compare
51f8d80 to
10a39da
Compare
|
@plebhash @Shourya742 I pushed a new commit (5a36d11) to extend the usage of I'll work on adapting the tProxy on the companion PR soon. |
8b94071 to
5a36d11
Compare
|
@plebhash @Shourya742 I pushed a new commit (ffb63c2) which renames the old In this way tProxy can use it (in the I pushed all the adaptations on the companion PR, and I did a quick round of testing, and everything looks good. But I want to do some deeper tests tomorrow. If you ACK this last commit, I'll squash it in b1c669e. |
|
I was thinking about the current design, and at the moment the server side of the channel can accept the For client_side of channel: #[derive(Debug, Clone, PartialEq, Eq)]
pub struct WireExtranoncePrefix {
prefix: Vec<u8>,
}For server_side of channel pub struct ExtranoncePrefix {
prefix: Vec<u8>,
allocation: PrefixAllocation,
}
#[derive(Debug)]
struct PrefixAllocation {
local_index: u32,
bitmap: Weak<BitVector>,
} |
ffb63c2 to
94ddb75
Compare
@GitGab19 what you think of this? |
|
@Shourya742 I just pushed a new commit (b61eaf4) which introduces a new In the case of client-side channels, we need to keep things as they are, because tProxy is using both pure prefixes coming from the wire and prefixes coming from the allocator (to extend the extranonce for its downstreams). |
This works as well, as long as server channels stay safe. Looks good to me |
|
a non-blocking comment about the current design (where standard and extended channels share a unified allocation space): standard channel allocation is evolving in this pattern: one could argue we're wasting search space with the 0-padding if standard channel allocation space was separate from extended, it could evolve under this pattern: this would lift the ceiling for max concurrent standard channels to an astronomical scale, with the tradeoffs:
it's hard to evaluate whether this will really have a meaningful impact in production scenarios, as a unified allocation space that caters for e.g.: anyways I don't think we need to do anything about this now (and perhaps ever) but I feel it's at least worthy of note, since this is something I've always contemplated about the previous design |
…ent in Sv2 channels
as a consequence, it also bumps: - `parsers_sv2`: 0.2.2 -> 0.3.0 - `handlers_sv2`: 0.2.2 -> 0.3.0
fd090db to
fd67587
Compare

This PR introduces a new
extranonce_managermodule inchannels_sv2centered aroundExtranonceAllocatorIt's a unified, reusable allocator for extranonce prefixes for both standard and extended channels.
It replaces the legacy
ExtendedExtranoncefactory frommining_sv2and provides a clearer, spec‑aligned, and more configurable way to size and manage extranonce space across pools, proxies (JDC/Translator), and other applications.Internally, the allocator uses a compact bitmap (1 bit per channel) to track local_prefix_id usage, ensuring fast allocations, deterministic reuse when channels close, and no overlap between standard and extended channel prefixes.
This PR is inspired by the @coleFD's bitvec approach (see #2049), but it doesn't add any new external dependencies to our crates.
Closes #1924
companion stratum-mining/sv2-apps#310