Storing the block.chainid is not safe. See this issue from a prior contest for details.
