bitpopulous / alpha

Populous Alpha
0 stars 0 forks source link

Deposit 0 GBP Poken and Deposit is Still Successful #70

Open PeterWong1 opened 6 years ago

PeterWong1 commented 6 years ago

Borrower Login

When I activate deposit by pressing deposit button I get request is being processed, transaction validation take a while and then deposit has been successful. However I made a 0 GBP Poken deposit.

If the field is set to "0" then the transaction should not be processed. Otherwise a waste of time and processing power incurred by borrower/investor and Populous.

Nugg3t commented 6 years ago

Seems like the gas was spent to process the transaction, hence the Transaction was still considered successful

zlatinov commented 6 years ago

The transaction gas can be spent, but the action could still not be completed. It's more costly to "crash" the transaction (with throw or require) instead of making validations and stop execution.

When you crash the transaction, ALL gas is spent. If you just validate the data and see you can't process the request, you don't need to crash it and spend ALL gas - you can just stop execution and use only the already processed gas. This reduces the system's gas costs overall.

This can be done, because all execution is done internally in the system and we know no state has been changed in the smart contracts and we don't need to crash the transaction to rollback the state.

Populous deposit function

Deposits Manager deposit function

Still proper checks for 0 amounts have to be added in the platform to avoid executing the transaction in the first place and in the smart contract entry point (Populous.deposit) to avoid further checks.