├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeModules ├── FindGperftools.cmake ├── FindWasm.cmake ├── InstallDirectoryPermissions.cmake ├── cotire.cmake ├── installer.cmake └── wasm.cmake ├── Dockerfile ├── Doxyfile ├── HEADER ├── LICENSE.Graphene.txt ├── LICENSE.md ├── README.md ├── Vagrantfile ├── contracts ├── CMakeLists.txt ├── examples │ ├── transfer.cpp │ └── transferV2.cpp ├── graphenelib │ ├── CMakeLists.txt │ ├── action.h │ ├── action.hpp │ ├── asset.h │ ├── contract.hpp │ ├── contract_asset.hpp │ ├── crypto.h │ ├── datastream.hpp │ ├── db.h │ ├── dispatcher.hpp │ ├── fixed_key.hpp │ ├── global.h │ ├── graphene.hpp │ ├── graphenelib.cpp │ ├── memory.h │ ├── memory.hpp │ ├── multi_index.hpp │ ├── print.h │ ├── print.hpp │ ├── serialize.hpp │ ├── stdlib.hpp │ ├── symbol.hpp │ ├── system.h │ ├── types.h │ ├── types.hpp │ ├── varint.hpp │ └── vector.hpp ├── libc++ │ └── CMakeLists.txt ├── musl │ └── CMakeLists.txt └── skeleton │ ├── skeleton.cpp │ └── skeleton.hpp ├── docker ├── default_config.ini └── launch ├── externals └── CMakeLists.txt ├── genesis-testnet3.0.json ├── genesis.json ├── genesis_master.json ├── genesis_origin.json ├── genesis_testnet.json ├── gui_version ├── libraries ├── CMakeLists.txt ├── abi_generator │ ├── CMakeLists.txt │ ├── abi_generator.cpp │ └── include │ │ └── graphene │ │ └── abi_generator │ │ └── abi_generator.hpp ├── app │ ├── CMakeLists.txt │ ├── api.cpp │ ├── application.cpp │ ├── application_impl.hxx │ ├── config_util.cpp │ ├── database_api.cpp │ ├── include │ │ └── graphene │ │ │ └── app │ │ │ ├── api.hpp │ │ │ ├── api_access.hpp │ │ │ ├── application.hpp │ │ │ ├── config_util.hpp │ │ │ ├── database_api.hpp │ │ │ ├── full_account.hpp │ │ │ ├── plugin.hpp │ │ │ └── util.hpp │ ├── plugin.cpp │ └── util.cpp ├── builtins │ ├── CMakeLists.txt │ ├── README.txt │ ├── compiler_builtins.hpp │ ├── fixdfti.c │ ├── fixsfti.c │ ├── fixtfti.c │ ├── fixunsdfti.c │ ├── fixunssfti.c │ ├── fixunstfti.c │ ├── floattidf.c │ ├── floatuntidf.c │ ├── fp128.h │ ├── fp32.h │ ├── fp64.h │ └── int_t.h ├── chain │ ├── CMakeLists.txt │ ├── abi_serializer.cpp │ ├── account_evaluator.cpp │ ├── account_object.cpp │ ├── advertising_evaluator.cpp │ ├── apply_context.cpp │ ├── asset_evaluator.cpp │ ├── asset_object.cpp │ ├── balance_lock_evaluator.cpp │ ├── block_database.cpp │ ├── committee_member_evaluator.cpp │ ├── committee_member_object.cpp │ ├── content_evaluator.cpp │ ├── contract_evaluator.cpp │ ├── csaf_evaluator.cpp │ ├── custom_vote_evaluator.cpp │ ├── database.cpp │ ├── db_balance.cpp │ ├── db_block.cpp │ ├── db_debug.cpp │ ├── db_getter.cpp │ ├── db_init.cpp │ ├── db_management.cpp │ ├── db_market.cpp │ ├── db_notify.cpp │ ├── db_update.cpp │ ├── db_voter.cpp │ ├── db_witness_schedule.cpp │ ├── evaluator.cpp │ ├── exceptions.cpp │ ├── fork_database.cpp │ ├── genesis_state.cpp │ ├── get_config.cpp │ ├── hardfork.d │ │ ├── 0_1_preamble.hf │ │ ├── 0_2.hf │ │ ├── 0_3.hf │ │ ├── 0_4.hf │ │ └── 3_0.hf │ ├── include │ │ └── graphene │ │ │ └── chain │ │ │ ├── abi_def.hpp │ │ │ ├── abi_serializer.hpp │ │ │ ├── account_evaluator.hpp │ │ │ ├── account_object.hpp │ │ │ ├── action.hpp │ │ │ ├── advertising_evaluator.hpp │ │ │ ├── advertising_object.hpp │ │ │ ├── apply_context.hpp │ │ │ ├── asset_evaluator.hpp │ │ │ ├── asset_object.hpp │ │ │ ├── balance_lock_evaluator.hpp │ │ │ ├── block_database.hpp │ │ │ ├── block_summary_object.hpp │ │ │ ├── chain_property_object.hpp │ │ │ ├── committee_member_evaluator.hpp │ │ │ ├── committee_member_object.hpp │ │ │ ├── config.hpp │ │ │ ├── content_evaluator.hpp │ │ │ ├── content_object.hpp │ │ │ ├── contract_evaluator.hpp │ │ │ ├── contract_table_objects.hpp │ │ │ ├── csaf_evaluator.hpp │ │ │ ├── csaf_object.hpp │ │ │ ├── custom_vote_evaluator.hpp │ │ │ ├── custom_vote_object.hpp │ │ │ ├── database.hpp │ │ │ ├── db_with.hpp │ │ │ ├── evaluator.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── fork_database.hpp │ │ │ ├── genesis_state.hpp │ │ │ ├── get_config.hpp │ │ │ ├── global_property_object.hpp │ │ │ ├── immutable_chain_parameters.hpp │ │ │ ├── impacted.hpp │ │ │ ├── internal_exceptions.hpp │ │ │ ├── is_authorized_asset.hpp │ │ │ ├── market_evaluator.hpp │ │ │ ├── market_object.hpp │ │ │ ├── multi_index_includes.hpp │ │ │ ├── node_property_object.hpp │ │ │ ├── operation_history_object.hpp │ │ │ ├── pledge_mining_evaluator.hpp │ │ │ ├── pledge_mining_object.hpp │ │ │ ├── proposal_evaluator.hpp │ │ │ ├── proposal_object.hpp │ │ │ ├── protocol │ │ │ ├── README.md │ │ │ ├── account.hpp │ │ │ ├── advertising.hpp │ │ │ ├── asset.hpp │ │ │ ├── asset_ops.hpp │ │ │ ├── authority.hpp │ │ │ ├── balance_lock.hpp │ │ │ ├── base.hpp │ │ │ ├── block.hpp │ │ │ ├── block_header.hpp │ │ │ ├── chain_parameters.hpp │ │ │ ├── committee_member.hpp │ │ │ ├── config.hpp │ │ │ ├── content.hpp │ │ │ ├── contract_asset.hpp │ │ │ ├── contract_ops.hpp │ │ │ ├── contract_receipt.hpp │ │ │ ├── csaf.hpp │ │ │ ├── custom_vote.hpp │ │ │ ├── ext.hpp │ │ │ ├── fee_schedule.hpp │ │ │ ├── market.hpp │ │ │ ├── memo.hpp │ │ │ ├── name.hpp │ │ │ ├── operations.hpp │ │ │ ├── pledge_mining.hpp │ │ │ ├── proposal.hpp │ │ │ ├── protocol.hpp │ │ │ ├── transaction.hpp │ │ │ ├── transfer.hpp │ │ │ ├── types.hpp │ │ │ └── witness.hpp │ │ │ ├── signature_object.hpp │ │ │ ├── symbol.hpp │ │ │ ├── transaction_context.hpp │ │ │ ├── transaction_evaluation_state.hpp │ │ │ ├── transaction_object.hpp │ │ │ ├── transfer_evaluator.hpp │ │ │ ├── wasm_binary_ops.hpp │ │ │ ├── wasm_constraints.hpp │ │ │ ├── wasm_injection.hpp │ │ │ ├── wasm_interface.hpp │ │ │ ├── wasm_interface_private.hpp │ │ │ ├── wasm_validation.hpp │ │ │ ├── wast_to_wasm.hpp │ │ │ ├── webassembly │ │ │ ├── binaryen.hpp │ │ │ ├── common.hpp │ │ │ ├── runtime_interface.hpp │ │ │ ├── wabt.hpp │ │ │ └── wavm.hpp │ │ │ ├── witness_evaluator.hpp │ │ │ ├── witness_object.hpp │ │ │ └── witness_schedule_object.hpp │ ├── index.cpp │ ├── is_authorized_asset.cpp │ ├── market_evaluator.cpp │ ├── name.cpp │ ├── pledge_mining_evaluator.cpp │ ├── proposal_evaluator.cpp │ ├── proposal_object.cpp │ ├── protocol │ │ ├── account.cpp │ │ ├── advertising.cpp │ │ ├── asset.cpp │ │ ├── asset_ops.cpp │ │ ├── authority.cpp │ │ ├── balance_lock.cpp │ │ ├── block.cpp │ │ ├── chain_parameters.cpp │ │ ├── committee_member.cpp │ │ ├── content.cpp │ │ ├── csaf.cpp │ │ ├── custom_vote.cpp │ │ ├── fee_schedule.cpp │ │ ├── market.cpp │ │ ├── memo.cpp │ │ ├── operations.cpp │ │ ├── pledge_mining.cpp │ │ ├── proposal.cpp │ │ ├── transaction.cpp │ │ ├── transfer.cpp │ │ ├── types.cpp │ │ └── witness.cpp │ ├── transaction_context.cpp │ ├── transaction_object.cpp │ ├── transfer_evaluator.cpp │ ├── utf8 │ │ ├── ReleaseNotes │ │ ├── checked.h │ │ ├── core.h │ │ ├── unchecked.h │ │ └── utf8cpp.html │ ├── wasm_binary_ops.cpp │ ├── wasm_injection.cpp │ ├── wasm_interface.cpp │ ├── wasm_validation.cpp │ ├── wast_to_wasm.cpp │ ├── webassembly │ │ ├── binaryen.cpp │ │ ├── wabt.cpp │ │ └── wavm.cpp │ └── witness_evaluator.cpp ├── custom_files │ ├── array.hpp │ ├── elliptic.hpp │ ├── elliptic_common.cpp │ ├── elliptic_secp256k1.cpp │ ├── file_mapping.cpp │ ├── file_mapping.hpp │ ├── raw.hpp │ ├── reflect.hpp │ ├── scoped_exit.hpp │ └── utility.hpp ├── db │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── db │ │ │ ├── flat_index.hpp │ │ │ ├── fwd.hpp │ │ │ ├── generic_index.hpp │ │ │ ├── index.hpp │ │ │ ├── object.hpp │ │ │ ├── object_database.hpp │ │ │ ├── object_id.hpp │ │ │ ├── simple_index.hpp │ │ │ └── undo_database.hpp │ ├── index.cpp │ ├── object_database.cpp │ └── undo_database.cpp ├── deterministic_openssl_rand │ ├── CMakeLists.txt │ ├── deterministic_openssl_rand.cpp │ └── include │ │ └── graphene │ │ └── utilities │ │ └── deterministic_openssl_rand.hpp ├── egenesis │ ├── CMakeLists.txt │ ├── egenesis_brief.cpp.tmpl │ ├── egenesis_full.cpp.tmpl │ ├── egenesis_none.cpp │ ├── embed_genesis.cpp │ └── include │ │ └── graphene │ │ └── egenesis │ │ └── egenesis.hpp ├── net │ ├── CMakeLists.txt │ ├── core_messages.cpp │ ├── exceptions.cpp │ ├── include │ │ └── graphene │ │ │ └── net │ │ │ ├── config.hpp │ │ │ ├── core_messages.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── message.hpp │ │ │ ├── message_oriented_connection.hpp │ │ │ ├── node.hpp │ │ │ ├── peer_connection.hpp │ │ │ ├── peer_database.hpp │ │ │ └── stcp_socket.hpp │ ├── message_oriented_connection.cpp │ ├── node.cpp │ ├── node_impl.hxx │ ├── peer_connection.cpp │ ├── peer_database.cpp │ └── stcp_socket.cpp ├── plugins │ ├── CMakeLists.txt │ ├── account_history │ │ ├── CMakeLists.txt │ │ ├── account_history_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── account_history │ │ │ └── account_history_plugin.hpp │ ├── debug_witness │ │ ├── CMakeLists.txt │ │ ├── debug_api.cpp │ │ ├── debug_witness.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── debug_witness │ │ │ ├── debug_api.hpp │ │ │ └── debug_witness.hpp │ ├── delayed_node │ │ ├── CMakeLists.txt │ │ ├── delayed_node_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── delayed_node │ │ │ └── delayed_node_plugin.hpp │ ├── market_history │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── market_history │ │ │ │ └── market_history_plugin.hpp │ │ └── market_history_plugin.cpp │ ├── non_consensus │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── non_consensus │ │ │ │ └── non_consensus_plugin.hpp │ │ └── non_consensus_plugin.cpp │ └── witness │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── graphene │ │ │ └── witness │ │ │ └── witness.hpp │ │ └── witness.cpp ├── utilities │ ├── CMakeLists.txt │ ├── git_revision.cpp.in │ ├── include │ │ └── graphene │ │ │ └── utilities │ │ │ ├── git_revision.hpp │ │ │ ├── key_conversion.hpp │ │ │ ├── padding_ostream.hpp │ │ │ ├── string_escape.hpp │ │ │ ├── tempdir.hpp │ │ │ └── words.hpp │ ├── key_conversion.cpp │ ├── string_escape.cpp │ ├── tempdir.cpp │ └── words.cpp ├── wallet │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── api_documentation_standin.cpp │ ├── generate_api_documentation.pl │ ├── include │ │ └── graphene │ │ │ └── wallet │ │ │ ├── api_documentation.hpp │ │ │ ├── reflect_util.hpp │ │ │ └── wallet.hpp │ └── wallet.cpp └── wasm-jit │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── Include │ ├── Emscripten │ │ └── Emscripten.h │ ├── IR │ │ ├── IR.h │ │ ├── Module.h │ │ ├── OperatorPrinter.h │ │ ├── Operators.h │ │ ├── Types.h │ │ └── Validate.h │ ├── Inline │ │ ├── BasicTypes.h │ │ ├── CMakeLists.txt │ │ ├── DenseStaticIntSet.h │ │ ├── Errors.h │ │ ├── Floats.h │ │ ├── Serialization.h │ │ ├── Timing.h │ │ └── UTF8.h │ ├── Logging │ │ └── Logging.h │ ├── Platform │ │ └── Platform.h │ ├── Runtime │ │ ├── Intrinsics.h │ │ ├── Linker.h │ │ ├── Runtime.h │ │ └── TaggedValue.h │ ├── WASM │ │ └── WASM.h │ └── WAST │ │ ├── TestScript.h │ │ └── WAST.h │ ├── LICENSE │ ├── README.md │ ├── Source │ ├── Emscripten │ │ ├── CMakeLists.txt │ │ └── Emscripten.cpp │ ├── IR │ │ ├── CMakeLists.txt │ │ ├── DisassemblyNames.cpp │ │ ├── Operators.cpp │ │ ├── Types.cpp │ │ └── Validate.cpp │ ├── Logging │ │ ├── CMakeLists.txt │ │ └── Logging.cpp │ ├── Platform │ │ ├── CMakeLists.txt │ │ ├── POSIX.cpp │ │ └── Windows.cpp │ ├── Programs │ │ ├── Assemble.cpp │ │ ├── CLI.h │ │ ├── CMakeLists.txt │ │ ├── Disassemble.cpp │ │ ├── Test.cpp │ │ └── wavm.cpp │ ├── Runtime │ │ ├── CMakeLists.txt │ │ ├── Intrinsics.cpp │ │ ├── LLVMEmitIR.cpp │ │ ├── LLVMJIT.cpp │ │ ├── LLVMJIT.h │ │ ├── Linker.cpp │ │ ├── Memory.cpp │ │ ├── ModuleInstance.cpp │ │ ├── ObjectGC.cpp │ │ ├── Runtime.cpp │ │ ├── RuntimePrivate.h │ │ ├── Table.cpp │ │ ├── Threads.cpp │ │ └── WAVMIntrinsics.cpp │ ├── ThirdParty │ │ ├── dtoa.c │ │ └── xxhash │ │ │ ├── LICENSE │ │ │ ├── xxhash.c │ │ │ └── xxhash.h │ ├── WASM │ │ ├── CMakeLists.txt │ │ └── WASMSerialization.cpp │ └── WAST │ │ ├── CMakeLists.txt │ │ ├── Lexer.cpp │ │ ├── Lexer.h │ │ ├── NFA.cpp │ │ ├── NFA.h │ │ ├── Parse.cpp │ │ ├── Parse.h │ │ ├── ParseFunction.cpp │ │ ├── ParseModule.cpp │ │ ├── ParseNumbers.cpp │ │ ├── ParseTests.cpp │ │ ├── Print.cpp │ │ ├── Regexp.cpp │ │ └── Regexp.h │ ├── Test │ ├── Benchmark │ │ ├── Benchmark.cpp │ │ └── Benchmark.wast │ ├── Blake2b │ │ └── blake2b.wast │ ├── fuzz │ │ ├── address.wast │ │ ├── echo.wast │ │ ├── func_ptrs.wast │ │ ├── globals.wast │ │ ├── helloworld.wast │ │ ├── i32.wast │ │ ├── labels.wast │ │ ├── loop.wast │ │ ├── resizing.wast │ │ ├── return.wast │ │ ├── tee.wast │ │ └── tee_local.wast │ ├── spec │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── WAVM_known_failures.wast │ │ ├── address.wast │ │ ├── align.wast │ │ ├── atomic.wast │ │ ├── binary.wast │ │ ├── block.wast │ │ ├── br.wast │ │ ├── br_if.wast │ │ ├── br_table.wast │ │ ├── break-drop.wast │ │ ├── call.wast │ │ ├── call_indirect.wast │ │ ├── comments.wast │ │ ├── const.wast │ │ ├── conversions.wast │ │ ├── custom_section.wast │ │ ├── elem.wast │ │ ├── endianness.wast │ │ ├── exports.wast │ │ ├── f32.wast │ │ ├── f32_bitwise.wast │ │ ├── f32_cmp.wast │ │ ├── f64.wast │ │ ├── f64_bitwise.wast │ │ ├── f64_cmp.wast │ │ ├── fac.wast │ │ ├── float_exprs.wast │ │ ├── float_literals.wast │ │ ├── float_memory.wast │ │ ├── float_misc.wast │ │ ├── forward.wast │ │ ├── func.wast │ │ ├── func_ptrs.wast │ │ ├── get_local.wast │ │ ├── globals.wast │ │ ├── i32.wast │ │ ├── i64.wast │ │ ├── if.wast │ │ ├── imports.wast │ │ ├── int_exprs.wast │ │ ├── int_literals.wast │ │ ├── labels.wast │ │ ├── left-to-right.wast │ │ ├── linking.wast │ │ ├── loop.wast │ │ ├── memory.wast │ │ ├── memory_redundancy.wast │ │ ├── memory_trap.wast │ │ ├── names.wast │ │ ├── nop.wast │ │ ├── resizing.wast │ │ ├── return.wast │ │ ├── select.wast │ │ ├── set_local.wast │ │ ├── skip-stack-guard-page.wast │ │ ├── stack.wast │ │ ├── start.wast │ │ ├── store_retval.wast │ │ ├── switch.wast │ │ ├── tee_local.wast │ │ ├── token.wast │ │ ├── traps.wast │ │ ├── type.wast │ │ ├── typecheck.wast │ │ ├── unreachable.wast │ │ ├── unreached-invalid.wast │ │ ├── unwind.wast │ │ ├── utf8-custom-section-id.wast │ │ ├── utf8-import-field.wast │ │ ├── utf8-import-module.wast │ │ └── utf8-invalid-encoding.wast │ ├── wast │ │ ├── echo.wast │ │ ├── helloworld.wast │ │ ├── skip-stack-guard-page.wast │ │ └── tee.wast │ └── zlib │ │ └── zlib.wast │ └── afl │ ├── readme │ ├── run-afl-fuzz │ ├── simplify-crashes │ └── wast.dict ├── programs ├── CMakeLists.txt ├── build_helpers │ ├── CMakeLists.txt │ ├── cat-parts.cpp │ ├── check_reflect.py │ └── member_enumerator.cpp ├── debug_node │ ├── CMakeLists.txt │ ├── README.md │ └── main.cpp ├── delayed_node │ ├── CMakeLists.txt │ └── main.cpp ├── genesis_util │ ├── CMakeLists.txt │ ├── apply_patch.py │ ├── canonical_format.py │ ├── change_asset_symbol.py │ ├── change_bitasset_owners.py │ ├── change_key_prefix.py │ ├── convert_address.cpp │ ├── create_bloom_filter.py │ ├── generate_account_patch.py │ ├── generate_init_config.py │ ├── generate_init_patch.py │ ├── genesis_update.cpp │ ├── get_dev_key.cpp │ ├── prefix_accounts.py │ ├── python_format.py │ ├── remove.py │ ├── sort_objects.py │ ├── unprefix_asset_owners.py │ ├── unprefix_names.py │ └── upgrade_members.py ├── js_operation_serializer │ ├── CMakeLists.txt │ └── main.cpp ├── size_checker │ ├── CMakeLists.txt │ └── main.cpp ├── yoyow_client │ ├── CMakeLists.txt │ └── main.cpp ├── yoyow_node │ ├── CMakeLists.txt │ ├── main.cpp │ └── saltpass.py └── yy_abigen │ ├── CMakeLists.txt │ └── main.cpp ├── scripts └── exchange.rb ├── tests ├── CMakeLists.txt ├── app │ └── main.cpp ├── benchmarks │ ├── genesis_allocation.cpp │ └── main.cpp ├── common │ ├── database_fixture.cpp │ └── database_fixture.hpp ├── content_update.docx ├── content_update.txt ├── generate_empty_blocks │ ├── CMakeLists.txt │ └── main.cpp ├── hardfork05_update.docx ├── intense │ ├── api_stress.py │ ├── block_tests.cpp │ └── main.cpp ├── limit_order test.md ├── performance │ └── performance_tests.cpp ├── test_log.txt ├── tests │ ├── basic_tests.cpp │ ├── content_tests.cpp │ ├── fee_tests.cpp │ ├── main.cpp │ ├── serialization_tests.cpp │ └── uia_tests.cpp ├── 文章奖池流程图.docx └── 经济模型-公式版.xlsx ├── tools ├── CMakeLists.txt └── gxx.in └── yoyow-3.0-guide.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.sw* 3 | 4 | *.cmake 5 | CMakeCache.txt 6 | CMakeFiles 7 | Makefile 8 | compile_commands.json 9 | moc_* 10 | *.moc 11 | 12 | genesis.json 13 | hardfork.hpp 14 | 15 | libraries/utilities/git_revision.cpp 16 | 17 | libraries/wallet/Doxyfile 18 | libraries/wallet/api_documentation.cpp 19 | libraries/wallet/doxygen 20 | 21 | programs/cli_wallet/cli_wallet 22 | programs/js_operation_serializer/js_operation_serializer 23 | programs/witness_node/witness_node 24 | 25 | tests/app_test 26 | tests/chain_bench 27 | tests/chain_test 28 | tests/intense_test 29 | tests/performance_test 30 | 31 | doxygen 32 | 33 | wallet.json 34 | witness_node_data_dir 35 | 36 | *.wallet 37 | 38 | programs/witness_node/object_database/* 39 | 40 | object_database/* 41 | 42 | *.pyc 43 | *.pyo 44 | .DS_Store 45 | build 46 | lbuild 47 | wbuild 48 | .vscode -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs"] 2 | path = docs 3 | url = https://github.com/yoyow-org/yoyow-core.wiki.git 4 | ignore = dirty 5 | [submodule "libraries/fc"] 6 | path = libraries/fc 7 | url = https://github.com/bitshares/bitshares-fc.git 8 | ignore = dirty 9 | [submodule "libraries/softfloat"] 10 | path = libraries/softfloat 11 | url = https://github.com/yoyow-org/berkeley-softfloat-3.git 12 | [submodule "externals/binaryen"] 13 | path = externals/binaryen 14 | url = https://github.com/yoyow-org/binaryen.git 15 | [submodule "externals/magic_get"] 16 | path = externals/magic_get 17 | url = https://github.com/yoyow-org/magic_get.git 18 | [submodule "contracts/libc++/upstream"] 19 | path = contracts/libc++/upstream 20 | url = https://github.com/yoyow-org/libcxx.git 21 | [submodule "contracts/musl/upstream"] 22 | path = contracts/musl/upstream 23 | url = https://github.com/yoyow-org/musl.git 24 | [submodule "libraries/wabt"] 25 | path = libraries/wabt 26 | url = https://github.com/yoyow-org/wabt.git 27 | -------------------------------------------------------------------------------- /CMakeModules/FindGperftools.cmake: -------------------------------------------------------------------------------- 1 | # Tries to find Gperftools. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(Gperftools) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # Gperftools_ROOT_DIR Set this variable to the root installation of 11 | # Gperftools if the module has problems finding 12 | # the proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # GPERFTOOLS_FOUND System has Gperftools libs/headers 17 | # GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) 18 | # GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers 19 | 20 | find_library(GPERFTOOLS_TCMALLOC 21 | NAMES tcmalloc 22 | HINTS ${Gperftools_ROOT_DIR}/lib) 23 | 24 | find_library(GPERFTOOLS_PROFILER 25 | NAMES profiler 26 | HINTS ${Gperftools_ROOT_DIR}/lib) 27 | 28 | find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER 29 | NAMES tcmalloc_and_profiler 30 | HINTS ${Gperftools_ROOT_DIR}/lib) 31 | 32 | find_path(GPERFTOOLS_INCLUDE_DIR 33 | NAMES gperftools/heap-profiler.h 34 | HINTS ${Gperftools_ROOT_DIR}/include) 35 | 36 | set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) 37 | 38 | include(FindPackageHandleStandardArgs) 39 | find_package_handle_standard_args( 40 | Gperftools 41 | DEFAULT_MSG 42 | GPERFTOOLS_LIBRARIES 43 | GPERFTOOLS_INCLUDE_DIR) 44 | 45 | mark_as_advanced( 46 | Gperftools_ROOT_DIR 47 | GPERFTOOLS_TCMALLOC 48 | GPERFTOOLS_PROFILER 49 | GPERFTOOLS_TCMALLOC_AND_PROFILER 50 | GPERFTOOLS_LIBRARIES 51 | GPERFTOOLS_INCLUDE_DIR) 52 | -------------------------------------------------------------------------------- /CMakeModules/FindWasm.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find WASM 2 | 3 | # TODO: Check if compiler is able to generate wasm32 4 | if ("${WASM_ROOT}" STREQUAL "") 5 | if (APPLE) 6 | set( WASM_ROOT "/usr/local/wasm" ) 7 | elseif (UNIX AND NOT APPLE) 8 | set( WASM_ROOT "$ENV{HOME}/opt/wasm" ) 9 | else() 10 | message(FATAL_ERROR "WASM not found and don't know where to look, please specify WASM_ROOT") 11 | endif() 12 | endif() 13 | find_program(WASM_CLANG clang PATHS ${WASM_ROOT}/bin NO_DEFAULT_PATH) 14 | find_program(WASM_LLC llc PATHS ${WASM_ROOT}/bin NO_DEFAULT_PATH) 15 | find_program(WASM_LLVM_LINK llvm-link PATHS ${WASM_ROOT}/bin NO_DEFAULT_PATH) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | 19 | find_package_handle_standard_args(WASM REQUIRED_VARS WASM_CLANG WASM_LLC WASM_LLVM_LINK) 20 | 21 | -------------------------------------------------------------------------------- /CMakeModules/InstallDirectoryPermissions.cmake: -------------------------------------------------------------------------------- 1 | # Fix directory permissions after installation of header files (primarily). 2 | macro(install_directory_permissions) 3 | cmake_parse_arguments(ARG "" "DIRECTORY" "" ${ARGN}) 4 | set(dir ${ARG_DIRECTORY}) 5 | install(DIRECTORY DESTINATION ${dir} 6 | DIRECTORY_PERMISSIONS OWNER_READ 7 | OWNER_WRITE 8 | OWNER_EXECUTE 9 | GROUP_READ 10 | GROUP_EXECUTE 11 | WORLD_READ 12 | WORLD_EXECUTE 13 | ) 14 | endmacro(install_directory_permissions) 15 | -------------------------------------------------------------------------------- /CMakeModules/installer.cmake: -------------------------------------------------------------------------------- 1 | include(InstallRequiredSystemLibraries) 2 | 3 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 4 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install) 5 | endif() 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # This will build the witness_node in a docker image. Make sure you've already 2 | # checked out the submodules before building. 3 | 4 | FROM l3iggs/archlinux:latest 5 | MAINTAINER Nathan Hourt 6 | 7 | RUN pacman -Syu --noconfirm gcc make autoconf automake cmake ninja boost libtool git 8 | 9 | ADD . /bitshares-2 10 | WORKDIR /bitshares-2 11 | RUN cmake -G Ninja -DCMAKE_BUILD_TYPE=Release . 12 | RUN ninja witness_node || ninja -j 1 witness_node 13 | 14 | RUN mkdir /data_dir 15 | ADD docker/default_config.ini /default_config.ini 16 | ADD docker/launch /launch 17 | RUN chmod a+x /launch 18 | VOLUME /data_dir 19 | 20 | EXPOSE 8090 9090 21 | 22 | ENTRYPOINT ["/launch"] 23 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Cryptonomex, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and 6 | * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted until September 8, 2015, provided that the following conditions are met: 8 | * 9 | * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. 10 | * 11 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 12 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 13 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 14 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 15 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 16 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 | */ 18 | -------------------------------------------------------------------------------- /LICENSE.Graphene.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2016 Cryptonomex Inc. 2 | Copyright (c) 2015-2017 contributors 3 | 4 | The MIT License 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # yoyow-core 2 | 3 | ## Getting Started 4 | We recommend building on Ubuntu 16.04 LTS (64-bit) 5 | 6 | building on other system : 7 | **NOTE:** Yoyow requires an [OpenSSL](https://www.openssl.org/) version in the 1.0.x series. OpenSSL 1.1.0 and newer are NOT supported. If your system OpenSSL version is newer, then you will need to manually provide an older version of OpenSSL and specify it to CMake using `-DOPENSSL_INCLUDE_DIR`, `-DOPENSSL_SSL_LIBRARY`, and `-DOPENSSL_CRYPTO_LIBRARY`. 8 | 9 | **NOTE:** Yoyow requires a [Boost](http://www.boost.org/) version in the range [1.57, 1.60]. Versions earlier than 10 | 1.57 or newer than 1.60 are NOT supported. If your system Boost version is newer, then you will need to manually build 11 | an older version of Boost and specify it to CMake using `DBOOST_ROOT`. 12 | 13 | ### Build Dependencies: 14 | ``` 15 | sudo apt-get update 16 | sudo apt-get install autoconf cmake make automake libtool git libboost-all-dev libssl-dev g++ libcurl4-openssl-dev 17 | ``` 18 | 19 | ### Build Script: 20 | ``` 21 | git clone https://github.com/yoyow-org/yoyow-core.git 22 | cd yoyow-core 23 | git checkout yy-mainnet # may substitute "yy-mainnet" with current release tag 24 | git submodule update --init --recursive 25 | mkdir build 26 | cd build 27 | cmake -DCMAKE_BUILD_TYPE=Release ../ 28 | make yoyow_node 29 | make yoyow_client 30 | ``` 31 | 32 | ### launch: 33 | ``` 34 | ./programs/yoyow_node/yoyow_node 35 | ``` 36 | The node will automatically create a data directory including a config file. It may take several hours to fully synchronize the blockchain. After syncing, you can exit the node using Ctrl+C and setup the command-line wallet by editing ```witness_node_data_dir/config.ini``` as follows: 37 | ``` 38 | rpc-endpoint = 127.0.0.1:9000 39 | ``` 40 | After starting the witness node again, in a separate terminal you can run: 41 | ``` 42 | ./programs/yoyow_client/yoyow_client 43 | ``` 44 | Set your inital password: 45 | ``` 46 | >>> set_password 47 | >>> unlock 48 | ``` 49 | 50 | ## Docs 51 | * https://github.com/yoyow-org/yoyow-core/wiki 52 | 53 | ## More Info 54 | * https://yoyow.org/ 55 | * https://wallet.yoyow.org/ 56 | -------------------------------------------------------------------------------- /contracts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(DEFAULT_SYSTEM_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include ${Boost_INCLUDE_DIR}) 2 | 3 | set(STANDARD_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts ${CMAKE_SOURCE_DIR}/externals/magic_get/include) 4 | 5 | add_subdirectory(graphenelib) 6 | add_subdirectory(musl) 7 | add_subdirectory(libc++) 8 | 9 | 10 | file(GLOB SKELETONS RELATIVE ${CMAKE_SOURCE_DIR}/contracts "skeleton/*") 11 | 12 | # Documented multiple output support is broken, so properly setting up the multiple 13 | # dependencies in the custom target is not possible. (CMake 3.5) 14 | add_custom_command(OUTPUT share/yy/skeleton/skeleton.cpp 15 | COMMAND ${CMAKE_COMMAND} -E make_directory ../share/yy/skeleton 16 | COMMAND ${CMAKE_COMMAND} -E copy_directory 17 | ${CMAKE_CURRENT_SOURCE_DIR}/skeleton ../share/yy/skeleton 18 | DEPENDS ${SKELETONS} 19 | COMMENT Copying skeleton contract... 20 | VERBATIM) 21 | add_custom_target(copy_skeleton_contract ALL DEPENDS share/yy/skeleton/skeleton.cpp) 22 | 23 | MESSAGE( STATUS "------- cmake_install_full_includedir ------ is: " 24 | ${CMAKE_INSTALL_FULL_INCLUDEDIR} ) 25 | 26 | install(DIRECTORY graphenelib DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 27 | install(DIRECTORY musl DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 28 | install(DIRECTORY libc++ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 29 | install(DIRECTORY skeleton DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/yy) 30 | install_directory_permissions(DIRECTORY ${CMAKE_INSTALL_FULL_DATAROOTDIR}/yy) 31 | -------------------------------------------------------------------------------- /contracts/examples/transfer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace graphene; 7 | 8 | class _transfer : public contract 9 | { 10 | public: 11 | _transfer(uint64_t id) 12 | : contract(id) 13 | , offers(_self, _self) 14 | { 15 | } 16 | 17 | //@abi action 18 | void add(const uint64_t& uid, const uint64_t& amount) 19 | { 20 | graphene_assert(offers.find(uid) == offers.end(),"item already exists"); 21 | offers.emplace(0, [&](auto &o) { 22 | o.uid = uid; 23 | o.amount = amount; 24 | }); 25 | } 26 | 27 | //@abi action 28 | void transfer(const uint64_t& from,const uint64_t& to,const uint64_t& amount) 29 | { 30 | auto itr_from = offers.find(from); 31 | graphene_assert(itr_from != offers.end(),"from not exists"); 32 | graphene_assert(itr_from->amount > amount,"balance is not enough"); 33 | 34 | offers.modify(itr_from,0, [&](auto &o) { 35 | o.amount -= amount; 36 | }); 37 | 38 | auto itr_to = offers.find(to); 39 | if(itr_to == offers.end()) 40 | { 41 | offers.emplace(0, [&](auto &o) { 42 | o.uid = to; 43 | o.amount = amount; 44 | }); 45 | } 46 | else 47 | { 48 | offers.modify(itr_to,0, [&](auto &o) { 49 | o.amount += amount; 50 | }); 51 | } 52 | } 53 | 54 | private: 55 | //@abi table offer i64 56 | struct offer { 57 | uint64_t uid; 58 | uint64_t amount; 59 | 60 | uint64_t primary_key() const { return uid; } 61 | 62 | 63 | GRAPHENE_SERIALIZE(offer, (uid)(amount)) 64 | }; 65 | 66 | typedef multi_index offer_index; 67 | 68 | offer_index offers; 69 | }; 70 | 71 | GRAPHENE_ABI(_transfer, (add)(transfer)) 72 | -------------------------------------------------------------------------------- /contracts/examples/transferV2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace graphene; 7 | 8 | class _transfer : public contract 9 | { 10 | public: 11 | _transfer(uint64_t id) 12 | : contract(id) 13 | , offers(_self, _self) 14 | { 15 | } 16 | 17 | //@abi action 18 | void add(const uint64_t& uid, const uint64_t& amount) 19 | { 20 | graphene_assert(offers.find(uid) == offers.end(),"item already exists"); 21 | 22 | offers.emplace(0, [&](auto &o) { 23 | o.uid = uid; 24 | o.amount = amount; 25 | }); 26 | } 27 | 28 | //@abi action 29 | void transfer(const uint64_t& from,const uint64_t& to,const uint64_t& amount) 30 | { 31 | auto itr_from = offers.find(from); 32 | graphene_assert(itr_from != offers.end(),"from not exists"); 33 | graphene_assert(itr_from->amount > amount,"balance is not enough"); 34 | 35 | graphene_assert(from == get_trx_sender(),"invalid authorityy"); 36 | 37 | offers.modify(itr_from,0, [&](auto &o) { 38 | o.amount -= amount; 39 | }); 40 | 41 | auto itr_to = offers.find(to); 42 | if(itr_to == offers.end()) 43 | { 44 | offers.emplace(0, [&](auto &o) { 45 | o.uid = to; 46 | o.amount = amount; 47 | }); 48 | } 49 | else 50 | { 51 | offers.modify(itr_to,0, [&](auto &o) { 52 | o.amount += amount; 53 | }); 54 | } 55 | } 56 | 57 | private: 58 | //@abi table offer i64 59 | struct offer { 60 | uint64_t uid; 61 | uint64_t amount; 62 | 63 | uint64_t primary_key() const { return uid; } 64 | 65 | 66 | GRAPHENE_SERIALIZE(offer, (uid)(amount)) 67 | }; 68 | 69 | typedef multi_index offer_index; 70 | 71 | offer_index offers; 72 | }; 73 | 74 | GRAPHENE_ABI(_transfer, (add)(transfer)) 75 | -------------------------------------------------------------------------------- /contracts/graphenelib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_wast_library(TARGET graphenelib 2 | INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" ${CMAKE_SOURCE_DIR}/externals/magic_get/include 3 | DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} 4 | ) 5 | -------------------------------------------------------------------------------- /contracts/graphenelib/action.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @copyright defined in LICENSE.txt 4 | */ 5 | #pragma once 6 | #include 7 | 8 | extern "C" { 9 | /** 10 | * @defgroup actionapi Action API 11 | * @ingroup contractdev 12 | * @brief Define API for querying action properties 13 | * 14 | */ 15 | 16 | /** 17 | * @defgroup actioncapi Action C API 18 | * @ingroup actionapi 19 | * @brief Define API for querying action properties 20 | * 21 | */ 22 | 23 | /** 24 | * Copy up to @ref len bytes of current action data to the specified location 25 | * @brief Copy current action data to the specified location 26 | * @param msg - a pointer where up to @ref len bytes of the current action data will be copied 27 | * @param len - len of the current action data to be copied, 0 to report required size 28 | * @return the number of bytes copied to msg, or number of bytes that can be copied if len==0 passed 29 | */ 30 | uint32_t read_action_data( void* msg, uint32_t len ); 31 | 32 | /** 33 | * Get the length of the current action's data field 34 | * This method is useful for dynamically sized actions 35 | * @brief Get the length of current action's data field 36 | * @return the length of the current action's data field 37 | */ 38 | uint32_t action_data_size(); 39 | 40 | 41 | /** 42 | * Send an inline action in the context of this action's parent transaction 43 | * @param serialized_action - serialized action 44 | * @param size - size of serialized action in bytes 45 | */ 46 | void send_inline(char *serialized_action, size_t size); 47 | 48 | /** 49 | * Get the current receiver of the action 50 | * @brief Get the current receiver of the action 51 | * @return the account which specifies the current receiver of the action 52 | */ 53 | uint64_t current_receiver(); 54 | 55 | uint64_t get_action_asset_id(); 56 | 57 | int64_t get_action_asset_amount(); 58 | 59 | ///@ } actioncapi 60 | } 61 | -------------------------------------------------------------------------------- /contracts/graphenelib/asset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | extern "C" { 5 | 6 | void withdraw_asset(uint64_t from, uint64_t to, uint64_t asset_id, int64_t amount); 7 | int64_t get_balance(int64_t account, int64_t asset_id); 8 | void inline_transfer(uint64_t from, uint64_t to, uint64_t asset_id, int64_t amount, const char* data, uint32_t length); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /contracts/graphenelib/contract.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace graphene { 5 | #define ACTION void 6 | #define PAYABLE void 7 | #define TABLE struct 8 | #define CONTRACT class 9 | 10 | class contract 11 | { 12 | public: 13 | contract(uint64_t account_id) 14 | : _self(account_id) 15 | { 16 | } 17 | 18 | inline uint64_t get_self() const { return _self; } 19 | 20 | protected: 21 | uint64_t _self; 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /contracts/graphenelib/global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | extern "C" { 5 | // return head block num 6 | int64_t get_head_block_num(); 7 | // return head block id 8 | void get_head_block_id(checksum160* hash); 9 | void get_block_id_for_num(checksum160* hash, uint32_t block_num); 10 | // return head block time 11 | int64_t get_head_block_time(); 12 | // return trx sender 13 | uint64_t get_trx_sender(); 14 | // return original trx sender 15 | uint64_t get_trx_origin(); 16 | // get account_id by name, return -1 if name not exists, return account_id if succeed 17 | int64_t get_account_id(const char *data, uint32_t length); 18 | // get asset_id by name, return -1 if asset not exists, return asset id if succeeed 19 | int64_t get_asset_id(const char *data, uint32_t length); 20 | // get asset_precision, return -1 if asset not exists, retrun precision if succeed 21 | int64_t get_asset_precision(const char *data, uint32_t datalen); 22 | // dump current transaction of current contract calling to dst in binary form 23 | int read_transaction(char* dst, uint32_t dst_size); 24 | // get current transaction size of current contract calling 25 | int transaction_size(); 26 | // return current transaction expiration 27 | uint64_t expiration(); 28 | // return ref block num(block_id.hash[0]) 29 | // eg. "block_id": "00000fa00f4dd71912f56dd6e23f03bf2af87be5" --> 00000fa0 30 | int tapos_block_num(); 31 | // return ref block prefix(block_id.hash[1]) 32 | //eg. "block_id": "00000fa00f4dd71912f56dd6e23f03bf2af87be5" --> 0f4dd719 33 | uint64_t tapos_block_prefix(); 34 | // get account_name by id, return -1 if fail, return 0 if success 35 | int64_t get_account_name_by_id(char* data, uint32_t datalen, int64_t account_id); 36 | } 37 | -------------------------------------------------------------------------------- /contracts/graphenelib/graphene.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /contracts/graphenelib/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /contracts/graphenelib/memory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | void* sbrk(size_t num_bytes); 7 | 8 | extern "C" { 9 | 10 | void* malloc(size_t size); 11 | 12 | void* calloc(size_t count, size_t size); 13 | 14 | void* realloc(void* ptr, size_t size); 15 | 16 | void free(void* ptr); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /contracts/graphenelib/serialize.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define GRAPHENELIB_REFLECT_MEMBER_OP( r, OP, elem ) \ 8 | OP t.elem 9 | 10 | /** 11 | * @def GRAPHENE_SERIALIZE(TYPE,MEMBERS) 12 | * 13 | * @brief Specializes graphene::reflector for TYPE where 14 | * type inherits other reflected classes 15 | * 16 | * @param INHERITS - a sequence of base class names (basea)(baseb)(basec) 17 | * @param MEMBERS - a sequence of member names. (field1)(field2)(field3) 18 | */ 19 | #define GRAPHENE_SERIALIZE( TYPE, MEMBERS ) \ 20 | template \ 21 | friend DataStream& operator << ( DataStream& ds, const TYPE& t ){ \ 22 | return ds BOOST_PP_SEQ_FOR_EACH( GRAPHENELIB_REFLECT_MEMBER_OP, <<, MEMBERS );\ 23 | }\ 24 | template \ 25 | friend DataStream& operator >> ( DataStream& ds, TYPE& t ){ \ 26 | return ds BOOST_PP_SEQ_FOR_EACH( GRAPHENELIB_REFLECT_MEMBER_OP, >>, MEMBERS );\ 27 | } 28 | 29 | 30 | #define GRAPHENE_SERIALIZE_DERIVED( TYPE, BASE, MEMBERS ) \ 31 | template \ 32 | friend DataStream& operator << ( DataStream& ds, const TYPE& t ){ \ 33 | ds << static_cast(t); \ 34 | return ds BOOST_PP_SEQ_FOR_EACH( GRAPHENELIB_REFLECT_MEMBER_OP, <<, MEMBERS );\ 35 | }\ 36 | template \ 37 | friend DataStream& operator >> ( DataStream& ds, TYPE& t ){ \ 38 | ds >> static_cast(t); \ 39 | return ds BOOST_PP_SEQ_FOR_EACH( GRAPHENELIB_REFLECT_MEMBER_OP, >>, MEMBERS );\ 40 | } 41 | -------------------------------------------------------------------------------- /contracts/graphenelib/stdlib.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /contracts/graphenelib/system.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | extern "C" { 5 | 6 | /** 7 | * Aborts processing of this action and unwinds all pending changes if the test condition is true 8 | * @brief Aborts processing of this action and unwinds all pending changes 9 | * @param test - 0 to abort, 1 to ignore 10 | * @param msg - a null terminated string explaining the reason for failure 11 | */ 12 | void graphene_assert( uint32_t test, const char* msg ); 13 | 14 | /** 15 | * Aborts processing of this action and unwinds all pending changes if the test condition is true 16 | * @brief Aborts processing of this action and unwinds all pending changes 17 | * @param test - 0 to abort, 1 to ignore 18 | * @param msg - a pointer to the start of string explaining the reason for failure 19 | * @param msg_len - length of the string 20 | */ 21 | void graphene_assert_message( uint32_t test, const char* msg, uint32_t msg_len ); 22 | 23 | /** 24 | * Aborts processing of this action and unwinds all pending changes if the test condition is true 25 | * @brief Aborts processing of this action and unwinds all pending changes 26 | * @param test - 0 to abort, 1 to ignore 27 | * @param code - the error code 28 | 29 | */ 30 | void graphene_assert_code( uint32_t test, uint64_t code ); 31 | 32 | /** 33 | * This method will abort execution of wasm without failing the contract. This 34 | * is used to bypass all cleanup / destructors that would normally be called. 35 | */ 36 | [[noreturn]] void graphene_exit( int32_t code ); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /contracts/graphenelib/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /** 10 | * @defgroup types Builtin Types 11 | * @ingroup contractdev 12 | * @brief Specifies typedefs and aliases 13 | * 14 | * @{ 15 | */ 16 | 17 | #define GRAPHENE_DB_MAX_INSTANCE_ID (uint64_t(-1)>>16) 18 | 19 | typedef uint64_t table_name; 20 | typedef uint32_t time; 21 | typedef uint64_t scope_name; 22 | typedef uint64_t action_name; 23 | 24 | typedef uint16_t weight_type; 25 | 26 | /* macro to align/overalign a type to ensure calls to intrinsics with pointers/references are properly aligned */ 27 | #define ALIGNED(X) __attribute__ ((aligned (16))) X 28 | 29 | struct public_key { 30 | char data[33]; 31 | }; 32 | 33 | struct signature { 34 | uint8_t data[65]; 35 | }; 36 | 37 | struct ALIGNED(checksum256) { 38 | uint8_t hash[32]; 39 | }; 40 | 41 | struct ALIGNED(checksum160) { 42 | uint8_t hash[20]; 43 | }; 44 | 45 | struct ALIGNED(checksum512) { 46 | uint8_t hash[64]; 47 | }; 48 | 49 | typedef struct checksum160 block_id_type; 50 | 51 | #ifdef __cplusplus 52 | } /// extern "C" 53 | #endif 54 | /// @} 55 | -------------------------------------------------------------------------------- /contracts/graphenelib/vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace graphene { 7 | 8 | using std::vector; 9 | 10 | typedef std::vector bytes; 11 | 12 | } /// namespace graphene 13 | -------------------------------------------------------------------------------- /contracts/libc++/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(SRC_FILENAMES algorithm.cpp any.cpp bind.cpp condition_variable.cpp exception.cpp functional.cpp 2 | future.cpp ios.cpp iostream.cpp locale.cpp memory.cpp mutex.cpp new.cpp optional.cpp 3 | regex.cpp shared_mutex.cpp stdexcept.cpp string.cpp strstream.cpp system_error.cpp 4 | thread.cpp typeinfo.cpp utility.cpp valarray.cpp variant.cpp vector.cpp) 5 | 6 | #SET(SRC_FILENAMES exception.cpp) 7 | 8 | SET(SRC_FILES "") 9 | FOREACH(FN ${SRC_FILENAMES}) 10 | LIST(APPEND SRC_FILES "upstream/src/${FN}") 11 | ENDFOREACH(FN) 12 | 13 | add_wast_library(TARGET libc++ 14 | NOWARNINGS 15 | SOURCE_FILES "${SRC_FILES}" 16 | INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" 17 | DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} 18 | ) 19 | -------------------------------------------------------------------------------- /contracts/musl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB CRYPT_SOURCES "upstream/src/crypt/*.c") 2 | file(GLOB CTYPE_SOURCES "upstream/src/ctype/*.c") 3 | file(GLOB ENV_SOURCES "upstream/src/env/*.c") 4 | file(GLOB ERRNO_SOURCES "upstream/src/errno/*.c") 5 | file(GLOB EXIT_SOURCES "upstream/src/exit/*.c") 6 | file(GLOB LOCALE_SOURCES "upstream/src/locale/*.c") 7 | file(GLOB MATH_SOURCES "upstream/src/math/*.c") 8 | file(GLOB MBYTE_SOURCES "upstream/src/multibyte/*.c") 9 | file(GLOB MISC_SOURCES "upstream/src/misc/*.c") 10 | file(GLOB SEARCH_SOURCES "upstream/src/search/*.c") 11 | file(GLOB STDIO_SOURCES "upstream/src/stdio/*.c") 12 | file(GLOB STDLIB_SOURCES "upstream/src/stdlib/*.c") 13 | file(GLOB STRING_SOURCES "upstream/src/string/*.c") 14 | file(GLOB TIME_SOURCES "upstream/src/time/*.c") 15 | file(GLOB THREAD_SOURCES "upstream/src/thread/*.c") #only for __lock __unlock 16 | set(INTERNAL_SOURCES upstream/src/internal/floatscan.c upstream/src/internal/intscan.c upstream/src/internal/shgetc.c upstream/src/internal/libc.c) 17 | 18 | add_wast_library(TARGET libc 19 | NOWARNINGS 20 | SOURCE_FILES ${CRYPT_SOURCES} ${CTYPE_SOURCES} ${ENV_SOURCES} ${ERRNO_SOURCES} ${EXIT_SOURCES} ${INTERNAL_SOURCES} ${LOCALE_SOURCES} ${MATH_SOURCES} 21 | ${MBYTE_SOURCES} ${MISC_SOURCES} ${SEARCH_SOURCES} ${STDIO_SOURCES} ${STDLIB_SOURCES} ${STRING_SOURCES} ${TIME_SOURCES} ${THREAD_SOURCES} 22 | INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include 23 | ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/src/internal 24 | ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/arch/yy 25 | ${CMAKE_SOURCE_DIR}/contracts/ 26 | DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} 27 | ) 28 | -------------------------------------------------------------------------------- /contracts/skeleton/skeleton.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace graphene; 7 | 8 | class skeleton : public contract 9 | { 10 | public: 11 | skeleton(uint64_t id) 12 | : contract(id) 13 | { 14 | } 15 | 16 | /// @abi action 17 | void hi(std::string user) 18 | { 19 | for (int i = 0; i < 2; ++i) { 20 | print("hi, ", user, "\n"); 21 | } 22 | } 23 | }; 24 | 25 | GRAPHENE_ABI(skeleton, (hi)) 26 | -------------------------------------------------------------------------------- /contracts/skeleton/skeleton.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /docker/launch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [ -e /data_dir/config.ini ] || cp /default_config.ini /data_dir/config.ini 4 | 5 | [ -e /data_dir/pre_exec ] && bash /data_dir/pre_exec 6 | if [ -e /data_dir/extra_args ]; then 7 | /bitshares-2/programs/witness_node/witness_node --data-dir /data_dir `cat /data_dir/extra_args` 8 | else 9 | /bitshares-2/programs/witness_node/witness_node --data-dir /data_dir 10 | fi 11 | [ -e /data_dir/post_exec ] && bash /data_dir/post_exec 12 | -------------------------------------------------------------------------------- /externals/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( binaryen ) 2 | install(DIRECTORY magic_get/include/boost DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 3 | -------------------------------------------------------------------------------- /gui_version: -------------------------------------------------------------------------------- 1 | 2.0.170418 2 | -------------------------------------------------------------------------------- /libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(COPY custom_files/elliptic.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/crypto/) 2 | file(COPY custom_files/file_mapping.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/interprocess/) 3 | file(COPY custom_files/raw.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/io/) 4 | file(COPY custom_files/reflect.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/reflect/) 5 | file(COPY custom_files/elliptic_common.cpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/src/crypto/) 6 | file(COPY custom_files/elliptic_secp256k1.cpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/src/crypto/) 7 | file(COPY custom_files/file_mapping.cpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/src/interprocess/) 8 | file(COPY custom_files/array.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/) 9 | file(COPY custom_files/scoped_exit.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/) 10 | file(COPY custom_files/utility.hpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/fc/include/fc/) 11 | 12 | add_subdirectory( fc ) 13 | add_subdirectory( builtins ) 14 | add_subdirectory( db ) 15 | add_subdirectory( wasm-jit ) 16 | add_subdirectory( softfloat ) 17 | add_subdirectory( chain ) 18 | add_subdirectory( egenesis ) 19 | add_subdirectory( net ) 20 | add_subdirectory( utilities ) 21 | add_subdirectory( app ) 22 | add_subdirectory( plugins ) 23 | add_subdirectory( wallet ) 24 | add_subdirectory( abi_generator ) 25 | add_subdirectory( wabt ) 26 | -------------------------------------------------------------------------------- /libraries/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/app/*.hpp") 2 | file(GLOB EGENESIS_HEADERS "../egenesis/include/graphene/app/*.hpp") 3 | 4 | add_library( graphene_app 5 | api.cpp 6 | application.cpp 7 | util.cpp 8 | database_api.cpp 9 | #impacted.cpp 10 | plugin.cpp 11 | config_util.cpp 12 | ${HEADERS} 13 | ${EGENESIS_HEADERS} 14 | ) 15 | 16 | # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 17 | target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness ) 18 | target_include_directories( graphene_app 19 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 20 | "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) 21 | 22 | if(MSVC) 23 | set_source_files_properties( application.cpp api.cpp database_api.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 24 | endif(MSVC) 25 | 26 | INSTALL( TARGETS 27 | graphene_app 28 | 29 | RUNTIME DESTINATION bin 30 | LIBRARY DESTINATION lib 31 | ARCHIVE DESTINATION lib 32 | ) 33 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/app" ) 34 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/api_access.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | namespace graphene { namespace app { 33 | 34 | struct api_access_info 35 | { 36 | std::string password_hash_b64; 37 | std::string password_salt_b64; 38 | std::vector< std::string > allowed_apis; 39 | }; 40 | 41 | struct api_access 42 | { 43 | std::map< std::string, api_access_info > permission_map; 44 | }; 45 | 46 | } } // graphene::app 47 | 48 | FC_REFLECT( graphene::app::api_access_info, 49 | (password_hash_b64) 50 | (password_salt_b64) 51 | (allowed_apis) 52 | ) 53 | 54 | FC_REFLECT( graphene::app::api_access, 55 | (permission_map) 56 | ) 57 | -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/config_util.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Lubos Ilcik, and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | namespace graphene { namespace app { 30 | 31 | void load_configuration_options(const fc::path &data_dir, const boost::program_options::options_description &cfg_options, 32 | boost::program_options::variables_map &options); 33 | 34 | } } // graphene::app -------------------------------------------------------------------------------- /libraries/app/include/graphene/app/util.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Abit More, and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | namespace graphene { namespace app { 33 | using namespace graphene::chain; 34 | 35 | typedef boost::multiprecision::uint256_t u256; 36 | 37 | u256 to256( const fc::uint128_t& t ); 38 | fc::uint128_t to_capped128( const u256& t ); 39 | string uint128_amount_to_string( const fc::uint128_t& amount, const uint8_t precision ); 40 | string price_to_string( const price& _price, const uint8_t base_precision, const uint8_t quote_precision); 41 | string price_diff_percent_string( const price& old_price, const price& new_price ); 42 | 43 | } } 44 | -------------------------------------------------------------------------------- /libraries/builtins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Defines builtins library 2 | project (builtins C) 3 | 4 | # generate compile command database for external tools 5 | set (CMAKE_EXPORT_COMPILE_COMMANDS "ON") 6 | 7 | message ( STATUS "Configuring Builtins" ) 8 | set(C_DEFINES, "-D__wasm__ -DQUAD_PRECISION") 9 | set( CMAKE_C_FLAGS " -Wall ${CMAKE_C_FLAGS} ${C_DEFINES}" ) 10 | set ( builtins_sources 11 | fixtfti.c 12 | fixunstfti.c 13 | fixsfti.c 14 | fixdfti.c 15 | fixunssfti.c 16 | fixunsdfti.c 17 | floattidf.c 18 | floatuntidf.c 19 | ) 20 | 21 | file ( GLOB builtins_headers "${CMAKE_CURRENT_SOURCE_DIR}*.h" ) 22 | list( APPEND builtins_sources ${builtins_headers} ) 23 | add_library ( builtins STATIC ${builtins_sources} ) 24 | target_include_directories( builtins PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" 25 | "${CMAKE_CURRENT_SOURCE_DIR}../softfloat/source/include" ) 26 | 27 | install ( TARGETS 28 | builtins 29 | 30 | RUNTIME DESTINATION bin 31 | LIBRARY DESTINATION lib 32 | ARCHIVE DESTINATION lib 33 | ) 34 | -------------------------------------------------------------------------------- /libraries/builtins/compiler_builtins.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | extern "C" { 6 | __int128 ___fixdfti(uint64_t); 7 | __int128 ___fixsfti(uint32_t); 8 | __int128 ___fixtfti( float128_t); 9 | unsigned __int128 ___fixunsdfti(uint64_t); 10 | unsigned __int128 ___fixunssfti(uint32_t); 11 | unsigned __int128 ___fixunstfti(float128_t); 12 | double ___floattidf(__int128); 13 | double ___floatuntidf(unsigned __int128); 14 | } 15 | -------------------------------------------------------------------------------- /libraries/builtins/fixdfti.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixdfti.c - Implement __fixdfti -----------------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | */ 10 | 11 | #include "fp64.h" 12 | 13 | typedef __int128 fixint_t; 14 | typedef unsigned __int128 fixuint_t; 15 | 16 | fixint_t ___fixdfti(uint64_t a) { 17 | const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2); 18 | const fixint_t fixint_min = -fixint_max - 1; 19 | // Break a into sign, exponent, significand 20 | const rep_t aRep = a; 21 | const rep_t aAbs = aRep & absMask; 22 | const fixint_t sign = aRep & signBit ? -1 : 1; 23 | const int exponent = (aAbs >> significandBits) - exponentBias; 24 | const rep_t significand = (aAbs & significandMask) | implicitBit; 25 | 26 | // If exponent is negative, the result is zero. 27 | if (exponent < 0) 28 | return 0; 29 | 30 | // If the value is too large for the integer type, saturate. 31 | if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT) 32 | return sign == 1 ? fixint_max : fixint_min; 33 | 34 | // If 0 <= exponent < significandBits, right shift to get the result. 35 | // Otherwise, shift left. 36 | if (exponent < significandBits) 37 | return sign * (significand >> (significandBits - exponent)); 38 | else 39 | return sign * ((fixint_t)significand << (exponent - significandBits)); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /libraries/builtins/fixsfti.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixsfti.c - Implement __fixsfti -----------------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | */ 10 | 11 | #include "fp32.h" 12 | 13 | typedef __int128 fixint_t; 14 | typedef unsigned __int128 fixuint_t; 15 | 16 | fixint_t ___fixsfti(uint32_t a) { 17 | const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2); 18 | const fixint_t fixint_min = -fixint_max - 1; 19 | // Break a into sign, exponent, significand 20 | const rep_t aRep = a; 21 | const rep_t aAbs = aRep & absMask; 22 | const fixint_t sign = aRep & signBit ? -1 : 1; 23 | const int exponent = (aAbs >> significandBits) - exponentBias; 24 | const rep_t significand = (aAbs & significandMask) | implicitBit; 25 | 26 | // If exponent is negative, the result is zero. 27 | if (exponent < 0) 28 | return 0; 29 | 30 | // If the value is too large for the integer type, saturate. 31 | if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT) 32 | return sign == 1 ? fixint_max : fixint_min; 33 | 34 | // If 0 <= exponent < significandBits, right shift to get the result. 35 | // Otherwise, shift left. 36 | if (exponent < significandBits) 37 | return sign * (significand >> (significandBits - exponent)); 38 | else 39 | return sign * ((fixint_t)significand << (exponent - significandBits)); 40 | } 41 | -------------------------------------------------------------------------------- /libraries/builtins/fixtfti.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixtfti.c - Implement __fixtfti -----------------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | */ 10 | 11 | #include "fp128.h" 12 | 13 | __int128 ___fixtfti( float128_t a) { 14 | const __int128 fixint_max = (__int128)((~(unsigned __int128)0) / 2); 15 | const __int128 fixint_min = -fixint_max - 1; 16 | // Break a into sign, exponent, significand 17 | const __int128 aRep = toRep(a); 18 | const __int128 aAbs = aRep & absMask; 19 | const __int128 sign = aRep & signBit ? -1 : 1; 20 | const int exponent = (aAbs >> significandBits) - exponentBias; 21 | const __int128 significand = (aAbs & significandMask) | implicitBit; 22 | 23 | // If exponent is negative, the result is zero. 24 | if (exponent < 0) 25 | return 0; 26 | 27 | // If the value is too large for the integer type, saturate. 28 | if ((unsigned)exponent >= sizeof(__int128) * CHAR_BIT) 29 | return sign == 1 ? fixint_max : fixint_min; 30 | 31 | // If 0 <= exponent < significandBits, right shift to get the result. 32 | // Otherwise, shift left. 33 | if (exponent < significandBits) 34 | return sign * (significand >> (significandBits - exponent)); 35 | else 36 | return sign * ((__int128)significand << (exponent - significandBits)); 37 | } 38 | -------------------------------------------------------------------------------- /libraries/builtins/fixunsdfti.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixunsdfti.c - Implement __fixunsdfti -----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | */ 10 | 11 | #include "fp64.h" 12 | 13 | typedef unsigned __int128 fixuint_t; 14 | 15 | fixuint_t ___fixunsdfti(uint64_t a) { 16 | // Break a into sign, exponent, significand 17 | const rep_t aRep = a; 18 | const rep_t aAbs = aRep & absMask; 19 | const int sign = aRep & signBit ? -1 : 1; 20 | const int exponent = (aAbs >> significandBits) - exponentBias; 21 | const rep_t significand = (aAbs & significandMask) | implicitBit; 22 | 23 | // If either the value or the exponent is negative, the result is zero. 24 | if (sign == -1 || exponent < 0) 25 | return 0; 26 | 27 | // If the value is too large for the integer type, saturate. 28 | if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT) 29 | return ~(fixuint_t)0; 30 | 31 | // If 0 <= exponent < significandBits, right shift to get the result. 32 | // Otherwise, shift left. 33 | if (exponent < significandBits) 34 | return significand >> (significandBits - exponent); 35 | else 36 | return (fixuint_t)significand << (exponent - significandBits); 37 | } 38 | -------------------------------------------------------------------------------- /libraries/builtins/fixunssfti.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixunssfti.c - Implement __fixunssfti -----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __fixunssfti for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "fp32.h" 16 | 17 | typedef unsigned __int128 fixuint_t; 18 | 19 | fixuint_t ___fixunssfti(uint32_t a) { 20 | // Break a into sign, exponent, significand 21 | const rep_t aRep = a; 22 | const rep_t aAbs = aRep & absMask; 23 | const int sign = aRep & signBit ? -1 : 1; 24 | const int exponent = (aAbs >> significandBits) - exponentBias; 25 | const rep_t significand = (aAbs & significandMask) | implicitBit; 26 | 27 | // If either the value or the exponent is negative, the result is zero. 28 | if (sign == -1 || exponent < 0) 29 | return 0; 30 | 31 | // If the value is too large for the integer type, saturate. 32 | if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT) 33 | return ~(fixuint_t)0; 34 | 35 | // If 0 <= exponent < significandBits, right shift to get the result. 36 | // Otherwise, shift left. 37 | if (exponent < significandBits) 38 | return significand >> (significandBits - exponent); 39 | else 40 | return (fixuint_t)significand << (exponent - significandBits); 41 | } 42 | -------------------------------------------------------------------------------- /libraries/builtins/fixunstfti.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixunstfsi.c - Implement __fixunstfsi -----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | */ 10 | 11 | #include "fp128.h" 12 | 13 | typedef float128_t fp_t; 14 | typedef unsigned __int128 fixuint_t; 15 | typedef unsigned __int128 tu_int; 16 | typedef __int128 rep_t; 17 | 18 | tu_int ___fixunstfti(fp_t a) { 19 | // Break a into sign, exponent, significand 20 | const rep_t aRep = toRep(a); 21 | const rep_t aAbs = aRep & absMask; 22 | const int sign = aRep & signBit ? -1 : 1; 23 | const int exponent = (aAbs >> significandBits) - exponentBias; 24 | const rep_t significand = (aAbs & significandMask) | implicitBit; 25 | 26 | // If either the value or the exponent is negative, the result is zero. 27 | if (sign == -1 || exponent < 0) 28 | return 0; 29 | 30 | // If the value is too large for the integer type, saturate. 31 | if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT) 32 | return ~(fixuint_t)0; 33 | 34 | // If 0 <= exponent < significandBits, right shift to get the result. 35 | // Otherwise, shift left. 36 | if (exponent < significandBits) 37 | return significand >> (significandBits - exponent); 38 | else 39 | return (fixuint_t)significand << (exponent - significandBits); 40 | } 41 | -------------------------------------------------------------------------------- /libraries/builtins/fp128.h: -------------------------------------------------------------------------------- 1 | #ifndef __compiler_rt_fp_128_h__ 2 | #define __compiler_rt_fp_128_h__ 3 | 4 | #include 5 | #include 6 | #include "../softfloat/source/include/softfloat.h" 7 | 8 | #define REP_C (__uint128_t) 9 | #define significandBits 112 10 | #define typeWidth (sizeof(__int128)*CHAR_BIT) 11 | #define exponentBits (typeWidth - significandBits - 1) 12 | #define maxExponent ((1 << exponentBits) - 1) 13 | #define exponentBias (maxExponent >> 1) 14 | 15 | #define implicitBit (REP_C(1) << significandBits) 16 | #define significandMask (implicitBit - 1U) 17 | #define signBit (REP_C(1) << (significandBits + exponentBits)) 18 | #define absMask (signBit - 1U) 19 | #define exponentMask (absMask ^ significandMask) 20 | #define oneRep ((rep_t)exponentBias << significandBits) 21 | #define infRep exponentMask 22 | #define quietBit (implicitBit >> 1) 23 | #define qnanRep (exponentMask | quietBit) 24 | 25 | static __inline __int128 toRep(float128_t x) { 26 | const union { float128_t f; __int128 i; } rep = {.f = x}; 27 | return rep.i; 28 | } 29 | 30 | #endif //__compiler_rt_fp_h__ 31 | -------------------------------------------------------------------------------- /libraries/builtins/fp32.h: -------------------------------------------------------------------------------- 1 | #ifndef __compiler_rt_fp_32_h__ 2 | #define __compiler_rt_fp_32_h__ 3 | 4 | #include 5 | #include 6 | 7 | typedef uint32_t rep_t; 8 | 9 | #define REP_C (uint32_t) 10 | #define significandBits 23 11 | #define typeWidth (sizeof(rep_t)*CHAR_BIT) 12 | #define exponentBits (typeWidth - significandBits - 1) 13 | #define maxExponent ((1 << exponentBits) - 1) 14 | #define exponentBias (maxExponent >> 1) 15 | 16 | #define implicitBit (REP_C(1) << significandBits) 17 | #define significandMask (implicitBit - 1U) 18 | #define signBit (REP_C(1) << (significandBits + exponentBits)) 19 | #define absMask (signBit - 1U) 20 | #define exponentMask (absMask ^ significandMask) 21 | #define oneRep ((rep_t)exponentBias << significandBits) 22 | #define infRep exponentMask 23 | #define quietBit (implicitBit >> 1) 24 | #define qnanRep (exponentMask | quietBit) 25 | 26 | #endif //__compiler_rt_fp_h__ 27 | -------------------------------------------------------------------------------- /libraries/builtins/fp64.h: -------------------------------------------------------------------------------- 1 | #ifndef __compiler_rt_fp_64_h__ 2 | #define __compiler_rt_fp_64_h__ 3 | 4 | #include 5 | #include 6 | 7 | typedef uint64_t rep_t; 8 | 9 | #define REP_C (uint64_t) 10 | #define significandBits 52 11 | #define typeWidth (sizeof(rep_t)*CHAR_BIT) 12 | #define exponentBits (typeWidth - significandBits - 1) 13 | #define maxExponent ((1 << exponentBits) - 1) 14 | #define exponentBias (maxExponent >> 1) 15 | 16 | #define implicitBit (REP_C(1) << significandBits) 17 | #define significandMask (implicitBit - 1U) 18 | #define signBit (REP_C(1) << (significandBits + exponentBits)) 19 | #define absMask (signBit - 1U) 20 | #define exponentMask (absMask ^ significandMask) 21 | #define oneRep ((rep_t)exponentBias << significandBits) 22 | #define infRep exponentMask 23 | #define quietBit (implicitBit >> 1) 24 | #define qnanRep (exponentMask | quietBit) 25 | 26 | #endif //__compiler_rt_fp_h__ 27 | -------------------------------------------------------------------------------- /libraries/builtins/int_t.h: -------------------------------------------------------------------------------- 1 | #ifndef __compiler_rt_int_t_h__ 2 | #define __compiler_rt_int_t_h__ 3 | #include 4 | #include 5 | 6 | typedef union 7 | { 8 | __int128 all; 9 | struct 10 | { 11 | uint64_t low; 12 | int64_t high; 13 | }s; 14 | } twords; 15 | 16 | typedef union 17 | { 18 | unsigned __int128 all; 19 | struct 20 | { 21 | uint64_t low; 22 | uint64_t high; 23 | }s; 24 | } utwords; 25 | 26 | typedef union 27 | { 28 | uint64_t all; 29 | struct 30 | { 31 | uint32_t low; 32 | uint32_t high; 33 | }s; 34 | } udwords; 35 | 36 | typedef union 37 | { 38 | udwords u; 39 | double f; 40 | } double_bits; 41 | 42 | 43 | typedef __int128 ti_int; 44 | typedef unsigned __int128 tu_int; 45 | inline __int128 __clzti2(__int128 a) 46 | { 47 | twords x; 48 | x.all = a; 49 | const int64_t f = -(x.s.high == 0); 50 | return __builtin_clzll((x.s.high & ~f) | (x.s.low & f)) + 51 | ((int32_t)f & ((int32_t)(sizeof(int64_t) * CHAR_BIT))); 52 | } 53 | 54 | #endif// __compiler_rt_int_t_h__ 55 | -------------------------------------------------------------------------------- /libraries/chain/database.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include "db_balance.cpp" 25 | #include "db_block.cpp" 26 | #include "db_debug.cpp" 27 | #include "db_getter.cpp" 28 | #include "db_init.cpp" 29 | #include "db_notify.cpp" 30 | #include "db_management.cpp" 31 | #include "db_market.cpp" 32 | #include "db_update.cpp" 33 | #include "db_voter.cpp" 34 | #include "db_witness_schedule.cpp" 35 | -------------------------------------------------------------------------------- /libraries/chain/genesis_state.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | // these are required to serialize a genesis_state 28 | #include 29 | 30 | namespace graphene { namespace chain { 31 | 32 | chain_id_type genesis_state_type::compute_chain_id() const 33 | { 34 | return initial_chain_id; 35 | } 36 | 37 | void genesis_state_type::override_witness_signing_keys( const std::string& new_key ) 38 | { 39 | public_key_type new_pubkey( new_key ); 40 | for( auto& wit : initial_witness_candidates ) 41 | { 42 | wit.block_signing_key = new_pubkey; 43 | } 44 | } 45 | 46 | 47 | } } // graphene::chain 48 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/0_1_preamble.hf: -------------------------------------------------------------------------------- 1 | /***************************************** 2 | * * 3 | * This file is automatically generated. * 4 | * To create new hardfork, please modify * 5 | * the .hf files in hardfork.d instead * 6 | * of modifying this file. * 7 | * * 8 | *****************************************/ 9 | 10 | #pragma once 11 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/0_2.hf: -------------------------------------------------------------------------------- 1 | // add create platform op 2 | #ifndef HARDFORK_0_2_TIME 3 | #define HARDFORK_0_2_TIME (fc::time_point_sec( 1519956000 )) //2018-03-02 02:00:00 4 | #endif 5 | 6 | // add partial-operations,max-ops-per-account and account auth platform op 7 | #ifndef HARDFORK_0_2_1_TIME 8 | #define HARDFORK_0_2_1_TIME (fc::time_point_sec( 1521709200 )) //2018-03-22 09:00:00 9 | #endif -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/0_3.hf: -------------------------------------------------------------------------------- 1 | // add create asset op 2 | #ifndef HARDFORK_0_3_TIME 3 | #define HARDFORK_0_3_TIME (fc::time_point_sec( 1530522000 )) //2018-07-02 09:00:00 UTC 4 | #endif 5 | 6 | // add proposal op 7 | #ifndef HARDFORK_0_3_1_TIME 8 | #define HARDFORK_0_3_1_TIME (fc::time_point_sec( 2100000000 )) //2036 9 | #endif 10 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/0_4.hf: -------------------------------------------------------------------------------- 1 | // add content ops 2 | #ifndef HARDFORK_0_4_TIME 3 | #define HARDFORK_0_4_TIME (fc::time_point_sec( 1561852800 )) //1561852800 2019-06-30T08:00:00 UTC 4 | #endif 5 | 6 | 7 | #ifndef HARDFORK_0_5_TIME 8 | #define HARDFORK_0_5_TIME (fc::time_point_sec( 1588204800 )) //1588204800 2020-04-30T08:00:00 UTC 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/3_0.hf: -------------------------------------------------------------------------------- 1 | // add contract support 2 | #ifndef HARDFORK_3_0_TIME 3 | #define HARDFORK_3_0_TIME (fc::time_point_sec( 1631671200 )) //2021-09-15T02:00:00 UTC 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/action.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace chain { 8 | 9 | struct action { 10 | 11 | uint64_t sender; 12 | uint64_t contract_id; 13 | contract_asset amount; 14 | action_name method_name; 15 | bytes data; 16 | 17 | action() {} 18 | 19 | action(uint64_t sender, uint64_t contract_id, action_name name, const bytes& data, const contract_asset &amt = contract_asset{0, 0}) 20 | : sender(sender) 21 | , contract_id(contract_id) 22 | , amount(amt) 23 | , method_name(name) 24 | , data(data) 25 | { 26 | } 27 | }; 28 | 29 | } } /// namespace graphene::chain 30 | 31 | FC_REFLECT(graphene::chain::action, (sender)(contract_id)(amount)(method_name)(data)) 32 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/balance_lock_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace graphene { namespace chain { 12 | 13 | class balance_lock_update_evaluator : public evaluator < balance_lock_update_evaluator > 14 | { 15 | public: 16 | typedef balance_lock_update_operation operation_type; 17 | 18 | void_result do_evaluate(const operation_type& op); 19 | void_result do_apply(const operation_type& op); 20 | 21 | const _account_statistics_object* account_stats = nullptr; 22 | const pledge_balance_object* pledge_balance_obj = nullptr; 23 | }; 24 | 25 | }} // graphene::chain 26 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/chain_property_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | class chain_property_object; 31 | 32 | /** 33 | * Contains invariants which are set at genesis and never changed. 34 | */ 35 | class chain_property_object : public abstract_object 36 | { 37 | public: 38 | static const uint8_t space_id = implementation_ids; 39 | static const uint8_t type_id = impl_chain_property_object_type; 40 | 41 | chain_id_type chain_id; 42 | immutable_chain_parameters immutable_parameters; 43 | }; 44 | 45 | } } 46 | 47 | FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object), 48 | (chain_id) 49 | (immutable_parameters) 50 | ) 51 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/csaf_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | namespace graphene { namespace chain { 10 | 11 | class csaf_collect_evaluator : public evaluator 12 | { 13 | public: 14 | typedef csaf_collect_operation operation_type; 15 | 16 | void_result do_evaluate( const operation_type& o ); 17 | void_result do_apply( const operation_type& o ); 18 | 19 | const _account_statistics_object* from_stats = nullptr; 20 | const _account_statistics_object* to_stats = nullptr; 21 | fc::uint128_t available_coin_seconds=0; 22 | fc::uint128_t collecting_coin_seconds=0; 23 | }; 24 | 25 | class csaf_lease_evaluator : public evaluator 26 | { 27 | public: 28 | typedef csaf_lease_operation operation_type; 29 | 30 | void_result do_evaluate( const operation_type& o ); 31 | object_id_type do_apply( const operation_type& o ); 32 | 33 | const _account_statistics_object* from_stats = nullptr; 34 | const _account_statistics_object* to_stats = nullptr; 35 | const csaf_lease_object* current_lease = nullptr; 36 | share_type delta; 37 | }; 38 | 39 | } } // graphene::chain 40 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/custom_vote_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace graphene { namespace chain { 12 | 13 | class custom_vote_create_evaluator : public evaluator < custom_vote_create_evaluator > 14 | { 15 | public: 16 | typedef custom_vote_create_operation operation_type; 17 | 18 | void_result do_evaluate(const operation_type& op); 19 | object_id_type do_apply(const operation_type& op); 20 | 21 | const _account_statistics_object* account_stats = nullptr; 22 | }; 23 | 24 | class custom_vote_cast_evaluator : public evaluator < custom_vote_cast_evaluator > 25 | { 26 | public: 27 | typedef custom_vote_cast_operation operation_type; 28 | 29 | void_result do_evaluate(const operation_type& op); 30 | void_result do_apply(const operation_type& op); 31 | }; 32 | }} // graphene::chain 33 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/get_config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | fc::variant_object get_config(); 31 | 32 | } } // graphene::chain 33 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | namespace graphene { namespace chain { 33 | 34 | struct immutable_chain_parameters 35 | { 36 | uint16_t min_committee_member_count = GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT; 37 | uint16_t min_witness_count = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT; 38 | uint32_t num_special_accounts = 0; 39 | uint32_t num_special_assets = 0; 40 | }; 41 | 42 | } } // graphene::chain 43 | 44 | FC_REFLECT( graphene::chain::immutable_chain_parameters, 45 | (min_committee_member_count) 46 | (min_witness_count) 47 | (num_special_accounts) 48 | (num_special_assets) 49 | ) 50 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/impacted.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | namespace graphene { namespace chain { 36 | 37 | using namespace graphene::db; 38 | 39 | void operation_get_impacted_account_uids( 40 | const operation& op, 41 | flat_set& result ); 42 | 43 | void transaction_get_impacted_account_uids( 44 | const transaction& tx, 45 | flat_set& result 46 | ); 47 | 48 | void get_relevant_accounts( const object* obj, flat_set& accounts ); 49 | 50 | } } // graphene::app 51 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/multi_index_includes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace bmi = boost::multi_index; 10 | using bmi::indexed_by; 11 | using bmi::ordered_unique; 12 | using bmi::ordered_non_unique; 13 | using bmi::composite_key; 14 | using bmi::member; 15 | using bmi::const_mem_fun; 16 | using bmi::tag; 17 | using bmi::composite_key_compare; 18 | 19 | struct by_id; 20 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/pledge_mining_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #pragma once 5 | #include 6 | #include 7 | 8 | namespace graphene { namespace chain { 9 | 10 | class pledge_mining_update_evaluator : public evaluator < pledge_mining_update_evaluator > 11 | { 12 | public: 13 | typedef pledge_mining_update_operation operation_type; 14 | 15 | void_result do_evaluate(const pledge_mining_update_operation& o); 16 | void_result do_apply(const pledge_mining_update_operation& o); 17 | 18 | const witness_object* witness_obj = nullptr; 19 | const pledge_mining_object* pledge_mining_obj = nullptr; 20 | const _account_statistics_object* account_stats = nullptr; 21 | }; 22 | 23 | class pledge_bonus_collect_evaluator : public evaluator < pledge_bonus_collect_evaluator > 24 | { 25 | public: 26 | typedef pledge_bonus_collect_operation operation_type; 27 | 28 | void_result do_evaluate(const pledge_bonus_collect_operation& o); 29 | void_result do_apply(const pledge_bonus_collect_operation& o); 30 | 31 | const _account_statistics_object* account_stats = nullptr; 32 | }; 33 | 34 | } } // graphene::chain 35 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/README.md: -------------------------------------------------------------------------------- 1 | Protocol Definition 2 | -------------------- 3 | 4 | The classes declared in these headers provide the complete definition of the 5 | Graphene protocol and are organized according to feature. Nothing in this 6 | directory should depend upon anything other than fc or other types defined 7 | in the protocol directory. 8 | 9 | To be more specific, implementation details such as the objects defined in 10 | the object database should not be required here. 11 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/balance_lock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #pragma once 5 | #include 6 | 7 | namespace graphene { namespace chain { 8 | 9 | /** 10 | * @brief Update a account locked balance 11 | * locked balance can produce csaf after HARDFORK_0_5_TIME 12 | * @ingroup operations 13 | */ 14 | struct balance_lock_update_operation : public base_operation 15 | { 16 | struct fee_parameters_type 17 | { 18 | uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION / 10; 19 | uint64_t min_real_fee = 0; 20 | uint16_t min_rf_percent = 0; 21 | extensions_type extensions; 22 | }; 23 | 24 | fee_type fee; 25 | /// The account that lock balance. This account pays the fee for this operation. 26 | account_uid_type account; 27 | 28 | /// The new lock balance 29 | share_type new_lock_balance; 30 | 31 | extensions_type extensions; 32 | 33 | account_uid_type fee_payer_uid()const { return account; } 34 | void validate()const; 35 | void get_required_active_uid_authorities(flat_set& a, bool enabled_hardfork)const 36 | { 37 | // need active authority 38 | a.insert(account); 39 | } 40 | }; 41 | }} // graphene::chain 42 | 43 | 44 | 45 | FC_REFLECT( graphene::chain::balance_lock_update_operation::fee_parameters_type, (fee)(min_real_fee)(min_rf_percent)(extensions)) 46 | FC_REFLECT( graphene::chain::balance_lock_update_operation, (fee)(account)(new_lock_balance)(extensions)) -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/block.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | 30 | struct signed_block : public signed_block_header 31 | { 32 | checksum_type calculate_merkle_root()const; 33 | vector transactions; 34 | }; 35 | 36 | } } // graphene::chain 37 | 38 | FC_REFLECT_DERIVED( graphene::chain::signed_block, (graphene::chain::signed_block_header), (transactions) ) 39 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/protocol/protocol.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | #include 27 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/wasm_constraints.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace IR { 7 | struct Module; 8 | } 9 | 10 | namespace graphene { namespace chain { namespace wasm_constraints { 11 | constexpr unsigned maximum_linear_memory = 33*1024*1024;//bytes 12 | constexpr unsigned maximum_mutable_globals = 1024; //bytes 13 | constexpr unsigned maximum_table_elements = 1024; //elements 14 | constexpr unsigned maximum_section_elements = 1024; //elements 15 | constexpr unsigned maximum_linear_memory_init = 64*1024; //bytes 16 | constexpr unsigned maximum_func_local_bytes = 8192; //bytes 17 | constexpr unsigned maximum_call_depth = 250; //nested calls 18 | constexpr unsigned maximum_code_size = 20*1024*1024; 19 | 20 | static constexpr unsigned wasm_page_size = 64*1024; 21 | 22 | static_assert(maximum_linear_memory%wasm_page_size == 0, "maximum_linear_memory must be mulitple of wasm page size"); 23 | static_assert(maximum_mutable_globals%4 == 0, "maximum_mutable_globals must be mulitple of 4"); 24 | static_assert(maximum_table_elements*8%4096 == 0, "maximum_table_elements*8 must be mulitple of 4096"); 25 | static_assert(maximum_linear_memory_init%wasm_page_size == 0, "maximum_linear_memory_init must be mulitple of wasm page size"); 26 | static_assert(maximum_func_local_bytes%8 == 0, "maximum_func_local_bytes must be mulitple of 8"); 27 | static_assert(maximum_func_local_bytes>32 , "maximum_func_local_bytes must be greater than 32"); 28 | } // namespace wasm_constraints 29 | 30 | }} // namespace graphene, chain 31 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/wast_to_wasm.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace graphene { namespace chain { 6 | 7 | std::vector wast_to_wasm( const std::string& wast ); 8 | std::string wasm_to_wast( const std::vector& wasm ); 9 | std::string wasm_to_wast( const uint8_t* data, uint64_t size ); 10 | 11 | } } /// graphene::chain 12 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/webassembly/runtime_interface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace graphene { namespace chain { 6 | 7 | class apply_context; 8 | 9 | class wasm_instantiated_module_interface { 10 | public: 11 | virtual void apply(apply_context& context) = 0; 12 | 13 | virtual ~wasm_instantiated_module_interface(); 14 | }; 15 | 16 | class wasm_runtime_interface { 17 | public: 18 | virtual std::unique_ptr instantiate_module(const char* code_bytes, size_t code_size, std::vector initial_memory) = 0; 19 | 20 | virtual ~wasm_runtime_interface(); 21 | }; 22 | 23 | }} 24 | -------------------------------------------------------------------------------- /libraries/chain/index.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace chain { 29 | void base_primary_index::save_undo( const object& obj ) 30 | { _db.save_undo( obj ); } 31 | 32 | void base_primary_index::on_add( const object& obj ) 33 | { 34 | _db.save_undo_add( obj ); 35 | for( auto ob : _observers ) ob->on_add( obj ); 36 | } 37 | 38 | void base_primary_index::on_remove( const object& obj ) 39 | { _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); } 40 | 41 | void base_primary_index::on_modify( const object& obj ) 42 | {for( auto ob : _observers ) ob->on_modify( obj ); } 43 | } } // graphene::chain 44 | -------------------------------------------------------------------------------- /libraries/chain/name.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace chain { 8 | 9 | void name::set( const char* str ) { 10 | const auto len = strnlen(str, 14); 11 | GRAPHENE_ASSERT(len <= 13, name_type_exception, "Name is longer than 13 characters (${name}) ", ("name", string(str))); 12 | value = string_to_name(str); 13 | GRAPHENE_ASSERT(to_string() == string(str), name_type_exception, 14 | "Name not properly normalized (name: ${name}, normalized: ${normalized}) ", 15 | ("name", string(str))("normalized", to_string())); 16 | } 17 | 18 | // keep in sync with name::to_string() in contract definition for name 19 | name::operator string()const { 20 | static const char* charmap = ".12345abcdefghijklmnopqrstuvwxyz"; 21 | 22 | string str(13,'.'); 23 | 24 | uint64_t tmp = value; 25 | for( uint32_t i = 0; i <= 12; ++i ) { 26 | char c = charmap[tmp & (i == 0 ? 0x0f : 0x1f)]; 27 | str[12-i] = c; 28 | tmp >>= (i == 0 ? 4 : 5); 29 | } 30 | 31 | boost::algorithm::trim_right_if( str, []( char c ){ return c == '.'; } ); 32 | return str; 33 | } 34 | 35 | } } /// graphene::chain 36 | 37 | namespace fc { 38 | void to_variant(const graphene::chain::name& c, fc::variant& v, uint32_t max_depth) { v = std::string(c); } 39 | void from_variant(const fc::variant& v, graphene::chain::name& check, uint32_t max_deptht) { check = v.get_string(); } 40 | } // fc 41 | -------------------------------------------------------------------------------- /libraries/chain/protocol/authority.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | namespace graphene { namespace chain { 28 | 29 | void add_authority_account_uids( 30 | flat_set& result, 31 | const authority& a 32 | ) 33 | { 34 | for( auto& item : a.account_uid_auths ) 35 | result.insert( item.first.uid ); 36 | } 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /libraries/chain/protocol/balance_lock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #include 5 | 6 | #include "../utf8/checked.h" 7 | 8 | namespace graphene { namespace chain { 9 | 10 | void balance_lock_update_operation::validate()const 11 | { 12 | validate_op_fee(fee, "balance_lock_update"); 13 | validate_account_uid(account, "lock balance account"); 14 | validate_non_negative_amount(new_lock_balance, " new lock balance amount"); 15 | FC_ASSERT(!extensions.valid(), "extension is currently not allowed"); 16 | } 17 | 18 | } } // graphene::chain 19 | -------------------------------------------------------------------------------- /libraries/chain/protocol/csaf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | void csaf_collect_operation::validate()const 9 | { 10 | validate_op_fee( fee, "csaf collect operation " ); 11 | validate_account_uid( from, "from " ); 12 | validate_account_uid( to, "to " ); 13 | validate_positive_core_asset( amount, "csaf collect amount" ); 14 | FC_ASSERT( time.sec_since_epoch() % 60 == 0, "time should be rounded down to nearest minute" ); 15 | } 16 | 17 | void csaf_lease_operation::validate()const 18 | { 19 | validate_op_fee( fee, "csaf lease operation " ); 20 | validate_account_uid( from, "from " ); 21 | validate_account_uid( to, "to " ); 22 | validate_non_negative_core_asset( amount, "csaf lease amount" ); 23 | FC_ASSERT( from != to, "can not lease to self." ); 24 | } 25 | 26 | 27 | 28 | } } // graphene::chain 29 | -------------------------------------------------------------------------------- /libraries/chain/protocol/custom_vote.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #include 5 | 6 | #include "../utf8/checked.h" 7 | 8 | namespace graphene { namespace chain { 9 | 10 | void custom_vote_create_operation::validate()const 11 | { 12 | validate_op_fee(fee, "custom_vote_create"); 13 | validate_account_uid(custom_vote_creator, "create_account"); 14 | 15 | FC_ASSERT(options.size() > 1 && options.size() < 256, "options size should more than 1 and less than 256"); 16 | FC_ASSERT(minimum_selected_items <= maximum_selected_items, 17 | "maximum selected items must be greater than or equal to minimum selected items"); 18 | FC_ASSERT(minimum_selected_items > 0, "minimum selected items must be greater than 0"); 19 | FC_ASSERT(maximum_selected_items < options.size(), "maximum selected items must be less than options size"); 20 | FC_ASSERT(required_asset_amount > 0, "required vote asset amount must be grater than 0"); 21 | FC_ASSERT(!extensions.valid(), "extension is currently not allowed"); 22 | } 23 | 24 | share_type custom_vote_create_operation::calculate_fee(const fee_parameters_type& k)const 25 | { 26 | share_type core_fee_required = k.fee; 27 | auto size = fc::raw::pack_size(description); 28 | size += fc::raw::pack_size(title); 29 | size += fc::raw::pack_size(options); 30 | core_fee_required += calculate_data_fee(size, k.price_per_kbyte); 31 | return core_fee_required; 32 | } 33 | 34 | void custom_vote_cast_operation::validate()const 35 | { 36 | FC_ASSERT(vote_result.size() > 0, "options size should more than 0"); 37 | validate_op_fee(fee, "custom_vote_cast "); 38 | validate_account_uid(voter, "voter"); 39 | FC_ASSERT(!extensions.valid(), "extension is currently not allowed"); 40 | } 41 | 42 | share_type custom_vote_cast_operation::calculate_fee(const fee_parameters_type& k)const 43 | { 44 | share_type core_fee_required = k.fee; 45 | return core_fee_required; 46 | } 47 | 48 | } } // graphene::chain 49 | -------------------------------------------------------------------------------- /libraries/chain/protocol/pledge_mining.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, YOYOW Foundation PTE. LTD. and contributors. 3 | */ 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | void pledge_mining_update_operation::validate() const 9 | { 10 | validate_op_fee(fee, "account pledge update"); 11 | validate_account_uid(pledge_account, "pledge account "); 12 | validate_account_uid(witness, "witness"); 13 | validate_non_negative_amount(new_pledge, " new pledge amount"); 14 | FC_ASSERT(pledge_account != witness, "witness pledge mining to oneself is not allowed"); 15 | FC_ASSERT(!extensions.valid(), "extension is currently not allowed"); 16 | } 17 | 18 | void pledge_bonus_collect_operation::validate() const 19 | { 20 | validate_op_fee(fee, "pledge bonus collecting "); 21 | validate_account_uid(account, "pledge account "); 22 | validate_positive_core_asset(bonus, "bonus"); 23 | FC_ASSERT(!extensions.valid(), "extension is currently not allowed"); 24 | } 25 | 26 | } } // graphene::chain 27 | -------------------------------------------------------------------------------- /libraries/chain/utf8/ReleaseNotes: -------------------------------------------------------------------------------- 1 | utf8 cpp library 2 | Release 2.3.4 3 | 4 | A minor bug fix release. Thanks to all who reported bugs. 5 | 6 | Note: Version 2.3.3 contained a regression, and therefore was removed. 7 | 8 | Changes from version 2.3.2 9 | - Bug fix [39]: checked.h Line 273 and unchecked.h Line 182 have an extra ';' 10 | - Bug fix [36]: replace_invalid() only works with back_inserter 11 | 12 | Files included in the release: utf8.h, core.h, checked.h, unchecked.h, utf8cpp.html, ReleaseNotes 13 | -------------------------------------------------------------------------------- /libraries/custom_files/file_mapping.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | namespace fc { 7 | 8 | 9 | file_mapping::file_mapping( const char* file, fm_mode_t m ) : 10 | my(file, m == read_only ? boost::interprocess::read_only : boost::interprocess::read_write ) 11 | {} 12 | 13 | file_mapping::~file_mapping() {} 14 | 15 | 16 | 17 | mapped_region::mapped_region( const file_mapping& fm, fm_mode_t m, uint64_t start, size_t size ) : 18 | my( *fm.my, m == read_only ? boost::interprocess::read_only : boost::interprocess::read_write ,start, size) 19 | {} 20 | 21 | mapped_region::mapped_region( const file_mapping& fm, fm_mode_t m ) : 22 | my( *fm.my, m == read_only ? boost::interprocess::read_only : boost::interprocess::read_write) 23 | {} 24 | 25 | mapped_region::~mapped_region(){} 26 | 27 | void* mapped_region::get_address() const 28 | { 29 | return my->get_address(); 30 | } 31 | 32 | void mapped_region::flush() 33 | { 34 | my->flush(); 35 | } 36 | 37 | size_t mapped_region::get_size() const 38 | { 39 | return my->get_size(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /libraries/custom_files/file_mapping.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace boost { 7 | namespace interprocess { 8 | class file_mapping; 9 | class mapped_region; 10 | } 11 | } 12 | namespace fc { 13 | enum fm_mode_t { 14 | read_only, 15 | write_only, 16 | read_write 17 | }; 18 | 19 | class file_mapping { 20 | public: 21 | file_mapping( const char* file, fm_mode_t ); 22 | ~file_mapping(); 23 | private: 24 | friend class mapped_region; 25 | #ifdef _WIN64 26 | fc::fwd my; 27 | #else 28 | fc::fwd my; 29 | #endif 30 | }; 31 | 32 | class mapped_region { 33 | public: 34 | mapped_region( const file_mapping& fm, fm_mode_t m, uint64_t start, size_t size ); 35 | mapped_region( const file_mapping& fm, fm_mode_t m ); 36 | ~mapped_region(); 37 | void flush(); 38 | void* get_address()const; 39 | size_t get_size()const; 40 | private: 41 | fc::fwd my; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /libraries/custom_files/scoped_exit.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc { 4 | 5 | template 6 | class scoped_exit { 7 | public: 8 | template 9 | scoped_exit( C&& c ):callback( std::forward(c) ){} 10 | scoped_exit( scoped_exit&& mv ):callback( std::move( mv.callback ) ){} 11 | 12 | ~scoped_exit() { 13 | try { callback(); } catch( ... ) {} 14 | } 15 | 16 | scoped_exit& operator = ( scoped_exit&& mv ) { 17 | callback = std::move(mv); 18 | return *this; 19 | } 20 | private: 21 | scoped_exit( const scoped_exit& ); 22 | scoped_exit& operator=( const scoped_exit& ); 23 | 24 | Callback callback; 25 | }; 26 | 27 | template 28 | scoped_exit make_scoped_exit( Callback&& c ) { 29 | return scoped_exit( std::forward(c) ); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /libraries/db/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/db/*.hpp") 2 | add_library( graphene_db undo_database.cpp index.cpp object_database.cpp ${HEADERS} ) 3 | target_link_libraries( graphene_db fc ) 4 | target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 5 | 6 | install( TARGETS 7 | graphene_db 8 | 9 | RUNTIME DESTINATION bin 10 | LIBRARY DESTINATION lib 11 | ARCHIVE DESTINATION lib 12 | ) 13 | install( FILES ${HEADERS} DESTINATION "include/graphene/db" ) 14 | -------------------------------------------------------------------------------- /libraries/db/include/graphene/db/fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace db { 28 | 29 | class peer; 30 | typedef std::shared_ptr peer_ptr; 31 | 32 | class peer_ram; 33 | typedef std::shared_ptr peer_ram_ptr; 34 | 35 | }} // namespace graphene::db 36 | -------------------------------------------------------------------------------- /libraries/db/index.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | #include 26 | #include 27 | 28 | namespace graphene { namespace db { 29 | void base_primary_index::save_undo( const object& obj ) 30 | { _db.save_undo( obj ); } 31 | 32 | void base_primary_index::on_add( const object& obj ) 33 | { 34 | _db.save_undo_add( obj ); 35 | for( auto ob : _observers ) ob->on_add( obj ); 36 | } 37 | 38 | void base_primary_index::on_remove( const object& obj ) 39 | { _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); } 40 | 41 | void base_primary_index::on_modify( const object& obj ) 42 | {for( auto ob : _observers ) ob->on_modify( obj ); } 43 | } } // graphene::chain 44 | -------------------------------------------------------------------------------- /libraries/deterministic_openssl_rand/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file(GLOB headers "include/graphene/utilities/*.hpp") 3 | 4 | set(sources deterministic_openssl_rand.cpp 5 | ${headers}) 6 | 7 | add_library( deterministic_openssl_rand 8 | ${sources} 9 | ${HEADERS} ) 10 | target_link_libraries( deterministic_openssl_rand fc ) 11 | target_include_directories( deterministic_openssl_rand 12 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 13 | "${CMAKE_CURRENT_SOURCE_DIR}/../blockchain/include" 14 | ) 15 | 16 | if (USE_PCH) 17 | set_target_properties(deterministic_openssl_rand PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 18 | cotire(deterministic_openssl_rand) 19 | endif(USE_PCH) 20 | 21 | install( TARGETS 22 | deterministic_openssl_rand 23 | 24 | RUNTIME DESTINATION bin 25 | LIBRARY DESTINATION lib 26 | ARCHIVE DESTINATION lib 27 | ) 28 | install( FILES ${headers} DESTINATION "include/graphene/deterministic_openssl_rand" ) 29 | -------------------------------------------------------------------------------- /libraries/deterministic_openssl_rand/include/graphene/utilities/deterministic_openssl_rand.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace utilities { 28 | 29 | void set_random_seed_for_testing(const fc::sha512& new_seed); 30 | 31 | } } // end namespace graphene::utilities 32 | -------------------------------------------------------------------------------- /libraries/egenesis/egenesis_brief.cpp.tmpl: -------------------------------------------------------------------------------- 1 | ${generated_file_banner} 2 | /* 3 | * Copyright (c) 2015, Cryptonomex, Inc. 4 | * All rights reserved. 5 | * 6 | * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and 7 | * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted until September 8, 2015, provided that the following conditions are met: 9 | * 10 | * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. 11 | * 12 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 13 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 14 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 15 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 17 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace graphene { namespace egenesis { 24 | 25 | using namespace graphene::chain; 26 | 27 | chain_id_type get_egenesis_chain_id() 28 | { 29 | return chain_id_type( "${chain_id}" ); 30 | } 31 | 32 | void compute_egenesis_json( std::string& result ) 33 | { 34 | result = ""; 35 | } 36 | 37 | fc::sha256 get_egenesis_json_hash() 38 | { 39 | return fc::sha256( "${genesis_json_hash}" ); 40 | } 41 | 42 | } } 43 | -------------------------------------------------------------------------------- /libraries/egenesis/egenesis_none.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | namespace graphene { namespace egenesis { 28 | 29 | using namespace graphene::chain; 30 | 31 | chain_id_type get_egenesis_chain_id() 32 | { 33 | return chain_id_type(); 34 | } 35 | 36 | void compute_egenesis_json( std::string& result ) 37 | { 38 | result = ""; 39 | } 40 | 41 | fc::sha256 get_egenesis_json_hash() 42 | { 43 | return fc::sha256::hash( "" ); 44 | } 45 | 46 | } } 47 | -------------------------------------------------------------------------------- /libraries/egenesis/include/graphene/egenesis/egenesis.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace graphene { namespace egenesis { 34 | 35 | /** 36 | * Get the chain ID of the built-in egenesis, or chain_id_type() 37 | * if none was compiled in. 38 | */ 39 | graphene::chain::chain_id_type get_egenesis_chain_id(); 40 | 41 | /** 42 | * Get the egenesis JSON, or the empty string if none was compiled in. 43 | */ 44 | void compute_egenesis_json( std::string& result ); 45 | 46 | /** 47 | * The file returned by compute_egenesis_json() should have this hash. 48 | */ 49 | fc::sha256 get_egenesis_json_hash(); 50 | 51 | } } // graphene::egenesis 52 | -------------------------------------------------------------------------------- /libraries/net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/net/*.hpp") 2 | 3 | set(SOURCES node.cpp 4 | stcp_socket.cpp 5 | core_messages.cpp 6 | exceptions.cpp 7 | peer_database.cpp 8 | peer_connection.cpp 9 | message_oriented_connection.cpp) 10 | 11 | add_library( graphene_net ${SOURCES} ${HEADERS} ) 12 | 13 | target_link_libraries( graphene_net 14 | PUBLIC fc graphene_db ) 15 | target_include_directories( graphene_net 16 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 17 | PRIVATE "${CMAKE_SOURCE_DIR}/libraries/chain/include" 18 | ) 19 | 20 | if(MSVC) 21 | set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 22 | endif(MSVC) 23 | 24 | if (USE_PCH) 25 | set_target_properties(graphene_net PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 26 | cotire(graphene_net) 27 | endif(USE_PCH) 28 | 29 | install( TARGETS 30 | graphene_net 31 | 32 | RUNTIME DESTINATION bin 33 | LIBRARY DESTINATION lib 34 | ARCHIVE DESTINATION lib 35 | ) 36 | install( FILES ${HEADERS} DESTINATION "include/graphene/net" ) 37 | -------------------------------------------------------------------------------- /libraries/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( witness ) 2 | add_subdirectory( account_history ) 3 | add_subdirectory( market_history ) 4 | #add_subdirectory( delayed_node ) 5 | add_subdirectory( debug_witness ) 6 | add_subdirectory( non_consensus ) 7 | -------------------------------------------------------------------------------- /libraries/plugins/account_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/account_history/*.hpp") 2 | 3 | add_library( graphene_account_history 4 | account_history_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_account_history graphene_chain graphene_app ) 8 | target_include_directories( graphene_account_history 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( account_history_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | install( TARGETS 16 | graphene_account_history 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/account_history" ) 23 | 24 | -------------------------------------------------------------------------------- /libraries/plugins/debug_witness/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/debug_witness/*.hpp") 2 | 3 | add_library( graphene_debug_witness 4 | debug_api.cpp 5 | debug_witness.cpp 6 | ) 7 | 8 | target_link_libraries( graphene_debug_witness graphene_chain graphene_app ) 9 | target_include_directories( graphene_debug_witness 10 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 11 | 12 | install( TARGETS 13 | graphene_debug_witness 14 | 15 | RUNTIME DESTINATION bin 16 | LIBRARY DESTINATION lib 17 | ARCHIVE DESTINATION lib 18 | ) 19 | -------------------------------------------------------------------------------- /libraries/plugins/delayed_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/delayed_node/*.hpp") 2 | 3 | add_library( graphene_delayed_node 4 | delayed_node_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_delayed_node graphene_chain graphene_app ) 8 | target_include_directories( graphene_delayed_node 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | if(MSVC) 12 | set_source_files_properties( delayed_node_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 13 | endif(MSVC) 14 | 15 | install( TARGETS 16 | graphene_delayed_node 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /libraries/plugins/market_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/market_history/*.hpp") 2 | 3 | add_library( graphene_market_history 4 | market_history_plugin.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( graphene_market_history graphene_chain graphene_app ) 9 | target_include_directories( graphene_market_history 10 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 11 | 12 | if(MSVC) 13 | set_source_files_properties( market_history_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 14 | endif(MSVC) 15 | 16 | install( TARGETS 17 | graphene_market_history 18 | 19 | RUNTIME DESTINATION bin 20 | LIBRARY DESTINATION lib 21 | ARCHIVE DESTINATION lib 22 | ) 23 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/market_history" ) 24 | 25 | -------------------------------------------------------------------------------- /libraries/plugins/non_consensus/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/non_consensus/*.hpp") 2 | 3 | add_library( graphene_non_consensus 4 | non_consensus_plugin.cpp 5 | ${HEADERS} 6 | ) 7 | 8 | target_link_libraries( graphene_non_consensus graphene_chain graphene_app ) 9 | target_include_directories( graphene_non_consensus 10 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 11 | 12 | if(MSVC) 13 | set_source_files_properties( graphene_non_consensus.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 14 | endif(MSVC) 15 | 16 | install( TARGETS 17 | graphene_non_consensus 18 | 19 | RUNTIME DESTINATION bin 20 | LIBRARY DESTINATION lib 21 | ARCHIVE DESTINATION lib 22 | ) 23 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/graphene_non_consensus" ) 24 | 25 | -------------------------------------------------------------------------------- /libraries/plugins/witness/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/witness/*.hpp") 2 | 3 | add_library( graphene_witness 4 | witness.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_witness graphene_chain graphene_app ) 8 | target_include_directories( graphene_witness 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | install( TARGETS 12 | graphene_witness 13 | 14 | RUNTIME DESTINATION bin 15 | LIBRARY DESTINATION lib 16 | ARCHIVE DESTINATION lib 17 | ) 18 | -------------------------------------------------------------------------------- /libraries/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/libraries/fc/GitVersionGen" ) 2 | include( GetGitRevisionDescription ) 3 | get_git_head_revision(GIT_REFSPEC GRAPHENE_GIT_REVISION_SHA) 4 | get_git_unix_timestamp(GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP) 5 | git_describe(GRAPHENE_GIT_REVISION_DESCRIPTION --tags) 6 | if(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 7 | set(GRAPHENE_GIT_REVISION_DESCRIPTION "unknown") 8 | endif(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 9 | 10 | file(GLOB HEADERS "include/graphene/utilities/*.hpp") 11 | 12 | set(sources 13 | key_conversion.cpp 14 | string_escape.cpp 15 | tempdir.cpp 16 | words.cpp 17 | ${HEADERS}) 18 | 19 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) 20 | list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") 21 | 22 | add_library( graphene_utilities 23 | ${sources} 24 | ${HEADERS} ) 25 | target_link_libraries( graphene_utilities fc ) 26 | target_include_directories( graphene_utilities 27 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 28 | if (USE_PCH) 29 | set_target_properties(graphene_utilities PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 30 | cotire(graphene_utilities) 31 | endif(USE_PCH) 32 | 33 | install( TARGETS 34 | graphene_utilities 35 | 36 | RUNTIME DESTINATION bin 37 | LIBRARY DESTINATION lib 38 | ARCHIVE DESTINATION lib 39 | ) 40 | install( FILES ${HEADERS} DESTINATION "include/graphene/utilities" ) 41 | -------------------------------------------------------------------------------- /libraries/utilities/git_revision.cpp.in: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define GRAPHENE_GIT_REVISION_SHA "@GRAPHENE_GIT_REVISION_SHA@" 5 | #define GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP @GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP@ 6 | #define GRAPHENE_GIT_REVISION_DESCRIPTION "@GRAPHENE_GIT_REVISION_DESCRIPTION@" 7 | 8 | namespace graphene { namespace utilities { 9 | 10 | const char* const git_revision_sha = GRAPHENE_GIT_REVISION_SHA; 11 | const uint32_t git_revision_unix_timestamp = GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP; 12 | const char* const git_revision_description = GRAPHENE_GIT_REVISION_DESCRIPTION; 13 | 14 | } } // end namespace graphene::utilities 15 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/git_revision.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | 27 | namespace graphene { namespace utilities { 28 | 29 | extern const char* const git_revision_sha; 30 | extern const uint32_t git_revision_unix_timestamp; 31 | extern const char* const git_revision_description; 32 | 33 | } } // end namespace graphene::utilities 34 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/key_conversion.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace graphene { namespace utilities { 31 | 32 | std::string key_to_wif(const fc::sha256& private_secret ); 33 | std::string key_to_wif(const fc::ecc::private_key& key); 34 | fc::optional wif_to_key( const std::string& wif_key ); 35 | 36 | } } // end namespace graphene::utilities 37 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/string_escape.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { namespace utilities { 29 | 30 | std::string escape_string_for_c_source_code(const std::string& input); 31 | 32 | bool is_number(const std::string& s); 33 | 34 | } } // end namespace graphene::utilities 35 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/tempdir.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | 30 | namespace graphene { namespace utilities { 31 | 32 | fc::path temp_directory_path(); 33 | 34 | } } // graphene::utilities 35 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/words.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | namespace graphene { namespace words { 27 | 28 | typedef const char* const_char_ptr; 29 | extern const const_char_ptr word_list[]; 30 | extern const uint32_t word_list_size; 31 | 32 | } } 33 | -------------------------------------------------------------------------------- /libraries/utilities/tempdir.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | #include 28 | 29 | namespace graphene { namespace utilities { 30 | 31 | fc::path temp_directory_path() 32 | { 33 | const char* graphene_tempdir = getenv("GRAPHENE_TEMPDIR"); 34 | if( graphene_tempdir != nullptr ) 35 | return fc::path( graphene_tempdir ); 36 | return fc::temp_directory_path() / "graphene-tmp"; 37 | } 38 | 39 | } } // graphene::utilities 40 | -------------------------------------------------------------------------------- /libraries/wasm-jit/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: c++ 4 | compiler: 5 | - clang 6 | - gcc 7 | 8 | install: 9 | - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi 10 | - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" != "osx" ]; then export CXX="clang++-3.8" CC="clang-3.8"; fi 11 | 12 | script: ./travis-build.sh 13 | 14 | os: 15 | - linux 16 | - osx 17 | 18 | matrix: 19 | exclude: 20 | - os: osx 21 | compiler: gcc 22 | 23 | addons: 24 | apt: 25 | sources: 26 | - llvm-toolchain-precise-3.8 27 | - ubuntu-toolchain-r-test 28 | packages: 29 | - gcc-5 30 | - g++-5 31 | - libedit-dev 32 | - clang-3.8 -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/Emscripten/Emscripten.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef EMSCRIPTEN_API 4 | #define EMSCRIPTEN_API DLL_IMPORT 5 | #endif 6 | 7 | #include 8 | 9 | namespace IR { struct Module; } 10 | namespace Runtime { struct ModuleInstance; } 11 | 12 | namespace Emscripten 13 | { 14 | EMSCRIPTEN_API void initInstance(const IR::Module& module,Runtime::ModuleInstance* moduleInstance); 15 | EMSCRIPTEN_API void injectCommandArgs(const std::vector& argStrings,std::vector& outInvokeArgs); 16 | } -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/IR/IR.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Platform/Platform.h" 4 | 5 | #ifndef IR_API 6 | #define IR_API DLL_IMPORT 7 | #endif 8 | 9 | namespace IR 10 | { 11 | enum { maxMemoryPages = (Uptr)65536 }; 12 | enum { numBytesPerPage = (Uptr)65536 }; 13 | enum { numBytesPerPageLog2 = (Uptr)16 }; 14 | 15 | enum { requireSharedFlagForAtomicOperators = false }; 16 | } 17 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/IR/Validate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IR.h" 4 | #include "IR/Operators.h" 5 | 6 | #include 7 | 8 | namespace IR 9 | { 10 | struct Module; 11 | struct FunctionDef; 12 | 13 | struct ValidationException 14 | { 15 | std::string message; 16 | ValidationException(std::string&& inMessage): message(inMessage) {} 17 | }; 18 | 19 | struct CodeValidationStreamImpl; 20 | 21 | struct CodeValidationStream 22 | { 23 | IR_API CodeValidationStream(const Module& module,const FunctionDef& function); 24 | IR_API ~CodeValidationStream(); 25 | 26 | IR_API void finish(); 27 | 28 | #define VISIT_OPCODE(_,name,nameString,Imm,...) IR_API void name(Imm imm = {}); 29 | ENUM_OPERATORS(VISIT_OPCODE) 30 | #undef VISIT_OPCODE 31 | 32 | private: 33 | CodeValidationStreamImpl* impl; 34 | }; 35 | 36 | template 37 | struct CodeValidationProxyStream 38 | { 39 | CodeValidationProxyStream(const Module& module,const FunctionDef& function,InnerStream& inInnerStream) 40 | : codeValidationStream(module,function) 41 | , innerStream(inInnerStream) 42 | {} 43 | 44 | void finishValidation() { codeValidationStream.finish(); } 45 | 46 | #define VISIT_OPCODE(_,name,nameString,Imm,...) \ 47 | void name(Imm imm = {}) \ 48 | { \ 49 | codeValidationStream.name(imm); \ 50 | innerStream.name(imm); \ 51 | } 52 | ENUM_OPERATORS(VISIT_OPCODE) 53 | #undef VISIT_OPCODE 54 | 55 | private: 56 | 57 | CodeValidationStream codeValidationStream; 58 | InnerStream& innerStream; 59 | }; 60 | 61 | IR_API void validateDefinitions(const IR::Module& module); 62 | } 63 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/Inline/BasicTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | typedef uint8_t U8; 6 | typedef int8_t I8; 7 | typedef uint16_t U16; 8 | typedef int16_t I16; 9 | typedef uint32_t U32; 10 | typedef int32_t I32; 11 | typedef uint64_t U64; 12 | typedef int64_t I64; 13 | typedef float F32; 14 | typedef double F64; 15 | 16 | // The OSX libc defines uintptr_t to be a long where U32/U64 are int. This causes uintptr_t/uint64 to be treated as distinct types for e.g. overloading. 17 | // Work around it by defining our own Uptr/Iptr that are always int type. 18 | template 19 | struct PointerIntHelper; 20 | template<> struct PointerIntHelper<4> { typedef I32 IntType; typedef U32 UnsignedIntType; }; 21 | template<> struct PointerIntHelper<8> { typedef I64 IntType; typedef U64 UnsignedIntType; }; 22 | typedef PointerIntHelper::UnsignedIntType Uptr; 23 | typedef PointerIntHelper::IntType Iptr; 24 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/Inline/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PublicHeaders 2 | BasicTypes.h 3 | DenseStaticIntSet.h 4 | Errors.h 5 | Floats.h 6 | Serialization.h 7 | Timing.h 8 | UTF8.h) 9 | add_custom_target(Inline SOURCES ${PublicHeaders}) 10 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/Inline/Errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Errors 10 | { 11 | // Fatal error handling. 12 | [[noreturn]] inline void fatalf(const char* messageFormat,...) 13 | { 14 | va_list varArgs; 15 | va_start(varArgs,messageFormat); 16 | std::vfprintf(stderr,messageFormat,varArgs); 17 | std::fflush(stderr); 18 | va_end(varArgs); 19 | std::abort(); 20 | } 21 | [[noreturn]] inline void fatal(const char* message) { fatalf("%s\n",message); } 22 | [[noreturn]] inline void unreachable() { fatalf("reached unreachable code\n"); } 23 | [[noreturn]] inline void unimplemented(const char* context) { fatalf("unimplemented: %s\n",context); } 24 | } 25 | 26 | // Like assert, but is never removed in any build configuration. 27 | #define errorUnless(condition) if(!(condition)) { Errors::fatalf("errorUnless(%s) failed\n",#condition); } 28 | 29 | #define WAVM_ASSERT_THROW(cond) ({ if( !(cond) ) throw std::runtime_error{"wavm assert: " #cond}; }) 30 | 31 | #define WAVM_ASSERT_TERMINATE(cond) ({ if( !(cond) ) { fprintf(stderr, "wavm assert in destructor: %s", #cond); std::terminate(); } }) 32 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/Inline/Timing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Logging/Logging.h" 6 | 7 | namespace Timing 8 | { 9 | // Encapsulates a timer that starts when constructed and stops when read. 10 | struct Timer 11 | { 12 | Timer(): startTime(std::chrono::high_resolution_clock::now()), isStopped(false) {} 13 | void stop() { endTime = std::chrono::high_resolution_clock::now(); } 14 | U64 getMicroseconds() 15 | { 16 | if(!isStopped) { stop(); } 17 | return std::chrono::duration_cast(endTime - startTime).count(); 18 | } 19 | F64 getMilliseconds() { return getMicroseconds() / 1000.0; } 20 | F64 getSeconds() { return getMicroseconds() / 1000000.0; } 21 | private: 22 | std::chrono::high_resolution_clock::time_point startTime; 23 | std::chrono::high_resolution_clock::time_point endTime; 24 | bool isStopped; 25 | }; 26 | 27 | // Helpers for printing timers. 28 | inline void logTimer(const char* context,Timer& timer) { Log::printf(Log::Category::metrics,"%s in %.2fms\n",context,timer.getMilliseconds()); } 29 | inline void logRatePerSecond(const char* context,Timer& timer,F64 numerator,const char* numeratorUnit) 30 | { 31 | Log::printf(Log::Category::metrics,"%s in %.2fms (%f %s/s)\n", 32 | context, 33 | timer.getMilliseconds(), 34 | numerator / timer.getSeconds(), 35 | numeratorUnit 36 | ); 37 | } 38 | } -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/Logging/Logging.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef LOGGING_API 4 | #define LOGGING_API DLL_IMPORT 5 | #endif 6 | 7 | #include "Inline/BasicTypes.h" 8 | #include "Platform/Platform.h" 9 | 10 | // Debug logging. 11 | namespace Log 12 | { 13 | // Allow filtering the logging by category. 14 | enum class Category 15 | { 16 | error, 17 | debug, 18 | metrics, 19 | num 20 | }; 21 | LOGGING_API void setCategoryEnabled(Category category,bool enable); 22 | LOGGING_API bool isCategoryEnabled(Category category); 23 | 24 | // Print some categorized, formatted string, and flush the output. Newline is not included. 25 | LOGGING_API void printf(Category category,const char* format,...); 26 | }; -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/WASM/WASM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef WEBASSEMBLY_API 4 | #define WEBASSEMBLY_API DLL_IMPORT 5 | #endif 6 | 7 | #include "Inline/BasicTypes.h" 8 | 9 | namespace IR { struct Module; struct DisassemblyNames; } 10 | namespace Serialization { struct InputStream; struct OutputStream; } 11 | 12 | namespace WASM 13 | { 14 | WEBASSEMBLY_API void serialize(Serialization::InputStream& stream,IR::Module& module); 15 | WEBASSEMBLY_API void serialize(Serialization::OutputStream& stream,const IR::Module& module); 16 | } 17 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Include/WAST/WAST.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef WAST_API 4 | #define WAST_API DLL_IMPORT 5 | #endif 6 | 7 | #include "Inline/BasicTypes.h" 8 | #include "Runtime/Runtime.h" 9 | #include "WASM/WASM.h" 10 | 11 | namespace WAST 12 | { 13 | // A location in a text file. 14 | struct TextFileLocus 15 | { 16 | std::string sourceLine; 17 | U32 newlines; 18 | U32 tabs; 19 | U32 characters; 20 | 21 | TextFileLocus(): newlines(0), tabs(0), characters(0) {} 22 | 23 | U32 lineNumber() const { return newlines + 1; } 24 | U32 column(U32 spacesPerTab = 4) const { return tabs * spacesPerTab + characters + 1; } 25 | 26 | std::string describe(U32 spacesPerTab = 4) const 27 | { 28 | return std::to_string(lineNumber()) + ":" + std::to_string(column(spacesPerTab)); 29 | } 30 | }; 31 | 32 | // A WAST parse error. 33 | struct Error 34 | { 35 | TextFileLocus locus; 36 | std::string message; 37 | }; 38 | 39 | // Parse a module from a string. Returns true if it succeeds, and writes the module to outModule. 40 | // If it fails, returns false and appends a list of errors to outErrors. 41 | WAST_API bool parseModule(const char* string,Uptr stringLength,IR::Module& outModule,std::vector& outErrors); 42 | 43 | // Prints a module in WAST format. 44 | WAST_API std::string print(const IR::Module& module); 45 | } -------------------------------------------------------------------------------- /libraries/wasm-jit/LICENSE: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | Copyright (c) 2016, Andrew Scheidecker 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | * Neither the name of WAVM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | 13 | The contents of [Test/spec](Test/spec) is covered by the license in [Test/spec/LICENSE](Test/spec/LICENSE). 14 | [Source/ThirdParty/dtoa.c](Source/ThirdParty/dtoa.c) is covered by the license in that file. 15 | [Source/ThirdParty/xxhash](Source/ThirdParty/xxhash) is covered by the license in [Source/ThirdParty/xxhash/LICENSE](Source/ThirdParty/xxhash/LICENSE). -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Emscripten/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources Emscripten.cpp) 2 | set(PublicHeaders ${WAVM_INCLUDE_DIR}/Emscripten/Emscripten.h) 3 | include_directories(${WAVM_INCLUDE_DIR}/Emscripten) 4 | 5 | add_library(Emscripten STATIC ${Sources} ${PublicHeaders}) 6 | 7 | add_definitions(-DEMSCRIPTEN_API=DLL_EXPORT) 8 | 9 | target_link_libraries(Emscripten Logging Platform Runtime) 10 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources 2 | DisassemblyNames.cpp 3 | Operators.cpp 4 | Types.cpp 5 | Validate.cpp) 6 | 7 | set(PublicHeaders 8 | ${WAVM_INCLUDE_DIR}/IR/IR.h 9 | ${WAVM_INCLUDE_DIR}/IR/Module.h 10 | ${WAVM_INCLUDE_DIR}/IR/OperatorPrinter.h 11 | ${WAVM_INCLUDE_DIR}/IR/Operators.h 12 | ${WAVM_INCLUDE_DIR}/IR/Types.h 13 | ${WAVM_INCLUDE_DIR}/IR/Validate.h) 14 | include_directories(${WAVM_INCLUDE_DIR}/IR) 15 | 16 | add_library(IR STATIC ${Sources} ${PublicHeaders}) 17 | add_definitions(-DIR_API=DLL_EXPORT) 18 | target_link_libraries(IR Logging) 19 | 20 | install(TARGETS IR 21 | LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} 22 | ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) 23 | 24 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/IR/Operators.cpp: -------------------------------------------------------------------------------- 1 | #include "Operators.h" 2 | 3 | namespace IR 4 | { 5 | const char* getOpcodeName(Opcode opcode) 6 | { 7 | switch(opcode) 8 | { 9 | #define VISIT_OPCODE(encoding,name,nameString,Imm,...) case Opcode::name: return nameString; 10 | ENUM_OPERATORS(VISIT_OPCODE) 11 | #undef VISIT_OPCODE 12 | default: return "unknown"; 13 | }; 14 | } 15 | } -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/IR/Types.cpp: -------------------------------------------------------------------------------- 1 | #include "Types.h" 2 | 3 | #include 4 | 5 | namespace IR 6 | { 7 | struct FunctionTypeMap 8 | { 9 | struct Key 10 | { 11 | ResultType ret; 12 | std::vector parameters; 13 | 14 | friend bool operator==(const Key& left,const Key& right) { return left.ret == right.ret && left.parameters == right.parameters; } 15 | friend bool operator!=(const Key& left,const Key& right) { return left.ret != right.ret || left.parameters != right.parameters; } 16 | friend bool operator<(const Key& left,const Key& right) { return left.ret < right.ret || (left.ret == right.ret && left.parameters < right.parameters); } 17 | }; 18 | static std::map& get() 19 | { 20 | static std::map map; 21 | return map; 22 | } 23 | }; 24 | 25 | template 26 | Value findExistingOrCreateNew(std::map& map,Key&& key,CreateValueThunk createValueThunk) 27 | { 28 | auto mapIt = map.find(key); 29 | if(mapIt != map.end()) { return mapIt->second; } 30 | else 31 | { 32 | Value value = createValueThunk(); 33 | map.insert({std::move(key),value}); 34 | return value; 35 | } 36 | } 37 | 38 | const FunctionType* FunctionType::get(ResultType ret,const std::initializer_list& parameters) 39 | { return findExistingOrCreateNew(FunctionTypeMap::get(),FunctionTypeMap::Key {ret,parameters},[=]{return new FunctionType(ret,parameters);}); } 40 | const FunctionType* FunctionType::get(ResultType ret,const std::vector& parameters) 41 | { return findExistingOrCreateNew(FunctionTypeMap::get(),FunctionTypeMap::Key {ret,parameters},[=]{return new FunctionType(ret,parameters);}); } 42 | const FunctionType* FunctionType::get(ResultType ret) 43 | { return findExistingOrCreateNew(FunctionTypeMap::get(),FunctionTypeMap::Key {ret,{}},[=]{return new FunctionType(ret,{});}); } 44 | } -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Logging/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources 2 | Logging.cpp) 3 | set(PublicHeaders 4 | ${WAVM_INCLUDE_DIR}/Logging/Logging.h) 5 | include_directories(${WAVM_INCLUDE_DIR}/Logging) 6 | 7 | add_definitions(-DLOGGING_API=DLL_EXPORT) 8 | 9 | add_library(Logging STATIC ${Sources} ${PublicHeaders}) 10 | target_link_libraries(Logging Platform) 11 | 12 | # Link with dl on Linux for dladdr. 13 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 14 | target_link_libraries(Logging dl pthread) 15 | endif() 16 | 17 | install(TARGETS Logging 18 | LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} 19 | ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) 20 | 21 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Logging/Logging.cpp: -------------------------------------------------------------------------------- 1 | #include "Logging.h" 2 | #include "Platform/Platform.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Log 9 | { 10 | static Platform::Mutex* categoryEnabledMutex = Platform::createMutex(); 11 | static bool categoryEnabled[(Uptr)Category::num] = 12 | { 13 | true, // error 14 | #ifdef _DEBUG // debug 15 | true, 16 | #else 17 | false, 18 | #endif 19 | WAVM_METRICS_OUTPUT != 0 // metrics 20 | }; 21 | void setCategoryEnabled(Category category,bool enable) 22 | { 23 | Platform::Lock lock(categoryEnabledMutex); 24 | WAVM_ASSERT_THROW(category < Category::num); 25 | categoryEnabled[(Uptr)category] = enable; 26 | } 27 | bool isCategoryEnabled(Category category) 28 | { 29 | Platform::Lock lock(categoryEnabledMutex); 30 | WAVM_ASSERT_THROW(category < Category::num); 31 | return categoryEnabled[(Uptr)category]; 32 | } 33 | void printf(Category category,const char* format,...) 34 | { 35 | Platform::Lock lock(categoryEnabledMutex); 36 | if(categoryEnabled[(Uptr)category]) 37 | { 38 | va_list varArgs; 39 | va_start(varArgs,format); 40 | vfprintf(stdout,format,varArgs); 41 | fflush(stdout); 42 | va_end(varArgs); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources 2 | POSIX.cpp 3 | Windows.cpp) 4 | set(PublicHeaders 5 | ${WAVM_INCLUDE_DIR}/Platform/Platform.h) 6 | include_directories(${WAVM_INCLUDE_DIR}/Platform) 7 | 8 | add_definitions(-DPLATFORM_API=DLL_EXPORT) 9 | 10 | add_library(Platform STATIC ${Sources} ${PublicHeaders}) 11 | 12 | # Link with dl on Linux for dladdr. 13 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 14 | target_link_libraries(Platform dl pthread rt) 15 | endif() 16 | 17 | install(TARGETS Platform 18 | LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} 19 | ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) 20 | 21 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Programs/Assemble.cpp: -------------------------------------------------------------------------------- 1 | #include "Inline/BasicTypes.h" 2 | #include "CLI.h" 3 | #include "WAST/WAST.h" 4 | #include "WASM/WASM.h" 5 | 6 | int commandMain(int argc,char** argv) 7 | { 8 | if(argc < 3) 9 | { 10 | std::cerr << "Usage: yy-wast2wasm in.wast out.wasm [switches]" << std::endl; 11 | std::cerr << " -n|--omit-names\t\tOmits WAST function and local names from the output" << std::endl; 12 | return EXIT_FAILURE; 13 | } 14 | const char* inputFilename = argv[1]; 15 | const char* outputFilename = argv[2]; 16 | bool omitNames = false; 17 | if(argc > 3) 18 | { 19 | for(Iptr argumentIndex = 3;argumentIndex < argc;++argumentIndex) 20 | { 21 | if(!strcmp(argv[argumentIndex],"-n") || !strcmp(argv[argumentIndex],"--omit-names")) 22 | { 23 | omitNames = true; 24 | } 25 | else 26 | { 27 | std::cerr << "Unrecognized argument: " << argv[argumentIndex] << std::endl; 28 | return EXIT_FAILURE; 29 | } 30 | } 31 | } 32 | 33 | // Load the WAST module. 34 | IR::Module module; 35 | if(!loadTextModule(inputFilename,module)) { return EXIT_FAILURE; } 36 | 37 | // If the command-line switch to omit names was specified, strip the name section. 38 | if(omitNames) 39 | { 40 | for(auto sectionIt = module.userSections.begin();sectionIt != module.userSections.end();++sectionIt) 41 | { 42 | if(sectionIt->name == "name") { module.userSections.erase(sectionIt); break; } 43 | } 44 | } 45 | 46 | // Write the binary module. 47 | if(!saveBinaryModule(outputFilename,module)) { return EXIT_FAILURE; } 48 | 49 | return EXIT_SUCCESS; 50 | } 51 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(yy-wast2wasm Assemble.cpp CLI.h) 2 | target_link_libraries(yy-wast2wasm Logging IR WAST WASM) 3 | set_target_properties(yy-wast2wasm PROPERTIES FOLDER Programs) 4 | INSTALL(TARGETS yy-wast2wasm DESTINATION ${CMAKE_INSTALL_BINDIR}) 5 | 6 | add_executable(Disassemble Disassemble.cpp CLI.h) 7 | target_link_libraries(Disassemble Logging IR WAST WASM) 8 | set_target_properties(Disassemble PROPERTIES FOLDER Programs) 9 | 10 | add_executable(Test Test.cpp CLI.h) 11 | target_link_libraries(Test Logging IR WAST Runtime) 12 | set_target_properties(Test PROPERTIES FOLDER Programs) 13 | 14 | add_executable(wavm wavm.cpp CLI.h) 15 | target_link_libraries(wavm Logging IR WAST WASM Runtime Emscripten) 16 | set_target_properties(wavm PROPERTIES FOLDER Programs) 17 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Programs/Disassemble.cpp: -------------------------------------------------------------------------------- 1 | #include "Inline/BasicTypes.h" 2 | #include "CLI.h" 3 | #include "WAST/WAST.h" 4 | #include "WASM/WASM.h" 5 | 6 | int commandMain(int argc,char** argv) 7 | { 8 | if(argc != 3) 9 | { 10 | std::cerr << "Usage: Disassemble in.wasm out.wast" << std::endl; 11 | return EXIT_FAILURE; 12 | } 13 | const char* inputFilename = argv[1]; 14 | const char* outputFilename = argv[2]; 15 | 16 | // Load the WASM file. 17 | IR::Module module; 18 | if(!loadBinaryModule(inputFilename,module)) { return EXIT_FAILURE; } 19 | 20 | // Print the module to WAST. 21 | const std::string wastString = WAST::print(module); 22 | 23 | // Write the serialized data to the output file. 24 | std::ofstream outputStream(outputFilename); 25 | outputStream.write(wastString.data(),wastString.size()); 26 | outputStream.close(); 27 | 28 | return EXIT_SUCCESS; 29 | } 30 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/Runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources 2 | Intrinsics.cpp 3 | Linker.cpp 4 | LLVMEmitIR.cpp 5 | LLVMJIT.cpp 6 | LLVMJIT.h 7 | Memory.cpp 8 | ModuleInstance.cpp 9 | ObjectGC.cpp 10 | Runtime.cpp 11 | RuntimePrivate.h 12 | Table.cpp 13 | Threads.cpp 14 | WAVMIntrinsics.cpp 15 | ) 16 | set(PublicHeaders 17 | ${WAVM_INCLUDE_DIR}/Runtime/Intrinsics.h 18 | ${WAVM_INCLUDE_DIR}/Runtime/Linker.h 19 | ${WAVM_INCLUDE_DIR}/Runtime/Runtime.h 20 | ${WAVM_INCLUDE_DIR}/Runtime/TaggedValue.h) 21 | include_directories(${WAVM_INCLUDE_DIR}/Runtime) 22 | 23 | add_library(Runtime STATIC ${Sources} ${PublicHeaders}) 24 | 25 | # Find an installed build of LLVM 26 | find_package(LLVM 4.0 REQUIRED CONFIG) 27 | 28 | # Include the LLVM headers 29 | include_directories(${LLVM_INCLUDE_DIRS}) 30 | add_definitions(${LLVM_DEFINITIONS}) 31 | 32 | add_definitions(-DRUNTIME_API=DLL_EXPORT) 33 | 34 | target_include_directories( Runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../chain/include ) 35 | 36 | # Link against the LLVM libraries 37 | llvm_map_components_to_libnames(LLVM_LIBS support core passes mcjit native DebugInfoDWARF) 38 | target_link_libraries(Runtime Platform Logging IR ${LLVM_LIBS}) 39 | 40 | install(TARGETS Runtime 41 | LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} 42 | ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) 43 | 44 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/ThirdParty/xxhash/LICENSE: -------------------------------------------------------------------------------- 1 | xxHash Library 2 | Copyright (c) 2012-2014, Yann Collet 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, this 12 | list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/WASM/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources WASMSerialization.cpp) 2 | set(PublicHeaders ${WAVM_INCLUDE_DIR}/WASM/WASM.h) 3 | include_directories(${WAVM_INCLUDE_DIR}/WASM) 4 | 5 | add_library(WASM STATIC ${Sources} ${PublicHeaders}) 6 | add_definitions(-DWEBASSEMBLY_API=DLL_EXPORT) 7 | target_link_libraries(WASM Logging IR) 8 | 9 | install(TARGETS WASM 10 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 11 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 12 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/WAST/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Sources 2 | NFA.cpp 3 | NFA.h 4 | Lexer.cpp 5 | Lexer.h 6 | Parse.cpp 7 | Parse.h 8 | ParseFunction.cpp 9 | ParseNumbers.cpp 10 | ParseModule.cpp 11 | ParseTests.cpp 12 | Print.cpp 13 | Regexp.cpp 14 | Regexp.h) 15 | set(PublicHeaders 16 | ${WAVM_INCLUDE_DIR}/WAST/WAST.h 17 | ${WAVM_INCLUDE_DIR}/WAST/TestScript.h) 18 | include_directories(${WAVM_INCLUDE_DIR}/WAST) 19 | 20 | add_library(WAST STATIC ${Sources} ${PublicHeaders}) 21 | add_definitions(-DWAST_API=DLL_EXPORT) 22 | target_link_libraries(WAST Logging IR WASM) 23 | install(TARGETS WAST 24 | LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} 25 | ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) 26 | 27 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Source/WAST/Regexp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Inline/BasicTypes.h" 4 | #include "NFA.h" 5 | 6 | namespace Regexp 7 | { 8 | // Parses a regular expression from a string, and adds a recognizer for it to the given NFA 9 | // The recognizer will start from initialState, and end in finalState when the regular expression has been completely matched. 10 | void addToNFA(const char* regexpString,NFA::Builder* nfaBuilder,NFA::StateIndex initialState,NFA::StateIndex finalState); 11 | }; 12 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/Benchmark/Benchmark.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct point 5 | { 6 | double x; 7 | double y; 8 | }; 9 | 10 | int main() 11 | { 12 | // Generate a lot of uniformly distributed 2d points in the range -1,-1 to +1,+1. 13 | enum { numXSamples = 10000 }; 14 | enum { numYSamples = 10000 }; 15 | std::vector points; 16 | points.reserve(numXSamples * numYSamples); 17 | for(int x = 0;x < numXSamples;++x) 18 | { 19 | for(int y = 0;y < numXSamples;++y) 20 | { 21 | point p = {-1.0 + 2.0 * x / (numXSamples-1),-1.0 + 2.0 * y / (numYSamples-1)}; 22 | points.push_back(p); 23 | } 24 | } 25 | 26 | // Count the ratio of points inside the unit circle. 27 | int numerator = 0; 28 | int denominator = 0; 29 | for(auto pointIt = points.begin();pointIt != points.end();++pointIt) 30 | { 31 | if(pointIt->x * pointIt->x + pointIt->y * pointIt->y < 1.0) 32 | { 33 | ++numerator; 34 | } 35 | ++denominator; 36 | } 37 | 38 | // Derive the area of the unit circle. 39 | auto circleArea = 4.0 * (double)numerator / denominator; 40 | std::cout << "result: " << circleArea << std::endl; 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/fuzz/address.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "spectest" "print" (func $print (param i32))) 3 | 4 | (memory 1) 5 | (data (i32.const 0) "abcdefghijklmnopqrstuvwxyz") 6 | 7 | (func $good (param $i i32) 8 | (call $print (i32.load8_u offset=0 (get_local $i))) ;; 97 'a' 9 | (call $print (i32.load8_u offset=1 (get_local $i))) ;; 98 'b' 10 | (call $print (i32.load8_u offset=2 (get_local $i))) ;; 99 'c' 11 | (call $print (i32.load8_u offset=25 (get_local $i))) ;; 122 'z' 12 | 13 | (call $print (i32.load16_u offset=0 (get_local $i))) ;; 25185 'ab' 14 | (call $print (i32.load16_u align=1 (get_local $i))) ;; 25185 'ab' 15 | (call $print (i32.load16_u offset=1 align=1 (get_local $i))) ;; 25442 'bc' 16 | (call $print (i32.load16_u offset=2 (get_local $i))) ;; 25699 'cd' 17 | (call $print (i32.load16_u offset=25 align=1 (get_local $i))) ;; 122 'z\0' 18 | 19 | (call $print (i32.load offset=0 (get_local $i))) ;; 1684234849 'abcd' 20 | (call $print (i32.load offset=1 align=1 (get_local $i))) ;; 1701077858 'bcde' 21 | (call $print (i32.load offset=2 align=2 (get_local $i))) ;; 1717920867 'cdef' 22 | (call $print (i32.load offset=25 align=1 (get_local $i))) ;; 122 'z\0\0\0' 23 | ) 24 | 25 | (func (export "main") 26 | (call $good (i32.const 0)) 27 | (call $good (i32.const 65507)) 28 | (call $good (i32.const 65508)) 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/fuzz/func_ptrs.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $T (func (param) (result i32))) 3 | (type $U (func (param) (result i32))) 4 | (table anyfunc (elem $t1 $t2 $t3 $u1 $u2 $t1 $t3)) 5 | 6 | (func $t1 (type $T) (i32.const 1)) 7 | (func $t2 (type $T) (i32.const 2)) 8 | (func $t3 (type $T) (i32.const 3)) 9 | (func $u1 (type $U) (i32.const 4)) 10 | (func $u2 (type $U) (i32.const 5)) 11 | 12 | (func $callt (param $i i32) (result i32) 13 | (call_indirect $T (get_local $i)) 14 | ) 15 | 16 | (func $callu (param $i i32) (result i32) 17 | (call_indirect $U (get_local $i)) 18 | ) 19 | 20 | (func (export "main") 21 | (drop (call $callt (i32.const 0))) 22 | (drop (call $callt (i32.const 1))) 23 | (drop (call $callt (i32.const 2))) 24 | (drop (call $callt (i32.const 3))) 25 | (drop (call $callt (i32.const 4))) 26 | (drop (call $callt (i32.const 5))) 27 | (drop (call $callt (i32.const 6))) 28 | (drop (call $callu (i32.const 0))) 29 | (drop (call $callu (i32.const 1))) 30 | (drop (call $callu (i32.const 2))) 31 | (drop (call $callu (i32.const 3))) 32 | (drop (call $callu (i32.const 4))) 33 | (drop (call $callu (i32.const 5))) 34 | (drop (call $callu (i32.const 6))) 35 | ) 36 | ) 37 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/fuzz/globals.wast: -------------------------------------------------------------------------------- 1 | ;; Test globals 2 | 3 | (module 4 | (global $a i32 (i32.const -2)) 5 | (global (;1;) f32 (f32.const -3)) 6 | (global (;2;) f64 (f64.const -4)) 7 | (global $b i64 (i64.const -5)) 8 | 9 | (global $x (mut i32) (i32.const -12)) 10 | (global (;5;) (mut f32) (f32.const -13)) 11 | (global (;6;) (mut f64) (f64.const -14)) 12 | (global $y (mut i64) (i64.const -15)) 13 | 14 | (func $get-a (result i32) (get_global $a)) 15 | (func $get-b (result i64) (get_global $b)) 16 | (func $get-x (result i32) (get_global $x)) 17 | (func $get-y (result i64) (get_global $y)) 18 | (func $set-x (param i32) (set_global $x (get_local 0))) 19 | (func $set-y (param i64) (set_global $y (get_local 0))) 20 | 21 | (func $get-1 (result f32) (get_global 1)) 22 | (func $get-2 (result f64) (get_global 2)) 23 | (func $get-5 (result f32) (get_global 5)) 24 | (func $get-6 (result f64) (get_global 6)) 25 | (func $set-5 (param f32) (set_global 5 (get_local 0))) 26 | (func $set-6 (param f64) (set_global 6 (get_local 0))) 27 | 28 | (func (export "main") 29 | (drop (call $get-a)) 30 | (drop (call $get-b)) 31 | (drop (call $get-x)) 32 | (drop (call $get-y)) 33 | 34 | (drop (call $get-1)) 35 | (drop (call $get-2)) 36 | (drop (call $get-5)) 37 | (drop (call $get-6)) 38 | 39 | (call $set-x (i32.const 6)) 40 | (call $set-y (i64.const 7)) 41 | (call $set-5 (f32.const 8)) 42 | (call $set-6 (f64.const 9)) 43 | 44 | (drop (call $get-x)) 45 | (drop (call $get-y)) 46 | (drop (call $get-5)) 47 | (drop (call $get-6)) 48 | ) 49 | ) 50 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/fuzz/helloworld.wast: -------------------------------------------------------------------------------- 1 | ;; WebAssembly WASM AST Hello World! program 2 | 3 | (module 4 | (import "env" "_fwrite" (func $__fwrite (param i32 i32 i32 i32) (result i32))) 5 | (import "env" "_stdout" (global $stdoutPtr (mut i32))) 6 | (import "env" "memory" (memory 1)) 7 | (export "main" (func $main)) 8 | 9 | (data (i32.const 8) "Hello World!\n") 10 | 11 | (func (export "establishStackSpace") (param i32 i32) (nop)) 12 | 13 | (func $main (result i32) 14 | (local $stdout i32) 15 | (set_local $stdout (i32.load align=4 (get_global $stdoutPtr))) 16 | 17 | (return (call $__fwrite 18 | (i32.const 8) ;; void *ptr => Address of our string 19 | (i32.const 1) ;; size_t size => Data size 20 | (i32.const 13) ;; size_t nmemb => Length of our string 21 | (get_local $stdout)) ;; stream 22 | ) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/fuzz/resizing.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 0) 3 | 4 | (func $load_at_zero (result i32) (i32.load (i32.const 0))) 5 | (func $store_at_zero (i32.store (i32.const 0) (i32.const 2))) 6 | 7 | (func $load_at_page_size (result i32) (i32.load (i32.const 0x10000))) 8 | (func $store_at_page_size (i32.store (i32.const 0x10000) (i32.const 3))) 9 | 10 | (func $grow (param $sz i32) (result i32) (grow_memory (get_local $sz))) 11 | (func $size (result i32) (current_memory)) 12 | 13 | (func (export "main") 14 | (drop (call $size)) 15 | (drop (call $grow (i32.const 1))) 16 | (drop (call $size)) 17 | (drop (call $load_at_zero)) 18 | (call $store_at_zero) 19 | (drop (call $load_at_zero)) 20 | (drop (call $grow (i32.const 4))) 21 | (drop (call $size)) 22 | (drop (call $load_at_zero)) 23 | (call $store_at_zero) 24 | (drop (call $load_at_zero)) 25 | (drop (call $load_at_page_size)) 26 | (call $store_at_page_size) 27 | (drop (call $load_at_page_size)) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/fuzz/tee.wast: -------------------------------------------------------------------------------- 1 | ;; poor man's tee 2 | ;; Outputs to stderr and stdout whatever comes in stdin 3 | 4 | (module 5 | 6 | (import "env" "memory" (memory 1)) 7 | (import "env" "_fwrite" (func $__fwrite (param i32 i32 i32 i32) (result i32))) 8 | (import "env" "_fread" (func $__fread (param i32 i32 i32 i32) (result i32))) 9 | (import "env" "_stdin" (global $stdinPtr (mut i32))) 10 | (import "env" "_stdout" (global $stdoutPtr (mut i32))) 11 | (import "env" "_stderr" (global $stderrPtr (mut i32))) 12 | (export "main" (func $main)) 13 | 14 | (func $main 15 | (local $stdin i32) 16 | (local $stdout i32) 17 | (local $stderr i32) 18 | (local $nmemb i32) 19 | (set_local $stdin (i32.load align=4 (get_global $stdinPtr))) 20 | (set_local $stdout (i32.load align=4 (get_global $stdoutPtr))) 21 | (set_local $stderr (i32.load align=4 (get_global $stderrPtr))) 22 | 23 | (loop $loop 24 | (block $done 25 | (set_local $nmemb (call $__fread (i32.const 0) (i32.const 1) (i32.const 32) (get_local $stdin))) 26 | (br_if $done (i32.eq (i32.const 0) (get_local $nmemb))) 27 | (drop (call $__fwrite (i32.const 0) (i32.const 1) (get_local $nmemb) (get_local $stdout))) 28 | (drop (call $__fwrite (i32.const 0) (i32.const 1) (get_local $nmemb) (get_local $stderr))) 29 | (br $loop) 30 | ) 31 | ) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/align.wast: -------------------------------------------------------------------------------- 1 | (assert_malformed 2 | (module quote 3 | "(module (memory 0) (func (drop (i64.load align=0 (i32.const 0)))))" 4 | ) 5 | "alignment" 6 | ) 7 | (assert_malformed 8 | (module quote 9 | "(module (memory 0) (func (drop (i64.load align=7 (i32.const 0)))))" 10 | ) 11 | "alignment" 12 | ) 13 | (assert_invalid 14 | (module (memory 0) (func (drop (i64.load align=16 (i32.const 0))))) 15 | "alignment" 16 | ) 17 | 18 | (assert_malformed 19 | (module quote 20 | "(module (memory 0) (func (i64.store align=0 (i32.const 0) (i64.const 0))))" 21 | ) 22 | "alignment" 23 | ) 24 | (assert_malformed 25 | (module quote 26 | "(module (memory 0) (func (i64.store align=5 (i32.const 0) (i64.const 0))))" 27 | ) 28 | "alignment" 29 | ) 30 | (assert_invalid 31 | (module (memory 0) (func (i64.store align=16 (i32.const 0) (i64.const 0)))) 32 | "alignment" 33 | ) 34 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/break-drop.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "br") (block (br 0))) 3 | (func (export "br_if") (block (br_if 0 (i32.const 1)))) 4 | (func (export "br_table") (block (br_table 0 (i32.const 0)))) 5 | ) 6 | 7 | (assert_return (invoke "br")) 8 | (assert_return (invoke "br_if")) 9 | (assert_return (invoke "br_table")) 10 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/comments.wast: -------------------------------------------------------------------------------- 1 | ;; Test comment syntax 2 | 3 | ;;comment 4 | 5 | ;;;;;;;;;;; 6 | 7 | ;;comment 8 | 9 | ( ;;comment 10 | module;;comment 11 | );;comment 12 | 13 | ;;) 14 | ;;;) 15 | ;; ;) 16 | ;; (; 17 | 18 | (;;) 19 | 20 | (;comment;) 21 | 22 | (;;comment;) 23 | 24 | (;;;comment;) 25 | 26 | (;;;;;;;;;;;;;;) 27 | 28 | (;(((((((((( ;) 29 | 30 | (;)))))))))));) 31 | 32 | (;comment";) 33 | 34 | (;comment"";) 35 | 36 | (;comment""";) 37 | 38 | ;; ASCII 00-1F, 7F 39 | (; 40 | ;) 41 | 42 | (;Heiße Würstchen;) 43 | 44 | (;;) 45 | 46 | (;comment 47 | comment;) 48 | 49 | (;comment;) 50 | 51 | (;comment;)((;comment;) 52 | (;comment;)module(;comment;) 53 | (;comment;))(;comment;) 54 | 55 | (;comment(;nested;)comment;) 56 | 57 | (;comment 58 | (;nested 59 | ;)comment 60 | ;) 61 | 62 | (module 63 | (;comment(;nested(;further;)nested;)comment;) 64 | ) 65 | 66 | (;comment;;comment;) 67 | 68 | (;comment;;comment 69 | ;) 70 | 71 | (module 72 | (;comment;;comment(;nested;)comment;) 73 | ) -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/forward.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $even (export "even") (param $n i32) (result i32) 3 | (if (result i32) (i32.eq (get_local $n) (i32.const 0)) 4 | (then (i32.const 1)) 5 | (else (call $odd (i32.sub (get_local $n) (i32.const 1)))) 6 | ) 7 | ) 8 | 9 | (func $odd (export "odd") (param $n i32) (result i32) 10 | (if (result i32) (i32.eq (get_local $n) (i32.const 0)) 11 | (then (i32.const 0)) 12 | (else (call $even (i32.sub (get_local $n) (i32.const 1)))) 13 | ) 14 | ) 15 | ) 16 | 17 | (assert_return (invoke "even" (i32.const 13)) (i32.const 0)) 18 | (assert_return (invoke "even" (i32.const 20)) (i32.const 1)) 19 | (assert_return (invoke "odd" (i32.const 13)) (i32.const 1)) 20 | (assert_return (invoke "odd" (i32.const 20)) (i32.const 0)) 21 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/store_retval.wast: -------------------------------------------------------------------------------- 1 | (assert_invalid 2 | (module (func (param i32) (result i32) (set_local 0 (i32.const 1)))) 3 | "type mismatch" 4 | ) 5 | (assert_invalid 6 | (module (func (param i64) (result i64) (set_local 0 (i64.const 1)))) 7 | "type mismatch" 8 | ) 9 | (assert_invalid 10 | (module (func (param f32) (result f32) (set_local 0 (f32.const 1)))) 11 | "type mismatch" 12 | ) 13 | (assert_invalid 14 | (module (func (param f64) (result f64) (set_local 0 (f64.const 1)))) 15 | "type mismatch" 16 | ) 17 | 18 | (assert_invalid 19 | (module (memory 1) (func (param i32) (result i32) (i32.store (i32.const 0) (i32.const 1)))) 20 | "type mismatch" 21 | ) 22 | (assert_invalid 23 | (module (memory 1) (func (param i64) (result i64) (i64.store (i32.const 0) (i64.const 1)))) 24 | "type mismatch" 25 | ) 26 | (assert_invalid 27 | (module (memory 1) (func (param f32) (result f32) (f32.store (i32.const 0) (f32.const 1)))) 28 | "type mismatch" 29 | ) 30 | (assert_invalid 31 | (module (memory 1) (func (param f64) (result f64) (f64.store (i32.const 0) (f64.const 1)))) 32 | "type mismatch" 33 | ) 34 | 35 | (assert_invalid 36 | (module (memory 1) (func (param i32) (result i32) (i32.store8 (i32.const 0) (i32.const 1)))) 37 | "type mismatch" 38 | ) 39 | (assert_invalid 40 | (module (memory 1) (func (param i32) (result i32) (i32.store16 (i32.const 0) (i32.const 1)))) 41 | "type mismatch" 42 | ) 43 | (assert_invalid 44 | (module (memory 1) (func (param i64) (result i64) (i64.store8 (i32.const 0) (i64.const 1)))) 45 | "type mismatch" 46 | ) 47 | (assert_invalid 48 | (module (memory 1) (func (param i64) (result i64) (i64.store16 (i32.const 0) (i64.const 1)))) 49 | "type mismatch" 50 | ) 51 | (assert_invalid 52 | (module (memory 1) (func (param i64) (result i64) (i64.store32 (i32.const 0) (i64.const 1)))) 53 | "type mismatch" 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/token.wast: -------------------------------------------------------------------------------- 1 | ;; Test tokenization 2 | 3 | (assert_malformed 4 | (module quote "(func (drop (i32.const0)))") 5 | "unknown operator" 6 | ) 7 | (assert_malformed 8 | (module quote "(func br 0drop)") 9 | "unknown operator" 10 | ) 11 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/spec/type.wast: -------------------------------------------------------------------------------- 1 | ;; Test type definitions 2 | 3 | (module 4 | (type (func)) 5 | (type $t (func)) 6 | 7 | (type (func (param i32))) 8 | (type (func (param $x i32))) 9 | (type (func (result i32))) 10 | (type (func (param i32) (result i32))) 11 | (type (func (param $x i32) (result i32))) 12 | 13 | (type (func (param f32 f64))) 14 | ;; (type (func (result i64 f32))) 15 | ;; (type (func (param i32 i64) (result f32 f64))) 16 | 17 | (type (func (param f32) (param f64))) 18 | (type (func (param $x f32) (param f64))) 19 | (type (func (param f32) (param $y f64))) 20 | (type (func (param $x f32) (param $y f64))) 21 | ;; (type (func (result i64) (result f32))) 22 | ;; (type (func (param i32) (param i64) (result f32) (result f64))) 23 | ;; (type (func (param $x i32) (param $y i64) (result f32) (result f64))) 24 | 25 | (type (func (param f32 f64) (param $x i32) (param f64 i32 i32))) 26 | ;; (type (func (result i64 i64 f32) (result f32 i32))) 27 | ;; (type 28 | ;; (func (param i32 i32) (param i64 i32) (result f32 f64) (result f64 i32)) 29 | ;; ) 30 | 31 | (type (func (param) (param $x f32) (param) (param) (param f64 i32) (param))) 32 | ;; (type 33 | ;; (func (result) (result) (result i64 i64) (result) (result f32) (result)) 34 | ;; ) 35 | ;; (type 36 | ;; (func 37 | ;; (param i32 i32) (param i64 i32) (param) (param $x i32) (param) 38 | ;; (result) (result f32 f64) (result f64 i32) (result) 39 | ;; ) 40 | ;; ) 41 | ) 42 | 43 | (assert_malformed 44 | (module quote "(type (func (result i32) (param i32)))") 45 | "result before parameter" 46 | ) 47 | (assert_malformed 48 | (module quote "(type (func (result $x i32)))") 49 | "unexpected token" 50 | ) 51 | 52 | (assert_invalid 53 | (module (type (func (result i32 i32)))) 54 | "invalid result arity" 55 | ) 56 | (assert_invalid 57 | (module (type (func (result i32) (result i32)))) 58 | "invalid result arity" 59 | ) 60 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/wast/helloworld.wast: -------------------------------------------------------------------------------- 1 | ;; WebAssembly WASM AST Hello World! program 2 | 3 | (module 4 | (import "env" "_fwrite" (func $__fwrite (param i32 i32 i32 i32) (result i32))) 5 | (import "env" "_stdout" (global $stdoutPtr i32)) 6 | (import "env" "memory" (memory 1)) 7 | (export "main" (func $main)) 8 | 9 | (data (i32.const 8) "Hello World!\n") 10 | 11 | (func (export "establishStackSpace") (param i32 i32) (nop)) 12 | 13 | (func $main (result i32) 14 | (local $stdout i32) 15 | (set_local $stdout (i32.load align=4 (get_global $stdoutPtr))) 16 | 17 | (return (call $__fwrite 18 | (i32.const 8) ;; void *ptr => Address of our string 19 | (i32.const 1) ;; size_t size => Data size 20 | (i32.const 13) ;; size_t nmemb => Length of our string 21 | (get_local $stdout)) ;; stream 22 | ) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /libraries/wasm-jit/Test/wast/tee.wast: -------------------------------------------------------------------------------- 1 | ;; poor man's tee 2 | ;; Outputs to stderr and stdout whatever comes in stdin 3 | 4 | (module 5 | 6 | (import "env" "memory" (memory 1)) 7 | (import "env" "_fwrite" (func $__fwrite (param i32 i32 i32 i32) (result i32))) 8 | (import "env" "_fread" (func $__fread (param i32 i32 i32 i32) (result i32))) 9 | (import "env" "_stdin" (global $stdinPtr i32)) 10 | (import "env" "_stdout" (global $stdoutPtr i32)) 11 | (import "env" "_stderr" (global $stderrPtr i32)) 12 | (export "main" (func $main)) 13 | 14 | (func $main 15 | (local $stdin i32) 16 | (local $stdout i32) 17 | (local $stderr i32) 18 | (local $nmemb i32) 19 | (set_local $stdin (i32.load align=4 (get_global $stdinPtr))) 20 | (set_local $stdout (i32.load align=4 (get_global $stdoutPtr))) 21 | (set_local $stderr (i32.load align=4 (get_global $stderrPtr))) 22 | 23 | (loop $loop 24 | (block $done 25 | (set_local $nmemb (call $__fread (i32.const 0) (i32.const 1) (i32.const 32) (get_local $stdin))) 26 | (br_if $done (i32.eq (i32.const 0) (get_local $nmemb))) 27 | (drop (call $__fwrite (i32.const 0) (i32.const 1) (get_local $nmemb) (get_local $stdout))) 28 | (drop (call $__fwrite (i32.const 0) (i32.const 1) (get_local $nmemb) (get_local $stderr))) 29 | (br $loop) 30 | ) 31 | ) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /libraries/wasm-jit/afl/readme: -------------------------------------------------------------------------------- 1 | Scripts for helping to run the AFL (http://lcamtuf.coredump.cx/afl/) fuzzer against wavm 2 | 3 | 1) Add the directory containing the AFL binaries to your path 4 | 2) Make a directory to contain the AFL build 5 | 3) From the new directory, run /afl/run-afl-fuzz (to run a n more slave instances if the machine can handle it) 6 | -------------------------------------------------------------------------------- /libraries/wasm-jit/afl/run-afl-fuzz: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ex 2 | 3 | WAVM="$1" 4 | WAVM_BIN=./bin 5 | 6 | TMPDIR=./tmp 7 | FINDINGS=${TMPDIR}/findings 8 | CORPUS_SRC=${WAVM}/Test/fuzz 9 | 10 | if [ -n "$2" ] ; then 11 | NUM_SLAVES=$2 12 | else 13 | NUM_SLAVES=0 14 | fi 15 | 16 | # Compile WAVM using the AFL compiler and ASAN. 17 | export CC=afl-clang-fast 18 | export CXX=afl-clang-fast++ 19 | export AFL_HARDEN=1 20 | cmake ${WAVM} -DENABLE_ASAN=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo 21 | make -j 22 | 23 | # Set up ASAN to ignore seg faults, ignore leaks, and abort on error. 24 | export ASAN_OPTIONS=handle_segv=0:detect_leaks=0:abort_on_error=1 25 | 26 | # Make a ramdisk to hold the AFL temp files. 27 | if [ ! -d $TMPDIR ] ; then 28 | mkdir $TMPDIR && chmod 777 $TMPDIR 29 | sudo mount -t tmpfs -o size=512M tmpfs $TMPDIR 30 | fi 31 | 32 | if [ ! -d $FINDINGS ] ; then 33 | mkdir $FINDINGS 34 | fi 35 | 36 | # Assemble the corpus. 37 | CORPUS=${TMPDIR}/corpus 38 | mkdir -p $CORPUS 39 | rm -rf ${CORPUS}/* 40 | for wast in ${CORPUS_SRC}/*.wast; do 41 | ${WAVM_BIN}/Assemble $wast ${CORPUS}/$(basename $wast).wasm 42 | done 43 | 44 | # Spawn the slave fuzzers 45 | for i in `seq 0 $NUM_SLAVES`; do 46 | afl-fuzz -i ${CORPUS} -o ${FINDINGS} -m 9999999999999999999 -t 5000 -S slave${i} -- ${WAVM_BIN}/wavm @@ 1>slave${i}.stdout.txt 2>slave${i}.stderr.txt & 47 | done 48 | 49 | # Run the master fuzzer 50 | afl-fuzz -i ${CORPUS} -o ${FINDINGS} -m 9999999999999999999 -t 5000 -M master -- ${WAVM_BIN}/wavm @@ 51 | -------------------------------------------------------------------------------- /libraries/wasm-jit/afl/simplify-crashes: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | for f in crashes/id* ; do 3 | afl-tmin -i $f -o $f.min -m 9999999999999999999 -e -- ./bin/wavm --text @@ 4 | done 5 | -------------------------------------------------------------------------------- /libraries/wasm-jit/afl/wast.dict: -------------------------------------------------------------------------------- 1 | # 2 | # AFL dictionary for WebAssembly WAST 3 | # ---------------------- 4 | # 5 | # Created by Benjamin Meyer 6 | # 7 | 8 | keyword_nop="nop" 9 | keyword_block="block" 10 | keyword_loop="loop" 11 | keyword_select="select" 12 | keyword_if="if" 13 | keyword_br="br" 14 | keyword_br_if="br_if" 15 | keyword_br_table="br_table" 16 | keyword_return="return" 17 | keyword_call="call" 18 | keyword_call_import="call_import" 19 | keyword_call_indirect="call_indirect" 20 | keyword_get_local="get_local" 21 | keyword_set_local="set_local" 22 | keyword_load8=".load8" 23 | keyword_load16=".load16" 24 | keyword_load32=".load32" 25 | keyword_store8=".store8" 26 | keyword_store16=".store16" 27 | keyword_store32=".store32" 28 | keyword_const8=".const8" 29 | keyword_const16=".const16" 30 | keyword_const32=".const32" 31 | keyword_unreachable="unreachable" 32 | keyword_current_memory="current_memory" 33 | keyword_grow_memory="grow_memory" 34 | keyword_func="func" 35 | keyword_sig="sig" 36 | keyword_param="param" 37 | keyword_result="result" 38 | keyword_local="local" 39 | keyword_module="module" 40 | keyword_typedef="typedef" 41 | keyword_import="import" 42 | keyword_export="export" 43 | keyword_start="start" 44 | keyword_table="table" 45 | keyword_memory="memory" 46 | keyword_segment="segment" 47 | 48 | type_i32="i32" 49 | type_i64="i64" 50 | type_f32="f32" 51 | type_f64="f64" 52 | 53 | unop_0="ctz" 54 | unop_1="clz" 55 | unop_2="popcnt" 56 | binop_0="add" 57 | binop_1="sub" 58 | binop_2="mul" 59 | relop_0="eq" 60 | relop_1="ne" 61 | relop_2="lt" 62 | 63 | offset="offset=" 64 | align="align=" 65 | cvtop_0="trunc_s" 66 | cvtop_1="trunc_u" 67 | cvtop_2="extend_s" 68 | cvtop_3="extend_u" 69 | 70 | string_quote_double="\"a\"" 71 | string_quote_single="'a'" 72 | 73 | snippet_comment0=";;" 74 | snippet_comment1="#" 75 | snippet_parentheses0="(" 76 | snippet_parentheses1=")" 77 | snippet_alt="?" 78 | -------------------------------------------------------------------------------- /programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( build_helpers ) 2 | add_subdirectory( yoyow_client ) 3 | #add_subdirectory( genesis_util ) 4 | add_subdirectory( yoyow_node ) 5 | 6 | #add_subdirectory( js_operation_serializer ) 7 | add_subdirectory( size_checker ) 8 | add_subdirectory( yy_abigen ) 9 | -------------------------------------------------------------------------------- /programs/build_helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( cat-parts cat-parts.cpp ) 3 | if( UNIX AND NOT APPLE ) 4 | set(rt_library rt ) 5 | endif() 6 | 7 | # we only actually need Boost, but link against FC for now so we don't duplicate it. 8 | target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 9 | 10 | #add_executable( member_enumerator member_enumerator.cpp ) 11 | if( UNIX AND NOT APPLE ) 12 | set(rt_library rt ) 13 | endif() 14 | 15 | # we only actually need Boost, but link against FC for now so we don't duplicate it. 16 | #target_link_libraries( member_enumerator PRIVATE fc graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 17 | 18 | -------------------------------------------------------------------------------- /programs/debug_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( debug_node main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling debug_node with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( debug_node 13 | PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_debug_witness graphene_chain graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 14 | 15 | install( TARGETS 16 | debug_node 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /programs/delayed_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( delayed_node main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling delayed_node with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( delayed_node 13 | PRIVATE graphene_app graphene_account_history graphene_market_history graphene_delayed_node graphene_chain graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 14 | 15 | install( TARGETS 16 | delayed_node 17 | 18 | RUNTIME DESTINATION bin 19 | LIBRARY DESTINATION lib 20 | ARCHIVE DESTINATION lib 21 | ) 22 | -------------------------------------------------------------------------------- /programs/genesis_util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable( genesis_update genesis_update.cpp ) 3 | if( UNIX AND NOT APPLE ) 4 | set(rt_library rt ) 5 | endif() 6 | 7 | target_link_libraries( genesis_update 8 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 9 | 10 | install( TARGETS 11 | genesis_update 12 | 13 | RUNTIME DESTINATION bin 14 | LIBRARY DESTINATION lib 15 | ARCHIVE DESTINATION lib 16 | ) 17 | 18 | add_executable( get_dev_key get_dev_key.cpp ) 19 | 20 | target_link_libraries( get_dev_key 21 | PRIVATE graphene_app graphene_chain graphene_egenesis_none graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 22 | 23 | install( TARGETS 24 | get_dev_key 25 | 26 | RUNTIME DESTINATION bin 27 | LIBRARY DESTINATION lib 28 | ARCHIVE DESTINATION lib 29 | ) 30 | 31 | add_executable( convert_address convert_address.cpp ) 32 | 33 | target_link_libraries( convert_address 34 | PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 35 | -------------------------------------------------------------------------------- /programs/genesis_util/apply_patch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Apply a patch file to a JSON object") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-d", "--delta", metavar="DELTA", nargs="+", help="list of delta file(s) to apply") 19 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 20 | opts = parser.parse_args() 21 | 22 | if opts.input == "-": 23 | genesis = json.load(sys.stdin) 24 | else: 25 | with open(opts.input, "r") as f: 26 | genesis = json.load(f) 27 | 28 | if opts.delta is None: 29 | opts.delta = [] 30 | for filename in opts.delta: 31 | with open(filename, "r") as f: 32 | patch = json.load(f) 33 | for k, v in patch.get("append", {}).items(): 34 | if k not in genesis: 35 | genesis[k] = [] 36 | sys.stderr.write("[WARN] item {k} was created\n".format(k=k)) 37 | genesis[k].extend(v) 38 | sys.stderr.write("appended {n} items to {k}\n".format(n=len(v), k=k)) 39 | for k, v in patch.get("replace", {}).items(): 40 | genesis[k] = v 41 | sys.stderr.write("replaced item {k}\n".format(k=k)) 42 | 43 | if opts.output == "-": 44 | dump_json( genesis, sys.stdout, opts.pretty ) 45 | sys.stdout.flush() 46 | else: 47 | with open(opts.output, "w") as f: 48 | dump_json( genesis, f, opts.pretty ) 49 | return 50 | 51 | if __name__ == "__main__": 52 | main() 53 | -------------------------------------------------------------------------------- /programs/genesis_util/canonical_format.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | if len(sys.argv) < 3: 8 | print("syntax: "+sys.argv[0]+" INFILE OUTFILE") 9 | sys.exit(0) 10 | 11 | with open(sys.argv[1], "r") as infile: 12 | genesis = json.load(infile) 13 | with open(sys.argv[2], "w") as outfile: 14 | json.dump(genesis, outfile, separators=(',', ':'), sort_keys=True) 15 | -------------------------------------------------------------------------------- /programs/genesis_util/change_asset_symbol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Change an asset's symbol with referential integrity") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-f", "--from", metavar="PREFIX", default="", help="initial prefix") 19 | parser.add_argument("-t", "--to", metavar="PREFIX", default="", help="new prefix") 20 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 21 | opts = parser.parse_args() 22 | 23 | if opts.input == "-": 24 | genesis = json.load(sys.stdin) 25 | else: 26 | with open(opts.input, "r") as f: 27 | genesis = json.load(f) 28 | 29 | frum = opts.__dict__["from"] # from is a language keyword and cannot be an attribute name 30 | 31 | for asset in genesis["initial_assets"]: 32 | if asset["symbol"] == frum: 33 | asset["symbol"] = opts.to 34 | 35 | for balance in genesis["initial_balances"]: 36 | if balance["asset_symbol"] == frum: 37 | balance["asset_symbol"] = opts.to 38 | 39 | for vb in genesis["initial_vesting_balances"]: 40 | if balance["asset_symbol"] == frum: 41 | balance["asset_symbol"] = opts.to 42 | 43 | if opts.output == "-": 44 | dump_json( genesis, sys.stdout, opts.pretty ) 45 | sys.stdout.flush() 46 | else: 47 | with open(opts.output, "w") as f: 48 | dump_json( genesis, f, opts.pretty ) 49 | return 50 | 51 | if __name__ == "__main__": 52 | main() 53 | -------------------------------------------------------------------------------- /programs/genesis_util/change_bitasset_owners.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Change initial_assets owned by the witness-account to the committee-account") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 19 | opts = parser.parse_args() 20 | 21 | if opts.input == "-": 22 | genesis = json.load(sys.stdin) 23 | else: 24 | with open(opts.input, "r") as f: 25 | genesis = json.load(f) 26 | 27 | for asset in genesis["initial_assets"]: 28 | if asset["issuer_name"] == "witness-account": 29 | asset["issuer_name"] = "committee-account" 30 | 31 | if opts.output == "-": 32 | dump_json( genesis, sys.stdout, opts.pretty ) 33 | sys.stdout.flush() 34 | else: 35 | with open(opts.output, "w") as f: 36 | dump_json( genesis, f, opts.pretty ) 37 | return 38 | 39 | if __name__ == "__main__": 40 | main() 41 | -------------------------------------------------------------------------------- /programs/genesis_util/convert_address.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | * Convert BTC / PTS addresses to a Graphene address. 27 | */ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | using namespace graphene::chain; 35 | 36 | int main(int argc, char** argv) 37 | { 38 | // grab 0 or more whitespace-delimited PTS addresses from stdin 39 | std::string s; 40 | while( std::cin >> s ) 41 | { 42 | std::cout << std::string( address( pts_address( s ) ) ) << std::endl; 43 | } 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /programs/genesis_util/python_format.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | if len(sys.argv) < 3: 8 | print("syntax: "+sys.argv[0]+" INFILE OUTFILE") 9 | sys.exit(0) 10 | 11 | with open(sys.argv[1], "r") as infile: 12 | genesis = json.load(infile) 13 | with open(sys.argv[2], "w") as outfile: 14 | json.dump(genesis, outfile, indent=2, sort_keys=True) 15 | -------------------------------------------------------------------------------- /programs/genesis_util/sort_objects.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Sort initial_accounts and initial_assets by \"id\" member, then remove \"id\" member") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 19 | opts = parser.parse_args() 20 | 21 | if opts.input == "-": 22 | genesis = json.load(sys.stdin) 23 | else: 24 | with open(opts.input, "r") as f: 25 | genesis = json.load(f) 26 | 27 | genesis["initial_assets"].sort( key=lambda e : e["id"] ) 28 | genesis["initial_accounts"].sort( key=lambda e : e["id"] ) 29 | 30 | for e in genesis["initial_assets"]: 31 | del e["id"] 32 | for e in genesis["initial_accounts"]: 33 | del e["id"] 34 | 35 | if opts.output == "-": 36 | dump_json( genesis, sys.stdout, opts.pretty ) 37 | sys.stdout.flush() 38 | else: 39 | with open(opts.output, "w") as f: 40 | dump_json( genesis, f, opts.pretty ) 41 | return 42 | 43 | if __name__ == "__main__": 44 | main() 45 | -------------------------------------------------------------------------------- /programs/genesis_util/unprefix_asset_owners.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description="Set is_prefixed=false for all asset owners") 16 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 17 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 18 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 19 | opts = parser.parse_args() 20 | 21 | if opts.input == "-": 22 | genesis = json.load(sys.stdin) 23 | else: 24 | with open(opts.input, "r") as f: 25 | genesis = json.load(f) 26 | 27 | asset_owners = set() 28 | for asset in genesis["initial_assets"]: 29 | asset_owners.add(asset["issuer_name"]) 30 | for account in genesis["initial_accounts"]: 31 | if account["name"] in asset_owners: 32 | account["is_prefixed"] = False 33 | 34 | if opts.output == "-": 35 | dump_json( genesis, sys.stdout, opts.pretty ) 36 | sys.stdout.flush() 37 | else: 38 | with open(opts.output, "w") as f: 39 | dump_json( genesis, f, opts.pretty ) 40 | return 41 | 42 | if __name__ == "__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /programs/genesis_util/unprefix_names.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | def dump_json(obj, out, pretty): 8 | if pretty: 9 | json.dump(obj, out, indent=2, sort_keys=True) 10 | else: 11 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 12 | return 13 | 14 | def load_names(infile): 15 | names = set() 16 | for line in infile: 17 | if '#' in line: 18 | line = line[:line.index('#')] 19 | line = line.strip() 20 | if line == "": 21 | continue 22 | names.add(line) 23 | return names 24 | 25 | def main(): 26 | parser = argparse.ArgumentParser(description="Set is_prefixed=False for a list of names") 27 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 28 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 29 | parser.add_argument("-n", "--names", metavar="NAMES", help="list of names to unprefix") 30 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 31 | opts = parser.parse_args() 32 | 33 | if opts.input == "-": 34 | genesis = json.load(sys.stdin) 35 | else: 36 | with open(opts.input, "r") as f: 37 | genesis = json.load(f) 38 | 39 | if opts.names == "-": 40 | names = load_names(sys.stdin) 41 | else: 42 | with open(opts.names, "r") as f: 43 | names = load_names(f) 44 | 45 | for account in genesis["initial_accounts"]: 46 | if account["name"] in names: 47 | account["is_prefixed"] = False 48 | 49 | if opts.output == "-": 50 | dump_json( genesis, sys.stdout, opts.pretty ) 51 | sys.stdout.flush() 52 | else: 53 | with open(opts.output, "w") as f: 54 | dump_json( genesis, f, opts.pretty ) 55 | return 56 | 57 | if __name__ == "__main__": 58 | main() 59 | -------------------------------------------------------------------------------- /programs/genesis_util/upgrade_members.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import re 6 | import sys 7 | 8 | def dump_json(obj, out, pretty): 9 | if pretty: 10 | json.dump(obj, out, indent=2, sort_keys=True) 11 | else: 12 | json.dump(obj, out, separators=(",", ":"), sort_keys=True) 13 | return 14 | 15 | re_init = re.compile(r"^init[0-9]+$") 16 | 17 | def load_names(infile): 18 | names = set() 19 | for line in infile: 20 | if '#' in line: 21 | line = line[:line.index('#')] 22 | line = line.strip() 23 | if line == "": 24 | continue 25 | names.add(line) 26 | return names 27 | 28 | def main(): 29 | parser = argparse.ArgumentParser(description="Upgrade a list of members") 30 | parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)") 31 | parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)") 32 | parser.add_argument("-n", "--names", metavar="NAMES", default="", help="file containing names to upgrade") 33 | parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output") 34 | opts = parser.parse_args() 35 | 36 | if opts.input == "-": 37 | genesis = json.load(sys.stdin) 38 | else: 39 | with open(opts.input, "r") as f: 40 | genesis = json.load(f) 41 | 42 | if opts.names == "-": 43 | names = load_names(sys.stdin) 44 | else: 45 | with open(opts.names, "r") as f: 46 | names = load_names(f) 47 | 48 | for account in genesis["initial_accounts"]: 49 | if account["name"] in names: 50 | account["is_lifetime_member"] = True 51 | 52 | if opts.output == "-": 53 | dump_json( genesis, sys.stdout, opts.pretty ) 54 | sys.stdout.flush() 55 | else: 56 | with open(opts.output, "w") as f: 57 | dump_json( genesis, f, opts.pretty ) 58 | return 59 | 60 | if __name__ == "__main__": 61 | main() 62 | -------------------------------------------------------------------------------- /programs/js_operation_serializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( js_operation_serializer main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | target_link_libraries( js_operation_serializer 7 | PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_none graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 8 | 9 | install( TARGETS 10 | js_operation_serializer 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /programs/size_checker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( size_checker main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | target_link_libraries( size_checker 7 | PRIVATE graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 8 | 9 | install( TARGETS 10 | size_checker 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /programs/yoyow_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( yoyow_client main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling yoyow_client with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( yoyow_client 13 | PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 14 | 15 | if(MSVC) 16 | set_source_files_properties( main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 17 | endif(MSVC) 18 | 19 | install( TARGETS 20 | yoyow_client 21 | 22 | RUNTIME DESTINATION bin 23 | LIBRARY DESTINATION lib 24 | ARCHIVE DESTINATION lib 25 | ) 26 | -------------------------------------------------------------------------------- /programs/yoyow_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( yoyow_node main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | find_package( Gperftools QUIET ) 7 | if( GPERFTOOLS_FOUND ) 8 | message( STATUS "Found gperftools; compiling yoyow_node with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | # We have to link against graphene_debug_witness because deficiency in our API infrastructure doesn't allow plugins to be fully abstracted #246 13 | target_link_libraries( yoyow_node 14 | PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_debug_witness graphene_non_consensus graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 15 | 16 | install( TARGETS 17 | yoyow_node 18 | 19 | RUNTIME DESTINATION bin 20 | LIBRARY DESTINATION lib 21 | ARCHIVE DESTINATION lib 22 | ) 23 | -------------------------------------------------------------------------------- /programs/yoyow_node/saltpass.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import base64 4 | import getpass 5 | import hashlib 6 | import json 7 | import os 8 | 9 | pw = getpass.getpass("enter your password: ") 10 | pw_bytes = pw.encode("utf-8") 11 | salt_bytes = os.urandom(8) 12 | salt_b64 = base64.b64encode( salt_bytes ) 13 | pw_hash = hashlib.sha256( pw_bytes + salt_bytes ).digest() 14 | pw_hash_b64 = base64.b64encode( pw_hash ) 15 | 16 | print(json.dumps( 17 | { 18 | "password_hash_b64" : pw_hash_b64.decode("ascii"), 19 | "password_salt_b64" : salt_b64.decode("ascii"), 20 | }, 21 | sort_keys=True, 22 | indent=3, separators=(',', ' : ') 23 | )) 24 | -------------------------------------------------------------------------------- /programs/yy_abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 2.8.12 ) 2 | set(SOURCES main.cpp) 3 | find_package(LLVM 4.0 REQUIRED CONFIG) 4 | 5 | link_directories(${LLVM_LIBRARY_DIR}) 6 | 7 | add_executable(yy-abigen ${SOURCES}) 8 | 9 | set( CMAKE_CXX_STANDARD 14 ) 10 | 11 | if( UNIX AND NOT APPLE ) 12 | set(rt_library rt ) 13 | endif() 14 | 15 | find_package( Gperftools QUIET ) 16 | if( GPERFTOOLS_FOUND ) 17 | message( STATUS "Found gperftools; compiling with TCMalloc") 18 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 19 | endif() 20 | 21 | target_link_libraries(yy-abigen abi_generator) 22 | 23 | 24 | install( TARGETS 25 | yy-abigen 26 | 27 | RUNTIME DESTINATION bin 28 | LIBRARY DESTINATION lib 29 | ARCHIVE DESTINATION lib 30 | ) 31 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB COMMON_SOURCES "common/*.cpp") 2 | 3 | find_package( Gperftools QUIET ) 4 | if( GPERFTOOLS_FOUND ) 5 | message( STATUS "Found gperftools; compiling tests with TCMalloc") 6 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 7 | endif() 8 | 9 | file(GLOB UNIT_TESTS "tests/*.cpp") 10 | add_executable( chain_test ${UNIT_TESTS} ${COMMON_SOURCES} ) 11 | target_link_libraries( chain_test graphene_chain graphene_app graphene_account_history graphene_non_consensus graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} ) 12 | if(MSVC) 13 | set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 14 | set_source_files_properties( tests/content_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 15 | set_source_files_properties( common/database_fixture.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 16 | endif(MSVC) 17 | 18 | file(GLOB PERFORMANCE_TESTS "performance/*.cpp") 19 | add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} ) 20 | target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history graphene_non_consensus graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 21 | 22 | #file(GLOB BENCH_MARKS "benchmarks/*.cpp") 23 | #add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} ) 24 | #target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_non_consensus graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 25 | 26 | #file(GLOB APP_SOURCES "app/*.cpp") 27 | #add_executable( app_test ${APP_SOURCES} ) 28 | #target_link_libraries( app_test graphene_app graphene_account_history graphene_non_consensus graphene_net graphene_chain graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 29 | 30 | #file(GLOB INTENSE_SOURCES "intense/*.cpp") 31 | #add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} ) 32 | #target_link_libraries( intense_test graphene_chain graphene_app graphene_account_history graphene_non_consensus graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 33 | 34 | #add_subdirectory( generate_empty_blocks ) 35 | -------------------------------------------------------------------------------- /tests/benchmarks/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #define BOOST_TEST_MODULE "C++ Benchmarks for Graphene Blockchain Database" 25 | #include 26 | -------------------------------------------------------------------------------- /tests/content_update.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoyow-org/yoyow-core/f4fe6e48844b0c01dc267a04c6ef61b39f1ea1c1/tests/content_update.docx -------------------------------------------------------------------------------- /tests/generate_empty_blocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( generate_empty_blocks main.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | target_link_libraries( generate_empty_blocks 7 | PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 8 | 9 | install( TARGETS 10 | generate_empty_blocks 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /tests/hardfork05_update.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoyow-org/yoyow-core/f4fe6e48844b0c01dc267a04c6ef61b39f1ea1c1/tests/hardfork05_update.docx -------------------------------------------------------------------------------- /tests/intense/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | #include 26 | #include 27 | 28 | boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { 29 | std::srand(time(NULL)); 30 | std::cout << "Random number generator seeded to " << time(NULL) << std::endl; 31 | return nullptr; 32 | } 33 | -------------------------------------------------------------------------------- /tests/tests/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #include 25 | #include 26 | #include 27 | 28 | extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; 29 | 30 | boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { 31 | std::srand(time(NULL)); 32 | std::cout << "Random number generator seeded to " << time(NULL) << std::endl; 33 | const char* genesis_timestamp_str = getenv("GRAPHENE_TESTING_GENESIS_TIMESTAMP"); 34 | if( genesis_timestamp_str != nullptr ) 35 | { 36 | GRAPHENE_TESTING_GENESIS_TIMESTAMP = std::stoul( genesis_timestamp_str ); 37 | } 38 | std::cout << "GRAPHENE_TESTING_GENESIS_TIMESTAMP is " << GRAPHENE_TESTING_GENESIS_TIMESTAMP << std::endl; 39 | return nullptr; 40 | } 41 | -------------------------------------------------------------------------------- /tests/文章奖池流程图.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoyow-org/yoyow-core/f4fe6e48844b0c01dc267a04c6ef61b39f1ea1c1/tests/文章奖池流程图.docx -------------------------------------------------------------------------------- /tests/经济模型-公式版.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoyow-org/yoyow-core/f4fe6e48844b0c01dc267a04c6ef61b39f1ea1c1/tests/经济模型-公式版.xlsx -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11) 2 | 3 | configure_file( gxx.in gxx @ONLY ) 4 | install( FILES ${CMAKE_CURRENT_BINARY_DIR}/gxx DESTINATION ${CMAKE_INSTALL_PREFIX}/bin 5 | PERMISSIONS OWNER_READ 6 | OWNER_WRITE 7 | OWNER_EXECUTE 8 | GROUP_READ 9 | GROUP_EXECUTE 10 | WORLD_READ 11 | WORLD_EXECUTE 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /yoyow-3.0-guide.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoyow-org/yoyow-core/f4fe6e48844b0c01dc267a04c6ef61b39f1ea1c1/yoyow-3.0-guide.txt --------------------------------------------------------------------------------