Let's say the transaction got picked up into a block by miner A and into a block by miner B. Both are working on those separate blocks, and each block contains information about Alice's transaction and it is just a matter of luck which miner solves it? Or are transactions picked up as "one bunch" by every miner out there working on the next block, so that Alice's transaction is in "every" block that is currently mined?
Both are working on those separate blocks, and each block contains information about Alice's transaction and it is just a matter of luck which miner solves it?
Mining a block is basically a race, the successful miner is usually the first one to find a valid block and send it to the rest of the network. In one respect, there is some luck involved, because hashing is purely probabilities, it might take you only one attempt to find a valid block or it might take you quadrillions of attempts. But obviously the more attempts you make, the more likely you are to find a valid block, hence why more mining power generally means higher success rates.
Sometimes, two miners find a block at almost the same time and a small fork happens where some nodes see one block first and others see the other, but this is generally resolved as soon as the next block is mined, because the nodes will move to whichever chain becomes longer.