Bitcoin Forum
July 12, 2024, 01:49:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: « 1 ... 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 [301] 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 ... 570 »
6001  Bitcoin / Development & Technical Discussion / Re: Which document is correct regarding response to "subscribe" method on: April 07, 2014, 08:42:00 AM
Perhaps you want this:
https://bitcointalk.org/index.php?topic=557866.0

And this:
https://bitcointalk.org/index.php?topic=557991.0

And this:
2013 Feb, after discussion, mining.subscribe was extended to take 2 arguments, so now it's mining.subscribe(String useragent, sessionid) where sessionid is optional, but if provided must match a previous session's mining.notify subscription id. If the server allows resuming a session, it will give you back the same subscription id and extranonce information.

cgminer handles it. No idea bout the rest.
6002  Bitcoin / Mining software (miners) / Re: CGMINER ASIC miner monitoring RPC linux/win/osx/mips/arm/r-pi 4.2.3 on: April 07, 2014, 04:41:56 AM
what does this mean?:

AMU 57 SendWork usb write err:(-9) LIBUSB_ERROR_PIPE

I'm getting hashrate to build up to 2/3rds the way then half of it shuts off and it stats to reload again until the cycle repeats.  Cannot get everything on and mining in harmony. 
It means there has been a fatal usb communication error and cgminer drops the device to allow it to restart again. You probably don't have enough power or dodgy connections etc.

Its not that simple though - I've have them all up and running before but for some reason I see that after a little that a string of them would turn on (an entire hub wont seem to connect, I have 9 hubs, of those 3 are daisy chained to a 4th.
Doesn't matter how complex your setup is, the error means the same thing. Often when something fails it can take out/reset a whole hub since the communication channel is shared.
6003  Bitcoin / Mining software (miners) / Re: CGMINER ASIC miner monitoring RPC linux/win/osx/mips/arm/r-pi 4.2.3 on: April 07, 2014, 03:58:44 AM
what does this mean?:

AMU 57 SendWork usb write err:(-9) LIBUSB_ERROR_PIPE

I'm getting hashrate to build up to 2/3rds the way then half of it shuts off and it stats to reload again until the cycle repeats.  Cannot get everything on and mining in harmony. 
It means there has been a fatal usb communication error and cgminer drops the device to allow it to restart again. You probably don't have enough power or dodgy connections etc.
6004  Bitcoin / Pools / Re: [6600 TH] BTC Guild - Pays TxFees+NMC, Stratum, VarDiff, Private Servers on: April 07, 2014, 03:16:57 AM
I wonder how much of this bad luck turn is due to external influences?

Somebody is DDOS eligius, and recently succeeded in a NMC payout hack against the pool. I also have noticed BTCGuild, Ghash and Blockchain showing the cloud flare error in the past few days.

A semi-well known fact about me:  my real life job includes DDoS mitigation at the ISP level for multiple ISPs.

This particular attack against Eligius has taken almost every form possible... UDP reflection attacks (DNS, NTP, SNMP, etc... 30+ gigabit at times), TCP SYN attacks (over 20 gigabit peaks), botnets directly flooding pool ports (multiple gigabit), botnets attempting application layer (stratum and HTTP) attacks (varies up to several gigabit and > 100k connections), HTTP request floods from botnets and other amplification (wordpress being one), hanging TCP connection attacks, various attack attempts against public facing bitcoinds, flood attacks against upstream routers, social engineering attempts (someone has contacted the abuse@ addresses for some nodes claiming Eligius is DoS attacking them, lol, presumably in an attempt to stir trouble with our hosts), and probably a ton of other things that are just automatically filtered/ignored.

https://bitcointalk.org/index.php?topic=441465.msg5986935#msg5986935

Luck for eligius and BTCGuild are both well under 100%
https://bitcointalk.org/index.php?topic=441465.msg6077549#msg6077549

Unknown pool is rapidly growing share, up to 33 34%
http://blockchain.info/pools?timespan=48hrs

And there maybe an unknown binary Merkle tree weakness being used (where the included transaction count are base 2). Now even if the weakness is theoretical, this is severely delaying confirmation times.

