regolith-labs / ore

ORE is a cryptocurrency everyone can mine.
https://ore.supply
685 stars 235 forks source link

fix claim tx failure in corner case #63

Closed miralandlabs closed 3 months ago

miralandlabs commented 3 months ago

Corner case description: a) When a CPI error occurs, the entire transaction is aborted immediately, which may cause potential state inconsistency. b) The probability of a subtract operation failure is much lower than the failure of the transfer CPI call. c) Subtract balance after successful transfer may be better since we can't really handle the error from invoke or invoke_signed.

Proposed solution: swap the execution order of balance subtract and transfer CPI

HardhatChad commented 3 months ago

If the transaction fails, no state change is committed