Skip to content

Commit

Permalink
remove inconsistency in genesis config
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Dec 13, 2016
1 parent a9d41ea commit 01d2544
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 73 deletions.
10 changes: 5 additions & 5 deletions eth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void help()
<< endl;
cout
<< "Client mode (default):" << endl
<< " --frontier Use the Frontier (1.0) protocol." << endl
<< " --mainnet Use the main network protocol." << endl
<< " --ropsten Use the Ropsten testnet." << endl
<< " --private <name> Use a private chain." << endl
<< " --test Testing mode: Disable PoW and provide test rpc interface." << endl
Expand Down Expand Up @@ -352,7 +352,7 @@ int main(int argc, char** argv)
#endif // ETH_JSONRPC

string jsonAdmin;
ChainParams chainParams(genesisInfo(eth::Network::Frontier), genesisStateRoot(eth::Network::Frontier));
ChainParams chainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));
u256 gasFloor = Invalid256;
string privateChain;

Expand Down Expand Up @@ -615,13 +615,13 @@ int main(int argc, char** argv)
}
else if (arg == "--gas-floor" && i + 1 < argc)
gasFloor = u256(argv[++i]);
else if (arg == "--frontier")
chainParams = ChainParams(genesisInfo(eth::Network::Frontier), genesisStateRoot(eth::Network::Frontier));
else if (arg == "--mainnet")
chainParams = ChainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));
else if (arg == "--ropsten" || arg == "--testnet")
chainParams = ChainParams(genesisInfo(eth::Network::Ropsten), genesisStateRoot(eth::Network::Ropsten));
else if (arg == "--oppose-dao-fork")
{
chainParams = ChainParams(genesisInfo(eth::Network::Frontier), genesisStateRoot(eth::Network::Frontier));
chainParams = ChainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));
chainParams.otherParams["daoHardforkBlock"] = toHex(u256(-1) - 10, HexPrefix::Add);
}
else if (arg == "--support-dao-fork")
Expand Down
8 changes: 5 additions & 3 deletions ethvm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using namespace std;
using namespace dev;
using namespace eth;

static const int64_t MaxBlockGasLimit = ChainParams(genesisInfo(Network::HomesteadTest)).u256Param("maxGasLimit").convert_to<int64_t>();
static const int64_t MaxBlockGasLimit = ChainParams(genesisInfo(Network::MainNetwork)).u256Param("maxGasLimit").convert_to<int64_t>();

void help()
{
Expand All @@ -59,7 +59,7 @@ void help()
<< " --vm <vm-kind> Select VM. Options are: interpreter, jit, smart. (default: interpreter)" << endl
#endif // ETH_EVMJIT
<< "Network options:" << endl
<< " --network Olympic|Frontier|Morden|Homestead" << endl
<< " --network Main|Ropsten|Homestead|Frontier" << endl
<< endl
<< "Options for trace:" << endl
<< " --flat Minimal whitespace in the JSON." << endl
Expand Down Expand Up @@ -129,7 +129,7 @@ int main(int argc, char** argv)
bool styledJson = true;
StandardTrace st;
EnvInfo envInfo;
Network networkName = Network::HomesteadTest;
Network networkName = Network::MainNetwork;
envInfo.setGasLimit(MaxBlockGasLimit);
bytes data;
bytes code;
Expand Down Expand Up @@ -194,6 +194,8 @@ int main(int argc, char** argv)
networkName = Network::Ropsten;
else if (network == "Homestead")
networkName = Network::HomesteadTest;
else if (network == "Main")
networkName = Network::MainNetwork;
else
{
cerr << "Unknown network type: " << network << endl;
Expand Down
9 changes: 5 additions & 4 deletions libethashseal/GenesisInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
This file is part of cpp-ethereum.
Expand Down Expand Up @@ -33,9 +34,9 @@ std::string const& dev::eth::genesisInfo(Network _n)
{
switch (_n)
{
case Network::Frontier: return c_genesisInfoFrontier;
case Network::MainNetwork: return c_genesisInfoFrontier;
case Network::Ropsten: return c_genesisInfoRopsten;
case Network::Test: return c_genesisInfoTest;
case Network::TransitionnetTest: return c_genesisInfoTest;
case Network::FrontierTest: return c_genesisInfoFrontierTest;
case Network::HomesteadTest: return c_genesisInfoHomesteadTest;
case Network::EIP150Test: return c_genesisInfoEIP150Test;
Expand All @@ -49,9 +50,9 @@ h256 const& dev::eth::genesisStateRoot(Network _n)
{
switch (_n)
{
case Network::Frontier: return c_genesisStateRootFrontier;
case Network::MainNetwork: return c_genesisStateRootFrontier;
case Network::Ropsten: return c_genesisStateRootRopsten;
case Network::Test: return c_genesisStateRootTest;
case Network::TransitionnetTest: return c_genesisStateRootTest;
case Network::FrontierTest: return c_genesisStateRootFrontierTest;
case Network::HomesteadTest: return c_genesisStateRootHomesteadTest;
case Network::EIP150Test: return c_genesisStateRootEIP150Test;
Expand Down
6 changes: 3 additions & 3 deletions libethashseal/GenesisInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace eth
enum class Network
{
//Olympic = 0, ///< Normal Olympic chain.
Frontier = 1, ///< Normal Frontier/Homestead chain.
//Morden = 2, ///< Normal Morden chain.
MainNetwork = 1, ///< Normal Frontier/Homestead/DAO/EIP150/EIP158 chain.
//Morden = 2, ///< Normal Morden chain.
Ropsten = 3, ///< New Ropsten Test Network
Test = 70, ///< Normal Frontier/Homestead chain without all the premine.
TransitionnetTest = 70, ///< Normal Frontier/Homestead/DAO/EIP150/EIP158 chain without all the premine.
FrontierTest = 71, ///< Just test the Frontier-era characteristics "forever" (no Homestead portion).
HomesteadTest = 72, ///< Just test the Homestead-era characteristics "forever" (no Frontier portion).
EIP150Test = 73, ///< Homestead + EIP150 Rules active from block 0 For BlockchainTests
Expand Down
1 change: 1 addition & 0 deletions libethashseal/genesis/eip150Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ R"E(
"params": {
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"homsteadForkBlock": "0x00",
"daoHardforkBlock": "0xfffffffffffffff",
"EIP150ForkBlock": "0x00",
"EIP158ForkBlock": "0xfffffffffffffff",
Expand Down
1 change: 1 addition & 0 deletions libethashseal/genesis/eip158Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ R"E(
"params": {
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"homsteadForkBlock": "0x00",
"daoHardforkBlock": "0xfffffffffffffff",
"EIP150ForkBlock": "0x00",
"EIP158ForkBlock": "0x00",
Expand Down
4 changes: 2 additions & 2 deletions libethashseal/genesis/frontier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ R"E(
"accountStartNonce": "0x00",
"homsteadForkBlock": "0x118c30",
"daoHardforkBlock": "0x1d4c00",
"EIP150ForkBlock": "0xfffffffffffffff",
"EIP158ForkBlock": "0xfffffffffffffff",
"EIP150ForkBlock": "0x259518",
"EIP158ForkBlock": "0x28d138",
"networkID" : "0x01",
"chainID": "0x01",
"maximumExtraDataSize": "0x20",
Expand Down
7 changes: 4 additions & 3 deletions libethashseal/genesis/homesteadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ R"E(
"params": {
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"daoHardforkBlock": "0x1d4c00",
"EIP150ForkBlock": "0x259518",
"EIP158ForkBlock": "0x28d138",
"homsteadForkBlock": "0x00",
"daoHardforkBlock": "0xfffffffffffffff",
"EIP150ForkBlock": "0xfffffffffffffff",
"EIP158ForkBlock": "0xfffffffffffffff",
"networkID" : "0x01",
"chainID": "0x01",
"minGasLimit": "0x1388",
Expand Down
10 changes: 4 additions & 6 deletions test/BlockChainHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,15 @@ void TestBlock::populateFrom(TestBlock const& _original)
m_dirty = false;
}

TestBlockChain::TestBlockChain(TestBlock const& _genesisBlock, bool _noProof)
TestBlockChain::TestBlockChain(TestBlock const& _genesisBlock)
{
reset(_genesisBlock, _noProof);
reset(_genesisBlock);
}

void TestBlockChain::reset(TestBlock const& _genesisBlock, bool _noProof)
void TestBlockChain::reset(TestBlock const& _genesisBlock)
{
(void)_noProof;
m_tempDirBlockchain.reset(new TransientDirectory);
ChainParams p = //_noProof ? ChainParams(genesisInfo(Network::FrontierTest), _genesisBlock.bytes(), _genesisBlock.accountMap()) :
ChainParams(genesisInfo(TestBlockChain::s_sealEngineNetwork), _genesisBlock.bytes(), _genesisBlock.accountMap());
ChainParams p = ChainParams(genesisInfo(TestBlockChain::s_sealEngineNetwork), _genesisBlock.bytes(), _genesisBlock.accountMap());

m_blockChain.reset(new BlockChain(p, m_tempDirBlockchain.get()->path(), WithExisting::Kill));
if (!m_blockChain->isKnown(BlockHeader::headerHashFromBlock(_genesisBlock.bytes())))
Expand Down
6 changes: 3 additions & 3 deletions test/BlockChainHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class TestBlock
class TestBlockChain
{
public:
TestBlockChain(bool _noProof = false): TestBlockChain(defaultGenesisBlock(), _noProof) {}
TestBlockChain(TestBlock const& _genesisBlock, bool _noProof = false);
TestBlockChain(): TestBlockChain(defaultGenesisBlock()) {}
TestBlockChain(TestBlock const& _genesisBlock);

void reset(TestBlock const& _genesisBlock, bool _noProof = false);
void reset(TestBlock const& _genesisBlock);
bool addBlock(TestBlock const& _block);
vector<TestBlock> syncUncles(vector<TestBlock> const& _uncles);
TestBlock const& topBlock() { return m_lastBlock; }
Expand Down
16 changes: 1 addition & 15 deletions test/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void printHelp()
cout << std::endl << "Test Creation" << std::endl;
cout << setw(30) << "--filltests" << setw(25) << "Run test fillers" << std::endl;
cout << setw(30) << "--checkstate" << setw(25) << "Enable expect section state checks" << std::endl;
cout << setw(30) << "--sealengine <Frontier|Homestead>" << setw(25) << "Set internal seal engine" << std::endl;
cout << setw(30) << "--createRandomTest" << setw(25) << "Create random test and output it to the console" << std::endl;
//cout << setw(30) << "--fulloutput" << setw(25) << "Disable address compression in the output field" << std::endl;

Expand Down Expand Up @@ -179,10 +178,7 @@ bytes ImportTest::executeTest()
{
if (m_testType == testType::StateTests)
{
eth::Network network = eth::Network::FrontierTest;
if (m_envInfo.number() >= dev::test::c_testHomesteadBlock)
network = eth::Network::HomesteadTest;

eth::Network network = eth::Network::MainNetwork;
std::pair<eth::State, ImportTest::execOutput> out = executeTransaction(network, m_envInfo, m_statePre, m_transaction);
m_statePost = out.first;
m_logs = out.second.second.log();
Expand Down Expand Up @@ -1153,16 +1149,6 @@ Options::Options(int argc, char** argv)
singleTestNet = std::string{argv[i + 1]};
else if (arg == "--fulloutput")
fulloutput = true;
else if (arg == "--sealengine")
{
if (std::string{argv[i + 1]} == "Frontier")
sealEngineNetwork = eth::Network::FrontierTest;
else if (std::string{argv[i + 1]} == "Homestead")
sealEngineNetwork = eth::Network::HomesteadTest;
else
sealEngineNetwork = eth::Network::Test;
++i;
}
else if (arg == "--verbosity" && i + 1 < argc)
{
static std::ostringstream strCout; //static string to redirect logs to
Expand Down
3 changes: 1 addition & 2 deletions test/TestHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ImportTest
struct transactionToExecute
{
transactionToExecute(int d, int g, int v, eth::Transaction const& t):
dataInd(d), gasInd(g), valInd(v), transaction(t), postState(0), netId(eth::Network::Test) {}
dataInd(d), gasInd(g), valInd(v), transaction(t), postState(0), netId(eth::Network::MainNetwork) {}
int dataInd;
int gasInd;
int valInd;
Expand Down Expand Up @@ -234,7 +234,6 @@ class Options
bool fulloutput = false;///< Replace large output to just it's length
bool createRandomTest = false; ///< Generate random test
Verbosity logVerbosity = Verbosity::NiceReport;
eth::Network sealEngineNetwork = eth::Network::Test; ///< set seal engine (Frontier, Homestead, ...)

/// Test selection
/// @{
Expand Down
34 changes: 24 additions & 10 deletions test/libethcore/difficulty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ void checkCalculatedDifficulty(BlockHeader const& _bi, BlockHeader const& _paren
u256 difficultyBoundDivisor;
switch(_n)
{
case Network::Frontier:
case Network::MainNetwork:
case Network::FrontierTest:
case Network::HomesteadTest:
case Network::Ropsten:
case Network::Test:
case Network::TransitionnetTest:
durationLimit = 13;
minimumDifficulty = 131072;
difficultyBoundDivisor = 2048;
Expand Down Expand Up @@ -194,12 +194,12 @@ BOOST_AUTO_TEST_CASE(difficultyTestsFrontier)
testFileFullName += "/BasicTests/difficultyFrontier.json";

Ethash sealEngine;
sealEngine.setChainParams(ChainParams(genesisInfo(Network::Frontier)));
sealEngine.setChainParams(ChainParams(genesisInfo(Network::FrontierTest)));

if (dev::test::Options::get().fillTests)
fillDifficulty(testFileFullName, sealEngine);

testDifficulty(testFileFullName, sealEngine, Network::Frontier);
testDifficulty(testFileFullName, sealEngine, Network::FrontierTest);
}

BOOST_AUTO_TEST_CASE(difficultyTestsRopsten)
Expand Down Expand Up @@ -230,13 +230,27 @@ BOOST_AUTO_TEST_CASE(difficultyTestsHomestead)
testDifficulty(testFileFullName, sealEngine, Network::HomesteadTest);
}

BOOST_AUTO_TEST_CASE(difficultyTestsCustomHomestead)
BOOST_AUTO_TEST_CASE(difficultyTestsMainNetwork)
{
string testFileFullName = test::getTestPath();
testFileFullName += "/BasicTests/difficultyCustomHomestead.json";
testFileFullName += "/BasicTests/difficultyMainNetwork.json";

Ethash sealEngine;
sealEngine.setChainParams(ChainParams(genesisInfo(Network::HomesteadTest)));
sealEngine.setChainParams(ChainParams(genesisInfo(Network::MainNetwork)));

if (dev::test::Options::get().fillTests)
fillDifficulty(testFileFullName, sealEngine);

testDifficulty(testFileFullName, sealEngine, Network::MainNetwork);
}

BOOST_AUTO_TEST_CASE(difficultyTestsCustomMainNetwork)
{
string testFileFullName = test::getTestPath();
testFileFullName += "/BasicTests/difficultyCustomMainNetwork.json";

Ethash sealEngine;
sealEngine.setChainParams(ChainParams(genesisInfo(Network::MainNetwork)));

if (dev::test::Options::get().fillTests)
{
Expand Down Expand Up @@ -290,7 +304,7 @@ BOOST_AUTO_TEST_CASE(difficultyTestsCustomHomestead)
writeFile(testFileFullName, asBytes(testFile));
}

testDifficulty(testFileFullName, sealEngine, Network::HomesteadTest);
testDifficulty(testFileFullName, sealEngine, Network::MainNetwork);
}

BOOST_AUTO_TEST_CASE(basicDifficultyTest)
Expand All @@ -299,9 +313,9 @@ BOOST_AUTO_TEST_CASE(basicDifficultyTest)
testPath += "/BasicTests/difficulty.json";

Ethash sealEngine;
sealEngine.setChainParams(ChainParams(genesisInfo(Network::Frontier)));
sealEngine.setChainParams(ChainParams(genesisInfo(Network::MainNetwork)));

testDifficulty(testPath, sealEngine, Network::Frontier);
testDifficulty(testPath, sealEngine, Network::MainNetwork);
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion test/libethereum/BlockChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(opendb)
{
TestBlock genesis = TestBlockChain::defaultGenesisBlock();
TransientDirectory tempDirBlockchain;
ChainParams p(genesisInfo(Network::Test), genesis.bytes(), genesis.accountMap());
ChainParams p(genesisInfo(Network::TransitionnetTest), genesis.bytes(), genesis.accountMap());
BlockChain bc(p, tempDirBlockchain.path(), WithExisting::Kill);
auto is_critical = []( std::exception const& _e) { return string(_e.what()).find("DatabaseAlreadyOpen") != string::npos; };
BOOST_CHECK_EXCEPTION(BlockChain bc2(p, tempDirBlockchain.path(), WithExisting::Verify), DatabaseAlreadyOpen, is_critical);
Expand Down
4 changes: 2 additions & 2 deletions test/libethereum/BlockChainTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct ChainBranch
else if (chainname == "EIP150")
dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::EIP150Test;
else if (chainname == "TestFtoH5")
dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::Test;
dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::TransitionnetTest;
}

static void resetBlockchain()
Expand All @@ -84,7 +84,7 @@ struct ChainBranch
static eth::Network s_tempBlockchainNetwork;
};

eth::Network ChainBranch::s_tempBlockchainNetwork = eth::Network::Test;
eth::Network ChainBranch::s_tempBlockchainNetwork = eth::Network::MainNetwork;

//Functions that working with test json
void compareBlocks(TestBlock const& _a, TestBlock const& _b);
Expand Down
3 changes: 1 addition & 2 deletions test/libethereum/BlockChainTestsBoost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class frontierFixture { public: frontierFixture() { dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::FrontierTest; } };
class homesteadFixture { public: homesteadFixture() { dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::HomesteadTest; } };
class transitionFixture { public: transitionFixture() { dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::Test; } };
class transitionFixture { public: transitionFixture() { dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::TransitionnetTest; } };
class eip150Fixture { public: eip150Fixture() { dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::EIP150Test; } };


Expand Down Expand Up @@ -158,7 +158,6 @@ BOOST_AUTO_TEST_CASE(bcWalletTest)
BOOST_AUTO_TEST_CASE(bcStateTest) { dev::test::executeTests("bcStateTest", "/BlockchainTests", "/BlockchainTestsFiller", dev::test::doBlockchainTests); }
BOOST_AUTO_TEST_CASE(userDefinedFile)
{
dev::test::TestBlockChain::s_sealEngineNetwork = dev::test::Options::get().sealEngineNetwork;
dev::test::userDefinedTest(dev::test::doBlockchainTests);
}
BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion test/libethereum/GasPricer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace dev::test;

namespace dev { namespace test {

void executeGasPricerTest(string const& name, double _etherPrice, double _blockFee, string const& bcTestPath, TransactionPriority _txPrio, u256 _expectedAsk, u256 _expectedBid, eth::Network _sealEngineNetwork = eth::Network::Test)
void executeGasPricerTest(string const& name, double _etherPrice, double _blockFee, string const& bcTestPath, TransactionPriority _txPrio, u256 _expectedAsk, u256 _expectedBid, eth::Network _sealEngineNetwork = eth::Network::TransitionnetTest)
{
BasicGasPricer gp(u256(double(ether / 1000) / _etherPrice), u256(_blockFee * 1000));

Expand Down
2 changes: 1 addition & 1 deletion test/libethereum/Genesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(genesis_tests)

js::mObject o = v.get_obj();

ChainParams p(genesisInfo(eth::Network::Frontier), genesisStateRoot(Network::Frontier));
ChainParams p(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(Network::MainNetwork));
BOOST_CHECK_EQUAL(p.calculateStateRoot(), h256(o["genesis_state_root"].get_str()));
BOOST_CHECK_EQUAL(toHex(p.genesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str())));
BOOST_CHECK_EQUAL(BlockHeader(p.genesisBlock()).hash(), h256(o["genesis_hash"].get_str()));
Expand Down
Loading

0 comments on commit 01d2544

Please sign in to comment.