提交 f5ed0b4a 编写于 作者: M Matt Witherspoon

initial work at allowing wasm runtime to be configurable

(not wired up yet)
上级 a276d30d
......@@ -77,6 +77,7 @@ namespace eosio { namespace chain {
std::vector<signal<void(const transaction_metadata&, const packed_transaction&)>::slot_type> on_pending_transaction_callbacks;
contracts::genesis_state_type genesis;
runtime_limits limits;
wasm_interface::vm_type wasm_runtime = config::default_wasm_runtime;
};
explicit chain_controller( const controller_config& cfg );
......
......@@ -4,6 +4,7 @@
*/
#pragma once
#include <eosio/chain/asset.hpp>
#include <eosio/chain/wasm_interface.hpp>
#include <fc/time.hpp>
#pragma GCC diagnostic ignored "-Wunused-variable"
......@@ -64,6 +65,8 @@ const static uint32_t rate_limiting_precision = 1000*1000;
const static uint16_t max_recursion_depth = 6;
const static eosio::chain::wasm_interface::vm_type default_wasm_runtime = eosio::chain::wasm_interface::vm_type::binaryen;
/**
* The number of sequential blocks produced by a single producer
*/
......
#pragma once
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/types.hpp>
namespace eosio { namespace chain {
......@@ -123,3 +122,7 @@ namespace eosio { namespace chain {
};
} } // eosio::chain
namespace eosio{ namespace chain {
std::istream& operator>>(std::istream& in, wasm_interface::vm_type& runtime);
}}
\ No newline at end of file
......@@ -1614,5 +1614,16 @@ REGISTER_INTRINSICS(db_index_api_key64x64x64_value_index_by_scope_primary, DB_
REGISTER_INTRINSICS(db_index_api_key64x64x64_value_index_by_scope_secondary, DB_INDEX_METHOD_SEQ(secondary_i64i64i64));
REGISTER_INTRINSICS(db_index_api_key64x64x64_value_index_by_scope_tertiary, DB_INDEX_METHOD_SEQ(tertiary_i64i64i64));
std::istream& operator>>(std::istream& in, wasm_interface::vm_type& runtime) {
std::string s;
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
in.setstate(std::ios_base::failbit);
return in;
}
} } /// eosio::chain
#include <eosio/chain/webassembly/wavm.hpp>
#include <eosio/chain/wasm_eosio_constraints.hpp>
#include <eosio/chain/apply_context.hpp>
#include <eosio/chain/exceptions.hpp>
#include "IR/Module.h"
#include "Platform/Platform.h"
......
......@@ -10,7 +10,7 @@
#include <eosio/chain/producer_object.hpp>
#include <eosio/chain/config.hpp>
#include <eosio/chain/types.hpp>
#include <eosio/chain/wasm_interface.hpp>
#include <eosio/chain/contracts/chain_initializer.hpp>
#include <eosio/chain/contracts/genesis_state.hpp>
......@@ -27,6 +27,7 @@ namespace eosio {
using namespace eosio;
using namespace eosio::chain;
using namespace eosio::chain::config;
using vm_type = wasm_interface::vm_type;
using fc::flat_map;
//using txn_msg_rate_limits = chain_controller::txn_msg_rate_limits;
......@@ -49,6 +50,7 @@ public:
uint32_t max_reversible_block_time_ms;
uint32_t max_pending_transaction_time_ms;
//txn_msg_rate_limits rate_limits;
fc::optional<vm_type> wasm_runtime;
};
chain_plugin::chain_plugin()
......@@ -69,6 +71,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
"Limits the maximum time (in milliseconds) that a reversible block is allowed to run before being considered invalid")
("max-pending-transaction-time", bpo::value<int32_t>()->default_value(-1),
"Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid")
("wasm-runtime", bpo::value<eosio::chain::wasm_interface::vm_type>(), "Override default WASM runtime; not supported")
#warning TODO: rate limiting
/*("per-authorized-account-transaction-msg-rate-limit-time-frame-sec", bpo::value<uint32_t>()->default_value(default_per_auth_account_time_frame_seconds),
"The time frame, in seconds, that the per-authorized-account-transaction-msg-rate-limit is imposed over.")
......@@ -161,6 +164,9 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
my->max_reversible_block_time_ms = options.at("max-reversible-block-time").as<int32_t>();
my->max_pending_transaction_time_ms = options.at("max-pending-transaction-time").as<int32_t>();
if(options.count("wasm-runtime"))
my->wasm_runtime = options.at("wasm-runtime").as<vm_type>();
#warning TODO: Rate Limits
/*my->rate_limits.per_auth_account_time_frame_sec = fc::time_point_sec(options.at("per-authorized-account-transaction-msg-rate-limit-time-frame-sec").as<uint32_t>());
my->rate_limits.per_auth_account = options.at("per-authorized-account-transaction-msg-rate-limit").as<uint32_t>();
......@@ -190,6 +196,9 @@ void chain_plugin::plugin_startup()
my->chain_config->limits.max_push_transaction_us = fc::milliseconds(my->max_pending_transaction_time_ms);
}
if(my->wasm_runtime)
my->chain_config->wasm_runtime = *my->wasm_runtime;
my->chain.emplace(*my->chain_config);
if(!my->readonly) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册