Skip to content

Instantly share code, notes, and snippets.

@mightybyte
Created December 14, 2020 02:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mightybyte/f1567c2bec0380539c638225fb8c1cf4 to your computer and use it in GitHub Desktop.
Save mightybyte/f1567c2bec0380539c638225fb8c1cf4 to your computer and use it in GitHub Desktop.
Kadena Stratum Protocol

Kadena stratum protocol

mining.subscribe

params: ["agent", null]
result: [null, "nonce1", "nonce2 size"]

nonce_1 is first part of the block header nonce in hex.

request:

{
  "id": 1,
  "method": "mining.subscribe",
  "params": ["kdaminer-v1.0.0", null]
}

response:

{
  "id": 1,
  "result": [null, "012345", 5],
  "error": null
}

mining.authorize

params: ["username", "password"]
result: true

request:

{
  "id": 2,
  "method": "mining.authorize",
  "params": ["900703b6dd2493696068af72957a94129e54e85f269becc665672bf4730fc6a3", "x"]
}

response:

{
  "id": 2,
  "result": true,
  "error": null
}

mining.set_target

params: ["32 bytes target in big endian hex"]

{
  "id": null,
  "method": "mining.set_target",
  "params": ["0001000000000000000000000000000000000000000000000000000000000000"]
}

mining.notify

params: ["jobId", "header", cleanJob]

{
  "id": null,
  "method": "mining.notify",
  "params": [
    "1234",
    "286 bytes header in hex",
    true
  ]
}

https://github.com/kadena-io/chainweb-node/wiki/Block-Header-Binary-Encoding

Size    Bytes    Value
8       0-7      nonce
8       8-15     time
32      16-47    parent
110     48-157   adjacents
32      158-189  target
32      190-221  payload
4       222-225  chain
32      226-257  weight
8       258-265  height
4       266-269  version
8       270-277  epoch start
8       278-285  flags

mining.submit

old version

params: ["username.worker", "jobId", "nonce2"]
result: true / false

request:

{
  "id": 102,
  "method": "mining.submit",
  "params": [
    "900703b6dd2493696068af72957a94129e54e85f269becc665672bf4730fc6a3.worker1",
    "1234",
    "6789abcdef"
  ]
}
===========================
GPU Mining Speedup Announcement
===========================

tl;dr New GPU miners are now available that mine 5x faster than before.

Hi Everyone,

We would like to announce a new development that is of likely interest to the Kadena mining community. A new version of NoncerPro is now available [1] that can mine more than five times faster than the previous version. A similar improvement is available for the bigolchungus miner as well [2].

For those wondering about what made this speedup possible, the last 64 bits of the block header had been reserved for future protocol changes. It was discovered that miners could use these bits as the nonce. Since these bits are at the end of the block header this makes it possible to mine significantly more efficiently. We’re announcing this to make the information available as broadly as possible to encourage a fair and decentralized mining ecosystem. We expect that other mining software, pools, etc will also come out with improvements to take advantage of this development.

If you are interested in getting more detailed information about this please reach out to us and we’ll be happy to assist.

[1] https://github.com/NoncerPro/Kadena/releases/tag/2.1.1
[2] https://github.com/kadena-community/bigolchungus/pull/20

new version

# new mining submit
params: ["username.worker", "jobId", "nonce2", "extraNonce(hex encoded `flags` field in the header)"]
result: true / false

for example:
{
  "id": 102,
  "method": "mining.submit",
  "params": [
    "900703b6dd2493696068af72957a94129e54e85f269becc665672bf4730fc6a3.worker1",
    "1234",
    "6789abcdef",
    "0123456789abcdef"
  ]
}
response:

accepted share response:

{
  "id": 102,
  "result": true,
  "error": null
}


rejected share response:

{
  "id": 102,
  "result": false,
  "error": [21, "low difficulty", null]
}


in this example:

nonce = nonce1 + nonce2 = 0123456789abcdef (hex in big endian)

we should do `reverse_bytes(hex_decode(nonce))` before writing this to the 286 header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment