rusk icon indicating copy to clipboard operation
rusk copied to clipboard

Implement PoW scheme for users creating paid-by-the-contract contract call transactions

Open miloszm opened this issue 10 months ago • 2 comments

Summary

Users submitting paid-by-the-contract contract calling transaction must provide a PoW which will prevent a possibility of DOS attack. Only then the contract call should be performed, after additional checks of contract's balance and contract's allowance.

Possible solution design or implementation

This logic should be implemented by pre-verifier. PoW could be passed in a form of a nonce proving the work performed in a form of searching for a partial pre-image consisting of the last block hash plus more data items (call arguments, more TBD). Upon verifying the PoW, pre-verifier code could also check target contract's balance and allowance declared by the contract to cover the gas cost of rejected or failed calls. After that, target contract's method will be called and upon return, contract's balance will be adjusted accordingly (i.e. decreased, as it is the contract who pays for gas).

Additional context

PoW reference code will be initially implemented in test, eventually it will be part of user client code. PoW is not needed if deposit is given, this pertains especially to contract-earns-a-fee scenario, in which contract decides how big a fee is charged and retains an excess fee (i.e., fee minus the actual gas spent) in its balance. Deposit may also be given in contract-pays-a-fee scenario, making the PoW superfluous as well.

miloszm avatar Apr 17 '24 14:04 miloszm

Rather than hashing PoW we will implement work as ZKP and extend circuit to verify the ZKP as PoW.

miloszm avatar Apr 18 '24 08:04 miloszm

The issue of checking the uniqueness of transaction when added in the mempool is part of this task. A more in-depth discussion about it needs to take place and be recorded here

autholykos avatar Jun 13 '24 13:06 autholykos