Genesis calc fixed
This commit is contained in:
parent
1f2c70387f
commit
f1ad918831
|
@ -39,11 +39,7 @@ public class Genesis extends Block {
|
||||||
"1a26338f0d905e295fccb71fa9ea849ffa12aaf4", // # (A)
|
"1a26338f0d905e295fccb71fa9ea849ffa12aaf4", // # (A)
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
Logger logger = LoggerFactory.getLogger("main");
|
||||||
// The proof-of-concept series include a development premine, making the state root hash
|
|
||||||
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
|
|
||||||
private AccountState acct = new AccountState(BigInteger.ZERO, BigInteger.valueOf(2).pow(200));
|
|
||||||
|
|
||||||
|
|
||||||
private static byte[] zeroHash256 = new byte[32];
|
private static byte[] zeroHash256 = new byte[32];
|
||||||
private static byte[] zeroHash160 = new byte[20];
|
private static byte[] zeroHash160 = new byte[20];
|
||||||
|
@ -68,11 +64,14 @@ public class Genesis extends Block {
|
||||||
NUMBER, MIN_GAS_PRICE, GAS_LIMIT, GAS_USED, TIMESTAMP,
|
NUMBER, MIN_GAS_PRICE, GAS_LIMIT, GAS_USED, TIMESTAMP,
|
||||||
EXTRA_DATA, NONCE, null, null);
|
EXTRA_DATA, NONCE, null, null);
|
||||||
|
|
||||||
// Premine state
|
// The proof-of-concept series include a development premine, making the state root hash
|
||||||
|
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
|
||||||
for (String address : premine) {
|
for (String address : premine) {
|
||||||
WorldManager.instance.repository.createAccount(Hex.decode(address));
|
WorldManager.instance.repository.createAccount(Hex.decode(address));
|
||||||
WorldManager.instance.repository.addBalance (Hex.decode(address), BigInteger.valueOf(2).pow(200) );
|
WorldManager.instance.repository.addBalance (Hex.decode(address), BigInteger.valueOf(2).pow(200) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setStateRoot( WorldManager.instance.repository.getRootHash() );
|
||||||
logger.info("Genesis-hash: " + Hex.toHexString(this.getHash()));
|
logger.info("Genesis-hash: " + Hex.toHexString(this.getHash()));
|
||||||
logger.info("Genesis-stateRoot: " + Hex.toHexString(this.getStateRoot()));
|
logger.info("Genesis-stateRoot: " + Hex.toHexString(this.getStateRoot()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,10 @@ public class Repository {
|
||||||
ContractDetails details = new ContractDetails();
|
ContractDetails details = new ContractDetails();
|
||||||
contractDetailsDB.put(addr, details.getEncoded());
|
contractDetailsDB.put(addr, details.getEncoded());
|
||||||
|
|
||||||
|
if (logger.isInfoEnabled())
|
||||||
|
logger.info("New account created: [ {} ]", Hex.toHexString(addr));
|
||||||
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,6 @@ public class BlockTest {
|
||||||
*/
|
*/
|
||||||
Block genesis = Genesis.getInstance();
|
Block genesis = Genesis.getInstance();
|
||||||
assertEquals(CPP_PoC5_GENESIS_HEX_RLP_ENCODED, Hex.toHexString(genesis.getEncoded()));
|
assertEquals(CPP_PoC5_GENESIS_HEX_RLP_ENCODED, Hex.toHexString(genesis.getEncoded()));
|
||||||
|
|
||||||
// Not really a good test because this compares Genesis.getHash() to itself
|
|
||||||
assertEquals(CPP_PoC5_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash()));
|
assertEquals(CPP_PoC5_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue