Bitcoin Forum
May 11, 2024, 10:51:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Blocknumber not part of the header  (Read 253 times)
Tym (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 14


View Profile
April 03, 2020, 10:03:45 AM
 #1

Hello,

compared to Ethereum there is no field "blocknumber" in a bitcoin-header. Only full nodes can verify a blocknumber since they know the whole chain.

My question: Is there some kind of an agreement out there (i.e. a BIP) which tells that the blocknumber should be stored for example in the "extra data"-field within the coinbase transaction?

I want to verify the blocknumber as a client which doesn't have full access to the chain.

I would love to read your answers.

Thanks,
Tym
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715424673
Hero Member
*
Offline Offline

Posts: 1715424673

View Profile Personal Message (Offline)

Ignore
1715424673
Reply with quote  #2

1715424673
Report to moderator
1715424673
Hero Member
*
Offline Offline

Posts: 1715424673

View Profile Personal Message (Offline)

Ignore
1715424673
Reply with quote  #2

1715424673
Report to moderator
nc50lc
Legendary
*
Offline Offline

Activity: 2408
Merit: 5595


Self-proclaimed Genius


View Profile
April 03, 2020, 10:19:24 AM
Merited by Quickseller (3), gmaxwell (2), darosior (2), pooya87 (1), ABCbits (1), A-Bolt (1)
 #2

My question: Is there some kind of an agreement out there (i.e. a BIP) which tells that the blocknumber should be stored for example in the "extra data"-field within the coinbase transaction?
BIP34, looks like you already knew the answer prior to posting this question because your guess too specific :p
For the "blocknumber", the equivalent must be bitcoin's "block height".

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
April 03, 2020, 10:19:36 AM
 #3

I believe the reason that "blocknumber" (aka Height) is not used as an identifier is explained by this:
Since multiple blocks can have the same height during a block chain fork, block height should not be used as a globally unique identifier. Instead, blocks are usually referenced by the hash of their header (often with the byte order reversed, and in hexadecimal).

So, as stated, the unique identifier for a given block is the hash of the header.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Tym (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 14


View Profile
April 03, 2020, 10:50:40 AM
 #4

My question: Is there some kind of an agreement out there (i.e. a BIP) which tells that the blocknumber should be stored for example in the "extra data"-field within the coinbase transaction?
BIP34, looks like you already knew the answer prior to posting this question because your guess too specific :p
For the "blocknumber", the equivalent must be bitcoin's "block height".

Thanks! Thats what i was looking for Wink
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10558



View Profile
April 04, 2020, 04:31:05 AM
 #5

I want to verify the blocknumber as a client which doesn't have full access to the chain.

if you mean as an SPV client then you still have to take additional steps to "verify" the block height because SPV clients only download block headers which does  not contain any block header field. so you have to download the first transaction of the block (aka coinbase transaction) and then decode its signature script to get the height.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4172
Merit: 8419



View Profile WWW
April 04, 2020, 02:08:17 PM
Merited by darosior (2), ABCbits (1)
 #6

Only full nodes can verify a blocknumber since they know the whole chain.
In addition to the other excellent responses you've received here, SPV nodes (lite clients) also know the height even without BIP34 because they process all the prior headers too.  If they didn't they'd have no clue about the appropriate difficulty or total work in the chain, and so they couldn't validate the header.
Tym (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 14


View Profile
April 06, 2020, 02:24:40 PM
 #7

if you mean as an SPV client then you still have to take additional steps to "verify" the block height because SPV clients only download block headers which does  not contain any block header field. so you have to download the first transaction of the block (aka coinbase transaction) and then decode its signature script to get the height.

Hello pooya87,

I just read your answer.
You said: "then decode its signature script to get the height"

Would you mind explaining this step more detailed to me?

I'd love to read your answer! Thanks!
Tym
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10558



View Profile
April 06, 2020, 03:47:34 PM
Merited by HCP (5), ABCbits (3)
 #8

You said: "then decode its signature script to get the height"
Would you mind explaining this step more detailed to me?

after block number 227,835 all blocks must include the block height in their coinbase transaction. they do it by including the number in their only input's signature script. if you are unfamiliar with transaction structure and scripts read [1] and [2].
numbers exist as bytes inside a script and bytes should be pushed to the stack with the appropriate push OP code. this push must be the first pushed item and the rest can be anything.
example from last block: https://blockchair.com/bitcoin/transaction/02d8cdb103f50532e2f18d9d1f85c016468ee0294908d387e38f80b99410d893
signature script is:
Code:
03348809041f4e8b5e7669702f7777772e6f6b65782e636f6d2ffabe6d6db388905769d4e3720b1e59081407ea75173ba3ed6137d32308591495198155ce020000004204cb9a2a31601215b2ffbeaf1c4e00
decoding this script is like this:
03 -> push following 3 bytes
348809 -> in little endian = 624692
041f... -> the rest can be anything

[1] https://bitcoin.org/en/developer-reference#transactions
[2] https://en.bitcoin.it/wiki/Script

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Tym (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 14


View Profile
April 07, 2020, 07:14:26 AM
 #9

Thank you so much @pooya87!
Appreciate it!
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!