Geth has functions addPeer() and addTrustedPeer(). And I wonder is it possible to connect peer of another network? Does Geth have some security restrictions for such scenario? For example, comparing ids of networks?

4 Answers 4


I don't think it is possible and this are my thoughts on this:

  • nodes works as servers for chain: get a reference to the last block, resolve a function to mine a new block, reach consensus\get confirmations from the rest nodes
  • each chain has their own set of configuration parameters and it is unique in this way
  • that's why they are not mutually exclusive and can not be connected to each other directly, however there are 3rd party solutions which connect them (possible via proxy)

Technically you can do it, it will behave exactly the same as a single-chain client.

Block-chain is called so for a reason. Each block's execution depends on the previous ending state of a block.

So what is state:

Ethereum defines itself as a distributed state machine.

So…what is a state machine? Every Ethereum clients keep the holistic information of the whole chain. This information includes:

  • The account addresses
  • Other information that is related to the account
    • Balance
    • Nonce
    • storageRoot – for smart contract code
    • Hash – for smart contract

This information is known as the global state. The global state represents the condition that every Ethereum account is in at a specific time. It is consistently updated whenever a new block is generated. Ideally, all Ethereum nodes are synced to have the same state at all times. [source]

Blocks are bundles of transactions.

When a block is received, the Geth client runs these transactions and updates the state, block by block. To ensure correctness, each block has an attribute parentBlock, which ensures all blocks are processed in the right order. You can learn how block works in detail here.

You may have an answer to your question by now.

When blocks from two chains are trying to apply changes to the same state, only one of them will be successful, because it has the right parent.

The other ones will be classified as bad block -meaning the block can't be applied to the current state- will be saved to a bad block entry.

Hope this helps. Happy coding.

  • Are you sure? You haven't mentioned anything about the p2p protocol, which is the part responsible for the communication between clients.
    – Ismael
    Feb 2, 2023 at 15:54

It is possible to connect to a peer from another network with Geth, but there are some security considerations to keep in mind.

Geth uses a network ID to identify and separate different Ethereum networks, so if you try to connect to a peer from a different network, you may encounter compatibility issues. To prevent connecting to peers from an unintended network, Geth compares the network ID of the peer with the local node's network ID before establishing a connection.

Additionally, Geth has a security mechanism to prevent malicious peers from exploiting vulnerabilities in the network. When connecting to a new peer, Geth verifies the peer's identity using an encrypted and authenticated handshake. This process helps to ensure that the peer is genuine and can be trusted.

  • Did you try connecting with other network to see if it works?
    – Ismael
    Feb 6, 2023 at 18:50

Yes, it is possible to connect to a peer from another network using the addPeer or addTrustedPeer functions in Geth.

Geth does not enforce any restrictions on connecting to peers from different networks. However, it is important to keep in mind that connecting to a peer from a different network can lead to potential security risks, as well as compatibility issues.

In a decentralized network like Ethereum, each node operates on its own copy of the blockchain. When connecting to a peer from a different network, the node may receive a different version of the blockchain, leading to a fork in the network.

Therefore, it is recommended to only connect to trusted peers and to validate the network ID of the peer before connecting. This can be achieved by comparing the network ID, which is a unique identifier for each Ethereum network. However, the network ID comparison is not built into Geth and needs to be implemented manually.

  • Did you try connecting with other network to see if it works?
    – Ismael
    Feb 4, 2023 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.