Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offchain Worker liquidator #63

Closed
xlc opened this issue Jan 14, 2020 · 4 comments
Closed

Offchain Worker liquidator #63

xlc opened this issue Jan 14, 2020 · 4 comments
Assignees

Comments

@xlc
Copy link
Member

xlc commented Jan 14, 2020

#2 (comment)

@xlc
Copy link
Member Author

xlc commented Jan 20, 2020

Offchain Worker 的执行策略初步想法:

  • 只有验证人/收集人执行
  • 没有奖励(暂定)。只要有几个诚实节点执行就够了,没有奖励应该不会有什么影响。
  • 每个节点一次只执行一个worker
    • worker启动的时候判断是否已有其他worker执行,有的话直接退出,可以参考im online模块的逻辑
  • worker 直接遍历某个抵押品的所有CDP判断是否有危险仓位,因为worker执行时间是没有限制的,所以没有什么顾虑
  • 第一次启动时随机挑选一个抵押品进行遍历,一次遍历一个抵押品,执行完成后保存修改下次一遍历的抵押品
  • 发现危险仓位后发送unsigned transaction平仓
  • SignedExtension::validate 可以验证unsigned transaction是否合法,就是仓位是否确实危险,不然就拒绝添加到交易池中
    • 这应该可以避免多个验证人同时平仓同一个仓位,但如果不能避免的话再考虑其他方案

@wangjj9219 wangjj9219 self-assigned this Feb 3, 2020
@wangjj9219
Copy link
Member

About iterate on key/value of StorageMap/StorageDouble, according to : paritytech/substrate#4610, can use blake2_128_concat hashing algorithms to keep the original key bytes in StorageMap/StorageDouble, then I can decode bytes slice to CurrencyId and AccountId ,but Substrate hasn't expose the field previous_key of PrefixIterator to public yet: https://github.com/paritytech/substrate/blob/605852eaa414ddae0bb12bb4974b9cba24ccf7db/frame/im-online/src/lib.rs#L376-L382

I prefer the another way they mentioned: paritytech/substrate#4362 , should we waiting for they to implement the feature in Storage? or we can store tuple (key, value) instead of value just for Debits before they implement it ?

@xlc
Copy link
Member Author

xlc commented Feb 10, 2020

Another way to avoid migration and maybe easier to do is add a new
Accounts: double_map AccountId, CurrencyId => (AccountId, CurrencyId)
and insert this when debits is more than zero, clear it when debits is zero.

So we don't need to modify existing storages, to avoid migration, and we can delete this Accounts later when a better iteration approach is implemented by Substrate.

@xlc
Copy link
Member Author

xlc commented Mar 11, 2020

Done

@xlc xlc closed this as completed Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants