harmony
harmony copied to clipboard
`block.chainid` returns unexpected id
Describe the bug
Querying of block.chainid
from smartcontract returns unexpected value
To Reproduce Steps to reproduce the behavior:
- Create smart contract with external view method which returns value of
block.chainid
- Deploy to Harmony Testnet Shard 0
- Call with web3
Expected behavior
Should returns 1666700000
Actual behavior
Returns 2
Additional context Ruins EIP712 implementation from open-zeppelin contracts
I can confirm this. I deployed this contract with remix on the testnet and get the same result.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
contract ChainIdViewer {
function chainId() public pure returns (uint256){
uint256 id;
assembly {
id := chainid()
}
return id;
}
}
Yes, the ‘block.chainid’ method called within the contract returns value of ‘2’. ChainId: 2 is currently assigned to ‘Expanse Network’.
Also just came across this. Is this only affecting the testnet or also the mainnet?
Also just came across this. Is this only affecting the testnet or also the mainnet?
I have only tried on the testnet
Also just came across this. Is this only affecting the testnet or also the mainnet?
Reading the code I assume it behaves the same way on mainnet, but returning 1
for mainnet.
@rlan35 this seems to not be conform with eip-155 (which was rolled out on Harmony):
This would provide a way to send transactions that work on Ethereum without working on ETC or the Morden testnet. ETC is encouraged to adopt this EIP but replacing CHAIN_ID with a different value, and all future testnets, consortium chains and alt-etherea are encouraged to adopt this EIP replacing CHAIN_ID with a unique value.
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
I'm not so firm with the harmony repository and couldn't locate where the ID is accessed. But I assume, that the value should return the config.EthCompatibleChainID
.
Fixed by #4154
@MaxMustermann2 Why is it marked fixed, if the hard fork wasn't completed?
https://github.com/harmony-one/harmony/blob/b11800fe3f813b682c22f056d5b5ed4809c0da19/internal/params/config.go#L68
block.chainid
still returns 1 for Harmony Mainnet.