Update to new genesis and eth-version 36

This commit is contained in:
nicksavers 2014-10-22 10:05:40 +02:00
parent e1a998ae08
commit f8021513fe
3 changed files with 10 additions and 12 deletions

View File

@ -3,7 +3,6 @@ package org.ethereum.core;
import org.ethereum.crypto.HashUtil;
import org.ethereum.trie.Trie;
import org.ethereum.trie.TrieImpl;
import org.ethereum.util.RLP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
@ -46,10 +45,9 @@ public class Genesis extends Block {
private static byte[] zeroHash256 = new byte[32];
private static byte[] zeroHash160 = new byte[20];
private static byte[] sha3EmptyList = HashUtil.sha3(RLP.encodeList());
public static byte[] PARENT_HASH = zeroHash256;
public static byte[] UNCLES_HASH = sha3EmptyList;
public static byte[] UNCLES_HASH = new byte[0];
public static byte[] COINBASE = zeroHash160;
public static byte[] DIFFICULTY = BigInteger.valueOf(2).pow(17).toByteArray();
public static long NUMBER = 0;

View File

@ -38,7 +38,7 @@ import static org.ethereum.net.message.StaticMessages.GET_TRANSACTIONS_MESSAGE;
*/
public class EthHandler extends SimpleChannelInboundHandler<EthMessage> {
public final static byte VERSION = 0x23;
public final static byte VERSION = 0x24;
public final static byte NETWORK_ID = 0x0;
private final static Logger logger = LoggerFactory.getLogger("net");

View File

@ -25,8 +25,8 @@ public class BlockTest {
}
// https://ethereum.etherpad.mozilla.org/12
private String PoC6_GENESIS_HEX_RLP_ENCODED = "f8abf8a7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a008bf6a98374f333b84e7d063d607696ac7cbbd409bd20fbe6a741c2dfc0eb28580830200008080830f4240808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0";
private String PoC6_GENESIS_HEX_HASH = "08436a4d33c77e6acf013e586a3333ad152f25d31df8b68749d85046810e1f4b";
private String PoC7_GENESIS_HEX_RLP_ENCODED = "f88bf887a0000000000000000000000000000000000000000000000000000000000000000080940000000000000000000000000000000000000000a008bf6a98374f333b84e7d063d607696ac7cbbd409bd20fbe6a741c2dfc0eb28580830200008080830f4240808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0";
private String PoC7_GENESIS_HEX_HASH = "9f0eb5da696ede7b44b22a8ef3a998f19e422195fdc9a8b3c82457858d310d6c";
String block_2 = "f8b5f8b1a0cf4b25b08b39350304fe12a16e4216c01a426f8f3dbf0d392b5b45"
+ "8ffb6a399da01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a1"
@ -57,7 +57,7 @@ public class BlockTest {
@Test /* got from go guy */
public void testGenesisFromRLP() {
// from RLP encoding
byte[] genesisBytes = Hex.decode(PoC6_GENESIS_HEX_RLP_ENCODED);
byte[] genesisBytes = Hex.decode(PoC7_GENESIS_HEX_RLP_ENCODED);
Block genesisFromRLP = new Block(genesisBytes);
Block genesis = Genesis.getInstance();
assertEquals(Hex.toHexString(genesis.getHash()), Hex.toHexString(genesisFromRLP.getHash()));
@ -86,8 +86,8 @@ public class BlockTest {
)
*/
Block genesis = Genesis.getInstance();
assertEquals(PoC6_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash()));
assertEquals(PoC6_GENESIS_HEX_RLP_ENCODED, Hex.toHexString(genesis.getEncoded()));
assertEquals(PoC7_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash()));
assertEquals(PoC7_GENESIS_HEX_RLP_ENCODED, Hex.toHexString(genesis.getEncoded()));
}
@Test /* block without transactions - block#32 in PoC5 cpp-chain */
@ -106,7 +106,7 @@ public class BlockTest {
@Test /* large block with 5 transactions -block#1 in PoC5 cpp-chain */
public void testBlockWithContractCreation() {
byte[] payload = Hex.decode(PoC6_GENESIS_HEX_RLP_ENCODED);
byte[] payload = Hex.decode(PoC7_GENESIS_HEX_RLP_ENCODED);
Block block = new Block(payload);
System.out.println(block.toString());
}
@ -122,7 +122,7 @@ public class BlockTest {
// Storing genesis because the parent needs to be in the DB for calculation.
WorldManager.getInstance().getBlockchain().add(genesis);
Block block1 = new Block(Hex.decode(PoC6_GENESIS_HEX_RLP_ENCODED));
Block block1 = new Block(Hex.decode(PoC7_GENESIS_HEX_RLP_ENCODED));
BigInteger calcDifficulty = new BigInteger(1, block1.calcDifficulty());
BigInteger actualDifficulty = new BigInteger(1, block1.getDifficulty());
System.out.println("Block#1 actual difficulty = " + actualDifficulty.toString());
@ -142,7 +142,7 @@ public class BlockTest {
WorldManager.getInstance().getBlockchain().add(genesis);
// Test with block
Block block1 = new Block(Hex.decode(PoC6_GENESIS_HEX_RLP_ENCODED));
Block block1 = new Block(Hex.decode(PoC7_GENESIS_HEX_RLP_ENCODED));
long calcGasLimit = block1.calcGasLimit();
long actualGasLimit = block1.getGasLimit();
System.out.println("Block#1 actual gasLimit = " + actualGasLimit);