提交 d6a6d6f3 编写于 作者: T Todd Fleming

Merge remote-tracking branch 'origin/develop' into state-history-plugin

......@@ -232,6 +232,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/EosioTester.cmake.in ${C
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/EosioTesterBuild.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/EosioTester.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EosioTester.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/)
install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/)
install(FILES libraries/wabt/LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.wabt)
install(FILES libraries/softfloat/COPYING.txt DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.softfloat)
install(FILES libraries/wasm-jit/LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.wavm)
install(FILES libraries/fc/secp256k1/upstream/COPYING DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.secp256k1)
install(FILES externals/binaryen/LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.binaryen)
include(installer)
include(doxygen)
......@@ -47,7 +47,6 @@ else()
find_library(libfc fc @CMAKE_INSTALL_FULL_LIBDIR@)
endif()
find_library(libbinaryen binaryen @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwasm WASM @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwast WAST @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwabt wabt @CMAKE_INSTALL_FULL_LIBDIR@)
......@@ -75,7 +74,6 @@ macro(add_eosio_test test_name)
${libtester}
${libchain}
${libfc}
${libbinaryen}
${libwast}
${libwasm}
${libwabt}
......
......@@ -47,7 +47,6 @@ else()
find_library(libfc fc @CMAKE_BINARY_DIR@/libraries/fc)
endif()
find_library(libbinaryen binaryen @CMAKE_BINARY_DIR@/externals/binaryen/lib)
find_library(libwasm WASM @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WASM)
find_library(libwast WAST @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WAST)
find_library(libir IR @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/IR)
......@@ -75,7 +74,6 @@ macro(add_eosio_test test_name)
${libtester}
${libchain}
${libfc}
${libbinaryen}
${libwast}
${libwasm}
${libwabt}
......
......@@ -37,7 +37,6 @@ add_library( eosio_chain
asset.cpp
webassembly/wavm.cpp
webassembly/binaryen.cpp
webassembly/wabt.cpp
# get_config.cpp
......@@ -51,12 +50,11 @@ add_library( eosio_chain
)
target_link_libraries( eosio_chain eos_utilities fc chainbase Logging IR WAST WASM Runtime
wasm asmjs passes cfg ast emscripten-optimizer support softfloat builtins wabt
softfloat builtins wabt
)
target_include_directories( eosio_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../wasm-jit/Include"
"${CMAKE_CURRENT_SOURCE_DIR}/../../externals/binaryen/src"
"${CMAKE_SOURCE_DIR}/libraries/wabt"
"${CMAKE_BINARY_DIR}/libraries/wabt"
)
......
......@@ -53,7 +53,6 @@ namespace eosio { namespace chain {
public:
enum class vm_type {
wavm,
binaryen,
wabt
};
......@@ -77,4 +76,4 @@ namespace eosio{ namespace chain {
std::istream& operator>>(std::istream& in, wasm_interface::vm_type& runtime);
}}
FC_REFLECT_ENUM( eosio::chain::wasm_interface::vm_type, (wavm)(binaryen)(wabt) )
FC_REFLECT_ENUM( eosio::chain::wasm_interface::vm_type, (wavm)(wabt) )
......@@ -2,7 +2,6 @@
#include <eosio/chain/wasm_interface.hpp>
#include <eosio/chain/webassembly/wavm.hpp>
#include <eosio/chain/webassembly/binaryen.hpp>
#include <eosio/chain/webassembly/wabt.hpp>
#include <eosio/chain/webassembly/runtime_interface.hpp>
#include <eosio/chain/wasm_eosio_injection.hpp>
......@@ -27,8 +26,6 @@ namespace eosio { namespace chain {
wasm_interface_impl(wasm_interface::vm_type vm) {
if(vm == wasm_interface::vm_type::wavm)
runtime_interface = std::make_unique<webassembly::wavm::wavm_runtime>();
else if(vm == wasm_interface::vm_type::binaryen)
runtime_interface = std::make_unique<webassembly::binaryen::binaryen_runtime>();
else if(vm == wasm_interface::vm_type::wabt)
runtime_interface = std::make_unique<webassembly::wabt_runtime::wabt_runtime>();
else
......@@ -98,7 +95,6 @@ namespace eosio { namespace chain {
#define _REGISTER_INTRINSIC_EXPLICIT(CLS, MOD, METHOD, WASM_SIG, NAME, SIG)\
_REGISTER_WAVM_INTRINSIC(CLS, MOD, METHOD, WASM_SIG, NAME, SIG)\
_REGISTER_BINARYEN_INTRINSIC(CLS, MOD, METHOD, WASM_SIG, NAME, SIG)\
_REGISTER_WABT_INTRINSIC(CLS, MOD, METHOD, WASM_SIG, NAME, SIG)
#define _REGISTER_INTRINSIC4(CLS, MOD, METHOD, WASM_SIG, NAME, SIG)\
......
......@@ -1911,8 +1911,6 @@ std::istream& operator>>(std::istream& in, wasm_interface::vm_type& runtime) {
in >> s;
if (s == "wavm")
runtime = eosio::chain::wasm_interface::vm_type::wavm;
else if (s == "binaryen")
runtime = eosio::chain::wasm_interface::vm_type::binaryen;
else if (s == "wabt")
runtime = eosio::chain::wasm_interface::vm_type::wabt;
else
......
#include <eosio/chain/webassembly/binaryen.hpp>
#include <eosio/chain/apply_context.hpp>
#include <wasm-binary.h>
namespace eosio { namespace chain { namespace webassembly { namespace binaryen {
class binaryen_instantiated_module : public wasm_instantiated_module_interface {
public:
binaryen_instantiated_module(linear_memory_type& shared_linear_memory,
std::vector<uint8_t> initial_memory,
call_indirect_table_type table,
import_lut_type import_lut,
unique_ptr<Module>&& module) :
_shared_linear_memory(shared_linear_memory),
_initial_memory(initial_memory),
_table(forward<decltype(table)>(table)),
_import_lut(forward<decltype(import_lut)>(import_lut)),
_module(forward<decltype(module)>(module)) {
}
void apply(apply_context& context) override {
LiteralList args = {Literal(uint64_t(context.receiver)),
Literal(uint64_t(context.act.account)),
Literal(uint64_t(context.act.name))};
call("apply", args, context);
}
private:
linear_memory_type& _shared_linear_memory;
std::vector<uint8_t> _initial_memory;
call_indirect_table_type _table;
import_lut_type _import_lut;
unique_ptr<Module> _module;
void call(const string& entry_point, LiteralList& args, apply_context& context){
const unsigned initial_memory_size = _module->memory.initial*Memory::kPageSize;
interpreter_interface local_interface(_shared_linear_memory, _table, _import_lut, initial_memory_size, context);
//zero out the initial pages
memset(_shared_linear_memory.data, 0, initial_memory_size);
//copy back in the initial data
memcpy(_shared_linear_memory.data, _initial_memory.data(), _initial_memory.size());
//be aware that construction of the ModuleInstance implictly fires the start function
ModuleInstance instance(*_module.get(), &local_interface);
instance.callExport(Name(entry_point), args);
}
};
binaryen_runtime::binaryen_runtime() {
}
std::unique_ptr<wasm_instantiated_module_interface> binaryen_runtime::instantiate_module(const char* code_bytes, size_t code_size, std::vector<uint8_t> initial_memory) {
try {
vector<char> code(code_bytes, code_bytes + code_size);
unique_ptr<Module> module(new Module());
WasmBinaryBuilder builder(*module, code, false);
builder.read();
EOS_ASSERT(module->memory.initial * Memory::kPageSize <= wasm_constraints::maximum_linear_memory, binaryen_exception, "exceeds maximum linear memory");
// create a temporary globals to use
TrivialGlobalManager globals;
for (auto& global : module->globals) {
globals[global->name] = ConstantExpressionRunner<TrivialGlobalManager>(globals).visit(global->init).value;
}
call_indirect_table_type table;
table.resize(module->table.initial);
for (auto& segment : module->table.segments) {
Address offset = ConstantExpressionRunner<TrivialGlobalManager>(globals).visit(segment.offset).value.geti32();
EOS_ASSERT( uint64_t(offset) + segment.data.size() <= module->table.initial, binaryen_exception, "");
for (size_t i = 0; i != segment.data.size(); ++i) {
table[offset + i] = segment.data[i];
}
}
// initialize the import lut
import_lut_type import_lut;
import_lut.reserve(module->imports.size());
for (auto& import : module->imports) {
std::string full_name = string(import->module.c_str()) + "." + string(import->base.c_str());
if (import->kind == ExternalKind::Function) {
auto& intrinsic_map = intrinsic_registrator::get_map();
auto intrinsic_itr = intrinsic_map.find(full_name);
if (intrinsic_itr != intrinsic_map.end()) {
import_lut.emplace(make_pair((uintptr_t)import.get(), intrinsic_itr->second));
continue;
}
}
EOS_ASSERT( !"unresolvable", wasm_exception, "${module}.${export} unresolveable", ("module",import->module.c_str())("export",import->base.c_str()) );
}
return std::make_unique<binaryen_instantiated_module>(_memory, initial_memory, move(table), move(import_lut), move(module));
} catch (const ParseException &e) {
FC_THROW_EXCEPTION(wasm_execution_error, "Error building interpreter: ${s}", ("s", e.text));
}
}
}}}}
......@@ -332,9 +332,7 @@ namespace eosio { namespace testing {
vcfg.genesis.initial_key = get_public_key( config::system_account_name, "active" );
for(int i = 0; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--binaryen"))
vcfg.wasm_runtime = chain::wasm_interface::vm_type::binaryen;
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
vcfg.wasm_runtime = chain::wasm_interface::vm_type::wavm;
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wabt"))
vcfg.wasm_runtime = chain::wasm_interface::vm_type::wabt;
......
......@@ -96,14 +96,10 @@ namespace eosio { namespace testing {
cfg.genesis.initial_key = get_public_key( config::system_account_name, "active" );
for(int i = 0; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--binaryen"))
cfg.wasm_runtime = chain::wasm_interface::vm_type::binaryen;
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
cfg.wasm_runtime = chain::wasm_interface::vm_type::wavm;
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wabt"))
cfg.wasm_runtime = chain::wasm_interface::vm_type::wabt;
else
cfg.wasm_runtime = chain::wasm_interface::vm_type::binaryen;
}
open();
......
......@@ -50,7 +50,7 @@ struct async_result_visitor : public fc::visitor<std::string> {
#define CALL_ASYNC(api_name, api_handle, api_namespace, call_name, call_result, http_response_code) \
{std::string("/v1/" #api_name "/" #call_name), \
[this, api_handle](string, string body, url_response_callback cb) mutable { \
[api_handle](string, string body, url_response_callback cb) mutable { \
if (body.empty()) body = "{}"; \
api_handle.validate(); \
api_handle.call_name(fc::json::from_string(body).as<api_namespace::call_name ## _params>(),\
......
......@@ -212,7 +212,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
("blocks-dir", bpo::value<bfs::path>()->default_value("blocks"),
"the location of the blocks directory (absolute path or relative to application data dir)")
("checkpoint", bpo::value<vector<string>>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.")
("wasm-runtime", bpo::value<eosio::chain::wasm_interface::vm_type>()->value_name("wavm/binaryen/wabt"), "Override default WASM runtime")
("wasm-runtime", bpo::value<eosio::chain::wasm_interface::vm_type>()->value_name("wavm/wabt"), "Override default WASM runtime")
("abi-serializer-max-time-ms", bpo::value<uint32_t>()->default_value(config::default_abi_serializer_max_time_ms),
"Override default maximum ABI serialization time allowed in ms")
("chain-state-db-size-mb", bpo::value<uint64_t>()->default_value(config::default_state_size / (1024 * 1024)), "Maximum size (in MiB) of the chain state database")
......
......@@ -166,7 +166,8 @@ bfs::path determine_home_directory()
}
string url = "http://127.0.0.1:8888/";
string wallet_url = "http://127.0.0.1:8900/";
string default_wallet_url = "unix://" + (determine_home_directory() / "eosio-wallet" / (string(key_store_executable_name) + ".sock")).string();
string wallet_url; //to be set to default_wallet_url in main
bool no_verify = false;
vector<string> headers;
......@@ -768,25 +769,22 @@ struct set_action_permission_subcommand {
};
bool local_port_used(const string& lo_address, uint16_t port) {
bool local_port_used() {
using namespace boost::asio;
io_service ios;
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(lo_address), port);
boost::asio::ip::tcp::socket socket(ios);
boost::system::error_code ec = error::would_block;
//connecting/failing to connect to localhost should be always fast - don't care about timeouts
socket.async_connect(endpoint, [&](const boost::system::error_code& error) { ec = error; } );
do {
ios.run_one();
} while (ec == error::would_block);
local::stream_protocol::endpoint endpoint(wallet_url.substr(strlen("unix://")));
local::stream_protocol::socket socket(ios);
boost::system::error_code ec;
socket.connect(endpoint, ec);
return !ec;
}
void try_local_port( const string& lo_address, uint16_t port, uint32_t duration ) {
void try_local_port(uint32_t duration) {
using namespace std::chrono;
auto start_time = duration_cast<std::chrono::milliseconds>( system_clock::now().time_since_epoch() ).count();
while ( !local_port_used(lo_address, port)) {
while ( !local_port_used()) {
if (duration_cast<std::chrono::milliseconds>( system_clock::now().time_since_epoch()).count() - start_time > duration ) {
std::cerr << "Unable to connect to keosd, if keosd is running please kill the process and try again.\n";
throw connection_exception(fc::log_messages{FC_LOG_MESSAGE(error, "Unable to connect to keosd")});
......@@ -806,16 +804,11 @@ void ensure_keosd_running(CLI::App* app) {
if (subapp->got_subcommand("listproducers") || subapp->got_subcommand("listbw") || subapp->got_subcommand("bidnameinfo")) // system list* do not require wallet
return;
}
if (wallet_url != default_wallet_url)
return;
auto parsed_url = parse_url(wallet_url);
auto resolved_url = resolve_url(context, parsed_url);
if (!resolved_url.is_loopback)
return;
for (const auto& addr: resolved_url.resolved_addresses)
if (local_port_used(addr, resolved_url.resolved_port)) // Hopefully taken by keosd
return;
if (local_port_used())
return;
boost::filesystem::path binPath = boost::dll::program_location();
binPath.remove_filename();
......@@ -827,13 +820,15 @@ void ensure_keosd_running(CLI::App* app) {
binPath.remove_filename().remove_filename().append("keosd").append(key_store_executable_name);
}
const auto& lo_address = resolved_url.resolved_addresses.front();
if (boost::filesystem::exists(binPath)) {
namespace bp = boost::process;
binPath = boost::filesystem::canonical(binPath);
vector<std::string> pargs;
pargs.push_back("--http-server-address=" + lo_address + ":" + std::to_string(resolved_url.resolved_port));
pargs.push_back("--http-server-address");
pargs.push_back("");
pargs.push_back("--https-server-address");
pargs.push_back("");
::boost::process::child keos(binPath, pargs,
bp::std_in.close(),
......@@ -842,13 +837,12 @@ void ensure_keosd_running(CLI::App* app) {
if (keos.running()) {
std::cerr << binPath << " launched" << std::endl;
keos.detach();
try_local_port(lo_address, resolved_url.resolved_port, 2000);
try_local_port(2000);
} else {
std::cerr << "No wallet service listening on " << lo_address << ":"
<< std::to_string(resolved_url.resolved_port) << ". Failed to launch " << binPath << std::endl;
std::cerr << "No wallet service listening on " << wallet_url << ". Failed to launch " << binPath << std::endl;
}
} else {
std::cerr << "No wallet service listening on " << lo_address << ":" << std::to_string(resolved_url.resolved_port)
std::cerr << "No wallet service listening on "
<< ". Cannot automatically start keosd because keosd was not found." << std::endl;
}
}
......@@ -1745,6 +1739,7 @@ int main( int argc, char** argv ) {
bindtextdomain(locale_domain, locale_path);
textdomain(locale_domain);
context = eosio::client::http::create_http_context();
wallet_url = default_wallet_url;
CLI::App app{"Command Line Interface to EOSIO Client"};
app.require_subcommand();
......
......@@ -1707,6 +1707,13 @@ launcher_def::bounce (const string& node_numbers) {
const string node_num = node.get_node_num();
cout << "Bouncing " << node.name << endl;
string cmd = "./scripts/eosio-tn_bounce.sh " + eosd_extra_args;
if (node_num != "bios" && !specific_nodeos_args.empty()) {
const auto node_num_i = boost::lexical_cast<uint16_t,string>(node_num);
if (specific_nodeos_args.count(node_num_i)) {
cmd += " " + specific_nodeos_args[node_num_i];
}
}
do_command(host, node.name, { { "EOSIO_HOME", host.eosio_home }, { "EOSIO_NODE", node_num } }, cmd);
}
}
......
......@@ -43,7 +43,7 @@ int main(int argc, char** argv)
http_plugin::set_defaults({
.address_config_prefix = "",
.default_unix_socket_path = keosd::config::key_store_executable_name + ".sock",
.default_http_port = 8900
.default_http_port = 0
});
app().register_plugin<wallet_api_plugin>();
if(!app().initialize<wallet_plugin, wallet_api_plugin, http_plugin>(argc, argv))
......
......@@ -32,9 +32,6 @@ add_dependencies(unit_test asserter test_api test_api_mem test_api_db test_ram_l
#Manually run unit_test for all supported runtimes
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose
add_test(NAME unit_test_binaryen COMMAND unit_test
-t \!wasm_tests/weighted_cpu_limit_tests
--report_level=detailed --color_output -- --binaryen)
add_test(NAME unit_test_wavm COMMAND unit_test
-t \!wasm_tests/weighted_cpu_limit_tests
--report_level=detailed --color_output --catch_system_errors=no -- --wavm)
......@@ -59,7 +56,7 @@ if(ENABLE_COVERAGE_TESTING)
endif() # NOT GENHTML_PATH
# no spaces allowed within tests list
set(ctest_tests 'unit_test_binaryen|unit_test_wavm')
set(ctest_tests 'unit_test_wabt|unit_test_wavm')
set(ctest_exclude_tests '')
# Setup target
......
......@@ -41,14 +41,10 @@ class whitelist_blacklist_tester {
cfg.genesis.initial_key = base_tester::get_public_key( config::system_account_name, "active" );
for(int i = 0; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--binaryen"))
cfg.wasm_runtime = chain::wasm_interface::vm_type::binaryen;
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
cfg.wasm_runtime = chain::wasm_interface::vm_type::wavm;
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wabt"))
cfg.wasm_runtime = chain::wasm_interface::vm_type::wabt;
else
cfg.wasm_runtime = chain::wasm_interface::vm_type::binaryen;
}
return cfg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册