Skip to content

Commit

Permalink
Update latest chains, remove deprecated chains - add newly synced cha…
Browse files Browse the repository at this point in the history
…ins (#163)

* Update latest chains, remove deprecated chains - add newly synced chains

* Correct spelling errors

* Remove unused iterator implementation

* Update commandline help doc

* Revert defaulting match case on threshold

* Fix and updated graph network test

Update github link

* Update hypersync url generator

---------

Co-authored-by: Jono Prest <[email protected]>
  • Loading branch information
JasoonS and JonoPrest authored Sep 2, 2024
1 parent 195987e commit 2bcb91e
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 108 deletions.
2 changes: 1 addition & 1 deletion codegenerator/cli/CommandLineHelp.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Initialize by pulling the contract ABI from a block explorer

* `-b`, `--blockchain <BLOCKCHAIN>` — Network from which contract address should be fetched for migration

Possible values: `ethereum-mainnet`, `goerli`, `optimism`, `base`, `base-sepolia`, `bsc`, `gnosis`, `fantom`, `polygon`, `optimism-goerli`, `optimism-sepolia`, `moonbeam`, `arbitrum-one`, `arbitrum-nova`, `arbitrum-goerli`, `arbitrum-sepolia`, `celo`, `fuji`, `avalanche`, `mumbai`, `sepolia`, `linea`, `polygon-zkevm`, `scroll`, `kroma`, `holesky`, `blast`, `blast-sepolia`, `amoy`
Possible values: `ethereum-mainnet`, `goerli`, `optimism`, `base`, `base-sepolia`, `bsc`, `gnosis`, `fantom`, `polygon`, `optimism-goerli`, `optimism-sepolia`, `moonbeam`, `arbitrum-one`, `arbitrum-nova`, `arbitrum-goerli`, `arbitrum-sepolia`, `celo`, `fuji`, `avalanche`, `sepolia`, `linea`, `polygon-zkevm`, `scroll`, `kroma`, `holesky`, `blast`, `blast-sepolia`, `amoy`



Expand Down
115 changes: 68 additions & 47 deletions codegenerator/cli/src/config_parsing/chain_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ pub enum Network {
#[subenum(GraphNetwork)]
PoaSokol = 77,
#[subenum(GraphNetwork)]
Chapel = 97,
Mumbai = 80001,
#[subenum(HypersyncNetwork, GraphNetwork(serde(rename = "chapel")))]
BscTestnet = 97,
#[subenum(GraphNetwork)]
PoaCore = 99,
#[subenum(HypersyncNetwork, NetworkWithExplorer, GraphNetwork)]
Expand Down Expand Up @@ -94,7 +96,7 @@ pub enum Network {
ArbitrumNova = 42170,
#[subenum(NetworkWithExplorer, GraphNetwork)]
ArbitrumGoerli = 421613,
#[subenum(HypersyncNetwork, NetworkWithExplorer)]
#[subenum(HypersyncNetwork, NetworkWithExplorer, GraphNetwork)]
ArbitrumSepolia = 421614,
#[subenum(HypersyncNetwork, GraphNetwork, NetworkWithExplorer)]
Celo = 42220,
Expand All @@ -104,8 +106,6 @@ pub enum Network {
Avalanche = 43114,
#[subenum(GraphNetwork)]
CeloAlfajores = 44787,
#[subenum(HypersyncNetwork, NetworkWithExplorer, GraphNetwork)]
Mumbai = 80001,
#[subenum(HypersyncNetwork, GraphNetwork)]
// Blockscout: https://explorer.aurora.dev/
Aurora = 1313161554,
Expand All @@ -116,7 +116,7 @@ pub enum Network {
// https://explorer.harmony.one/
// https://getblock.io/explorers/harmony/
Harmony = 1666600000, // shard 0
#[subenum(GraphNetwork)]
#[subenum(GraphNetwork(serde(rename = "base-testnet")))]
BaseGoerli = 84531,
#[subenum(HypersyncNetwork, GraphNetwork)]
ZksyncEra = 324,
Expand All @@ -143,10 +143,6 @@ pub enum Network {
// blockscout: https://pacific-explorer.manta.network/
// w3w.ai: https://manta.socialscan.io/
Manta = 169,
#[subenum(HypersyncNetwork)]
// Explorers:
// blockscout: https://explorer.jolnir.taiko.xyz/
TaikoJolnr = 167007,
#[subenum(HypersyncNetwork, NetworkWithExplorer)]
Kroma = 255,
#[subenum(HypersyncNetwork)]
Expand Down Expand Up @@ -174,14 +170,6 @@ pub enum Network {
Zora = 7777777,
#[subenum(HypersyncNetwork)]
// Explorers:
// https://explorer.publicgoods.network/
PublicGoods = 424,
#[subenum(HypersyncNetwork)]
// Explorers:
// Blockscout: https://explorer-mainnet-algorand-rollup.a1.milkomeda.com/
A1Milkomeda = 2002,
#[subenum(HypersyncNetwork)]
// Explorers:
// Blockscout: https://explorer-mainnet-cardano-evm.c1.milkomeda.com/
C1Milkomeda = 2001,
#[subenum(HypersyncNetwork)]
Expand All @@ -201,10 +189,6 @@ pub enum Network {
Zeta = 7000,
#[subenum(HypersyncNetwork)]
// Explorers:
// https://artio.beratrail.io/
BerachainArtio = 80085,
#[subenum(HypersyncNetwork)]
// Explorers:
// https://neonscan.org/
// https://neon.blockscout.com/
NeonEvm = 245022934,
Expand Down Expand Up @@ -245,6 +229,25 @@ pub enum Network {
// // Explorers:
// // https://explorer.degen.tips/
// Degen = 666666666,
#[subenum(HypersyncNetwork)]
Chiliz = 8888,
#[subenum(HypersyncNetwork)]
IncoGentryTestnet = 9090,
#[subenum(HypersyncNetwork)]
Zircuit = 48900,
#[subenum(HypersyncNetwork)]
MevCommit = 17864,
#[subenum(HypersyncNetwork)]
GaladrielDevnet = 696969,
#[subenum(HypersyncNetwork)]
SophonTestnet = 531050104,
#[subenum(HypersyncNetwork)]
KakarotSepolia = 1802203764,
#[subenum(HypersyncNetwork)]
BerachainBartio = 80084,
// Still syncing
// #[subenum(HypersyncNetwork)]
// Saakuru = 7225878,
}

impl Network {
Expand All @@ -260,39 +263,41 @@ impl Network {
//TODO: research a sufficient threshold for all chain (some should be 0)
pub fn get_confirmed_block_threshold(&self) -> i32 {
match self {
Network::EthereumMainnet
| Network::Goerli
//Reorgs do not happen on these networks
Network::OptimismGoerli
| Network::OptimismSepolia
| Network::Optimism
| Network::Base
| Network::ArbitrumOne
| Network::ArbitrumNova
| Network::ArbitrumGoerli
| Network::ArbitrumSepolia => 0,
//TODO: research a sufficient threshold for all chains
Network::Base
| Network::Mumbai
| Network::BaseSepolia
| Network::Bsc
| Network::PoaSokol
| Network::Chapel
| Network::PoaCore
| Network::Goerli
| Network::Gnosis
| Network::Fuse
| Network::Fantom
| Network::Polygon
| Network::Boba
| Network::OptimismGoerli
| Network::OptimismSepolia
| Network::Celo
| Network::Aurora
| Network::AuroraTestnet
| Network::Harmony
| Network::EthereumMainnet
| Network::PoaSokol
| Network::BscTestnet
| Network::PoaCore
| Network::Fuse
| Network::Clover
| Network::Moonbeam
| Network::Moonriver
| Network::Mbase
| Network::FantomTestnet
| Network::ArbitrumOne
| Network::ArbitrumNova
| Network::ArbitrumGoerli
| Network::ArbitrumSepolia
| Network::Celo
| Network::Fuji
| Network::Avalanche
| Network::CeloAlfajores
| Network::Mumbai
| Network::Aurora
| Network::AuroraTestnet
| Network::Harmony
| Network::BaseGoerli
| Network::ZksyncEra
| Network::Sepolia
Expand All @@ -305,21 +310,17 @@ impl Network {
| Network::Scroll
| Network::Metis
| Network::Manta
| Network::TaikoJolnr
| Network::Kroma
| Network::Lukso
| Network::XLayerTestnet
| Network::XLayer
| Network::Holesky
| Network::GnosisChiado
| Network::Zora
| Network::PublicGoods
| Network::A1Milkomeda
| Network::C1Milkomeda
| Network::Flare
| Network::Mantle
| Network::Zeta
| Network::BerachainArtio
| Network::NeonEvm
| Network::Rsk
| Network::ShimmerEvm
Expand All @@ -329,7 +330,15 @@ impl Network {
| Network::Amoy
| Network::Crab
| Network::Darwinia
| Network::Cyber => DEFAULT_CONFIRMED_BLOCK_THRESHOLD,
| Network::Cyber
| Network::Chiliz
| Network::IncoGentryTestnet
| Network::Zircuit
| Network::MevCommit
| Network::GaladrielDevnet
| Network::SophonTestnet
| Network::KakarotSepolia
| Network::BerachainBartio => DEFAULT_CONFIRMED_BLOCK_THRESHOLD,
}
}
}
Expand Down Expand Up @@ -469,9 +478,11 @@ pub fn get_confirmed_block_threshold_from_id(id: u64) -> i32 {

#[cfg(test)]
mod test {

use super::{get_etherscan_client, GraphNetwork, HypersyncNetwork, NetworkWithExplorer};
use crate::config_parsing::chain_helpers::Network;
use pretty_assertions::assert_eq;
use serde::Deserialize;
use strum::IntoEnumIterator;

#[test]
Expand Down Expand Up @@ -500,7 +511,7 @@ mod test {
#[test]
fn network_deserialize_graph() {
/*List of networks supported by graph found here:
* https://github.com/graphprotocol/graph-tooling/blob/main/packages/cli/src/protocols/index.ts#L76-L117
* https://github.com/graphprotocol/graph-tooling/blob/main/packages/cli/src/protocols/index.ts#L94-L132
*/
let networks = r#"[
"mainnet",
Expand All @@ -526,11 +537,12 @@ mod test {
"mbase",
"arbitrum-one",
"arbitrum-goerli",
"arbitrum-sepolia",
"optimism",
"optimism-goerli",
"aurora",
"aurora-testnet",
"base-goerli",
"base-testnet",
"base",
"zksync-era",
"zksync-era-testnet",
Expand All @@ -541,7 +553,16 @@ mod test {
"scroll"
]"#;

let supported_graph_networks = serde_json::from_str::<Vec<GraphNetwork>>(networks).unwrap();
let supported_graph_networks = serde_json::from_str::<Vec<String>>(networks)
.unwrap()
.into_iter()
.map(|s| {
GraphNetwork::deserialize(serde_json::Value::String(s.clone()))
// serde_json::from_str::<GraphNetwork>(&s)
.expect(format!("Invalid graph network: {}", s).as_str())
// GraphNetwork::from_str(&s).expect(format!("Invalid graph network: {}", s).as_str())
})
.collect::<Vec<GraphNetwork>>();

let defined_networks = GraphNetwork::iter().collect::<Vec<_>>();

Expand Down
60 changes: 3 additions & 57 deletions codegenerator/cli/src/config_parsing/hypersync_endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,8 @@ use anyhow::Context;

use super::chain_helpers::{HypersyncNetwork, Network};

pub fn network_to_skar_url(network: &HypersyncNetwork) -> String {
match network {
HypersyncNetwork::EthereumMainnet => "https://eth.hypersync.xyz".to_string(),
HypersyncNetwork::Polygon => "https://polygon.hypersync.xyz".to_string(),
HypersyncNetwork::Mumbai => "https://mumbai.hypersync.xyz".to_string(),
HypersyncNetwork::Gnosis => "https://gnosis.hypersync.xyz".to_string(),
HypersyncNetwork::Bsc => "https://bsc.hypersync.xyz".to_string(),
HypersyncNetwork::Goerli => "https://goerli.hypersync.xyz".to_string(),
HypersyncNetwork::Optimism => "https://optimism.hypersync.xyz".to_string(),
HypersyncNetwork::OptimismSepolia => "https://optimism-sepolia.hypersync.xyz".to_string(),
HypersyncNetwork::ArbitrumOne => "https://arbitrum.hypersync.xyz".to_string(),
HypersyncNetwork::ArbitrumSepolia => "https://arbitrum-sepolia.hypersync.xyz".to_string(),
HypersyncNetwork::Linea => "https://linea.hypersync.xyz".to_string(),
HypersyncNetwork::Sepolia => "https://sepolia.hypersync.xyz".to_string(),
HypersyncNetwork::Base => "https://base.hypersync.xyz".to_string(),
HypersyncNetwork::BaseSepolia => "https://base-sepolia.hypersync.xyz".to_string(),
HypersyncNetwork::Scroll => "https://scroll.hypersync.xyz".to_string(),
HypersyncNetwork::Metis => "https://metis.hypersync.xyz".to_string(),
HypersyncNetwork::TaikoJolnr => "https://taiko-jolnr.hypersync.xyz".to_string(),
HypersyncNetwork::Manta => "https://manta.hypersync.xyz".to_string(),
HypersyncNetwork::PolygonZkevm => "https://polygon-zkevm.hypersync.xyz".to_string(),
HypersyncNetwork::Kroma => "https://kroma.hypersync.xyz".to_string(),
HypersyncNetwork::Celo => "https://celo.hypersync.xyz".to_string(),
HypersyncNetwork::Avalanche => "https://avalanche.hypersync.xyz".to_string(),
HypersyncNetwork::Fuji => "https://fuji.hypersync.xyz".to_string(),
HypersyncNetwork::Boba => "https://boba.hypersync.xyz".to_string(),
HypersyncNetwork::ZksyncEra => "https://zksync.hypersync.xyz".to_string(),
HypersyncNetwork::Moonbeam => "https://moonbeam.hypersync.xyz".to_string(),
HypersyncNetwork::Lukso => "https://lukso.hypersync.xyz".to_string(),
HypersyncNetwork::Holesky => "https://holesky.hypersync.xyz".to_string(),
HypersyncNetwork::GnosisChiado => "https://gnosis-chiado.hypersync.xyz".to_string(),
HypersyncNetwork::XLayerTestnet => "https://x-layer-testnet.hypersync.xyz".to_string(),
HypersyncNetwork::XLayer => "https://x-layer.hypersync.xyz".to_string(),
HypersyncNetwork::A1Milkomeda => "https://a1-milkomeda.hypersync.xyz".to_string(),
HypersyncNetwork::PublicGoods => "https://publicgoods.hypersync.xyz".to_string(),
HypersyncNetwork::Zora => "https://zora.hypersync.xyz".to_string(),
HypersyncNetwork::Fantom => "https://fantom.hypersync.xyz".to_string(),
HypersyncNetwork::ArbitrumNova => "https://arbitrum-nova.hypersync.xyz".to_string(),
HypersyncNetwork::Harmony => "https://harmony-shard-0.hypersync.xyz".to_string(),
HypersyncNetwork::Aurora => "https://aurora.hypersync.xyz".to_string(),
HypersyncNetwork::C1Milkomeda => "https://c1-milkomeda.hypersync.xyz".to_string(),
HypersyncNetwork::Flare => "https://flare.hypersync.xyz".to_string(),
HypersyncNetwork::Mantle => "https://mantle.hypersync.xyz".to_string(),
HypersyncNetwork::Zeta => "https://zeta.hypersync.xyz".to_string(),
HypersyncNetwork::Rsk => "https://rsk.hypersync.xyz".to_string(),
HypersyncNetwork::BerachainArtio => "https://berachain-artio.hypersync.xyz".to_string(),
HypersyncNetwork::NeonEvm => "https://neon-evm.hypersync.xyz".to_string(),
HypersyncNetwork::ShimmerEvm => "https://shimmer-evm.hypersync.xyz".to_string(),
HypersyncNetwork::Blast => "https://blast.hypersync.xyz".to_string(),
HypersyncNetwork::BlastSepolia => "https://blast-sepolia.hypersync.xyz".to_string(),
HypersyncNetwork::FhenixTestnet => "https://fhenix-testnet.hypersync.xyz".to_string(),
HypersyncNetwork::Amoy => "https://amoy.hypersync.xyz".to_string(),
HypersyncNetwork::Crab => "https://crab.hypersync.xyz".to_string(),
HypersyncNetwork::Darwinia => "https://darwinia.hypersync.xyz".to_string(),
HypersyncNetwork::Cyber => "https://cyber.hypersync.xyz".to_string(),
}
pub fn network_to_hypersync_url(network: &HypersyncNetwork) -> String {
format!("https://{}.hypersync.xyz", *network as u64)
}

pub fn get_default_hypersync_endpoint(chain_id: u64) -> anyhow::Result<String> {
Expand All @@ -69,7 +15,7 @@ pub fn get_default_hypersync_endpoint(chain_id: u64) -> anyhow::Result<String> {
network_name, chain_id
))?;

Ok(network_to_skar_url(&network))
Ok(network_to_hypersync_url(&network))
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions codegenerator/cli/src/hbs_templating/codegen_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ mod test {
id: 1,
rpc_config: None,
hypersync_config: Some(HypersyncConfig {
endpoint_url: "https://eth.hypersync.xyz".to_string(),
endpoint_url: "https://1.hypersync.xyz".to_string(),
is_client_decoder: true,
}),
hyperfuel_config: None,
Expand Down Expand Up @@ -1020,7 +1020,7 @@ mod test {
id: 5,
rpc_config: None,
hypersync_config: Some(HypersyncConfig {
endpoint_url: "https://goerli.hypersync.xyz".to_string(),
endpoint_url: "https://5.hypersync.xyz".to_string(),
is_client_decoder: true,
}),
hyperfuel_config: None,
Expand Down
2 changes: 1 addition & 1 deletion scenarios/test_codegen/test/Config_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("getGeneratedByChainId Test", () => {
Assert.deepEqual(
configYaml,
{
syncSource: HyperSync({endpointUrl: "https://eth.hypersync.xyz"}),
syncSource: HyperSync({endpointUrl: "https://1.hypersync.xyz"}),
startBlock: 1,
confirmedBlockThreshold: 200,
contracts: Js.Dict.empty(),
Expand Down

0 comments on commit 2bcb91e

Please sign in to comment.