If I have a function that changes the state of the contract, and further down in the same function, there is a require statement. What happens to the contract state if something fails to pass the require statement? As in: if the function changes the variable x, then fails the require on the next line, will x remain changed since it happened before the failure? or will it revert because the entire txn fails?
example: calling changeX(1, 5);
Contract:
uint x;
function changeX(uint _x, uint _y){ x = _x; require(_y != 5, "_y was 5"); }
In this simple example I am aware I should just put the require statement at the top but I am using this as a metaphor for a more complex contract I am writing. I just need to know: if a txn fails, do any of the state changes remain? Or do they all revert regardless of how many there were before the failure.