You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/MERGE_MINING.MD
+54-1Lines changed: 54 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,59 @@ Each of the aux chains must provide a 32-byte value `unique_id` that singles it
36
36
37
37
`unique_id` is used to enforce the order in which aux hashes are added to the Merkle tree. This prevents an attack where miners can mine two versions of the same chain (for example when double spending) without any additional cost.
38
38
39
-
Forked chains can choose whether to keep their `unique_id` or change it. If they keep it, it will not be possible to merge mine with the chain they forked from beause they will always be assigned the same slot in the Merkle tree.
39
+
Forked chains can choose whether to keep their `unique_id` or change it. If they keep it, it will be impossible to merge mine with the chain they forked from beause they will always be assigned the same slot in the Merkle tree.
40
+
41
+
A deterministic pseudo-random function `SHA256(unique_id|nonce|"m") % N` is applied to determine which slot is used by which chain. `nonce` is brute-forced until all `N` chains are assigned different slots. This limits `N` to no more than 15-16 in practice.
40
42
41
43
Reference code: `get_aux_slot` and `find_aux_nonce` in `merkle.cpp`
44
+
45
+
## Proposed RPC API
46
+
47
+
P2Pool must be able to get mining jobs from merge mined chains and submit PoW solutions to them.
48
+
49
+
### merge_mining_get_id
50
+
51
+
Request: an empty JSON
52
+
53
+
Response: a JSON containing these fields:
54
+
Field|Description
55
+
-|-
56
+
`result`|`OK` or an error message
57
+
`id`|A unique 32-byte hex-encoded value that identifies this merge mined chain.
58
+
59
+
### merge_mining_get_job
60
+
61
+
Request: a JSON containing these fields:
62
+
Field|Description
63
+
-|-
64
+
`height`|Monero height
65
+
`prev_id`|Hash of the previous Monero block
66
+
`address`|A wallet address on the merge mined chain
67
+
`aux_hash`|Merge mining job that is currently being used
68
+
69
+
Response: a JSON containing these fields:
70
+
Field|Description
71
+
-|-
72
+
`result`|`OK` or an error message
73
+
`aux_blob`|A hex-encoded blob of data. Merge mined chain defines the contents of this blob. It's opaque to P2Pool and will not be changed by it.
74
+
`aux_hash`|A 32-byte hex-encoded hash of the `aux_blob`. Merge mined chain defines how exactly this hash is calculated. It's opaque to P2Pool.
75
+
`aux_diff`|Mining difficulty (decimal number).
76
+
77
+
If `aux_hash` is the same as in the request, all other fields will be ignored by P2Pool, so they don't have to be included in the response. Moreover, `{"result":"OK"}` response will be interpreted as a response having the same `aux_hash` as in the request. This enables an efficient polling.
78
+
79
+
### merge_mining_submit_solution
80
+
81
+
Request: a JSON containing these fields:
82
+
Field|Description
83
+
-|-
84
+
`aux_blob`|Blob of data returned by `merge_mining_get_job`.
85
+
`aux_hash`|A 32-byte hex-encoded hash of the `aux_blob` - the same value that was returned by `merge_mining_get_job`.
86
+
`blob`|Monero block template that has enough PoW to satisfy difficulty returned by `merge_mining_get_job`. It also must have a merge mining tag in tx_extra of the coinbase transaction.
87
+
`merkle_proof`|A proof that `aux_hash` was included when calculating Merkle root hash from the merge mining tag
88
+
89
+
Note that `merkle_proof` only contains a vector of 32-byte hashes for `aux_hash` to be combined with. It can be verified by running this pseudo-code and functions from `merkle.cpp` (adapt it to your codebase):
0 commit comments