Pages:
Author

Topic: Question about bitcoin nodes (Read 1519 times)

legendary
Activity: 3472
Merit: 4801
June 30, 2017, 11:05:26 AM
#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.
member
Activity: 142
Merit: 13
June 30, 2017, 08:06:06 AM
#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!
legendary
Activity: 3472
Merit: 4801
June 30, 2017, 07:15:34 AM
#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.

member
Activity: 142
Merit: 13
June 30, 2017, 02: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?



legendary
Activity: 3472
Merit: 4801
June 29, 2017, 09:41:40 AM
#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.
member
Activity: 142
Merit: 13
June 29, 2017, 08:09:32 AM
#20
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?

And in which moments the miner comes in? Should the miner not mine it first before a node broadcast this transaction?

How do the miner know that there is a new block? is the miner connected to all nodes?
legendary
Activity: 3472
Merit: 4801
June 28, 2017, 01:25:17 PM
#19
Hey, thanks all for the help.

And what type of blocks are available?  i though the only "block" is a transaction of bitcoins (?)

recently i've seen an implementation of a blockchain with nodejs, called naiveChain, my question is that the class block haven't any btc input and ouputs, why? what different types of blocks are there?

In Bitcoin, a block is a set of one or more valid transactions with an 80 byte header.

The header consists of:
  • Version number (4 bytes)
  • Hash of the previous block in the chain (32 bytes)
  • Merkle root of the list of transactions (32 bytes)
  • Timestamp (4 bytes)
  • Difficulty target (4 bytes)
  • Nonce (4 bytes)

Between, a "full node" doens't mine or does it?

It is possible to be a full node on the peer-to-peer network without mining.  In that case you:
  • Receive transactions
  • Receive blocks
  • Check the validity of transactions
  • Check the validity of blocks
  • Store blocks locally to provide to peer nodes on request
  • Relay transactions to the peer nodes you are connected to
  • Relay blocks to the peer nodes you are connected to
  • Maintain a list if IP addresses of nodes on the network that you have either connected to or hear about from peer nodes

If you are solo-mining (the only way to mine originally), then you need to have a full node so that you can receive transactions, blocks, and build valid blocks.

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.
staff
Activity: 3458
Merit: 6793
Just writing some code
June 28, 2017, 01:10:48 PM
#18
Hey, thanks all for the help.

And what type of blocks are available?  i though the only "block" is a transaction of bitcoins (?)
In Bitcoin, there is only one type of block. Blocks are a collection of transactions, not a transaction themselves.
member
Activity: 142
Merit: 13
June 28, 2017, 01:02:23 PM
#17
Hey, thanks all for the help.

And what type of blocks are available?  i though the only "block" is a transaction of bitcoins (?)

recently i've seen an implementation of a blockchain with nodejs, called naiveChain, my question is that the class block haven't any btc input and ouputs, why? what different types of blocks are there?

https://github.com/lhartikk/naivechain/blob/master/main.js

Between, a "full node" doens't mine or does it?
legendary
Activity: 3472
Merit: 4801
June 28, 2017, 07:34:06 AM
#16
It's not my intention, i just want to view different "angles" because it's a hard concept and i can't really imagina this "decentralized" money system, in reality, the first node would be the master node,  also the "central" server, atleast for the next nodes.

The first node won't be a "master node", it will be the ONLY node.

The first node is only a "central server" for the second node, and it is only the "central server" until the second node has a full copy of the existing blockchain.  Once it has the blockchain the second node can start mining, and if it does then the first node and the second node will be equal peers.  Neither will be "master".

Every "full node" has its own copy of the blockchain.

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

You are also missing the purpose of mining.

A node that is not mining new blocks cannot modify anything in the blockchain, it can only receive new blocks (and transactions) from peers, check if those blocks (and transactions) are valid, add the valid blocks to its own copy of the blockchain (and share those blocks and transactions with other peers).

Each full node downloads and stores an entire copy of the blockchain from its peers.

If you create a new bitcoin-like currency, and you are the only one that knows about it, then you can start mining and create a blockchain.  You can send transactions to yourself, and you can send transactions to burn-addresses.  You can NOT send transactions to anybody else, since nobody else is using your system yet.  If you don't like some of the blocks you have mined, you can start at the most recently mined block and delete blocks working backwards until you get to the most recent block that you want to keep.  Then you can mine new replacement blocks and just never tell anybody about the previously mined blocks.

