codex-storage / codex-contracts-eth

Ethereum smart contracts for Codex
Other
5 stars 9 forks source link

feat: collateral per slot #44

Closed AuHau closed 1 year ago

AuHau commented 1 year ago

The code is ready for review, but I have not yet touched the tests. Some remarks below.

I have removed the Collateral abstract contract. The collateral is now pretty much tied to the Slot structure, and I don't see clearly how it could be split into a separate contract like it was till now. But if you think there is a way, I am happy to hear it! ;-) This means, though, that the collateral funds tracking and collateralInvariant is removed, but as we want to move toward fuzzing anyhow, I don't think it is necessary

Regarding timed-out Requests. I have considered for the Client to return the collaterals for already filled slots (in the withdrawFunds() method), but since uint64 can be quite a big number of slots to cover, I have decided to leave it up to the Host to call the freeSlot() at his discretion when he detects that the Request of his Slot was canceled and wants his collateral back. This could be improved by allowing calling this in bulk. Currently, as discussed in #43, the hosts also get the slot's reward, but in the follow-up PR, I will change that for them to get only the collateral back.

Closes #38