hirosystems / stacks-blockchain-api

API for the Stacks blockchain
https://stacks-blockchain-api.vercel.app
GNU General Public License v3.0
178 stars 114 forks source link

Accounts can own multiple names which is forbidden by the BNS contract #1540

Closed badonyx closed 1 year ago

badonyx commented 1 year ago

API reports that this account owns 2 names

https://stacks-node-api.mainnet.stacks.co/v1/addresses/stacks/SP28NCDY6V4T7NJBMYGTJ55NHMXMC0GG806JW1ZTB

{
  "names": [
    "bc-6276751a883e8520.id.blockstack",
    "emanuele.btc"
  ]
}

Meanwhile the contract function resolve-principal only reports one associated name

(ok (tuple (name 0x656d616e75656c65) (namespace 0x627463)))

This results in inconsistencies like Gamma resolving to one name (.btc) and Tradeport resolving to another (.id.blockstack).

badonyx commented 1 year ago

Revoked names also result in multiple names resolving as owned by an address (see #1502). Example:

https://stacks-node-api.mainnet.stacks.co/v1/addresses/stacks/SP1SHCAV24FGYN8CD8G4XHAGKRV69WFPKADBCH4GB

{
  "names": [
    "dailymail.btc",
    "nars.btc",
    "wimbldon.btc"
  ]
}

Update: Revoked names no longer resolve as of stacks-blockchain-api v6.3.4 (master:6d66c3cc)

{
  "names": [
    "dailymail.btc"
  ]
}
badonyx commented 1 year ago

For the account in the top level comment, one of the names is I guess carried over from Blockstack in a way that I don't entirely understand; BNS contract does not have any registered_subdomain function, what does that mean?

Names carried over from Blockstack did not need to have an NFT minted which should be considered a bug to be fixed in the the next iteration of BNS. The resolution by the API of a name without an NFT should also be considered a bug.

https://stacks-node-api.mainnet.stacks.co/v1/names/bc-6276751a883e8520.id.blockstack

{
  "address": "SP28NCDY6V4T7NJBMYGTJ55NHMXMC0GG806JW1ZTB",
  "blockchain": "stacks",
  "last_txid": "0x2f079994c9bd92b2272258b9de73e278824d76efe1b5a83a3b00941f9559de8a",
  "resolver": "https://registrar.blockstack.org",
  "status": "registered_subdomain",
  "zonefile": "$ORIGIN bc-6276751a883e8520\n$TTL 3600\n_https._tcp URI 10 1 \"https://gaia.blockstack.org/hub/1EFUGLe28aJX11zs8fgqxmehdCSK7BzyEk/profile.json\n",
  "zonefile_hash": "c0999b5bd31a2e5b060439beb50345800ecdd09a"
}
rafaelcr commented 1 year ago

one of the names is I guess carried over from Blockstack

@0xbabo That's correct. When we boot an API node, we import old Blockstack v1 names into the new v2 tables. There are a lot of old subdomains imported during this process (a couple million IIRC), and some of them are owned by just one address. I think this is an artifact of the v1 chain but AFAIK wouldn't be possible to replicate from a v2 call to BNS to register a subdomain.

Names carried over from Blockstack did not need to have an NFT minted

Yep, also correct. It actually makes it very difficult to determine name ownership on API responses because we can't just look at the NFT tables.

rafaelcr commented 1 year ago

Closing this, feel free to reopen if you have further questions