which nodes have ethereum vm? I have read that nodes with evms run the transactions and check if they all got the same result. How do they sync and compare their results?
which nodes have ethereum vm?
All clients run the EVM. (So I think that basically means "all nodes", including light nodes.)
I have read that nodes with evms run the transactions and check if they all got the same result.
When a node receives a new block, it will validate the state transitions associated with each transaction. If the transactions can't be applied to the state stored by a given node, the block will be rejected as invalid. So if a mining node created a new block with invalid transactions, the rest of the network would (should) reject it.
How do they sync and compare their results?
They don't compare their results directly, but rely on consensus mechanisms. If everyone is playing by the rules, then all nodes should reject invalid blocks when they receive them. There is an implicit assumption that all nodes do this. In which case, there's an implicit assumption that everyone has the same view of the world.
The complications arise when two or more mining nodes create different but valid blocks, and propagate them to the network. If this happens, part of the network will have one view of the world, and another part of the network will have another view. Both of them valid. This is a chain fork. At this point, the consensus algorithms work their magic1 to reconcile the differences between the two forks of the chain, ultimately leading to one fork being marked invalid.