Open emizzle opened 1 year ago
As an alternative to increaseAllowance
, when an availability is created (or edited/patched), we approve infinite token allowance for the entire availability. Infinite token approval is a known attack vector, however, there is a plan to include a separate address for token payouts/profit, which means the storage provider node would be funded separately, and therefore any profits earned by the node would not be vulnerable from an attack.
On PUT/PATCH, if token approval is not infinity, change it to infinite.
https://github.com/codex-storage/codex-contracts-eth/issues/71 should be implemented first.
I'm not sure that approving the totalCollateral
when an Availability is added/edited will be enough to get rid of increaseAllowance
. Instead, there could be an approve
call with totalCollateral
of all Availabilities minus collateral that's already been spent in active requests.
Imo, this is safer than using infinite approval.
See https://github.com/codex-storage/nim-codex/issues/550#issuecomment-1754481085 for more context.
In an ideal world, it would be best to avoid usage of
increaseAllowance
so that the potential for using ERC20 stablecoins (eg DAI) that may not haveincreaseAllowance
in their contract is left open, and also to avoid the need to wrap a token (so that it would haveincreaseAllowance
).To prevent reliance on
increaseAllowance
, the following changes to Availabilities were proposed:maxCollateral
per slot tomaxCollateral
total across all slots in the AvailabilitymaxCollateral
. ModifyfillSlot
so that we don't need to approve the collateral amount.maxCollateralPerByte
that specifies the maximum amount of collateral per byte a provider is willing to commit to a request. This can be used to prioritise slots in the slot queue.increaseAllowance
, but was discussed at the same time, when an Availability is created, deposit themaxCollateral
into theMarketplace
contract. This would act as a commitment from the provider that they are willing to participate.maxCollateral
can be topped up for an Availability.