Blockchain: How do nodes know what Data is correct from Consensus process? How do nodes know what data is correct from consensus?

What about if two nodes execute two different consensus with 2 different Valid blocks with the same height at the same time, can that happen? 

I’m talking about Blockchain in general, not bitcoin, not mining.

Not bitcoin related, Not mining related
Consensus

My understanding of this word, in the context of cryptocurrencies, is as follows:

In a finite network of nodes with independent data-storage, consensus exists if all, or at least a majority of, nodes hold a set of data that is identical to, or at least not inconsistent with, the data sets held by other nodes.

That is, consensus is a state, independent of the rules or mechanisms used to achieve it.


  How do nodes know what data is correct from consensus?


They don't necessarily. Consensus is sometimes really an emergent behavior, albeit a planned one. In some systems, nodes don't explicitly seek consensus - that is they don't confer about consensus as a subject - only about what blocks other nodes know of and have already validated.

In these types of system consensus emerges simply because nodes follow the same rules, for example that the chain with the most proof-of-work (or equivalent) is accepted and any alternatives are discarded.


  What about if two nodes execute two different consensus with 2 different Valid blocks with the same height at the same time, can that happen?


That can and does happen for a short while in at least some systems. For example, eventually one of those blocks will have more blocks built on top of it than the other. This block will be then accepted in place of the other by the node(s) that had previously accepted the other. The other block and all blocks built on it will then be discarded. Or there may be other ways in which rules resolve the Byzantine Generals problem.

In this specific example system, transactions in those discarded blocks are also then lost unless they have already been included in the rival block or in blocks built on the rival block. If not they may still exist in memory pools and be later incorporated into the blockchain. This is probably one reason why a significant number of confirmations are needed in this specific system.



Other sources:


Consensus in Blockchain Systems. In Short &mdash; Chris Hammerschmidt  &mdash; 2017