How Does Gas Limit Prevent Infinite Loops during a State Change?
The gas limit is the maximum amount of gas a user is willing to spend on a transaction. Each operation in a smart contract costs a specific amount of gas.
If the contract enters an infinite loop or performs too many operations, it will eventually consume all the allocated gas. When the gas runs out, the transaction is immediately halted, and the state change is reverted, preventing network congestion.