https://blockchain.info/blocks/80.241.217.46
http://www.reddit.com/r/Bitcoin/comments/22cohy/8024121746_mining_18_blocks_today_containing/
http://reddit.com/r/Bitcoin/comments/20y0nq/why_do_all_the_blocks_hashed_by_unknown_miners/

Would a faster-to-calculate power of 2 Merkle tree make a selfish attack slightly more effective ?


Luck has nothing to do with any of the above, it's just... luck.

The only thing that miners can do is a block withhold attack and without a PPS pay scheme the miners stand to lose if they do this, though with a large enough pool they may be willing to sacrifice some income leaving the other miners to subsidise their mining. Unlikely but not impossible. Theoretically pools may have implemented block withhold detection techniques but the pool ops would never reveal if they were not because that would then be opening themselves up to this attack. Attack is a very strong term though since there's so little to gain from doing this, it's not worth dwelling on it any more.

Merkle tree size choice has no effect on luck nor can it be used in any kind of attack. It's just a crappy optimisation for inefficient code.
6005  Bitcoin / Hardware / Re: NanoFury Project - Open Source Design on: April 07, 2014, 02:45:01 AM
I hope the NF* variants have a unique identifier on USB to make them easy to distinguish on USB.
The nanofury currently nicely identifies itself as:
Code:
iProduct                2 NanoFury NF1 v0.7
Managing variant devices is much easier when some forethought goes into it by the hardware devs thanks Wink
6006  Bitcoin / Hardware / Re: [ANN] Spondoolies-Tech launches a new line of ASIC miners - Best W/GH/s ratio on: April 06, 2014, 11:23:47 PM
SP-Tech recently contacted me asking for some advice regarding their driver development and then decided they would send me one of their SP10 devices, which I can confirm I have just received.
6007  Bitcoin / Mining software (miners) / Re: CGminer crashing on: April 06, 2014, 06:24:54 PM
New rig, worked fine out of the box. Decided to change mulipool address this morning and now the cgminer program won't open. Well, it opens for a split second then vanishes. It is the latest version available I believe - 3.7.2.

Any ideas what I'm doing wrong?
3.7.2 is over 6 months old. The latest version is 4.2.3, though you may be trying to GPU mine which has long since been deprecated and all support removed from cgminer.
6008  Bitcoin / Hardware / Re: Bitmain Antminer U2 on: April 06, 2014, 05:11:33 PM
Ok so do I just delete the entire icarus-options line outof the config or do I have to thange the value to something else
Delete icarus options and icarus timing entirely.
6009  Bitcoin / Hardware / Re: Bitmain Antminer U2 on: April 06, 2014, 05:02:01 PM

 My settings


My results

Hmm ok I am not a expert here and I just start playing with bitcoin stuff. As I mentioned before I use a Raspberry Pi with CGMiner Ver. 4.2.3 and one U2. So honsestly I dont have any idea what all the settings do. What I know is that I went thru alot of forums to find a answer;)

I know the numbers GH/s is high but the pool stats show only 1.3gh/s . Everybody in the web is just copies from forum to forum the same old stuff. Can somebody be so kind and explain their own settings if poss. using cgminer. The unit is cooled by a 120mm Tower fan i  riped out of a old tower, cut the cable and soldered it to a micro-USB charger cable.So the unit is pretty cool.
You are using icarus options inappropriately and telling cgminer to report double the hashrate. Don't use icarus options at all, they're totally not required with current cgminer and most people use them wrongly as you have.
6010  Bitcoin / Mining software (miners) / Re: CGMINER ASIC miner monitoring RPC linux/win/osx/mips/arm/r-pi 4.2.3 on: April 06, 2014, 08:26:25 AM
Hi, I have a question about the Cgminer API, and I hope this is the correct thread for these questions.

The Network Difficulty is reported by the Coin command, but if you have two pools with different coins, you don't know for which pool the Network Difficulty is reported. It looks like the Coin command reports the network difficulty for the pool/coin that had the last network difficulty change, but that isn't always the highest prioritized pool where you actually mine.

Isn't the Network Difficulty something that would be better to include in the Pool command, and specified for each pool?

Thanks for a great API and please let me know if I got all this wrong.
We don't care about anything but bitcoin so we have no interest in making changes for multiple coin support.
6011  Bitcoin / Hardware / Re: [ANN] NEW USB MINER - 5 Gh/s NANO FURY II USB MINER, **LOWER PRICE** on: April 05, 2014, 03:05:35 PM
Cgminer?  My linux box loathes bfgminer...

I am also eager to see support for them in cgminer but so far noone has added the code in it .. and the last time we checked with Con he indicated that he was busy with some other projects. So the best answer for now is that it will happen eventually but we don't know when.
Not so much busy as not having access to 2+ chip nanofury devices which is to be rectified shortly I believe due to hardware donation from yours truly, so support should be forthcoming in the next week.
6012  Bitcoin / Pools / Re: Stratum protocol discussion on: April 05, 2014, 02:52:45 PM
As someone who's working on a Stratum implementation right now, I must say this is a VERY narrow view of reality.

I've been using the following resources to gain my knowledge of the protocol:
https://bitcointalk.org/index.php?topic=55842.0
https://bitcointalk.org/index.php?topic=108533.0
http://mining.bitcoin.cz/stratum-mining
https://www.btcguild.com/new_protocol.php

Notice how 50% of those links were forum posts   Cheesy

But, I'm guessing none of the discussion here counts as documentation either and can be entirely ignored  Wink
Did you miss this sticky post?
https://bitcointalk.org/index.php?topic=557866.0
It's as close as it gets to the repository of the collated official documentation which was never written, only the draft proposal by slush which is quoted there.
6013  Bitcoin / Pools / Stratum protocol discussion on: April 05, 2014, 06:27:26 AM
BFGMiner (at least) will also send mining.suggest_target("hex target") upon connection, if the user has a preferred target.
Why would it do this?
There is already mining.suggest_difficulty(difficulty)
No, there isn't. Nothing implements this, and it isn't documented anywhere.

Using a target fixes the inherent problems with using difficulty as a Number:
  • There is no agreement over which difficulty measurement is to be used. The official spec says bdiff; BTCGuild uses pdiff; various scrypt pools use Ldiff
  • Some common targets (such as pdiff 1) cannot be accurately conveyed without huge data sizes
  • Implementing conversion to/from difficulty accurately requires a bignum library, so often (eg, *gminer) it is just approximated.
Seems like a valid concern to me since it was described over a year ago and yours isn't documented anywhere except as part of your code. Of course you're free to implement whatever you want on top of stratum. Cgminer happily works with any arbitrary diffs and does not have problems with the accuracy of the shares it returns in response, using true diff 1 as the base for all stratum operations. I wasn't aware there was any controversy about the move to true diff1; that old simplification only affected getwork. Since work in stratum is even defined in terms of difficulty, it makes even less sense to then request a difficulty as a target. I don't see a problem with you using it for your software and your pool but I can't see why it should be seen as part of the stratum spec.
6014  Bitcoin / Pools / Re: [ANN] Stratum mining protocol - ASIC ready on: April 05, 2014, 03:01:05 AM
I've created a new forum thread that tries to collate all relevant information in one place:

https://bitcointalk.org/index.php?topic=557866.0
6015  Bitcoin / Pools / Stratum protocol discussion on: April 05, 2014, 02:54:06 AM
Discussion goes here  Smiley
6016  Bitcoin / Pools / Re: Stratum protocol documentation on: April 05, 2014, 02:53:35 AM
Get transactions
Today I implemented and released to my pool new method called mining.get_transactions(job_id). This call simply dumps transactions used for given job. Thanks to this, miners now have everything needed to reconstruct source block template used by the pool and they can check online if pool isn't doing something nasty.

With this extension, Stratum is still the most optimized mining protocol, but also as open as GBT from the view that miners don't need to trust pool operator that he's not preparing some malicious attack with their hashpower. Anybody is welcome to write some tool for inspecting GBT/Stratum jobs; since now, there's no practical difference in "mining safety" between those two solutions.

Benefits of get_transactions call instead of sending transactions in job broadcast directly are:
* Lower stale ratio for everybody, because pool firstly broadcast just the job itself and *then* send full transactions to interested clients. Miner don't need to wait to full transaction list to start mining on new template.
* Lower bandwidth usage, because only users interested in block inspection will download the list of transactions
* Possibly lower bandwidth usage even for users doing template inspection, because they don't need to perform inspection on every job. Random checks will work as well, because pool never know who and when will ask for transaction list, so cheating is very unlikely.

Please note that sending of transaction list may become a paid feature on some pools, because it requires large amount of pool bandwidth, which is not required for mining itself. Tiny  fee for such additional feature may become an easy prevention against pool DoS.

Note discussion following this quote on the original thread regarding abusing this as a pool DoS and why no pools implement it. If they do, consider rate limiting it.

As per the discussion above with suggest_difficulty, a more logical evolution of this command has evolved placing the job_id in the params instead of the keyname.

eg:
Code:
{"id": 0, "method": "mining.get_transactions", "params":["545198de00000000"]}
6017  Bitcoin / Pools / Re: Stratum protocol documentation on: April 05, 2014, 02:53:23 AM
Alternative documentation from btcguild:

https://www.btcguild.com/new_protocol.php
Code:
 Summary

The Stratum protocol reduces client-server communications to levels that are usable with very low bandwidth, and reduces the strain on servers drastically.
The key concept behind Stratum based mining is "push" based work, where the server pushes work to the miner, and the miner is able to utilize that work until the next push, regardless of the hash rate.
This is done by allowing the miner to increase a counter in the coinbase transaction, and build a new merkleroot for the block header, which effectively means the miner generates new work continuously without contacting the server.
Additionally, this new protocol utilizes a single asynchronous socket connection for all communication, rather than opening/closing HTTP connections with each communication.



Building Local Work

The mining pool provides a miner with two pieces of information upon connecting. The first is ExtraNonce1. The second piece of information is ExtraNonce2_size. This is how many bytes should be used for the ExtraNonce2 counter. ExtraNonce2 is a hexadecimal counter, and should be padded to fill up the number of bytes identified as the ExtraNonce2_size.

When the pool pushes work, it provides the coinbase transaction in two pieces. When the miner is building the block header to hash, it builds a merkleroot by creating a coinbase transaction. This is done by combining: Coinbase1 + ExtraNonce1 + ExtraNonce2 (padded) + Coinbase2.

This transaction is then passed through a double SHA256 to get the coinbase tx hash. You then combine that with first merkle branch provided by the work (if any), and double SHA256 the combined string. You then take that result, and do the same with the next merkle branch, repeating this process until all merkle branch hashes have been combined with previous results.

This process creates a unique merkle root for the new block header, which can then be pushed through the miner using the standard 32-bit nonce counter.



Initial Connection Communication

Client: {"id": 1, "method": "mining.subscribe", "params": []}\n
Server:  {"id": 1, "result": [["mining.notify", "ae6812eb4cd7735a302a8a9dd95cf71f"], "08000002", 4], "error": null}\n

Connection uses 'mining.subscribe' to subscribe to work from the server.
Server result response contains:
result[0] = "mining.notify", "ae6812eb4cd7735a302a8a9dd95cf71f" - Unique string used for the subscription
result[1] = ExtraNonce1, used for building the coinbase.
result[2] = Extranonce2_size, the number of bytes that the miner users for its ExtraNonce2 counter



Server Work Communication

Server: {"params": ["bf", "4d16b6f85af6e2198f44ae2a6de67f78487ae5611b77c6c0440b921e00000000",
"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff20020862062f503253482f04b8864e5008",
"072f736c7573682f000000000100f2052a010000001976a914d23fcdf86f7e756a64a7a9688ef9903327048ed988ac00000000",
["c5bd77249e27c2d3a3602dd35c3364a7983900b64a34644d03b930bfdb19c0e5","049b4e78e2d0b24f7c6a2856aa7b41811ed961ee52ae75527df9e80043fd2f12"],
"00000002", "1c2ac4af", "504e86b9", false], "id": null, "method": "mining.notify"}\n

This is sent at regular intervals by the server. It should be sent almost immediately after an acknowledge subscription.
Work pushes contain:
params[0] = Job ID. This is included when miners submit a results so work can be matched with proper transactions.
params[1] = Hash of previous block. Used to build the header.
params[2] = Coinbase (part 1). The miner inserts ExtraNonce1 and ExtraNonce2 after this section of the coinbase.
params[3] = Coinbase (part 2). The miner appends this after the first part of the coinbase and the two ExtraNonce values.
params[4][] = List of merkle branches. The coinbase transaction is hashed against the merkle branches to build the final merkle root.
params[5] = Bitcoin block version, used in the block header.
params[6] = nBit, the encoded network difficulty. Used in the block header.
params[7] = nTime, the current time. nTime rolling should be supported, but should not increase faster than actual time.
params[8] = Clean Jobs. If true, miners should abort their current work and immediately use the new job. If false, they can still use the current job, but should move to the new one after exhausting the current nonce range.



Worker Authorization

Client: {"params": ["eleuthria_miner1", "password"], "id": 2, "method": "mining.authorize"}\n
Server: {"error": null, "id": 2, "result": true}\n

Client authorizes a worker using the method "mining.authorize". Client request contains:
params[0] = Worker Name
params[1] = Worker Password (can be "" or omitted if server does not require passwords)

Server response is "result": true for successful authorization, "result": false for unsuccessful authorization.



Work Submissions

Client: {"params": ["eleuthria_miner1", "bf", "00000001", "504e86ed", "b2957c02"], "id": 4, "method": "mining.submit"}\n
Server: {"error": null, "id": 4, "result": true}\n

Miners submit shares using the method "mining.submit".
Client submissions contain:
params[0] = Worker Name
params[1] = Job ID
params[2] = ExtraNonce 2
params[3] = nTime
params[4] = nonce
Server response is result: true for accepted, false for rejected.



Difficulty Adjustment

Server: { "id": null, "method": "mining.set_difficulty", "params": [2]}\n

The server can adjust the difficulty required for miner shares with the "mining.set_difficulty" method.
The miner should begin enforcing the new difficulty on the next job received. Some pools may force a new job out when set_difficulty is sent, using clean_jobs to force the miner to begin using the new difficulty immediately.



Cheat Sheet

Methods:
mining.subscribe     : Used to subscribe to work from a server, required before all other communication.
mining.authorize     : Used to authorize a worker, required before any shares can be submitted.
mining.notify        : Used to push new work to the miner.  Previous work should be aborted if Clean Jobs = true!
mining.submit        : Used to submit shares
mining.set_difficulty: Used to signal the miner to stop submitting shares under the new difficulty.
6018  Bitcoin / Pools / Re: Stratum protocol documentation on: April 05, 2014, 02:52:38 AM
Documentation from Slush's site:
http://mining.bitcoin.cz/stratum-mining

Code:
For mining software developers

Stratum protocol is based on JSON-RPC 2.0. In this chapter I expect that you're familiar with this protocol and you understand terms like "request", "response" and "notification". Please read JSON-RPC specification for more details.

For high level image of the Stratum protocol concept, please read Stratum protocol specification on Google docs. This document needs some care, but give you the basic examples how to connect to Stratum server.
Exception handling

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

{"id": 10, "result": null, "error": (21, "Job not found", null)}

Where 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 difficulty share
    24 - Unauthorized worker
    25 - Not subscribed

Real-world example

This chapter contains real log of miner-pool communication which solved testnet3 block 000000002076870fe65a2b6eeed84fa892c0db924f1482243a6247d931dcab32
Miner connects the server

On the beginning of the session, client subscribes current connection for receiving mining jobs:

{"id": 1, "method": "mining.subscribe", "params": []}\n
{"id": 1, "result": [[["mining.set_difficulty", "b4b6693b72a50c7116db18d6497cac52"], ["mining.notify", "ae6812eb4cd7735a302a8a9dd95cf71f"]], "08000002", 4], "error": null}\n

Reminder: The newline character \n is a part of the message and must be added to the end of *every* JSON message. Server may wait to this magic character to start processing the message. This is the most common mistake which people implementing line-based clients do!

The result contains three items:

    Subscriptions details - 2-tuple with name of subscribed notification and subscription ID. Teoretically it may be used for unsubscribing, but obviously miners won't use it.
    Extranonce1 - Hex-encoded, per-connection unique string which will be used for coinbase serialization later. Keep it safe!
    Extranonce2_size - Represents expected length of extranonce2 which will be generated by the miner.

Authorize workers

Now let authorize some workers. You can authorize as many workers as you wish and at any time during the session. In this way, you can handle big basement of independent mining rigs just by one Stratum connection.

