cess icon indicating copy to clipboard operation
cess copied to clipboard

SBP: `UnitPrice` issues

Open NachoPal opened this issue 2 years ago • 1 comments

  • [x] UnitPrice value should be able to be set from genesis or have a default value. If for some reason OCW http request fails, UnitPrice would default to 0.
  • [x] Conditions to fetch price should be modified. In case the first http request fails or it retrieves a wrong value, offchain_fetch_price() will not be run until the next day. Some conditions should be added to automatically check if the retrieved price is under some limits or otherwise to fallback to some default value or perform the http request again. Make sure the results the OCWs generate are validated on-chain (and not assumed to be valid).
  • [x] update_price() is an unsigned dispatchable. Anyone could call to this method and modify the price: https://github.com/CESSProject/cess/blob/main/c-pallets/file-bank/src/lib.rs#L603-L607

NachoPal avatar May 23 '22 04:05 NachoPal

Thank you. According to your suggestion, I set the default value for UnitPrice. When the offchain worker encounters an unexpected condition, it is re executed, and the upper limit of the cycle is 5 times. Method update_price is modified from no signature to signature, and the signers are filtered. Below is the PR link: https://github.com/CESSProject/cess/commit/49be59beab78aa809524e40d58fc00aefe64f07e

ytqaljn avatar Jun 08 '22 03:06 ytqaljn