paritytech / substrate-telemetry

Polkadot Telemetry service
GNU General Public License v3.0
305 stars 206 forks source link

Unable to handle networks with duplicated name #375

Closed xlc closed 3 years ago

xlc commented 3 years ago

This is a network list I just fetched from https://telemetry.polkadot.io/ (by inspecting ws messages)

You can see there are multiple Local Testnet and Karura. For some reason the frontend now decides display Karura with 3 nodes (someone's Karura private testnet), not the one with 60 nodes (the Karura mainnet).

There are some race conditions on backend & frontend.

Why the backend is not merging network with same name? It is useful to distinguish between different Local Testnet but there isn't any unique id exposed so impossible correctly handle them.

The frontend should also display the network with most nodes, not pick some arbitrary one.

[0,31,11,["ChainX",81],11,["Local Testnet",8],11,["Curio",101],11,["Kusama",1272],11,["Joystream",407],11,["Curio testnet",5],11,["Polkadot",803],11,["Cerebellum Ext Devs Network 2",8],11,["Bit.Country Tewai Chain",500],11,["Centrifuge Testnet Amber CC2",14],11,["Dusty",235],11,["Stafi",238],11,["Stafi Testnet Sitara2.0",4],11,["Cerebellum Ext Devs Network 4",10],11,["Centrifuge Mainnet",75],11,["Joystream",40],11,["Subsocial",7],11,["Chainflip local Testnet",6],11,["Cerebellum Mainnet Alpha",20],11,["Robonomics",14],11,["Cerebellum Testnet",15],11,["Equilibrium",9],11,["Edgeware",89],11,["Cerebellum Ext Devs Network 5",7],11,["ShiftNrg Testnet",19],11,["Karura",60],11,["Subplay",4],11,["CENNZnet Nikau",13],11,["Zeitgeist Battery Park",213],11,["Centrifuge Testnet Flint CC3",16],11,["Pirl",36],11,["Crust Maxwell",500],11,["Phala PoC-3",9],11,["CENNZnet Azalea",29],11,["Creator Development Testnet",3],11,["Moonbase Alpha",500],11,["Neu Blockchain Staging Testnet",4],11,["Shiden",33],11,["Clover",29],11,["Joystream Antioch Staging",9],11,["Rococo",4],11,["Staging Testnet",43],11,["ChainX",11],11,["PlugNet T1",3],11,["DBC Network",6],11,["Dock PoS Mainnet",77],11,["Development",1],11,["Zirca PROD",2],11,["Cerebellum Network Testnet",16],11,["Rococo",9],11,["IpseTestnet",4],11,["Local Testnet",12],11,["Moving Walls Prod",3],11,["Westend",103],11,["Stafi Testnet Seiya",4],11,["RioChain CC-1",1],11,["Cerebellum Mainnet Alpha",6],11,["ChainX Malan",2],11,["Darwinia",91],11,["HydraDX Snakenet Gen3",280],11,["Crust",123],11,["EquilibriumTestnet",5],11,["ZERO.IO",9],11,["Asclepius",6],11,["Robonomics",90],11,["Khala",123],11,["Cerebellum Ext Devs Network 1",7],11,["Moonriver",139],11,["Acuity",10],11,["Acala Mandala TC4",1],11,["Legends",5],11,["Bitg Testnet",4],11,["Cerebellum Devnet",6],11,["Laminar Turbulence TC3",6],11,["Stafi Testnet Sitara3.0",1],11,["Rococo",1],11,["Khala Testnet",336],11,["Staging Testnet",1],11,["SORA",100],11,["Polkadex Public Testnet",6],11,["Parami Dana",49],11,["Dusty",7],11,["Robonomics",5],11,["Reef Mainnet",18],11,["HydraDX Snakenet",8],11,["Nuchain",40],11,["Bifrost Asgard CC3",8],11,["Nftmart Staging",37],11,["BML Testnet",4],11,["Galital",128],11,["Cerebellum Ext Devs Network 4",4],11,["Chachacha Staging Testnet",24],11,["Paralink Aura Testnet",3],11,["IPSE Mainnet",8],11,["Local Testnet",7],11,["Cerebellum Ext Devs Network 3",8],11,["IPCI",13],11,["Opportunity Standalone Testnet",42],11,["Moonbase Alpha",3],11,["Acala Mandala TC6",19],11,["Acala Mandala TC5",11],11,["Vodka",1],11,["Shopbring Staging Testnet",2],11,["Pangolin",6],11,["Darwinia Crab",50],11,["Parami Dana",100],11,["Borlaug Maya",4],11,["Beresheet v2",6],11,["Stafi Testnet Seiya",2],11,["xx protonet",128],11,["ICX Testnet",2],11,["1COIN Network",1],11,["Clover Sakura",11],11,["GemshiroTestnet",4],11,["Dexchain Staging Testnet",5],11,["Clover Mainnet",34],11,["Cerebellum Network Testnet Beta",2],11,["Zeitgeist Battery Park",1],11,["Ternoa Chaos Net",21],11,["Arcadia Nodle Network",14],11,["Rococo Battery Station Relay Testnet",5],11,["Neatcoin",27],11,["ParaState Testnet 2021-07-15",75],11,["Nodle Chain Network",27],11,["Charcoal Testnet",6],11,["Encointer Testnet Gesell",3],11,["Karura",4],11,["Wika TestNet",2],11,["Rococo",1],11,["SORA-staging Testnet",8],11,["DOTMog.com NET",5],11,["Bifrost Asgard CC4",3],11,["Colombo",4],11,["Myriad Staging Tesnet",4],11,["Tercera",10],11,["Stafi Testnet Sitara",2],11,["Hammer",5],11,["Rococo",2],11,["Uni-Arts Staging network",2],11,["Kim Local",2],11,["Galois-PoC-1",5],11,["Manta Testnet",6],11,["Local Testnet",8],11,["Bifrost",11],11,["OAK Testnet",100],11,["Steam PC",2],11,["Local Polkadex Testnet",3],11,["Dusty",8],11,["Nftmart Testnet-fork",6],11,["Galois",3],11,["Spanner",7],11,["DBC Mainnet",46],11,["Galois",1],11,["Clover",8],11,["GWI live net",6],11,["RioChain Beta",4],11,["Parami Dana",44],11,["DBC Network",1],11,["Syntropy Network",7],11,["Provenance Ledger STG",3],11,["Encointer Testnet Cantillon",4],11,["Local Testnet",1],11,["Acala Mandala TC6",1],11,["Dock PoS Testnet",14],11,["Reef Testnet",4],11,["Nodle Chain Network",1],11,["Local Testnet",2],11,["Local Testnet",2],11,["cartman",2],11,["Opportunity Standalone Testnet",8],11,["DBC Testnet Phase 2",3],11,["Chachacha Staging Testnet",2],11,["Standard Parachain",3],11,["Rococo",12],11,["Neu Blockchain Mainnet",4],11,["Bholdus Testnet",4],11,["Galois",4],11,["ParaState Testnet 2021-04-22",2],11,["Local Testnet",2],11,["RUPT",4],11,["RareMint Testnet",2],11,["glitch_node",1],11,["Basilisk",7],11,["Moonbase Alpha",10],11,["Slonigiraf",5],11,["Galois",5],11,["Spartan testnet",5],11,["Staging Testnet",2],11,["Rococo",5],11,["Local Testnet",3],11,["Karura Testnet",4],11,["Local Testnet",4],11,["Rajasthan Royals DEV",2],11,["ORION",1],11,["GamePower Network",2],11,["Rock N'Roll",4],11,["Battery Station",2],11,["Bool Staging Testnet2",1],11,["Robonomics",1],11,["AvN TestNet",1],11,["Nftmart Staging",1],11,["Local Testnet",10],11,["DataHighway Harbour Testnet",1],11,["Selendra Staging Testnet",2],11,["UniArts Mainnet",6],11,["Zirca DEV",1],11,["Phala PoC-2",1],11,["Acria Testnet",3],11,["Barocco Testnet",6],11,["HydraDX Snakenet Gen2",3],11,["Creatorchain Testnet",2],11,["Beresheet",1],11,["Poa Testnet",1],11,["AvN TestNet",1],11,["DAO IPCI",5],11,["Staging Testnet",1],11,["Myriad Development Tesnet",2],11,["SpiderDAO_Testnet",1],11,["Nices Testnet",2],11,["Standard Parachain",3],11,["IPCI",7],11,["Local Testnet",3],11,["Moonbase Development Testnet",1],11,["Kulupu",3],11,["RobonomicsEarth",7],11,["Local Testnet",1],11,["Stencil Testnet",1],11,["EquilibriumTestnet",2],11,["SkyPirl2",11],11,["GlueOs",1],11,["SubDAO PC1",1],11,["Rococo",2],11,["Laminar Turbulence TC1",1],11,["DBC testnet phase2",6],11,["Scry Info",1],11,["GPASS",1],11,["DBC testnet phase3",5],11,["Staging Testnet",1],11,["CENNZnet Rata",12],11,["Nices Testnet",4],11,["Crab Redirect",1],11,["Earth",3],11,["Kylin Rococo Testnet",1],11,["Parami Testnet",1],11,["DataHighway Westlake Mainnet",8],11,["Zeitgeist Battery Park",1],11,["Development",1],11,["Karura Testnet",1],11,["Rococo",1],11,["Listen Development",1],11,["Moonbase Alpha",3],11,["DBC testnet phase_v2",6],11,["Local Testnet",3],11,["Karura",1],11,["MyBank Testnet",1],11,["Parami PC2",1],11,["Altair",4],11,["Bifrost Asgard CC4",2],11,["OMNI Livenet",4],11,["Local Testnet",1],11,["EquilibriumTestnet",1],11,["Litentry Rostock",1],11,["Nftmart Staging",1],11,["Karura",3],11,["RobonomicsEarth",7],11,["Wendala",4],11,["Chainflip local Testnet",6],11,["Staging Testnet",2],11,["Tercera",1],11,["Nodle Chain Network",1],11,["Dock Testnet",4],11,["Listen Development",1],11,["Cerebellum Network Testnet Beta",2],11,["Manta Testnet",1],11,["Dock Mainnet",2],11,["Moonbase Development Testnet",1],11,["Dusty",1],11,["Crust Maxwell CC2",1],11,["Local Testnet",2],11,["Creatorchain Testnet",3],11,["Local Testnet",1],11,["NFTMart_Staging",6],11,["Development",1]]
dvdplm commented 3 years ago

The backend uses the genesis hash of the network to distinguish networks (or at least that should be the case; you report seem to indicate there might be a bug here) and when chains share the genesis we use the name that the most nodes use (so that a node claiming to be on the "banana" chain but actually is on polkadot will be "drowned out" by the honest majority).

jsdw commented 3 years ago

The backend indeed groups by genesis hash, but the UI only cares about chain names. Because of this, the backend needs to keep a mapping from current chain name to genesis hash for the UI. My guess is therefore that if there are two chains using the same name, something like this happens:

To prevent this sort of thing, the frontend and backend should agree on how nodes are grouped into chains. #350 suggests both sides group by genesis hash (but it's noted that optimally we might need to group by genesis hash + name or something in the longer term to properly cater for forks).

xlc commented 3 years ago

Any plan on getting this fixed or if you can provide some pointers and I can someone from our team to take a look?

jsdw commented 3 years ago

We don't think that getting a fix in for this will be very difficult, but as we're midway through reworking our deployment approach to handle the new sharded telemetry server, there may be a delay in getting the fix into production I'm afraid!

We'll see what we can do though, and post an update here once we have deployed something containing the fix!

xlc commented 3 years ago

Looks like other teams are also having this issues suddenly. Please keep us posted. Thanks.

jsdw commented 3 years ago

As might be evident from the issue being closed, we've merged (and deployed, by the looks of it) a fix for this issue now. The new behaviour will be that, if nodes are sending telemetry from different genesis hashes but the same chain name, you'll see the chain name twice in the UI (with the different nodes counts next to it, and higher node counts sorted first) and be able to view each set of nodes independently.

This is a compromise which means that all telemetry should appear (rather than us picking the chain name with most nodes in case of a conflict), but at the expense of seeing the same chain name more than once if nodes from different chains (by genesis hash) happen to use the same name.