Once you have at least 1 peer, and you have shared your current copy of the blockchain with them it becomes more difficult to modify the history in the blockchain.  This is because your peer will refuse to accept any modified blocks that you create unless/until you mine enough blocks to exceed the total proof-of-work that the peer already has.

If peers start mining, it will become MUCH more difficult for you to modify the history in the blockchain.  The is because the blockchain that your peers already have will be growing while you are trying to modify your copy.  You will be chasing a moving target when it comes to total proof-of-work of the blockchain.

If the sum of the hash power of all the mining peers exceeds your personal hash power, then it will become impossible for you to modify the history in the blockchain.  The is because the blockchain that your peers already have will be growing faster than you can grow your copy.  You will be chasing a moving target when it comes to total proof-of-work of the blockchain. And that target will be moving faster than you.  You wion't be able to catch up.

Nodes that aren't mining will check to make sure that a transaction is valid before they relay it to any peers.  They will also check to make sure that a block is valid and is built on top of the greatest proof-of-work chain before they add it to their own blockchain or relay it to any peers. As such, a node with a huge amount of hash power will not be able to force the network of nodes to accept invalid transactions or invalid blocks.

Modifying a transaction that is NOT yet in the blockchain would require you to get enough hash power to accept that replacement transaction such that the next block mined includes the replacement transaction instead of the original.

Modifying a transaction that IS in the blockchain would require that you to get enough hash power to replace (re-mine) EVERY block that has been created after that original transaction was included in the blockchain.  You would have to exceed the total proof-of-work of the blockchain that everyone else is using, And if you are not the only miner, then you'd have to exceed that blockchain as it is still growing.

The number of nodes that have modified blockchains doesn't matter.  Only the validity of that chain and its total proof-of-work.

In your example where you just "modify the same transaction in A and B, faking it", the C node would refuse to accept your modified blockchain, either because the block wouldn't be valid, or because your blockchain would have less proof-of-work than the blockchain that C already has.

member
Activity: 142
Merit: 13
June 28, 2017, 06:18:27 AM
#15
It's not my intention, i just want to view different "angles" because it's a hard concept and i can't really imagina this "decentralized" money system, in reality, the first node would be the master node,  also the "central" server, atleast for the next nodes.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
June 28, 2017, 05:32:34 AM
#14
Thank you very much.

But i mean, if i would develop a cryptocurrencie, and only one node is available, what would happen if i modify the data in that blockchain?
if onlye one is available?
You will need 51% of the mining hashrate to modify the past blocks. A block has to be valid for the client to add it into their own copy of Blockchain.

Anyways, if you were to delete half of the blockchain, half of the transaction will be gone. If the blocks are missing, the transaction history will also be missing. Since you are the only person that has a copy of the Blockchain, you can easily delete the blocks and transaction history will be gone. Take note that this will only work if you are deleting the last X block, not blocks in the middle. If the blocks in the middle are missing, everything after that will also be invalid.

No, you still cannot steal coins from others if you are the sole owner of the Blockchain.
member
Activity: 142
Merit: 13
June 28, 2017, 04:30:30 AM
#13
Thank you very much.

But i mean, if i would develop a cryptocurrencie, and only one node is available, what would happen if i modify the data in that blockchain?
if onlye one is available?
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
June 28, 2017, 04:16:19 AM
#12
So, then every node has it's own blockchain attached, right?
Yes.
So, what would happen if only one node is available? I could modify all and fake all, right?
Modify what? If you are in control of every node in the network, you cannot modify the blockchain easily. Clients do not trust what your nodes are saying. You have to get at least 51% of the network hash to modify your OWN previous transactions after the checkpoint. You cannot change anyone's balance. Read my response below.
And what would happen in this scenario: there are 3 nodes:
A, B ,C

I modify the same transaction in A and B, faking it, what would happen in the C node?
Huh? Can you elaborate?
And other scenario:

An transaction ("block") comes with an id, which is an increment of the last block, what would happen if 2 nodes emit the same block with the same ip, a 2 transactions made in the same time?

Thank you very much!

The network will temporarily be split into half. Lets say block A and block B have the same block height and similar transactions inside.

The block will be propagated throughout the network and miners will start working on whichever block they see first. If I am a miner and I saw Block A first, I'll start working on it. If I mine Block A1 based on Block A, the network will recognise Block A1 and Block A as the valid block in the mainchain and will orphan the other block. If someone else mines Block B1 that is based on Block B, the network will recognise Block B1 and Block B as the valid block in the main chain and orphan the other block. The other block will be forgotten.

