graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.9k stars 968 forks source link

Chain name aliases #3075

Open schmidsi opened 2 years ago

schmidsi commented 2 years ago

Do you want to request a feature or report a bug? feature

What is the current behavior? Every chain has a unique network identifier, like mainnet, matic, xdai. Some of these chains were renamed but their unique identifier stayed the same. Eventually, new developers will be confused because they do not intuitively understand why a subgraph running on Polygon should have matic as network identifier. Same for xDai which was renamed to Gnosis Chain.

Though, just changing these network identifiers would break all existing subgraphs that still have matic as network and not polygon.

What is the expected behavior?

I would recommend to introduce network identifier aliases, so we can start to communicate the new names but still support the old ones.

Example:

matic -> polygon xdai -> gnosis-chain

Etc.

azf20 commented 2 years ago

This makes sense, though perhaps the underlying problem is that graph-node isn't using the canonical chain identifiers (chainID for EVM chains) which are unchanged. That will always be a painful migration, but perhaps this aliasing is also a good first step in that direction. Presumably this could just be part of the advanced graph-node config:

networkAliases = [
{ alias = "matic", network = "polygon" }
{ alias = "xdai", network = "gnosis-chain" }
]

That would then give us future leeway to move to more robust (but less human readable) identifiers Interested in your thoughts @lutter

lutter commented 2 years ago

If we do this in the config file, I would just make that another property for the provider, something like

[chains.matic]
shard = "blocks_b"
provider = [ .. ]
aliases = ["polygon"]
azf20 commented 2 years ago

Thanks @lutter that makes sense to me.

There are two general concerns here:

David's suggestion meets the first need. I think the second is outside the remit of Graph Node, which isn't network aware. I propose that new chain names should be added to networks.md, with an aliases column for other accepted names. This may require all indexers to use more advanced graph node configuration, @fordN are most indexers doing so already, or are some using CLI args?

azf20 commented 2 years ago

Adding a GIP on this improvement, as it is relevant to the network https://forum.thegraph.com/t/chain-identification-aliasing-for-the-graph-protocol/3514

azf20 commented 2 years ago

Considerations:

neysofu commented 1 year ago

As I'm working my way through the changes necessary to get aliasing of of the door, I'll try to summarize the most important changes in this comment. The ticks as in "done" are approximations. I may be missing something, in that case I'll update this comment and/or the future PR description.

[chains.matic]
shard = "blocks_b"
provider = [ "..." ]
aliases = ["polygon"]