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

Improve efficiency of discovery of Resolvers / ReservedResolvers from fresh wallet #19

Closed
ross-weir opened this issue May 31, 2023 · 2 comments

Comments

@ross-weir
Copy link
Contributor

ross-weir commented May 31, 2023

In order to retrieve Resolvers from a fresh wallet restore the wallet will need to check every single Resolver box to see if it can be spent, this is done by checking if the wallet has the SK for the PK stored in R4.

This won't scale when there's many users and Resolvers minted.

Instead we could:

  1. Embed the PK as a const in the contract
  2. This would require a different way of checking script hash
    val validScript = blake2b256(resolverOutBox.propositionBytes) == fromBase16("$resolverScriptHash")
  • will need to manually construct the script hash (blake2b256(const(pk) ++ restOfScriptBytes)) - there might actually be a function for this: def substConstants[T](scriptBytes: Coll[Byte], positions: Coll[Int], newValues: Coll[T]): Coll[Byte]
  • will this have impacts on other contracts checking for script hashes?
  1. Then the wallet could check for script addresses with the wallets PKs

Consideration with this approach: We won't be able to embed the resolver script hash to check the out box script hash, we instead need to embed the resolver script prop bytes and use substConsts with the buyer pk - this could increase the size of boxes quite a lot if resolver contracts get more complicated (i.e if we add subresolvers).

Max size of boxes are 16kb, I think it's pretty likely we'd reach that limit if we were to include the prop bytes as a constant

Maybe we could have a "locator" nft that is also minted that will live at a P2PK address in the wallet enabling easy resolver box finding, adds a bit of complexity as there's an extra token that needs to be managed and traded when selling a resolver

@ross-weir ross-weir added this to the Testnet launch milestone May 31, 2023
@ross-weir ross-weir added the enhancement New feature or request label May 31, 2023
@ross-weir ross-weir moved this to Todo in bitdomains May 31, 2023
@ross-weir
Copy link
Contributor Author

Added my thoughts here: https://github.com/bitdomains/contracts/blob/main/docs/resolver-utxo-discovery.md

I think that having a static contract and adding more querying options to the nodes indexer is likely the best option

@ross-weir ross-weir removed this from the Testnet launch milestone Jun 3, 2023
@ross-weir ross-weir removed the enhancement New feature or request label Jun 3, 2023
@ross-weir
Copy link
Contributor Author

Added my thoughts here: https://github.com/bitdomains/contracts/blob/main/docs/resolver-utxo-discovery.md

I think that having a static contract and adding more querying options to the nodes indexer is likely the best option

Querying utxos by registers appears to already be in the works: pragmaxim-com/ergo-uexplorer#3

With this in place a users wallet can discover bitdomains related boxes by generating a batch of keys and querying the indexer r4 == key[i] && script == bitdomainsContract

@github-project-automation github-project-automation bot moved this from Todo to Done in bitdomains Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant