Page MenuHomePhabricator

[Cashtab] [Alias] pt 7 - Mitigate edge cases for registration records
ClosedPublic

Authored by emack on Feb 16 2023, 07:59.

Details

Summary

T2551

Depends on D13124

This diff mitigates the edge case of duplicate alias registration transactions by leveraging the approach used in D13115, achieved by setting unconfirmed txs to a block height of 100000000, sorting the txs by blockheight and txid, before filtering out subsequent instances of the same alias registration.

As part of testing, I have also validated it handles special characters and non-english languages. However depending on the language, the character counts evaluates differently as seen below.

german: Mädchen.xec <-- 7 characters, an extra one for the ä
korean: 소주.xec <-- 2 characters
chinese: 苦屎.xec <-- 2 characters
spanish: sandía.xec <-- 7 characters, an extra one for the í
arabic: محيط.xec <-- 4 characters
gibberish: ( ͡~ ͜ʖ ͡°).xec <-- 8 characters, 2 for each symbol with spaces stripped out

Based on above we can just let the existing char limit remain as is, since the char length is calculated at the point of determining the appropriate registration fee. When I hook it up to the send components in the next diff we'll need to test these thoroughly via the send inputs.

[Cashtab] [Alias] pt 1 - Create scaffold for new Identity component
[Cashtab] [Alias] pt 2 - Upgrade sendXec() to handle alias registration
[Cashtab] [Alias] pt 3 - Implement isAliasAvailable function
[Cashtab] [Alias] pt 4 - Implement isAddressRegistered function
[Cashtab] [Alias] pt 5 - Implement getAddressFromAlias function
[Cashtab] [Alias] pt 6.1 - Get latest alias tx count from payment address
[Cashtab] [Alias] pt 6.1.1 - Apply Promise.All approach for alias history retrieval
[Cashtab] [Alias] pt 6.2 - Implement getAliasesFromLocalForage
[Cashtab] [Alias] pt 6.3 - Implement updateAliases
[Cashtab] [Alias] pt 6.4 - Update getAliases() to extract both alias and address
[Cashtab] [Alias] pt 6.5 - Optimize getAllTxHistory to only make API calls for uncached tx history pages
[Cashtab] [Alias] pt 6.6 - Render list of Aliases owned by active wallet in Alias.js
[Cashtab] [Alias] pt 7 - Mitigate edge cases for registration records (same rego in same block, validate emoji char counts)
[Cashtab] [Alias] pt 8 - Enable alias lookup for Send XEC component
[Cashtab] [Alias] pt 9 - Enable alias lookup for Send Token component
[Cashtab] [Alias] pt 10 - Upgrade tx history to recognize alias registration txs
[Cashtab] [Alias] pt 11 - Set final registration fees and remove residual dev logs

Test Plan
  • npm test
  • npm start
  • register a new alias, quickly delete the cashtabCache object and navigate to the Alias page again. Verify there are no duplicate aliases in cachtabCache.aliasCache.aliases
  • Verify via the console log the unconfirmed tx in the aliasTxsSortedByTxidAndBlockheight output has now been updated with the block.height: 100000000 attribute
  • attempt to register some antediluvian language that's within the char limit and ensure it registers all ok
  • refresh alias page and ensure the partial tx retrieval has not regressed

Diff Detail

Event Timeline

emack requested review of this revision.Feb 16 2023, 07:59
Unknown Object (User) awarded a token.Feb 16 2023, 09:36

huh, the length limit in the front end seems to "just work", e.g. it only lets me put in 👀👀👀👀👀👀👀👀👀👀1 if I use emojis, vs abcdefghijklmnopqrstu alphabetical (21 chars).

Reviewing with Fabien, I think we should find a way to land these into prod. This way wa get the benefits of CI testing and also spare ourselves any rebase nightmares if other diffs need to get in.

However, we should make sure that the feature is disabled in prod.

Best way to do this, I think, is

  • green this diff
  • for Part 8, do nothing but implement "disable in prod"
  • land the stack
  • continue
web/cashtab/src/utils/chronik.js
255 ↗(On Diff #37911)

No need to change in this diff but should patch later

we shouldn't have multiple functions that get alias tx history.

this function should take the most up to date, parsed, version of alias tx history as an input.

This revision is now accepted and ready to land.Feb 16 2023, 18:00
emack marked an inline comment as done.Feb 16 2023, 23:17

@bytesofman - isAliasAvailable() optimization patch added as T2941