Bitcoin Forum
May 04, 2024, 06:33:57 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Determining a Block's Extranonce Value  (Read 1270 times)
Geremia (OP)
Sr. Member
****
Offline Offline

Activity: 502
Merit: 251


View Profile WWW
March 14, 2015, 01:22:31 AM
 #1

How do I determine a block's extranonce value? I know they are in the coinbase transaction, but where?

BTC tip jar | my BTC wiki, BTC StackExchange | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
1714804437
Hero Member
*
Offline Offline

Posts: 1714804437

View Profile Personal Message (Offline)

Ignore
1714804437
Reply with quote  #2

1714804437
Report to moderator
1714804437
Hero Member
*
Offline Offline

Posts: 1714804437

View Profile Personal Message (Offline)

Ignore
1714804437
Reply with quote  #2

1714804437
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714804437
Hero Member
*
Offline Offline

Posts: 1714804437

View Profile Personal Message (Offline)

Ignore
1714804437
Reply with quote  #2

1714804437
Report to moderator
laurentmt
Sr. Member
****
Offline Offline

Activity: 384
Merit: 258


View Profile
March 14, 2015, 03:25:53 PM
Last edit: March 14, 2015, 03:54:54 PM by laurentmt
 #2

The extranonce can be found in the coinbase data from a coinbase transaction.
This data can be interpreted as a script pushing data onto the stack and the extranonce is the second value.

Example
Quote
{
   ...
    "vin" : [
        {
            "coinbase" : "03443b0403858402062f503253482f",
            "sequence" : 4294967295
        }
    ],
   ...
}

can be interpreted as:
03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack <-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack <-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack <-- arbitrary data

EDIT: This format was defined by BIP34 and applies to blocks with version >= 2. I'm not sure how the extranonce was managed before that.
Geremia (OP)
Sr. Member
****
Offline Offline

Activity: 502
Merit: 251


View Profile WWW
March 14, 2015, 03:56:30 PM
Last edit: March 14, 2015, 04:08:13 PM by Geremia
 #3

Example
Quote
{
   ...
    "vin" : [
        {
            "coinbase" : "03443b0403858402062f503253482f",
            "sequence" : 4294967295
        }
    ],
   ...
}

can be interpreted as:
03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack <-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack <-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack <-- arbitrary data
I thought the extranonce was 8 bytes.

BTC tip jar | my BTC wiki, BTC StackExchange | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
laurentmt
Sr. Member
****
Offline Offline

Activity: 384
Merit: 258


View Profile
March 14, 2015, 05:25:43 PM
Last edit: March 14, 2015, 06:06:00 PM by laurentmt
 #4

I thought the extranonce was 8 bytes.
My guess is that the extranonce is 8 bytes max but is stored with a compressed representation for lower values.

The extranonce is outside the scope of the bitcoin protocol (BIP34 doesn't say anything about it) and it seems hard to find reliable information about how mining pools manage the coinbase data. Actually, I think different mining pools may enforce different formats.
I've found some sources indicating the 2nd value as the extranonce but I suspect that it's only true for some clients (bitcoind ?).

Investigation in progress...

EDIT:
After some forum archeology, I've found this interesting post related to a study done by Sergio_Demian_Lerner about extranonces.
It seems to confirm the script structure with the extranonce being the second value pushed onto the stack. I was puzzled by the first value but it may be the same value as the bits fields stored in the header.

Geremia (OP)
Sr. Member
****
Offline Offline

Activity: 502
Merit: 251


View Profile WWW
March 14, 2015, 07:25:27 PM
 #5

On #eligius I asked Luke-Jr, operator of Eligius pool, and he said:
Quote
[12:08] <@Luke-Jr> throwing it on the end of the coinbase
[12:08] <@Luke-Jr> or in the middle
[12:08] <@Luke-Jr> I think most stratum pools use the end of it
[12:08] <@Luke-Jr> p2pool abuses an output
[12:09] <@Luke-Jr> GBT pools let miners put anything on the end, and at least BFGMiner does <extranonce><miner version>
It seems pretty arbitrary, then.

He also said that the BitcoinTalk post you cited is outdated.

BTC tip jar | my BTC wiki, BTC StackExchange | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
nickodell
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
March 14, 2015, 07:36:13 PM
 #6

EDIT: This format was defined by BIP34 and applies to blocks with version >= 2. I'm not sure how the extranonce was managed before that.
I wrote a summary of how the coinbase scriptSig has changed over time here.
You've pretty much got it right.
laurentmt
Sr. Member
****
Offline Offline

Activity: 384
Merit: 258


View Profile
March 14, 2015, 07:57:39 PM
 #7

I wrote a summary of how the coinbase scriptSig has changed over time here.
You've pretty much got it right.
Thanks. It's bookmarked ! Smiley

It seems pretty arbitrary, then.
Yep !

He also said that the BitcoinTalk post you cited is outdated.
It is. I've linked this thread because I thought you might be interested by formats used in older blocks (before BIP34). It was just an inference from your previous post about nonces & hash values. My apologies if I was wrong.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!