1. A method comprising: identifying, by a processing device of a computing device participating in a distributed transaction with other computing devices, a first operation to change a resource associated with the distributed transaction from an initial state to an intermediate state, a second operation to change the resource from the intermediate state to a resultant state, and an additional operation to change the resource from the resultant state to a new state; performing the first operation, second operation, and the additional operation to change the resource from the initial state to the new state; determining that an amount of resources to determine a plurality of inverse operations to return the resource from the new state to the initial state after a performance of the first operation, the second operation, and the additional operation does not exceed an amount of resources to store the initial state of the resource; in response to determining that the amount of resources to determine the plurality of inverse operations does not exceed the amount of resources to store the initial state of the resource, determine, by the processing device, the plurality of inverse operations that, when applied to the resource, changes the resource from the new state to the initial state, the plurality of inverse operations comprising a first inverse operation to change the resource from the intermediate state to the initial state, a second inverse operation to change the resource from the resultant state to the intermediate state, and an additional inverse operation to change the resource from the new state to the resultant state; optimizing the plurality of inverse operations to generate a new inverse operation to replace the first inverse operation, the second inverse operation, and the additional inverse operation by combining the first inverse operation, the second inverse operation, and the additional inverse operation to change the resource from the new state directly to the initial state; and performing the new inverse operation on the resource after the performing of the first operation, the second operation, and the additional operation.