create account

Improved algorithm for Koinos Nicknames! by jga

View this thread on: hive.blogpeakd.comecency.com
· @jga ·
$28.89
Improved algorithm for Koinos Nicknames!
![ogi_or_twitter_post.png](https://files.peakd.com/file/peakd-hive/jga/23u5tVw35wXth186HyJnBMjWEZKnSdSDrXSX6XEpd9UgB7ZHtuWRNEKskkjDdA2nALgru.png)

Last week when I announced that the contract was fixed in order to prevent similar names, some members contacted with me to show me some examples where the algorithm was not working properly, like @fu1 and @fm1... again, I had to take a pen and paper to determine what was wrong with the algorithm and come up with new ideas to improve the design.

I found that the problem with the algorithm to detect similar names is that I was ordering the names alphabetically, and making comparisons with the closest names in the list... which is not enough!

For instance, let's say the contract already has this list o names: @alice, @alimento, @alitas, and @alligator. And then we try to create the new name @aliwe. If we look closely, @alice and @aliwe are very similar, so ideally these 2 words should be compared in order to detect that they are similar. However, the contract was comparing this new word just with @alitas and @alligator, because @aliwe is in the middle of these 2 words if we order them alphabetically. Since @aliwe is very different to these words then it was accepted.

After thinking about it a lot, I found a solution to the problem.

# Unique Patterns

This new approach doesn't order the names alphabetically. Instead of that, from each name we extract a list of patterns, and we make sure that these patterns are unique.

Let's come back to the example of @alice. When alice is created, the contract saves this list of patterns: **lice, aice, alce, alie, alic**. These patterns are the result of removing 1 letter from the original name alice. If we remove the first letter we get "lice". If we remove the second letter we get "aice". Alice without the third letter is "alce". Without the fourth letter is "alie". And without the last one is "alic".

The algorithm consists in verify that these patterns are unique for each name in the contract. For instance, if @aliwe is created, it will be rejected because "alie" is one of its patterns, and this pattern is already saved for alice. Apart from that this verification is done by removing up to 2 letters. For instance, @alicce will be rejected as well because if we remove 2 letters we get again the pattern "alie", which is already taken by alice.

In conclusion, we just have to extract and compare if the patterns already exist. No need to order them alphabetically, or compute the levenshtein distance. Which not only solves the problem we faced with similar names, but also improves the performance of the contract 💪 **Koinos Nicknames continues with its mission of SAFE TRANSFERS**.

# Contract patched

This change represented a complete refactor of the contract. But apart from that, I had to create a plan to rewrite the existing data in the contract in order to apply the new algorithm:

1. Remove conflicting names.
2. Rebuild patterns for all names and write them in the state of the contract.
3. Remove the previous lists dedicated to save the names alphabetically.

I successfully managed to apply the patch. During this process I consumed around 260 MANA! (splitted in several transactions) It's the first time I consume this big amount of mana. As a reference, today a transfer of koin consumes around 0.2 mana. So, this patch consumed the mana of making 1300 koin transfers.

**Names removed**
As I said, I had to remove some conflicting names after applying the new rules. Sorry for the incovenience. Here is the list of names removed:
@ggg, @bill, @buick, @open, @toys, @free, @burn, @bull, @tim, @mary, @bren, @olga, @taco, @best, @fm1, @kk11, @snoop, @bts, @poe, @koins, @teing, @ford, @maria, @jenny, @lol, @zero, @axa, @bitforex, @cmc, @ordi, @diana, @pop, @nbc, @play, @france, @sha, @jeff, @lily, @star, @xoom, @coingate, @space, @sell, @koinos, @my-wallet, @block, @xin, @may, @miner, @mac.

Transaction - [a801bad2](https://koinosblocks.com/tx/0x122090ad007c92486d295a76f87df28da275d62215d9b40903ff95b1b21ca801bad2)

# Reminder for Hive Users

I put here some reminder for Hive users (more details in the [previous post](https://peakd.com/koinos/@jga/nicknames-update1)):

- If you are in the following list: @gtg, @ezzy, @smooth, @arcange, @yabapmatt, @ausbitbank, @blocktrades, @therealwolf, @splinterlands and you would like to claim your name in Koinos, please reply to this post and put your koinos address 😉 **The limit to claim these names is October 28th, 2023**. If it is not claimed then it will be released to the initial address that took them.

- As a way to prevent further hive account takeovers, I have taken the liberty of reserving some accounts: @peakd, @pfunk, @acidyo, @detlev, @haejin, @aggroed, @asgarth, @edicted, @gadrian, @tarazkp, @bluerobo, @stoodkev, @timcliff, @tobetada, @vimukthi, @buggedout, @fredrikaa, @kevinwong, @mahdiyari, @trafalgar, @transisto, @anomadsoul, @emrebeyler, @good-karma, @lukestokes, @someguy123, @resiliencia, @fulltimegeek, @penguinpablo, @brianoflondon, @lordbutterfly, @theycallmedan, @taskmaster4450, @thecryptodrive. If you are in this list and want to claim your name in koinos please comment as well in the post with your koinos address. In this case there is no time limit.

- If your account was not mentioned above check if your name is still available in https://koinosbox.com/nicknames and claim it. It's free:
  1. Install kondor wallet.
  2. Go to https://koinosbox.com/nicknames, set your name and click create.
  3. Add an image, short bio, etc (optional fields) and click register.
  4. In the popup click "advanced".
  5. Tick "use free mana" and set max. mana to 10.
  6. Go down, click check events and send.
  7. Enjoy your name 😎

The reception at the moment is very good. Now, we have more than 1000 names in the contract.

We are close to the end in order to give 100% control to Koinos Governance. I hope that with this patch we will have a more robust system. If you detect new bugs please let me know.

# Support
Please support this development. There are several ways you can contribute:

Join the [JGA Mining Pool](https://koinosbox.com/jgapool) (very good APY).
Buy a [Kondor NFT](https://koinosbox.com/kondor-nft)
Send a donation in https://koinosbox.com/nicknames
Become a sponsor in https://github.com/sponsors/joticajulian
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 39 others
properties (23)
authorjga
permlinknicknames-update2
categorykoinos
json_metadata"{"app":"peakd/2023.10.1","format":"markdown","description":"New improved algorithm to detect similar names in koinos nicknames in order to have safe transfers","tags":["koinos","dapp","contract","nicknames","blockchain","hive","devs"],"users":["fu1","fm1...","alice","alimento","alitas","alligator.","aliwe.","aliwe","alligator","alice."],"image":["https://files.peakd.com/file/peakd-hive/jga/23u5tVw35wXth186HyJnBMjWEZKnSdSDrXSX6XEpd9UgB7ZHtuWRNEKskkjDdA2nALgru.png"]}"
created2023-10-18 22:15:51
last_update2023-10-18 22:15:51
depth0
children9
last_payout2023-10-25 22:15:51
cashout_time1969-12-31 23:59:59
total_payout_value14.454 HBD
curator_payout_value14.437 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6,357
author_reputation76,172,796,162,312
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,109,053
net_rshares63,729,378,606,346
author_curate_reward""
vote details (103)
@arcange ·
$0.02
Please check DM on Mattermost. Thx
👍  
properties (23)
authorarcange
permlinkre-jga-s2rtfm
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-19 10:07:00
last_update2023-10-19 10:07:00
depth1
children0
last_payout2023-10-26 10:07:00
cashout_time1969-12-31 23:59:59
total_payout_value0.012 HBD
curator_payout_value0.012 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length34
author_reputation1,148,349,221,690,653
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,122,758
net_rshares56,004,693,179
author_curate_reward""
vote details (1)
@emrebeyler ·
Thanks for reserving. ❤️
properties (22)
authoremrebeyler
permlinks2ugtm
categorykoinos
json_metadata{"app":"hiveblog/0.1"}
created2023-10-20 20:27:24
last_update2023-10-20 20:27:24
depth1
children1
last_payout2023-10-27 20:27:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length24
author_reputation448,535,049,068,622
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,162,871
net_rshares0
@jga ·
you're welcome. Please install [Kondor Wallet](https://chrome.google.com/webstore/detail/kondor/ghipkefkpgkladckmlmdnadmcchefhjl) and create an account. Then send me your address and I will asign the name to that address.
properties (22)
authorjga
permlinkre-emrebeyler-s2ujlj
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-20 21:27:30
last_update2023-10-20 21:27:30
depth2
children0
last_payout2023-10-27 21:27:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length221
author_reputation76,172,796,162,312
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,164,438
net_rshares0
@guiltyparties ·
properties (23)
authorguiltyparties
permlinks2r6jv
categorykoinos
json_metadata{"app":"hiveblog/0.1"}
created2023-10-19 01:52:42
last_update2023-10-19 01:52:42
depth1
children1
last_payout2023-10-26 01:52:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length88
author_reputation261,203,126,670,124
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,113,500
net_rshares-3,153,110,897,493
author_curate_reward""
vote details (24)
@jga ·
Good point. Right now, the support is only for Koinos Wallets. In the long term it would be possible to support other wallets like Hive Keychain by creating smart contract wallets trained to interact with other protocols.
But for the moment I don't see viable this support in the short term. I will ping you if something like this happens in the future.
properties (22)
authorjga
permlinkre-guiltyparties-s2rtho
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-19 10:08:21
last_update2023-10-19 10:08:21
depth2
children0
last_payout2023-10-26 10:08:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length353
author_reputation76,172,796,162,312
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,122,797
net_rshares0
@jga ·
$0.02
@klye due to the new rules your name is not in conflict with @ply anymore. Then I claimed @klye and sent it to you 😎 https://koinosbox.com/nicknames/@klye
👍  
properties (23)
authorjga
permlinkre-jga-s2qy6t
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-18 22:52:09
last_update2023-10-18 22:52:09
depth1
children1
last_payout2023-10-25 22:52:09
cashout_time1969-12-31 23:59:59
total_payout_value0.010 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length154
author_reputation76,172,796,162,312
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,109,979
net_rshares51,828,534,043
author_curate_reward""
vote details (1)
@klye ·
THANK YOU!

That is awesome that you remembered me when the shift of rules occurred.

You are the man. Thank you again. Made my morning!
👍  
properties (23)
authorklye
permlinkre-jga-s2sdpq
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-19 17:25:00
last_update2023-10-19 17:25:00
depth2
children0
last_payout2023-10-26 17:25:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length136
author_reputation412,497,049,523,103
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,131,736
net_rshares0
author_curate_reward""
vote details (1)
@wlffreitas ·
But what is this about?
properties (22)
authorwlffreitas
permlinkre-jga-s2qxb6
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-18 22:33:06
last_update2023-10-18 22:33:06
depth1
children1
last_payout2023-10-25 22:33:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length23
author_reputation89,938,242,082,961
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,109,343
net_rshares0
@jga ·
Nicknames is a name service on Koinos Blockchain (to have human readable accounts). See more details here https://peakd.com/koinos/@jga/nicknames
properties (22)
authorjga
permlinkre-wlffreitas-s2qxw4
categorykoinos
json_metadata{"tags":["koinos"],"app":"peakd/2023.10.1"}
created2023-10-18 22:45:45
last_update2023-10-18 22:45:45
depth2
children0
last_payout2023-10-25 22:45:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length145
author_reputation76,172,796,162,312
root_title"Improved algorithm for Koinos Nicknames!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,109,774
net_rshares0