Bitcoin Forum
May 05, 2024, 02:48:59 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Question about bitcoin nodes  (Read 1529 times)
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
June 29, 2017, 02:41:40 PM
Merited by ABCbits (4)
 #21

Thank you, i think i'm better understanding now.

So, if i made a transaction, send it to a node, this node checks if the transaction is correct, and broadcast it to other nodes, right?

Correct.  And those nodes broadcast it to other nodes, and so on until nearly the entire network is aware of the transaction.  This is how the transaction gets from you to the wallet that you are sending to, and it is how the transaction gets from you to the miners.

When you broadcast the transaction, it is "unconfirmed".  It is "valid", or else the nodes wouldn't relay it, but if you were a scammer it would be possible for you to transmit 2 different transactions that spend the exact same bitcoins to different nodes on the network at the exact same time.  Then nodes wouldn't know which is the "REAL" transaction, and which is the invalid one.  They can't just assume that the one they get first is the REAL one since different nodes would get different transactions first.  The network needs a way to reach a consensus agreement on which transaction to treat as the REAL transaction.  This is what the blockchain is for.

And in which moments the miner comes in?

The miner software chooses unconfirmed VALID transactions that it knows about and combines them into a block of data with a header.  Then it begins the proof-of-work process.  The block won't be considered valid by the network until the proof-of-work is complete. The first miner that completes the proof-of-work gets to broadcast his VALID block to all the peers that he is connected to.  They check to make sure it is valid and then relay the block to all the nodes they are connected to.  Thie relay process continues until all nodes on the network are aware of the new block.  Once a transaction is in a block, it is "CONFIRMED" and is considered to be the "REAL" transaction.  Any other unconfirmed transaction on the network that tries to spend those same bitcoins is then considered to be INVALID and it ignored and removed from memory by any nodes that receive or are storing the invalid unconfirmed transaction.

This is how the network reaches a consensus agreement on which transaction is REAL and which is INVALID.

Now, it is possible that two different miners each mine different blocks with competing transactions spending the same bitcoins.  Each node will accept whichever of these two blocks they receive first.  Some miners will receive one of the blocks, other miners will receive the other.  Since the blocks are at the same height in the chain (same total proof-of-work in the chain), each miner will just accept the first valid block it receives and will start building a new block on top of that.  There will be a temporary fork in the chain with two different blocks at the same height. Eventually a miner will solve a next block and will broadcast it.  All miners that were working on top of the same block will just accept this new block as an extension of their chain and will continue as normal.  Any miners that were working on top of the OTHER block will see that this new block is part of a longer chain now.  They will abandon the block they are working on AND the previous block that they had accepted, and replace them with the two blocks from this longer chain. They will then start working on a new block on top of these two that they've just accepted.  In that way the network eventually reaches consensus on which chain is the correct one.


Should the miner not mine it first before a node broadcast this transaction?

The miner doesn't know about the transaction until it has been broadcast and relayed to him.

How do the miner know that there is a new block?

They receive it from one of their peer nodes, which received it from one of their peer nodes, which received it from one of their peer nodes, which received . . .  which received it form the miner that completed the proof-of-work on the block.

is the miner connected to all nodes?

No.  The miner is just running a peer node in the decentralized network, just like any other node.  He just happens to ALSO be assembling blocks to work on from the list of unconfirmed transactions he knows about and performing the hash proof-of-work.
1714920539
Hero Member
*
Offline Offline

Posts: 1714920539

View Profile Personal Message (Offline)

Ignore
1714920539
Reply with quote  #2

1714920539
Report to moderator
1714920539
Hero Member
*
Offline Offline

Posts: 1714920539

View Profile Personal Message (Offline)

Ignore
1714920539
Reply with quote  #2

1714920539
Report to moderator
1714920539
Hero Member
*
Offline Offline

Posts: 1714920539

View Profile Personal Message (Offline)

Ignore
1714920539
Reply with quote  #2

1714920539
Report to moderator
I HATE TABLES I HATE TABLES I HA(╯°□°)╯︵ ┻━┻ TABLES I HATE TABLES I HATE TABLES
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714920539
Hero Member
*
Offline Offline

Posts: 1714920539

View Profile Personal Message (Offline)

Ignore
1714920539
Reply with quote  #2

1714920539
Report to moderator
1714920539
Hero Member
*
Offline Offline

Posts: 1714920539

View Profile Personal Message (Offline)

Ignore
1714920539
Reply with quote  #2

1714920539
Report to moderator
1714920539
Hero Member
*
Offline Offline

Posts: 1714920539

View Profile Personal Message (Offline)

Ignore
1714920539
Reply with quote  #2

1714920539
Report to moderator
redigaffi (OP)
Member
**
Offline Offline

Activity: 142
Merit: 13


View Profile
June 30, 2017, 07:35:13 AM
 #22

Hey,

So a miner just acts like another node, right? And receives blocks from broadcasted from other nodes?

But this is unfair, that means that a transaction would only arrive to some miner, not to all, right?

Or does the miner broadcast the transaction before mining it again?

Or a node broadcast a transaction to many other nodes, that eventually are miners?




Earn Money With Skill while having fun, Answer this 6 questions and get a bonus when the project get's launched:

https://docs.google.com/forms/d/e/1FAIpQLSdCRubC4wu4seHYdDqiZDFsXizqaViUnOtE5sZcx3spjGc84A/viewform
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
June 30, 2017, 12:15:34 PM
Merited by ABCbits (2)
 #23

Hey,

So a miner just acts like another node, right? And receives blocks from broadcasted from other nodes?

Those that are solo-mining?  Yes.

Pool mining is a bit different as I've mentioned above:
Mining is now commonly broken into two parts.  A mining pool that is running a full node builds blocks of transactions and the associated header, then the pool sends the block header to participants that do the hash work on the header to find a valid nonce.  The hashing participants don't need to have a full node.  The mining pool is effectively just renting the hash power from the hashing participants.

So in that case the mining pool "acts like another node" and "receives blocks from broadcasted from other nodes". The hashing participants (that like to call themselves "miners" are just receiving the block header from the pool and performing the proof-of-work on it.

But this is unfair, that means that a transaction would only arrive to some miner, not to all, right?

It will arrive to most miners.  The transaction is relayed from peer to peer.  As long as a miner is connected to peers, they should receive the transaction.  Why is that unfair?

Or does the miner broadcast the transaction before mining it again?

The solo-miner (or pool) is operating a full node, so they are relaying it to all the peers that they are connected to, just like any other node would.  Even if they decided to be malicious and not relay the transaction, it would simply be relayed by other nodes until it got to the other miners.

Or a node broadcast a transaction to many other nodes, that eventually are miners?

A node sends the transaction to EVERY node which it is connected to that has not yet received it. Nodes are frequently connected to hundreds or even thousands of other nodes.

redigaffi (OP)
Member
**
Offline Offline

Activity: 142
Merit: 13


View Profile
June 30, 2017, 01:06:06 PM
 #24

Cool, bitcoin technology is so awesome. Thank you very much. This concepts are so complex.

are the wallet/balances stored in the synced blockchain too?

thanks!

Earn Money With Skill while having fun, Answer this 6 questions and get a bonus when the project get's launched:

https://docs.google.com/forms/d/e/1FAIpQLSdCRubC4wu4seHYdDqiZDFsXizqaViUnOtE5sZcx3spjGc84A/viewform
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
June 30, 2017, 04:05:26 PM
 #25

- snip -
are the wallet/balances stored in the synced blockchain too?
- snip -

As I already mentioned earlier in this conversation:

- snip -
There are no balances in the blockchain, ONLY transactions (and a header for each block).
- snip -

If a wallet wants to know how much value it has control over, it needs to find all the transactions in the blockchain that create outputs which haven't yet been spent that it can satisfy and then add up the values of all those outputs.

Full nodes keep a running list of transaction outputs that haven't been spent yet as they synchronize. Then they update that list when receiving transactions and blocks from peers. That way they only need to scan the full blockchain once, and can search through their indexed list of unspent transaction outputs after that.  The list of Unspent Transaction Outputs that a node is aware of is commonly called the UTXO.
Pages: « 1 [2]  All
  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!