├── .clang-format ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeModules ├── FindWasm.cmake ├── InstallDirectoryPermissions.cmake ├── installer.cmake └── wasm.cmake ├── LICENSE ├── README.md ├── contracts ├── CMakeLists.txt ├── examples │ ├── bank │ │ ├── README.md │ │ └── bank.cpp │ ├── helloworld │ │ ├── README.md │ │ ├── helloworld.abi │ │ ├── helloworld.cpp │ │ ├── helloworld.hpp │ │ ├── helloworld.wasm │ │ └── helloworld.wast │ ├── linear_vesting_asset │ │ ├── README.md │ │ └── linear_vesting_asset.cpp │ ├── redpacket │ │ ├── README.md │ │ └── redpacket.cpp │ ├── relay │ │ ├── Cross_chain.cpp │ │ ├── README.md │ │ └── relay.cpp │ ├── riddle │ │ ├── README.md │ │ └── riddle.cpp │ ├── swap │ │ ├── README.md │ │ ├── log.cpp │ │ ├── message.hpp │ │ └── swap.cpp │ └── test │ │ ├── apiexample │ │ └── example.cpp │ │ ├── bancor │ │ ├── README.md │ │ └── bancor.cpp │ │ ├── betdice │ │ ├── README.md │ │ └── betdice.cpp │ │ ├── callself │ │ ├── README.md │ │ └── callself.cpp │ │ ├── ccctransfer │ │ ├── README.md │ │ ├── contracta │ │ │ └── contracta.cpp │ │ └── contractb │ │ │ └── contractb.cpp │ │ ├── contract_call_contract_testcases │ │ ├── README.md │ │ ├── contracta │ │ │ └── contracta.cpp │ │ ├── contractb │ │ │ └── contractb.cpp │ │ ├── contractc │ │ │ └── contractc.cpp │ │ └── parameters.hpp │ │ ├── contract_storage_demo │ │ └── contract_storage_demo.cpp │ │ ├── dice │ │ ├── README.md │ │ └── dice.cpp │ │ ├── example_macro │ │ └── example_macro.cpp │ │ ├── idexdel │ │ └── idexdel.cpp │ │ ├── multindex │ │ └── multindex.cpp │ │ ├── recruitment │ │ ├── recruitment.abi │ │ ├── recruitment.cpp │ │ ├── recruitment.hpp │ │ ├── recruitment.wasm │ │ └── recruitment.wast │ │ ├── simpledice │ │ └── simpledice.cpp │ │ ├── testapi │ │ ├── inline_transfer_test.cpp │ │ └── testapi.cpp │ │ ├── testapi1 │ │ └── testapi1.cpp │ │ ├── testcase │ │ └── testcase.cpp │ │ ├── testmapset │ │ └── testmapset.cpp │ │ └── verify_sign │ │ ├── verify_sign.cpp │ │ └── verify_sign.hpp ├── 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 ├── Dockerfile ├── default_config.ini ├── gxchain_image_builder └── start.sh ├── externals └── CMakeLists.txt ├── genesis.json ├── libraries ├── CMakeLists.txt ├── abi_generator │ ├── CMakeLists.txt │ ├── abi_generator.cpp │ └── include │ │ └── graphene │ │ └── abi_generator │ │ └── abi_generator.hpp ├── app │ ├── CMakeLists.txt │ ├── api.cpp │ ├── application.cpp │ ├── database_api.cpp │ ├── database_api_impl.cpp │ ├── include │ │ └── graphene │ │ │ └── app │ │ │ ├── api.hpp │ │ │ ├── api_access.hpp │ │ │ ├── application.hpp │ │ │ ├── database_api.hpp │ │ │ ├── database_api_common.hpp │ │ │ ├── database_api_impl.hpp │ │ │ ├── full_account.hpp │ │ │ ├── network_broadcast_api.hpp │ │ │ └── plugin.hpp │ ├── network_broadcast_api.cpp │ └── plugin.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 │ ├── apply_context.cpp │ ├── assert_evaluator.cpp │ ├── asset_evaluator.cpp │ ├── asset_object.cpp │ ├── balance_evaluator.cpp │ ├── block_database.cpp │ ├── buyback.cpp │ ├── committee_member_evaluator.cpp │ ├── confidential_evaluator.cpp │ ├── contract_evaluator.cpp │ ├── data_market_evaluator.cpp │ ├── data_transaction_evaluator.cpp │ ├── database.cpp │ ├── datasource_copyright_evaluator.cpp │ ├── db_balance.cpp │ ├── db_block.cpp │ ├── db_debug.cpp │ ├── db_getter.cpp │ ├── db_init.cpp │ ├── db_maint.cpp │ ├── db_management.cpp │ ├── db_notify.cpp │ ├── db_update.cpp │ ├── db_witness_schedule.cpp │ ├── evaluator.cpp │ ├── fba_object.cpp │ ├── fork_database.cpp │ ├── free_data_product_evaluator.cpp │ ├── genesis_state.cpp │ ├── get_config.cpp │ ├── include │ │ └── graphene │ │ │ └── chain │ │ │ ├── abi_def.hpp │ │ │ ├── abi_serializer.hpp │ │ │ ├── account_evaluator.hpp │ │ │ ├── account_object.hpp │ │ │ ├── action.hpp │ │ │ ├── apply_context.hpp │ │ │ ├── assert_evaluator.hpp │ │ │ ├── asset_evaluator.hpp │ │ │ ├── asset_object.hpp │ │ │ ├── balance_evaluator.hpp │ │ │ ├── balance_object.hpp │ │ │ ├── block_database.hpp │ │ │ ├── block_summary_object.hpp │ │ │ ├── budget_record_object.hpp │ │ │ ├── buyback.hpp │ │ │ ├── buyback_object.hpp │ │ │ ├── chain_property_object.hpp │ │ │ ├── committee_member_evaluator.hpp │ │ │ ├── committee_member_object.hpp │ │ │ ├── confidential_evaluator.hpp │ │ │ ├── confidential_object.hpp │ │ │ ├── config.hpp │ │ │ ├── contract_evaluator.hpp │ │ │ ├── contract_table_objects.hpp │ │ │ ├── custom_evaluator.hpp │ │ │ ├── data_market_evaluator.hpp │ │ │ ├── data_market_object.hpp │ │ │ ├── data_transaction_evaluator.hpp │ │ │ ├── data_transaction_object.hpp │ │ │ ├── database.hpp │ │ │ ├── datasource_copyright_evaluator.hpp │ │ │ ├── datasource_copyright_object.hpp │ │ │ ├── db_with.hpp │ │ │ ├── evaluator.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── fba_accumulator_id.hpp │ │ │ ├── fba_object.hpp │ │ │ ├── fork_database.hpp │ │ │ ├── free_data_product_evaluator.hpp │ │ │ ├── free_data_product_object.hpp │ │ │ ├── genesis_state.hpp │ │ │ ├── get_config.hpp │ │ │ ├── global_property_object.hpp │ │ │ ├── hardfork.hpp │ │ │ ├── immutable_chain_parameters.hpp │ │ │ ├── impacted.hpp │ │ │ ├── internal_exceptions.hpp │ │ │ ├── is_authorized_asset.hpp │ │ │ ├── league_data_product_evaluator.hpp │ │ │ ├── league_data_product_object.hpp │ │ │ ├── league_evaluator.hpp │ │ │ ├── league_object.hpp │ │ │ ├── loyalty_evaluator.hpp │ │ │ ├── market_evaluator.hpp │ │ │ ├── market_object.hpp │ │ │ ├── multi_index_includes.hpp │ │ │ ├── node_property_object.hpp │ │ │ ├── operation_entry_object.hpp │ │ │ ├── operation_history_object.hpp │ │ │ ├── pay_data_transaction_evaluator.hpp │ │ │ ├── personal_auth_evaluator.hpp │ │ │ ├── personal_auth_object.hpp │ │ │ ├── pocs_object.hpp │ │ │ ├── proposal_evaluator.hpp │ │ │ ├── proposal_object.hpp │ │ │ ├── protocol │ │ │ ├── README.md │ │ │ ├── account.hpp │ │ │ ├── address.hpp │ │ │ ├── assert.hpp │ │ │ ├── asset.hpp │ │ │ ├── asset_ops.hpp │ │ │ ├── authority.hpp │ │ │ ├── balance.hpp │ │ │ ├── base.hpp │ │ │ ├── block.hpp │ │ │ ├── buyback.hpp │ │ │ ├── chain_parameters.hpp │ │ │ ├── committee_member.hpp │ │ │ ├── confidential.hpp │ │ │ ├── config.hpp │ │ │ ├── contract_asset.hpp │ │ │ ├── contract_ops.hpp │ │ │ ├── contract_receipt.hpp │ │ │ ├── custom.hpp │ │ │ ├── data_market_ops.hpp │ │ │ ├── data_storage_params.hpp │ │ │ ├── data_transaction_ops.hpp │ │ │ ├── datasource_copyright_ops.hpp │ │ │ ├── ext.hpp │ │ │ ├── fba.hpp │ │ │ ├── fee_schedule.hpp │ │ │ ├── free_data_product_ops.hpp │ │ │ ├── league_data_product_ops.hpp │ │ │ ├── league_ops.hpp │ │ │ ├── loyalty_ops.hpp │ │ │ ├── market.hpp │ │ │ ├── memo.hpp │ │ │ ├── name.hpp │ │ │ ├── operations.hpp │ │ │ ├── pay_data_transaction_ops.hpp │ │ │ ├── proposal.hpp │ │ │ ├── protocol.hpp │ │ │ ├── proxy_transfer_ops.hpp │ │ │ ├── special_authority.hpp │ │ │ ├── staking_ops.hpp │ │ │ ├── stale_ops.hpp │ │ │ ├── transaction.hpp │ │ │ ├── transfer.hpp │ │ │ ├── types.hpp │ │ │ ├── vesting.hpp │ │ │ ├── vote.hpp │ │ │ ├── withdraw_permission.hpp │ │ │ ├── witness.hpp │ │ │ └── worker.hpp │ │ │ ├── proxy_transfer_evaluator.hpp │ │ │ ├── pts_address.hpp │ │ │ ├── schema_context_object.hpp │ │ │ ├── second_hand_data_object.hpp │ │ │ ├── signature_object.hpp │ │ │ ├── special_authority.hpp │ │ │ ├── special_authority_object.hpp │ │ │ ├── staking_evaluator.hpp │ │ │ ├── staking_object.hpp │ │ │ ├── stale_evaluator.hpp │ │ │ ├── symbol.hpp │ │ │ ├── transaction_context.hpp │ │ │ ├── transaction_entry_object.hpp │ │ │ ├── transaction_evaluation_state.hpp │ │ │ ├── transaction_object.hpp │ │ │ ├── transfer_evaluator.hpp │ │ │ ├── trust_node_pledge_helper.hpp │ │ │ ├── vesting_balance_evaluator.hpp │ │ │ ├── vesting_balance_object.hpp │ │ │ ├── vote_count.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 │ │ │ ├── withdraw_permission_evaluator.hpp │ │ │ ├── withdraw_permission_object.hpp │ │ │ ├── witness_evaluator.hpp │ │ │ ├── witness_object.hpp │ │ │ ├── witness_schedule_object.hpp │ │ │ ├── worker_evaluator.hpp │ │ │ └── worker_object.hpp │ ├── is_authorized_asset.cpp │ ├── league_data_product_evaluator.cpp │ ├── league_evaluator.cpp │ ├── loyalty_evaluator.cpp │ ├── market_evaluator.cpp │ ├── name.cpp │ ├── pay_data_transaction_evaluator.cpp │ ├── proposal_evaluator.cpp │ ├── proposal_object.cpp │ ├── protocol │ │ ├── account.cpp │ │ ├── address.cpp │ │ ├── assert.cpp │ │ ├── asset.cpp │ │ ├── asset_ops.cpp │ │ ├── authority.cpp │ │ ├── block.cpp │ │ ├── committee_member.cpp │ │ ├── confidential.cpp │ │ ├── custom.cpp │ │ ├── fee_schedule.cpp │ │ ├── market.cpp │ │ ├── memo.cpp │ │ ├── operations.cpp │ │ ├── proposal.cpp │ │ ├── transaction.cpp │ │ ├── transfer.cpp │ │ ├── types.cpp │ │ ├── vote.cpp │ │ ├── withdraw_permission.cpp │ │ ├── witness.cpp │ │ └── worker.cpp │ ├── proxy_transfer_evaluator.cpp │ ├── pts_address.cpp │ ├── special_authority.cpp │ ├── staking_evaluator.cpp │ ├── stale_evaluator.cpp │ ├── transaction_context.cpp │ ├── transfer_evaluator.cpp │ ├── trust_node_pledge_helper.cpp │ ├── vesting_balance_evaluator.cpp │ ├── vesting_balance_object.cpp │ ├── wasm_binary_ops.cpp │ ├── wasm_injection.cpp │ ├── wasm_interface.cpp │ ├── wasm_validation.cpp │ ├── wast_to_wasm.cpp │ ├── webassembly │ │ ├── binaryen.cpp │ │ ├── wabt.cpp │ │ └── wavm.cpp │ ├── withdraw_permission_evaluator.cpp │ ├── witness_evaluator.cpp │ └── worker_evaluator.cpp ├── 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 ├── 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 │ ├── 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 │ ├── README.md │ ├── account_history │ │ ├── CMakeLists.txt │ │ ├── account_history_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── account_history │ │ │ └── account_history_plugin.hpp │ ├── account_history_leveldb │ │ ├── CMakeLists.txt │ │ ├── account_history_leveldb_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── account_history_leveldb │ │ │ └── account_history_leveldb_plugin.hpp │ ├── data_transaction │ │ ├── CMakeLists.txt │ │ ├── data_transaction_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── data_transaction │ │ │ └── data_transaction_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 │ ├── elasticsearch │ │ ├── CMakeLists.txt │ │ ├── elasticsearch_plugin.cpp │ │ └── include │ │ │ └── graphene │ │ │ └── elasticsearch │ │ │ └── elasticsearch_plugin.hpp │ ├── market_history │ │ └── market_history_plugin.cpp │ ├── query_txid │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── query_txid │ │ │ │ └── query_txid_plugin.hpp │ │ └── query_txid_plugin.cpp │ ├── snapshot │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── graphene │ │ │ │ └── snapshot │ │ │ │ └── snapshot.hpp │ │ └── snapshot.cpp │ └── witness │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── graphene │ │ │ └── witness │ │ │ └── witness.hpp │ │ └── witness.cpp ├── utilities │ ├── CMakeLists.txt │ ├── elasticsearch.cpp │ ├── git_revision.cpp.in │ ├── include │ │ └── graphene │ │ │ └── utilities │ │ │ ├── elasticsearch.hpp │ │ │ ├── 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 │ ├── check_reflect.py │ └── member_enumerator.cpp ├── cli_wallet │ ├── CMakeLists.txt │ └── main.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 ├── gxc_abigen │ ├── CMakeLists.txt │ └── main.cpp ├── js_operation_serializer │ ├── CMakeLists.txt │ └── main.cpp ├── size_checker │ ├── CMakeLists.txt │ └── main.cpp └── witness_node │ ├── CMakeLists.txt │ ├── main.cpp │ └── saltpass.py ├── script ├── boost_install.sh ├── gcc5_install.sh ├── gxchain_install.sh ├── gxchain_private_net_install.sh ├── gxchain_setup_dev_env_centos.sh ├── gxchain_testnet_install.sh └── monitor │ ├── gxs_fee_pool.py │ ├── opengateway_balance.py │ └── witness_participation_rate.py ├── tests ├── CMakeLists.txt ├── app │ └── main.cpp ├── benchmarks │ ├── genesis_allocation.cpp │ └── main.cpp ├── common │ ├── database_fixture.cpp │ └── database_fixture.hpp ├── generate_empty_blocks │ ├── CMakeLists.txt │ └── main.cpp ├── intense │ └── api_stress.py ├── performance │ └── performance_tests.cpp └── tests │ ├── asset_tests.cpp │ ├── authority_tests.cpp │ ├── basic_tests.cpp │ ├── block_tests.cpp │ ├── confidential_tests.cpp │ ├── cross_contract_calling_tests.cpp │ ├── database_api_tests.cpp │ ├── database_tests.cpp │ ├── fee_tests.cpp │ ├── history_api_tests.cpp │ ├── main.cpp │ ├── operation_tests.cpp │ ├── operation_tests2.cpp │ ├── serialization_tests.cpp │ ├── staking_tests.cpp │ ├── test_wasts.hpp │ ├── trust_node_pledge_tests.cpp │ ├── uia_tests.cpp │ ├── voting_tests.cpp │ └── wasm_tests.cpp └── tools ├── CMakeLists.txt └── gxx.in /.gitattributes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxchain/gxb-core/96ee1928eea8d82a91fa77b2e90e97e081eac559/.gitattributes -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | 37 | **Your GXChain Wallet Account** 38 | Please leave your GXChain wallet account for bug bounty . 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | 19 | **Your GXChain Wallet Account** 20 | Please leave your GXChain wallet account for bug bounty . 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .settings 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libraries/fc"] 2 | path = libraries/fc 3 | url = https://github.com/gxchain/gxb-fc.git 4 | [submodule "docs"] 5 | path = docs 6 | url = https://github.com/gxchain/gxb-core.wiki.git 7 | [submodule "libraries/softfloat"] 8 | path = libraries/softfloat 9 | url = https://github.com/gxchain/berkeley-softfloat-3.git 10 | [submodule "externals/binaryen"] 11 | path = externals/binaryen 12 | url = https://github.com/gxchain/binaryen.git 13 | [submodule "externals/magic_get"] 14 | path = externals/magic_get 15 | url = https://github.com/gxchain/magic_get.git 16 | [submodule "contracts/libc++/upstream"] 17 | path = contracts/libc++/upstream 18 | url = https://github.com/gxchain/libcxx.git 19 | [submodule "contracts/musl/upstream"] 20 | path = contracts/musl/upstream 21 | url = https://github.com/gxchain/musl.git 22 | [submodule "libraries/wabt"] 23 | path = libraries/wabt 24 | url = https://github.com/gxchain/wabt.git 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/gxc/skeleton/skeleton.cpp 15 | COMMAND ${CMAKE_COMMAND} -E make_directory ../share/gxc/skeleton 16 | COMMAND ${CMAKE_COMMAND} -E copy_directory 17 | ${CMAKE_CURRENT_SOURCE_DIR}/skeleton ../share/gxc/skeleton 18 | DEPENDS ${SKELETONS} 19 | COMMENT Copying skeleton contract... 20 | VERBATIM) 21 | add_custom_target(copy_skeleton_contract ALL DEPENDS share/gxc/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}/gxc) 30 | install_directory_permissions(DIRECTORY ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gxc) 31 | -------------------------------------------------------------------------------- /contracts/examples/bank/README.md: -------------------------------------------------------------------------------- 1 | bank 合约 2 | --------- 3 | bank 合约提供了充值(deposit)和提现(withdraw)方法,可以向合约充值、从合约中提取资产。 4 | 5 | 6 | #### 合约编译 7 | 8 | 1. 生成wast: 9 | ``` 10 | gxx -o contracts/examples/bank/bank.wast contracts/examples/bank/bank.cpp 11 | ``` 12 | 13 | 2. 生成abi: 14 | ``` 15 | gxx -g contracts/examples/bank/bank.abi contracts/examples/bank/bank.cpp 16 | ``` 17 | 18 | #### 合约部署和调用 19 | 20 | ##### 启动cli_wallet 21 | ``` 22 | ./programs/cli_wallet/cli_wallet -sws:///127.0.0.1:28099 --chain-id xxxx 23 | ``` 24 | 25 | ##### 部署合约 26 | ``` 27 | // 这里使用nathan帐户部署合约,部署的合约名为bank 28 | unlocked >>> deploy_contract bank nathan 0 0 ./contracts/examples/bank GXC true 29 | 30 | ``` 31 | 32 | ##### 调用合约 33 | 34 | 1. 调用合约的deposit方法 35 | ``` 36 | // 使用nathan帐户,调用bank合约,方法名为deposit, 发送资产总量为100 GXS(链上为大数,需要乘以10万) 37 | unlocked >>> call_contract nathan bank {"amount":10000000,"asset_id":1.3.1} deposit "{}" GXC true 38 | ``` 39 | 40 | 2. 查询bank合约的帐户余额 41 | ``` 42 | unlocked >>> list_account_balances bank 43 | 100 GXS 44 | ``` 45 | 46 | 3. 列出合约所有的存储表 47 | ``` 48 | unlocked >>> get_contract_tables bank 49 | [ 50 | "account" 51 | ] 52 | ``` 53 | 该bank合约只有一个account表 54 | 55 | 4. 查询合约的account表,该表记录了帐户在合约中的余额 56 | ``` 57 | unlocked >>> get_table_rows bank account 0 -1 58 | [{ 59 | "owner": 17, 60 | "balances": [{ 61 | "amount": 10000000, 62 | "asset_id": 1 63 | } 64 | ] 65 | } 66 | ] 67 | ``` 68 | 69 | 5. 调用合约的withdraw方法提现 70 | 71 | ``` 72 | // 提现到nathan帐户 73 | unlocked >>> call_contract nathan bank null withdraw "{\"to_account\":\"nathan\", \"amount\":{\"asset_id\": 1, \"amount\":100000}}" GXS true 74 | 75 | // 提现到init0帐户 76 | unlocked >>> call_contract nathan bank null withdraw "{\"to_account\":\"init0\", \"amount\":{\"asset_id\": 1, \"amount\":100000}}" GXS true 77 | 78 | ``` 79 | 80 | -------------------------------------------------------------------------------- /contracts/examples/helloworld/README.md: -------------------------------------------------------------------------------- 1 | helloworld 合约 2 | ------------- 3 | helloworld 合约用于简单的演示,提供了一个hi方法,调用该合约会打印一行日志。 4 | 5 | 6 | #### 编译合约 7 | 执行如下命令, 生成wast和wasm文件: 8 | ``` 9 | gxx -o helloworld/helloworld.wast helloworld/helloworld.cpp 10 | ``` 11 | 12 | 生成abi: 13 | ``` 14 | gxx -g helloworld/helloworld.abi helloworld/helloworld.cpp 15 | ``` 16 | 17 | #### 部署合约 18 | 以开发环境为例,使用cli_wallet部署合约。 19 | 20 | 执行cli_wallet,连接到本地节点: 21 | ``` 22 | // --chain-id 填写本地链的chain-id 23 | ./programs/cli_wallet/cli_wallet -sws://127.0.0.1:28090 --chain-id bc59e6e7f500fa56504ce7101f7df8eb74151398f62167567adcf18a026928d1 24 | 25 | ``` 26 | 27 | 如果之前没有导入过私钥,需要设置钱包密码、导入私钥,如下: 28 | ``` 29 | new >>> set_password caochong 30 | 31 | 32 | locked >>> unlock caochong 33 | 34 | // 导入nathan帐户私钥 35 | unlocked >>> import_key nathan 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 36 | 37 | ``` 38 | 39 | 上述步骤完成后,使用deploy_contract方法部署合约: 40 | 41 | ``` 42 | // 使用nathan帐户,部署名为helloworld的合约 43 | unlocked >>> deploy_contract helloworld nathan 0 0 ./helloworld GXS true 44 | 45 | ``` 46 | 其中 47 | ``` 48 | // helloworld指定将要创建的合约名 49 | // nathan为部署合约的帐户 50 | // 0 0 分别指定了vm类型和版本号 51 | // ./helloworld指定合约文件的路径 52 | // GXS表示使用GXS支付手续费 53 | // true表示执行,发起广播 54 | ``` 55 | 56 | #### 调用合约 57 | 调用helloworld合约的hi方法: 58 | ``` 59 | unlocked >>> call_contract nathan helloworld null hi "{\"user\":\"zhuliting\"}" GXS true 60 | ``` 61 | 其中 62 | ``` 63 | // nathan指定调用合约的帐户 64 | // helloworld指定要调用的合约帐户名 65 | // null 表示不向合约发送资产 66 | // hi 表示要调用的合约方法 67 | // "{\"user\":\"zhuliting\"}" 表示合约hi文件的参数,参数以json格式传入 68 | // GXS表示使用GXS支付手续费 69 | // true表示执行,发起广播 70 | ``` 71 | 72 | -------------------------------------------------------------------------------- /contracts/examples/helloworld/helloworld.abi: -------------------------------------------------------------------------------- 1 | { 2 | "____comment": "This file was generated by gxc-abigen. DO NOT EDIT - 2018-08-08T03:47:17", 3 | "version": "gxc::abi/1.0", 4 | "types": [], 5 | "structs": [{ 6 | "name": "hi", 7 | "base": "", 8 | "fields": [{ 9 | "name": "user", 10 | "type": "string" 11 | } 12 | ] 13 | } 14 | ], 15 | "actions": [{ 16 | "name": "hi", 17 | "type": "hi", 18 | "payable": false 19 | } 20 | ], 21 | "tables": [], 22 | "error_messages": [], 23 | "abi_extensions": [] 24 | } -------------------------------------------------------------------------------- /contracts/examples/helloworld/helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace graphene; 7 | 8 | class helloworld : public contract 9 | { 10 | public: 11 | helloworld(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(helloworld, (hi)) 26 | -------------------------------------------------------------------------------- /contracts/examples/helloworld/helloworld.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /contracts/examples/helloworld/helloworld.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxchain/gxb-core/96ee1928eea8d82a91fa77b2e90e97e081eac559/contracts/examples/helloworld/helloworld.wasm -------------------------------------------------------------------------------- /contracts/examples/linear_vesting_asset/README.md: -------------------------------------------------------------------------------- 1 | 2 | linear_vesting_asset合约 3 | ------------- 4 | 5 | 线性解冻资产合约,可以通过vestingcreate方法向某一帐户(A)转帐,同时设置冻结时间(lock_duration)和释放时间(release_duration),即经过lock_duration 秒后,资产开始解冻,经过release_duration秒后,A帐户可以调用vestingclaim方法,将资产全部取出。 6 | 7 | 8 | #### 编译合约 9 | 生成wast: 10 | ``` 11 | gxx -o contracts/examples/linear_vesting_asset/linear_vesting_asset.wast contracts/examples/linear_vesting_asset/linear_vesting_asset.cpp 12 | ``` 13 | 生成abi 14 | ``` 15 | gxx -g contracts/examples/linear_vesting_asset/linear_vesting_asset.abi contracts/examples/linear_vesting_asset/linear_vesting_asset.cpp 16 | ``` 17 | 18 | 19 | #### 部署合约 20 | ``` 21 | deploy_contract ch3 nathan 0 0 ./contracts/examples/linear_vesting_asset/ GXS true 22 | ``` 23 | #### 调用合约 24 | 25 | 1. 从beita账号转账给nathan,100GXC(1.3.0),锁定30秒后开始根据时间线性释放,120秒全部释放完毕 26 | ``` 27 | call_contract beita t81611 {"amount":10000000,"asset_id":1.3.0} vestingcreate "{\"to\":\"nathan\",\"lock_duration\":30,\"release_duration\":120}" GXC true 28 | ``` 29 | 30 | 2. 查询合约ch3有哪些表 31 | ``` 32 | unlocked >>> get_contract_tables ch3 33 | [ 34 | "vestingrule" 35 | ] 36 | ``` 37 | 38 | 3. 查询合约ch3 vestingrule,最多查询10ms就立即返回结果 39 | ``` 40 | unlocked >>> get_table_rows ch3 vestingrule 0 -1 41 | [{ 42 | "account_id": 17, 43 | "asset_id": 0, 44 | "vesting_amount": 10000000, 45 | "vested_amount": 0, 46 | "lock_time_point": 1534422875, 47 | "lock_duration": 30, 48 | "release_time_point": 1534422905, 49 | "release_duration": 120 50 | } 51 | ] 52 | 53 | ``` 54 | 55 | 4. 查询合约下有多少资产 56 | 57 | ``` 58 | unlocked >>> list_account_balances ch3 59 | 100 GXC 60 | ``` 61 | 62 | 5. 尝试释放ch3中nathan的GXC(1.3.0)资产,根据当前时间和vestingrule来释放 63 | ``` 64 | call_contract beita t81611 null vestingclaim "{\"who\":\"nathan\"}" GXC true 65 | ``` 66 | -------------------------------------------------------------------------------- /contracts/examples/riddle/README.md: -------------------------------------------------------------------------------- 1 | riddle 合约 2 | 3 | ------ 4 | 5 | riddle合约是一个谜题合约,提供2个接口:(issue)发行谜题和(reveal)解密谜题。 6 | 7 | 任意一个帐户都可以调用issue方法来创建一个谜题,创建时带上问题和加密的答案,问题和答案将会保存在合约里。解谜时调用reveal方法,带上明文答案。 8 | 9 | #### 合约编译 10 | 11 | 1. 生成wast: 12 | 13 | ``` 14 | gxx -o contracts/examples/riddle/riddle.wast contracts/examples/riddle/riddle.cpp 15 | ``` 16 | 17 | 2. 生成abi: 18 | 19 | ``` 20 | gxx -g contracts/examples/riddle/riddle.abi contracts/examples/riddle/riddle.cpp 21 | ``` 22 | 23 | #### 合约部署和调用 24 | 25 | ##### 启动cli_wallet 26 | 27 | ``` 28 | ./programs/cli_wallet/cli_wallet -sws:///127.0.0.1:28099 --chain-id xxxx 29 | ``` 30 | 31 | ##### 部署合约 32 | 33 | ```shell 34 | // 这里使用nathan帐户部署合约,部署的合约名为riddle 35 | unlocked >>> deploy_contract riddle nathan 0 0 ./contracts/examples/riddle GXC true 36 | ``` 37 | 38 | ##### 调用合约 39 | 40 | 1. 发起谜题, 使用nathan帐户,发起一个谜题,问题:"1 + 2 = ?" 答案: "I don't know." 41 | 42 | ```shell 43 | 字符串生成sha256 命令行: 44 | # echo -n "I don't know." | shasum -a 256 45 | 810d7c3ca6aa6411102588f8636833035138a35f32f5e7b2df96d2ab2dc4d660 46 | ``` 47 | 48 | ```shell 49 | // 发起谜题 50 | call_contract nathan riddle null issue "{\"question\":\"1 + 2 = ?\", \"hashed_answer\":\"810d7c3ca6aa6411102588f8636833035138a35f32f5e7b2df96d2ab2dc4d660\"}" GXC true 51 | ``` 52 | 53 | 2. 查询riddle合约的存储表 54 | 55 | ``` 56 | unlocked >>> get_table_objects riddle record 57 | [{ 58 | "issuer": 17, 59 | "question": "1 + 2 = ?", 60 | "hashed_answer": "810d7c3ca6aa6411102588f8636833035138a35f32f5e7b2df96d2ab2dc4d660" 61 | } 62 | ] 63 | ``` 64 | 65 | 3. 解开谜题 66 | 67 | ``` 68 | // 使用nathan帐户解谜 69 | unlocked >>> call_contract nathan riddle null reveal "{\"issuer\":\"nathan\", \"answer\":\"I don't know.\"}" GXC true 70 | ``` 71 | 72 | 4. 合约存储表 73 | 74 | ``` 75 | unlocked >>> get_table_rows riddle record 0 -1 76 | [] 77 | ``` 78 | -------------------------------------------------------------------------------- /contracts/examples/swap/log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define INVALID_SENDER "Invalid sender." 5 | 6 | using namespace graphene; 7 | 8 | // swap合约账户. 9 | static const int64_t SWAPACCOUNT = 5308; 10 | 11 | class log : public contract { 12 | public: 13 | log(int64_t account_id) 14 | : contract(account_id) {} 15 | 16 | //@abi action 17 | void addlq(int64_t amount1, int64_t amount2, int64_t lq) { 18 | graphene_assert(get_trx_sender() == SWAPACCOUNT, INVALID_SENDER); 19 | } 20 | }; 21 | GRAPHENE_ABI(log, (addlq)) -------------------------------------------------------------------------------- /contracts/examples/swap/message.hpp: -------------------------------------------------------------------------------- 1 | #define INVALID_PARAMS "Invalid params." 2 | #define INVALID_TRADING_PAIR "Invalid trading pair." 3 | #define INVALID_TO_ACCOUNT "Invalid to account." 4 | #define INVALID_FROM_ACCOUNT "Invalid from account." 5 | #define INVALID_SENDER_ACCOUNT "Invalid sender account." 6 | #define INVALID_PATH "Invalid path." 7 | #define PAIR_LOCKED "The trading pair has been locked." 8 | 9 | #define INSUFFICIENT_AMOUNT "Insufficient amount." 10 | #define INSUFFICIENT_ALLOWANCE "Insufficient allowance." 11 | #define INSUFFICIENT_LIQUIDITY "Insufficient liquidity." 12 | 13 | #define NUMBER_OVERFLOW "Number overflow." -------------------------------------------------------------------------------- /contracts/examples/test/bancor/README.md: -------------------------------------------------------------------------------- 1 | #### 调用合约 2 | 3 | ##### 初始化bancor:需要调用2次,使用2个资产创建2个connector, 之后这2个资产就可以基于bancor的buy方法进行互相兑换 4 | 5 | ``` 6 | call_contract beita bancor20 {"amount":10000000,"asset_id":1.3.1} issue "{}" GXC true 7 | call_contract beita bancor20 {"amount":100000000,"asset_id":1.3.2} issue "{}" GXC true 8 | ``` 9 | 10 | ##### 开始执行asset_id(1.3.1(GXS))和asset_id(1.3.2(TXT))两种资产的互相兑换 11 | 12 | 用1000个TXT兑换一定量的GXS 13 | 14 | ``` 15 | call_contract beita bancor20 {"amount":100000000,"asset_id":1.3.2} buy "{}" GXC true 16 | ``` 17 | 用1000个GXS兑换一定量的TXT 18 | 19 | ``` 20 | call_contract beita bancor20 {"amount":100000000,"asset_id":1.3.1} buy "{}" GXC true 21 | ``` 22 | 23 | 查询合约币的状态,合约币并不真正存在这种资产,只是作为状态记录在合约中,用于根据supply和cw进行计算价格等 24 | 25 | ``` 26 | get_table_objects bancor coinmarket 27 | ``` 28 | 29 | [{ 30 | "bancorid": 1016, 31 | "supply": 100000000, 32 | "base": { 33 | "balance": { 34 | "amount": 9695770, 35 | "asset_id": 1 36 | }, 37 | "weight": "0.50000000000000000" 38 | }, 39 | "quote": { 40 | "balance": { 41 | "amount": 103226653, 42 | "asset_id": 2 43 | }, 44 | "weight": "0.50000000000000000" 45 | } 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /contracts/examples/test/betdice/README.md: -------------------------------------------------------------------------------- 1 | betdice 合约 2 | --------- 3 | 4 | ##### 部署合约 5 | ``` 6 | deploy_contract b7 nathan 0 0 /Users/sky/gxb_install/betdice GXC true 7 | ``` 8 | 9 | ##### 调用合约 10 | 11 | 1. 初始化合约 12 | ``` 13 | call_contract nathan b7 null init "{}" GXC true 14 | ``` 15 | 16 | 2. 向合约充值 17 | ``` 18 | call_contract nathan b7 {"amount":1000000000,"asset_id":1.3.0} deposit "{}" GXC true 19 | ``` 20 | 21 | 3. roll 22 | ``` 23 | call_contract beita b7 {"amount":20000000,"asset_id":1.3.0} roll "{\"roll_under\":35,\"roll_seed\":\"gooaadd\"}" GXC true 24 | ``` 25 | 26 | 4. 从合约提取资金 27 | ``` 28 | call_contract beita b7 null withdraw "{\"amt\":100000000,\"to\":18}" GXC true 29 | ``` 30 | 31 | ##### 查询合约 32 | 33 | ``` 34 | get_table_objects b7 globalvar 1 111 1111 35 | 36 | get_table_objects b7 bet 1 111 1111 37 | ``` 38 | 39 | -------------------------------------------------------------------------------- /contracts/examples/test/callself/README.md: -------------------------------------------------------------------------------- 1 | ### 用于测试跨合约调用当合约调用自己的情况 2 | 3 | ``` 4 | deploy_contract cs dev 0 0 /Users/sky/gxb_install/callself GXC true 5 | 6 | call_contract dev cs null f1 "{\"p1\":100000}" GXC true 7 | ``` 8 | -------------------------------------------------------------------------------- /contracts/examples/test/callself/callself.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace graphene; 8 | 9 | class callself : public contract 10 | { 11 | public: 12 | callself(uint64_t uname) 13 | : contract(uname) 14 | { 15 | } 16 | 17 | // @abi action 18 | // @abi payable 19 | void f1(uint64_t p1) 20 | { 21 | print("hi i'm function f1, hello p1:", p1, "\n"); 22 | struct p { 23 | uint64_t p1; 24 | }; 25 | p pf1{100}; 26 | action a(_self, N(f2), std::move(p1), _self, {100000, 1}); 27 | a.send(); 28 | } 29 | 30 | // @abi action 31 | // @abi payable 32 | void f2(uint64_t p1) 33 | { 34 | print("hi i'm function f2, hello p1:", p1, "\n"); 35 | } 36 | }; 37 | 38 | GRAPHENE_ABI(callself, (f1)(f2)) 39 | -------------------------------------------------------------------------------- /contracts/examples/test/ccctransfer/README.md: -------------------------------------------------------------------------------- 1 | ### 用于测试跨合约转账 2 | - user(dev) [4GXC] --> contracta [1GXC] --> contractb 3 | 4 | #### case1 5 | ``` 6 | 用户dev调用合约contracta同时向合约转账4GXC,合约contracta调用contractb同时向contractb转账1GXC 7 | contracta,contractb初始余额为0,最终调用失败,原因是跟函数一样,在dev调用contracta的hi方法时,hi方法会调用contractb,此时contracta的hi方法没有执行完毕,所以此时余额是0,相当于函数执行过程中压栈,之后执行向合约contractb转账1GXC由于余额不够最终失败 8 | ``` 9 | 10 | #### case2 11 | ``` 12 | 用户dev调用合约contracta同时向合约转账4GXC,合约contracta调用contractb同时向contractb转账1GXC 13 | contracta,contractb初始余额为10GXC,最终contracta余额13GXC,contractb余额11GXC 14 | ``` -------------------------------------------------------------------------------- /contracts/examples/test/ccctransfer/contracta/contracta.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace graphene; 8 | 9 | class contracta : public contract 10 | { 11 | public: 12 | contracta(uint64_t uname) 13 | : contract(uname) 14 | { 15 | } 16 | 17 | // @abi action 18 | // @abi payable 19 | void hi(uint64_t contratb_id) 20 | { 21 | print("hi i'm contracta's function hi\n"); 22 | 23 | action b(contratb_id, N(hi), "", _self, {100000, 1}); 24 | b.send(); 25 | } 26 | }; 27 | 28 | GRAPHENE_ABI(contracta, (hi)) 29 | -------------------------------------------------------------------------------- /contracts/examples/test/ccctransfer/contractb/contractb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace graphene; 8 | 9 | class contractb : public contract 10 | { 11 | public: 12 | contractb(uint64_t uname) 13 | : contract(uname) 14 | { 15 | } 16 | 17 | // @abi action 18 | // @abi payable 19 | void hi() 20 | { 21 | print("hi i'm contractb\n"); 22 | } 23 | }; 24 | 25 | GRAPHENE_ABI(contractb, (hi)) 26 | -------------------------------------------------------------------------------- /contracts/examples/test/contract_call_contract_testcases/README.md: -------------------------------------------------------------------------------- 1 | ## contract test cases 2 | -------------------------------------------------------------------------------- /contracts/examples/test/contract_call_contract_testcases/parameters.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct circle_params_t { 4 | std::string ccca; 5 | std::string cccb; 6 | std::string cccc; 7 | }; 8 | 9 | struct sender_params_t { 10 | std::string ccca; 11 | std::string cccb; 12 | std::string cccc; 13 | uint64_t cnt; 14 | }; 15 | 16 | struct origin_params_t { 17 | std::string origin; 18 | std::string ccca; 19 | std::string cccb; 20 | std::string cccc; 21 | uint64_t cnt; 22 | }; 23 | 24 | struct ram_params_t { 25 | std::string ccca; 26 | std::string cccb; 27 | std::string cccc; 28 | bool aflag; 29 | bool bflag; 30 | bool cflag; 31 | uint64_t pk = 0; 32 | }; 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /contracts/examples/test/recruitment/recruitment.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxchain/gxb-core/96ee1928eea8d82a91fa77b2e90e97e081eac559/contracts/examples/test/recruitment/recruitment.wasm -------------------------------------------------------------------------------- /contracts/examples/test/testapi/inline_transfer_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace graphene; 12 | 13 | class bank : public contract 14 | { 15 | public: 16 | bank(uint64_t account_id) 17 | : contract(account_id) 18 | { 19 | } 20 | 21 | // @abi action 22 | // @abi payable 23 | void deposit() 24 | { 25 | uint64_t owner = get_trx_sender(); 26 | print("hello, ", owner, "\n"); 27 | } 28 | 29 | // @abi action 30 | void withdraw(std::string to_account, contract_asset amount) 31 | { 32 | int64_t account_id = get_account_id(to_account.c_str(), to_account.size()); 33 | graphene_assert(account_id >= 0, "invalid account_name to_account"); 34 | graphene_assert(amount.amount > 0, "invalid amount"); 35 | 36 | std::string memo = "withdraw test";; 37 | inline_transfer(_self, account_id, amount.asset_id, amount.amount, memo.c_str(), memo.size()); 38 | } 39 | }; 40 | 41 | GRAPHENE_ABI(bank, (deposit)(withdraw)) 42 | -------------------------------------------------------------------------------- /contracts/examples/test/testapi/testapi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace graphene; 9 | 10 | class testapi : public contract 11 | { 12 | public: 13 | testapi(uint64_t id) 14 | : contract(id) 15 | { 16 | } 17 | 18 | /// @abi action 19 | void test() 20 | { 21 | char dst[1024] = {0}; 22 | //获取当前合约调用所属transaction序列化后的数据到的长度 23 | int dst_len = transaction_size(); 24 | print("transaction_size() = ", dst_len, "\n"); 25 | 26 | //获取当前合约调用所属transaction序列化后的数据到dst中 27 | read_transaction(dst, dst_len); 28 | 29 | //计算dst的sha256并输出前20byte。trx_id的值就是transaction的序列化数据的sha256的前20个字节 30 | checksum256 hs; 31 | sha256(dst, dst_len, &hs); 32 | printhex(hs.hash, 20); 33 | print("\n"); 34 | 35 | printhex(dst, dst_len); 36 | print("\n"); 37 | 38 | //获取当前合约调用所属transaction的过期时间,单位秒 39 | print("expiration() = ", expiration(), "\n"); 40 | 41 | //获取当前合约调用所属block的ref block number 42 | print("tapos_block_num() = ", tapos_block_num(), "\n"); 43 | 44 | //获取当前合约调用所属block的ref block prefix 45 | print("tapos_block_prefix() = ", tapos_block_prefix(), "\n"); 46 | } 47 | }; 48 | 49 | GRAPHENE_ABI(testapi, (test)) 50 | -------------------------------------------------------------------------------- /contracts/examples/test/testmapset/testmapset.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace graphene; 9 | 10 | class testmapset : public contract 11 | { 12 | public: 13 | testmapset(uint64_t id) 14 | : contract(id), mapsettabs(_self, _self) 15 | { 16 | } 17 | 18 | /// @abi action 19 | void mapaction(std::map mappar) 20 | { 21 | auto itor = mappar.begin(); 22 | auto str = itor->first; 23 | auto num = itor->second; 24 | for (int i = 0; i < 1; ++i) { 25 | print("str:",str,"\n"); 26 | print("num:",num,"\n"); 27 | 28 | } 29 | uint64_t pk = mapsettabs.available_primary_key(); 30 | mapsettabs.emplace(0, [&](auto &o) { 31 | o.id = pk; 32 | o.mymap = mappar; 33 | }); 34 | } 35 | 36 | // @abi action 37 | void setaction(std::set setpar) 38 | { 39 | auto itor = setpar.begin(); 40 | print("set: ",*itor,"\n"); 41 | 42 | uint64_t pk = mapsettabs.available_primary_key(); 43 | mapsettabs.emplace(0, [&](auto &o) { 44 | o.id = pk; 45 | o.myset = setpar; 46 | }); 47 | } 48 | 49 | //@abi table mapsettab i64 50 | struct mapsettab { 51 | uint64_t id; 52 | std::map mymap; 53 | std::set myset; 54 | 55 | uint64_t primary_key() const { return id; } 56 | 57 | GRAPHENE_SERIALIZE(mapsettab, (id)(mymap)(myset)) 58 | }; 59 | 60 | typedef graphene::multi_index mapset_index; 61 | mapset_index mapsettabs; 62 | 63 | }; 64 | 65 | GRAPHENE_ABI(testmapset, (mapaction)(setaction)) 66 | -------------------------------------------------------------------------------- /contracts/examples/test/verify_sign/verify_sign.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace graphene; 9 | 10 | class verify_sign : public contract 11 | { 12 | public: 13 | verify_sign(uint64_t id) 14 | : contract(id) 15 | { 16 | } 17 | 18 | void verify(std::string raw_string, std::string pub_key, signature sig) 19 | { 20 | print("string, ", raw_string, "\n"); 21 | print(pub_key, "\n"); 22 | bool flag = verify_signature(raw_string.c_str(), raw_string.length(), &sig, pub_key.c_str(), pub_key.length()); 23 | print("ret code, ", flag, "\n"); 24 | } 25 | }; 26 | 27 | GRAPHENE_ABI(verify_sign, (verify)) 28 | -------------------------------------------------------------------------------- /contracts/examples/test/verify_sign/verify_sign.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /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/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/gxc 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/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gxchain/builder 2 | MAINTAINER GXChain 3 | 4 | 5 | RUN export LC_ALL=C 6 | 7 | RUN git config --global http.postBuffer 1048576000 8 | 9 | RUN git clone https://github.com/gxchain/gxb-core.git 10 | RUN cd gxb-core \ 11 | && git checkout master \ 12 | && git submodule update --init --recursive \ 13 | && mkdir build && cd build \ 14 | && export WASM_ROOT=~/opt/wasm \ 15 | && export C_COMPILER=clang-4.0 \ 16 | && export CXX_COMPILER=clang++-4.0 \ 17 | && cmake -G "Unix Makefiles" -DWASM_ROOT=~/opt/wasm -DCMAKE_INSTALL_PREFIX=~/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release .. \ 18 | && make witness_node cli_wallet \ 19 | && cp -rf programs /usr/local/ 20 | 21 | # Home directory $HOME 22 | WORKDIR / 23 | 24 | ENV GXB_DATA /gxb 25 | RUN rm -rf "$GXB_DATA" \ 26 | && mkdir "$GXB_DATA" \ 27 | && ln -sfn /usr/local/programs "$GXB_DATA" 28 | 29 | VOLUME /gxb 30 | 31 | # Copy default configuration 32 | ADD docker/start.sh /start.sh 33 | ADD genesis.json /genesis.json 34 | RUN chmod a+x /start.sh 35 | 36 | # rpc service port(cli_wallet or witness_node) 37 | EXPOSE 8091 38 | 39 | # P2P node to connect to on startup 40 | EXPOSE 8092 41 | 42 | # Endpoint for P2P node to listen on 43 | EXPOSE 8093 44 | 45 | # Entry point 46 | ENTRYPOINT [ "/start.sh" ] 47 | -------------------------------------------------------------------------------- /docker/gxchain_image_builder: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER GXS 3 | 4 | ENV LANG=en_US.UTF-8 5 | 6 | RUN \ 7 | apt-get update -y && \ 8 | apt-get install -y \ 9 | software-properties-common wget make python-dev \ 10 | libbz2-dev libdb++-dev libdb-dev libssl-dev \ 11 | openssl libreadline-dev autoconf libtool \ 12 | git ntp doxygen 13 | 14 | RUN \ 15 | apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main" && \ 16 | apt-get update -y && \ 17 | apt-get install -y --force-yes clang-4.0 lldb-4.0 libclang-4.0-dev 18 | 19 | RUN \ 20 | cd /tmp && wget https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.sh && \ 21 | mkdir -p /opt/cmake && chmod +x /tmp/cmake-3.11.0-Linux-x86_64.sh && \ 22 | bash /tmp/cmake-3.11.0-Linux-x86_64.sh --prefix=/opt/cmake --skip-license && \ 23 | ln -sfT /opt/cmake/bin/cmake /usr/local/bin/cmake 24 | 25 | RUN \ 26 | apt-get update -y && \ 27 | apt-get install -y gcc g++ 28 | 29 | RUN \ 30 | wget https://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.gz/download -O boost_1_67_0.tar.gz && \ 31 | tar -zxvf boost_1_67_0.tar.gz && cd boost_1_67_0 && chmod +x bootstrap.sh && \ 32 | ./bootstrap.sh --prefix=/usr && \ 33 | ./b2 --buildtype=complete install 34 | 35 | RUN \ 36 | mkdir ~/wasm-compiler && cd ~/wasm-compiler && \ 37 | git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git && \ 38 | cd llvm/tools && \ 39 | git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git && \ 40 | cd .. && mkdir -p build && cd build && \ 41 | cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=~/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release .. && \ 42 | make -j4 install 43 | 44 | 45 | -------------------------------------------------------------------------------- /docker/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | APPPATH="/gxb/programs" 4 | ARGS="" 5 | 6 | # Translate environmental variables 7 | if [[ "$bool_wallet" == "true" ]] || [[ -z "$bool_wallet" ]]; then 8 | APPPATH+="/cli_wallet/cli_wallet" 9 | ARGS+="" 10 | if [[ ! -z "$ws_server" ]]; then 11 | ARGS+=" -s${ws_server}" 12 | fi 13 | 14 | if [[ ! -z "$rpc_endpoint" ]]; then 15 | ARGS+=" -r${rpc_endpoint}" 16 | fi 17 | 18 | if [[ ! -z "$data_dir" ]]; then 19 | ARGS+=" --data-dir=${data_dir}" 20 | fi 21 | 22 | if [[ ! -z "$wallet_file" ]]; then 23 | ARGS+=" --wallet-file=${wallet_file}" 24 | fi 25 | elif [[ "$bool_wallet" == "false" ]] 26 | APPPATH+="/witness_node/witness_node" 27 | ARGS+=" --enable-stale-production" 28 | if [[ ! -z "$data_dir" ]]; then 29 | ARGS+=" --data-dir=${data_dir}" 30 | fi 31 | 32 | if [[ ! -z "$rpc_endpoint" ]]; then 33 | ARGS+=" --rpc-endpoint=${rpc_endpoint}" 34 | fi 35 | 36 | if [[ ! -z "$witness_id" ]]; then 37 | ARGS+=" --witness-id=${witness_id}" 38 | fi 39 | 40 | if [[ ! -z "$seed_nodes" ]]; then 41 | ARGS+=" --seed-nodes=${seed_nodes}" 42 | fi 43 | 44 | if [[ ! -z "$p2p_endpoint" ]]; then 45 | ARGS+=" --p2p-endpoint=${p2p_endpoint}" 46 | fi 47 | 48 | if [[ ! -z "$genesis_json" ]]; then 49 | ARGS+=" --genesis-json=${genesis_json}" 50 | fi 51 | 52 | if [[ "$replay" == "true" ]] || [[ -z "$replay" ]]; then 53 | ARGS+=" --replay-blockchain" 54 | elif [[ "$replay" == "false" ]]; then 55 | ARGS+=" --resync-blockchain" 56 | fi 57 | fi 58 | 59 | echo $APPPATH 60 | echo $ARGS 61 | $APPPATH $ARGS 62 | -------------------------------------------------------------------------------- /externals/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( binaryen ) 2 | install(DIRECTORY magic_get/include/boost DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 3 | -------------------------------------------------------------------------------- /libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( fc ) 2 | add_subdirectory( builtins ) 3 | add_subdirectory( db ) 4 | add_subdirectory( wasm-jit ) 5 | add_subdirectory( softfloat ) 6 | add_subdirectory( chain ) 7 | add_subdirectory( egenesis ) 8 | add_subdirectory( net ) 9 | add_subdirectory( utilities ) 10 | add_subdirectory( app ) 11 | add_subdirectory( plugins ) 12 | add_subdirectory( wallet ) 13 | add_subdirectory( abi_generator ) 14 | add_subdirectory( wabt ) 15 | -------------------------------------------------------------------------------- /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 | network_broadcast_api.cpp 6 | api.cpp 7 | application.cpp 8 | database_api_impl.cpp 9 | database_api.cpp 10 | plugin.cpp 11 | ${HEADERS} 12 | ${EGENESIS_HEADERS} 13 | ) 14 | 15 | # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 16 | target_link_libraries( graphene_app graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness ${QUERY_TXID} ${ACCOUNT_HISTORY_LEVELDB}) 17 | target_include_directories( graphene_app 18 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) 20 | 21 | if(MSVC) 22 | set_source_files_properties( application.cpp network_broadcast_api.cpp 23 | api.cpp database_api.cpp database_api_impl.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/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 25 | #include "db_balance.cpp" 26 | #include "db_block.cpp" 27 | #include "db_debug.cpp" 28 | #include "db_getter.cpp" 29 | #include "db_init.cpp" 30 | #include "db_maint.cpp" 31 | #include "db_management.cpp" 32 | #include "db_update.cpp" 33 | #include "db_witness_schedule.cpp" 34 | #include "db_notify.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 // required for gcc in release mode 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | 33 | chain_id_type genesis_state_type::compute_chain_id() const 34 | { 35 | return initial_chain_id; 36 | } 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /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/assert_evaluator.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 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class assert_evaluator : public evaluator 32 | { 33 | public: 34 | typedef assert_operation operation_type; 35 | 36 | void_result do_evaluate( const assert_operation& o ); 37 | void_result do_apply(const assert_operation &o, uint32_t billed_cpu_time_us = 0); 38 | }; 39 | 40 | } } // graphene::chain 41 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/buyback.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 database; 31 | 32 | void evaluate_buyback_account_options( const database& db, const buyback_account_options& auth ); 33 | 34 | } } // graphene::chain 35 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/custom_evaluator.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 | #include 28 | 29 | namespace graphene { namespace chain { 30 | 31 | class custom_evaluator : public evaluator 32 | { 33 | public: 34 | typedef custom_operation operation_type; 35 | 36 | void_result do_evaluate( const custom_operation& o ){ return void_result(); } 37 | void_result do_apply(const custom_operation& o, uint32_t billed_cpu_time_us = 0){ return void_result(); } 38 | }; 39 | } } 40 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/datasource_copyright_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2017 gxb 3 | 4 | This file is part of gxb-core. 5 | 6 | gxb-core is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | gxb-core is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with gxb-core. If not, see . 18 | */ 19 | #pragma once 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace graphene { namespace chain { 26 | 27 | class datasource_copyright_clear_evaluator : public evaluator 28 | { 29 | public: 30 | typedef datasource_copyright_clear_operation operation_type; 31 | 32 | void_result do_evaluate(const datasource_copyright_clear_operation& o); 33 | void_result do_apply(const datasource_copyright_clear_operation& o, uint32_t billed_cpu_time_us = 0); 34 | }; 35 | 36 | } } // graphene::chain 37 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/fba_accumulator_id.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 | /** 31 | * An object will be created at genesis for each of these FBA accumulators. 32 | */ 33 | enum graphene_fba_accumulator_id_enum 34 | { 35 | fba_accumulator_id_transfer_to_blind = 0, 36 | fba_accumulator_id_blind_transfer, 37 | fba_accumulator_id_transfer_from_blind, 38 | fba_accumulator_id_count 39 | }; 40 | 41 | } } 42 | -------------------------------------------------------------------------------- /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/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 | #include 28 | #include 29 | #include 30 | 31 | namespace graphene { namespace chain { 32 | 33 | void operation_get_impacted_accounts( 34 | const graphene::chain::operation& op, 35 | fc::flat_set& result ); 36 | 37 | void transaction_get_impacted_accounts( 38 | const graphene::chain::transaction& tx, 39 | fc::flat_set& result 40 | ); 41 | 42 | } } // graphene::chain 43 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/league_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2017 gxb 3 | 4 | This file is part of gxb-core. 5 | 6 | gxb-core is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | gxb-core is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with gxb-core. If not, see . 18 | */ 19 | #pragma once 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace graphene { namespace chain { 27 | 28 | class league_create_evaluator : public evaluator 29 | { 30 | public: 31 | typedef league_create_operation operation_type; 32 | 33 | void_result do_evaluate( const league_create_operation& o ); 34 | object_id_type do_apply(const league_create_operation& o, int32_t billed_cpu_time_us = 0); 35 | }; 36 | 37 | class league_update_evaluator : public evaluator 38 | { 39 | public: 40 | typedef league_update_operation operation_type; 41 | 42 | void_result do_evaluate( const league_update_operation& o ); 43 | void_result do_apply(const league_update_operation& o, int32_t billed_cpu_time_us = 0); 44 | }; 45 | 46 | } } // graphene::chain 47 | -------------------------------------------------------------------------------- /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/operation_entry_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | class op_entry_object : public abstract_object 9 | { 10 | public: 11 | static const uint8_t space_id = implementation_ids; 12 | static const uint8_t type_id = impl_op_entry_history_object_type; 13 | 14 | op_entry_object(){} 15 | 16 | uint32_t block_num; 17 | uint32_t trx_in_block; 18 | uint32_t op_in_trx; 19 | std::string op_index; 20 | uint32_t sequence; //operation in account history number 21 | bool is_virtual = false; // wheather virtual operation 22 | operation virtual_op;//if vitual op, record 23 | }; 24 | 25 | struct by_id; 26 | struct by_opindex; 27 | struct by_blocknum; 28 | 29 | typedef multi_index_container< 30 | op_entry_object, 31 | indexed_by< 32 | ordered_unique< tag, member< object, object_id_type, &object::id > >, 33 | ordered_unique< tag, member< op_entry_object, std::string, &op_entry_object::op_index > >, 34 | ordered_non_unique< tag, member< op_entry_object, uint32_t, &op_entry_object::block_num > > 35 | > 36 | 37 | > op_entry_multi_index_type; 38 | 39 | typedef generic_index op_entry_index; 40 | 41 | } } // graphene::chain 42 | 43 | FC_REFLECT_DERIVED( graphene::chain::op_entry_object, (graphene::chain::object), 44 | (block_num)(trx_in_block)(op_in_trx)(op_index)(sequence)(is_virtual)(virtual_op)) 45 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/personal_auth_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2017 gxb 3 | 4 | This file is part of gxb-core. 5 | 6 | gxb-core is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | gxb-core is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with gxb-core. If not, see . 18 | */ 19 | #pragma once 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace graphene { namespace chain { 27 | 28 | class personal_auth_create_evaluator : public evaluator 29 | { 30 | public: 31 | typedef personal_auth_create_operation operation_type; 32 | 33 | void_result do_evaluate( const personal_auth_create_operation& o ); 34 | object_id_type do_apply(const personal_auth_create_operation& o, int32_t billed_cpu_time_us = 0); 35 | }; 36 | 37 | } } // graphene::chain 38 | 39 | -------------------------------------------------------------------------------- /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/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/data_storage_params.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 gxb 3 | 4 | This file is part of gxb-core. 5 | 6 | gxb-core is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | gxb-core is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with gxb-core. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | namespace graphene { 24 | namespace chain { 25 | struct data_storage_params 26 | { 27 | asset fee; 28 | fc::string data_md5; 29 | fc::time_point_sec expiration; 30 | }; 31 | }} 32 | 33 | FC_REFLECT(graphene::chain::data_storage_params, 34 | (fee)(data_md5)(expiration)) 35 | -------------------------------------------------------------------------------- /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/proxy_transfer_evaluator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 gxb 3 | 4 | This file is part of gxb-core. 5 | 6 | gxb-core is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | gxb-core is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with gxb-core. If not, see . 18 | */ 19 | #pragma once 20 | #include 21 | #include 22 | #include 23 | 24 | namespace graphene { namespace chain { 25 | 26 | class proxy_transfer_evaluator : public evaluator 27 | { 28 | public: 29 | typedef proxy_transfer_operation operation_type; 30 | 31 | void_result do_evaluate(const proxy_transfer_operation &o); 32 | void_result do_apply(const proxy_transfer_operation &o, int32_t billed_cpu_time_us = 0); 33 | 34 | private: 35 | share_type cut_fee(share_type a, uint16_t p); 36 | }; 37 | } } 38 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/special_authority.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 database; 31 | 32 | void evaluate_special_authority( const database& db, const special_authority& auth ); 33 | 34 | } } // graphene::chain 35 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transaction_entry_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace chain { 7 | 8 | class trx_entry_object : public abstract_object 9 | { 10 | public: 11 | static const uint8_t space_id = implementation_ids; 12 | static const uint8_t type_id = impl_trx_entry_history_object_type; 13 | 14 | trx_entry_object(){} 15 | 16 | transaction_id_type txid; 17 | uint32_t block_num; 18 | uint32_t trx_in_block; 19 | }; 20 | 21 | struct by_id; 22 | struct by_txid; 23 | struct by_blocknum; 24 | 25 | typedef multi_index_container< 26 | trx_entry_object, 27 | indexed_by< 28 | ordered_unique< tag, member< object, object_id_type, &object::id > >, 29 | ordered_unique< tag, member< trx_entry_object, transaction_id_type, &trx_entry_object::txid > >, 30 | ordered_non_unique< tag, member< trx_entry_object, uint32_t, &trx_entry_object::block_num > > 31 | > 32 | 33 | > trx_entry_multi_index_type; 34 | 35 | typedef generic_index trx_entry_index; 36 | 37 | } } // graphene::chain 38 | 39 | FC_REFLECT_DERIVED( graphene::chain::trx_entry_object, (graphene::chain::object), 40 | (txid)(block_num)(trx_in_block)) 41 | 42 | -------------------------------------------------------------------------------- /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/include/graphene/chain/worker_evaluator.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 chain { 28 | 29 | class worker_create_evaluator : public evaluator 30 | { 31 | public: 32 | typedef worker_create_operation operation_type; 33 | 34 | void_result do_evaluate( const operation_type& o ); 35 | object_id_type do_apply(const operation_type& o, int32_t billed_cpu_time_us = 0); 36 | }; 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /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_accounts( 30 | flat_set& result, 31 | const authority& a 32 | ) 33 | { 34 | for( auto& item : a.account_auths ) 35 | result.insert( item.first ); 36 | } 37 | 38 | } } // graphene::chain 39 | -------------------------------------------------------------------------------- /libraries/chain/protocol/custom.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 | 26 | namespace graphene { namespace chain { 27 | 28 | void custom_operation::validate()const 29 | { 30 | FC_ASSERT( fee.amount > 0 ); 31 | } 32 | share_type custom_operation::calculate_fee(const fee_parameters_type& k)const 33 | { 34 | return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); 35 | } 36 | 37 | } } 38 | -------------------------------------------------------------------------------- /libraries/chain/protocol/market.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 | 26 | namespace graphene { namespace chain { 27 | 28 | void limit_order_create_operation::validate()const 29 | { 30 | FC_ASSERT( fee.amount >= 0 ); 31 | } 32 | 33 | void limit_order_cancel_operation::validate()const 34 | { 35 | FC_ASSERT( fee.amount >= 0 ); 36 | } 37 | 38 | void call_order_update_operation::validate()const 39 | { try { 40 | FC_ASSERT( fee.amount >= 0 ); 41 | } FC_CAPTURE_AND_RETHROW((*this)) } 42 | 43 | } } // graphene::chain 44 | -------------------------------------------------------------------------------- /libraries/chain/protocol/worker.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 | 26 | namespace graphene { namespace chain { 27 | 28 | void worker_create_operation::validate() const 29 | { 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/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/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 | peer_database.cpp 7 | peer_connection.cpp 8 | message_oriented_connection.cpp) 9 | 10 | add_library( graphene_net ${SOURCES} ${HEADERS} ) 11 | 12 | target_link_libraries( graphene_net 13 | PUBLIC fc graphene_db ) 14 | target_include_directories( graphene_net 15 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 16 | PRIVATE "${CMAKE_SOURCE_DIR}/libraries/chain/include" 17 | ) 18 | 19 | if(MSVC) 20 | set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 21 | endif(MSVC) 22 | 23 | if (USE_PCH) 24 | set_target_properties(graphene_net PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 25 | cotire(graphene_net) 26 | endif(USE_PCH) 27 | 28 | install( TARGETS 29 | graphene_net 30 | 31 | RUNTIME DESTINATION bin 32 | LIBRARY DESTINATION lib 33 | ARCHIVE DESTINATION lib 34 | ) 35 | install( FILES ${HEADERS} DESTINATION "include/graphene/net" ) 36 | -------------------------------------------------------------------------------- /libraries/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( witness ) 2 | add_subdirectory( account_history ) 3 | add_subdirectory( delayed_node ) 4 | add_subdirectory( debug_witness ) 5 | add_subdirectory( data_transaction ) 6 | add_subdirectory( snapshot ) 7 | if(LOAD_TXID_PLUGIN) 8 | add_subdirectory( query_txid ) 9 | endif() 10 | if(LOAD_ACCOUNT_HISTORY_LEVELDB_PLUGIN) 11 | add_subdirectory( account_history_leveldb ) 12 | endif() 13 | if(LOAD_ELASTICSEARCH_PLUGIN) 14 | add_subdirectory( elasticsearch ) 15 | endif() 16 | -------------------------------------------------------------------------------- /libraries/plugins/README.md: -------------------------------------------------------------------------------- 1 | # GXChain Plugins 2 | 3 | The plugins are a collection of tools that brings new functionality without the need of modifications in the consensus. 4 | 5 | The main source of I/O of the GXChain blockchain is the API. Plugins are a more powerful alternative to build more complex developments for when the current API is not enough. 6 | 7 | Plugins are optional to run by node operator according to their needs. However, all plugins here will be compiled. 8 | 9 | # Available Plugins 10 | 11 | Folder | Name | Description | Category | Status | SpaceID 12 | -----------------------------------|--------------------------|-----------------------------------------------------------------------------|----------------|---------------|--------------| 13 | [account_history](account_history) | Account History | Save account history data | History | Stable | 4 14 | [debug_witness](debug_witness) | Debug Witness | Run "what-if" tests | Debug | Stable | 15 | [snapshot](snapshot) | Snapshot | Get a json of all objects in blockchain at a specificed time or block | Debug | Stable | 16 | [witness](witness) | Witness | Generate and sign blocks | Block producer | Stable | 17 | -------------------------------------------------------------------------------- /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/account_history_leveldb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/account_history_leveldb/*.hpp") 2 | 3 | add_library( graphene_account_history_leveldb 4 | account_history_leveldb_plugin.cpp 5 | ) 6 | find_path(LevelDB_INCLUDE_PATH NAMES leveldb/db.h leveldb/write_batch.h) 7 | find_library(LevelDB_LIBRARY NAMES libleveldb.a) 8 | find_library(Snappy_LIBRARY NAMES libsnappy.a) 9 | 10 | if(LevelDB_INCLUDE_PATH AND LevelDB_LIBRARY AND Snappy_LIBRARY) 11 | target_link_libraries( graphene_account_history_leveldb graphene_chain graphene_app ${LevelDB_LIBRARY} ${Snappy_LIBRARY}) 12 | target_include_directories( graphene_account_history_leveldb 13 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ${LevelDB_INCLUDE_PATH}) 14 | install( TARGETS 15 | graphene_account_history_leveldb 16 | 17 | RUNTIME DESTINATION bin 18 | LIBRARY DESTINATION lib 19 | ARCHIVE DESTINATION lib 20 | ) 21 | else(LevelDB_INCLUDE_PATH AND LevelDB_LIBRARY AND Snappy_LIBRARY) 22 | message(FATAL_ERROR "You need leveldb and snappy") 23 | endif() 24 | 25 | -------------------------------------------------------------------------------- /libraries/plugins/account_history_leveldb/include/graphene/account_history_leveldb/account_history_leveldb_plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace graphene 6 | { 7 | namespace account_history_leveldb 8 | { 9 | 10 | using namespace chain; 11 | namespace detail 12 | { 13 | class account_history_leveldb_plugin_impl; 14 | } 15 | class account_history_leveldb_plugin : public graphene::app::plugin 16 | { 17 | public: 18 | account_history_leveldb_plugin(); 19 | virtual ~account_history_leveldb_plugin(); 20 | 21 | std::string plugin_name() const override; 22 | 23 | virtual void plugin_set_program_options( 24 | boost::program_options::options_description &cli, 25 | boost::program_options::options_description &cfg) override; 26 | 27 | virtual void plugin_initialize(const boost::program_options::variables_map &options) override; 28 | virtual void plugin_startup() override; 29 | 30 | static optional query_op_by_index(std::string op_index); 31 | 32 | friend class detail::account_history_leveldb_plugin_impl; 33 | 34 | std::unique_ptr my; 35 | }; 36 | } // namespace account_history_leveldb 37 | } // namespace graphene 38 | -------------------------------------------------------------------------------- /libraries/plugins/data_transaction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/data_transaction/*.hpp") 2 | 3 | add_library( graphene_data_transaction 4 | data_transaction_plugin.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_data_transaction graphene_chain graphene_app ) 8 | target_include_directories( graphene_data_transaction 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | install( TARGETS 12 | graphene_data_transaction 13 | 14 | RUNTIME DESTINATION bin 15 | LIBRARY DESTINATION lib 16 | ARCHIVE DESTINATION lib 17 | ) 18 | -------------------------------------------------------------------------------- /libraries/plugins/data_transaction/include/graphene/data_transaction/data_transaction_plugin.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2017 gxb 3 | 4 | This file is part of gxb-core. 5 | 6 | gxb-core is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | gxb-core is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with gxb-core. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | namespace graphene { namespace data_transaction { 26 | using namespace chain; 27 | 28 | class data_transaction_plugin : public graphene::app::plugin 29 | { 30 | public: 31 | ~data_transaction_plugin() {} 32 | 33 | std::string plugin_name() const override; 34 | 35 | virtual void plugin_set_program_options( 36 | boost::program_options::options_description &command_line_options, 37 | boost::program_options::options_description &config_file_options) override; 38 | 39 | virtual void plugin_initialize(const boost::program_options::variables_map &options) override; 40 | virtual void plugin_startup() override; 41 | virtual void plugin_shutdown() override; 42 | 43 | private: 44 | void check_data_transaction(const graphene::chain::signed_block &b); 45 | 46 | uint32_t data_transaction_lifetime = 0; 47 | }; 48 | } } //graphene::data_transaction_plugin 49 | -------------------------------------------------------------------------------- /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/elasticsearch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/elasticsearch/*.hpp") 2 | 3 | add_library( graphene_elasticsearch 4 | elasticsearch_plugin.cpp 5 | ) 6 | find_package(CURL REQUIRED) 7 | include_directories(${CURL_INCLUDE_DIRS}) 8 | if(MSVC) 9 | set_source_files_properties(elasticsearch_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) 10 | endif(MSVC) 11 | if(CURL_STATICLIB) 12 | SET_TARGET_PROPERTIES(graphene_elasticsearch PROPERTIES 13 | COMPILE_DEFINITIONS "CURL_STATICLIB") 14 | endif(CURL_STATICLIB) 15 | target_link_libraries( graphene_elasticsearch graphene_chain graphene_app ${CURL_LIBRARIES} ) 16 | target_include_directories( graphene_elasticsearch 17 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 18 | PUBLIC "${CURL_INCLUDE_DIR}" ) 19 | 20 | 21 | install( TARGETS 22 | graphene_elasticsearch 23 | 24 | RUNTIME DESTINATION bin 25 | LIBRARY DESTINATION lib 26 | ARCHIVE DESTINATION lib 27 | ) 28 | INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/elasticsearch" ) 29 | 30 | -------------------------------------------------------------------------------- /libraries/plugins/query_txid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/query_txid/*.hpp") 2 | 3 | add_library( graphene_query_txid 4 | query_txid_plugin.cpp 5 | ) 6 | find_path(LevelDB_INCLUDE_PATH NAMES leveldb/db.h leveldb/write_batch.h) 7 | find_library(LevelDB_LIBRARY NAMES libleveldb.a) 8 | find_library(Snappy_LIBRARY NAMES libsnappy.a) 9 | 10 | if(LevelDB_INCLUDE_PATH AND LevelDB_LIBRARY AND Snappy_LIBRARY) 11 | target_link_libraries( graphene_query_txid graphene_chain graphene_app ${LevelDB_LIBRARY} ${Snappy_LIBRARY}) 12 | target_include_directories( graphene_query_txid 13 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ${LevelDB_INCLUDE_PATH}) 14 | install( TARGETS 15 | graphene_query_txid 16 | 17 | RUNTIME DESTINATION bin 18 | LIBRARY DESTINATION lib 19 | ARCHIVE DESTINATION lib 20 | ) 21 | else(LevelDB_INCLUDE_PATH AND LevelDB_LIBRARY AND Snappy_LIBRARY) 22 | message(FATAL_ERROR "You need leveldb and snappy") 23 | endif() 24 | 25 | -------------------------------------------------------------------------------- /libraries/plugins/query_txid/include/graphene/query_txid/query_txid_plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace graphene 6 | { 7 | namespace query_txid 8 | { 9 | 10 | using namespace chain; 11 | namespace detail 12 | { 13 | class query_txid_plugin_impl; 14 | } 15 | class query_txid_plugin : public graphene::app::plugin 16 | { 17 | public: 18 | query_txid_plugin(); 19 | virtual ~query_txid_plugin(); 20 | 21 | std::string plugin_name() const override; 22 | 23 | virtual void plugin_set_program_options( 24 | boost::program_options::options_description &cli, 25 | boost::program_options::options_description &cfg) override; 26 | 27 | virtual void plugin_initialize(const boost::program_options::variables_map &options) override; 28 | virtual void plugin_startup() override; 29 | 30 | static optional query_trx_by_id(std::string txid); 31 | 32 | friend class detail::query_txid_plugin_impl; 33 | 34 | std::unique_ptr my; 35 | }; 36 | } // namespace query_txid 37 | } // namespace graphene 38 | -------------------------------------------------------------------------------- /libraries/plugins/snapshot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/snapshot/*.hpp") 2 | 3 | add_library( graphene_snapshot 4 | snapshot.cpp 5 | ) 6 | 7 | target_link_libraries( graphene_snapshot graphene_chain graphene_app ) 8 | target_include_directories( graphene_snapshot 9 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 10 | 11 | install( TARGETS 12 | graphene_snapshot 13 | 14 | RUNTIME DESTINATION bin 15 | LIBRARY DESTINATION lib 16 | ARCHIVE DESTINATION lib 17 | ) 18 | -------------------------------------------------------------------------------- /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 | if(LOAD_ELASTICSEARCH_PLUGIN) 12 | set( ELASTIC_SEARCH_CPP elasticsearch.cpp) 13 | endif() 14 | set(sources 15 | key_conversion.cpp 16 | string_escape.cpp 17 | tempdir.cpp 18 | words.cpp 19 | ${ELASTIC_SEARCH_CPP} 20 | ${HEADERS}) 21 | 22 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) 23 | list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") 24 | find_package(CURL REQUIRED) 25 | include_directories(${CURL_INCLUDE_DIRS}) 26 | add_library( graphene_utilities 27 | ${sources} 28 | ${HEADERS} ) 29 | if(CURL_STATICLIB) 30 | SET_TARGET_PROPERTIES(graphene_utilities PROPERTIES 31 | COMPILE_DEFINITIONS "CURL_STATICLIB") 32 | endif(CURL_STATICLIB) 33 | target_link_libraries( graphene_utilities fc ) 34 | target_include_directories( graphene_utilities 35 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 36 | if (USE_PCH) 37 | set_target_properties(graphene_utilities PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 38 | cotire(graphene_utilities) 39 | endif(USE_PCH) 40 | 41 | install( TARGETS 42 | graphene_utilities 43 | 44 | RUNTIME DESTINATION bin 45 | LIBRARY DESTINATION lib 46 | ARCHIVE DESTINATION lib 47 | ) 48 | install( FILES ${HEADERS} DESTINATION "include/graphene/utilities" ) 49 | -------------------------------------------------------------------------------- /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 | } } // end namespace graphene::utilities 33 | -------------------------------------------------------------------------------- /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/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: gxc-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(gxc-wast2wasm Assemble.cpp CLI.h) 2 | target_link_libraries(gxc-wast2wasm Logging IR WAST WASM) 3 | set_target_properties(gxc-wast2wasm PROPERTIES FOLDER Programs) 4 | INSTALL(TARGETS gxc-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/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 | -------------------------------------------------------------------------------- /programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( build_helpers ) 2 | add_subdirectory( cli_wallet ) 3 | add_subdirectory( genesis_util ) 4 | add_subdirectory( witness_node ) 5 | #add_subdirectory( delayed_node ) 6 | add_subdirectory( js_operation_serializer ) 7 | add_subdirectory( size_checker ) 8 | add_subdirectory( gxc_abigen ) 9 | -------------------------------------------------------------------------------- /programs/build_helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( member_enumerator member_enumerator.cpp ) 2 | if( UNIX AND NOT APPLE ) 3 | set(rt_library rt ) 4 | endif() 5 | 6 | # we only actually need Boost, but link against FC for now so we don't duplicate it. 7 | 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} ) 8 | 9 | -------------------------------------------------------------------------------- /programs/cli_wallet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( cli_wallet 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 cli_wallet with TCMalloc") 9 | list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) 10 | endif() 11 | 12 | target_link_libraries( cli_wallet 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 | cli_wallet 21 | 22 | RUNTIME DESTINATION bin 23 | LIBRARY DESTINATION lib 24 | ARCHIVE DESTINATION lib 25 | ) 26 | -------------------------------------------------------------------------------- /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_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_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/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_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 | #include 31 | 32 | #include 33 | #include 34 | 35 | using namespace graphene::chain; 36 | 37 | int main(int argc, char** argv) 38 | { 39 | // grab 0 or more whitespace-delimited PTS addresses from stdin 40 | std::string s; 41 | while( std::cin >> s ) 42 | { 43 | std::cout << std::string( address( pts_address( s ) ) ) << std::endl; 44 | } 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /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/gxc_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(gxc-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(gxc-abigen abi_generator) 22 | 23 | 24 | install( TARGETS 25 | gxc-abigen 26 | 27 | RUNTIME DESTINATION bin 28 | LIBRARY DESTINATION lib 29 | ARCHIVE DESTINATION lib 30 | ) 31 | -------------------------------------------------------------------------------- /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/witness_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( witness_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 witness_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( witness_node 14 | PRIVATE graphene_app graphene_delayed_node 15 | graphene_account_history ${ELASTIC_SEARCH} 16 | graphene_witness graphene_chain graphene_debug_witness ${QUERY_TXID} ${ACCOUNT_HISTORY_LEVELDB} 17 | graphene_data_transaction graphene_snapshot graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 18 | 19 | install( TARGETS 20 | witness_node 21 | 22 | RUNTIME DESTINATION bin 23 | LIBRARY DESTINATION lib 24 | ARCHIVE DESTINATION lib 25 | ) 26 | -------------------------------------------------------------------------------- /programs/witness_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 | -------------------------------------------------------------------------------- /script/boost_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # install boost 1.57.0 on MacOS / linux 3 | 4 | sys_os=`uname -s` 5 | if [ $sys_os == "Darwin" ]; then 6 | echo "----- MacOS -----" 7 | elif [ $sys_os == "Linux" ]; then 8 | echo "----- Linux -----" 9 | else 10 | echo "only support MaxOS / Linux" 11 | exit 1 12 | fi 13 | 14 | # download boost 1.57.0 15 | wget 'http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.gz' -O boost_1_57_0.tar.gz 16 | tar zxvf boost_1_57_0.tar.gz 17 | 18 | cd boost_1_57_0 19 | bash ./bootstrap.sh --prefix=/usr 20 | 21 | if [ $sys_os == "Darwin" ]; then 22 | ./b2 --buildtype=complewte install toolset=clang cxxflags="-arch x86_64" linkflags="-arch x86_64" 23 | else 24 | if [ $(id -u) != 0 ]; then 25 | SUDO="sudo" 26 | fi 27 | $SUDO ./b2 --buildtype=complete install 28 | fi 29 | 30 | 31 | -------------------------------------------------------------------------------- /script/gcc5_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #sudo apt-get install software-properties-common 4 | 5 | # install gcc5 on ubuntu 14.04 6 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test 7 | sudo apt-get update 8 | sudo apt-get install gcc-5 g++-5 9 | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 10 | -------------------------------------------------------------------------------- /script/gxchain_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | 4 | ARCH=$(uname) 5 | if [ "$ARCH" == "Linux" ]; then 6 | OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) 7 | if [ "$OS_NAME" != "Ubuntu" ]; then 8 | printf "\\n\\tGXChain core currently supports macOS & Ubuntu Linux only.\\n" 9 | exit 1 10 | fi 11 | OS_VERSION=$(lsb_release -a | grep "Release" | sed -e 's/Release:[\t]*//g') 12 | echo "Your OS Version: Ubuntu ${OS_VERSION}" 13 | if [ "$OS_VERSION" == "14.04" ]; then 14 | curl -L 'https://github.com/gxchain/gxb-core/releases/download/v1.0.200327/gxb_1.0.200327-ubuntu-14.04.tar.gz' -o gxb_1.0.200327-ubuntu-14.04.tar.gz 15 | tar zxvf gxb_1.0.200327-ubuntu-14.04.tar.gz 16 | else 17 | curl -L 'https://github.com/gxchain/gxb-core/releases/download/v1.0.200327/gxb_1.0.200327-ubuntu-14.04.tar.gz' -o gxb_1.0.200327-ubuntu-14.04.tar.gz 18 | tar zxvf gxb_1.0.200327-ubuntu-14.04.tar.gz 19 | fi 20 | elif [ "$ARCH" == "Darwin" ]; then 21 | curl -L 'https://github.com/gxchain/gxb-core/releases/download/v1.0.190318/gxb_1.0.190318-osx.tar.gz' -o gxb_1.0.190318-osx.tar.gz 22 | tar zxvf gxb_1.0.190318-osx.tar.gz 23 | else 24 | printf "\\n\\tGXChain core currently supports macOS & Ubuntu Linux only.\\n" 25 | exit 1 26 | fi 27 | -------------------------------------------------------------------------------- /script/gxchain_private_net_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ARCH=$(uname) 3 | if [ "$ARCH" == "Linux" ]; then 4 | OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) 5 | if [ "$OS_NAME" != "Ubuntu" ]; then 6 | printf "\\n\\tGXChain core currently supports macOS & Ubuntu Linux only.\\n" 7 | exit 1 8 | fi 9 | curl -L 'http://gxb-package.oss-cn-hangzhou.aliyuncs.com/gxb-core/private-net/gxb_gxb_ubuntu_1.0.180929.private-net.tar.gz' -o gxb_ubuntu_private-net.tar.gz 10 | tar zxvf gxb_ubuntu_private-net.tar.gz 11 | elif [ "$ARCH" == "Darwin" ]; then 12 | curl -L 'http://gxb-package.oss-cn-hangzhou.aliyuncs.com/gxb-core/private-net/gxb_osx_1.0.180929.private-net.tar.gz' -o gxb_osx_private-net.tar.gz 13 | tar zxvf gxb_osx_private-net.tar.gz 14 | else 15 | printf "\\n\\tGXChain core currently supports macOS & Ubuntu Linux only.\\n" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /script/gxchain_testnet_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | 4 | ARCH=$(uname) 5 | if [ "$ARCH" == "Linux" ]; then 6 | OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) 7 | if [ "$OS_NAME" != "Ubuntu" ]; then 8 | printf "\\n\\tGXChain core currently supports macOS & Ubuntu Linux only.\\n" 9 | exit 1 10 | fi 11 | OS_VERSION=$(lsb_release -a | grep "Release" | sed -e 's/Release:[\t]*//g') 12 | echo "Your OS Version: Ubuntu ${OS_VERSION}" 13 | if [ "$OS_VERSION" = "14.04" ]; then 14 | curl -L 'https://github.com/gxchain/gxb-core/releases/download/testnet-1.0.190315/gxb_1.0.190315-ubuntu-14.04.testnet.tar.gz' -o gxb_1.0.190315-ubuntu-14.04.testnet.tar.gz 15 | tar zxvf gxb_1.0.190315-ubuntu-14.04.testnet.tar.gz 16 | else 17 | curl -L 'https://github.com/gxchain/gxb-core/releases/download/testnet-1.0.190315/gxb_1.0.190315-ubuntu-14.04.testnet.tar.gz' -o gxb_1.0.190315-ubuntu-16.04.testnet.tar.gz 18 | tar zxvf gxb_1.0.190315-ubuntu-16.04.testnet.tar.gz 19 | fi 20 | elif [ "$ARCH" == "Darwin" ]; then 21 | curl -L 'https://github.com/gxchain/gxb-core/releases/download/testnet-1.0.190315/gxb_1.0.190315-osx.testnet.tar.gz' -o gxb_1.0.190315-osx.testnet.tar.gz 22 | tar zxvf gxb_1.0.190315-osx.testnet.tar.gz 23 | else 24 | printf "\\n\\tGXChain core currently supports macOS & Ubuntu Linux only.\\n" 25 | exit 1 26 | fi -------------------------------------------------------------------------------- /script/monitor/gxs_fee_pool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | import json 5 | import urllib2 6 | import urllib 7 | 8 | WITNESS_URL = "http://127.0.0.1:28090" 9 | POST_DATA = '{"jsonrpc": "2.0", "method": "call", "params": [0, "get_objects", [["2.3.1"]]], "id": 1}' 10 | 11 | GXS_THRESHOLD = 5000000000 12 | WECHAT_NOTIFY_URL = "http://172.19.19.49:8091/notify/wechat/send?message=%s&agent=GXCHAIN" 13 | NO_RESULT_MSG = "GXS手续费资金池监控,无法获取手续费资金池余额, 错误信息:" 14 | WARNING_MSG = "GXS手续费资金池余额不足5万, 当前余额:" 15 | 16 | def download(url, data = None): 17 | opener = urllib2.build_opener() 18 | request = urllib2.Request(url, data) 19 | response = opener.open(request, timeout=60) 20 | return response.read() 21 | 22 | def main(): 23 | # get error_msg 24 | error_msg = "" 25 | try: 26 | res = download(WITNESS_URL, POST_DATA) 27 | js = json.loads(res) 28 | fee_pool_balance = js['result'][0]['fee_pool'] 29 | if GXS_THRESHOLD > int(fee_pool_balance): 30 | error_msg = "%s %f GXC, 请尽快操作" % (WARNING_MSG, float(fee_pool_balance)/100000) 31 | except Exception as e: 32 | error_msg = NO_RESULT_MSG + str(e) 33 | 34 | # send error_msg 35 | if len(error_msg) > 0: 36 | notify_url = WECHAT_NOTIFY_URL % (urllib.quote(error_msg)) 37 | #print notify_url 38 | download(notify_url) 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /script/monitor/opengateway_balance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | import json 5 | import urllib2 6 | import urllib 7 | 8 | WITNESS_URL = "http://127.0.0.1:28090" 9 | POST_DATA = '{"jsonrpc": "2.0", "method": "call", "params": [0, "get_account_balances", ["1.2.26", ["1.3.0"]]], "id": 1}' 10 | 11 | WECHAT_NOTIFY_URL = "http://172.19.19.49:8091/notify/wechat/send?message=%s&agent=GXCHAIN" 12 | NO_RESULT_MSG = "opengateway帐户无法获取余额, 错误信息:" 13 | WARNING_MSG = "opengateway帐余额不足1万, 当前余额:" 14 | 15 | def download(url, data = None): 16 | opener = urllib2.build_opener() 17 | request = urllib2.Request(url, data) 18 | response = opener.open(request, timeout=60) 19 | return response.read() 20 | 21 | def main(): 22 | # get error_msg 23 | error_msg = "" 24 | try: 25 | res = download(WITNESS_URL, POST_DATA) 26 | js = json.loads(res) 27 | balance = js['result'][0]['amount'] 28 | if 1000000000 > int(balance): 29 | error_msg = "%s %f GXC, 请尽快操作" % (WARNING_MSG, float(balance)/100000) 30 | except Exception as e: 31 | error_msg = NO_RESULT_MSG + str(e) 32 | 33 | # send error_msg 34 | if len(error_msg) > 0: 35 | notify_url = WECHAT_NOTIFY_URL % (urllib.quote(error_msg)) 36 | # print notify_url 37 | download(notify_url) 38 | 39 | if __name__ == "__main__": 40 | main() 41 | -------------------------------------------------------------------------------- /script/monitor/witness_participation_rate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | import json 5 | import urllib2 6 | import urllib 7 | 8 | WITNESS_URL = "http://127.0.0.1:28090" 9 | POST_DATA = '{"jsonrpc": "2.0", "method": "call", "params": [0, "get_witness_participation_rate", []], "id": 1}' 10 | 11 | WECHAT_NOTIFY_URL = "http://172.19.19.49:8091/notify/wechat/send?message=%s&agent=GXCHAIN" 12 | NO_RESULT_MSG = "见证人监控程序,无法获取参与率, 错误信息:" 13 | WARNING_MSG = "见证人参与率预期为100%,当前参与率:" 14 | 15 | def download(url, data = None): 16 | opener = urllib2.build_opener() 17 | request = urllib2.Request(url, data) 18 | response = opener.open(request, timeout=60) 19 | return response.read() 20 | 21 | def main(): 22 | # get error_msg 23 | error_msg = "" 24 | try: 25 | res = download(WITNESS_URL, POST_DATA) 26 | js = json.loads(res) 27 | participation_rate = js['result'] 28 | if 10000 <> participation_rate: 29 | error_msg = "%s %f %%" % (WARNING_MSG, float(participation_rate)/100) 30 | except Exception as e: 31 | error_msg = NO_RESULT_MSG + str(e) 32 | 33 | # send error_msg 34 | if len(error_msg) > 0: 35 | notify_url = WECHAT_NOTIFY_URL % (urllib.quote(error_msg)) 36 | #print notify_url 37 | download(notify_url) 38 | 39 | if __name__ == "__main__": 40 | main() 41 | -------------------------------------------------------------------------------- /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_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 | endif(MSVC) 15 | 16 | file(GLOB PERFORMANCE_TESTS "performance/*.cpp") 17 | add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} ) 18 | target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 19 | 20 | file(GLOB BENCH_MARKS "benchmarks/*.cpp") 21 | add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} ) 22 | target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 23 | 24 | file(GLOB APP_SOURCES "app/*.cpp") 25 | add_executable( app_test ${APP_SOURCES} ) 26 | target_link_libraries( app_test graphene_app graphene_account_history graphene_net graphene_chain graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) 27 | 28 | add_subdirectory( generate_empty_blocks ) 29 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------