There is now an official page for documentation:
http://stratumprotocol.org/Stratum protocol extensions recently added and copied below:
http://stratumprotocol.org/stratum-extensionsStratum protocol extensions
(Adding version rolling support to stratum)
Initial motivation for specifying some general support for stratum protocol extensions was a need to allow miners to do so called “version rolling”, changing value in the first field of the Bitcoin block header.
Version rolling is backwards incompatible change to stratum protocol because miner couldn’t communicate different block version value to the server in the original version of the stratum protocol. Similarly, a server couldn’t communicate safe bits for rolling to a miner. So both miners and pools need to implement some protocol extension to support version rolling.
Typically, if a miner sends an unknown message to a server, the server closes the connection (not all implementations do that but some do). So it is not very safe to try to send unknown messages to servers.
We can use the opportunity to make one backward incompatible change to the protocol to support multiple extensions in the future. In a way that a miner can advertise its capabilities and at the same time it can request some needed features from server.
It is preferable that the same mechanism for feature negotiation can be used for not yet known features. It should be easy to implement in the mining software too.
We introduce one new message to the stratum protocol ( “mining.configure” ) which handles the initial configuration/negotiation of features in a generic way. So that adding features in the future can be done without a necessity to add
Each extension has its unique string name, so called extension code.
Currently, the following extensions are defined:
“version-rolling”
“minimum-difficulty”
“subscribe-extranonce”
“promise-protocol”
“binary-protocol”
more to be published
Additional data types
The following names are used as type aliases, making the message description easier.
TMask - case independent hexadecimal string of length 8, encoding unsigned 32-bit integer (~[0-9a-fA-F]{8})
TExtensionCode - non-empty string with a value equal to a name of some protocol extension.
TExtensionResult - true / true / String. true = The requested feature is supported and its configuration understood and applied. false = The feature is not supported or unknown. String = Error message containing information about what went wrong.
Request “mining.configure”
This message (JSON RPC Request) SHOULD be the first message sent by a miner after connection with a server is established. The client uses the message to advertise its features and to request/allow some protocol extensions.
The reason for being the first is that we want the implementation and possible interactions as easy and simple as possible. An extensions can define explicitly what does a repeated configuration of that extension mean.
Each extension code provides a namespace for its extension parameters and extension return values. By convention, the names are formed from extension codes by adding “.” and a parameter name. The same applies for the return values, which are transferred in a result map too. E.g. “version-rolling.mask” is a name of parameter “mask” of extension “version-rolling”.
Parameters:
extensions (required, List of TExtensionCode)
Each string in the list must be a valid extension code. The meaning of each code is described independently as part of the extension definition.
A miner SHOULD advertise all its available features.
extension-parameters (required, Map of (String -> Any))
Parameters of the requested/allowed extensions from the first parameter.
Return value:
Map of (String -> Any)
Each code from extensions list MUST have a defined return value (TExtensionCode -> TExtensionResult). This way the miner knows if the extension is activated or not. E.g. {"version-rolling":false} for unsupported version rolling.
Some extensions need additional information to be delivered to the miner. The return value map is used for this purpose.
Example request (new-lines added):
{"method": "mining.configure",
"id": 1,
"params": [["minimum-difficulty", "version-rolling"],
{"minimum-difficulty.value": 2048,
"version-rolling.mask": "00fff000", "version-rolling.min-bit-count": 2}]}
(The miner requests extensions "version-rolling" and "minimum-difficulty". It sets parameters according to the extensions’ definitions.)
Example result (new-lines added):
{"error": null,
"id": 1,
"result": {"version-rolling": true,
"version-rolling.mask": "007f8000",
"minimum-difficulty": true}}
Defined extensions
Extension “version-rolling”
This extension allows the miner to change value of some bits in the version field in a block header. Currently there are no standard bits used for version rolling so they need to be negotiated between a miner and a server.
A miner sends to the server a mask describing bits which the miner is capable to change. 1 = changeable bit, 0 = not changeable (miner_mask) and a minimum number of bits that it needs for efficient version rolling.
A server typically allows to change only some of the version bits (server_mask) and the rest of the version bits are fixed. E.g. because the block needs to be valid or some signaling is in place.
The server responds to the configuration message by sending a mask with common bits intersection of the miner’s mask and its a mask (response = server_mask & miner_mask)
Example request (a miner capable of changing any 2 bits from a 12-bit mask):
{"method": "mining.configure", "id": 1, "params": [["version-rolling"], {"version-rolling.mask": "00fff000", "version-rolling.min-bit-count": 2}]}
Example result (success):
{"error": null, "id": 1, "result": {"version-rolling": true, "version-rolling.mask": "007f8000"}}
Example result (unknown extension):
{"error": null, "id": 1, "result": {"version-rolling": false}}
Extension parameters:
“version-rolling.mask” (optional, TMask, default value "ffffffff")
Bits set to 1 can be changed by the miner. This value is expected to be stable for the whole mining session. A miner doesn’t have to sent the mask, in such case a default full mask is expected.
Extension return values:
“version-rolling” (required, TExtensionResult)
When responded true, the server will accept new parameter of “mining.submit”, see later.
“version-rolling.mask” (required, TMask)
Bits set to 1 are allowed to be changed by the miner. If a miner changes bits with mask value 0, the server will reject the submit.
The server SHOULD return the largest mask possible (as many bits set to 1 as possible). This can be useful in a mining proxy setup when a proxy needs to negotiate the best mask for its future clients. There is a BIP(TBD) describing available nVersion bits. The server should pick a mask that preferably covers all bits specified in the BIP.
“version-rolling.min-bit-count” (required, TMask)
The miner also provides a minimum number of bits that it needs for efficient version rolling in hardware. Note that this parameter provides important diagnostic information to the pool server. If the requested bit count exceeds pool server limit, the miner always has the chance to operate in a degraded mode without using full hashing power. The pool server should NOT terminate miner connection if this rare mismatch case occurs.
Notification “mining.set_version_mask”
Server notifies the miner about a new mask valid for the connection. This message can be sent any time after successful setup of the version rolling by “mining.configure” message. The new mask is valid immediately, so that the server doesn’t wait for the next job.
TODO: Is it really better to use the mask immediately or “next job” approach would be better?
Parameters:
mask (required, TMask): The meaning is the same as “version-rolling.mask” return parameter.
Example:
{"params":["00003000"], "id":null, "method": "mining.set_version_mask"}
Changes in request “mining.submit”
Immediately after successful activation of version-rolling extension (result to “mining.configure” sent by server), the server MUST accept one additional parameter of the message “mining.submit”. Client MUST send one additional parameter, version_bits (6th parameter, after worker_name, job_id, extranonce2, ntime and nonce).
Additional parameter:
version_bits (required, TMask) - Version bits set by miner.
Miner can set only bits corresponding to the set bits in the last received mask from the server either as response to “mining.configure” or “mining.set_version_mask” notification (last_mask). This must hold: version_bits & ~last_mask == 0.
nVersion for the submit is computed by the server as follows: nVersion = (job_version & ~last_mask) | (version_bits & last_mask), where job_version is a block version sent to miner as part of job with id job_id.
Extension “minimum-difficulty”
This extension allows miner to request a minimum difficulty for the connected machine. It solves a problem in the original stratum protocol where there is no way how to communicate hard limit of the connected device.
Extension parameters:
“minimum-difficulty.value” (required, Integer/Float, >= 0)
The minimum difficulty value acceptable for the miner/connection. The value can be 0 for essentially disabling the feature.
Extension return values:
“minimum-difficulty” (required, TExtensionResult)
Whether the minimum difficulty was accepted or not.
This extension can be configured multiple times by calling “mining.configure” with “minimum-difficulty” code again.
Extension “subscribe-extranonce”
Parameter-less extension. Miner advertises its capability of receiving message “mining.set_extranonce” message (useful for hash rate routing scenarios).
Extension “info”
Miner provides additional text-based information.
Extension parameters:
“info.connection-url” (optional, String) Exact URL used by the mining software to connect to the stratum server.
“info.hw-version” (optional, String) Manufacturer specific hardware revision string.
“info.sw-version” (optional, String) Manufacturer specific software version
“info.hw-id” (optional, String) Unique identifier of the mining device
Notification mining.set_extranonce:
TBD
Extension “binary-protocol”
To be published
Extension “promise-protocol”
To be published