3

I have a couple of questions and will try to explain them here.

So, let's say we have 4 nodes in the whole network.

  1. one of the nodes (node A) took transactions from pool. before they put it into a candidate block, they first validate each transaction, right ? if so, i guess they check balance and signature. Anything else ? and if all good, they put each valid transactions into a candidate block and after that, they start mining this block... I guess unvalid transactions disappear or something..

  2. Let's say node A mined the block the quickest. It put the block into its ledger and also shared this block to other nodes so they can add it to their own ledger too. I know that other nodes won't just add it to the ledger until they confirm that this new block was really mined(will take the hash of the header and check if it's below current). Is this correct ? if so, Then, question is, will they also conduct a validation for each transaction from this block ? if yes - why ? if no - why ?

  3. If I make 2 transactions one after another, even though I only have balance for only one transaction, those 2 will go to pool first. and I guess, when my node checks validation of transactions before putting it into a candidate block, they will see that whichever they check first is valid, and second one is not valid anymore since they already have checked the first one. Right ?

1
  • I've been wondering the same. Every tutorial emphasizes how pow hashing works and says little about how tx are actually validated..
    – GN.
    Apr 1, 2021 at 4:53

1 Answer 1

3

Generally each transaction is validated when it is added to the mempool of the node. This happens when the node first sees the transaction, it doesn't wait til it is added to a candidate block for mining. The candidate block for mining would be formed out of the transactions already in the mempool - those which have already been validated by the node.

If another node receives a block then yes, it will validate the proof of work and other factors such as the timestamp, and it will also validate each transaction in the block that it hasn't seen before. The ones it has seen before will simply be removed from its mempool and do not need to be re-validated.

Re 3., nodes will not accept two conflicting transactions into their mempool. Each node will accept whichever valid transaction they see first. This may not be the one that ends up in the block eventually, but the node will correct this once one of the two conflicting transactions has been mined.

3
  • 1) So, when a transaciton is being made, before it gets added to the mempool, it gets validated first, right ? and if it's correct, then that's when node adds it to mempool. Correct ? 2) how does node check if user has the right balance ? it seems like node has to loop through the whole blockchain's UTXO transactions , isn't that tiresome ? i remember there is something else to quickly check if user has the valid balance. Sep 18, 2020 at 10:25
  • @NikaKurashvili Computers are ideally suited to that kind of "tedious" task. It's precisely the kind of thing that is nearly trivial for them to do. This is, for example, exactly what any search engine does. And the process of building indexes to make searches efficient is a solved problem. Sep 19, 2020 at 18:22
  • @NikaKurashvili That's correct, validating nodes will store the entire set of unspent transaction outputs (UTXOs) in order to check that all inputs to a transaction are valid (not just the balance, also that they fulfill all the other conditions such as checking the script or signature required is present). Sep 21, 2020 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.