ganache icon indicating copy to clipboard operation
ganache copied to clipboard

Unable to set a different networkId when fork mainnet

Open baibinghere opened this issue 2 years ago • 2 comments

> ganache-cli --version
ganache v7.4.1 (@ganache/cli: 0.5.1, @ganache/core: 0.5.1)

> ganache-cli --fork https://mainnet.infura.io/v3/infuraToken --unlock "0xb527a981e1d415AF696936B3174f2d7
aC8D11369" --chain.chainId 999 --chain.networkId 999
ganache v7.4.1 (@ganache/cli: 0.5.1, @ganache/core: 0.5.1)
Starting RPC server

Available Accounts                                       
==================                                       
(0) 0x3FFc491644cFac697E6B882BaFbD7769631476c4 (1000 ETH)
(1) 0x5Eb6a195494c3292C324C74161dD2Cc76e18A4fe (1000 ETH)
(2) 0x71969f8A3326502e428325f33Fb97Ce433d032D2 (1000 ETH)
(3) 0x8088CE397D98ecAcF46d5235D8528B39422CAb1D (1000 ETH)
(4) 0xd47Db623B7309AD6199F79A56676Fd976D3f39F9 (1000 ETH)
(5) 0x8251Cc65d8fe19Ddfe93f6bB8f65481A9b46C163 (1000 ETH)
(6) 0x848b79A17314f6Db83907208367916dcbd361745 (1000 ETH)
(7) 0x620b5F98165A41b52c3731aC14411B81E193b30a (1000 ETH)
(8) 0x1c0666486ef1702095aA089e81e2e90bc5e1B8A5 (1000 ETH)
(9) 0x22c7F59d6A077844f81BB797Ec7f26E349E8443b (1000 ETH)

Private Keys
==================
(0) 0x3356d8270631af099d50f4bbc9e0d3a052224d2b5ee6b37f29a02c6ba6afd06d
(1) 0xe6fc0c38cc94bc28456f9f20570b53aad40daf30d7c580ff6a9bb8ff8fdd95c3
(2) 0xd2cac05ac4768e9ee7d51b814a38a92e7836005bf0e60dc3b70d5c5c0ec30e1c
(3) 0xacd21829460b611d5791a6ad754f456a22708b2ebf08ce9fa10ae36c837414b2
(4) 0x00b2b6ec569dc1632f75f7302a7af43728e12d0fbd362828e2f37b275ca19aad
(5) 0xa19a84cdafbc86644b5e4c45084992902ecf795cd90e568ed7d31c39522d3702
(6) 0x948903800d9cbbab5d0ccc340c454dec3e069e201952287b1cb1e2e5cf53f05e
(7) 0x0240e4e1c1e29a4472b6d7b47994e6ebb014ee36667c34271d14fad741480686
(8) 0x6d80e0cfc366facc1b3325d5beea23ef6dca20a198111b7cd650146f014b8c79
(9) 0x01c0ce6f2a95e7d2b7ec4b8b558e796a72b2e36fff2ad9d43d4374f0aa4186bb

HD Wallet
==================
Mnemonic:      license laugh crane wife speed critic zebra poem control coyote input miracle
Base HD Path:  m/44'/60'/0'/0/{account_index}

Default Gas Price
==================
2000000000

BlockGas Limit
==================
30000000

Call Gas Limit
==================
50000000

Forked Chain
==================
Location:        https://mainnet.infura.io/v3/infuraToken
Block:           15466144
Network ID:      1
Time:            Sat Sep 03 2022 23:27:17 GMT+0800 (China Standard Time)

Chain Id
==================
999

RPC Listening on 127.0.0.1:8545

As you can see, I've specified the networkId to be 999, but the forked chain still has the networkId 1.

If forked chain can't change networkId, we need to know, this command should bail out instead of keep running. It may confuse many people that it's a bug cauing --chain.networkId un-usable.

baibinghere avatar Sep 03 '22 15:09 baibinghere

Quick note for when we work this: This is a bit tricky because Truffle needs the networkId field in order to call fetchExternal in the debugger. So Ganache would still need to give Truffle the correct network id of the fork, while also maintaining the user-set network id.

MicaiahReid avatar Sep 15 '22 20:09 MicaiahReid

I think a message or warning could be much better for user experience point of view...

baibinghere avatar Sep 16 '22 03:09 baibinghere