-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1033 from rsksmart/genesis-hash-fix
Genesis instance is retrieved when decoding block 0
- Loading branch information
Showing
6 changed files
with
200 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
rskj-core/src/main/java/org/ethereum/core/GenesisHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package org.ethereum.core; | ||
|
||
import co.rsk.core.BlockDifficulty; | ||
import co.rsk.core.Coin; | ||
import co.rsk.core.RskAddress; | ||
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils; | ||
import org.ethereum.crypto.HashUtil; | ||
import org.ethereum.util.ByteUtil; | ||
import org.ethereum.util.RLP; | ||
|
||
public class GenesisHeader extends BlockHeader { | ||
|
||
private final byte[] difficulty; | ||
|
||
public GenesisHeader(byte[] parentHash, | ||
byte[] unclesHash, | ||
byte[] logsBloom, | ||
byte[] difficulty, | ||
long number, | ||
byte[] gasLimit, | ||
long gasUsed, | ||
long timestamp, | ||
byte[] extraData, | ||
byte[] bitcoinMergedMiningHeader, | ||
byte[] bitcoinMergedMiningMerkleProof, | ||
byte[] bitcoinMergedMiningCoinbaseTransaction, | ||
byte[] minimumGasPrice, | ||
boolean useRskip92Encoding, | ||
byte[] coinbase, | ||
byte[] stateRootHash) { | ||
super( | ||
parentHash, | ||
unclesHash, | ||
new RskAddress(coinbase), | ||
stateRootHash, | ||
ByteUtils.clone(HashUtil.EMPTY_TRIE_HASH), | ||
ByteUtils.clone(HashUtil.EMPTY_TRIE_HASH), | ||
logsBloom, | ||
RLP.parseBlockDifficulty(difficulty), | ||
number, | ||
ByteUtil.stripLeadingZeroes(gasLimit), | ||
gasUsed, | ||
timestamp, | ||
extraData, | ||
Coin.ZERO, | ||
bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningMerkleProof, | ||
bitcoinMergedMiningCoinbaseTransaction, | ||
new byte[0], | ||
RLP.parseSignedCoinNonNullZero(minimumGasPrice), | ||
0, | ||
false, | ||
useRskip92Encoding, | ||
false); | ||
this.difficulty = ByteUtils.clone(difficulty); | ||
} | ||
|
||
public GenesisHeader(byte[] parentHash, | ||
byte[] unclesHash, | ||
byte[] logsBloom, | ||
byte[] difficulty, | ||
long number, | ||
byte[] gasLimit, | ||
long gasUsed, | ||
long timestamp, | ||
byte[] extraData, | ||
byte[] bitcoinMergedMiningHeader, | ||
byte[] bitcoinMergedMiningMerkleProof, | ||
byte[] bitcoinMergedMiningCoinbaseTransaction, | ||
byte[] minimumGasPrice, | ||
boolean useRskip92Encoding, | ||
byte[] coinbase) { | ||
super( | ||
parentHash, | ||
unclesHash, | ||
new RskAddress(coinbase), | ||
ByteUtils.clone(HashUtil.EMPTY_TRIE_HASH), | ||
ByteUtils.clone(HashUtil.EMPTY_TRIE_HASH), | ||
ByteUtils.clone(HashUtil.EMPTY_TRIE_HASH), | ||
logsBloom, | ||
RLP.parseBlockDifficulty(difficulty), | ||
number, | ||
ByteUtil.stripLeadingZeroes(gasLimit), | ||
gasUsed, | ||
timestamp, | ||
extraData, | ||
Coin.ZERO, | ||
bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningMerkleProof, | ||
bitcoinMergedMiningCoinbaseTransaction, | ||
new byte[0], | ||
RLP.parseSignedCoinNonNullZero(minimumGasPrice), | ||
0, | ||
false, | ||
useRskip92Encoding, | ||
false); | ||
this.difficulty = ByteUtils.clone(difficulty); | ||
} | ||
|
||
@Override | ||
protected byte[] encodeBlockDifficulty(BlockDifficulty ignored) { | ||
return RLP.encodeElement(difficulty); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters