Skip to content
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

Add stratum style mining protocol #352

Closed
kseo opened this Issue Jul 9, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@kseo
Copy link
Contributor

kseo commented Jul 9, 2018

No description provided.

@kseo kseo added the miner label Jul 9, 2018

@kseo

This comment has been minimized.

Copy link
Contributor Author

kseo commented Jul 11, 2018

@redongjun will work on this issue.

@redongjun

This comment has been minimized.

Copy link
Contributor

redongjun commented Jul 16, 2018

@kseo I have written a protocol spec as below. could you review it?
(ref https://slushpool.com/help/manual/stratum-protocol)

mining.subscribe

Used for subscribing mining jobs.

Params: No parameters
Return Type: No parameters

Request Example

{
    "jsonrpc": "2.0", 
    "id": 1, 
    "method": "mining.subscribe", 
    "params": []
}

Response Example

{
    "jsonrpc": "2.0", 
    "id": 1, 
    "result": [],
    "error": null
}

mining.authorize

Used for authorizing miner.

Params:

  1. name: string
  2. password: string

Return Type: bool

Request Example

{
    "jsonrpc": "2.0", 
    "id":2, 
    "method": "mining.authorize", 
    "params": ["miner1", "password"]
}

Response Example

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

mining.notify

Used for sending notifications with mining jobs

Params: WorkObject

Notification Example

{
    "jsonrpc": "2.0",
    "id": 3, 
    "method": "mining.notify", 
    "params": {
        "0x56642f04d519ae3262c7ba6facf1c5b11450ebaeb7955337cfbc45420d573077",
        "100"
    },
}

mining.submit

Used for submitting a proof-of-work solution.

Params:

  1. powHash: string
  2. seal: string[]

Return Type: bool

Request Example

{
    "jsonrpc": "2.0",
    "id": 4, 
    "method": "mining.submit", 
    "params": ["0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", ["0x56642f04d519ae3262c7ba6facf1c5b11450ebaeb7955337cfbc45420d573077"]],
}

Response Example

{
    "jsonrpc": "2.0",
    "id": 4, 
    "result": true,
    "error": null
}

Exception Handling

Stratum defines simple exception handling. Example of rejected share looks like:

{
    "jsonrpc": "2.0",
    "id": 5, 
    "result": null, 
    "error": (21, "Job not found", null)
}

Where the error field is defined as (error_code, human_readable_message, traceback). Traceback may contain additional information for debugging errors.
Proposed error codes for mining service are:

  • 20 - Other/Unknown
  • 21 - Job not found (=stale)
  • 22 - Duplicate share
  • 23 - Low target share
  • 24 - Unauthorized worker
  • 25 - Not subscribed
@kseo

This comment has been minimized.

Copy link
Contributor Author

kseo commented Jul 17, 2018

@redongjun Thanks for the suggestion. Let's discuss the spec tomorrow at the developers meeting.

@redongjun

This comment has been minimized.

Copy link
Contributor

redongjun commented Jul 20, 2018

After the developers meeting, I have read another stratum article and existing stratum codes in codechain. the proposal spec was a mistake due to a lack of understanding about mining pool and reward. so the specification has been slightly modified as above.

In summary:
subscribing give miner basic information for working. (currently no parameter, but need to discuss in the future)
authorizing register as a worker on a node.
notify and submit are the same as before.

I have prototyped as spec as above. #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.