Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::wasm_interface Class Reference

#include <wasm_interface.hpp>

Public Types

enum class  vm_type { eos_vm , eos_vm_jit , eos_vm_oc }
 

Public Member Functions

 wasm_interface (vm_type vm, bool eosvmoc_tierup, const chainbase::database &d, const boost::filesystem::path data_dir, const eosvmoc::config &eosvmoc_config, bool profile)
 
 ~wasm_interface ()
 
void indicate_shutting_down ()
 
void code_block_num_last_used (const digest_type &code_hash, const uint8_t &vm_type, const uint8_t &vm_version, const uint32_t &block_num)
 
void current_lib (const uint32_t lib)
 
void apply (const digest_type &code_hash, const uint8_t &vm_type, const uint8_t &vm_version, apply_context &context)
 
void exit ()
 

Static Public Member Functions

static std::string vm_type_string (vm_type vmtype)
 
static void validate (const controller &control, const bytes &code)
 

Public Attributes

std::function< bool(const digest_type &code_hash, uint8_t vm_type, uint8_t vm_version, apply_context &context)> substitute_apply
 

Detailed Description

Definition at line 25 of file wasm_interface.hpp.

Member Enumeration Documentation

◆ vm_type

Constructor & Destructor Documentation

◆ wasm_interface()

sysio::chain::wasm_interface::wasm_interface ( vm_type vm,
bool eosvmoc_tierup,
const chainbase::database & d,
const boost::filesystem::path data_dir,
const eosvmoc::config & eosvmoc_config,
bool profile )

Definition at line 36 of file wasm_interface.cpp.

37 : my( new wasm_interface_impl(vm, eosvmoc_tierup, d, data_dir, eosvmoc_config, profile) ) {}

◆ ~wasm_interface()

sysio::chain::wasm_interface::~wasm_interface ( )

Definition at line 39 of file wasm_interface.cpp.

39{}

Member Function Documentation

◆ apply()

void sysio::chain::wasm_interface::apply ( const digest_type & code_hash,
const uint8_t & vm_type,
const uint8_t & vm_version,
apply_context & context )

Definition at line 81 of file wasm_interface.cpp.

81 {
82 if(substitute_apply && substitute_apply(code_hash, vm_type, vm_version, context))
83 return;
84#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
85 if(my->eosvmoc) {
86 const chain::eosvmoc::code_descriptor* cd = nullptr;
87 try {
88 cd = my->eosvmoc->cc.get_descriptor_for_code(code_hash, vm_version);
89 }
90 catch(...) {
91 //swallow errors here, if SYS VM OC has gone in to the weeds we shouldn't bail: continue to try and run baseline
92 //In the future, consider moving bits of SYS VM that can fire exceptions and such out of this call path
93 static bool once_is_enough;
94 if(!once_is_enough)
95 elog("SYS VM OC has encountered an unexpected failure");
96 once_is_enough = true;
97 }
98 if(cd) {
99 my->eosvmoc->exec.execute(*cd, my->eosvmoc->mem, context);
100 return;
101 }
102 }
103#endif
104 my->get_instantiated_module(code_hash, vm_type, vm_version, context.trx_context)->apply(context);
105 }
std::function< bool(const digest_type &code_hash, uint8_t vm_type, uint8_t vm_version, apply_context &context)> substitute_apply
#define elog(FORMAT,...)
Definition logger.hpp:130
Here is the caller graph for this function:

◆ code_block_num_last_used()

void sysio::chain::wasm_interface::code_block_num_last_used ( const digest_type & code_hash,
const uint8_t & vm_type,
const uint8_t & vm_version,
const uint32_t & block_num )

Definition at line 73 of file wasm_interface.cpp.

73 {
74 my->code_block_num_last_used(code_hash, vm_type, vm_version, block_num);
75 }

◆ current_lib()

void sysio::chain::wasm_interface::current_lib ( const uint32_t lib)

Definition at line 77 of file wasm_interface.cpp.

77 {
78 my->current_lib(lib);
79 }

◆ exit()

void sysio::chain::wasm_interface::exit ( )

Definition at line 107 of file wasm_interface.cpp.

107 {
108 my->runtime_interface->immediately_exit_currently_running_module();
109 }

◆ indicate_shutting_down()

void sysio::chain::wasm_interface::indicate_shutting_down ( )

Definition at line 69 of file wasm_interface.cpp.

69 {
70 my->is_shutting_down = true;
71 }

◆ validate()

void sysio::chain::wasm_interface::validate ( const controller & control,
const bytes & code )
static

Definition at line 41 of file wasm_interface.cpp.

41 {
42 const auto& pso = control.db().get<protocol_state_object>();
43
44 if (control.is_builtin_activated(builtin_protocol_feature_t::configurable_wasm_limits)) {
45 const auto& gpo = control.get_global_properties();
46 webassembly::eos_vm_runtime::validate( code, gpo.wasm_configuration, pso.whitelisted_intrinsics );
47 return;
48 }
50 try {
51 Serialization::MemoryInputStream stream((U8*)code.data(), code.size());
52 WASM::serialize(stream, module);
54 SYS_ASSERT(false, wasm_serialization_error, e.message.c_str());
55 } catch(const IR::ValidationException& e) {
56 SYS_ASSERT(false, wasm_serialization_error, e.message.c_str());
57 }
58
59 wasm_validations::wasm_binary_validation validator(control, module);
60 validator.validate();
61
62 webassembly::eos_vm_runtime::validate( code, pso.whitelisted_intrinsics );
63
64 //there are a couple opportunties for improvement here--
65 //Easy: Cache the Module created here so it can be reused for instantiaion
66 //Hard: Kick off instantiation in a separate thread at this location
67 }
uint8_t U8
Definition BasicTypes.h:5
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
void serialize(Stream &stream, U8 &i)
void validate(const bytes &code, const whitelisted_intrinsics_type &intrinsics)
Definition sys-vm.cpp:64
std::string message
Definition Validate.h:15
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vm_type_string()

static std::string sysio::chain::wasm_interface::vm_type_string ( vm_type vmtype)
inlinestatic

Definition at line 34 of file wasm_interface.hpp.

34 {
35 switch (vmtype) {
36 case vm_type::eos_vm:
37 return "sys-vm";
38 case vm_type::eos_vm_oc:
39 return "sys-vm-oc";
40 default:
41 return "sys-vm-jit";
42 }
43 }
Here is the caller graph for this function:

Member Data Documentation

◆ substitute_apply

std::function<bool( const digest_type& code_hash, uint8_t vm_type, uint8_t vm_version, apply_context& context)> sysio::chain::wasm_interface::substitute_apply

Definition at line 69 of file wasm_interface.hpp.


The documentation for this class was generated from the following files: