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

Commit

Permalink
Changes for this revision:
Browse files Browse the repository at this point in the history
- Added changelog for added parameter change.
- Made some revisions based on review.
  • Loading branch information
josephnicholas committed Nov 27, 2019
1 parent 99528a1 commit bb59c10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added: [#5699](https://github.com/ethereum/aleth/pull/5699) EIP 2046: Reduced gas cost for static calls made to precompiles.
- Added: [#5741](https://github.com/ethereum/aleth/pull/5741) Support for individual EIP activation to facilitate EIP-centric network upgrade process.
- Added: [#5752](https://github.com/ethereum/aleth/pull/5752) [#5753](https://github.com/ethereum/aleth/pull/5753) [#5809](https://github.com/ethereum/aleth/pull/5809) Implement EIP1380 (reduced gas costs for call-to-self).
- Added: [#5848](https://github.com/ethereum/aleth/pull/5848) Add "codefile" parameter into aleth-vm options. `aleth-vm --codefile <PATH>` now reads bytecode file from path and `aleth-vm --codefile - <bytecode>` now reads bytcode from input.
- Changed: [#5750](https://github.com/ethereum/aleth/pull/5750) Use `testeth -t <SUITE_NAME> -- --testfile <PATH>` to run the tests from file at any path. Use `testeth -t <SUITE_NAME> -- --testfile <PATH> --singletest <TEST_NAME>` to run only single test from any file.
- Changed: [#5801](https://github.com/ethereum/aleth/pull/5801) `testeth -t BlockchainTests` command now doesn't run the tests for the forks before Istanbul. To run those tests use a separate LegacyTests suite with command `testeth -t LegacyTests/Constantinople/BlockchainTests`.
- Changed: [#5807](https://github.com/ethereum/aleth/pull/5807) Optimize selfdestruct opcode in LegacyVM by reducing state accesses in certain out-of-gas scenarios.
Expand Down
24 changes: 14 additions & 10 deletions aleth-vm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ int main(int argc, char** argv)
// Read code from input file.
if (!codeFile.empty())
{
if (vm.count("code"))
if (!code.empty())
{
cerr << "Options --code and --codefile shouldn't be used at the same time" << '\n';
return AlethErrors::BadConfigOption;
Expand All @@ -255,14 +255,7 @@ int main(int argc, char** argv)
std::getline(std::cin, code);
else
code = contentsString(codeFile);

try // Try decoding from hex.
{
code.erase(code.find_last_not_of(" \t\n\r") + 1); // Right trim.
}
catch (BadHexCharacter const&)
{
} // Ignore decoding errors./ Right trim.
code.erase(code.find_last_not_of(" \t\n\r") + 1); // Right trim.
}

unique_ptr<SealEngineFace> se(ChainParams(genesisInfo(networkName)).createSealEngine());
Expand All @@ -276,7 +269,18 @@ int main(int argc, char** argv)
// Deploy the code on some fake account to be called later.
Account account(0, 0);
auto const latestVersion = se->evmSchedule(envInfo.number()).accountVersion;
account.setCode(fromHex(code, WhenError::Throw), latestVersion);

bytes codeBytes{};
try
{
codeBytes = fromHex(code, WhenError::Throw);
}catch (BadHexCharacter const& e)
{
cerr << "Exception: " << e.what() << '\n';
return AlethErrors::BadFormatOption;
}

account.setCode(bytes{codeBytes}, latestVersion);
std::unordered_map<Address, Account> map;
map[contractDestination] = account;
state.populateFrom(map);
Expand Down

0 comments on commit bb59c10

Please sign in to comment.