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

Discussion - Atlas and GAIA for BNS v2 #33

Open
bilalanees98 opened this issue Apr 30, 2024 · 4 comments
Open

Discussion - Atlas and GAIA for BNS v2 #33

bilalanees98 opened this issue Apr 30, 2024 · 4 comments

Comments

@bilalanees98
Copy link
Collaborator

bilalanees98 commented Apr 30, 2024

Opening up this ticket just so we can have a discussion around it. Its entirely possible that there are no changes that will be required in atlas or gaia for the upgrade, but thats what we have to figure out.

Atlas network: runs on the stacks node and is responsible for tracking/storing/replicating attachment data.
GAIA: currently unsure how GAIA comes into play for BNS names

Some initial questions:

  1. Zonefile hashes are stored on the BNS contract in a map. Will migrating those ensure zone-file attachments are available for BNS v2?
  2. What is GAIA's role in BNS, what information does it store?
  3. Stacks API has a separate table for zone files that it uses exclusively for the BNS apis. Are those zone files a separate entry or are those synced with stacks-nodes? How does Stacks API populate its own entries?

PS. This is just to get the conversation started, I'll keep on adding more information as I find it.

Known issues:

@bilalanees98
Copy link
Collaborator Author

bilalanees98 commented May 8, 2024

Zonefile hashes are stored on the BNS contract in a map. Will migrating those ensure zone-file attachments are available for BNS v2?

  • Nodes are configured to track attachment events generated through (print …) statements on a smart-contract
  • Once attachments are logged, atlas contacts peers to check if any of them have the attachment data. This data is stored in something called AtlasDB
  • By default they are set to track .bns events here
    • This will have to be updated, nodes will have to track the new bns contract
  • There are 2 tables in AtlasDB: attachment and attachment_instances. Ref
  • attachments hold the actual data and have a hash as a primary key
  • The api provides an endpoint for fetching the attachment data /v2/attachments/<attachment-20-byte-hash>. Ref
  • attachment_instances contain references to an attachment
  • attachment_instances have a composite primary key of: index_block_hash, contract_id, attachment_index
  • attachments are stored against a contract_id. For all BNS attachments the contract_id will be that of the BNS contract
  • Every zone file is actually an attachment and the zone file hash is an attachment hash.
  • My current understanding is that even if we do not migrate the attachment_instance data and only migrate zone file hashes we will be able to get a names zone file via the API.
  • However, I have been trying to fetch attachments on this endpoint: /v2/attachments/<attachment-20-byte-hash> by using the hash provided but it always returns a "Unable to find attachment" error.

@bilalanees98
Copy link
Collaborator Author

What is GAIA's role in BNS, what information does it store?

  • gaia stores a profile.json for every BNS name. The zone file of a name holds the url of the profile.json file on a gaia hub.
  • for example the zone file for bilall.btc has the record:
_http._tcp IN URI 10 1 "https://gaia.hiro.so/hub/1ATHwKg6bA1ZY17fqrXzRS8Ee3TsJva8Ny/profile.json
  • The corresponding zone file looks like this:
[
  {
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJqdGkiOiJiMjNiZmY2NS00ZGVhLTQ1ZmEtYjY3YS1kMGQxNDJhYjcxYmYiLCJpYXQiOiIyMDIzLTAyLTIwVDE1OjEwOjQwLjM0N1oiLCJleHAiOiIyMDI0LTAyLTIwVDE1OjEwOjQwLjM0N1oiLCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzN2I4MDMwZTQ1MDFiY2JjMmFkN2NiYjc0ZWI4MTJiNGQ2ZTgyZjYzYjc0MGNhZGI4ODNlZmRmNTRkYTAxNDgxNyJ9LCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDM3YjgwMzBlNDUwMWJjYmMyYWQ3Y2JiNzRlYjgxMmI0ZDZlODJmNjNiNzQwY2FkYjg4M2VmZGY1NGRhMDE0ODE3In0sImNsYWltIjp7IkB0eXBlIjoiUGVyc29uIiwiQGNvbnRleHQiOiJodHRwOi8vc2NoZW1hLm9yZyIsImFwcHMiOnsiaHR0cHM6Ly9leHBsb3Jlci5zdGFja3MuY28iOiJodHRwczovL2dhaWEuYmxvY2tzdGFjay5vcmcvaHViLzFHQlBURmM2ZWk3c0hjWW9wZmpmVHVLZGVWRWNhdkZQVU0vIiwiaHR0cHM6Ly93d3cuYm5zem9uZWZpbGUuY29tIjoiaHR0cHM6Ly9nYWlhLmJsb2Nrc3RhY2sub3JnL2h1Yi8xRUNhUndHTm53Rko5bVZrR3hycDJ5bThHbkVaSjJOSnJKLyJ9LCJhcHBzTWV0YSI6eyJodHRwczovL2V4cGxvcmVyLnN0YWNrcy5jbyI6eyJzdG9yYWdlIjoiaHR0cHM6Ly9nYWlhLmJsb2Nrc3RhY2sub3JnL2h1Yi8xR0JQVEZjNmVpN3NIY1lvcGZqZlR1S2RlVkVjYXZGUFVNLyIsInB1YmxpY0tleSI6IjAzM2FkMGQxZjJlNmNjYTExOTQ4NTEzNjE3NDFjMjMwNWYxNDQxNDQ2N2Q4Mjk1MThlMTgyYWNiYmYxODkwYjhiZCJ9LCJodHRwczovL3d3dy5ibnN6b25lZmlsZS5jb20iOnsic3RvcmFnZSI6Imh0dHBzOi8vZ2FpYS5ibG9ja3N0YWNrLm9yZy9odWIvMUVDYVJ3R05ud0ZKOW1Wa0d4cnAyeW04R25FWkoyTkpySi8iLCJwdWJsaWNLZXkiOiIwMmE4YTI5N2M2MTY2YTQxNzA4OTA3NmZlNDBmY2M4ZDBhNzRhYzBlYzRhM2MzNjAwZGIxYTU1ODgxYTE5MGI2YTEifX19fQ.epd5Ta-ocvsGU6gsTN-fW77YOcwqSssIzcsQ1NNdqt6MQb952xZ3y4kbdfeEryCQuRldQ8gQfeJmRDlupItENQ",
    "decodedToken": {
      "header": {
        "typ": "JWT",
        "alg": "ES256K"
      },
      "payload": {
        "jti": "b23bff65-4dea-45fa-b67a-d0d142ab71bf",
        "iat": "2023-02-20T15:10:40.347Z",
        "exp": "2024-02-20T15:10:40.347Z",
        "subject": {
          "publicKey": "037b8030e4501bcbc2ad7cbb74eb812b4d6e82f63b740cadb883efdf54da014817"
        },
        "issuer": {
          "publicKey": "037b8030e4501bcbc2ad7cbb74eb812b4d6e82f63b740cadb883efdf54da014817"
        },
        "claim": {
          "@type": "Person",
          "@context": "http://schema.org",
          "apps": {
            "https://explorer.stacks.co": "https://gaia.blockstack.org/hub/1GBPTFc6ei7sHcYopfjfTuKdeVEcavFPUM/",
            "https://www.bnszonefile.com": "https://gaia.blockstack.org/hub/1ECaRwGNnwFJ9mVkGxrp2ym8GnEZJ2NJrJ/"
          },
          "appsMeta": {
            "https://explorer.stacks.co": {
              "storage": "https://gaia.blockstack.org/hub/1GBPTFc6ei7sHcYopfjfTuKdeVEcavFPUM/",
              "publicKey": "033ad0d1f2e6cca1194851361741c2305f14414467d829518e182acbbf1890b8bd"
            },
            "https://www.bnszonefile.com": {
              "storage": "https://gaia.blockstack.org/hub/1ECaRwGNnwFJ9mVkGxrp2ym8GnEZJ2NJrJ/",
              "publicKey": "02a8a297c6166a417089076fe40fcc8d0a74ac0ec4a3c3600db1a55881a190b6a1"
            }
          }
        }
      },
      "signature": "epd5Ta-ocvsGU6gsTN-fW77YOcwqSssIzcsQ1NNdqt6MQb952xZ3y4kbdfeEryCQuRldQ8gQfeJmRDlupItENQ"
    }
  }
]
  • Apparently, there does not seem to be any other link between BNS and gaia. With BNS v2 its unlikely that any change will be required as long as zone files are maintained.

@jcnelson
Copy link

jcnelson commented Jul 9, 2024

By default they are set to track .bns events here

  • This will have to be updated, nodes will have to track the new bns contract

Can you open an issue on the Stacks blockchain repo so this gets done prior to BNSv2 going live? Presumably, this would be part of the Nakamoto release.

Apparently, there does not seem to be any other link between BNS and gaia. With BNS v2 its unlikely that any change will be required as long as zone files are maintained.

Gaia is defunct, I'm afraid. The Atlas system, however, still enjoys first-class support, especially in the service of .btc.us domains.

@friedger
Copy link
Collaborator

friedger commented Jul 9, 2024

The Atlas system, however, still enjoys first-class support

Good to know.
Looking forward to support for stacks-network/stacks-core#3270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants