Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChainID & NetworkID mixup #288

Open
H34D opened this issue Jun 21, 2022 · 0 comments
Open

ChainID & NetworkID mixup #288

H34D opened this issue Jun 21, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@H34D
Copy link
Contributor

H34D commented Jun 21, 2022

Describe the bug

The Ethereum Protocol supports two different identifiers for Networks ChainID and NetworkID

They can be retrieved with:

        const networkId = await this.web3.eth.net.getId()
        const chainId = await this.web3.eth.getChainId()

Using NetworkId for ChainId and vice versa can lead to unexpected problems on networks where they are different.

Additional info can be found here: https://besu.hyperledger.org/en/stable/Concepts/NetworkID-And-ChainID/

public async getPastEvents(options: EventOptions): EventResult {
const chainId = await this.web3.eth.net.getId()
options.fromBlock = 0
options.toBlock = 'latest'
// Temporary workaround to work with mumbai
// Infura as a 1000 blokcs limit on their api
if (chainId === 80001 || chainId === 42) {
const latestBlock = await this.web3.eth.getBlockNumber()
options.fromBlock = latestBlock - 99
}
const data = await this.getEventData(options)
return data
}

// TODO: https://github.com/nevermined-io/sdk-js/issues/265
// If the error is because of no support for eip-1559, just continue
const chainId = await this.web3.eth.net.getId()
// no eip-1559 support
if (![42220, 44787, 80001, 8997, 137].includes(chainId)) {
throw new KeeperError(err)
}

Peer-to-peer communication between nodes uses the network ID, 
while the transaction signature process uses the chain ID.

const chainId = await this.web3.eth.net.getId()
if (chainId == 44787 || chainId == 42220) {
console.log('Calling Celo...')
txparams = {
from,
value,
gas,
gasPrice
}
}

To Reproduce

Steps to reproduce the behavior:
1.
2.

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

@H34D H34D added the bug Something isn't working label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant