Skip to content

Commit

Permalink
Fix compiler errors after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
learnforpractice committed Oct 24, 2018
1 parent ed22313 commit cffcb63
Show file tree
Hide file tree
Showing 28 changed files with 142 additions and 136 deletions.
2 changes: 1 addition & 1 deletion externals/python
Submodule python updated 2 files
+1 −1 CMakeLists.txt
+0 −4,154 inspector.wrap.cpp
10 changes: 2 additions & 8 deletions libraries/chain/apply_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,9 @@ void apply_context::exec_one( action_trace& trace )
control.check_contract_list( receiver );
control.check_action_list( act.account, act.name );
}
try {
if (a.vm_type == 0 && wasm_apply_debug(receiver.value, act.account.value, act.name.value)) {
//
} else {
try {
vm_manager::get().apply(a.vm_type, receiver.value, act.account.value, act.name.value);
}
// control.get_wasm_interface().apply(a.code_version, a.code, *this);
} catch ( const wasm_exit& ){}

} catch ( const wasm_exit& ){}
}
} FC_RETHROW_EXCEPTIONS( warn, "pending console output: ${console}", ("console", _pending_console_output.str()) )
} catch( fc::exception& e ) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/chain_api.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <eosio/chain/chain_api.hpp>
#include <eosio/chain/controller.hpp>
#include <eosio/chain/chain_api.hpp>

using namespace fc;

Expand Down
27 changes: 2 additions & 25 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ using contract_database_index_set = index_set<
index128_index,
index256_index,
index_double_index,
index_long_double_index
index_long_double_index,
key256_value_index
>;

class maybe_session {
Expand Down Expand Up @@ -198,7 +199,6 @@ struct controller_impl {
SET_APP_HANDLER( eosio, eosio, newaccount );
SET_APP_HANDLER( eosio, eosio, setcode );
SET_APP_HANDLER( eosio, eosio, setabi );
SET_APP_HANDLER( eosio, eosio, setconfig );
SET_APP_HANDLER( eosio, eosio, updateauth );
SET_APP_HANDLER( eosio, eosio, deleteauth );
SET_APP_HANDLER( eosio, eosio, linkauth );
Expand Down Expand Up @@ -2102,29 +2102,6 @@ void controller::validate_tapos( const transaction& trx )const { try {
("tapos_summary", tapos_block_summary));
} FC_CAPTURE_AND_RETHROW() }

const action_object& controller::get_action_object() const{
return db().get<action_object>();
}

void controller::set_action_object(const account_name& receiver, const action& act) {
const action_object& _act_obj = get_action_object();
try {
db().modify(_act_obj, [&](action_object& act_obj) {
act_obj.receiver = receiver;
act_obj.account = act.account;
act_obj.name = act.name;

// act_obj.authorization.resize(0);
act_obj.authorization.resize(act.authorization.size());
memcpy(act_obj.authorization.data(), act.authorization.data(), act.authorization.size());

// act_obj.data.resize(0);
act_obj.data.resize(act.data.size());
memcpy(act_obj.data.data(), act.data.data(), act.data.size());
});
} FC_LOG_AND_DROP();
}

void controller::validate_db_available_size() const {
const auto free = db().get_segment_manager()->get_free_memory();
const auto guard = my->conf.state_guard_size;
Expand Down
24 changes: 0 additions & 24 deletions libraries/chain/eosio_contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,30 +278,6 @@ void apply_eosio_setabi(apply_context& context) {
}
}

void apply_eosio_setconfig(apply_context& context) {
auto& db = context.db;
auto act = context.act.data_as<setconfig>();

context.require_authorization(act.account);

const auto& account = db.get<account_object,by_name>(act.account);

int64_t config_size = act.config.size();

int64_t old_size = (int64_t)account.config.size();
int64_t new_size = config_size;

db.modify( account, [&]( auto& a ) {
a.config.resize( config_size );
if( config_size > 0 )
memcpy( a.config.data(), act.config.data(), config_size );
});

if (new_size != old_size) {
context.add_ram_usage( act.account, new_size - old_size );
}
}

void apply_eosio_updateauth(apply_context& context) {

auto update = context.act.data_as<updateauth>();
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace eosio { namespace chain {

class account_object : public chainbase::object<account_object_type, account_object> {
OBJECT_CTOR(account_object,(code)(abi)(config))
OBJECT_CTOR(account_object,(code)(abi))

id_type id;
account_name name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ namespace eosio { namespace chain {
};

DECLARE_TABLE_ID_TAG(key_value_object, by_scope_primary)
DECLARE_TABLE_ID_TAG(key256_value_object, by_scope_primary)
DECLARE_TABLE_ID_TAG(index64_object, by_primary)
DECLARE_TABLE_ID_TAG(index128_object, by_primary)
DECLARE_TABLE_ID_TAG(index256_object, by_primary)
Expand Down Expand Up @@ -274,6 +275,7 @@ CHAINBASE_SET_INDEX_TYPE(eosio::chain::index_long_double_object, eosio::chain::i

FC_REFLECT(eosio::chain::table_id_object, (code)(scope)(table)(payer)(count) )
FC_REFLECT(eosio::chain::key_value_object, (primary_key)(payer)(value) )
FC_REFLECT(eosio::chain::key256_value_object, (primary_key)(payer)(value) )

#define REFLECT_SECONDARY(type)\
FC_REFLECT(type, (primary_key)(payer)(secondary_key) )
Expand Down
3 changes: 0 additions & 3 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ namespace eosio { namespace chain {
void add_indices();
void startup( const snapshot_reader_ptr& snapshot = nullptr );

void set_action_object(const account_name& receiver, const action& act);
const action_object& get_action_object() const;

/**
* Starts a new pending block session upon which new transactions can
* be pushed.
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/eosio/chain/database_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ namespace fc {

inline
void to_variant( const float128_t& f, variant& v ) {
v = variant(*reinterpret_cast<const uint128_t*>(&f));
v = variant(*reinterpret_cast<const eosio::chain::uint128_t*>(&f));
}

inline
void from_variant( const variant& v, float128_t& f ) {
from_variant(v, *reinterpret_cast<uint128_t*>(&f));
from_variant(v, *reinterpret_cast<eosio::chain::uint128_t*>(&f));
}

inline
Expand Down
9 changes: 6 additions & 3 deletions libraries/chain/vm_api_native/vm_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,17 @@ static struct vm_api_cpp _vm_api_cpp = {
extern "C" void vm_manager_init() {
//action.cpp
vm_register_api(&_vm_api);
vm_manager::get().init(&_vm_api);
vm_manager::get().init();

s_args.reserve(256);
s_results.reserve(256);
}

extern "C" void vm_manager_init_python() {
//action.cpp
vm_manager::get().load_vm_cpython();
}

static int vm_apply(int type, uint64_t receiver, uint64_t account, uint64_t act) {
try {
return vm_manager::get().apply( type, receiver, account, act);
Expand Down Expand Up @@ -770,8 +775,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
Expand Down
2 changes: 1 addition & 1 deletion libraries/fc
2 changes: 1 addition & 1 deletion libraries/ipc/ipc_client/ipc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#include <fc/log/logger.hpp>

#include <softfloat.hpp>
#include <eosiolib_native/vm_api.h>

#include <eosio/chain/db_api.hpp>
#include "thrift/blockingconcurrentqueue.h"
#include "thrift/readerwriterqueue.h"
#include "thrift/RpcService.h"

#include <vm_manager.hpp>
#include <eosiolib_native/vm_api.h>

using namespace eosio::chain;

Expand Down
8 changes: 2 additions & 6 deletions libraries/ipc/ipc_client/vm_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ int run_mode() // 0 for server, 1 for client
static struct vm_api _vm_api = {
};

struct vm_api* get_vm_api() {
return &_vm_api;
}

void vm_manager_init(int vm_type) {
vm_register_api(&_vm_api);
vm_manager::get().set_vm_api(&_vm_api);
Expand All @@ -140,8 +136,8 @@ 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
in.setstate(std::ios_base::failbit);
return in;
Expand Down
4 changes: 3 additions & 1 deletion libraries/ipc/ipc_server/ipc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
#include <fc/log/logger.hpp>

#include <softfloat.hpp>
#include <eosiolib_native/vm_api.h>

#include <eosio/chain/db_api.hpp>
#include "thrift/blockingconcurrentqueue.h"
#include "thrift/readerwriterqueue.h"
#include "thrift/RpcService.h"
#include <mutex>

#include <eosiolib_native/vm_api.h>
#include <eosiolib/db.h>

using namespace eosio::chain;

using namespace ::apache::thrift;
Expand Down
14 changes: 9 additions & 5 deletions libraries/vm/vm_cpython/vm_cpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ void get_code(uint64_t account, string& code) {
code = string(_code, size);
}


void init_vm_cpython() {
PyImport_AppendInittab("vm_cpython", PyInit_vm_cpython);
PyImport_AppendInittab("db", PyInit_db);
PyImport_AppendInittab("eoslib", PyInit_eoslib);
}

void vm_init(struct vm_api* api) {
api->vm_cpython_compile = vm_cpython_compile;
s_api = api;
Py_InitializeEx(0);

PyInit_db();
PyInit_eoslib();
PyInit_vm_cpython();
//for PEP489_MULTI_PHASE_INIT compatibility
init_vm_cpython();
}

void vm_deinit() {
Expand Down
10 changes: 8 additions & 2 deletions libraries/vm/vm_cpython_ss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ add_library(vm_cpython_ss SHARED
vm_cpython.wrap.cpp
opcode.cc
test.wrap.cpp
vm_cpython.cpp)
vm_cpython.cpp
${CMAKE_SOURCE_DIR}/libraries/vm/libvmapi4python/eoslib.wrap.cpp
${CMAKE_SOURCE_DIR}/libraries/vm/libvmapi4python/db.wrap.cpp
${CMAKE_SOURCE_DIR}/libraries/vm/libvmapi4python/eoslib_.cpp
)

set_target_properties(vm_cpython_ss PROPERTIES LINK_FLAGS "${LINK_FLAGS}")

target_link_libraries(vm_cpython_ss PRIVATE python3-ss vmapi4python)
target_link_libraries(vm_cpython_ss PRIVATE python3-ss fc)
#target_compile_options(vm_cpython_ss PUBLIC -DCYTHON_PEP489_MULTI_PHASE_INIT=0)

target_include_directories(vm_cpython_ss PRIVATE ${Boost_INCLUDE_DIR}
# PRIVATE ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include
Expand All @@ -43,6 +48,7 @@ target_include_directories(vm_cpython_ss PRIVATE ${Boost_INCLUDE_DIR}
PUBLIC ${CMAKE_SOURCE_DIR}/externals/python/Include
PUBLIC ${CMAKE_SOURCE_DIR}/externals/python

PRIVATE ${CMAKE_SOURCE_DIR}/libraries/fc/include
PRIVATE ${CMAKE_BINARY_DIR}/libraries/fc/include
# PRIVATE ${CMAKE_BINARY_DIR}/libraries/chain/include
PRIVATE ${CMAKE_SOURCE_DIR}/contracts
Expand Down
38 changes: 28 additions & 10 deletions libraries/vm/vm_cpython_ss/vm_cpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ PyObject* PyInit_sys2(void);
PyObject* PyInit_readline(void);

PyObject* PyInit__tracemalloc(void);

PyThreadState* Py_NewInterpreterEx(void);
}

Expand All @@ -32,6 +31,7 @@ int cpython_clearcode(uint64_t account);

int cpython_apply(unsigned long long receiver, unsigned long long account, unsigned long long action);
int init_function_whitelist();
int error_handler(string& error);

void get_code(uint64_t account, string& code) {
size_t size;
Expand Down Expand Up @@ -213,29 +213,47 @@ void prepare_env(uint64_t account) {
name = PyUnicode_FromString("_tracemalloc");
_PyImport_SetModule(name, module);

module = PyInit_inspector();
name = PyUnicode_FromString("inspector");
_PyImport_SetModule(name, module);

module = PyInit_vm_cpython();
name = PyUnicode_FromString("vm_cpython");
module = PyInit_db();
if (module == NULL) {
goto error;
}
name = PyUnicode_FromString("db");
_PyImport_SetModule(name, module);
s->modules["db"] = module;

module = PyInit_eoslib();
if (module == NULL) {
goto error;
}
name = PyUnicode_FromString("eoslib");
_PyImport_SetModule(name, module);
s->modules["eoslib"] = module;

module = PyInit_db();
name = PyUnicode_FromString("db");
module = PyInit_inspector();
if (module == NULL) {
goto error;
}
name = PyUnicode_FromString("inspector");
_PyImport_SetModule(name, module);

module = PyInit_vm_cpython();
if (module == NULL) {
goto error;
}
name = PyUnicode_FromString("vm_cpython");
_PyImport_SetModule(name, module);
s->modules["db"] = module;

s_sandbox_map[account] = std::move(s);
} else {
PyThreadState_Swap(itr->second->state);
}
return;
error:
string error;
error_handler(error);
vmdlog("+++++++%s \n", error.c_str());
// PyThreadState_Swap(mainstate);
return;
}

int vm_setcode(uint64_t account) {
Expand Down
4 changes: 2 additions & 2 deletions libraries/vm/vm_native/native_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "native_interface.hpp"

#include <eosio/chain/types.hpp>
#include <eosio/chain/db_api.hpp>

#include <fc/ext_string.h>
#include <dlfcn.h>

#include "native_interface.hpp"

using namespace fc;


Expand Down
Loading

0 comments on commit cffcb63

Please sign in to comment.