codex-storage / nim-codex

Decentralized Durability Engine
Apache License 2.0
62 stars 22 forks source link

Sales module retrieves whole `Request` instead of doing decision making with `Ask` #395

Open AuHau opened 1 year ago

AuHau commented 1 year ago

Marketplace contract emits StorageRequested event that contains the StorageAsk object, which represents the basic parameters of the StorageRequest. The idea presented to me by @markspanbroek is that the host nodes should use this object to make decision-making on whether it wants to accept the Request and fill its slot or not.

Currently, though, it downloads the whole Request in the SaleDownloading state, which is unnecessary.

emizzle commented 1 year ago

While this could definitely be done, this would require more gas to emit during requestStorage. Is the gas penalty on the client worth the saving of a request during SaleDownloading?

gmega commented 5 months ago

Is this still current/important, guys?

markspanbroek commented 5 months ago

This is still current, and probably easily fixed. In the SalePreparing state, we (1) retrieve the request, then we (2) check availability, and then (3) do a reservation. Both (2) and (3) can be done with just the request ask. If we change the order to be (2), (3), (1), then we only retrieve the request when needed.

AuHau commented 5 months ago

To add to Mark's reply though, this is more of an optimization and not really "bug - bug" ;-)