diff --git a/CHANGELOG.md b/CHANGELOG.md index a3ddd9a389d..d0677c2f792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ` now reads bytecode file from path and `aleth-vm --codefile - ` now reads bytcode from input. - Changed: [#5750](https://github.com/ethereum/aleth/pull/5750) Use `testeth -t -- --testfile ` to run the tests from file at any path. Use `testeth -t -- --testfile --singletest ` 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. diff --git a/aleth-vm/main.cpp b/aleth-vm/main.cpp index b580d9740d3..931b02c563a 100644 --- a/aleth-vm/main.cpp +++ b/aleth-vm/main.cpp @@ -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; @@ -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 se(ChainParams(genesisInfo(networkName)).createSealEngine()); @@ -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 map; map[contractDestination] = account; state.populateFrom(map);