├── .bumpversion.cfg ├── .clang-format ├── .dockerignore ├── .editorconfig ├── .gitignore ├── .gitmodules ├── .travis.yml ├── .ycm_extra_conf.py ├── CHANGELOG.md ├── CMakeLists.txt ├── CODING_STYLE.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── aleth-bootnode ├── CMakeLists.txt ├── README.md └── main.cpp ├── aleth-key ├── CMakeLists.txt ├── KeyAux.h └── main.cpp ├── aleth-vm ├── CMakeLists.txt └── main.cpp ├── aleth ├── AccountManager.cpp ├── AccountManager.h ├── CMakeLists.txt ├── MinerAux.cpp ├── MinerAux.h └── main.cpp ├── appveyor.yml ├── circle.yml ├── cmake ├── EthCcache.cmake ├── EthCheckCXXCompilerFlag.cmake ├── EthCompilerSettings.cmake ├── EthDependencies.cmake ├── EthExecutableHelper.cmake ├── EthOptions.cmake ├── EthUtils.cmake ├── FindLevelDB.cmake ├── FindMiniupnpc.cmake ├── Hunter │ ├── config.cmake │ └── passwords.cmake ├── HunterGate.cmake ├── ProjectBinaryen.cmake ├── ProjectLibFF.cmake ├── ProjectMPIR.cmake ├── ProjectSecp256k1.cmake ├── UseMiniupnpc.cmake ├── scripts │ ├── configure.cmake │ ├── copydlls.cmake │ ├── helpers.cmake │ ├── jsonrpcstub.cmake │ ├── resource.hpp.in │ ├── resources.cmake │ └── runtest.cmake ├── secp256k1 │ └── CMakeLists.txt └── templates │ └── BuildInfo.h.in ├── codecov.yml ├── doc ├── Doxyfile ├── database_layout.rst ├── dependencies.rst ├── generating_tests.rst ├── gitbook │ ├── README.md │ ├── SUMMARY.md │ ├── aleth-key.md │ ├── book.json │ ├── cli_tools.md │ ├── cold_wallet_storage_device.md │ ├── getting_started.md │ ├── installation.md │ ├── interactive_console.md │ ├── mining.md │ ├── styles │ │ └── website.css │ ├── transaction_explorer.md │ └── whisper.md ├── index.rst ├── private_net_remix.rst ├── private_net_sync.rst ├── snapshot_sync.rst └── usingtesteth.rst ├── homebrew ├── INSTALL_RECEIPT.json ├── fix_homebrew_paths_in_standalone_zip.py ├── homebrew.mxcl.cpp-ethereum.plist └── prepare_receipt.sh ├── libaleth-interpreter ├── CMakeLists.txt ├── VM.cpp ├── VM.h ├── VMCalls.cpp ├── VMConfig.h ├── VMOpt.cpp └── interpreter.h ├── libdevcore ├── Address.cpp ├── Address.h ├── Assertions.h ├── Base64.cpp ├── Base64.h ├── CMakeLists.txt ├── Common.cpp ├── Common.h ├── CommonData.cpp ├── CommonData.h ├── CommonIO.cpp ├── CommonIO.h ├── CommonJS.cpp ├── CommonJS.h ├── DBFactory.cpp ├── DBFactory.h ├── Exceptions.h ├── FileSystem.cpp ├── FileSystem.h ├── FixedHash.cpp ├── FixedHash.h ├── Guards.cpp ├── Guards.h ├── JsonUtils.cpp ├── JsonUtils.h ├── LevelDB.cpp ├── LevelDB.h ├── Log.cpp ├── Log.h ├── LoggingProgramOptions.cpp ├── LoggingProgramOptions.h ├── LruCache.h ├── MemoryDB.cpp ├── MemoryDB.h ├── OverlayDB.cpp ├── OverlayDB.h ├── RLP.cpp ├── RLP.h ├── RangeMask.h ├── RocksDB.cpp ├── RocksDB.h ├── SHA3.cpp ├── SHA3.h ├── StateCacheDB.cpp ├── StateCacheDB.h ├── Terminal.h ├── TransientDirectory.cpp ├── TransientDirectory.h ├── TrieCommon.cpp ├── TrieCommon.h ├── TrieDB.h ├── TrieHash.cpp ├── TrieHash.h ├── UndefMacros.h ├── Worker.cpp ├── Worker.h ├── concurrent_queue.h ├── db.h ├── dbfwd.h └── vector_ref.h ├── libdevcrypto ├── AES.cpp ├── AES.h ├── Blake2.cpp ├── Blake2.h ├── CMakeLists.txt ├── Common.cpp ├── Common.h ├── CryptoPP.cpp ├── CryptoPP.h ├── Exceptions.h ├── Hash.cpp ├── Hash.h ├── LibSnark.cpp ├── LibSnark.h ├── SecretStore.cpp └── SecretStore.h ├── libethashseal ├── CMakeLists.txt ├── Ethash.cpp ├── Ethash.h ├── EthashCPUMiner.cpp ├── EthashCPUMiner.h ├── EthashProofOfWork.cpp ├── EthashProofOfWork.h ├── GenesisInfo.cpp ├── GenesisInfo.h └── genesis │ ├── mainNetwork.cpp │ ├── ropsten.cpp │ └── test │ ├── ByzantiumToConstantinopleFixAt5Test.cpp │ ├── EIP158ToByzantiumAt5Test.cpp │ ├── berlinTest.cpp │ ├── byzantiumNoProofTest.cpp │ ├── byzantiumTest.cpp │ ├── byzantiumTransitionTest.cpp │ ├── constantinopleFixTest.cpp │ ├── constantinopleNoProofTest.cpp │ ├── constantinopleTest.cpp │ ├── eip150Test.cpp │ ├── eip158Test.cpp │ ├── experimentalTransitionTest.cpp │ ├── frontierNoProofTest.cpp │ ├── frontierTest.cpp │ ├── frontierToHomesteadAt5Test.cpp │ ├── homesteadTest.cpp │ ├── homesteadToDaoAt5Test.cpp │ ├── homesteadToEIP150At5Test.cpp │ ├── istanbulTest.cpp │ ├── istanbulTransitionTest.cpp │ ├── mainNetworkNoProofTest.cpp │ ├── mainNetworkTest.cpp │ ├── muirGlacierTest.cpp │ └── transitionnetTest.cpp ├── libethcore ├── BasicAuthority.cpp ├── BasicAuthority.h ├── BlockHeader.cpp ├── BlockHeader.h ├── CMakeLists.txt ├── ChainOperationParams.cpp ├── ChainOperationParams.h ├── Common.cpp ├── Common.h ├── CommonJS.cpp ├── CommonJS.h ├── EVMSchedule.cpp ├── EVMSchedule.h ├── Exceptions.h ├── KeyManager.cpp ├── KeyManager.h ├── LogEntry.cpp ├── LogEntry.h ├── Precompiled.cpp ├── Precompiled.h ├── SealEngine.cpp ├── SealEngine.h ├── TransactionBase.cpp └── TransactionBase.h ├── libethereum ├── Account.cpp ├── Account.h ├── BasicGasPricer.cpp ├── BasicGasPricer.h ├── Block.cpp ├── Block.h ├── BlockChain.cpp ├── BlockChain.h ├── BlockChainImporter.cpp ├── BlockChainImporter.h ├── BlockChainSync.cpp ├── BlockChainSync.h ├── BlockDetails.cpp ├── BlockDetails.h ├── BlockQueue.cpp ├── BlockQueue.h ├── CMakeLists.txt ├── ChainParams.cpp ├── ChainParams.h ├── Client.cpp ├── Client.h ├── ClientBase.cpp ├── ClientBase.h ├── ClientTest.cpp ├── ClientTest.h ├── CodeSizeCache.h ├── CommonNet.cpp ├── CommonNet.h ├── DatabasePaths.cpp ├── DatabasePaths.h ├── EthereumCapability.cpp ├── EthereumCapability.h ├── EthereumPeer.cpp ├── EthereumPeer.h ├── Executive.cpp ├── Executive.h ├── ExtVM.cpp ├── ExtVM.h ├── GasPricer.cpp ├── GasPricer.h ├── GenericFarm.h ├── GenericMiner.cpp ├── GenericMiner.h ├── GenesisInfo.cpp ├── GenesisInfo.h ├── ImportPerformanceLogger.cpp ├── ImportPerformanceLogger.h ├── Interface.cpp ├── Interface.h ├── LastBlockHashesFace.h ├── LogFilter.cpp ├── LogFilter.h ├── SecureTrieDB.h ├── SnapshotImporter.cpp ├── SnapshotImporter.h ├── SnapshotStorage.cpp ├── SnapshotStorage.h ├── StandardTrace.cpp ├── StandardTrace.h ├── State.cpp ├── State.h ├── StateImporter.cpp ├── StateImporter.h ├── Transaction.cpp ├── Transaction.h ├── TransactionQueue.cpp ├── TransactionQueue.h ├── TransactionReceipt.cpp ├── TransactionReceipt.h ├── ValidationSchemes.cpp ├── ValidationSchemes.h ├── VerifiedBlock.h ├── WarpCapability.cpp └── WarpCapability.h ├── libevm ├── CMakeLists.txt ├── EVMC.cpp ├── EVMC.h ├── ExtVMFace.cpp ├── ExtVMFace.h ├── Instruction.cpp ├── Instruction.h ├── LegacyVM.cpp ├── LegacyVM.h ├── LegacyVMCalls.cpp ├── LegacyVMConfig.h ├── LegacyVMOpt.cpp ├── VMFace.h ├── VMFactory.cpp └── VMFactory.h ├── libp2p ├── All.h ├── CMakeLists.txt ├── Capability.h ├── CapabilityHost.cpp ├── CapabilityHost.h ├── Common.cpp ├── Common.h ├── ENR.cpp ├── ENR.h ├── EndpointTracker.cpp ├── EndpointTracker.h ├── Host.cpp ├── Host.h ├── Network.cpp ├── Network.h ├── NodeTable.cpp ├── NodeTable.h ├── Peer.cpp ├── Peer.h ├── RLPXFrameCoder.cpp ├── RLPXFrameCoder.h ├── RLPXPacket.h ├── RLPXSocket.h ├── RLPxHandshake.cpp ├── RLPxHandshake.h ├── Session.cpp ├── Session.h ├── UDP.cpp ├── UDP.h ├── UPnP.cpp └── UPnP.h ├── libweb3jsonrpc ├── AccountHolder.cpp ├── AccountHolder.h ├── AdminEth.cpp ├── AdminEth.h ├── AdminEthFace.h ├── AdminNet.cpp ├── AdminNet.h ├── AdminNetFace.h ├── CMakeLists.txt ├── Debug.cpp ├── Debug.h ├── DebugFace.h ├── Eth.cpp ├── Eth.h ├── EthFace.h ├── IpcServer.h ├── IpcServerBase.cpp ├── IpcServerBase.h ├── JsonHelper.cpp ├── JsonHelper.h ├── ModularServer.h ├── Net.cpp ├── Net.h ├── NetFace.h ├── Personal.cpp ├── Personal.h ├── PersonalFace.h ├── SessionManager.cpp ├── SessionManager.h ├── Test.cpp ├── Test.h ├── TestFace.h ├── UnixSocketServer.cpp ├── UnixSocketServer.h ├── Web3.cpp ├── Web3.h ├── Web3Face.h ├── WinPipeServer.cpp ├── WinPipeServer.h ├── admin_eth.json ├── admin_net.json ├── debug.json ├── eth.json ├── net.json ├── personal.json ├── test.json └── web3.json ├── libwebthree ├── CMakeLists.txt ├── WebThree.cpp └── WebThree.h ├── refilltests ├── rlp ├── CMakeLists.txt └── main.cpp ├── sanitizer-blacklist.txt ├── scripts ├── aleth.py ├── build.sh ├── cleanup_ccache.sh ├── docker-eth ├── docker │ ├── aleth.dockerfile │ ├── cpp-build-env.dockerfile │ ├── eth-centos │ │ └── Dockerfile │ ├── eth-debian │ │ └── Dockerfile │ ├── eth-fedora │ │ └── Dockerfile │ └── eth-oraclelinux │ │ └── Dockerfile ├── dopple.py ├── duplicates.sh ├── install_cmake.sh ├── install_solc_lllc.sh ├── plot_sync_perf.py ├── ppabuild.sh ├── runalltests.sh ├── sync_files_with_solidity.sh ├── tests.bat ├── tests.sh └── upload-homebrew-formula.sh ├── snapcraft.yaml ├── test ├── CMakeLists.txt ├── tools │ ├── fuzzTesting │ │ ├── BoostRandomCode.cpp │ │ ├── BoostRandomCode.h │ │ ├── RandomCode.h │ │ ├── createRandomTest.cpp │ │ ├── fuzzHelper.cpp │ │ └── fuzzHelper.h │ ├── jsontests │ │ ├── BlockChainTests.cpp │ │ ├── BlockChainTests.h │ │ ├── LegacyTests.cpp │ │ ├── LegacyTests.h │ │ ├── RLPTests.cpp │ │ ├── StateTestFixtureBase.h │ │ ├── StateTests.cpp │ │ ├── StateTests.h │ │ ├── TransactionTests.cpp │ │ ├── TransactionTests.h │ │ ├── vm.cpp │ │ └── vm.h │ ├── libtesteth │ │ ├── AllTestNames.h.in │ │ ├── BlockChainHelper.cpp │ │ ├── BlockChainHelper.h │ │ ├── FillJsonFunctions.cpp │ │ ├── ImportTest.cpp │ │ ├── ImportTest.h │ │ ├── JsonSpiritHeaders.h │ │ ├── Options.cpp │ │ ├── Options.h │ │ ├── Stats.cpp │ │ ├── Stats.h │ │ ├── TestHelper.cpp │ │ ├── TestHelper.h │ │ ├── TestOutputHelper.cpp │ │ ├── TestOutputHelper.h │ │ ├── TestSuite.cpp │ │ ├── TestSuite.h │ │ ├── TestUtils.cpp │ │ ├── TestUtils.h │ │ ├── boostTest.cpp │ │ ├── wast2wasm.cpp │ │ └── wast2wasm.h │ └── libtestutils │ │ ├── BlockChainLoader.cpp │ │ ├── BlockChainLoader.h │ │ ├── Common.cpp │ │ ├── Common.h │ │ ├── FixedClient.cpp │ │ ├── FixedClient.h │ │ └── TestLastBlockHashes.h └── unittests │ ├── libdevcore │ ├── CommonJS.cpp │ ├── FixedHash.cpp │ ├── LruCache.cpp │ ├── RLP.cpp │ ├── RangeMask.cpp │ └── core.cpp │ ├── libdevcrypto │ ├── AES.cpp │ ├── LibSnark.cpp │ ├── MemTrie.cpp │ ├── MemTrie.h │ ├── SecretStore.cpp │ ├── crypto.cpp │ ├── hexPrefix.cpp │ └── trie.cpp │ ├── libethashseal │ └── EthashTest.cpp │ ├── libethcore │ ├── BlockHeader.cpp │ ├── CommonJS.cpp │ ├── KeyManager.cpp │ ├── PrecompiledTest.cpp │ ├── SealEngineTest.cpp │ └── difficulty.cpp │ ├── libethereum │ ├── Block.cpp │ ├── BlockChain.cpp │ ├── BlockChainInsert.cpp │ ├── BlockQueue.cpp │ ├── ClientBase.cpp │ ├── ClientTest.cpp │ ├── ExecutiveTest.cpp │ ├── ExtVMTest.cpp │ ├── GasPricer.cpp │ ├── Genesis.cpp │ ├── SnapshotImporterTest.cpp │ ├── StateUnitTests.cpp │ ├── Transaction.cpp │ ├── TransactionQueue.cpp │ └── ValidationSchemes.cpp │ ├── libevm │ └── VMTest.cpp │ ├── libp2p │ ├── ENRTest.cpp │ ├── EndpointTrackerTest.cpp │ ├── capability.cpp │ ├── eip-8.cpp │ ├── net.cpp │ ├── peer.cpp │ └── rlpx.cpp │ ├── libtesteth │ ├── blockchainTest.cpp │ ├── statetestTest.cpp │ └── testHelperTest.cpp │ ├── libweb3core │ ├── memorydb.cpp │ ├── overlaydb.cpp │ └── statecachedb.cpp │ ├── libweb3jsonrpc │ ├── AccountHolder.cpp │ ├── Client.cpp │ ├── JSON_test.sol │ ├── WebThreeStubClient.h │ └── jsonrpc.cpp │ └── performance │ ├── README │ ├── add128.asm │ ├── add256.asm │ ├── add64.asm │ ├── bop.sol │ ├── csv2gas.py │ ├── csv2nano.py │ ├── csv2ops.py │ ├── div128.asm │ ├── div256.asm │ ├── div64.asm │ ├── exp.asm │ ├── fun.sol │ ├── log2csv.py │ ├── loop.sol │ ├── mix.sol │ ├── mul128.asm │ ├── mul256.asm │ ├── mul64.asm │ ├── mul64c.c │ ├── nop.asm │ ├── parity-tests.sh │ ├── pop.asm │ ├── pop.sol │ ├── popcpyc.c │ ├── popincc.c │ ├── poplnkc.c │ ├── rc5.sol │ ├── rng.sol │ ├── shift-tests.asm │ ├── sub128.asm │ ├── sub256.asm │ ├── sub64.asm │ ├── tests.mk │ ├── thrash.sol │ └── top.sol └── utils └── json_spirit ├── JsonSpiritHeaders.h ├── json_spirit.h ├── json_spirit.vcproj ├── json_spirit_error_position.h ├── json_spirit_reader.cpp ├── json_spirit_reader.h ├── json_spirit_reader_template.h ├── json_spirit_stream_reader.h ├── json_spirit_utils.h ├── json_spirit_value.cpp ├── json_spirit_value.h ├── json_spirit_writer.cpp ├── json_spirit_writer.h └── json_spirit_writer_template.h /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.8.0 3 | commit = True 4 | message = Aleth {new_version} 5 | 6 | Bump version: {current_version} → {new_version} 7 | tag = True 8 | sign_tags = True 9 | tag_message = Aleth {new_version} 10 | parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?Prc|alpha)\.(?P\d+))? 11 | serialize = 12 | {major}.{minor}.{patch}-{prerel}.{prerelver} 13 | {major}.{minor}.{patch} 14 | 15 | [bumpversion:part:prerel] 16 | optional_value = rel 17 | values = 18 | alpha 19 | rc 20 | rel 21 | 22 | [bumpversion:file:CMakeLists.txt] 23 | 24 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /build 2 | /deps 3 | /test/jsontests 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # http://editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.{cpp,c,hpp,h}] 14 | indent_style = tab 15 | indent_size = 4 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # VS stuff 16 | build 17 | ipch 18 | *.sdf 19 | *.opensdf 20 | *.suo 21 | *.vcxproj 22 | *.vcxproj.filters 23 | *.sln 24 | 25 | # VIM stuff 26 | *.swp 27 | 28 | # Xcode stuff 29 | build_xc 30 | 31 | *.user 32 | *.user.* 33 | *~ 34 | 35 | # build system 36 | build.*/ 37 | /deps/ 38 | extdep/install 39 | extdep/download 40 | /cmake-build-*/ 41 | 42 | *.pyc 43 | 44 | # MacOS Development 45 | .DS_Store 46 | # CocoaPods 47 | Pods/ 48 | Podfile.lock 49 | # Xcode 50 | .DS_Store 51 | build/ 52 | *.pbxuser 53 | !default.pbxuser 54 | *.mode1v3 55 | !default.mode1v3 56 | *.mode2v3 57 | !default.mode2v3 58 | *.perspectivev3 59 | !default.perspectivev3 60 | *.xcworkspace 61 | !default.xcworkspace 62 | xcuserdata 63 | *.xcuserstate 64 | profile 65 | *.moved-aside 66 | DerivedData 67 | project.pbxproj 68 | 69 | # JetBrains stuff 70 | .idea/ 71 | cmake-build-*/ 72 | bin/ 73 | 74 | # Visual Studio Code 75 | browse.VC.db 76 | 77 | doc/html 78 | *.autosave 79 | node_modules/ 80 | 81 | dependency_graph.svg 82 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/jsontests"] 2 | path = test/jsontests 3 | url = https://github.com/ethereum/tests.git 4 | [submodule "evmc"] 5 | path = evmc 6 | url = https://github.com/ethereum/evmc 7 | [submodule "cable"] 8 | path = cmake/cable 9 | url = https://github.com/ethereum/cable 10 | [submodule "scripts/dopple"] 11 | path = scripts/dopple 12 | url = https://github.com/ethereum/dopple 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Aleth Contributing and Review Guidelines 2 | 3 | 1. All submitted **Pull Requests** are assumed to be ready for review 4 | unless they are labeled with `[in progress]` or have "[WIP]" in title. 5 | 6 | 2. All submitted **Pull Requests** which change Aleth in a way that is visible to users (e.g. new features, bug fixes, significant logging changes) should include an entry in [`CHANGELOG.md`](CHANGELOG.md) in the unreleased version section. Please categorize your entry appropriately and group it with other entries of the same category. Please see the following for details on categories and how to make a good changelog entry: https://keepachangelog.com/en/1.0.0/ 7 | 8 | 2. **Code formatting** rules are described by the [Clang-Format Style Options] file [.clang-format]. 9 | Please use the [clang-format] (version 5.0 or higher recommended) tool to format your code _changes_ accordingly. 10 | [git-clang-format] tool is useful to limit reformatting to your changes only: 11 | 12 | git clang-format # to reformat the changes in the staging area and put the result into working directory 13 | git clang-format -f # to reformat the changes in the working directory 14 | git clang-format # to reformat commits between specified commit and HEAD 15 | 16 | 17 | [Clang-Format Style Options]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html 18 | [clang-format]: https://clang.llvm.org/docs/ClangFormat.html 19 | [.clang-format]: .clang-format 20 | [git-clang-format]: https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format 21 | 22 | -------------------------------------------------------------------------------- /aleth-bootnode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( 2 | sources 3 | main.cpp 4 | ) 5 | 6 | add_executable(aleth-bootnode ${sources}) 7 | target_link_libraries( 8 | aleth-bootnode 9 | PRIVATE p2p devcore Boost::program_options 10 | ) 11 | 12 | install(TARGETS aleth-bootnode DESTINATION bin) 13 | -------------------------------------------------------------------------------- /aleth-key/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(aleth-key KeyAux.h main.cpp) 2 | target_link_libraries(aleth-key PRIVATE ethcore devcore Boost::program_options) 3 | install(TARGETS aleth-key EXPORT alethTargets DESTINATION bin) 4 | -------------------------------------------------------------------------------- /aleth-vm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(aleth-vm main.cpp) 2 | 3 | target_link_libraries(aleth-vm PRIVATE ethereum evm ethashseal devcore Boost::program_options) 4 | 5 | target_include_directories(aleth-vm PRIVATE ../utils) 6 | 7 | install(TARGETS aleth-vm EXPORT alethTargets DESTINATION bin) 8 | -------------------------------------------------------------------------------- /aleth/AccountManager.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | #include 7 | 8 | /** 9 | * Add account management functionnalities to CLI. 10 | * account list 11 | * account new 12 | * account update 13 | * account import 14 | * wallet import (import presale wallet) 15 | */ 16 | class AccountManager 17 | { 18 | public: 19 | /// uses @a argc, @a argv provided by the CLI and executes implemented options. 20 | bool execute(int argc, char** argv); 21 | /// stream account help section 22 | void static streamAccountHelp(std::ostream& _out); 23 | /// stream wallet help section 24 | void static streamWalletHelp(std::ostream& _out); 25 | 26 | private: 27 | /// ask end user to create a password. 28 | std::string createPassword(std::string const& _prompt) const; 29 | /// creates a ramdom secret/address pair. It uses ICAP. 30 | dev::KeyPair makeKey() const; 31 | /// instanciate KeyManager and open the wallet. 32 | bool openWallet(); 33 | 34 | std::unique_ptr m_keyManager; 35 | }; 36 | 37 | 38 | -------------------------------------------------------------------------------- /aleth/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( 2 | sources 3 | AccountManager.cpp AccountManager.h 4 | main.cpp 5 | MinerAux.cpp MinerAux.h 6 | ) 7 | 8 | add_executable(aleth ${sources}) 9 | target_link_libraries( 10 | aleth 11 | PRIVATE ethereum ethashseal evm web3jsonrpc webthree devcore Boost::program_options 12 | ) 13 | 14 | target_include_directories(aleth PRIVATE ../utils) 15 | 16 | if(MINIUPNPC) 17 | target_compile_definitions(aleth PRIVATE ETH_MINIUPNPC) 18 | endif() 19 | 20 | install(TARGETS aleth DESTINATION bin) 21 | -------------------------------------------------------------------------------- /aleth/MinerAux.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// CLI module for mining. 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | class BadArgument: public dev::Exception {}; 15 | 16 | class MinerCLI 17 | { 18 | public: 19 | enum class OperationMode 20 | { 21 | None, 22 | Benchmark 23 | }; 24 | 25 | explicit MinerCLI(OperationMode _mode = OperationMode::None) : mode(_mode) 26 | { 27 | } 28 | 29 | void execute(); 30 | 31 | std::string minerType() const { return m_minerType; } 32 | 33 | void interpretOptions(boost::program_options::variables_map const& _options); 34 | static boost::program_options::options_description createProgramOptions(unsigned int _lineLength); 35 | 36 | private: 37 | void doBenchmark(std::string const& _m, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5); 38 | 39 | /// Operating mode. 40 | OperationMode mode; 41 | 42 | /// Mining options 43 | std::string m_minerType = "cpu"; 44 | unsigned m_miningThreads = UINT_MAX; 45 | uint64_t m_currentBlock = 0; 46 | 47 | /// Benchmarking params 48 | unsigned m_benchmarkWarmup = 3; 49 | unsigned m_benchmarkTrial = 3; 50 | unsigned m_benchmarkTrials = 5; 51 | }; 52 | -------------------------------------------------------------------------------- /cmake/EthCcache.cmake: -------------------------------------------------------------------------------- 1 | # Setup ccache. 2 | # 3 | # The ccache is auto-enabled if the tool is found. 4 | # To disable set -DCCACHE=OFF option. 5 | if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER) 6 | find_program(CCACHE ccache DOC "ccache tool path; set to OFF to disable") 7 | if(CCACHE) 8 | set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE}) 9 | if(COMMAND cotire) 10 | # Change ccache config to meet cotire requirements. 11 | set(ENV{CCACHE_SLOPPINESS} pch_defines,time_macros) 12 | endif() 13 | message(STATUS "[ccache] Enabled: ${CCACHE}") 14 | endif() 15 | endif() 16 | -------------------------------------------------------------------------------- /cmake/EthCheckCXXCompilerFlag.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlag) 2 | 3 | # Adds CXX compiler flag if the flag is supported by the compiler. 4 | # 5 | # This is effectively a combination of CMake's check_cxx_compiler_flag() 6 | # and add_compile_options(): 7 | # 8 | # if(check_cxx_compiler_flag(flag)) 9 | # add_compile_options(flag) 10 | # 11 | function(eth_add_cxx_compiler_flag_if_supported FLAG) 12 | # Remove leading - or / from the flag name. 13 | string(REGEX REPLACE "^-|/" "" name ${FLAG}) 14 | check_cxx_compiler_flag(${FLAG} ${name}) 15 | if(${name}) 16 | add_compile_options(${FLAG}) 17 | endif() 18 | 19 | # If the optional argument passed, store the result there. 20 | if(ARGV1) 21 | set(${ARGV1} ${name} PARENT_SCOPE) 22 | endif() 23 | endfunction() 24 | -------------------------------------------------------------------------------- /cmake/FindMiniupnpc.cmake: -------------------------------------------------------------------------------- 1 | # Find miniupnpc 2 | # 3 | # Find the miniupnpc includes and library 4 | # 5 | # if you nee to add a custom library search path, do it via CMAKE_PREFIX_PATH 6 | # 7 | # This module defines 8 | # MINIUPNPC_INCLUDE_DIRS, where to find header, etc. 9 | # MINIUPNPC_LIBRARIES, the libraries needed to use miniupnpc. 10 | # MINIUPNPC_FOUND, If false, do not try to use miniupnpc. 11 | 12 | # only look in default directories 13 | find_path( 14 | MINIUPNPC_INCLUDE_DIR 15 | NAMES miniupnpc/miniupnpc.h 16 | DOC "miniupnpc include dir" 17 | ) 18 | 19 | find_library( 20 | MINIUPNPC_LIBRARY 21 | NAMES miniupnpc 22 | DOC "miniupnpc library" 23 | ) 24 | 25 | set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR}) 26 | set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY}) 27 | 28 | # debug library on windows 29 | # same naming convention as in QT (appending debug library with d) 30 | # boost is using the same "hack" as us with "optimized" and "debug" 31 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") 32 | 33 | find_library( 34 | MINIUPNPC_LIBRARY_DEBUG 35 | NAMES miniupnpcd 36 | DOC "miniupnpc debug library" 37 | ) 38 | 39 | set(MINIUPNPC_LIBRARIES "iphlpapi" optimized ${MINIUPNPC_LIBRARIES} debug ${MINIUPNPC_LIBRARY_DEBUG}) 40 | 41 | endif() 42 | 43 | # handle the QUIETLY and REQUIRED arguments and set MINIUPNPC_FOUND to TRUE 44 | # if all listed variables are TRUE, hide their existence from configuration view 45 | include(FindPackageHandleStandardArgs) 46 | find_package_handle_standard_args(miniupnpc DEFAULT_MSG 47 | MINIUPNPC_LIBRARY MINIUPNPC_INCLUDE_DIR) 48 | mark_as_advanced (MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY) 49 | 50 | -------------------------------------------------------------------------------- /cmake/Hunter/config.cmake: -------------------------------------------------------------------------------- 1 | # cryptopp has very bad CMakeLists.txt config. 2 | # We have to enforce "cross compiling mode" there by setting CMAKE_SYSTEM_VERSION=NO 3 | # to any "false" value. 4 | hunter_config(cryptopp VERSION ${HUNTER_cryptopp_VERSION} CMAKE_ARGS CMAKE_SYSTEM_VERSION=NO) 5 | 6 | hunter_config( 7 | libjson-rpc-cpp 8 | VERSION ${HUNTER_libjson-rpc-cpp_VERSION} 9 | CMAKE_ARGS 10 | UNIX_DOMAIN_SOCKET_SERVER=NO 11 | UNIX_DOMAIN_SOCKET_CLIENT=NO 12 | FILE_DESCRIPTOR_SERVER=NO 13 | FILE_DESCRIPTOR_CLIENT=NO 14 | TCP_SOCKET_SERVER=NO 15 | TCP_SOCKET_CLIENT=NO 16 | HTTP_SERVER=NO 17 | HTTP_CLIENT=NO 18 | ) 19 | 20 | hunter_config(Boost VERSION 1.70.0-p0) 21 | 22 | hunter_config( 23 | intx 24 | VERSION 0.4.0 25 | URL https://github.com/chfast/intx/archive/v0.4.0.tar.gz 26 | SHA1 8a2a0b0efa64899db972166a9b3568a6984c61bc 27 | ) 28 | 29 | hunter_config( 30 | GTest 31 | VERSION 1.8.1 32 | URL https://github.com/google/googletest/archive/release-1.8.1.tar.gz 33 | SHA1 152b849610d91a9dfa1401293f43230c2e0c33f8 34 | CMAKE_ARGS BUILD_GMOCK=OFF gtest_force_shared_crt=ON 35 | ) 36 | 37 | if (MSVC) 38 | hunter_config( 39 | libscrypt 40 | VERSION ${HUNTER_libscrypt_VERSION} 41 | CMAKE_ARGS CMAKE_C_FLAGS=-D_CRT_SECURE_NO_WARNINGS 42 | ) 43 | endif() -------------------------------------------------------------------------------- /cmake/Hunter/passwords.cmake: -------------------------------------------------------------------------------- 1 | 2 | hunter_upload_password( 3 | # REPO_OWNER + REPO = https://github.com/ethereum/hunter-cache 4 | REPO_OWNER "ethereum" 5 | REPO "hunter-cache" 6 | 7 | # USERNAME = https://github.com/hunter-cache-bot 8 | USERNAME "hunter-cache-bot" 9 | 10 | # PASSWORD = GitHub token saved as a secure environment variable 11 | PASSWORD "$ENV{GITHUB_USER_PASSWORD}" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/ProjectMPIR.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set(prefix "${CMAKE_BINARY_DIR}/deps") 4 | set(MPIR_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}mpir${CMAKE_STATIC_LIBRARY_SUFFIX}") 5 | set(MPIR_INCLUDE_DIR "${prefix}/include") 6 | 7 | ExternalProject_Add(mpir 8 | PREFIX "${prefix}" 9 | DOWNLOAD_NAME mpir-cmake.tar.gz 10 | DOWNLOAD_NO_PROGRESS TRUE 11 | URL https://github.com/chfast/mpir/archive/cmake.tar.gz 12 | URL_HASH SHA256=d32ea73cb2d8115a8e59b244f96f29bad7ff03367162b660bae6495826811e06 13 | CMAKE_ARGS 14 | -DCMAKE_INSTALL_PREFIX= 15 | -DCMAKE_INSTALL_LIBDIR=lib 16 | -DCMAKE_BUILD_TYPE=Release 17 | -DMPIR_GMP=On 18 | BUILD_BYPRODUCTS "${MPIR_LIBRARY}" 19 | ) 20 | 21 | add_library(MPIR::mpir STATIC IMPORTED) 22 | set_property(TARGET MPIR::mpir PROPERTY IMPORTED_CONFIGURATIONS Release) 23 | set_property(TARGET MPIR::mpir PROPERTY IMPORTED_LOCATION_RELEASE ${MPIR_LIBRARY}) 24 | set_property(TARGET MPIR::mpir PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MPIR_INCLUDE_DIR}) 25 | add_dependencies(MPIR::mpir mpir) 26 | -------------------------------------------------------------------------------- /cmake/UseMiniupnpc.cmake: -------------------------------------------------------------------------------- 1 | function(eth_apply TARGET REQUIRED) 2 | find_package (Miniupnpc 1.8.2013) 3 | if (MINIUPNPC AND MINIUPNPC_FOUND) 4 | target_include_directories(${TARGET} SYSTEM PRIVATE ${MINIUPNPC_INCLUDE_DIRS}) 5 | target_link_libraries(${TARGET} ${MINIUPNPC_LIBRARIES}) 6 | target_compile_definitions(${TARGET} PUBLIC ETH_MINIUPNPC) 7 | elseif (NOT ${REQUIRED} STREQUAL "OPTIONAL") 8 | message(FATAL_ERROR "Miniupnpc library not found") 9 | endif() 10 | endfunction() 11 | -------------------------------------------------------------------------------- /cmake/scripts/configure.cmake: -------------------------------------------------------------------------------- 1 | # adds possibility to run configure_file as buildstep 2 | # reference: 3 | # http://www.cmake.org/pipermail/cmake/2012-May/050227.html 4 | # 5 | # This module expects 6 | # INFILE 7 | # OUTFILE 8 | # other custom vars 9 | # 10 | # example usage: 11 | # cmake -DINFILE=blah.in -DOUTFILE=blah.out -Dvar1=value1 -Dvar2=value2 -P scripts/configure.cmake 12 | 13 | configure_file(${INFILE} ${OUTFILE}) 14 | 15 | -------------------------------------------------------------------------------- /cmake/scripts/copydlls.cmake: -------------------------------------------------------------------------------- 1 | # this module expects 2 | # DLLS 3 | # CONF 4 | # DESTINATION 5 | 6 | # example usage: 7 | # cmake -DDLL_DEBUG=xd.dll -DDLL_RELEASE=x.dll -DCONFIGURATION=Release -DDESTINATION=dest -P scripts/copydlls.cmake 8 | 9 | # this script is created cause we do not know configuration in multiconfiguration generators at cmake configure phase ;) 10 | 11 | if ("${CONF}" STREQUAL "Debug") 12 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL_DEBUG}" "${DESTINATION}") 13 | 14 | # hack, copy it twice. with and without d.dll suffix 15 | # at first let's get the file name part 16 | get_filename_component(DLL_DEBUG_D_NAME ${DLL_DEBUG} NAME) 17 | string(REPLACE "d.dll" ".dll" DLL_DEBUG_D_NAME "${DLL_DEBUG_D_NAME}") 18 | string(REPLACE "_.dll" ".dll" DLL_DEBUG_D_NAME "${DLL_DEBUG_D_NAME}") 19 | 20 | set(DESTINATION_D "${DESTINATION}/${DLL_DEBUG_D_NAME}") 21 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL_DEBUG}" "${DESTINATION_D}") 22 | else () 23 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL_RELEASE}" "${DESTINATION}") 24 | endif() 25 | -------------------------------------------------------------------------------- /cmake/scripts/resource.hpp.in: -------------------------------------------------------------------------------- 1 | // this file is autogenerated, do not modify!!! 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | namespace dev 8 | { 9 | namespace eth 10 | { 11 | 12 | class ${ETH_RESOURCE_NAME} 13 | { 14 | public: 15 | ${ETH_RESOURCE_NAME}() 16 | { 17 | ${ETH_RESULT_DATA} 18 | ${ETH_RESULT_INIT} 19 | } 20 | 21 | std::string loadResourceAsString(std::string _name) { return std::string(m_resources[_name], m_sizes[_name]); } 22 | 23 | private: 24 | std::map m_resources; 25 | std::map m_sizes; 26 | }; 27 | 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /cmake/scripts/runtest.cmake: -------------------------------------------------------------------------------- 1 | # Should be used to run ctest 2 | # 3 | # example usage: 4 | # cmake -DETH_TEST_NAME=TestInterfaceStub -DCTEST_COMMAND=/path/to/ctest -P scripts/runtest.cmake 5 | 6 | if (NOT CTEST_COMMAND) 7 | message(FATAL_ERROR "ctest could not be found!") 8 | endif() 9 | 10 | # verbosity is off, cause BOOST_MESSAGE is not thread safe and output is a trash 11 | # see https://codecrafter.wordpress.com/2012/11/01/c-unit-test-framework-adapter-part-3/ 12 | # 13 | # output might not be usefull cause of thread safety issue 14 | execute_process(COMMAND ${CTEST_COMMAND} --force-new-ctest-process -C Debug --output-on-failure -j 4 -R "${ETH_TEST_NAME}[.].*") 15 | 16 | -------------------------------------------------------------------------------- /cmake/templates/BuildInfo.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define ETH_PROJECT_VERSION "@PROJECT_VERSION@" 4 | #define ETH_COMMIT_HASH @ETH_COMMIT_HASH@ 5 | #define ETH_CLEAN_REPO @ETH_CLEAN_REPO@ 6 | #define ETH_BUILD_TYPE @ETH_BUILD_TYPE@ 7 | #define ETH_BUILD_OS @ETH_BUILD_OS@ 8 | #define ETH_BUILD_COMPILER @ETH_BUILD_COMPILER@ 9 | #define ETH_BUILD_JIT_MODE @ETH_BUILD_JIT_MODE@ 10 | #define ETH_BUILD_PLATFORM @ETH_BUILD_PLATFORM@ 11 | #define ETH_BUILD_NUMBER @ETH_BUILD_NUMBER@ 12 | #define ETH_VERSION_SUFFIX "@ETH_VERSION_SUFFIX@" 13 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | branch: master 3 | coverage: 4 | range: 50...100 5 | notify: 6 | gitter: 7 | default: 8 | threshold: 0 9 | url: https://gitter.im/ethereum/cpp-ethereum-development 10 | status: 11 | patch: 12 | default: 13 | target: 50 14 | project: 15 | default: 16 | target: auto 17 | threshold: 0.05 18 | app: 19 | target: auto 20 | threshold: 0.05 21 | paths: "!test/" 22 | tests: 23 | target: auto 24 | paths: "test/" 25 | changes: 26 | default: 27 | enabled: no 28 | comment: 29 | layout: "reach, diff" 30 | flags: 31 | alltests: 32 | joined: false 33 | ignore: 34 | - test/tools/fuzzTesting/fuzzHelper.cpp 35 | -------------------------------------------------------------------------------- /doc/dependencies.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Dependencies 3 | ============ 4 | 5 | Hunter package manager 6 | ====================== 7 | 8 | Hunter is *CMake-driven cross-platform package manager for C++ projects*. 9 | See documentation at https://docs.hunter.sh. 10 | 11 | Security aspects 12 | ---------------- 13 | 14 | A project which uses Hunter first downloads the Hunter client. This is 15 | done with the help of the HunterGate CMake module. A copy of the HunterGate module 16 | is included in the main project. The module is instructed to download a specified 17 | Hunter release and verify the downloaded source matches the checksum provided to the HunterGate invocation. 18 | 19 | A Hunter release contains a full list of (a specific version) of packages and checksums. Each downloaded package source checksum is compared against the corresponding checksum in the Hunter release. 20 | 21 | The HunterGate and selected Hunter release can be audited to verify that 22 | the expected dependency source code is downloaded. This audit must be repeated for each release in case the main project upgrades Hunter. 23 | 24 | Hunter has an option to download package binaries from a specified cache server instead of building packages from source. This option is enabled by default. Because checksums of binaries are not known up front, a compromised cache server is an attack vector. In Aleth we decided to 25 | use the cache server controlled by our team located here: https://github.com/ethereum/hunter-cache. 26 | 27 | -------------------------------------------------------------------------------- /doc/generating_tests.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | Generating Consensus Tests 3 | ========================== 4 | 5 | This part of the documentation has been moved to the central `testing documentation `_ on ReadTheDocs. -------------------------------------------------------------------------------- /doc/gitbook/README.md: -------------------------------------------------------------------------------- 1 | cpp-ethereum guide 2 | ======= 3 | 4 | This book is intended as a practical user guide for the cpp-ethereum software distribution. 5 | 6 | cpp-ethereum is a distribution of software including a number of diverse tools. This book begins with the installation instructions, before proceeding to introductions, walk-throughs and references for the various tools that make up cpp-ethereum. 7 | 8 | The full software suite of cpp-ethereum includes: 9 | 10 | - **aleth** (`aleth`) The mainline CLI Ethereum client. Run it in the background and it will connect to the Ethereum network; you can mine, make transactions and inspect the blockchain. 11 | - `aleth-key` A key/wallet management tool for Ethereum keys. This lets you add, remove and change your keys as well as *cold wallet device*-friendly transaction inspection and signing. 12 | - `ethminer` A standalone miner. This can be used to check how fast you can mine and will mine for you in concert with `eth`, `geth` and `pyethereum`. 13 | - `rlp` An serialisation/deserialisation tool for the Recursive Length Prefix format. 14 | -------------------------------------------------------------------------------- /doc/gitbook/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | * [Introduction](README.md) 4 | * [Installation](installation.md) 5 | * [CLI Tools](cli_tools.md) 6 | * [Getting started](getting_started.md) 7 | * [Interactive Console](interactive_console.md) 8 | * [Mining](mining.md) 9 | * [aleth-key](aleth-key.md) 10 | * [Whisper](whisper.md) 11 | * Recipes and How-tos 12 | * [Cold Wallet Storage Device](cold_wallet_storage_device.md) 13 | 14 | -------------------------------------------------------------------------------- /doc/gitbook/book.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /doc/gitbook/cli_tools.md: -------------------------------------------------------------------------------- 1 | # CLI Tools 2 | 3 | -------------------------------------------------------------------------------- /doc/gitbook/styles/website.css: -------------------------------------------------------------------------------- 1 | /* CSS for website */ 2 | -------------------------------------------------------------------------------- /doc/gitbook/transaction_explorer.md: -------------------------------------------------------------------------------- 1 | # Transaction Explorer 2 | 3 | Using the transaction pane 4 | 5 | The transaction pane enables you to explore transactions receipts, including 6 | 7 | Input parameters 8 | Return parameters 9 | As well as Event logs 10 | To display the transaction explorer, click on the down triangle icon which is on the right of each transaction, this will expand transaction details: 11 | 12 | ![](mix_bc.png) 13 | 14 | 15 | 16 | Then you can either copy the content of this transaction in the clipboard, Edit the current transaction (you will have to rerun the blockchain then), or debug the transaction. -------------------------------------------------------------------------------- /doc/gitbook/whisper.md: -------------------------------------------------------------------------------- 1 | # The Whisper Specific Commands 2 | 3 | Whisper is a hybrid DHT/point-to-point communications system. It allows for transient publication and subscription of messages using a novel topic-based routing system. It gives exceptional levels of privacy, and can be configured to provide a privacy/efficiency tradeoff per application. 4 | 5 | Here follows a few gotchas in the present whisper API on the `eth` interactive console. It will be updated shortly. 6 | 7 | Points to note: 8 | - All API for whisper is contained in the `web3.shh` object. Type it in the interactive console to get a list of all functions and variables provided. 9 | - Topic values are user-readable strings and as such should be given as plain text. E.g., topic `"zxcv"` in the console corresponds directly to the topic `"zxcv"`. 10 | - Payload should be in JSONRPC standard data representation (i.e. hexadecimal encoding). E.g., text `"zxcv"` must be represented as `"0x847a786376"`. This can be done through usage of the `web3.fromAscii` function. 11 | - The function `web3.shh.request()` returns the request object instead of sending it to the core (except for some complicated functions). E.g. `web3.shh.post.request({topcis: ["0xC0FFEE"]})` 12 | - When sending/posting a message, don't omit the `ttl` parameter, because default value is zero, and therefore the message will immediately expire, before being sent. 13 | - The functions `filter.get()` and `web3.shh.getMessages()` should return the same messages, but in a different format. 14 | 15 | ### Examples of usage 16 | 17 | ```javascript 18 | var f = web3.shh.filter({topics: ["qwerty"]}) 19 | f.get() 20 | web3.shh.getMessages("qwerty") 21 | web3.shh.post({topics: ["qwerty"], payload: "0x847a786376", ttl: "0x1E", workToProve: "0x9" }) 22 | ``` -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | Internal documentation 2 | ====================== 3 | 4 | 1. `Dependencies `_ 5 | 2. `Database Layout `_ 6 | 3. `Generating Consensus Tests `_ 7 | 4. `Using snapshot sync `_ 8 | 5. `Creating a single-node private network and deploying a contract with Remix `_ 9 | 6. `Creating a private network with two syncing nodes `_ 10 | -------------------------------------------------------------------------------- /doc/snapshot_sync.rst: -------------------------------------------------------------------------------- 1 | Using snapshot sync 2 | =============== 3 | 4 | Snapshot sync feature is still work in progress and currently is not very user-friendly yet. These are the instructions to make it work with the main net as of January 2018. 5 | 6 | If you have Parity installed, alternative to the `Downloading snapshot` steps below is to get it from the directory like ``Parity/Ethereum/chains/ethereum/db/906a34e69aec8c0d/snapshot`` 7 | 8 | Downloading the snapshot 9 | ------ 10 | 11 | 1. Start downloading providing the path to the directory to save the snapshot into 12 | :: 13 | aleth --download-snapshot SNAPSHOT_DIR -v 9 14 | 15 | If it doesn't find the peer to download from, you can also provide the address of a running node with main net snapshot (can be a Parity node or an aleth node with imported snapshot) 16 | :: 17 | aleth --download-snapshot SNAPSHOT_DIR -v 9 --peerset required:493d52068ec72230688da539926f47a452b762bc348d2ab1491f399b532186d71d7c512e09ffb8e9c24d292d064c00f6234ef1221bc0d86093d2de32358d33da@52.169.85.130:30303 --pin --no-discovery 18 | 19 | The one above is an Aleth node, if it doesn't work try one of the Parity boot nodes from https://github.com/paritytech/parity/blob/master/ethcore/res/ethereum/foundation.json#L176 20 | 21 | 2. Exit (Ctrl-C) when it says ``Snapshot download complete!`` 22 | 23 | Importing the snapshot 24 | ------ 25 | 26 | 1. Start importing the snapshot providing the path to the snapshot directory 27 | :: 28 | aleth --import-snapshot SNAPSHOT_DIR -v 8 29 | 30 | 2. After import is complete, it will automatically switch to regular sync process to get the blocks between snapshot and the current chain head. 31 | -------------------------------------------------------------------------------- /homebrew/INSTALL_RECEIPT.json: -------------------------------------------------------------------------------- 1 | {"used_options":["--with-evmjit"],"unused_options":["--with-gui","--without-gpu-mining","--with-debug","--with-vmtrace","--with-paranoia","--successful"],"built_as_bottle":true,"poured_from_bottle":false,"time":1440062311,"HEAD":"4511a6ad3149f514d161dc6c64505f795a0f9cc1","stdlib":"libcxx","compiler":"clang","source":{"path":"/Users/administrator/slave/build-cpp-osx-develop-brew/brew/cpp-ethereum.rb","tap":null,"spec":"devel"}} 2 | -------------------------------------------------------------------------------- /homebrew/homebrew.mxcl.cpp-ethereum.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | homebrew.mxcl.cpp-ethereum 7 | RunAtLoad 8 | 9 | KeepAlive 10 | 11 | ThrottleInterval 12 | 300 13 | ProgramArguments 14 | 15 | @@HOMEBREW_PREFIX@@/opt/cpp-ethereum/bin/eth 16 | -d 17 | @@HOMEBREW_CELLAR@@/cpp-ethereum/0.9.41-61/.ethereum 18 | -b 19 | 20 | WorkingDirectory 21 | @@HOMEBREW_PREFIX@@ 22 | 23 | 24 | -------------------------------------------------------------------------------- /libaleth-interpreter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Aleth: Ethereum C++ client, tools and libraries. 2 | # Copyright 2018-2019 Aleth Authors. 3 | # Licensed under the GNU General Public License, Version 3. See the LICENSE file. 4 | hunter_add_package(intx) 5 | find_package(intx CONFIG REQUIRED) 6 | 7 | set( 8 | sources 9 | interpreter.h 10 | VM.cpp 11 | VM.h 12 | VMCalls.cpp 13 | VMConfig.h 14 | VMOpt.cpp 15 | ) 16 | 17 | set( 18 | dependencies 19 | aleth-buildinfo 20 | ethash::ethash 21 | evmc::evmc 22 | evmc::instructions 23 | Boost::boost 24 | intx::intx 25 | ) 26 | 27 | add_library(aleth-interpreter STATIC ${sources}) 28 | target_link_libraries(aleth-interpreter PRIVATE ${dependencies}) 29 | 30 | if(EVM_OPTIMIZE) 31 | target_compile_definitions(aleth-interpreter PRIVATE EVM_OPTIMIZE) 32 | endif() 33 | 34 | if(ALETH_INTERPRETER_SHARED) 35 | # Build aleth-interpreter additionally as a shared library to include it in the package 36 | add_library(aleth-interpreter-shared SHARED ${sources}) 37 | target_link_libraries(aleth-interpreter-shared PRIVATE ${dependencies}) 38 | set_target_properties(aleth-interpreter-shared PROPERTIES OUTPUT_NAME aleth-interpreter) 39 | install(TARGETS aleth-interpreter-shared EXPORT alethTargets 40 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 41 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 42 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 43 | ) 44 | if(EVM_OPTIMIZE) 45 | target_compile_definitions(aleth-interpreter-shared PRIVATE EVM_OPTIMIZE) 46 | endif() 47 | endif() 48 | 49 | if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) 50 | target_compile_options(aleth-interpreter PRIVATE -fstack-usage) 51 | endif() 52 | -------------------------------------------------------------------------------- /libaleth-interpreter/interpreter.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2018-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #if __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | EVMC_EXPORT struct evmc_vm* evmc_create_aleth_interpreter() EVMC_NOEXCEPT; 14 | 15 | #if __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /libdevcore/Address.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "Address.h" 5 | 6 | namespace dev 7 | { 8 | Address const ZeroAddress; 9 | Address const MaxAddress{"0xffffffffffffffffffffffffffffffffffffffff"}; 10 | Address const SystemAddress{"0xfffffffffffffffffffffffffffffffffffffffe"}; 11 | } 12 | -------------------------------------------------------------------------------- /libdevcore/Address.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2013-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// This file defines Address alias for FixedHash of 160 bits and some 7 | /// special Address constants. 8 | 9 | #pragma once 10 | 11 | #include "FixedHash.h" 12 | 13 | namespace dev 14 | { 15 | 16 | /// An Ethereum address: 20 bytes. 17 | /// @NOTE This is not endian-specific; it's just a bunch of bytes. 18 | using Address = h160; 19 | 20 | /// A vector of Ethereum addresses. 21 | using Addresses = h160s; 22 | 23 | /// A hash set of Ethereum addresses. 24 | using AddressHash = std::unordered_set; 25 | 26 | /// The zero address. 27 | extern Address const ZeroAddress; 28 | 29 | /// The last address. 30 | extern Address const MaxAddress; 31 | 32 | /// The SYSTEM address. 33 | extern Address const SystemAddress; 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /libdevcore/Base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | base64.cpp and base64.h 3 | 4 | Copyright (C) 2004-2008 René Nyffenegger 5 | 6 | This source code is provided 'as-is', without any express or implied 7 | warranty. In no event will the author be held liable for any damages 8 | arising from the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this source code must not be misrepresented; you must not 15 | claim that you wrote the original source code. If you use this source code 16 | in a product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 19 | 2. Altered source versions must be plainly marked as such, and must not be 20 | misrepresented as being the original source code. 21 | 22 | 3. This notice may not be removed or altered from any source distribution. 23 | 24 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch 25 | */ 26 | /// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c 27 | /// Originally by René Nyffenegger. 28 | /// DEVified by Gav Wood. 29 | #pragma once 30 | 31 | #include "FixedHash.h" 32 | #include 33 | 34 | namespace dev 35 | { 36 | std::string toBase64(bytesConstRef _in); 37 | std::string toBase64URLSafe(bytesConstRef _in); 38 | bytes fromBase64(std::string const& _in); 39 | 40 | } // namespace dev 41 | -------------------------------------------------------------------------------- /libdevcore/CommonJS.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #include "CommonJS.h" 7 | 8 | using namespace std; 9 | 10 | namespace dev 11 | { 12 | 13 | bytes jsToBytes(string const& _s, OnFailed _f) 14 | { 15 | try 16 | { 17 | return fromHex(_s, WhenError::Throw); 18 | } 19 | catch (...) 20 | { 21 | if (_f == OnFailed::InterpretRaw) 22 | return asBytes(_s); 23 | else if (_f == OnFailed::Throw) 24 | throw invalid_argument("Cannot intepret '" + _s + "' as bytes; must be 0x-prefixed hex or decimal."); 25 | } 26 | return bytes(); 27 | } 28 | 29 | bytes padded(bytes _b, unsigned _l) 30 | { 31 | while (_b.size() < _l) 32 | _b.insert(_b.begin(), 0); 33 | return asBytes(asString(_b).substr(_b.size() - max(_l, _l))); 34 | } 35 | 36 | bytes paddedRight(bytes _b, unsigned _l) 37 | { 38 | _b.resize(_l); 39 | return _b; 40 | } 41 | 42 | bytes unpadded(bytes _b) 43 | { 44 | auto p = asString(_b).find_last_not_of((char)0); 45 | _b.resize(p == string::npos ? 0 : (p + 1)); 46 | return _b; 47 | } 48 | 49 | bytes unpadLeft(bytes _b) 50 | { 51 | unsigned int i = 0; 52 | if (_b.size() == 0) 53 | return _b; 54 | 55 | while (i < _b.size() && _b[i] == byte(0)) 56 | i++; 57 | 58 | if (i != 0) 59 | _b.erase(_b.begin(), _b.begin() + i); 60 | return _b; 61 | } 62 | 63 | string fromRaw(h256 _n) 64 | { 65 | if (_n) 66 | { 67 | string s((char const*)_n.data(), 32); 68 | auto l = s.find_first_of('\0'); 69 | if (!l) 70 | return ""; 71 | if (l != string::npos) 72 | s.resize(l); 73 | for (auto i: s) 74 | if (i < 32) 75 | return ""; 76 | return s; 77 | } 78 | return ""; 79 | } 80 | 81 | } 82 | 83 | -------------------------------------------------------------------------------- /libdevcore/DBFactory.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include "Common.h" 8 | #include "db.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace dev 14 | { 15 | namespace db 16 | { 17 | enum class DatabaseKind 18 | { 19 | LevelDB, 20 | RocksDB, 21 | MemoryDB 22 | }; 23 | 24 | /// Provide a set of program options related to databases 25 | /// 26 | /// @param _lineLength The line length for description text wrapping, the same as in 27 | /// boost::program_options::options_description::options_description(). 28 | boost::program_options::options_description databaseProgramOptions( 29 | unsigned _lineLength = boost::program_options::options_description::m_default_line_length); 30 | 31 | bool isDiskDatabase(); 32 | DatabaseKind databaseKind(); 33 | void setDatabaseKindByName(std::string const& _name); 34 | void setDatabaseKind(DatabaseKind _kind); 35 | boost::filesystem::path databasePath(); 36 | 37 | class DBFactory 38 | { 39 | public: 40 | DBFactory() = delete; 41 | ~DBFactory() = delete; 42 | 43 | static std::unique_ptr create(); 44 | static std::unique_ptr create(boost::filesystem::path const& _path); 45 | static std::unique_ptr create(DatabaseKind _kind); 46 | static std::unique_ptr create( 47 | DatabaseKind _kind, boost::filesystem::path const& _path); 48 | 49 | private: 50 | }; 51 | } // namespace db 52 | } // namespace dev -------------------------------------------------------------------------------- /libdevcore/FileSystem.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace dev 11 | { 12 | 13 | /// Sets the data dir for the default ("ethereum") prefix. 14 | void setDataDir(boost::filesystem::path const& _dir); 15 | /// @returns the path for user data. 16 | boost::filesystem::path getDataDir(std::string _prefix = "ethereum"); 17 | /// @returns the default path for user data, ignoring the one set by `setDataDir`. 18 | boost::filesystem::path getDefaultDataDir(std::string _prefix = "ethereum"); 19 | /// Sets the ipc socket dir 20 | void setIpcPath(boost::filesystem::path const& _ipcPath); 21 | /// @returns the ipc path (default is DataDir) 22 | boost::filesystem::path getIpcPath(); 23 | 24 | /// @returns a new path whose file name is suffixed with the given suffix. 25 | boost::filesystem::path appendToFilename(boost::filesystem::path const& _orig, std::string const& _suffix); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /libdevcore/FixedHash.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "FixedHash.h" 5 | #include 6 | 7 | namespace dev 8 | { 9 | 10 | std::random_device s_fixedHashEngine; 11 | 12 | h128 fromUUID(std::string const& _uuid) 13 | { 14 | try 15 | { 16 | return h128(boost::replace_all_copy(_uuid, "-", "")); 17 | } 18 | catch (...) 19 | { 20 | return h128(); 21 | } 22 | } 23 | 24 | std::string toUUID(h128 const& _uuid) 25 | { 26 | std::string ret = toHex(_uuid.ref()); 27 | for (unsigned i: {20, 16, 12, 8}) 28 | ret.insert(ret.begin() + i, '-'); 29 | return ret; 30 | } 31 | 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /libdevcore/Guards.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "Guards.h" 6 | using namespace std; 7 | using namespace dev; 8 | 9 | namespace dev 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /libdevcore/JsonUtils.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace dev 13 | { 14 | // Throws UnknownField() if _obj contains field names not listed in _allowedFields. 15 | void validateFieldNames(json_spirit::mObject const& _obj, std::set const& _allowedFields); 16 | 17 | // Converts json value type to string 18 | std::string jsonTypeAsString(json_spirit::Value_type _type); 19 | 20 | enum class JsonFieldPresence 21 | { 22 | Required, 23 | Optional 24 | }; 25 | using JsonTypeSet = std::set; 26 | using JsonFieldOptions = std::pair; 27 | /// Check the json object with validation map that reuires certain field of certain type to be 28 | /// present in json 29 | /** 30 | @param _o a json object to check 31 | @param _configName a string with json object name. Will apper in error message. 32 | @param _validationMap a map with json objects that would be checked. "objName" -> {js::str_type, 33 | jsonField::Required} 34 | */ 35 | void requireJsonFields(json_spirit::mObject const& _o, std::string const& _configName, 36 | std::map const& _validationMap); 37 | } 38 | -------------------------------------------------------------------------------- /libdevcore/LevelDB.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2017-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include "db.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace dev 14 | { 15 | namespace db 16 | { 17 | class LevelDB : public DatabaseFace 18 | { 19 | public: 20 | static leveldb::ReadOptions defaultReadOptions(); 21 | static leveldb::WriteOptions defaultWriteOptions(); 22 | static leveldb::Options defaultDBOptions(); 23 | 24 | explicit LevelDB(boost::filesystem::path const& _path, 25 | leveldb::ReadOptions _readOptions = defaultReadOptions(), 26 | leveldb::WriteOptions _writeOptions = defaultWriteOptions(), 27 | leveldb::Options _dbOptions = defaultDBOptions()); 28 | 29 | std::string lookup(Slice _key) const override; 30 | bool exists(Slice _key) const override; 31 | void insert(Slice _key, Slice _value) override; 32 | void kill(Slice _key) override; 33 | 34 | std::unique_ptr createWriteBatch() const override; 35 | void commit(std::unique_ptr _batch) override; 36 | 37 | void forEach(std::function _f) const override; 38 | 39 | private: 40 | std::unique_ptr m_db; 41 | leveldb::ReadOptions const m_readOptions; 42 | leveldb::WriteOptions const m_writeOptions; 43 | }; 44 | 45 | } // namespace db 46 | } // namespace dev 47 | -------------------------------------------------------------------------------- /libdevcore/LoggingProgramOptions.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2018-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "LoggingProgramOptions.h" 6 | 7 | namespace po = boost::program_options; 8 | 9 | namespace dev 10 | { 11 | po::options_description createLoggingProgramOptions( 12 | unsigned _lineLength, LoggingOptions& _options, std::string const& _logChannels) 13 | { 14 | po::options_description optionsDescr("LOGGING OPTIONS", _lineLength); 15 | auto addLoggingOption = optionsDescr.add_options(); 16 | addLoggingOption("log-verbosity,v", po::value(&_options.verbosity)->value_name("<0 - 4>"), 17 | "Set the log verbosity from 0 to 4 (default: 2)."); 18 | 19 | std::string const logChannelsDescription = 20 | "Space-separated list of the log channels to show (default: show all channels)." + 21 | (_logChannels.empty() ? "" : "\nChannels: " + _logChannels); 22 | addLoggingOption("log-channels", 23 | po::value>(&_options.includeChannels) 24 | ->value_name("") 25 | ->multitoken(), 26 | logChannelsDescription.c_str()); 27 | addLoggingOption("log-exclude-channels", 28 | po::value>(&_options.excludeChannels) 29 | ->value_name("") 30 | ->multitoken(), 31 | "Space-separated list of the log channels to hide.\n"); 32 | 33 | return optionsDescr; 34 | } 35 | 36 | } // namespace dev 37 | -------------------------------------------------------------------------------- /libdevcore/LoggingProgramOptions.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include "Log.h" 8 | #include 9 | 10 | namespace dev 11 | { 12 | boost::program_options::options_description createLoggingProgramOptions( 13 | unsigned _lineLength, LoggingOptions& _options, std::string const& _logChannels = {}); 14 | 15 | } // namespace dev -------------------------------------------------------------------------------- /libdevcore/MemoryDB.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2017-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include "Common.h" 8 | #include "Guards.h" 9 | #include "db.h" 10 | 11 | namespace dev 12 | { 13 | namespace db 14 | { 15 | class MemoryDBWriteBatch : public WriteBatchFace 16 | { 17 | public: 18 | void insert(Slice _key, Slice _value) override; 19 | void kill(Slice _key) override; 20 | 21 | std::unordered_map& writeBatch() { return m_batch; } 22 | size_t size() { return m_batch.size(); } 23 | 24 | private: 25 | std::unordered_map m_batch; 26 | }; 27 | 28 | class MemoryDB : public DatabaseFace 29 | { 30 | public: 31 | std::string lookup(Slice _key) const override; 32 | bool exists(Slice _key) const override; 33 | void insert(Slice _key, Slice _value) override; 34 | void kill(Slice _key) override; 35 | 36 | std::unique_ptr createWriteBatch() const override; 37 | void commit(std::unique_ptr _batch) override; 38 | 39 | // A database must implement the `forEach` method that allows the caller 40 | // to pass in a function `f`, which will be called with the key and value 41 | // of each record in the database. If `f` returns false, the `forEach` 42 | // method must return immediately. 43 | void forEach(std::function _f) const override; 44 | 45 | size_t size() const { return m_db.size(); } 46 | 47 | private: 48 | std::unordered_map m_db; 49 | mutable Mutex m_mutex; 50 | }; 51 | } // namespace db 52 | } // namespace dev -------------------------------------------------------------------------------- /libdevcore/OverlayDB.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace dev 14 | { 15 | 16 | class OverlayDB: public StateCacheDB 17 | { 18 | public: 19 | explicit OverlayDB(std::unique_ptr _db = nullptr) 20 | : m_db(_db.release(), [](db::DatabaseFace* db) { 21 | clog(VerbosityDebug, "overlaydb") << "Closing state DB"; 22 | delete db; 23 | }) 24 | {} 25 | 26 | ~OverlayDB(); 27 | 28 | // Copyable 29 | OverlayDB(OverlayDB const&) = default; 30 | OverlayDB& operator=(OverlayDB const&) = default; 31 | // Movable 32 | OverlayDB(OverlayDB&&) = default; 33 | OverlayDB& operator=(OverlayDB&&) = default; 34 | 35 | void commit(); 36 | void rollback(); 37 | 38 | std::string lookup(h256 const& _h) const; 39 | bool exists(h256 const& _h) const; 40 | void kill(h256 const& _h); 41 | 42 | bytes lookupAux(h256 const& _h) const; 43 | 44 | private: 45 | using StateCacheDB::clear; 46 | 47 | std::shared_ptr m_db; 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /libdevcore/RocksDB.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2017-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #include "db.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace dev 13 | { 14 | namespace db 15 | { 16 | class RocksDB : public DatabaseFace 17 | { 18 | public: 19 | static rocksdb::ReadOptions defaultReadOptions(); 20 | static rocksdb::WriteOptions defaultWriteOptions(); 21 | static rocksdb::Options defaultDBOptions(); 22 | 23 | explicit RocksDB(boost::filesystem::path const& _path, 24 | rocksdb::ReadOptions _readOptions = defaultReadOptions(), 25 | rocksdb::WriteOptions _writeOptions = defaultWriteOptions(), 26 | rocksdb::Options _dbOptions = defaultDBOptions()); 27 | 28 | std::string lookup(Slice _key) const override; 29 | bool exists(Slice _key) const override; 30 | void insert(Slice _key, Slice _value) override; 31 | void kill(Slice _key) override; 32 | 33 | std::unique_ptr createWriteBatch() const override; 34 | void commit(std::unique_ptr _batch) override; 35 | 36 | void forEach(std::function f) const override; 37 | 38 | private: 39 | std::unique_ptr m_db; 40 | rocksdb::ReadOptions const m_readOptions; 41 | rocksdb::WriteOptions const m_writeOptions; 42 | }; 43 | 44 | } // namespace db 45 | } // namespace dev 46 | -------------------------------------------------------------------------------- /libdevcore/SHA3.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "SHA3.h" 6 | #include "RLP.h" 7 | 8 | #include 9 | 10 | namespace dev 11 | { 12 | h256 const EmptySHA3 = sha3(bytesConstRef()); 13 | h256 const EmptyListSHA3 = sha3(rlpList()); 14 | 15 | bool sha3(bytesConstRef _input, bytesRef o_output) noexcept 16 | { 17 | if (o_output.size() != 32) 18 | return false; 19 | ethash::hash256 h = ethash::keccak256(_input.data(), _input.size()); 20 | bytesConstRef{h.bytes, 32}.copyTo(o_output); 21 | return true; 22 | } 23 | } // namespace dev 24 | -------------------------------------------------------------------------------- /libdevcore/TransientDirectory.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #include 7 | #include 8 | #include "Exceptions.h" 9 | #include "TransientDirectory.h" 10 | #include "CommonIO.h" 11 | #include "Log.h" 12 | using namespace std; 13 | using namespace dev; 14 | namespace fs = boost::filesystem; 15 | 16 | TransientDirectory::TransientDirectory(): 17 | TransientDirectory((boost::filesystem::temp_directory_path() / "eth_transient" / toString(FixedHash<4>::random())).string()) 18 | {} 19 | 20 | TransientDirectory::TransientDirectory(std::string const& _path): 21 | m_path(_path) 22 | { 23 | // we never ever want to delete a directory (including all its contents) that we did not create ourselves. 24 | if (boost::filesystem::exists(m_path)) 25 | BOOST_THROW_EXCEPTION(FileError()); 26 | 27 | if (!fs::create_directories(m_path)) 28 | BOOST_THROW_EXCEPTION(FileError()); 29 | DEV_IGNORE_EXCEPTIONS(fs::permissions(m_path, fs::owner_all)); 30 | } 31 | 32 | TransientDirectory::~TransientDirectory() 33 | { 34 | boost::system::error_code ec; 35 | fs::remove_all(m_path, ec); 36 | if (!ec) 37 | return; 38 | 39 | // In some cases, antivirus runnig on Windows will scan all the newly created directories. 40 | // As a consequence, directory is locked and can not be deleted immediately. 41 | // Retry after 10 milliseconds usually is successful. 42 | // This will help our tests run smoothly in such environment. 43 | this_thread::sleep_for(chrono::milliseconds(10)); 44 | 45 | ec.clear(); 46 | fs::remove_all(m_path, ec); 47 | if (!ec) 48 | { 49 | cwarn << "Failed to delete directory '" << m_path << "': " << ec.message(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /libdevcore/TransientDirectory.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace dev 10 | { 11 | 12 | /** 13 | * @brief temporary directory implementation 14 | * It creates temporary directory in the given path. On dealloc it removes the directory 15 | * @throws if the given path already exists, throws an exception 16 | */ 17 | class TransientDirectory 18 | { 19 | public: 20 | TransientDirectory(); 21 | TransientDirectory(std::string const& _path); 22 | ~TransientDirectory(); 23 | 24 | std::string const& path() const { return m_path; } 25 | 26 | private: 27 | std::string m_path; 28 | }; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /libdevcore/TrieHash.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include 10 | 11 | namespace dev 12 | { 13 | 14 | bytes rlp256(BytesMap const& _s); 15 | h256 hash256(BytesMap const& _s); 16 | 17 | h256 orderedTrieRoot(std::vector const& _data); 18 | 19 | template inline h256 trieRootOver(unsigned _itemCount, T const& _getKey, U const& _getValue) 20 | { 21 | BytesMap m; 22 | for (unsigned i = 0; i < _itemCount; ++i) 23 | m[_getKey(i)] = _getValue(i); 24 | return hash256(m); 25 | } 26 | 27 | h256 orderedTrieRoot(std::vector const& _data); 28 | h256 orderedTrieRoot(std::vector const& _data); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /libdevcore/UndefMacros.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// This header should be used to #undef some really evil macros defined by 7 | /// windows.h which result in conflict with our libsolidity/Token.h 8 | #pragma once 9 | 10 | #if defined(_MSC_VER) || defined(__MINGW32__) 11 | 12 | #undef DELETE 13 | #undef IN 14 | #undef VOID 15 | #undef THIS 16 | #undef CONST 17 | 18 | // Conflicting define on MinGW in windows.h 19 | // windows.h(19): #define interface struct 20 | #ifdef interface 21 | #undef interface 22 | #endif 23 | 24 | #elif defined(DELETE) || defined(IN) || defined(VOID) || defined(THIS) || defined(CONST) || defined(interface) 25 | 26 | #error "The preceding macros in this header file are reserved for V8's "\ 27 | "TOKEN_LIST. Please add a platform specific define above to undefine "\ 28 | "overlapping macros." 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libdevcore/dbfwd.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #include "vector_ref.h" 7 | 8 | namespace dev 9 | { 10 | namespace db 11 | { 12 | using Slice = vector_ref; 13 | class WriteBatchFace; 14 | class DatabaseFace; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libdevcrypto/AES.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "AES.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace dev; 13 | using namespace dev::crypto; 14 | 15 | bytes dev::aesDecrypt(bytesConstRef _ivCipher, std::string const& _password, unsigned _rounds, bytesConstRef _salt) 16 | { 17 | bytes pw = asBytes(_password); 18 | 19 | if (!_salt.size()) 20 | _salt = &pw; 21 | 22 | bytes target(64); 23 | CryptoPP::PKCS5_PBKDF2_HMAC().DeriveKey(target.data(), target.size(), 0, pw.data(), pw.size(), _salt.data(), _salt.size(), _rounds); 24 | 25 | try 26 | { 27 | CryptoPP::AES::Decryption aesDecryption(target.data(), 16); 28 | auto cipher = _ivCipher.cropped(16); 29 | auto iv = _ivCipher.cropped(0, 16); 30 | CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data()); 31 | std::string decrypted; 32 | CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decrypted)); 33 | stfDecryptor.Put(cipher.data(), cipher.size()); 34 | stfDecryptor.MessageEnd(); 35 | return asBytes(decrypted); 36 | } 37 | catch (std::exception const& e) 38 | { 39 | // FIXME: Handle this error better. 40 | std::cerr << e.what() << '\n'; 41 | return bytes(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libdevcrypto/AES.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | /** 5 | * AES 6 | * todo: use openssl 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Common.h" 12 | 13 | namespace dev 14 | { 15 | 16 | bytes aesDecrypt(bytesConstRef _cipher, std::string const& _password, unsigned _rounds = 2000, bytesConstRef _salt = bytesConstRef()); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /libdevcrypto/Blake2.h: -------------------------------------------------------------------------------- 1 | /// Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace dev 10 | { 11 | namespace crypto 12 | { 13 | /// Calculates the compression function F used in the BLAKE2 cryptographic hashing algorithm 14 | /// Throws exception in case input data has incorrect size. 15 | /// @param _rounds the number of rounds 16 | /// @param _stateVector the state vector - 8 unsigned 64-bit little-endian words 17 | /// @param _t0, _t1 offset counters - unsigned 64-bit little-endian words 18 | /// @param _lastBlock the final block indicator flag 19 | /// @param _messageBlock the message block vector - 16 unsigned 64-bit little-endian words 20 | /// @returns updated state vector with unchanged encoding (little-endian) 21 | bytes blake2FCompression(uint32_t _rounds, bytesConstRef _stateVector, bytesConstRef _t0, 22 | bytesConstRef _t1, bool _lastBlock, bytesConstRef _messageBlock); 23 | } 24 | } // namespace dev 25 | -------------------------------------------------------------------------------- /libdevcrypto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB SOURCES "*.cpp") 2 | file(GLOB HEADERS "*.h") 3 | 4 | add_library(devcrypto ${SOURCES} ${HEADERS}) 5 | target_include_directories(devcrypto PRIVATE ${UTILS_INCLUDE_DIR}) 6 | target_link_libraries(devcrypto PUBLIC devcore Secp256k1 PRIVATE libff::ff cryptopp-static libscrypt::scrypt) 7 | -------------------------------------------------------------------------------- /libdevcrypto/CryptoPP.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | /** 5 | * CryptoPP headers and primitive helper methods 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Common.h" 11 | 12 | namespace dev 13 | { 14 | namespace crypto 15 | { 16 | /// Amount of bytes added when encrypting with encryptECIES. 17 | static const unsigned c_eciesOverhead = 113; 18 | 19 | /** 20 | * CryptoPP secp256k1 algorithms. 21 | * @todo Collect ECIES methods into class. 22 | */ 23 | class Secp256k1PP 24 | { 25 | public: 26 | static Secp256k1PP* get(); 27 | 28 | /// Encrypts text (replace input). (ECIES w/XOR-SHA1) 29 | void encrypt(Public const& _k, bytes& io_cipher); 30 | 31 | /// Decrypts text (replace input). (ECIES w/XOR-SHA1) 32 | void decrypt(Secret const& _k, bytes& io_text); 33 | 34 | /// Encrypts text (replace input). (ECIES w/AES128-CTR-SHA256) 35 | void encryptECIES(Public const& _k, bytes& io_cipher); 36 | 37 | /// Encrypts text (replace input). (ECIES w/AES128-CTR-SHA256) 38 | void encryptECIES(Public const& _k, bytesConstRef _sharedMacData, bytes& io_cipher); 39 | 40 | /// Decrypts text (replace input). (ECIES w/AES128-CTR-SHA256) 41 | bool decryptECIES(Secret const& _k, bytes& io_text); 42 | 43 | /// Decrypts text (replace input). (ECIES w/AES128-CTR-SHA256) 44 | bool decryptECIES(Secret const& _k, bytesConstRef _sharedMacData, bytes& io_text); 45 | 46 | private: 47 | Secp256k1PP() = default; 48 | }; 49 | 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /libdevcrypto/Exceptions.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace dev 11 | { 12 | namespace crypto 13 | { 14 | 15 | /// Rare malfunction of cryptographic functions. 16 | DEV_SIMPLE_EXCEPTION(CryptoException); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libdevcrypto/Hash.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | /** 5 | * The FixedHash fixed-size "hash" container type. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "libdevcore/FixedHash.h" 11 | #include "libdevcore/vector_ref.h" 12 | 13 | namespace dev 14 | { 15 | 16 | h256 sha256(bytesConstRef _input) noexcept; 17 | 18 | h160 ripemd160(bytesConstRef _input); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /libdevcrypto/LibSnark.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace dev 11 | { 12 | namespace crypto 13 | { 14 | 15 | std::pair alt_bn128_pairing_product(bytesConstRef _in); 16 | std::pair alt_bn128_G1_add(bytesConstRef _in); 17 | std::pair alt_bn128_G1_mul(bytesConstRef _in); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /libethashseal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | Ethash.cpp 3 | Ethash.h 4 | EthashCPUMiner.cpp 5 | EthashCPUMiner.h 6 | EthashProofOfWork.cpp 7 | EthashProofOfWork.h 8 | GenesisInfo.cpp 9 | GenesisInfo.h 10 | ) 11 | 12 | add_library(ethashseal ${sources}) 13 | target_include_directories(ethashseal PRIVATE ../utils) 14 | target_link_libraries(ethashseal PUBLIC ethereum ethcore) 15 | -------------------------------------------------------------------------------- /libethashseal/EthashCPUMiner.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include "EthashProofOfWork.h" 9 | 10 | #include 11 | 12 | namespace dev 13 | { 14 | namespace eth 15 | { 16 | class EthashCPUMiner : public GenericMiner 17 | { 18 | public: 19 | explicit EthashCPUMiner(GenericMiner::ConstructionInfo const& _ci); 20 | ~EthashCPUMiner() override; 21 | 22 | static unsigned instances() 23 | { 24 | return s_numInstances > 0 ? s_numInstances : std::thread::hardware_concurrency(); 25 | } 26 | static std::string platformInfo(); 27 | static void setNumInstances(unsigned _instances) 28 | { 29 | s_numInstances = std::min(_instances, std::thread::hardware_concurrency()); 30 | } 31 | 32 | protected: 33 | void kickOff() override; 34 | void pause() override; 35 | 36 | private: 37 | static unsigned s_numInstances; 38 | 39 | void startWorking(); 40 | void stopWorking(); 41 | void minerBody(); 42 | 43 | std::unique_ptr m_thread; 44 | std::atomic m_shouldStop; 45 | }; 46 | } // namespace eth 47 | } // namespace dev 48 | -------------------------------------------------------------------------------- /libethashseal/EthashProofOfWork.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | /** 5 | * Determines the PoW algorithm. 6 | */ 7 | 8 | #include "EthashProofOfWork.h" 9 | #include "Ethash.h" 10 | using namespace std; 11 | using namespace chrono; 12 | using namespace dev; 13 | using namespace eth; 14 | 15 | const unsigned EthashProofOfWork::defaultLocalWorkSize = 64; 16 | const unsigned EthashProofOfWork::defaultGlobalWorkSizeMultiplier = 4096; // * CL_DEFAULT_LOCAL_WORK_SIZE 17 | const unsigned EthashProofOfWork::defaultMSPerBatch = 0; 18 | const EthashProofOfWork::WorkPackage EthashProofOfWork::NullWorkPackage = EthashProofOfWork::WorkPackage(); 19 | 20 | EthashProofOfWork::WorkPackage::WorkPackage(BlockHeader const& _bh): 21 | boundary(Ethash::boundary(_bh)), 22 | seedHash(Ethash::seedHash(_bh)), 23 | m_headerHash(_bh.hash(WithoutSeal)) 24 | {} 25 | 26 | EthashProofOfWork::WorkPackage::WorkPackage(WorkPackage const& _other): 27 | boundary(_other.boundary), 28 | seedHash(_other.seedHash), 29 | m_headerHash(_other.headerHash()) 30 | {} 31 | 32 | EthashProofOfWork::WorkPackage& EthashProofOfWork::WorkPackage::operator=(EthashProofOfWork::WorkPackage const& _other) 33 | { 34 | if (this == &_other) 35 | return *this; 36 | boundary = _other.boundary; 37 | seedHash = _other.seedHash; 38 | h256 headerHash = _other.headerHash(); 39 | { 40 | Guard l(m_headerHashLock); 41 | m_headerHash = std::move(headerHash); 42 | } 43 | return *this; 44 | } 45 | -------------------------------------------------------------------------------- /libethashseal/EthashProofOfWork.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | /** 5 | * Determines the PoW algorithm. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace dev 14 | { 15 | namespace eth 16 | { 17 | 18 | /// Proof of work definition for Ethash. 19 | struct EthashProofOfWork 20 | { 21 | struct Solution 22 | { 23 | Nonce nonce; 24 | h256 mixHash; 25 | }; 26 | 27 | struct Result 28 | { 29 | h256 value; 30 | h256 mixHash; 31 | }; 32 | 33 | struct WorkPackage 34 | { 35 | WorkPackage() {} 36 | WorkPackage(BlockHeader const& _bh); 37 | WorkPackage(WorkPackage const& _other); 38 | WorkPackage& operator=(WorkPackage const& _other); 39 | 40 | void reset() { Guard l(m_headerHashLock); m_headerHash = h256(); } 41 | operator bool() const { Guard l(m_headerHashLock); return m_headerHash != h256(); } 42 | h256 headerHash() const { Guard l(m_headerHashLock); return m_headerHash; } 43 | 44 | h256 boundary; 45 | h256 seedHash; 46 | 47 | private: 48 | h256 m_headerHash; ///< When h256() means "pause until notified a new work package is available". 49 | mutable Mutex m_headerHashLock; 50 | }; 51 | 52 | static const WorkPackage NullWorkPackage; 53 | 54 | /// Default value of the local work size. Also known as workgroup size. 55 | static const unsigned defaultLocalWorkSize; 56 | /// Default value of the global work size as a multiplier of the local work size 57 | static const unsigned defaultGlobalWorkSizeMultiplier; 58 | /// Default value of the milliseconds per global work size (per batch) 59 | static const unsigned defaultMSPerBatch; 60 | }; 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/ByzantiumToConstantinopleFixAt5Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoByzantiumToConstantinopleFixAt5Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x00", 14 | "EIP150ForkBlock": "0x00", 15 | "EIP158ForkBlock": "0x00", 16 | "byzantiumForkBlock": "0x00", 17 | "constantinopleForkBlock": "0x05", 18 | "constantinopleFixForkBlock": "0x05", 19 | "networkID" : "0x1", 20 | "chainID": "0x01", 21 | "maximumExtraDataSize": "0x20", 22 | "tieBreakingGas": false, 23 | "minGasLimit": "0x1388", 24 | "maxGasLimit": "0x7fffffffffffffff", 25 | "gasLimitBoundDivisor": "0x0400", 26 | "minimumDifficulty": "0x020000", 27 | "difficultyBoundDivisor": "0x0800", 28 | "durationLimit": "0x0d", 29 | "blockReward": "0x4563918244F40000", 30 | "allowFutureBlocks" : true 31 | }, 32 | "genesis": { 33 | "nonce": "0x0000000000000042", 34 | "difficulty": "0x020000", 35 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 36 | "author": "0x0000000000000000000000000000000000000000", 37 | "timestamp": "0x00", 38 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 39 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 40 | "gasLimit": "0x1388" 41 | }, 42 | "accounts": { 43 | } 44 | } 45 | )E"; 46 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/EIP158ToByzantiumAt5Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoEIP158ToByzantiumAt5Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x00", 14 | "EIP150ForkBlock": "0x00", 15 | "EIP158ForkBlock": "0x00", 16 | "byzantiumForkBlock": "0x05", 17 | "networkID" : "0x1", 18 | "chainID": "0x01", 19 | "maximumExtraDataSize": "0x20", 20 | "tieBreakingGas": false, 21 | "minGasLimit": "0x1388", 22 | "maxGasLimit": "0x7fffffffffffffff", 23 | "gasLimitBoundDivisor": "0x0400", 24 | "minimumDifficulty": "0x020000", 25 | "difficultyBoundDivisor": "0x0800", 26 | "durationLimit": "0x0d", 27 | "blockReward": "0x4563918244F40000", 28 | "allowFutureBlocks" : true 29 | }, 30 | "genesis": { 31 | "nonce": "0x0000000000000042", 32 | "difficulty": "0x020000", 33 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 34 | "author": "0x0000000000000000000000000000000000000000", 35 | "timestamp": "0x00", 36 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 37 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 38 | "gasLimit": "0x1388" 39 | }, 40 | "accounts": { 41 | } 42 | } 43 | )E"; 44 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/byzantiumNoProofTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "../../GenesisInfo.h" 5 | 6 | static std::string const c_genesisInfoByzantiumNoProofTest = R"E( 7 | { 8 | "sealEngine": "NoProof", 9 | "params": { 10 | "accountStartNonce": "0x00", 11 | "maximumExtraDataSize": "0x20", 12 | "homesteadForkBlock": "0x00", 13 | "EIP150ForkBlock": "0x00", 14 | "EIP158ForkBlock": "0x00", 15 | "byzantiumForkBlock": "0x00", 16 | "minGasLimit": "0x1388", 17 | "maxGasLimit": "7fffffffffffffff", 18 | "tieBreakingGas": false, 19 | "gasLimitBoundDivisor": "0x0400", 20 | "minimumDifficulty": "0x020000", 21 | "difficultyBoundDivisor": "0x0800", 22 | "durationLimit": "0x0d", 23 | "blockReward": "0x4563918244F40000", 24 | "networkID" : "0x1", 25 | "chainID": "0x01", 26 | "allowFutureBlocks" : true 27 | }, 28 | "genesis": { 29 | "nonce": "0x0000000000000042", 30 | "difficulty": "0x020000", 31 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 32 | "author": "0x0000000000000000000000000000000000000000", 33 | "timestamp": "0x00", 34 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 36 | "gasLimit": "0x1388" 37 | }, 38 | "accounts": { 39 | } 40 | } 41 | )E"; 42 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/byzantiumTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoByzantiumTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "maximumExtraDataSize": "0x20", 14 | "homesteadForkBlock": "0x00", 15 | "EIP150ForkBlock": "0x00", 16 | "EIP158ForkBlock": "0x00", 17 | "byzantiumForkBlock": "0x00", 18 | "minGasLimit": "0x1388", 19 | "maxGasLimit": "7fffffffffffffff", 20 | "tieBreakingGas": false, 21 | "gasLimitBoundDivisor": "0x0400", 22 | "minimumDifficulty": "0x020000", 23 | "difficultyBoundDivisor": "0x0800", 24 | "durationLimit": "0x0d", 25 | "blockReward": "0x4563918244F40000", 26 | "networkID" : "0x1", 27 | "chainID": "0x01", 28 | "allowFutureBlocks" : true 29 | }, 30 | "genesis": { 31 | "nonce": "0x0000000000000042", 32 | "difficulty": "0x020000", 33 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 34 | "author": "0x0000000000000000000000000000000000000000", 35 | "timestamp": "0x00", 36 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 37 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 38 | "gasLimit": "0x1388" 39 | }, 40 | "accounts": { 41 | } 42 | } 43 | )E"; 44 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/byzantiumTransitionTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "../../GenesisInfo.h" 5 | 6 | static std::string const c_genesisInfoByzantiumTransitionTest = std::string() + 7 | R"E( 8 | { 9 | "sealEngine": "NoProof", 10 | "params": { 11 | "accountStartNonce": "0x00", 12 | "maximumExtraDataSize": "0x20", 13 | "homesteadForkBlock": "0x00", 14 | "EIP150ForkBlock": "0x00", 15 | "EIP158ForkBlock": "0x00", 16 | "byzantiumForkBlock": "0x02", 17 | "minGasLimit": "0x1388", 18 | "maxGasLimit": "7fffffffffffffff", 19 | "tieBreakingGas": false, 20 | "gasLimitBoundDivisor": "0x0400", 21 | "minimumDifficulty": "0x020000", 22 | "difficultyBoundDivisor": "0x0800", 23 | "durationLimit": "0x0d", 24 | "blockReward": "0x4563918244F40000", 25 | "networkID" : "0x1", 26 | "chainID": "0x01", 27 | "allowFutureBlocks" : true 28 | }, 29 | "genesis": { 30 | "nonce": "0x0000000000000042", 31 | "difficulty": "0x020000", 32 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 33 | "author": "0x0000000000000000000000000000000000000000", 34 | "timestamp": "0x00", 35 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 36 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 37 | "gasLimit": "0x1388" 38 | }, 39 | "accounts": { 40 | } 41 | } 42 | )E"; 43 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/constantinopleNoProofTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoConstantinopleNoProofTest = R"E( 8 | { 9 | "sealEngine": "NoProof", 10 | "params": { 11 | "accountStartNonce": "0x00", 12 | "maximumExtraDataSize": "0x20", 13 | "homesteadForkBlock": "0x00", 14 | "EIP150ForkBlock": "0x00", 15 | "EIP158ForkBlock": "0x00", 16 | "byzantiumForkBlock": "0x00", 17 | "constantinopleForkBlock": "0x00", 18 | "minGasLimit": "0x1388", 19 | "maxGasLimit": "7fffffffffffffff", 20 | "tieBreakingGas": false, 21 | "gasLimitBoundDivisor": "0x0400", 22 | "minimumDifficulty": "0x020000", 23 | "difficultyBoundDivisor": "0x0800", 24 | "durationLimit": "0x0d", 25 | "blockReward": "0x4563918244F40000", 26 | "networkID" : "0x1", 27 | "chainID": "0x01", 28 | "allowFutureBlocks" : true 29 | }, 30 | "genesis": { 31 | "nonce": "0x0000000000000042", 32 | "difficulty": "0x020000", 33 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 34 | "author": "0x0000000000000000000000000000000000000000", 35 | "timestamp": "0x00", 36 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 37 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 38 | "gasLimit": "0x1388" 39 | }, 40 | "accounts": { 41 | } 42 | } 43 | )E"; 44 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/constantinopleTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoConstantinopleTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "maximumExtraDataSize": "0x20", 14 | "homesteadForkBlock": "0x00", 15 | "EIP150ForkBlock": "0x00", 16 | "EIP158ForkBlock": "0x00", 17 | "byzantiumForkBlock": "0x00", 18 | "constantinopleForkBlock": "0x00", 19 | "minGasLimit": "0x1388", 20 | "maxGasLimit": "7fffffffffffffff", 21 | "tieBreakingGas": false, 22 | "gasLimitBoundDivisor": "0x0400", 23 | "minimumDifficulty": "0x020000", 24 | "difficultyBoundDivisor": "0x0800", 25 | "durationLimit": "0x0d", 26 | "blockReward": "0x4563918244F40000", 27 | "networkID" : "0x1", 28 | "chainID": "0x01", 29 | "allowFutureBlocks" : true 30 | }, 31 | "genesis": { 32 | "nonce": "0x0000000000000042", 33 | "difficulty": "0x020000", 34 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "author": "0x0000000000000000000000000000000000000000", 36 | "timestamp": "0x00", 37 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 38 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 39 | "gasLimit": "0x1388" 40 | }, 41 | "accounts": { 42 | } 43 | } 44 | )E"; 45 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/eip150Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoEIP150Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "maximumExtraDataSize": "0x20", 14 | "homesteadForkBlock": "0x00", 15 | "EIP150ForkBlock": "0x00", 16 | "networkID" : "0x01", 17 | "chainID": "0x01", 18 | "minGasLimit": "0x1388", 19 | "maxGasLimit": "7fffffffffffffff", 20 | "tieBreakingGas": false, 21 | "gasLimitBoundDivisor": "0x0400", 22 | "minimumDifficulty": "0x020000", 23 | "difficultyBoundDivisor": "0x0800", 24 | "durationLimit": "0x0d", 25 | "blockReward": "0x4563918244F40000", 26 | "allowFutureBlocks" : true 27 | }, 28 | "genesis": { 29 | "nonce": "0x0000000000000042", 30 | "difficulty": "0x020000", 31 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 32 | "author": "0x0000000000000000000000000000000000000000", 33 | "timestamp": "0x00", 34 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 36 | "gasLimit": "0x1388" 37 | }, 38 | "accounts": { 39 | } 40 | } 41 | )E"; 42 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/eip158Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoEIP158Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "maximumExtraDataSize": "0x20", 14 | "homesteadForkBlock": "0x00", 15 | "EIP150ForkBlock": "0x00", 16 | "EIP158ForkBlock": "0x00", 17 | "minGasLimit": "0x1388", 18 | "maxGasLimit": "7fffffffffffffff", 19 | "tieBreakingGas": false, 20 | "gasLimitBoundDivisor": "0x0400", 21 | "minimumDifficulty": "0x020000", 22 | "difficultyBoundDivisor": "0x0800", 23 | "durationLimit": "0x0d", 24 | "blockReward": "0x4563918244F40000", 25 | "networkID" : "0x1", 26 | "chainID": "0x01", 27 | "allowFutureBlocks" : true 28 | }, 29 | "genesis": { 30 | "nonce": "0x0000000000000042", 31 | "difficulty": "0x020000", 32 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 33 | "author": "0x0000000000000000000000000000000000000000", 34 | "timestamp": "0x00", 35 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 36 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 37 | "gasLimit": "0x1388" 38 | }, 39 | "accounts": { 40 | } 41 | } 42 | )E"; 43 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/experimentalTransitionTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2018-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoExperimentalTransitionTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "NoProof", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "maximumExtraDataSize": "0x20", 14 | "homesteadForkBlock": "0x00", 15 | "EIP150ForkBlock": "0x00", 16 | "EIP158ForkBlock": "0x00", 17 | "byzantiumForkBlock": "0x00", 18 | "constantinopleForkBlock": "0x00", 19 | "experimentalForkBlock": "0x02", 20 | "minGasLimit": "0x1388", 21 | "maxGasLimit": "7fffffffffffffff", 22 | "tieBreakingGas": false, 23 | "gasLimitBoundDivisor": "0x0400", 24 | "minimumDifficulty": "0x020000", 25 | "difficultyBoundDivisor": "0x0800", 26 | "durationLimit": "0x0d", 27 | "blockReward": "0x4563918244F40000", 28 | "networkID" : "0x1", 29 | "chainID": "0x01", 30 | "allowFutureBlocks" : true 31 | }, 32 | "genesis": { 33 | "nonce": "0x0000000000000042", 34 | "difficulty": "0x020000", 35 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 36 | "author": "0x0000000000000000000000000000000000000000", 37 | "timestamp": "0x00", 38 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 39 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 40 | "gasLimit": "0x1388" 41 | }, 42 | "accounts": { 43 | } 44 | } 45 | )E"; 46 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/frontierNoProofTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoFrontierNoProofTest = 8 | R"E( 9 | { 10 | "sealEngine": "NoProof", 11 | "params":{ 12 | "accountStartNonce": "0x00", 13 | "networkID" : "0x01", 14 | "chainID": "0x01", 15 | "maximumExtraDataSize": "0x20", 16 | "tieBreakingGas": false, 17 | "minGasLimit": "0x1388", 18 | "maxGasLimit": "7fffffffffffffff", 19 | "gasLimitBoundDivisor": "0x0400", 20 | "minimumDifficulty": "0x020000", 21 | "difficultyBoundDivisor": "0x0800", 22 | "durationLimit": "0x0d", 23 | "blockReward": "0x4563918244F40000", 24 | "allowFutureBlocks" : true 25 | }, 26 | "genesis": { 27 | "nonce": "0x0000000000000042", 28 | "difficulty": "0x020000", 29 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 30 | "author": "0x0000000000000000000000000000000000000000", 31 | "timestamp": "0x00", 32 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 33 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 34 | "gasLimit": "0x1388" 35 | }, 36 | "accounts": { 37 | } 38 | } 39 | )E"; 40 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/frontierTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoFrontierTest = 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params":{ 12 | "accountStartNonce": "0x00", 13 | "networkID" : "0x01", 14 | "chainID": "0x01", 15 | "maximumExtraDataSize": "0x20", 16 | "tieBreakingGas": false, 17 | "minGasLimit": "0x1388", 18 | "maxGasLimit": "7fffffffffffffff", 19 | "gasLimitBoundDivisor": "0x0400", 20 | "minimumDifficulty": "0x020000", 21 | "difficultyBoundDivisor": "0x0800", 22 | "durationLimit": "0x0d", 23 | "blockReward": "0x4563918244F40000", 24 | "allowFutureBlocks" : true 25 | }, 26 | "genesis": { 27 | "nonce": "0x0000000000000042", 28 | "difficulty": "0x020000", 29 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 30 | "author": "0x0000000000000000000000000000000000000000", 31 | "timestamp": "0x00", 32 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 33 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 34 | "gasLimit": "0x1388" 35 | }, 36 | "accounts": { 37 | } 38 | } 39 | )E"; 40 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/frontierToHomesteadAt5Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoFrontierToHomesteadAt5Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x05", 14 | "networkID" : "0x1", 15 | "chainID": "0x01", 16 | "maximumExtraDataSize": "0x20", 17 | "tieBreakingGas": false, 18 | "minGasLimit": "0x1388", 19 | "maxGasLimit": "0x7fffffffffffffff", 20 | "gasLimitBoundDivisor": "0x0400", 21 | "minimumDifficulty": "0x020000", 22 | "difficultyBoundDivisor": "0x0800", 23 | "durationLimit": "0x0d", 24 | "blockReward": "0x4563918244F40000", 25 | "allowFutureBlocks" : true 26 | }, 27 | "genesis": { 28 | "nonce": "0x0000000000000042", 29 | "difficulty": "0x020000", 30 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 31 | "author": "0x0000000000000000000000000000000000000000", 32 | "timestamp": "0x00", 33 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 34 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 35 | "gasLimit": "0x1388" 36 | }, 37 | "accounts": { 38 | } 39 | } 40 | )E"; 41 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/homesteadTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoHomesteadTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "maximumExtraDataSize": "0x20", 14 | "homesteadForkBlock": "0x00", 15 | "networkID" : "0x01", 16 | "chainID": "0x01", 17 | "minGasLimit": "0x1388", 18 | "maxGasLimit": "7fffffffffffffff", 19 | "tieBreakingGas": false, 20 | "gasLimitBoundDivisor": "0x0400", 21 | "minimumDifficulty": "0x020000", 22 | "difficultyBoundDivisor": "0x0800", 23 | "durationLimit": "0x0d", 24 | "blockReward": "0x4563918244F40000", 25 | "allowFutureBlocks" : true 26 | }, 27 | "genesis": { 28 | "nonce": "0x0000000000000042", 29 | "difficulty": "0x020000", 30 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 31 | "author": "0x0000000000000000000000000000000000000000", 32 | "timestamp": "0x00", 33 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 34 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 35 | "gasLimit": "0x1388" 36 | }, 37 | "accounts": { 38 | } 39 | } 40 | )E"; 41 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/homesteadToDaoAt5Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2017-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoHomesteadToDaoAt5Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x00", 14 | "daoHardforkBlock": "0x05", 15 | "networkID" : "0x1", 16 | "chainID": "0x01", 17 | "maximumExtraDataSize": "0x20", 18 | "tieBreakingGas": false, 19 | "minGasLimit": "0x1388", 20 | "maxGasLimit": "0x7fffffffffffffff", 21 | "gasLimitBoundDivisor": "0x0400", 22 | "minimumDifficulty": "0x020000", 23 | "difficultyBoundDivisor": "0x0800", 24 | "durationLimit": "0x0d", 25 | "blockReward": "0x4563918244F40000", 26 | "allowFutureBlocks" : true 27 | }, 28 | "genesis": { 29 | "nonce": "0x0000000000000042", 30 | "difficulty": "0x020000", 31 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 32 | "author": "0x0000000000000000000000000000000000000000", 33 | "timestamp": "0x00", 34 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 36 | "gasLimit": "0x1388" 37 | }, 38 | "accounts": { 39 | } 40 | } 41 | )E"; 42 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/homesteadToEIP150At5Test.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoHomesteadToEIP150At5Test = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x00", 14 | "EIP150ForkBlock": "0x05", 15 | "networkID" : "0x1", 16 | "chainID": "0x01", 17 | "maximumExtraDataSize": "0x20", 18 | "tieBreakingGas": false, 19 | "minGasLimit": "0x1388", 20 | "maxGasLimit": "0x7fffffffffffffff", 21 | "gasLimitBoundDivisor": "0x0400", 22 | "minimumDifficulty": "0x020000", 23 | "difficultyBoundDivisor": "0x0800", 24 | "durationLimit": "0x0d", 25 | "blockReward": "0x4563918244F40000", 26 | "allowFutureBlocks" : true 27 | }, 28 | "genesis": { 29 | "nonce": "0x0000000000000042", 30 | "difficulty": "0x020000", 31 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 32 | "author": "0x0000000000000000000000000000000000000000", 33 | "timestamp": "0x00", 34 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 36 | "gasLimit": "0x1388" 37 | }, 38 | "accounts": { 39 | } 40 | } 41 | )E"; 42 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/mainNetworkNoProofTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoMainNetworkNoProofTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "NoProof", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x118c30", 14 | "daoHardforkBlock": "0x1d4c00", 15 | "EIP150ForkBlock": "0x259518", 16 | "EIP158ForkBlock": "0x28d138", 17 | "byzantiumForkBlock": "0x2dc6c0", 18 | "constantinopleForkBlock": "0x2f36ca", 19 | "networkID" : "0x01", 20 | "chainID": "0x01", 21 | "maximumExtraDataSize": "0x20", 22 | "tieBreakingGas": false, 23 | "minGasLimit": "0x1388", 24 | "maxGasLimit": "7fffffffffffffff", 25 | "gasLimitBoundDivisor": "0x0400", 26 | "minimumDifficulty": "0x020000", 27 | "difficultyBoundDivisor": "0x0800", 28 | "durationLimit": "0x0d", 29 | "blockReward": "0x4563918244F40000" 30 | }, 31 | "genesis": { 32 | "nonce": "0x0000000000000042", 33 | "difficulty": "0x020000", 34 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "author": "0x0000000000000000000000000000000000000000", 36 | "timestamp": "0x00", 37 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 38 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 39 | "gasLimit": "0x1388" 40 | }, 41 | "accounts": { 42 | } 43 | } 44 | )E"; 45 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/mainNetworkTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoMainNetworkTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x118c30", 14 | "daoHardforkBlock": "0x1d4c00", 15 | "EIP150ForkBlock": "0x259518", 16 | "EIP158ForkBlock": "0x28d138", 17 | "byzantiumForkBlock": "0x42ae50", 18 | "constantinopleForkBlock": "0x500000", 19 | "networkID" : "0x01", 20 | "chainID": "0x01", 21 | "maximumExtraDataSize": "0x20", 22 | "tieBreakingGas": false, 23 | "minGasLimit": "0x1388", 24 | "maxGasLimit": "7fffffffffffffff", 25 | "gasLimitBoundDivisor": "0x0400", 26 | "minimumDifficulty": "0x020000", 27 | "difficultyBoundDivisor": "0x0800", 28 | "durationLimit": "0x0d", 29 | "blockReward": "0x4563918244F40000" 30 | }, 31 | "genesis": { 32 | "nonce": "0x0000000000000042", 33 | "difficulty": "0x020000", 34 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 35 | "author": "0x0000000000000000000000000000000000000000", 36 | "timestamp": "0x00", 37 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 38 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 39 | "gasLimit": "0x1388" 40 | }, 41 | "accounts": { 42 | } 43 | } 44 | )E"; 45 | -------------------------------------------------------------------------------- /libethashseal/genesis/test/transitionnetTest.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2016-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "../../GenesisInfo.h" 6 | 7 | static std::string const c_genesisInfoTest = std::string() + 8 | R"E( 9 | { 10 | "sealEngine": "Ethash", 11 | "params": { 12 | "accountStartNonce": "0x00", 13 | "homesteadForkBlock": "0x05", 14 | "daoHardforkBlock": "0x08", 15 | "EIP150ForkBlock": "0x0a", 16 | "EIP158ForkBlock": "0x0e", 17 | "byzantiumForkBlock": "0x10", 18 | "constantinopleForkBlock": "0x14", 19 | "networkID" : "0x01", 20 | "chainID": "0x01", 21 | "maximumExtraDataSize": "0x20", 22 | "tieBreakingGas": false, 23 | "minGasLimit": "0x1388", 24 | "maxGasLimit": "0x7fffffffffffffff", 25 | "gasLimitBoundDivisor": "0x0400", 26 | "minimumDifficulty": "0x020000", 27 | "difficultyBoundDivisor": "0x0800", 28 | "durationLimit": "0x0d", 29 | "blockReward": "0x4563918244F40000", 30 | "allowFutureBlocks" : true 31 | }, 32 | "genesis": { 33 | "nonce": "0x0000000000000042", 34 | "difficulty": "0x020000", 35 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 36 | "author": "0x0000000000000000000000000000000000000000", 37 | "timestamp": "0x00", 38 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 39 | "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 40 | "gasLimit": "0x1388" 41 | }, 42 | "accounts": { 43 | } 44 | } 45 | )E"; 46 | -------------------------------------------------------------------------------- /libethcore/BasicAuthority.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include "SealEngine.h" 10 | 11 | namespace dev 12 | { 13 | namespace eth 14 | { 15 | 16 | class BasicAuthority: public SealEngineBase 17 | { 18 | public: 19 | static std::string name() { return "BasicAuthority"; } 20 | unsigned revision() const override { return 0; } 21 | unsigned sealFields() const override { return 1; } 22 | bytes sealRLP() const override { return rlp(Signature()); } 23 | 24 | void populateFromParent(BlockHeader&, BlockHeader const&) const override; 25 | StringHashMap jsInfo(BlockHeader const& _bi) const override; 26 | void verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const override; 27 | bool shouldSeal(Interface*) override; 28 | void generateSeal(BlockHeader const& _bi) override; 29 | 30 | static Signature sig(BlockHeader const& _bi) { return _bi.seal(); } 31 | static BlockHeader& setSig(BlockHeader& _bi, Signature const& _sig) { _bi.setSeal(_sig); return _bi; } 32 | void setSecret(Secret const& _s) { m_secret = _s; } 33 | static void init(); 34 | 35 | private: 36 | bool onOptionChanging(std::string const& _name, bytes const& _value) override; 37 | 38 | Secret m_secret; 39 | AddressHash m_authorities; 40 | }; 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libethcore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp" "*.h") 2 | 3 | add_library(ethcore ${sources}) 4 | 5 | target_include_directories(ethcore PRIVATE "${UTILS_INCLUDE_DIR}") 6 | target_link_libraries(ethcore PUBLIC devcrypto devcore) 7 | -------------------------------------------------------------------------------- /libethcore/CommonJS.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "CommonJS.h" 6 | 7 | namespace dev 8 | { 9 | 10 | std::string prettyU256(u256 _n, bool _abridged) 11 | { 12 | std::string raw; 13 | std::ostringstream s; 14 | if (!(_n >> 64)) 15 | s << " " << (uint64_t)_n << " (0x" << std::hex << (uint64_t)_n << ")"; 16 | else if (!~(_n >> 64)) 17 | s << " " << (int64_t)_n << " (0x" << std::hex << (int64_t)_n << ")"; 18 | else if ((_n >> 160) == 0) 19 | { 20 | Address a = right160(_n); 21 | 22 | std::string n; 23 | if (_abridged) 24 | n = a.abridged(); 25 | else 26 | n = toHex(a.ref()); 27 | 28 | if (n.empty()) 29 | s << "0"; 30 | else 31 | s << _n << "(0x" << n << ")"; 32 | } 33 | else if (!(raw = fromRaw((h256)_n)).empty()) 34 | return "\"" + raw + "\""; 35 | else 36 | s << "" << (h256)_n; 37 | return s.str(); 38 | } 39 | 40 | namespace eth 41 | { 42 | 43 | BlockNumber jsToBlockNumber(std::string const& _js) 44 | { 45 | if (_js == "latest") 46 | return LatestBlock; 47 | else if (_js == "earliest") 48 | return 0; 49 | else if (_js == "pending") 50 | return PendingBlock; 51 | else 52 | return (unsigned)jsToInt(_js); 53 | } 54 | 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /libethcore/CommonJS.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include "Common.h" 12 | 13 | // devcrypto 14 | 15 | namespace dev 16 | { 17 | 18 | /// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length. 19 | inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } 20 | 21 | /// Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length. 22 | inline Secret jsToSecret(std::string const& _s) { h256 d = jsToFixed(_s); Secret ret(d); d.ref().cleanse(); return ret; } 23 | 24 | /// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length. 25 | inline Address jsToAddress(std::string const& _s) { return eth::toAddress(_s); } 26 | 27 | /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. 28 | std::string prettyU256(u256 _n, bool _abridged = true); 29 | 30 | } 31 | 32 | 33 | // ethcore 34 | namespace dev 35 | { 36 | namespace eth 37 | { 38 | 39 | /// Convert to a block number, a bit like jsToInt, except that it correctly recognises "pending" and "latest". 40 | BlockNumber jsToBlockNumber(std::string const& _js); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libethcore/EVMSchedule.cpp: -------------------------------------------------------------------------------- 1 | /// Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "EVMSchedule.h" 6 | #include 7 | 8 | namespace dev 9 | { 10 | namespace eth 11 | { 12 | EVMSchedule::EVMSchedule(EVMSchedule const& _schedule, AdditionalEIPs const& _eips) 13 | : EVMSchedule(_schedule) 14 | { 15 | if (_eips.eip1380) 16 | callSelfGas = 40; 17 | if (_eips.eip2046) 18 | precompileStaticCallGas = 40; 19 | } 20 | } // namespace eth 21 | } // namespace dev 22 | -------------------------------------------------------------------------------- /libethcore/LogEntry.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "LogEntry.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace dev 10 | { 11 | namespace eth 12 | { 13 | 14 | LogEntry::LogEntry(RLP const& _r) 15 | { 16 | assert(_r.itemCount() == 3); 17 | address = (Address)_r[0]; 18 | topics = _r[1].toVector(); 19 | data = _r[2].toBytes(); 20 | } 21 | 22 | void LogEntry::streamRLP(RLPStream& _s) const 23 | { 24 | _s.appendList(3) << address << topics << data; 25 | } 26 | 27 | LogBloom LogEntry::bloom() const 28 | { 29 | LogBloom ret; 30 | ret.shiftBloom<3>(sha3(address.ref())); 31 | for (auto t: topics) 32 | ret.shiftBloom<3>(sha3(t.ref())); 33 | return ret; 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /libethereum/BasicGasPricer.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include "GasPricer.h" 9 | 10 | namespace dev 11 | { 12 | namespace eth 13 | { 14 | 15 | class BasicGasPricer: public GasPricer 16 | { 17 | public: 18 | explicit BasicGasPricer(u256 _weiPerRef, u256 _refsPerBlock): m_weiPerRef(_weiPerRef), m_refsPerBlock(_refsPerBlock) {} 19 | 20 | void setRefPrice(u256 _weiPerRef) { if ((bigint)m_refsPerBlock * _weiPerRef > std::numeric_limits::max() ) BOOST_THROW_EXCEPTION(Overflow() << errinfo_comment("ether price * block fees is larger than 2**256-1, choose a smaller number.") ); else m_weiPerRef = _weiPerRef; } 21 | void setRefBlockFees(u256 _refsPerBlock) { if ((bigint)m_weiPerRef * _refsPerBlock > std::numeric_limits::max() ) BOOST_THROW_EXCEPTION(Overflow() << errinfo_comment("ether price * block fees is larger than 2**256-1, choose a smaller number.") ); else m_refsPerBlock = _refsPerBlock; } 22 | 23 | u256 ask(Block const&) const override { return m_weiPerRef * m_refsPerBlock / m_gasPerBlock; } 24 | u256 bid(TransactionPriority _p = TransactionPriority::Medium) const override { return m_octiles[(int)_p] > 0 ? m_octiles[(int)_p] : (m_weiPerRef * m_refsPerBlock / m_gasPerBlock); } 25 | 26 | void update(BlockChain const& _bc) override; 27 | 28 | private: 29 | u256 m_weiPerRef; 30 | u256 m_refsPerBlock; 31 | u256 m_gasPerBlock = DefaultBlockGasLimit; 32 | std::array m_octiles; 33 | }; 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /libethereum/BlockChainImporter.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "BlockChainImporter.h" 6 | #include "BlockChain.h" 7 | 8 | #include 9 | #include 10 | 11 | namespace dev 12 | { 13 | namespace eth 14 | { 15 | 16 | namespace 17 | { 18 | 19 | class BlockChainImporter: public BlockChainImporterFace 20 | { 21 | public: 22 | explicit BlockChainImporter(BlockChain& _blockChain): m_blockChain(_blockChain) {} 23 | 24 | void importBlock(BlockHeader const& _header, RLP _transactions, RLP _uncles, RLP _receipts, u256 const& _totalDifficulty) override 25 | { 26 | RLPStream headerRlp; 27 | _header.streamRLP(headerRlp); 28 | 29 | RLPStream block(3); 30 | block.appendRaw(headerRlp.out()); 31 | block << _transactions << _uncles; 32 | 33 | m_blockChain.insertWithoutParent(block.out(), _receipts.data(), _totalDifficulty); 34 | } 35 | 36 | void setChainStartBlockNumber(u256 const& _number) override 37 | { 38 | m_blockChain.setChainStartBlockNumber(static_cast(_number)); 39 | } 40 | 41 | private: 42 | BlockChain& m_blockChain; 43 | }; 44 | 45 | } 46 | 47 | std::unique_ptr createBlockChainImporter(BlockChain& _blockChain) 48 | { 49 | return std::unique_ptr(new BlockChainImporter(_blockChain)); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /libethereum/BlockChainImporter.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// Class for importing blocks into the blockchain. 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace dev 14 | { 15 | 16 | class RLP; 17 | 18 | namespace eth 19 | { 20 | 21 | class BlockChain; 22 | class BlockHeader; 23 | 24 | class BlockChainImporterFace 25 | { 26 | public: 27 | virtual ~BlockChainImporterFace() = default; 28 | 29 | virtual void importBlock(BlockHeader const& _header, RLP _transactions, RLP _uncles, RLP _receipts, u256 const& _totalDifficulty) = 0; 30 | 31 | virtual void setChainStartBlockNumber(u256 const& _number) = 0; 32 | }; 33 | 34 | std::unique_ptr createBlockChainImporter(BlockChain& _blockChain); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /libethereum/BlockDetails.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #include "BlockDetails.h" 7 | 8 | #include 9 | using namespace std; 10 | using namespace dev; 11 | using namespace dev::eth; 12 | 13 | BlockDetails::BlockDetails(RLP const& _r) 14 | { 15 | number = _r[0].toInt(); 16 | totalDifficulty = _r[1].toInt(); 17 | parentHash = _r[2].toHash(); 18 | childHashes = _r[3].toVector(); 19 | size = _r.size(); 20 | blockSizeBytes = _r[4].toInt(); 21 | } 22 | 23 | bytes BlockDetails::rlp() const 24 | { 25 | auto const detailsRlp = 26 | rlpList(number, totalDifficulty, parentHash, childHashes, blockSizeBytes); 27 | size = detailsRlp.size(); 28 | return detailsRlp; 29 | } 30 | -------------------------------------------------------------------------------- /libethereum/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp" "*.h") 2 | 3 | add_library(ethereum ${sources}) 4 | 5 | target_include_directories(ethereum PRIVATE "${UTILS_INCLUDE_DIR}") 6 | target_link_libraries(ethereum PUBLIC evm ethcore p2p devcrypto devcore PRIVATE jsoncpp_lib_static Snappy::snappy Boost::fiber Boost::context) 7 | -------------------------------------------------------------------------------- /libethereum/CodeSizeCache.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace dev 12 | { 13 | namespace eth 14 | { 15 | 16 | /** 17 | * @brief Simple thread-safe cache to store a mapping from code hash to code size. 18 | * If the cache is full, a random element is removed. 19 | */ 20 | class CodeSizeCache 21 | { 22 | public: 23 | void store(h256 const& _hash, size_t size) 24 | { 25 | UniqueGuard g(x_cache); 26 | if (m_cache.size() >= c_maxSize) 27 | removeRandomElement(); 28 | m_cache[_hash] = size; 29 | } 30 | bool contains(h256 const& _hash) const 31 | { 32 | UniqueGuard g(x_cache); 33 | return m_cache.count(_hash); 34 | } 35 | size_t get(h256 const& _hash) const 36 | { 37 | UniqueGuard g(x_cache); 38 | return m_cache.at(_hash); 39 | } 40 | 41 | static CodeSizeCache& instance() { static CodeSizeCache cache; return cache; } 42 | 43 | private: 44 | /// Removes a random element from the cache. 45 | void removeRandomElement() 46 | { 47 | if (!m_cache.empty()) 48 | { 49 | auto it = m_cache.lower_bound(h256::random()); 50 | if (it == m_cache.end()) 51 | it = m_cache.begin(); 52 | m_cache.erase(it); 53 | } 54 | } 55 | 56 | static const size_t c_maxSize = 50000; 57 | mutable Mutex x_cache; 58 | std::map m_cache; 59 | }; 60 | 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /libethereum/CommonNet.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #include "CommonNet.h" 7 | using namespace std; 8 | using namespace dev; 9 | using namespace dev::eth; 10 | 11 | namespace dev 12 | { 13 | namespace eth 14 | { 15 | #pragma GCC diagnostic ignored "-Wunused-variable" 16 | namespace 17 | { 18 | char dummy; 19 | } 20 | 21 | 22 | char const* ethPacketTypeToString(EthSubprotocolPacketType _packetType) 23 | { 24 | switch (_packetType) 25 | { 26 | case StatusPacket: 27 | return "Status"; 28 | case NewBlockHashesPacket: 29 | return "NewBlockHashes"; 30 | case TransactionsPacket: 31 | return "Transactions"; 32 | case GetBlockHeadersPacket: 33 | return "GetBlockHeaders"; 34 | case BlockHeadersPacket: 35 | return "BlockHeaders"; 36 | case GetBlockBodiesPacket: 37 | return "GetBlockBodies"; 38 | case BlockBodiesPacket: 39 | return "BlockBodies"; 40 | case NewBlockPacket: 41 | return "NewBlock"; 42 | case GetNodeDataPacket: 43 | return "GetNodeData"; 44 | case NodeDataPacket: 45 | return "NodeData"; 46 | case GetReceiptsPacket: 47 | return "GetReceipts"; 48 | case ReceiptsPacket: 49 | return "Receipts"; 50 | default: 51 | return "UnknownEthPacket"; 52 | } 53 | } 54 | } // namespace eth 55 | } // namespace dev -------------------------------------------------------------------------------- /libethereum/DatabasePaths.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include "libdevcore/FixedHash.h" 8 | #include 9 | 10 | namespace dev 11 | { 12 | namespace eth 13 | { 14 | class DatabasePaths 15 | { 16 | public: 17 | DatabasePaths(boost::filesystem::path const& _rootPath, h256 const& _genesisHash) noexcept; 18 | boost::filesystem::path const& rootPath() const noexcept; 19 | boost::filesystem::path const& chainPath() const noexcept; 20 | boost::filesystem::path const& blocksPath() const noexcept; 21 | boost::filesystem::path const& statePath() const noexcept; 22 | boost::filesystem::path const& extrasPath() const noexcept; 23 | boost::filesystem::path const& extrasTemporaryPath() const noexcept; 24 | boost::filesystem::path const& extrasMinorVersionPath() const noexcept; 25 | 26 | private: 27 | boost::filesystem::path m_rootPath; 28 | boost::filesystem::path m_chainPath; 29 | boost::filesystem::path m_blocksPath; 30 | boost::filesystem::path m_statePath; 31 | boost::filesystem::path m_extrasPath; 32 | boost::filesystem::path m_extrasTemporaryPath; 33 | boost::filesystem::path m_extrasMinorVersionPath; 34 | }; 35 | } // namespace eth 36 | } // namespace dev -------------------------------------------------------------------------------- /libethereum/GasPricer.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #include "GasPricer.h" 7 | 8 | using namespace std; 9 | using namespace dev; 10 | using namespace dev::eth; 11 | -------------------------------------------------------------------------------- /libethereum/GasPricer.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace dev 11 | { 12 | namespace eth 13 | { 14 | 15 | class Block; 16 | class BlockChain; 17 | 18 | enum class TransactionPriority 19 | { 20 | Lowest = 0, 21 | Low = 2, 22 | Medium = 4, 23 | High = 6, 24 | Highest = 8 25 | }; 26 | 27 | static const u256 DefaultGasPrice = 20 * shannon; 28 | 29 | class GasPricer 30 | { 31 | public: 32 | GasPricer() = default; 33 | virtual ~GasPricer() = default; 34 | 35 | virtual u256 ask(Block const&) const = 0; 36 | virtual u256 bid(TransactionPriority _p = TransactionPriority::Medium) const = 0; 37 | 38 | virtual void update(BlockChain const&) {} 39 | }; 40 | 41 | class TrivialGasPricer: public GasPricer 42 | { 43 | public: 44 | TrivialGasPricer() = default; 45 | TrivialGasPricer(u256 const& _ask, u256 const& _bid): m_ask(_ask), m_bid(_bid) {} 46 | 47 | void setAsk(u256 const& _ask) { m_ask = _ask; } 48 | void setBid(u256 const& _bid) { m_bid = _bid; } 49 | 50 | u256 ask() const { return m_ask; } 51 | u256 ask(Block const&) const override { return m_ask; } 52 | u256 bid(TransactionPriority = TransactionPriority::Medium) const override { return m_bid; } 53 | 54 | private: 55 | u256 m_ask = DefaultGasPrice; 56 | u256 m_bid = DefaultGasPrice; 57 | }; 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /libethereum/GenericMiner.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/aleth/5d1078ac43e0e2eaffb6e58300686d20a0bfb512/libethereum/GenericMiner.cpp -------------------------------------------------------------------------------- /libethereum/GenesisInfo.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace dev 13 | { 14 | namespace eth 15 | { 16 | 17 | extern std::string const c_genesisInfoTestBasicAuthority; 18 | extern dev::Addresses childDaos(); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /libethereum/ImportPerformanceLogger.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "ImportPerformanceLogger.h" 5 | 6 | #include 7 | #include 8 | 9 | using namespace dev; 10 | using namespace eth; 11 | 12 | namespace 13 | { 14 | 15 | template 16 | static std::string pairToString(std::pair const& _pair) 17 | { 18 | return "\"" + _pair.first + "\": " + toString(_pair.second); 19 | } 20 | 21 | } 22 | 23 | std::string ImportPerformanceLogger::constructReport(double _totalElapsed, std::unordered_map const& _additionalValues) 24 | { 25 | static std::string const Separator = ", "; 26 | 27 | std::string result; 28 | if (!_additionalValues.empty()) 29 | { 30 | auto const keyValuesAdditional = _additionalValues | boost::adaptors::transformed(pairToString); 31 | result += boost::algorithm::join(keyValuesAdditional, Separator); 32 | result += Separator; 33 | } 34 | 35 | m_stages.emplace("total", _totalElapsed); 36 | auto const keyValuesStages = m_stages | boost::adaptors::transformed(pairToString); 37 | result += boost::algorithm::join(keyValuesStages, Separator); 38 | 39 | return result; 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /libethereum/ImportPerformanceLogger.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// Class for logging of importing a Block into BlockChain. 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | namespace dev 16 | { 17 | 18 | namespace eth 19 | { 20 | 21 | class ImportPerformanceLogger 22 | { 23 | public: 24 | void onStageFinished(std::string const& _name) 25 | { 26 | m_stages[_name] = m_stageTimer.elapsed(); 27 | m_stageTimer.restart(); 28 | } 29 | 30 | double stageDuration(std::string const& _name) const 31 | { 32 | auto const it = m_stages.find(_name); 33 | return it != m_stages.end() ? it->second : 0; 34 | } 35 | 36 | void onFinished(std::unordered_map const& _additionalValues) 37 | { 38 | double const totalElapsed = m_totalTimer.elapsed(); 39 | if (totalElapsed > 0.5) 40 | { 41 | cdebug << "SLOW IMPORT: { " << constructReport(totalElapsed, _additionalValues) << " }"; 42 | } 43 | } 44 | 45 | private: 46 | std::string constructReport(double _totalElapsed, std::unordered_map const& _additionalValues); 47 | 48 | Timer m_totalTimer; 49 | Timer m_stageTimer; 50 | std::unordered_map m_stages; 51 | }; 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /libethereum/Interface.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #include "Interface.h" 5 | 6 | using namespace std; 7 | using namespace dev; 8 | using namespace eth; 9 | 10 | void Interface::submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data, u256 const& _gas, u256 const& _gasPrice, u256 const& _nonce) 11 | { 12 | TransactionSkeleton ts; 13 | ts.creation = false; 14 | ts.value = _value; 15 | ts.to = _dest; 16 | ts.data = _data; 17 | ts.gas = _gas; 18 | ts.gasPrice = _gasPrice; 19 | ts.nonce = _nonce; 20 | submitTransaction(ts, _secret); 21 | } 22 | 23 | BlockHeader Interface::blockInfo(BlockNumber _block) const 24 | { 25 | if (_block == PendingBlock) 26 | return pendingInfo(); 27 | return blockInfo(hashFromNumber(_block)); 28 | } 29 | 30 | BlockDetails Interface::blockDetails(BlockNumber _block) const 31 | { 32 | if (_block == PendingBlock) 33 | return pendingDetails(); 34 | return blockDetails(hashFromNumber(_block)); 35 | } 36 | -------------------------------------------------------------------------------- /libethereum/LastBlockHashesFace.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// Interface for getting a list of recent block hashes 7 | #pragma once 8 | 9 | #include 10 | 11 | 12 | namespace dev 13 | { 14 | 15 | namespace eth 16 | { 17 | 18 | /** 19 | * @brief Interface for getting a list of recent block hashes 20 | * @threadsafe 21 | */ 22 | class LastBlockHashesFace 23 | { 24 | public: 25 | virtual ~LastBlockHashesFace() {} 26 | 27 | /// Get hashes of 256 consecutive blocks preceding and including @a _mostRecentHash 28 | /// Hashes are returned in the order of descending height, 29 | /// i.e. result[0] is @a _mostRecentHash, result[1] is its parent, result[2] is grandparent etc. 30 | virtual h256s precedingHashes(h256 const& _mostRecentHash) const = 0; 31 | 32 | /// Clear any cached result 33 | virtual void clear() = 0; 34 | }; 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /libethereum/SecureTrieDB.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace dev 10 | { 11 | namespace eth 12 | { 13 | #if ETH_FATDB 14 | template 15 | using SecureTrieDB = SpecificTrieDB, KeyType>; 16 | #else 17 | template 18 | using SecureTrieDB = SpecificTrieDB, KeyType>; 19 | #endif 20 | 21 | } // namespace eth 22 | } // namespace dev 23 | -------------------------------------------------------------------------------- /libethereum/SnapshotImporter.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// Class for importing snapshot from directory on disk 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace dev 15 | { 16 | 17 | namespace eth 18 | { 19 | 20 | class Client; 21 | class BlockChainImporterFace; 22 | class SnapshotStorageFace; 23 | class StateImporterFace; 24 | 25 | class SnapshotImporter 26 | { 27 | public: 28 | SnapshotImporter(StateImporterFace& _stateImporter, BlockChainImporterFace& _bcImporter): m_stateImporter(_stateImporter), m_blockChainImporter(_bcImporter) {} 29 | 30 | void import(SnapshotStorageFace const& _snapshotStorage, h256 const& _genesisHash); 31 | 32 | private: 33 | void importStateChunks(SnapshotStorageFace const& _snapshotStorage, h256s const& _stateChunkHashes, h256 const& _stateRoot); 34 | void importBlockChunks(SnapshotStorageFace const& _snapshotStorage, h256s const& _blockChunkHashes); 35 | 36 | StateImporterFace& m_stateImporter; 37 | BlockChainImporterFace& m_blockChainImporter; 38 | 39 | Logger m_logger{createLogger(VerbosityInfo, "snap")}; 40 | }; 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libethereum/SnapshotStorage.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace dev 16 | { 17 | 18 | namespace eth 19 | { 20 | 21 | DEV_SIMPLE_EXCEPTION(FailedToReadSnapshotManifestFile); 22 | DEV_SIMPLE_EXCEPTION(FailedToReadChunkFile); 23 | DEV_SIMPLE_EXCEPTION(ChunkIsTooBig); 24 | DEV_SIMPLE_EXCEPTION(ChunkDataCorrupted); 25 | DEV_SIMPLE_EXCEPTION(FailedToGetUncompressedLength); 26 | DEV_SIMPLE_EXCEPTION(FailedToUncompressedSnapshotChunk); 27 | 28 | class SnapshotStorageFace 29 | { 30 | public: 31 | virtual ~SnapshotStorageFace() = default; 32 | 33 | virtual bytes readManifest() const = 0; 34 | 35 | virtual std::string readCompressedChunk(h256 const& _chunkHash) const = 0; 36 | 37 | virtual std::string readChunk(h256 const& _chunkHash) const = 0; 38 | 39 | virtual void copyTo(boost::filesystem::path const& _path) const = 0; 40 | }; 41 | 42 | 43 | std::unique_ptr createSnapshotStorage( 44 | boost::filesystem::path const& _snapshotDirPath); 45 | 46 | boost::filesystem::path importedSnapshotPath( 47 | boost::filesystem::path const& _dataDir, h256 const& _genesisHash); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /libethereum/StateImporter.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// Class for importing accounts into the State Trie 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace dev 16 | { 17 | 18 | class OverlayDB; 19 | 20 | namespace eth 21 | { 22 | 23 | DEV_SIMPLE_EXCEPTION(InvalidAccountInTheDatabase); 24 | 25 | class StateImporterFace 26 | { 27 | public: 28 | virtual ~StateImporterFace() = default; 29 | 30 | virtual void importAccount(h256 const& _addressHash, u256 const& _nonce, u256 const& _balance, std::map const& _storage, h256 const& _codeHash) = 0; 31 | 32 | virtual h256 importCode(bytesConstRef _code) = 0; 33 | 34 | virtual void commitStateDatabase() = 0; 35 | 36 | virtual bool isAccountImported(h256 const& _addressHash) const = 0; 37 | 38 | virtual h256 stateRoot() const = 0; 39 | 40 | virtual std::string lookupCode(h256 const& _hash) const = 0; 41 | }; 42 | 43 | std::unique_ptr createStateImporter(OverlayDB& _stateDb); 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /libethereum/VerifiedBlock.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | 7 | #include 8 | #include 9 | 10 | #pragma once 11 | 12 | namespace dev 13 | { 14 | namespace eth 15 | { 16 | 17 | class Transaction; 18 | 19 | /// @brief Verified block info, does not hold block data, but a reference instead 20 | struct VerifiedBlockRef 21 | { 22 | bytesConstRef block; ///< Block data reference 23 | BlockHeader info; ///< Prepopulated block info 24 | std::vector transactions; ///< Verified list of block transactions 25 | }; 26 | 27 | /// @brief Verified block info, combines block data and verified info/transactions 28 | struct VerifiedBlock 29 | { 30 | VerifiedBlock() {} 31 | 32 | VerifiedBlock(BlockHeader&& _bi) 33 | { 34 | verified.info = std::move(_bi); 35 | } 36 | 37 | VerifiedBlock(VerifiedBlock&& _other): 38 | verified(std::move(_other.verified)), 39 | blockData(std::move(_other.blockData)) 40 | { 41 | } 42 | 43 | VerifiedBlock& operator=(VerifiedBlock&& _other) 44 | { 45 | assert(&_other != this); 46 | 47 | verified = std::move(_other.verified); 48 | blockData = std::move(_other.blockData); 49 | return *this; 50 | } 51 | 52 | VerifiedBlockRef verified; ///< Verified block structures 53 | bytes blockData; ///< Block data 54 | 55 | private: 56 | VerifiedBlock(VerifiedBlock const&) = delete; 57 | VerifiedBlock operator=(VerifiedBlock const&) = delete; 58 | }; 59 | 60 | using VerifiedBlocks = std::vector; 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /libevm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(sources 3 | EVMC.cpp EVMC.h 4 | ExtVMFace.cpp ExtVMFace.h 5 | Instruction.cpp Instruction.h 6 | LegacyVM.cpp LegacyVM.h 7 | LegacyVMConfig.h 8 | LegacyVMCalls.cpp 9 | LegacyVMOpt.cpp 10 | VMFace.h 11 | VMFactory.cpp VMFactory.h 12 | ) 13 | 14 | add_library(evm ${sources}) 15 | 16 | target_link_libraries( 17 | evm 18 | PUBLIC ethcore devcore evmc::evmc 19 | PRIVATE aleth-interpreter aleth-buildinfo jsoncpp_lib_static Boost::program_options evmc::loader 20 | ) 21 | 22 | if(EVM_OPTIMIZE) 23 | target_compile_definitions(evm PRIVATE EVM_OPTIMIZE) 24 | endif() 25 | -------------------------------------------------------------------------------- /libevm/EVMC.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace dev 13 | { 14 | namespace eth 15 | { 16 | /// The wrapper implementing the VMFace interface with a EVMC VM as a backend. 17 | class EVMC : public evmc::VM, public VMFace 18 | { 19 | public: 20 | EVMC(evmc_vm* _vm, std::vector> const& _options) noexcept; 21 | 22 | owning_bytes_ref exec(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _onOp) final; 23 | }; 24 | } // namespace eth 25 | } // namespace dev 26 | -------------------------------------------------------------------------------- /libevm/VMFactory.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #include "VMFace.h" 7 | 8 | #include 9 | 10 | namespace dev 11 | { 12 | namespace eth 13 | { 14 | enum class VMKind 15 | { 16 | Interpreter, 17 | Legacy, 18 | DLL 19 | }; 20 | 21 | /// Provide a set of program options related to VMs. 22 | /// 23 | /// @param _lineLength The line length for description text wrapping, the same as in 24 | /// boost::program_options::options_description::options_description(). 25 | boost::program_options::options_description vmProgramOptions( 26 | unsigned _lineLength = boost::program_options::options_description::m_default_line_length); 27 | 28 | using VMPtr = std::unique_ptr; 29 | 30 | class VMFactory 31 | { 32 | public: 33 | VMFactory() = delete; 34 | ~VMFactory() = delete; 35 | 36 | /// Creates a VM instance of the global kind (controlled by the --vm command line option). 37 | static VMPtr create(); 38 | 39 | /// Creates a VM instance of the kind provided. 40 | static VMPtr create(VMKind _kind); 41 | }; 42 | } // namespace eth 43 | } // namespace dev 44 | -------------------------------------------------------------------------------- /libp2p/All.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | #include "HostCapability.h" 5 | #include "Capability.h" 6 | #include "Host.h" 7 | #include "Session.h" 8 | 9 | -------------------------------------------------------------------------------- /libp2p/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources "*.cpp" "*.h") 2 | 3 | add_library(p2p ${sources}) 4 | target_link_libraries(p2p PUBLIC devcrypto devcore) 5 | target_include_directories(p2p SYSTEM PRIVATE ${CRYPTOPP_INCLUDE_DIR}) 6 | 7 | if(MINIUPNPC) 8 | target_link_libraries(p2p PRIVATE "${MINIUPNPC_LIBRARY}") 9 | target_include_directories(p2p SYSTEM PRIVATE "${MINIUPNPC_INCLUDE_DIR}") 10 | target_compile_definitions(p2p PRIVATE ETH_MINIUPNPC) 11 | endif() -------------------------------------------------------------------------------- /libp2p/RLPXSocket.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include "Common.h" 8 | 9 | namespace dev 10 | { 11 | namespace p2p 12 | { 13 | 14 | /** 15 | * @brief Shared pointer wrapper for ASIO TCP socket. 16 | * 17 | * Thread Safety 18 | * Distinct Objects: Safe. 19 | * Shared objects: Unsafe. 20 | * * an instance method must not be called concurrently 21 | */ 22 | class RLPXSocket: public std::enable_shared_from_this 23 | { 24 | public: 25 | explicit RLPXSocket(bi::tcp::socket _socket) : m_socket(std::move(_socket)) {} 26 | ~RLPXSocket() { close(); } 27 | 28 | bool isConnected() const { return m_socket.is_open(); } 29 | void close() { try { boost::system::error_code ec; m_socket.shutdown(bi::tcp::socket::shutdown_both, ec); if (m_socket.is_open()) m_socket.close(); } catch (...){} } 30 | bi::tcp::endpoint remoteEndpoint() { boost::system::error_code ec; return m_socket.remote_endpoint(ec); } 31 | bi::tcp::socket& ref() { return m_socket; } 32 | 33 | protected: 34 | bi::tcp::socket m_socket; 35 | }; 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /libp2p/UDP.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "UDP.h" 6 | using namespace std; 7 | using namespace dev; 8 | using namespace dev::p2p; 9 | 10 | h256 RLPXDatagramFace::sign(Secret const& _k) 11 | { 12 | assert(packetType()); 13 | 14 | RLPStream rlpxstream; 15 | // rlpxstream.appendRaw(toPublic(_k).asBytes()); // for mdc-based signature 16 | rlpxstream.appendRaw(bytes(1, packetType())); // prefix by 1 byte for type 17 | streamRLP(rlpxstream); 18 | bytes rlpxBytes(rlpxstream.out()); 19 | 20 | bytesConstRef rlpx(&rlpxBytes); 21 | h256 sighash(dev::sha3(rlpx)); // H(type||data) 22 | Signature sig = dev::sign(_k, sighash); // S(H(type||data)) 23 | 24 | data.resize(h256::size + Signature::size + rlpx.size()); 25 | bytesRef rlpxHash(&data[0], h256::size); 26 | bytesRef rlpxSig(&data[h256::size], Signature::size); 27 | bytesRef rlpxPayload(&data[h256::size + Signature::size], rlpx.size()); 28 | 29 | sig.ref().copyTo(rlpxSig); 30 | rlpx.copyTo(rlpxPayload); 31 | 32 | bytesConstRef signedRLPx(&data[h256::size], data.size() - h256::size); 33 | h256 hash(dev::sha3(signedRLPx)); 34 | hash.ref().copyTo(rlpxHash); 35 | 36 | return hash; 37 | } 38 | 39 | Public RLPXDatagramFace::authenticate(bytesConstRef _sig, bytesConstRef _rlp) 40 | { 41 | Signature const& sig = *(Signature const*)_sig.data(); 42 | return dev::recover(sig, sha3(_rlp)); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /libp2p/UPnP.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct UPNPUrls; 14 | struct IGDdatas; 15 | 16 | namespace dev 17 | { 18 | namespace p2p 19 | { 20 | 21 | class UPnP 22 | { 23 | public: 24 | UPnP(); 25 | ~UPnP(); 26 | 27 | std::string externalIP(); 28 | int addRedirect(char const* addr, int port); 29 | void removeRedirect(int port); 30 | 31 | bool isValid() const { return m_ok; } 32 | 33 | private: 34 | std::set m_reg; 35 | bool m_ok; 36 | std::shared_ptr m_urls; 37 | std::shared_ptr m_data; 38 | }; 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /libweb3jsonrpc/AdminNet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AdminNetFace.h" 3 | 4 | namespace dev 5 | { 6 | 7 | class NetworkFace; 8 | 9 | namespace rpc 10 | { 11 | 12 | class SessionManager; 13 | 14 | class AdminNet: public dev::rpc::AdminNetFace 15 | { 16 | public: 17 | AdminNet(NetworkFace& _network, SessionManager& _sm); 18 | virtual RPCModules implementedModules() const override 19 | { 20 | return RPCModules{RPCModule{"admin", "1.0"}}; 21 | } 22 | virtual bool admin_net_connect(std::string const& _node, std::string const& _session) override; 23 | virtual Json::Value admin_net_peers(std::string const& _session) override; 24 | virtual Json::Value admin_net_nodeInfo(std::string const& _session) override; 25 | virtual Json::Value admin_nodeInfo() override; 26 | virtual Json::Value admin_peers() override; 27 | virtual bool admin_addPeer(std::string const& _node) override; 28 | 29 | private: 30 | NetworkFace& m_network; 31 | SessionManager& m_sm; 32 | }; 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /libweb3jsonrpc/IpcServer.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #if _WIN32 7 | #include "WinPipeServer.h" 8 | #else 9 | #include "UnixSocketServer.h" 10 | #endif 11 | 12 | namespace dev 13 | { 14 | #if _WIN32 15 | using IpcServer = WindowsPipeServer; 16 | #else 17 | using IpcServer = UnixDomainSocketServer; 18 | #endif 19 | } // namespace dev 20 | -------------------------------------------------------------------------------- /libweb3jsonrpc/IpcServerBase.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace dev 16 | { 17 | template class IpcServerBase: public jsonrpc::AbstractServerConnector 18 | { 19 | public: 20 | IpcServerBase(std::string const& _path); 21 | virtual bool StartListening(); 22 | virtual bool StopListening(); 23 | virtual bool SendResponse(std::string const& _response, void* _addInfo = nullptr); 24 | 25 | protected: 26 | virtual void Listen() = 0; 27 | virtual void CloseConnection(S _socket) = 0; 28 | virtual size_t Write(S _connection, std::string const& _data) = 0; 29 | virtual size_t Read(S _connection, void* _data, size_t _size) = 0; 30 | void GenerateResponse(S _connection); 31 | 32 | protected: 33 | std::atomic m_running{false}; 34 | std::string m_path; 35 | std::unordered_set m_sockets; 36 | std::mutex x_sockets; 37 | std::thread m_listeningThread; //TODO use asio for parallel request processing 38 | }; 39 | } // namespace dev 40 | -------------------------------------------------------------------------------- /libweb3jsonrpc/Net.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include 6 | #include 7 | #include 8 | #include "Net.h" 9 | 10 | using namespace dev; 11 | using namespace dev::rpc; 12 | 13 | Net::Net(NetworkFace& _network): m_network(_network) {} 14 | 15 | std::string Net::net_version() 16 | { 17 | return toString(m_network.networkId()); 18 | } 19 | 20 | std::string Net::net_peerCount() 21 | { 22 | return toJS(m_network.peerCount()); 23 | } 24 | 25 | bool Net::net_listening() 26 | { 27 | return m_network.isNetworkStarted(); 28 | } 29 | -------------------------------------------------------------------------------- /libweb3jsonrpc/Net.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | 6 | #pragma once 7 | #include "NetFace.h" 8 | 9 | namespace dev 10 | { 11 | 12 | class NetworkFace; 13 | 14 | namespace rpc 15 | { 16 | 17 | class Net: public NetFace 18 | { 19 | public: 20 | Net(NetworkFace& _network); 21 | virtual RPCModules implementedModules() const override 22 | { 23 | return RPCModules{RPCModule{"net", "1.0"}}; 24 | } 25 | virtual std::string net_version() override; 26 | virtual std::string net_peerCount() override; 27 | virtual bool net_listening() override; 28 | 29 | private: 30 | NetworkFace& m_network; 31 | }; 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /libweb3jsonrpc/Personal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PersonalFace.h" 3 | 4 | namespace dev 5 | { 6 | 7 | namespace eth 8 | { 9 | class KeyManager; 10 | class AccountHolder; 11 | class Interface; 12 | } 13 | 14 | namespace rpc 15 | { 16 | 17 | class Personal: public dev::rpc::PersonalFace 18 | { 19 | public: 20 | Personal(dev::eth::KeyManager& _keyManager, dev::eth::AccountHolder& _accountHolder, eth::Interface& _eth); 21 | virtual RPCModules implementedModules() const override 22 | { 23 | return RPCModules{RPCModule{"personal", "1.0"}}; 24 | } 25 | virtual std::string personal_newAccount(std::string const& _password) override; 26 | virtual bool personal_unlockAccount(std::string const& _address, std::string const& _password, int _duration) override; 27 | virtual std::string personal_signAndSendTransaction(Json::Value const& _transaction, std::string const& _password) override; 28 | virtual std::string personal_sendTransaction(Json::Value const& _transaction, std::string const& _password) override; 29 | virtual Json::Value personal_listAccounts() override; 30 | 31 | private: 32 | dev::eth::KeyManager& m_keyManager; 33 | dev::eth::AccountHolder& m_accountHolder; 34 | dev::eth::Interface& m_eth; 35 | }; 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /libweb3jsonrpc/SessionManager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SessionManager.h" 3 | 4 | using namespace std; 5 | using namespace dev; 6 | using namespace dev::rpc; 7 | 8 | std::string SessionManager::newSession(SessionPermissions const& _p) 9 | { 10 | std::string s = toBase64(h64::random().ref()); 11 | m_sessions[s] = _p; 12 | return s; 13 | } 14 | 15 | void SessionManager::addSession(std::string const& _session, SessionPermissions const& _p) 16 | { 17 | m_sessions[_session] = _p; 18 | } 19 | 20 | bool SessionManager::hasPrivilegeLevel(std::string const& _session, Privilege _l) const 21 | { 22 | auto it = m_sessions.find(_session); 23 | return it != m_sessions.end() && it->second.privileges.count(_l); 24 | } 25 | -------------------------------------------------------------------------------- /libweb3jsonrpc/SessionManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #define RPC_ADMIN if (!m_sm.hasPrivilegeLevel(_session, Privilege::Admin)) throw jsonrpc::JsonRpcException("Invalid privileges"); 6 | 7 | namespace dev 8 | { 9 | namespace rpc 10 | { 11 | 12 | enum class Privilege 13 | { 14 | Admin 15 | }; 16 | 17 | } 18 | } 19 | 20 | namespace std 21 | { 22 | template<> struct hash 23 | { 24 | size_t operator()(dev::rpc::Privilege _value) const { return (size_t)_value; } 25 | }; 26 | } 27 | 28 | namespace dev 29 | { 30 | namespace rpc 31 | { 32 | 33 | struct SessionPermissions 34 | { 35 | std::unordered_set privileges; 36 | }; 37 | 38 | class SessionManager 39 | { 40 | public: 41 | std::string newSession(SessionPermissions const& _p); 42 | void addSession(std::string const& _session, SessionPermissions const& _p); 43 | bool hasPrivilegeLevel(std::string const& _session, Privilege _l) const; 44 | 45 | private: 46 | std::unordered_map m_sessions; 47 | }; 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /libweb3jsonrpc/Test.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | #include "TestFace.h" 7 | 8 | namespace dev 9 | { 10 | 11 | namespace eth 12 | { 13 | class Client; 14 | } 15 | 16 | namespace rpc 17 | { 18 | 19 | class Test: public TestFace 20 | { 21 | public: 22 | Test(eth::Client& _eth); 23 | virtual RPCModules implementedModules() const override 24 | { 25 | return RPCModules{RPCModule{"test", "1.0"}}; 26 | } 27 | virtual std::string test_getLogHash(std::string const& _param1) override; 28 | virtual std::string test_importRawBlock(std::string const& _blockRLP) override; 29 | virtual bool test_setChainParams(const Json::Value& _param1) override; 30 | virtual bool test_mineBlocks(int _number) override; 31 | virtual bool test_modifyTimestamp(int _timestamp) override; 32 | virtual bool test_rewindToBlock(int _number) override; 33 | 34 | private: 35 | eth::Client& m_eth; 36 | }; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /libweb3jsonrpc/UnixSocketServer.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #include "IpcServerBase.h" 7 | 8 | #include 9 | #include 10 | 11 | namespace dev 12 | { 13 | class UnixDomainSocketServer : public IpcServerBase 14 | { 15 | public: 16 | explicit UnixDomainSocketServer(std::string const& _appId); 17 | ~UnixDomainSocketServer() override; 18 | bool StartListening() override; 19 | bool StopListening() override; 20 | 21 | protected: 22 | void Listen() override; 23 | void CloseConnection(int _socket) override; 24 | size_t Write(int _connection, std::string const& _data) override; 25 | size_t Read(int _connection, void* _data, size_t _size) override; 26 | 27 | sockaddr_un m_address; 28 | std::atomic m_socket{0}; 29 | }; 30 | 31 | } // namespace dev 32 | -------------------------------------------------------------------------------- /libweb3jsonrpc/Web3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Web3.h" 4 | 5 | using namespace std; 6 | using namespace dev; 7 | 8 | std::string rpc::Web3::web3_sha3(std::string const& _param1) 9 | { 10 | return toJS(sha3(jsToBytes(_param1))); 11 | } -------------------------------------------------------------------------------- /libweb3jsonrpc/Web3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Web3Face.h" 3 | 4 | namespace dev 5 | { 6 | namespace rpc 7 | { 8 | 9 | class Web3: public Web3Face 10 | { 11 | public: 12 | Web3(std::string _clientVersion = "C++ (cpp-ethereum)"): m_clientVersion(std::move(_clientVersion)) {} 13 | virtual RPCModules implementedModules() const override 14 | { 15 | return RPCModules{RPCModule{"web3", "1.0"}}; 16 | } 17 | virtual std::string web3_sha3(std::string const& _param1) override; 18 | virtual std::string web3_clientVersion() override { return m_clientVersion; } 19 | 20 | private: 21 | std::string m_clientVersion; 22 | }; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /libweb3jsonrpc/Web3Face.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! 3 | */ 4 | 5 | #ifndef JSONRPC_CPP_STUB_DEV_RPC_WEB3FACE_H_ 6 | #define JSONRPC_CPP_STUB_DEV_RPC_WEB3FACE_H_ 7 | 8 | #include "ModularServer.h" 9 | 10 | namespace dev { 11 | namespace rpc { 12 | class Web3Face : public ServerInterface 13 | { 14 | public: 15 | Web3Face() 16 | { 17 | this->bindAndAddMethod(jsonrpc::Procedure("web3_sha3", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &dev::rpc::Web3Face::web3_sha3I); 18 | this->bindAndAddMethod(jsonrpc::Procedure("web3_clientVersion", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &dev::rpc::Web3Face::web3_clientVersionI); 19 | } 20 | 21 | inline virtual void web3_sha3I(const Json::Value &request, Json::Value &response) 22 | { 23 | response = this->web3_sha3(request[0u].asString()); 24 | } 25 | inline virtual void web3_clientVersionI(const Json::Value &request, Json::Value &response) 26 | { 27 | (void)request; 28 | response = this->web3_clientVersion(); 29 | } 30 | virtual std::string web3_sha3(const std::string& param1) = 0; 31 | virtual std::string web3_clientVersion() = 0; 32 | }; 33 | 34 | } 35 | } 36 | #endif //JSONRPC_CPP_STUB_DEV_RPC_WEB3FACE_H_ 37 | -------------------------------------------------------------------------------- /libweb3jsonrpc/WinPipeServer.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #include "IpcServerBase.h" 7 | 8 | #include 9 | 10 | namespace dev 11 | { 12 | class WindowsPipeServer : public IpcServerBase 13 | { 14 | public: 15 | WindowsPipeServer(std::string const& _appId); 16 | 17 | protected: 18 | void Listen() override; 19 | void CloseConnection(HANDLE _socket) override; 20 | size_t Write(HANDLE _connection, std::string const& _data) override; 21 | size_t Read(HANDLE _connection, void* _data, size_t _size) override; 22 | }; 23 | 24 | } // namespace dev 25 | -------------------------------------------------------------------------------- /libweb3jsonrpc/admin_eth.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "admin_eth_blockQueueStatus", "params": [""], "returns": {}}, 3 | { "name": "admin_eth_setAskPrice", "params": ["", ""], "returns": true }, 4 | { "name": "admin_eth_setBidPrice", "params": ["", ""], "returns": true }, 5 | { "name": "admin_eth_setMining", "params": [true, ""], "returns": true }, 6 | { "name": "admin_eth_findBlock", "params": ["", ""], "returns": {} }, 7 | { "name": "admin_eth_blockQueueFirstUnknown", "params": [""], "returns": "" }, 8 | { "name": "admin_eth_blockQueueRetryUnknown", "params": [""], "returns": true }, 9 | { "name": "admin_eth_allAccounts", "params": [""], "returns": [] }, 10 | { "name": "admin_eth_newAccount", "params": [{}, ""], "returns": {} }, 11 | { "name": "admin_eth_setMiningBenefactor", "params": ["", ""], "returns": true }, 12 | { "name": "admin_eth_inspect", "params": ["", ""], "returns": {} }, 13 | { "name": "admin_eth_vmTrace", "params": ["", 0, ""], "returns": {} }, 14 | { "name": "admin_eth_getReceiptByHashAndIndex", "params": ["", 0, ""], "returns": {} }, 15 | { "name": "miner_start", "params": [0], "returns": true }, 16 | { "name": "miner_stop", "params": [], "returns": true }, 17 | { "name": "miner_setEtherbase", "params": [""], "returns": true }, 18 | { "name": "miner_setExtra", "params": [""], "returns": true }, 19 | { "name": "miner_setGasPrice", "params": [""], "returns": true }, 20 | { "name": "miner_hashrate", "params": [], "returns": "" } 21 | ] 22 | -------------------------------------------------------------------------------- /libweb3jsonrpc/admin_net.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "admin_net_connect", "params": ["", ""], "returns": true }, 3 | { "name": "admin_net_peers", "params": [""], "returns": [] }, 4 | { "name": "admin_net_nodeInfo", "params": [""], "returns": {}}, 5 | { "name": "admin_nodeInfo", "params": [], "returns": {}}, 6 | { "name": "admin_peers", "params": [], "returns": {}}, 7 | { "name": "admin_addPeer", "params": [""], "returns": true} 8 | ] 9 | -------------------------------------------------------------------------------- /libweb3jsonrpc/debug.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "debug_accountRange", "params": ["", 0, "", 0], "returns": {}}, 3 | { "name": "debug_traceTransaction", "params": ["", {}], "returns": {}}, 4 | { "name": "debug_storageRangeAt", "params": ["", 0, "", "", 0], "returns": {}}, 5 | { "name": "debug_preimage", "params": [""], "returns": ""}, 6 | { "name": "debug_traceBlockByNumber", "params": [0, {}], "returns": {}}, 7 | { "name": "debug_traceBlockByHash", "params": ["", {}], "returns": {}}, 8 | { "name": "debug_traceCall", "params": [{}, "", {}], "returns": {}} 9 | ] 10 | -------------------------------------------------------------------------------- /libweb3jsonrpc/net.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "net_version", "params": [], "order": [], "returns" : "" }, 3 | { "name": "net_peerCount", "params": [], "order": [], "returns" : "" }, 4 | { "name": "net_listening", "params": [], "order": [], "returns" : false } 5 | ] 6 | -------------------------------------------------------------------------------- /libweb3jsonrpc/personal.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "personal_newAccount", "params": [""], "returns": "" }, 3 | { "name": "personal_unlockAccount", "params": ["", "", 0], "returns": true }, 4 | { "name": "personal_signAndSendTransaction", "params": [{}, ""], "returns": "" }, 5 | { "name": "personal_sendTransaction", "params": [{}, ""], "returns": "" }, 6 | { "name": "personal_listAccounts", "params": [], "returns": [] } 7 | ] 8 | -------------------------------------------------------------------------------- /libweb3jsonrpc/test.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "test_getLogHash", "params": [""], "order": [], "returns": ""}, 3 | { "name": "test_importRawBlock", "params": [""], "order": [], "returns": ""}, 4 | { "name": "test_setChainParams", "params": [{}], "order": [], "returns": false}, 5 | { "name": "test_mineBlocks", "params": [0], "returns": false }, 6 | { "name": "test_modifyTimestamp", "params": [0], "returns": false }, 7 | { "name": "test_rewindToBlock", "params": [0], "returns": false } 8 | ] 9 | -------------------------------------------------------------------------------- /libweb3jsonrpc/web3.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "web3_sha3", "params": [""], "returns" : "" }, 3 | { "name": "web3_clientVersion", "params": [], "returns" : "" } 4 | ] 5 | -------------------------------------------------------------------------------- /libwebthree/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(webthree WebThree.cpp WebThree.h) 2 | target_include_directories(webthree PRIVATE ../utils) 3 | target_link_libraries(webthree PUBLIC ethereum p2p devcore) 4 | -------------------------------------------------------------------------------- /refilltests: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/aleth/5d1078ac43e0e2eaffb6e58300686d20a0bfb512/refilltests -------------------------------------------------------------------------------- /rlp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(rlp main.cpp) 2 | target_include_directories(rlp PRIVATE "${UTILS_INCLUDE_DIR}") 3 | target_link_libraries(rlp PRIVATE devcrypto devcore Boost::program_options) 4 | -------------------------------------------------------------------------------- /sanitizer-blacklist.txt: -------------------------------------------------------------------------------- 1 | # Ignore standard library headers. 2 | src:*/include/c\+\+/* 3 | 4 | # Ignore boost libraries headers. 5 | src:*/include/boost/* 6 | 7 | # Ignore Crypto++ library. We plan to remove it in the future. It exploits interger overflow and uses memcpy incorrectly. 8 | src:*/include/cryptopp/* 9 | -------------------------------------------------------------------------------- /scripts/aleth.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import subprocess 5 | import sys 6 | import os 7 | 8 | from dopple import run_daemon, DEFAULT_PROXY_URL, DEFAULT_BACKEND_PATH 9 | 10 | DEFAULT_ALETH_EXEC = '/usr/bin/aleth' 11 | 12 | parser = argparse.ArgumentParser(add_help=False) 13 | parser.add_argument('--aleth-exec', default=DEFAULT_ALETH_EXEC) 14 | parser.add_argument('--rpc', metavar='URL', nargs='?', const=DEFAULT_PROXY_URL, default=False) 15 | parser.add_argument('-d', '--db-path', help=argparse.SUPPRESS) 16 | parser.add_argument('--ipcpath', help=argparse.SUPPRESS) 17 | parser.add_argument('--no-ipc', action='store_true', help=argparse.SUPPRESS) 18 | wrapper_args, aleth_args = parser.parse_known_args() 19 | aleth_exec = wrapper_args.aleth_exec 20 | 21 | if not os.path.isfile(aleth_exec): 22 | print("Wrong path to aleth executable: {}".format(aleth_exec), file=sys.stderr) 23 | parser.print_usage(sys.stderr) 24 | exit(1) 25 | 26 | ipcpath = DEFAULT_BACKEND_PATH 27 | 28 | if wrapper_args.db_path: 29 | ipcpath = os.path.join(wrapper_args.db_path, 'geth.ipc') 30 | aleth_args += ['--db-path', wrapper_args.db_path] 31 | 32 | if wrapper_args.ipcpath: 33 | ipcpath = os.path.join(wrapper_args.ipcpath, 'geth.ipc') 34 | aleth_args += ['--ipcpath', wrapper_args.ipcpath] 35 | 36 | if wrapper_args.no_ipc: 37 | if wrapper_args.rpc: 38 | print("Option --no-ipc cannot be used with --rpc", file=sys.stderr) 39 | exit(2) 40 | else: 41 | aleth_args += ['--no-ipc'] 42 | 43 | try: 44 | if wrapper_args.rpc: 45 | run_daemon(wrapper_args.rpc, ipcpath) 46 | p = subprocess.run([aleth_exec] + aleth_args) 47 | exit(p.returncode) 48 | except KeyboardInterrupt: 49 | pass 50 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #------------------------------------------------------------------------------ 4 | # Bash script to build cpp-ethereum within TravisCI. 5 | # 6 | # The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org 7 | # 8 | # ------------------------------------------------------------------------------ 9 | # Aleth: Ethereum C++ client, tools and libraries. 10 | # Copyright 2019 Aleth Authors. 11 | # Licensed under the GNU General Public License, Version 3. 12 | #------------------------------------------------------------------------------ 13 | 14 | set -e -x 15 | 16 | # There is an implicit assumption here that we HAVE to run from repo root 17 | 18 | mkdir -p build 19 | cd build 20 | if [ $(uname -s) == "Linux" ]; then 21 | # Disabling while llvm-3.9 package is broken 22 | # cmake .. -DCMAKE_BUILD_TYPE=$1 -DCOVERAGE=ON -DEVMJIT=ON -DLLVM_DIR=/usr/lib/llvm-3.9/lib/cmake/llvm 23 | cmake .. -DCMAKE_BUILD_TYPE=$1 -DCOVERAGE=ON 24 | else 25 | cmake .. -DCMAKE_BUILD_TYPE=$1 -DCOVERAGE=ON 26 | fi 27 | 28 | make -j2 29 | -------------------------------------------------------------------------------- /scripts/cleanup_ccache.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | ccache --cleanup 6 | ccache --show-stats 7 | -------------------------------------------------------------------------------- /scripts/docker-eth: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | mkdir -p ~/.ethereum ~/.web3 3 | 4 | # check if sudo is necessary 5 | if ! id -nG $(whoami)|grep -qw "docker"; then SUDO='sudo'; else SUDO=''; fi 6 | 7 | $SUDO docker run --rm -it \ 8 | -p 127.0.0.1:8545:8545 \ 9 | -p 0.0.0.0:30303:30303 \ 10 | -v ~/.ethereum:/.ethereum \ 11 | -v ~/.web3:/.web3 \ 12 | -e HOME=/ \ 13 | --user $(id -u):$(id -g) \ 14 | ethereum/client-cpp $@ 15 | 16 | -------------------------------------------------------------------------------- /scripts/docker/aleth.dockerfile: -------------------------------------------------------------------------------- 1 | # Multistage Dockerfile for the Aleth tools. 2 | # It depends on sources being available in the docker context, 3 | # so build it from the project root dir as 4 | # docker build -f scripts/docker/aleth.dockerfile . 5 | 6 | 7 | # Build stage 8 | 9 | FROM alpine:latest AS builder 10 | RUN apk add --no-cache \ 11 | linux-headers \ 12 | g++ \ 13 | cmake \ 14 | make \ 15 | git 16 | COPY . /source 17 | WORKDIR /build 18 | RUN cmake /source -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DHUNTER_JOBS_NUMBER=$(nproc) 19 | RUN make -j $(nproc) && make install 20 | 21 | # Target: testeth 22 | # This is not the last stage so build it as 23 | # docker build --target testeth -f scripts/docker/aleth.dockerfile . 24 | 25 | FROM alpine:latest AS testeth 26 | RUN adduser -D testeth 27 | RUN apk add --no-cache libstdc++ 28 | USER testeth 29 | COPY --from=builder /build/test/testeth /usr/bin/ 30 | ENTRYPOINT ["/usr/bin/testeth"] 31 | 32 | 33 | # Target: aleth 34 | 35 | FROM alpine:latest AS aleth 36 | RUN apk add --no-cache python3 libstdc++ 37 | RUN adduser -D aleth 38 | COPY --from=builder /usr/bin/aleth* /source/scripts/aleth.py /source/scripts/dopple.py /usr/bin/ 39 | COPY --from=builder /usr/share/aleth/ /usr/share/aleth/ 40 | USER aleth 41 | EXPOSE 8545 42 | ENTRYPOINT ["/usr/bin/aleth.py"] 43 | -------------------------------------------------------------------------------- /scripts/docker/eth-centos/Dockerfile: -------------------------------------------------------------------------------- 1 | # This Dockerfile script is a proof that Aleth can be built on CentOS. 2 | 3 | FROM centos:7 4 | 5 | RUN yum -q -y install git centos-release-scl 6 | RUN yum -q -y install devtoolset-7-gcc-c++ 7 | RUN git clone --recursive https://github.com/ethereum/aleth --single-branch --depth 100 8 | RUN /aleth/scripts/install_cmake.sh --prefix /usr 9 | 10 | RUN source scl_source enable devtoolset-7 && cd /tmp && cmake /aleth 11 | RUN cd /tmp && make -j8 && make install 12 | 13 | ENTRYPOINT ["/usr/local/bin/aleth"] 14 | -------------------------------------------------------------------------------- /scripts/docker/eth-debian/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | RUN apt-get -q update && \ 4 | apt-get -qy install \ 5 | git \ 6 | curl \ 7 | build-essential \ 8 | libboost-all-dev \ 9 | libgmp-dev \ 10 | libleveldb-dev && \ 11 | git clone --recursive https://github.com/ethereum/cpp-ethereum --branch build-on-linux --single-branch --depth 1 && \ 12 | cpp-ethereum/scripts/install_cmake.sh --prefix /tmp && \ 13 | cd /tmp && PATH=$PATH:/tmp/bin cmake /cpp-ethereum && \ 14 | PATH=$PATH:/tmp/bin cmake --build /tmp -- -j8 && \ 15 | cd /tmp && make install && \ 16 | apt-get purge git build-essential -qy && \ 17 | apt-get autoremove -qy && \ 18 | apt-get clean && \ 19 | rm /cpp-ethereum -rf && \ 20 | rm /tmp/* -rf 21 | 22 | ENTRYPOINT ["/usr/local/bin/eth"] 23 | -------------------------------------------------------------------------------- /scripts/docker/eth-fedora/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:25 2 | 3 | RUN dnf -qy install git cmake 4 | RUN git clone --recursive https://github.com/ethereum/cpp-ethereum --branch build-on-linux --single-branch --depth 2 5 | 6 | RUN cd /tmp && cmake /cpp-ethereum 7 | RUN cd /tmp && make -j8 && make install && ldconfig 8 | 9 | ENTRYPOINT ["/usr/local/bin/eth"] 10 | -------------------------------------------------------------------------------- /scripts/docker/eth-oraclelinux/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM oraclelinux:7.3 2 | 3 | RUN yum -q -y install git 4 | RUN git clone --recursive https://github.com/ethereum/cpp-ethereum --branch build-on-linux --single-branch --depth 2 5 | RUN yum -y install \ 6 | make \ 7 | gcc-c++ \ 8 | curl-devel \ 9 | gmp-devel 10 | 11 | RUN yum -y install epel-release 12 | RUN yum -y install leveldb-devel 13 | 14 | RUN /cpp-ethereum/scripts/install_cmake.sh --prefix /usr 15 | 16 | RUN cmake --version 17 | 18 | RUN cd /tmp && cmake /cpp-ethereum 19 | RUN cd /tmp && make -j8 && make install && ldconfig 20 | 21 | ENTRYPOINT ["/usr/local/bin/eth"] 22 | -------------------------------------------------------------------------------- /scripts/dopple.py: -------------------------------------------------------------------------------- 1 | dopple/dopple.py -------------------------------------------------------------------------------- /scripts/install_cmake.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # This script downloads the CMake binary and installs it in $PREFIX directory 4 | # (the cmake executable will be in $PREFIX/bin). By default $PREFIX is 5 | # ~/.local but can we changes with --prefix argument. 6 | 7 | # This is mostly suitable for CIs, not end users. 8 | 9 | set -e 10 | 11 | VERSION=3.12.4 12 | 13 | if [ "$1" = "--prefix" ]; then 14 | PREFIX="$2" 15 | else 16 | PREFIX=~/.local 17 | fi 18 | 19 | OS=$(uname -s) 20 | case $OS in 21 | Linux) SHA256=486edd6710b5250946b4b199406ccbf8f567ef0e23cfe38f7938b8c78a2ffa5f;; 22 | Darwin) SHA256=95d76c00ccb9ecb5cb51de137de00965c5e8d34b2cf71556cf8ba40577d1cff3;; 23 | esac 24 | 25 | 26 | BIN=$PREFIX/bin 27 | 28 | if test -f $BIN/cmake && ($BIN/cmake --version | grep -q "$VERSION"); then 29 | echo "CMake $VERSION already installed in $BIN" 30 | else 31 | FILE=cmake-$VERSION-$OS-x86_64.tar.gz 32 | URL=https://cmake.org/files/v3.12/$FILE 33 | ERROR=0 34 | TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz) 35 | echo "Downloading CMake ($URL)..." 36 | curl -s "$URL" > "$TMPFILE" 37 | 38 | if type -p sha256sum > /dev/null; then 39 | SHASUM="sha256sum" 40 | else 41 | SHASUM="shasum -a256" 42 | fi 43 | 44 | if ! ($SHASUM "$TMPFILE" | grep -q "$SHA256"); then 45 | echo "Checksum mismatch ($TMPFILE)" 46 | exit 1 47 | fi 48 | mkdir -p "$PREFIX" 49 | tar xzf "$TMPFILE" -C "$PREFIX" --strip 1 50 | rm $TMPFILE 51 | fi 52 | -------------------------------------------------------------------------------- /scripts/install_solc_lllc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # This script downloads the lllc/solc binaries and installs them in $PREFIX directory 4 | # (the solc/lllc executables will be in $PREFIX/bin). By default $PREFIX is 5 | # ~/.local but can we changes with --prefix argument. 6 | 7 | # This is mostly suitable for CIs, not end users. 8 | 9 | set -e 10 | 11 | VERSION=0.4.17 12 | 13 | if [ "$1" = "--prefix" ]; then 14 | PREFIX="$2" 15 | else 16 | PREFIX=~/.local 17 | fi 18 | 19 | SHA256=0f00df61c43215a82db7e9620d9bfaa964c63ff1f745ece62df89a7829ac9f7b 20 | 21 | 22 | BIN=$PREFIX/bin 23 | 24 | if test -f $BIN/lllc && ($BIN/lllc --version | grep -q "$VERSION"); then 25 | echo "CMake $VERSION already installed in $BIN" 26 | else 27 | URL=https://github.com/ethereum/solidity/releases/download/v$VERSION/solidity-ubuntu-trusty.zip 28 | ERROR=0 29 | TMPFILE=$(mktemp --tmpdir solidity-$VERSION-$OS.XXXXXXXX.zip) 30 | echo "Downloading lllc ($URL)..." 31 | curl -L -s "$URL" > "$TMPFILE" 32 | 33 | if type -p sha256sum > /dev/null; then 34 | SHASUM="sha256sum" 35 | else 36 | SHASUM="shasum -a256" 37 | fi 38 | 39 | if ! ($SHASUM "$TMPFILE" | grep -q "$SHA256"); then 40 | echo "Checksum mismatch ($TMPFILE)" 41 | exit 1 42 | fi 43 | mkdir -p "$PREFIX" 44 | unzip $TMPFILE -d $BIN 45 | rm -rf $TMPFILE 46 | fi 47 | -------------------------------------------------------------------------------- /scripts/sync_files_with_solidity.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | files=( 4 | cmake/EthCcache.cmake 5 | cmake/EthCheckCXXCompilerFlag.cmake 6 | cmake/EthCompilerSettings.cmake 7 | ) 8 | 9 | project_root=$(readlink -f "$(dirname $0)/..") 10 | solidity_root=$(readlink -f "$project_root/../solidity") 11 | 12 | echo "project_root: $project_root" 13 | echo "solidity_root: $solidity_root" 14 | 15 | for file in "${files[@]}"; do 16 | here_timestamp=$(cd "$project_root" && git log -1 --format="%at" -- "$file") 17 | there_timestamp=$(cd "$solidity_root" && git log -1 --format="%at" -- "$file") 18 | 19 | if [ "$there_timestamp" ] && [ "$there_timestamp" -gt "$here_timestamp" ]; then 20 | echo "$solidity_root/$file -> $project_root/$file" 21 | cp "$solidity_root/$file" "$project_root/$file" 22 | elif [ "$here_timestamp" ]; then 23 | echo "$project_root/$file -> $solidity_root/$file" 24 | cp "$project_root/$file" "$solidity_root/$file" 25 | fi 26 | done 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /scripts/tests.bat: -------------------------------------------------------------------------------- 1 | 2 | REM --------------------------------------------------------------------------- 3 | REM Batch file for running the unit-tests for cpp-ethereum for Windows. 4 | REM 5 | REM The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org 6 | REM 7 | REM --------------------------------------------------------------------------- 8 | REM Aleth: Ethereum C++ client, tools and libraries. 9 | REM Copyright 2019 Aleth Authors. 10 | REM Licensed under the GNU General Public License, Version 3. 11 | REM --------------------------------------------------------------------------- 12 | 13 | set TESTS=%1 14 | set CONFIGURATION=%2 15 | set APPVEYOR_BUILD_FOLDER=%cd% 16 | set ETHEREUM_DEPS_PATH=%4 17 | 18 | if "%TESTS%"=="On" ( 19 | 20 | REM Copy the DLLs into the test directory which need to be able to run. 21 | cd %APPVEYOR_BUILD_FOLDER%\build\test\%CONFIGURATION% 22 | copy "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT\msvc*.dll" . 23 | 24 | REM Run the tests for the Interpreter 25 | echo Testing testeth 26 | testeth.exe -- --testpath %APPVEYOR_BUILD_FOLDER%\test\jsontests 27 | IF errorlevel 1 GOTO ON-ERROR-CONDITION 28 | 29 | REM Run the tests for the JIT 30 | REM echo Testing EVMJIT 31 | REM testeth.exe -t VMTests,StateTests -- --vm jit --testpath %APPVEYOR_BUILD_FOLDER%\test\jsontests 32 | REM IF errorlevel 1 GOTO ON-ERROR-CONDITION 33 | 34 | cd ..\..\.. 35 | 36 | ) 37 | 38 | EXIT 0 39 | 40 | :ON-ERROR-CONDITION 41 | echo "ERROR - Unit-test run returned error code." 42 | EXIT 1 43 | -------------------------------------------------------------------------------- /scripts/upload-homebrew-formula.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # author: Lefteris Karapetsas 3 | # 4 | # Just upload the generated .rb file to homebrew ethereum 5 | 6 | echo ">>> Starting the script to upload .rb file to homebrew ethereum" 7 | rm -rf homebrew-ethereum 8 | git clone git@github.com:ethereum/homebrew-ethereum.git 9 | cp webthree-umbrella/build/cpp-ethereum.rb homebrew-ethereum 10 | cd homebrew-ethereum 11 | git add . -u 12 | git commit -m "update cpp-ethereum.rb" 13 | git push origin 14 | cd .. 15 | rm -rf homebrew-ethereum 16 | echo ">>> Succesfully uploaded the .rb file to homebrew ethereum" 17 | -------------------------------------------------------------------------------- /snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: cpp-ethereum 2 | version: master 3 | summary: blockchain app platform 4 | description: Ethereum C++ project 5 | 6 | grade: devel 7 | confinement: devmode 8 | 9 | apps: 10 | eth: 11 | command: eth 12 | ethvm: 13 | command: ethvm 14 | 15 | parts: 16 | cpp-ethereum: 17 | source: . 18 | source-type: git 19 | plugin: cmake 20 | build-packages: 21 | - build-essential 22 | - libgmp-dev 23 | -------------------------------------------------------------------------------- /test/tools/fuzzTesting/fuzzHelper.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | #include 7 | #include 8 | 9 | //Test Templates 10 | extern std::string const c_testExampleStateTest; 11 | extern std::string const c_testExampleTransactionTest; 12 | extern std::string const c_testExampleVMTest; 13 | extern std::string const c_testExampleBlockchainTest; 14 | extern std::string const c_testExampleRLPTest; 15 | 16 | namespace dev 17 | { 18 | namespace test 19 | { 20 | 21 | struct RlpDebug 22 | { 23 | std::string rlp; 24 | int insertions; 25 | }; 26 | 27 | class RandomCode 28 | { 29 | public: 30 | static BoostRandomCode& get() 31 | { 32 | static RandomCode instance; 33 | return instance.generator; 34 | } 35 | RandomCode(RandomCode const&) = delete; 36 | void operator=(RandomCode const&) = delete; 37 | 38 | private: 39 | RandomCode() = default; 40 | BoostRandomCode generator; 41 | }; 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/tools/jsontests/StateTests.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | #include 7 | #include 8 | #include 9 | 10 | namespace dev 11 | { 12 | namespace test 13 | { 14 | 15 | class StateTestSuite: public TestSuite 16 | { 17 | public: 18 | json_spirit::mValue doTests(json_spirit::mValue const& _input, bool _fillin) const override; 19 | boost::filesystem::path suiteFolder() const override; 20 | boost::filesystem::path suiteFillerFolder() const override; 21 | }; 22 | 23 | 24 | class GeneralTestFixture : public StateTestFixtureBase 25 | { 26 | public: 27 | GeneralTestFixture() : StateTestFixtureBase({}) {} 28 | }; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/tools/jsontests/TransactionTests.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | /// @file 6 | /// Transaction test functions. 7 | #pragma once 8 | #include 9 | #include 10 | 11 | namespace dev 12 | { 13 | namespace test 14 | { 15 | 16 | class TransactionTestSuite: public TestSuite 17 | { 18 | json_spirit::mValue doTests(json_spirit::mValue const& _input, bool _fillin) const override; 19 | boost::filesystem::path suiteFolder() const override; 20 | boost::filesystem::path suiteFillerFolder() const override; 21 | }; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/tools/libtesteth/AllTestNames.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | std::vector const c_allTestNames 6 | { 7 | @allTests@ 8 | }; 9 | -------------------------------------------------------------------------------- /test/tools/libtesteth/JsonSpiritHeaders.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2013-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | #pragma once 5 | 6 | #pragma warning(push) 7 | #pragma warning(disable: 4100) 8 | #pragma GCC diagnostic push 9 | #pragma GCC diagnostic ignored "-Wconversion" 10 | #pragma GCC diagnostic ignored "-Wunused-parameter" 11 | #include 12 | #include 13 | #pragma GCC diagnostic pop 14 | #pragma warning(pop) 15 | 16 | -------------------------------------------------------------------------------- /test/tools/libtesteth/Stats.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2013-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #include "TestHelper.h" 11 | 12 | namespace dev 13 | { 14 | namespace test 15 | { 16 | 17 | class Stats: public Listener 18 | { 19 | public: 20 | using clock = std::chrono::high_resolution_clock; 21 | 22 | struct Item 23 | { 24 | clock::duration duration; 25 | int64_t gasUsed; 26 | std::string name; 27 | }; 28 | 29 | static Stats& get(); 30 | 31 | ~Stats() final; 32 | 33 | void suiteStarted(std::string const& _name) override; 34 | void testStarted(std::string const& _name) override; 35 | void testFinished(int64_t _gasUsed) override; 36 | 37 | private: 38 | clock::time_point m_tp; 39 | std::string m_currentSuite; 40 | std::string m_currentTest; 41 | std::vector m_stats; 42 | }; 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/tools/libtesteth/wast2wasm.cpp: -------------------------------------------------------------------------------- 1 | #include "wast2wasm.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | // Disable MSVC warning "unary minus operator applied to unsigned type". 8 | #pragma warning(push) 9 | #pragma warning(disable: 4146) 10 | #include 11 | #include 12 | #include 13 | #pragma warning(pop) 14 | 15 | using namespace std; 16 | 17 | namespace dev 18 | { 19 | 20 | namespace test 21 | { 22 | 23 | /* from https://github.com/ewasm/evm2wasm */ 24 | string wast2wasm(string const& input, bool debug) 25 | { 26 | wasm::Module module; 27 | 28 | try { 29 | // FIXME: binaryen 1.37.28 actually modifies the input... 30 | // as a workaround make a copy here 31 | string tmp = input; 32 | wasm::SExpressionParser parser(const_cast(tmp.c_str())); 33 | wasm::Element& root = *parser.root; 34 | wasm::SExpressionWasmBuilder builder(module, *root[0]); 35 | } catch (wasm::ParseException& p) { 36 | ostringstream err; 37 | p.dump(err); 38 | BOOST_ERROR("Error parsing wasm: " + err.str()); 39 | } 40 | 41 | BOOST_REQUIRE_MESSAGE(wasm::WasmValidator().validate(module), "Compiled WASM module is not valid."); 42 | 43 | wasm::BufferWithRandomAccess buffer(debug); 44 | wasm::WasmBinaryWriter writer(&module, buffer, debug); 45 | writer.setNamesSection(false); 46 | writer.write(); 47 | 48 | ostringstream output; 49 | buffer.writeTo(output); 50 | 51 | return toHexPrefixed(output.str()); 52 | } 53 | 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /test/tools/libtesteth/wast2wasm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dev 6 | { 7 | 8 | namespace test 9 | { 10 | 11 | std::string wast2wasm(std::string const& input, bool debug = false); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/tools/libtestutils/BlockChainLoader.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include 6 | #include 7 | #include 8 | #include "BlockChainLoader.h" 9 | #include "Common.h" 10 | using namespace std; 11 | using namespace dev; 12 | using namespace dev::test; 13 | using namespace dev::eth; 14 | 15 | BlockChainLoader::BlockChainLoader(Json::Value const& _json, eth::Network _sealEngineNetwork): 16 | m_block(Block::Null) 17 | { 18 | // load genesisBlock 19 | Json::FastWriter a; 20 | bytes genesisBlock = fromHex(_json["genesisRLP"].asString()); 21 | ChainParams params( 22 | genesisInfo(_sealEngineNetwork), genesisBlock, jsonToAccountMap(a.write(_json["pre"]))); 23 | if (_json.isMember("sealEngine")) 24 | { 25 | if (_json["sealEngine"].asString() == eth::NoProof::name()) 26 | params.sealEngineName = eth::NoProof::name(); 27 | else if (_json["sealEngine"].asString() == eth::Ethash::name()) 28 | params.sealEngineName = eth::Ethash::name(); 29 | } 30 | m_bc.reset(new BlockChain(params, m_dir.path(), WithExisting::Kill)); 31 | 32 | // load pre state 33 | m_block = m_bc->genesisBlock(State::openDB(m_dir.path(), m_bc->genesisHash(), WithExisting::Kill)); 34 | 35 | assert(m_block.rootHash() == m_bc->info().stateRoot()); 36 | 37 | // load blocks 38 | for (auto const& block: _json["blocks"]) 39 | { 40 | bytes rlp = fromHex(block["rlp"].asString()); 41 | m_bc->import(rlp, state().db()); 42 | } 43 | 44 | // sync state 45 | m_block.sync(*m_bc); 46 | } 47 | -------------------------------------------------------------------------------- /test/tools/libtestutils/BlockChainLoader.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace dev 13 | { 14 | namespace test 15 | { 16 | 17 | /** 18 | * @brief Should be used to load test blockchain from json file 19 | * Loads the blockchain from json, creates temporary directory to store it, removes the directory on dealloc 20 | */ 21 | class BlockChainLoader 22 | { 23 | public: 24 | explicit BlockChainLoader(Json::Value const& _json, eth::Network _sealEngineNetwork = eth::Network::TransitionnetTest); 25 | eth::BlockChain const& bc() const { return *m_bc; } 26 | eth::State const& state() const { return m_block.state(); } // TODO remove? 27 | eth::Block const& block() const { return m_block; } 28 | 29 | private: 30 | TransientDirectory m_dir; 31 | std::unique_ptr m_bc; 32 | eth::Block m_block; 33 | }; 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/tools/libtestutils/Common.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace dev 14 | { 15 | namespace test 16 | { 17 | 18 | boost::filesystem::path getTestPath(); 19 | int randomNumber(int _min = 1, int _max = INT_MAX); 20 | unsigned short randomPortNumber(unsigned short _min = 1024, unsigned short _max = USHRT_MAX); 21 | Json::Value loadJsonFromFile(boost::filesystem::path const& _path); 22 | boost::filesystem::path toTestFilePath(std::string const& _filename); 23 | boost::filesystem::path getRandomPath(); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/tools/libtestutils/FixedClient.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include "FixedClient.h" 6 | 7 | using namespace dev; 8 | using namespace dev::eth; 9 | using namespace dev::test; 10 | 11 | Block FixedClient::block(h256 const& _h) const 12 | { 13 | ReadGuard l(x_stateDB); 14 | Block ret(bc(), m_block.db()); 15 | ret.populateFromChain(bc(), _h); 16 | return ret; 17 | } 18 | -------------------------------------------------------------------------------- /test/tools/libtestutils/TestLastBlockHashes.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | /** 5 | * Test implementation for LastBlockHahsesFace 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace dev 13 | { 14 | namespace test 15 | { 16 | 17 | class TestLastBlockHashes: public eth::LastBlockHashesFace 18 | { 19 | public: 20 | explicit TestLastBlockHashes(h256s const& _hashes): m_hashes(_hashes) {} 21 | 22 | h256s precedingHashes(h256 const& /* _mostRecentHash */) const override { return m_hashes; } 23 | void clear() override {} 24 | 25 | private: 26 | h256s const m_hashes; 27 | }; 28 | 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /test/unittests/libdevcrypto/MemTrie.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2013-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace dev 11 | { 12 | 13 | class MemTrieNode; 14 | 15 | /** 16 | * @brief Merkle Patricia Tree "Trie": a modifed base-16 Radix tree. 17 | */ 18 | class MemTrie 19 | { 20 | public: 21 | MemTrie(): m_root(nullptr) {} 22 | ~MemTrie(); 23 | 24 | h256 hash256() const; 25 | bytes rlp() const; 26 | 27 | void debugPrint(); 28 | 29 | std::string const& at(std::string const& _key) const; 30 | void insert(std::string const& _key, std::string const& _value); 31 | void remove(std::string const& _key); 32 | 33 | private: 34 | MemTrieNode* m_root; 35 | }; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /test/unittests/libethcore/BlockHeader.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2018-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include 6 | 7 | #include 8 | 9 | using namespace dev::eth; 10 | 11 | TEST(BlockHeader, isValid) 12 | { 13 | BlockHeader header; 14 | EXPECT_FALSE(header); 15 | header.setTimestamp(0); 16 | EXPECT_TRUE(header); 17 | header.setTimestamp(-2); 18 | EXPECT_FALSE(header); 19 | } 20 | -------------------------------------------------------------------------------- /test/unittests/libethcore/CommonJS.cpp: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2015-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #include 6 | 7 | #include 8 | 9 | using namespace std; 10 | using namespace dev; 11 | using namespace dev::eth; 12 | 13 | TEST(CommonJS, jsToPublic) 14 | { 15 | KeyPair kp = KeyPair::create(); 16 | string s = toJS(kp.pub()); 17 | Public pub = dev::jsToPublic(s); 18 | EXPECT_EQ(kp.pub(), pub); 19 | } 20 | 21 | TEST(CommonJS, jsToAddress) 22 | { 23 | KeyPair kp = KeyPair::create(); 24 | string s = toJS(kp.address()); 25 | Address address = dev::jsToAddress(s); 26 | EXPECT_EQ(kp.address(), address); 27 | } 28 | 29 | TEST(CommonJS, jsToSecret) 30 | { 31 | KeyPair kp = KeyPair::create(); 32 | string s = toJS(kp.secret().makeInsecure()); 33 | Secret secret = dev::jsToSecret(s); 34 | EXPECT_EQ(kp.secret().makeInsecure(), secret.makeInsecure()); 35 | } 36 | -------------------------------------------------------------------------------- /test/unittests/performance/add128.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0xffffffffffffffff 6 | 0xf5470b43c6549b016288e9a65629687 7 | 0xffffffffffffffff 8 | 9 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 10 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 11 | pop 12 | dup2 13 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 14 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 15 | pop 16 | dup2 17 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 18 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 19 | pop 20 | dup2 21 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 22 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 23 | pop 24 | dup2 25 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 26 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 27 | pop 28 | dup2 29 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 30 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 31 | pop 32 | dup2 33 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 34 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 35 | pop 36 | dup2 37 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 38 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0xf5470b43c6549b026288e9a65629686f { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/unittests/performance/add64.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0xffffffff 6 | 0xfd37f3e2bba2c4f 7 | 0xffffffff 8 | 9 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 10 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 11 | pop 12 | dup2 13 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 14 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 15 | pop 16 | dup2 17 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 18 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 19 | pop 20 | dup2 21 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 22 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 23 | pop 24 | dup2 25 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 26 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 27 | pop 28 | dup2 29 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 30 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 31 | pop 32 | dup2 33 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 34 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 35 | pop 36 | dup2 37 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 38 | dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add dup2 add 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0xfd37f3e3bba2c4ef { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } -------------------------------------------------------------------------------- /test/unittests/performance/bop.sol: -------------------------------------------------------------------------------- 1 | // do not optimize 2 | pragma solidity ^0.4.0; 3 | 4 | contract bop { 5 | function bop() { 6 | uint r; 7 | assembly { 8 | 2 9 | 1 10 | dup2 11 | pop 12 | pop 13 | =: r 14 | } 15 | if (r != 2) 16 | throw; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/unittests/performance/csv2gas.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | 4 | clients = [] 5 | seconds = [] 6 | tests = [] 7 | data = {} 8 | 9 | # read in csv file 10 | for line in sys.stdin: 11 | 12 | # read the header 13 | if not clients: 14 | clients = [word for word in line.rstrip().split(', ')] 15 | clients.pop(0) 16 | continue 17 | 18 | # read the data 19 | seconds = [second for second in line.rstrip().split(', ')] 20 | test = seconds.pop(0) 21 | if test not in tests: 22 | tests += [test] 23 | if test not in data: 24 | data[test] = {} 25 | for i, second in enumerate (seconds): 26 | data[test][clients[i]] = second 27 | 28 | # print extended header 29 | sys.stdout.write("(ns/gas)") 30 | for client in clients: 31 | if client == 'gas': 32 | continue 33 | sys.stdout.write(", " + client) 34 | sys.stdout.write("\n") 35 | 36 | # nanos = ns/gas is run time scaled by amount of gas 37 | # print the test, gas, nanos ... 38 | for test in tests: 39 | sys.stdout.write(test) 40 | gas_per_run = float(data[test]['gas']) 41 | for client in clients: 42 | if client == 'gas': 43 | continue 44 | run_nanos = float(data[test][client])*10**9 45 | nanos_per_gas = int(run_nanos/gas_per_run + .5) 46 | sys.stdout.write(", %d" % nanos_per_gas) 47 | sys.stdout.write("\n") 48 | -------------------------------------------------------------------------------- /test/unittests/performance/csv2nano.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | 4 | clients = [] 5 | seconds = [] 6 | tests = [] 7 | data = {} 8 | 9 | # read in csv file 10 | for line in sys.stdin: 11 | 12 | # read the header 13 | if not clients: 14 | clients = [word for word in line.rstrip().split(', ')] 15 | units = clients.pop(0) 16 | continue 17 | 18 | # read the data 19 | seconds = [second for second in line.rstrip().split(', ')] 20 | test = seconds.pop(0) 21 | if test not in tests: 22 | tests += [test] 23 | if test not in data: 24 | data[test] = {} 25 | for i, second in enumerate (seconds): 26 | client = clients[i] 27 | data[test][client] = second 28 | 29 | # print extended header 30 | sys.stdout.write("(ns/test)") 31 | for client in clients: 32 | sys.stdout.write(", " + client) 33 | sys.stdout.write("\n") 34 | 35 | # ns/test is run time scaled by number of operations 36 | # print the test, gas, nanos, ... 37 | N_ops = 2**27 38 | N_app = 2**20 39 | N = 0 40 | for test in tests: 41 | sys.stdout.write(test) 42 | if test in ['nop', 'pop', 'add64', 'add128', 'add256', 'sub64', 'sub128', 'sub256', 43 | 'mul64', 'mul128', 'mul256', 'div64', 'div128', 'div256']: 44 | N = N_ops 45 | else: 46 | N = N_app 47 | for client in clients: 48 | if client == 'gas': 49 | gas_per_test = int(float(data[test][client])/N + .5) 50 | sys.stdout.write(", %d" % gas_per_test) 51 | continue 52 | nanos_per_test = int(float(data[test][client])*10**9/N + .5) 53 | sys.stdout.write(", %d" % nanos_per_test) 54 | sys.stdout.write("\n") 55 | -------------------------------------------------------------------------------- /test/unittests/performance/csv2ops.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | 4 | clients = [] 5 | seconds = [] 6 | tests = [] 7 | data = {} 8 | 9 | # read in csv file 10 | for line in sys.stdin: 11 | 12 | # read the header 13 | if not clients: 14 | clients = [word for word in line.rstrip().split(', ')] 15 | units = clients.pop(0) 16 | continue 17 | 18 | # read the data 19 | seconds = [second for second in line.rstrip().split(', ')] 20 | test = seconds.pop(0) 21 | if test not in ['nop', 'pop', 'add64', 'add128', 'add256', 'sub64', 'sub128', 'sub256', 22 | 'mul64', 'mul128', 'mul256', 'div64', 'div128', 'div256']: 23 | continue 24 | if test not in tests: 25 | tests += [test] 26 | if test not in data: 27 | data[test] = {} 28 | for i, second in enumerate (seconds): 29 | client = clients[i] 30 | data[test][client] = second 31 | 32 | # print header 33 | sys.stdout.write("(ns/OP)") 34 | for client in clients: 35 | if client == 'gas': 36 | continue 37 | sys.stdout.write(", " + client) 38 | sys.stdout.write("\n") 39 | 40 | # ns/op is run time scaled by number of operations and offset by estimated overhead 41 | # print the test, gas, nanos, ... 42 | N = 2**27 43 | for test in tests: 44 | if test in ['nop', 'pop']: 45 | continue 46 | sys.stdout.write(test) 47 | for client in clients: 48 | if client == 'gas': 49 | continue 50 | nanos_per_test = int(float(data[test][client])*10**9/N + .5) 51 | nanos_per_nop = int(float(data['nop'][client])*10**9/N + .5) 52 | nanos_per_pop = int(float(data['pop'][client])*10**9/N + .5) 53 | nanos_per_test -= (nanos_per_nop + nanos_per_pop)/2 54 | sys.stdout.write(", %d" % nanos_per_test) 55 | sys.stdout.write("\n") 56 | -------------------------------------------------------------------------------- /test/unittests/performance/div128.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0xfdedc7f10142ff97 6 | 0xfbdfda0e2ce356173d1993d5f70a2b11 7 | 0xfdedc7f10142ff97 8 | 9 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 10 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 11 | pop 12 | dup2 13 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 14 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 15 | pop 16 | dup2 17 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 18 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 19 | pop 20 | dup2 21 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 22 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 23 | pop 24 | dup2 25 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 26 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 27 | pop 28 | dup2 29 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 30 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 31 | pop 32 | dup2 33 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 34 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 35 | pop 36 | dup2 37 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 38 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0xfdedc7f10142ff97 { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /test/unittests/performance/div64.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0xfcb34eb3 6 | 0xf97180878e839129 7 | 0xfcb34eb3 8 | 9 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 10 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 11 | pop 12 | dup2 13 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 14 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 15 | pop 16 | dup2 17 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 18 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 19 | pop 20 | dup2 21 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 22 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 23 | pop 24 | dup2 25 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 26 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 27 | pop 28 | dup2 29 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 30 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 31 | pop 32 | dup2 33 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 34 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 35 | pop 36 | dup2 37 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 38 | dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div dup2 div 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0xfcb34eb3 { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/unittests/performance/fun.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | 3 | contract base { 4 | 5 | function nada(uint u) internal returns (uint) { 6 | return u; 7 | } 8 | } 9 | 10 | contract derived is base { 11 | function nada(uint u) internal returns (uint) { 12 | return base.nada(base.nada(u)); 13 | } 14 | } 15 | 16 | contract fun is derived { 17 | 18 | function useless(uint u) returns (uint) { 19 | return nada(nada(u)); 20 | } 21 | 22 | function test() { 23 | uint u = 8; 24 | for (int i = 0; i < 1048576; ++i) 25 | u = useless(useless(u)); 26 | assert(u == 8); 27 | } 28 | 29 | function fun() { 30 | test(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/unittests/performance/log2csv.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | 4 | # regex for the lines with relevant data 5 | test_line = 'time -p ([-_./A-Za-z0-9]*/)*([-_A-Za-z0-9]+) .*; touch (.+).ran$' 6 | gas_line = 'as used: ([0-9]+)' 7 | secs_line = 'user ([0-9.]+)' 8 | 9 | # read in data 10 | path = '' 11 | client = '' 12 | test = '' 13 | clients = [] 14 | tests = [] 15 | gas = {} 16 | data = {} 17 | for line in sys.stdin: 18 | match = re.search(test_line, line) 19 | if match: 20 | path = match.group(1) 21 | client = match.group(2) 22 | test = match.group(3) 23 | if client not in clients: 24 | clients += [client] 25 | if test not in tests: 26 | tests += [test] 27 | continue 28 | match = re.search(gas_line, line) 29 | if match: 30 | gas[test] = match.group(1) 31 | continue 32 | match = re.search(secs_line, line) 33 | if match: 34 | if test not in data: 35 | data[test] = {} 36 | data[test][client] = match.group(1) 37 | continue 38 | 39 | # print the header 40 | sys.stdout.write("(sec/run)") 41 | if len(gas): 42 | sys.stdout.write(", gas") 43 | for client in clients: 44 | sys.stdout.write(", %s" % client) 45 | sys.stdout.write("\n") 46 | 47 | # print the test, gas, secs, secs, ... 48 | for test in tests: 49 | sys.stdout.write("%s" % test) 50 | if gas[test]: 51 | sys.stdout.write(", %s" % gas[test]) 52 | for client in clients: 53 | sys.stdout.write(", %s" % data[test][client]) 54 | sys.stdout.write("\n") 55 | -------------------------------------------------------------------------------- /test/unittests/performance/loop.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | 3 | contract loop { 4 | int N; 5 | function loop(){ 6 | for (int i = 0; i < 1048576; ++i) { 7 | } 8 | N = i; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/unittests/performance/mul128.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0xb5 6 | 0xb5 7 | 0xb5 8 | 9 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 10 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 11 | pop 12 | dup2 13 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 14 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 15 | pop 16 | dup2 17 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 18 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 19 | pop 20 | dup2 21 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 22 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 23 | pop 24 | dup2 25 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 26 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 27 | pop 28 | dup2 29 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 30 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 31 | pop 32 | dup2 33 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 34 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 35 | pop 36 | dup2 37 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 38 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0xb4b0df2687b7c1a6fb5d5b1943a57675 { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /test/unittests/performance/mul64.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0xd 6 | 0xd 7 | 0xd 8 | 9 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 10 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 11 | pop 12 | dup2 13 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 14 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 15 | pop 16 | dup2 17 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 18 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 19 | pop 20 | dup2 21 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 22 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 23 | pop 24 | dup2 25 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 26 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 27 | pop 28 | dup2 29 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 30 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 31 | pop 32 | dup2 33 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 34 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 35 | pop 36 | dup2 37 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 38 | dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul dup2 mul 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0x780c7372621bd74d { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /test/unittests/performance/mul64c.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | uint64_t r; 5 | for (uint64_t i = 0; i < 1048576; ++i) { 6 | uint64_t z = 0xd; 7 | uint64_t y = 0xd; 8 | uint64_t x = 0xd; 9 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 10 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 11 | x = z; 12 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 13 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 14 | x = z; 15 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 16 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 17 | x = z; 18 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 19 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 20 | x = z; 21 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 22 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 23 | x = z; 24 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 25 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 26 | x = z; 27 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 28 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 29 | x = z; 30 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 31 | x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; x *= y; 32 | r = x; 33 | } 34 | printf(r == 0x780c7372621bd74d ? "success\n\n" : "failure\n"); 35 | } 36 | -------------------------------------------------------------------------------- /test/unittests/performance/pop.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 1 6 | 2 7 | 1 8 | 9 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 10 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 11 | pop 12 | dup2 13 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 14 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 15 | pop 16 | dup2 17 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 18 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 19 | pop 20 | dup2 21 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 22 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 23 | pop 24 | dup2 25 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 26 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 27 | pop 28 | dup2 29 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 30 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 31 | pop 32 | dup2 33 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 34 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 35 | pop 36 | dup2 37 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 38 | dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop dup2 pop 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 1 { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/unittests/performance/popcpyc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | struct link { 5 | struct link* next; 6 | long long slot[8]; 7 | } stack[2], *sp; 8 | for (uint64_t i = 0; i < 8388608; ++i) { 9 | stack[0] = stack[1]; sp = stack + 1; 10 | stack[0] = stack[1]; sp = stack + 1; 11 | stack[0] = stack[1]; sp = stack + 1; 12 | stack[0] = stack[1]; sp = stack + 1; 13 | stack[0] = stack[1]; sp = stack + 1; 14 | stack[0] = stack[1]; sp = stack + 1; 15 | stack[0] = stack[1]; sp = stack + 1; 16 | stack[0] = stack[1]; sp = stack + 1; 17 | stack[0] = stack[1]; sp = stack + 1; 18 | stack[0] = stack[1]; sp = stack + 1; 19 | stack[0] = stack[1]; sp = stack + 1; 20 | stack[0] = stack[1]; sp = stack + 1; 21 | stack[0] = stack[1]; sp = stack + 1; 22 | stack[0] = stack[1]; sp = stack + 1; 23 | stack[0] = stack[1]; sp = stack + 1; 24 | stack[0] = stack[1]; sp = stack + 1; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/unittests/performance/popincc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | uint64_t r; 5 | for (uint64_t i = 0; i < 1048576; ++i) { 6 | uint64_t z = 0; 7 | uint64_t y = 64; 8 | uint64_t x = 0; 9 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 10 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 11 | x = z; 12 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 13 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 14 | x = z; 15 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 16 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 17 | x = z; 18 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 19 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 20 | x = z; 21 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 22 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 23 | x = z; 24 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 25 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 26 | x = z; 27 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 28 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 29 | x = z; 30 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 31 | x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; 32 | r = x; 33 | } 34 | printf(r == 1024 ? "success\n" : "failure\n"); 35 | } 36 | -------------------------------------------------------------------------------- /test/unittests/performance/poplnkc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | struct link { 5 | struct link* next; 6 | long long slot[8]; 7 | } stack; 8 | struct link* sp = &stack; 9 | struct link* free = &stack; 10 | struct link* tmp = 0; 11 | stack.next = &stack; 12 | for (uint64_t i = 0; i < 8388608; ++i) { 13 | 14 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 15 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 16 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 17 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 18 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 19 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 20 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 21 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 22 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 23 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 24 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 25 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 26 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 27 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 28 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 29 | tmp = sp->next, sp->next = free, free = sp, sp = tmp; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/unittests/performance/rng.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | 3 | contract rng { 4 | 5 | // 2**20 tests 6 | function rng() { 7 | 8 | // magic seeds 9 | uint blum = 0x20fa78d1fb3d86d2b02d955ec04ed801 10 | * 0x2fc84408f87e831d280a05613124dc35; 11 | uint[5] memory shub = [uint(0xa96d80548950c6e1fd4299395ee381a3), 12 | 0xec36bfc9cfdfcbf201fd78ee4cdad4fb, 13 | 0xdba29b85a759fb10848f01256f2b5c39, 14 | 0xa9390182a3a79447c8394ae189edcfc1, 15 | 0xd66ec8a137fb01fae6b7a83c83d0adf9]; 16 | 17 | // 2**20 / 32 18 | for (uint i = 0; i < 32768; ++i) { 19 | uint[5] memory out = [uint256(0),0,0,0,0]; 20 | 21 | // need 32 bytes of output for each log argument 22 | for (uint j = 1; j< 32; ++j) { 23 | 24 | // harvest low order bytes of 5 Blum Blum Shubs for 5-word log output 25 | for (uint k = 0; k < 5; ++k) { 26 | uint sqr = shub[k]; 27 | sqr *= sqr; 28 | sqr %= blum; 29 | shub[k] = sqr; 30 | out[k] |= (sqr & 255) << j; 31 | } 32 | } 33 | // parity chokes log4(bytes32(out[0]), bytes32(out[1]), bytes32(out[2]), bytes32(out[3]), bytes32(out[4])); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/unittests/performance/sub64.asm: -------------------------------------------------------------------------------- 1 | { 2 | let r := 0 3 | for { let i := 0 } lt(i, 1048576) { i := add(i, 1) } { 4 | 5 | 0x51022b6317003a9d 6 | 0xa20456c62e00753a 7 | 0x51022b6317003a9d 8 | 9 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 10 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 11 | pop 12 | dup2 13 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 14 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 15 | pop 16 | dup2 17 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 18 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 19 | pop 20 | dup2 21 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 22 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 23 | pop 24 | dup2 25 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 26 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 27 | pop 28 | dup2 29 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 30 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 31 | pop 32 | dup2 33 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 34 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 35 | pop 36 | dup2 37 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 38 | dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub dup2 sub 39 | 40 | =: r 41 | pop 42 | pop 43 | } 44 | switch r 45 | case 0x51022b6317003a9d { 46 | stop 47 | } 48 | default { 49 | 0 50 | 0 51 | revert 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/unittests/performance/thrash.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | contract thrash { 3 | function thrash() { 4 | uint x = 3; 5 | while (true) x *= x; 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/unittests/performance/top.sol: -------------------------------------------------------------------------------- 1 | // do not optimize 2 | pragma solidity ^0.4.0; 3 | 4 | contract top { 5 | function top() { 6 | uint r; 7 | assembly { 8 | 0 9 | 2 10 | div 11 | =: r 12 | } 13 | if (r != 0) 14 | throw; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /utils/json_spirit/JsonSpiritHeaders.h: -------------------------------------------------------------------------------- 1 | // Aleth: Ethereum C++ client, tools and libraries. 2 | // Copyright 2014-2019 Aleth Authors. 3 | // Licensed under the GNU General Public License, Version 3. 4 | 5 | #pragma once 6 | 7 | #pragma warning(push) 8 | #pragma warning(disable: 4100) 9 | #pragma GCC diagnostic push 10 | #pragma GCC diagnostic ignored "-Wconversion" 11 | #pragma GCC diagnostic ignored "-Wunused-parameter" 12 | #include "../json_spirit/json_spirit_reader_template.h" 13 | #include "../json_spirit/json_spirit_writer_template.h" 14 | #pragma GCC diagnostic pop 15 | #pragma warning(pop) 16 | 17 | -------------------------------------------------------------------------------- /utils/json_spirit/json_spirit.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT 2 | #define JSON_SPIRIT 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_value.h" 14 | #include "json_spirit_reader.h" 15 | #include "json_spirit_writer.h" 16 | #include "json_spirit_utils.h" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /utils/json_spirit/json_spirit_error_position.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_ERROR_POSITION 2 | #define JSON_SPIRIT_ERROR_POSITION 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include 14 | 15 | namespace json_spirit 16 | { 17 | // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. 18 | // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" 19 | // functions that return a bool. 20 | // 21 | struct Error_position 22 | { 23 | Error_position(); 24 | Error_position( unsigned int line, unsigned int column, const std::string& reason ); 25 | bool operator==( const Error_position& lhs ) const; 26 | unsigned int line_; 27 | unsigned int column_; 28 | std::string reason_; 29 | }; 30 | 31 | inline Error_position::Error_position() 32 | : line_( 0 ) 33 | , column_( 0 ) 34 | { 35 | } 36 | 37 | inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) 38 | : line_( line ) 39 | , column_( column ) 40 | , reason_( reason ) 41 | { 42 | } 43 | 44 | inline bool Error_position::operator==( const Error_position& lhs ) const 45 | { 46 | if( this == &lhs ) return true; 47 | 48 | return ( reason_ == lhs.reason_ ) && 49 | ( line_ == lhs.line_ ) && 50 | ( column_ == lhs.column_ ); 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /utils/json_spirit/json_spirit_value.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 John W Wilkinson 2 | 3 | This source code can be used for any purpose as long as 4 | this comment is retained. */ 5 | 6 | // json spirit version 2.00 7 | 8 | #include "json_spirit_value.h" 9 | --------------------------------------------------------------------------------