Bitcoin blocks doesn't come with an ID. They have the merkle root which has the hash of the previous block. If Block A and Block B have the same hash of the previous block in the merkle root, the above will happen.
member
Activity: 142
Merit: 13
June 28, 2017, 03:03:36 AM
#11
So, then every node has it's own blockchain attached, right?

So, what would happen if only one node is available? I could modify all and fake all, right?

And what would happen in this scenario: there are 3 nodes:
A, B ,C

I modify the same transaction in A and B, faking it, what would happen in the C node?

And other scenario:

An transaction ("block") comes with an id, which is an increment of the last block, what would happen if 2 nodes emit the same block with the same ip, a 2 transactions made in the same time?

Thank you very much!
staff
Activity: 3458
Merit: 6793
Just writing some code
June 28, 2017, 01:53:39 AM
#10
So, there is only 1 Blockchain, and all nodes connect to this?
The blockchain is not something that nodes connect to.

I thought that every node download a copy of the blockchain
Yes, every node downloads a copy of the same blockchain. Everyone's copy of the blockchain updates basically at the same time as they receive new blocks. Blocks are transmitted in the same way that transactions are.

When a node downloads the blockchain, it does not do so from a central server either. Once it establishes connections to other nodes, it begins requesting blocks from all of the nodes that it is connected. When it receives a block, it will validate each block according to the built in consensus rules before it accepts the block. If conflicting blocks are received, the node will choose the block that corresponds to the blockchain with the most work.
member
Activity: 142
Merit: 13
June 28, 2017, 01:16:02 AM
#9
So, there is only 1 Blockchain, and all nodes connect to this?

I thought that every node download a copy of the blockchain
staff
Activity: 3458
Merit: 6793
Just writing some code
June 27, 2017, 03:21:02 PM
#8
So, let me clarify, a node = blockchain, right?
No. A node is a computer that is connected to other computers and sends and receives data to those other computers. All nodes on the Bitcoin network use the same blockchain.

And, blockchain = where all the balances of the users lives and all the transactions
Yes.

So what i understand is, that a node can only be connected to a node, not to many? If i had 4 nodes, A, B, C, D, it would look like this:

A->B->C->D , or can a node be connected to more nodes? like this:

A->B
A->D
B->D
B->C
A node can connect to many nodes simultaneously.
member
Activity: 142
Merit: 13
June 27, 2017, 12:42:36 PM
#7
So, let me clarify, a node = blockchain, right?

And, blockchain = where all the balances of the users lives and all the transactions

So what i understand is, that a node can only be connected to a node, not to many? If i had 4 nodes, A, B, C, D, it would look like this:

A->B->C->D , or can a node be connected to more nodes? like this:

A->B
A->D
B->D
B->C

Then for example, if i would create a cryptocurrency, and i only have a node A, i could modify all balances and transactions? because there is only one blockchain, right?

And if another person runs a node B, this node would download the blockchain data from node B, and if i again modify a transaction or balance it would check this in node A and node B and it see that this transaction is incorrect and would not verify it, right?

And if another node C gets connected, would it download the blockchain from A and B? or only from one of the 2, or from A ?

Also, if i have for example 500 nodes, the transaction would go through all 500 nodes to check this transaction right?

And i only 1 node is available this transaction would go only through 1 node?

So if i have only 1 node i could edit all the data and fake all?

So in teory, if i only had one node, this would be the master node untill more nodes will be connecte, right ?

And between, in which point would enter the miner? I imagine before replicating each the transaction in each node (Blockchain) right?

Thank you very much !!

staff
Activity: 3458
Merit: 6793
Just writing some code
June 27, 2017, 11:55:08 AM
#6
Ohh, thank you. So basically:
when a new node connects, it connects to a "master list server" (or many), requesting nodes, this will return a node list with many nodes? or one?
It is a list with a couple of nodes. IIRC it's something like 5 or 6 nodes.

Then the transaction will broadcast to another node, and than this another node broadcast this transaction to other, and so on, right?
Yes.    

And how many times a transaction go through nodes?
It goes through once. Each node will only broadcast the transaction once. This means that if a new node join the network after a transaction has been broadcast to all nodes, they won't receive the transaction until it is confirmed.

And who updates this "master list server", everytime a new node connects there the "master server list" saves it as a new node?
I'm not sure how often the DNS seeders are updated, but IIRC they use a bot (each server has its own bot) to connect to nodes, request some IP addresses from them, and connect to those and repeat. This way they can tell who is still online and build up a large list of potential node IP addresses.
Pages:
Jump to: