Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5850 from ethereum/config-accounts-optional
Browse files Browse the repository at this point in the history
Make accounts section optional in config
  • Loading branch information
gumb0 authored Nov 26, 2019
2 parents 13c6e0a + 41ff2c8 commit bdc7674
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Changed: [#5837](https://github.com/ethereum/aleth/pull/5837) [#5839](https://github.com/ethereum/aleth/pull/5839) [#5845](https://github.com/ethereum/aleth/pull/5845) [#5846](https://github.com/ethereum/aleth/pull/5846) Output format of `testeth --jsontrace` command changed to better match output of geth's evm tool and to integrate with evmlab project.
- Removed: [#5760](https://github.com/ethereum/aleth/pull/5760) Official support for Visual Studio 2015 has been dropped. Compilation with this compiler is expected to stop working after migration to C++14.
- Removed: [#5840](https://github.com/ethereum/aleth/pull/5840) The list of precompiled contracts is not required in config files anymore.
- Removed: [#5850](https://github.com/ethereum/aleth/pull/5850) accounts section is now optional in config files.
- Fixed: [#5792](https://github.com/ethereum/aleth/pull/5792) Faster and cheaper execution of RPC functions which query blockchain state (e.g. getBalance).
- Fixed: [#5811](https://github.com/ethereum/aleth/pull/5811) RPC methods querying transactions (`eth_getTransactionByHash`, `eth_getBlockByNumber`) return correct `v` value.
- Fixed: [#5821](https://github.com/ethereum/aleth/pull/5821) `test_setChainParams` correctly initializes custom configuration of precompiled contracts.
Expand Down
8 changes: 5 additions & 3 deletions libethereum/ChainParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ void ChainParams::loadConfig(
string genesisStr = js::write_string(obj[c_genesis], false);
loadGenesis(genesisStr, _stateRoot);
// genesis state
string genesisStateStr = js::write_string(obj[c_accounts], false);

genesisState = jsonToAccountMap(genesisStateStr, accountStartNonce, nullptr, _configPath);
if (contains(obj, c_accounts))
{
string genesisStateStr = js::write_string(obj[c_accounts], false);
genesisState = jsonToAccountMap(genesisStateStr, accountStartNonce, nullptr, _configPath);
}

precompiled.insert({Address{0x1}, PrecompiledContract{"ecrecover"}});
precompiled.insert({Address{0x2}, PrecompiledContract{"sha256"}});
Expand Down
11 changes: 7 additions & 4 deletions libethereum/ValidationSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void validateConfigJson(js::mObject const& _obj)
{{c_sealEngine, {{js::str_type}, JsonFieldPresence::Required}},
{c_params, {{js::obj_type}, JsonFieldPresence::Required}},
{c_genesis, {{js::obj_type}, JsonFieldPresence::Required}},
{c_accounts, {{js::obj_type}, JsonFieldPresence::Required}}});
{c_accounts, {{js::obj_type}, JsonFieldPresence::Optional}}});

requireJsonFields(_obj.at(c_genesis).get_obj(), "ChainParams::loadConfig::genesis",
{{c_author, {{js::str_type}, JsonFieldPresence::Required}},
Expand All @@ -81,9 +81,12 @@ void validateConfigJson(js::mObject const& _obj)
{c_mixHash, {{js::str_type}, JsonFieldPresence::Required}},
{c_parentHash, {{js::str_type}, JsonFieldPresence::Optional}}});

js::mObject const& accounts = _obj.at(c_accounts).get_obj();
for (auto const& acc : accounts)
validateAccountObj(acc.second.get_obj());
if (_obj.count(c_accounts) != 0)
{
js::mObject const& accounts = _obj.at(c_accounts).get_obj();
for (auto const& acc : accounts)
validateAccountObj(acc.second.get_obj());
}
}

void validateAccountMaskObj(js::mObject const& _obj)
Expand Down
2 changes: 0 additions & 2 deletions test/unittests/libethereum/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ static std::string const c_configString = R"(
"gasLimit": "0x1000000000000",
"difficulty": "0x020000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"accounts": {
}
}
)";
Expand Down

0 comments on commit bdc7674

Please sign in to comment.