-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] add Proxy Annex #103
Draft
plebhash
wants to merge
1
commit into
stratum-mining:main
Choose a base branch
from
plebhash:add-proxy-annex
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## 11 Proxies | ||
|
||
Proxies are entities that aggregate hashrate from multiple Mining Devices into a single Connection. | ||
|
||
The following protocol primitives are based on the assumption that proxies are part of the infrastructure: | ||
- Extended Extranonces: allowing for efficient hashing space distribution. | ||
- Future Jobs: allowing for in-site caching of Future Jobs (therefore avoiding empty Jobs). | ||
|
||
Proxies can be nested into multiple layers, depending on different needs for miner infrastructure. | ||
The infrastructure complexity may vary according to operational requirements, but a single proxy layer should suffice for most simple setups. | ||
|
||
Proxies can be split in two main categories: | ||
|
||
### 11.1 Mining Proxy | ||
|
||
TODO: review correctness of this | ||
|
||
A Mining Proxy covers the full scope of the Mining Protocol. It supports all types of channels, both for Upstream and Downstream Connections. | ||
|
||
| | **Standard Channels** | **Group Channels** | **Extended Channels** | | ||
|----------------|-----------------------|--------------------|-----------------------| | ||
| **Upstream** | yes | yes | yes | | ||
| **Downstream** | yes | yes | yes | | ||
|
||
A Mining Proxy is responsible for delivering Jobs to Downstream Channels and is a crucial piece of infrastructure for optimizing the hash space distribution across multiple SV2 Mining Devices (plus SV1 Mining Devices, in case a Translator Proxy is available Downstream). | ||
|
||
A Mining Proxy can forward multiple Standard Channels to the Upstream, ideally one representing each SV2 Mining Device Downstream. | ||
The Upstream (Pool, JDC or another Mining Proxy) is expected to send a `SetGroupChannel` message aggregating different Standard Channels. | ||
The Upstream sends jobs via `NewExtendedMiningJob` to Group Channels, and if some Downstream is a Mining Device (i.e.: the `SetupConnection` had the `REQUIRES_STANDARD_JOBS` flag) the Mining Proxy converts that message into different `NewMiningJob` messages after calculating the correct Merkle Root based on each Standard Channel's `extranonce_prefix`. | ||
|
||
Alternatively, a Mining Proxy could aggregate multiple Donwstream Standard Channels into a single Extended Channel. The Upstream sends Jobs via `NewExtendedMiningJob`, and for each Downstream SV2 Mining Device, the Mining Proxy sends different `NewMiningJob` message, where the Merkle Root is based on the Standard Channel's `extranonce_prefix`. | ||
|
||
![](./img/mining_proxy_standard.png) | ||
|
||
### 11.2 Translator Proxy | ||
|
||
A Translator Proxy has a much more limited scope of functionality, when compared to a Mining Proxy. | ||
It can only open Extended Channels with its Upstream, and all its Downstream Connections are SV1. | ||
|
||
Its main purpose is to allow legacy SV1 Mining Devices to be deployed within SV2 infrastructures. | ||
|
||
| | **Standard Channels** | **Group Channels** | **Extended Channels** | | ||
|----------------|-----------------------|--------------------|-----------------------| | ||
| **Upstream** | no | no | yes | | ||
| **Downstream** | no (SV1) | no (SV1) | no (SV1) | | ||
|
||
A Translator Proxy establishes SV1 connections with its Downstream SV1 Mining Devices, and establishes `extranonce_size` and a unique `extranonce_prefix` for each one of them via the `mining.set_extranonce` SV1 message. | ||
|
||
It receives Extended Jobs from the Upstream via `NewExtendedMiningJob` messages. For each Downstream SV1 Mining Device, a `mining.notify` SV1 message is sent, and the SV1 Mining Devices are expected to calculate their own Merkle Roots while rolling over their assigned Extranonce space. | ||
|
||
![](./img/translator_proxy.png) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" version="24.8.2"> | ||
<diagram id="N4VejNDs0hO81L9vthc3" name="Mining Proxy Standard"> | ||
<mxGraphModel dx="1434" dy="1987" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0"> | ||
<root> | ||
<mxCell id="0" /> | ||
<mxCell id="1" parent="0" /> | ||
<mxCell id="DT3knt80q17mCQlJXY2i-1" value="Mining Proxy" style="rounded=0;whiteSpace=wrap;html=1;fillOpacity=100;" parent="1" vertex="1"> | ||
<mxGeometry x="290" y="150" width="160" height="80" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;shape=link;" parent="1" target="yj93N_Tji8AnoezUfCwW-3" edge="1"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="370" y="160.00000000000045" as="sourcePoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-6" value="<font color="#ff99cc"><b>Standard</b> Channel</font><div><font color="#ff99cc">channel_id=A<br>extranonce_prefix=A</font></div>" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=1;entryDx=0;entryDy=0;shape=link;strokeColor=#FF99CC;" parent="1" source="V2UcTeTZU-o2jDbRS0ZS-3" edge="1"> | ||
<mxGeometry x="-0.0434" y="-30" relative="1" as="geometry"> | ||
<mxPoint as="offset" /> | ||
<mxPoint x="327.5735931287986" y="228.2842712474676" as="targetPoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-3" value="SV2 Mining<div>Device A</div>" style="rhombus;whiteSpace=wrap;html=1;strokeColor=#FF99CC;" parent="1" vertex="1"> | ||
<mxGeometry x="70" y="350" width="110" height="110" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;shape=link;strokeColor=#CC99FF;" parent="1" target="DT3knt80q17mCQlJXY2i-1" edge="1"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="370" y="240.00000000000045" as="targetPoint" /> | ||
<mxPoint x="370" y="230" as="sourcePoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=1;entryY=1;entryDx=0;entryDy=0;shape=link;strokeColor=#B266FF;" parent="1" source="V2UcTeTZU-o2jDbRS0ZS-5" edge="1"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="412.4264068712014" y="228.2842712474676" as="targetPoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-5" value="SV2 Mining<div>Device B</div>" style="rhombus;whiteSpace=wrap;html=1;strokeColor=#B266FF;" parent="1" vertex="1"> | ||
<mxGeometry x="555" y="350" width="110" height="110" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-14" value="<font color="#9933ff"><b style="">Standard</b> Channel</font><div><font color="#9933ff">channel_id=B<br>extranonce_prefix=B</font></div>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="1" connectable="0" vertex="1"> | ||
<mxGeometry x="500.00365134908645" y="229.99820592225535" as="geometry"> | ||
<mxPoint x="15" y="99" as="offset" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=0;exitDx=0;exitDy=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;shape=link;strokeColor=#9933FF;" parent="1" source="yj93N_Tji8AnoezUfCwW-3" target="V2UcTeTZU-o2jDbRS0ZS-1" edge="1"> | ||
<mxGeometry relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=0;exitDx=0;exitDy=0;entryX=0.25;entryY=1;entryDx=0;entryDy=0;shape=link;strokeColor=#FF99CC;" parent="1" source="yj93N_Tji8AnoezUfCwW-3" target="V2UcTeTZU-o2jDbRS0ZS-1" edge="1"> | ||
<mxGeometry relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;textShadow=1;shadow=1;shadowColor=#FFFFFF;shadowOpacity=100;shadowOffsetX=1;shadowOffsetY=1;shadowBlur=1;" parent="1" source="yj93N_Tji8AnoezUfCwW-17" target="DT3knt80q17mCQlJXY2i-1" edge="1"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="309.9999999999941" y="200.00000000000045" as="targetPoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-17" value="<b>NewExtendedMiningJob</b><br>channel_id=G<br>merkle_path=G<br>coinbase_prefix=G<br>coinbase_suffix=G" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="1" vertex="1"> | ||
<mxGeometry x="120" y="-20" width="190" height="80" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-22" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0;entryDx=0;entryDy=0;textShadow=1;shadow=1;shadowColor=#FFFFFF;shadowOpacity=100;shadowOffsetX=1;shadowOffsetY=1;shadowBlur=1;" parent="1" source="yj93N_Tji8AnoezUfCwW-19" target="V2UcTeTZU-o2jDbRS0ZS-3" edge="1"> | ||
<mxGeometry relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-19" value="<b>NewMiningJob</b><div><font color="#ff99cc">channel_id=A<br>merkle_root=A</font></div>" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="1" vertex="1"> | ||
<mxGeometry x="50" y="220" width="120" height="60" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=1;entryY=0;entryDx=0;entryDy=0;textShadow=1;shadow=1;shadowColor=#FFFFFF;shadowOpacity=100;shadowOffsetX=1;shadowOffsetY=1;shadowBlur=1;" parent="1" source="yj93N_Tji8AnoezUfCwW-20" target="V2UcTeTZU-o2jDbRS0ZS-5" edge="1"> | ||
<mxGeometry relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-20" value="<b>NewMiningJob</b><div><font color="#9933ff">channel_id=B<br>merkle_root=B</font></div>" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="1" vertex="1"> | ||
<mxGeometry x="580" y="220" width="120" height="60" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-27" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;textShadow=1;shadow=1;shadowColor=#FFFFFF;shadowOpacity=100;shadowOffsetX=1;shadowOffsetY=1;shadowBlur=1;" parent="1" source="yj93N_Tji8AnoezUfCwW-26" target="DT3knt80q17mCQlJXY2i-1" edge="1"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="430.00000000000614" y="200.00000000000045" as="targetPoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-26" value="<b>SetGroupChannel</b><div>group_channel_id=G</div><div>channel_ids=[A,B]</div>" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="1" vertex="1"> | ||
<mxGeometry x="425" y="30" width="170" height="60" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="V2UcTeTZU-o2jDbRS0ZS-1" value="Connection" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1"> | ||
<mxGeometry x="310" y="-90" width="120" height="20" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="DT3knt80q17mCQlJXY2i-3" value="Conn" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1"> | ||
<mxGeometry x="310" y="230" width="40" height="20" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="DT3knt80q17mCQlJXY2i-8" value="Conn" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1"> | ||
<mxGeometry x="390" y="230" width="40" height="20" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="RgBkzOm2UzhGMEhQhQTZ-1" value="Upstream<br><br><div>(Pool, JDC, or another Mining Proxy)</div>" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1"> | ||
<mxGeometry x="185" y="-270" width="370" height="180" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="yj93N_Tji8AnoezUfCwW-3" value="Group Channel<div>id=G</div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#B3B3B3;fontColor=#333333;strokeColor=#666666;fillOpacity=100;" parent="1" vertex="1"> | ||
<mxGeometry x="310" y="100" width="120" height="60" as="geometry" /> | ||
</mxCell> | ||
</root> | ||
</mxGraphModel> | ||
</diagram> | ||
</mxfile> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cross referencing review from @jakubtrnka
originally I was trying to capture every single possible use-case into Mining Proxy, but it seems we should split these functionalities into different categories
#98 (comment)