ethereumjs-monorepo
ethereumjs-monorepo copied to clipboard
devp2p / common: Polygon Support Analysis
Hi,
I'm trying out https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/devp2p/examples/simple.ts
and I'm using const common = Common.custom(CustomChain.PolygonMainnet)
and custom set of bootnodes from polygon's website const bootstrapNodes: BootstrapNodeConfig[] = [ { id: "0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c", ip: "44.232.55.71", port: "30303", location: "IDK", comment: "bootnode-1", chainId: 137, network: "bor-mainnet", }, { id: "88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710", ip: "159.203.9.164", port: "30303", location: "IDK", comment: "bootnode-2", chainId: 137, network: "bor-mainnet", }, { id: "4be7248c3a12c5f95d4ef5fff37f7c44ad1072fdb59701b2e5987c5f3846ef448ce7eabc941c5575b13db0fb016552c1fa5cca0dda1a8008cf6d63874c0f3eb7", ip: "3.93.224.197", port: "30303", location: "IDK", comment: "bootnode-3", chainId: 137, network: "bor-mainnet", }, { id: "32dd20eaf75513cf84ffc9940972ab17a62e88ea753b0780ea5eca9f40f9254064dacb99508337043d944c2a41b561a17deaad45c53ea0be02663e55e6a302b2", ip: "3.212.183.151", port: "30303", location: "IDK", comment: "bootnode-4", chainId: 137, network: "bor-mainnet", }, ];
But when it's trying to bootstrap it's throwing error DPT error: Error: Timeout error: ping 3.212.183.151:30303
Bootnode reference:- https://wiki.polygon.technology/docs/develop/network-details/full-node-deployment/
Oh, we have never tried to get the devp2p library working with Polygon. That's definitely an interesting experiment and we can keep this issue open and see over time if we get this working. If you continue on testing this out, writing down your experiences here is also highly appreciated. We can try to assist a bit on general upcoming questions around the devp2p library, but - again - this is very much new territory for us as well! 🙂
Ah, one thing as some starting point though, just occurred to me: the setting of a custom network with these predefined CustomChain
enum values is just a very much stripped down version of a chain configuration, basically just setting the chain ID and nothing else, so that things work for e.g. creating a tx containing the chain ID within the signature for replay protection.
For devp2p this is very likely not enough and you need a "full" Polygon chain config with the HF blocks and all that stuff (for devp2p for the fork hashes, you can google the associated EIP if this doesn't say you anything). So you should try to initialize a Polygon chain with a complete custom chain initialization, either using the @ethereumjs/common
chain file format (more/better structured but "proprietary"), see e.g. mainnet.json or a chain config in the Geth genesis file format (see doc link as well).
If you are successful and get a full chain config together we might even go the step to directly integrate this chain config file in the Common library, that would be pretty interesting if there are no caveats (does Polygon has its own HFs e.g.? 🤔).
Anyhow, hope that helps, happy networking! 🤩
Hi @holgerd77, I created an repo with correct chain settings, https://github.com/buchan123/devp2p-matic and still I'm getting timeouts on bootstrap node. It's basically timing out and Yes Polygon has it's own hardforks like "jaipur" and "delhi".

Hi @holgerd77, turns out the problem was I was passing port as string whereas it should be int, I fixed it now its able to connect to bootnodes. I'm trying check the peer-communication example and see if it remains connected to certain peers
Hi @holgerd77, turns out the problem was I was passing port as string whereas it should be int, I fixed it now its able to connect to bootnodes. I'm trying check the peer-communication example and see if it remains connected to certain peers
Hi, oh, that's really interesting, congrats 🤩, would it be ok for you if we take over parts of your code if we decide to integrate? I personally think this might be an interesting option.
@buchan123 I've generalized the title of your issue a bit, I hope that's ok, then we can keep this a bit as a general Polygon support analysis issue.