Skip to content

Commit ba85329

Browse files
author
Lukasz Gasior
committed
fix
1 parent 98cebfb commit ba85329

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/main/resources/blockchain/default-genesis.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"gasLimit": "0x1388",
55
"nonce": "0x0000000000000042",
66
"ommersHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
7-
"timestamp": 0,
7+
"timestamp": "0x0",
88
"coinbase": "0x0000000000000000000000000000000000000000",
99
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
1010
"alloc": {

src/main/scala/io/iohk/ethereum/blockchain/data/GenesisDataLoader.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ class GenesisDataLoader(dataSource: DataSource, blockchain: Blockchain) extends
101101
number = 0,
102102
gasLimit = BigInt(genesisData.gasLimit.replace("0x", ""), 16),
103103
gasUsed = 0,
104-
unixTimestamp = genesisData.timestamp,
104+
unixTimestamp = BigInt(genesisData.timestamp.replace("0x", ""), 16).toLong,
105105
extraData = genesisData.extraData,
106-
mixHash = genesisData.mixHash,
106+
mixHash = genesisData.mixHash.getOrElse(zeros(hashLength)),
107107
nonce = genesisData.nonce)
108108

109109
blockchain.getBlockHeaderByNumber(0) match {
@@ -135,7 +135,10 @@ object GenesisDataLoader {
135135
implicit object ByteStringJsonFormat extends RootJsonFormat[ByteString] {
136136
def read(value: JsValue): ByteString = value match {
137137
case s: JsString =>
138-
val inp = s.value.replace("0x", "")
138+
val noPrefix = s.value.replace("0x", "")
139+
val inp =
140+
if (noPrefix.length % 2 == 0) noPrefix
141+
else "0" ++ noPrefix
139142
Try(ByteString(Hex.decode(inp))) match {
140143
case Success(bs) => bs
141144
case Failure(ex) => deserializationError("Cannot parse hex string: " + s)

src/main/scala/io/iohk/ethereum/blockchain/data/genesis.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ case class AllocAccount(balance: String)
66

77
case class GenesisData(
88
nonce: ByteString,
9-
mixHash: ByteString,
9+
mixHash: Option[ByteString],
1010
difficulty: String,
1111
extraData: ByteString,
1212
gasLimit: String,
1313
coinbase: ByteString,
14-
timestamp: Long,
14+
timestamp: String,
1515
alloc: Map[String, AllocAccount])

0 commit comments

Comments
 (0)