{"params": ["slush.miner1", "password"], "id": 2, "method": "mining.authorize"}\n
{"error": null, "id": 2, "result": true}\n

Server start sending notifications with mining jobs

Server sends one job *almost* instantly after the subscription.

Small engineering note: There's a good reason why first job is not included directly in subscription response - miner will need to handle one response type in two different way; firstly as a subscription response and then as a standalone notification. Hook job processing just to JSON-RPC notification sounds a bit better to me.

{"params": ["bf", "4d16b6f85af6e2198f44ae2a6de67f78487ae5611b77c6c0440b921e00000000",
"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff20020862062f503253482f04b8864e5008",
"072f736c7573682f000000000100f2052a010000001976a914d23fcdf86f7e756a64a7a9688ef9903327048ed988ac00000000", [],
"00000002", "1c2ac4af", "504e86b9", false], "id": null, "method": "mining.notify"}

Now we finally have some interesting stuff here! I'll descibe every field of the notification in the particular order:

    job_id - ID of the job. Use this ID while submitting share generated from this job.
    prevhash - Hash of previous block.
    coinb1 - Initial part of coinbase transaction.
    coinb2 - Final part of coinbase transaction.
    merkle_branch - List of hashes, will be used for calculation of merkle root. This is not a list of all transactions, it only contains prepared hashes of steps of merkle tree algorithm. Please read some materials for understanding how merkle trees calculation works. Unfortunately this example don't have any step hashes included, my bad!
    version - Bitcoin block version.
    nbits - Encoded current network difficulty
    ntime - Current ntime/
    clean_jobs - When true, server indicates that submitting shares from previous jobs don't have a sense and such shares will be rejected. When this flag is set, miner should also drop all previous jobs, so job_ids can be eventually rotated.

How to build coinbase transaction

Now miner received all data required to serialize coinbase transaction: Coinb1, Extranonce1, Extranonce2_size and Coinb2. Firstly we need to generate Extranonce2 (must be unique for given job_id!). Extranonce2_size tell us expected length of binary structure. Just be absolutely sure that your extranonce2 generator always produces extranonce2 with correct length! For example my pool implementation sets extranonce2_size=4, which mean this is valid Extranonce2 (in hex): 00000000.

To produce coinbase, we just concatenate Coinb1 + Extranonce1 + Extranonce2 + Coinb2 together. That's all!

For following calculations we have to produce double-sha256 hash of given coinbase. In following snippets I'm using Python, but I'm sure you'll understand the concept even if you're a rubyist! It is as simple as:

import hashlib
import binascii
coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest()

How to build merkle root

Following Python snippet will generate merkle root for you. Use merkle_branch from broadcast and coinbase_hash_bin from previous snippet as an input:

import binascii

def build_merkle_root(self, merkle_branch, coinbase_hash_bin):
    merkle_root = coinbase_hash_bin
    for h in self.merkle_branch:
        merkle_root = doublesha(merkle_root + binascii.unhexlify(h))
    return binascii.hexlify(merkle_root)

How to build block header?

Now we're almost done! We have to put all together to produce block header for hashing:

version + prevhash + merkle_root + ntime + nbits + '00000000' +
'000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000'

First zeroes are blank nonce, the rest is padding to uint512 and it is always the same.

Note that merkle_root must be in reversed byte order. If you're a miner developer, you already have util methods there for doing it. For some example in Python see Stratum mining proxy source codes.
Server can occasionally ask miner to change share difficulty

Default share difficulty is 1 (big-endian target for difficulty 1 is 0x00000000ffff0000000000000000000000000000000000000000000000000000), but server can ask you anytime during the session to change it:
{ "id": null, "method": "mining.set_difficulty", "params": [2]}

This means that difficulty 2 will be applied to every next job received from the server.
How to submit share?

When miner find the job which meets requested difficulty, it can submit share to the server:

{"params": ["slush.miner1", "bf", "00000001", "504e86ed", "b2957c02"], "id": 4, "method": "mining.submit"}
{"error": null, "id": 4, "result": true}

Values in particular order: worker_name (previously authorized!), job_id, extranonce2, ntime, nonce.

6019  Bitcoin / Pools / Re: Stratum protocol documentation on: April 05, 2014, 02:50:37 AM
Managing difficulty changes
I have read the discussion about separating target/difficulty and work data. I have to say I think this was a mistake as it opens possibilities for abuse. I think something about these issues should go in the docs. Otherwise someone is going to create a naive implementation with some nasty issues.

Well, after discussion with Kano I slightly changed my mind. As I described few posts ago, with slightly modified meaning of "set difficulty" message, everything should be fixed.

Instead of meaning "stop sending lower difficulty shares than X immediately", set_difficulty should mean "all next jobs are using difficulty X". This still keeps the concept of separated difficulty message from the job itself, it doesn't require sending both messages together, fixes the problem of roundtrips (sending some bad-diff shares by the client because of latency) etc. It also gives the possibility to choose if pool wants to change difficulty in aggressive or in lazy way; by just sending "set difficulty" message without new job with clean_jobs=True, clients will slowly adopt higher difficulty as miners will start using new jobs, but pool can enforce higher difficulty with immediate effect by sending clean_jobs=True, as it is now.

This change in protocol is also backward compatible, because pools using current meaning of set_difficulty don't need to change anything, they just *may* stop sending clean_jobs job, if they want. Because of this, it is win-win solution for me. I described this already, but the idea didn't get any significant attention yet.

Quote
Is it ok to pipeline commands to the client? That is, send the difficulty change and new work (2 RPC calls) in quick succession without waiting for a reply to the first.

Yes, commands (notifications) can be pipelined. set_difficulty() and notify() don't expect any response from the client. Just sending one packet with both commands serialized is possible.
6020  Bitcoin / Pools / Re: Stratum protocol documentation on: April 05, 2014, 02:50:14 AM
Reconnect support
Ok for those not watching the discussion on #stratum on IRC, I believe we have a final protocol for mining resume which should not break any clients or pools.

It was decided that the parameters could include both the user agent and the session ID as the first and second parameters. If this fails cgminer/other clients should resort to sending blank set of parameters as previously.

The session Id, it was decided, would be encoded along with the notification message "mining.notify" as a member of the 3 deep array parameters returned for "result" by the pool.

See the following for an example of an initial connect followed by a reconnect.
Code:
 [2013-02-25 10:30:58] SEND: {"id": 0, "method": "mining.subscribe", "params": ["cgminer/2.10.5"]}
 [2013-02-25 10:30:58] RECVD: {"result": [[["mining.notify", "02000000b507a8fd1ea2b7d9cdec867086f6935228aba1540154f83930377ea5a2e37108"], ["mining.set_difficulty", "02000000b507a8fd1ea2b7d9cdec867086f6935228aba1540154f83930377ea5a2e371082"]], "02000000", 4], "id": 0, "error": null}
 [2013-02-25 10:30:58] Pool 0 stratum session id: 02000000b507a8fd1ea2b7d9cdec867086f6935228aba1540154f83930377ea5a2e37108
 [2013-02-25 10:30:58] Pool 0 confirmed mining.subscribe with extranonce1 02000000 extran2size 4

 [2013-02-25 10:33:00] SEND: {"id": 2, "method": "mining.subscribe", "params": ["cgminer/2.10.5", "02000000b507a8fd1ea2b7d9cdec867086f6935228aba1540154f83930377ea5a2e37108"]}
 [2013-02-25 10:33:00] RECVD: {"result": [[["mining.notify", "02000000c33cfaa37a964c2ba76c78b99dc170a1b1fe7a5fe025f72e89afba7fc6f23d0e"], ["mining.set_difficulty", "02000000c33cfaa37a964c2ba76c78b99dc170a1b1fe7a5fe025f72e89afba7fc6f23d0e2"]], "02000000", 4], "id": 2, "error": null}
 [2013-02-25 10:33:00] Pool 0 stratum session id: 02000000c33cfaa37a964c2ba76c78b99dc170a1b1fe7a5fe025f72e89afba7fc6f23d0e
 [2013-02-25 10:33:00] Pool 0 confirmed mining.subscribe with extranonce1 02000000 extran2size 4
Note the session ID has changed between the initial subscription and the resume, BUT the extranonce1 has remained the same. This tells the miner it can (re)submit shares before the disconnection.

Hopefully we will not need to revise this any further.
Pages: « 1 ... 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 [301] 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 ... 570 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!