-
Notifications
You must be signed in to change notification settings - Fork 2
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
Optimize sorted list #8
Comments
Thanks for the Issue! However, according to the documentation (doc/erc/ideas.md), items with the same score in the sorted list MUST return different rankings, which is related to the reward algorithm at reward cycle end. I'll continue to refer to your thoughts on optimizing sorted lists. Thanks again for your Issue! |
This approach here also supports giving the lower ranking if there is a tie. So 20, 20, 20, 30 would produce ranking of 3, 3, 3, 4. In Solidity I have not seen projects that sort data on on-chain because it is so expensive. Let's benchmark it well and decide the acceptable gas. It may be necessary to pick a different game mechanism if the gas costs are prohibitive. |
According to the gas cost reported by npm package hardhat-gas-reporter, if we insert 40 items which has random hash and score(0-1000) to 32 length list ,it costs:
when insert into a 16 length list, it costs:
I`m not familiar with gas limit but I think it may be acceptable? |
Are those typical usage scenarios? We expecting 40 participants and each one only sets the score once? Or will there be many participants and each one is updating the score frequently? |
This new API is more efficient assuming
update
is run more often thanranking
.The text was updated successfully, but these errors were encountered: