Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
serialization.hpp
Go to the documentation of this file.
1#pragma once
2
14#include <sysio/chain/trace.hpp>
16
17#include <type_traits>
18
19template <typename T>
24
25template <typename T>
29
30template <typename P, typename T>
36
37template <typename P, typename T>
39 const P& context, const T& obj) {
40 return {db, context, obj};
41}
42
43namespace fc {
44
45template <typename T>
46const T& as_type(const T& x) {
47 return x;
48}
49
50template <typename ST, typename T>
52 fc::raw::pack(ds, unsigned_int(v.size()));
53 for (auto& x : v)
54 ds << make_history_serial_wrapper(db, x);
55 return ds;
56}
57
58template <typename ST, typename T>
60 const std::vector<std::shared_ptr<T>>& v) {
61 fc::raw::pack(ds, unsigned_int(v.size()));
62 for (auto& x : v) {
63 SYS_ASSERT(!!x, sysio::chain::plugin_exception, "null inside container");
64 ds << make_history_serial_wrapper(db, *x);
65 }
66 return ds;
67}
68
69template <typename ST, typename P, typename T>
71 const std::vector<T>& v) {
72 fc::raw::pack(ds, unsigned_int(v.size()));
73 for (const auto& x : v) {
75 }
76 return ds;
77}
78
79template <typename ST, typename T>
80datastream<ST>& operator<<(datastream<ST>& ds, const sysio::state_history::big_vector_wrapper<T>& obj) {
81 FC_ASSERT(obj.obj.size() <= 1024 * 1024 * 1024);
82 fc::raw::pack(ds, unsigned_int((uint32_t)obj.obj.size()));
83 for (auto& x : obj.obj)
84 fc::raw::pack(ds, x);
85 return ds;
86}
87
88template <typename ST>
90 do {
91 uint8_t b = uint8_t(val) & 0x7f;
92 val >>= 7;
93 b |= ((val > 0) << 7);
94 ds.write((char*)&b, 1);
95 } while (val);
96}
97
98template <typename ST>
100 history_pack_varuint64(ds, v.size());
101 if (v.size())
102 ds.write(&v.front(), v.size());
103}
104
105template <typename ST>
106void history_pack_big_bytes(datastream<ST>& ds, const std::optional<sysio::chain::bytes>& v) {
107 fc::raw::pack(ds, v.has_value());
108 if (v)
110}
111
112template <typename ST, typename T>
113datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<std::vector<T>>& obj) {
114 return history_serialize_container(ds, obj.db, obj.obj);
115}
116
117template <typename ST, typename P, typename T>
118datastream<ST>& operator<<(datastream<ST>& ds, const history_context_wrapper<P, std::vector<T>>& obj) {
119 return history_context_serialize_container(ds, obj.db, obj.context, obj.obj);
120}
121
122template <typename ST, typename First, typename Second>
123datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<std::pair<First, Second>>& obj) {
124 fc::raw::pack(ds, obj.obj.first);
125 fc::raw::pack(ds, obj.obj.second);
126 return ds;
127}
128
129template <typename ST>
130datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::account_object>& obj) {
132 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.to_uint64_t()));
135 return ds;
136}
137
138template <typename ST>
139datastream<ST>& operator<<(datastream<ST>& ds,
142 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.to_uint64_t()));
143 fc::raw::pack(ds, as_type<bool>(obj.obj.is_privileged()));
144 fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.last_code_update));
145 bool has_code = obj.obj.code_hash != sysio::chain::digest_type();
146 fc::raw::pack(ds, has_code);
147 if (has_code) {
148 fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_type));
149 fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_version));
151 }
152 return ds;
153}
154
155template <typename ST>
156datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::code_object>& obj) {
158 fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_type));
159 fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_version));
162 return ds;
163}
164
165template <typename ST>
166datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::table_id_object>& obj) {
168 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.code.to_uint64_t()));
169 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.scope.to_uint64_t()));
170 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.table.to_uint64_t()));
171 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.payer.to_uint64_t()));
172 return ds;
173}
174
175template <typename ST>
176datastream<ST>&
177operator<<(datastream<ST>& ds,
180 fc::raw::pack(ds, as_type<uint64_t>(obj.context.code.to_uint64_t()));
181 fc::raw::pack(ds, as_type<uint64_t>(obj.context.scope.to_uint64_t()));
182 fc::raw::pack(ds, as_type<uint64_t>(obj.context.table.to_uint64_t()));
183 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.primary_key));
184 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.payer.to_uint64_t()));
186 return ds;
187}
188
189template <typename ST, typename T>
191 fc::raw::pack(ds, obj);
192}
193
194template <typename ST>
196 uint64_t i;
197 memcpy(&i, &obj, sizeof(i));
198 fc::raw::pack(ds, i);
199}
200
201template <typename ST>
203 __uint128_t i;
204 memcpy(&i, &obj, sizeof(i));
205 fc::raw::pack(ds, i);
206}
207
208template <typename ST>
210 auto rev = [&](__uint128_t x) {
211 char* ch = reinterpret_cast<char*>(&x);
212 std::reverse(ch, ch + sizeof(x));
213 return x;
214 };
215 fc::raw::pack(ds, rev(obj[0]));
216 fc::raw::pack(ds, rev(obj[1]));
217}
218
219template <typename ST, typename T>
221 const T& obj) {
223 fc::raw::pack(ds, as_type<uint64_t>(context.code.to_uint64_t()));
224 fc::raw::pack(ds, as_type<uint64_t>(context.scope.to_uint64_t()));
225 fc::raw::pack(ds, as_type<uint64_t>(context.table.to_uint64_t()));
226 fc::raw::pack(ds, as_type<uint64_t>(obj.primary_key));
227 fc::raw::pack(ds, as_type<uint64_t>(obj.payer.to_uint64_t()));
228 serialize_secondary_index_data(ds, obj.secondary_key);
229 return ds;
230}
231
232template <typename ST>
233datastream<ST>&
234operator<<(datastream<ST>& ds,
236 return serialize_secondary_index(ds, obj.context, obj.obj);
237}
238
239template <typename ST>
240datastream<ST>&
241operator<<(datastream<ST>& ds,
243 return serialize_secondary_index(ds, obj.context, obj.obj);
244}
245
246template <typename ST>
247datastream<ST>&
248operator<<(datastream<ST>& ds,
250 return serialize_secondary_index(ds, obj.context, obj.obj);
251}
252
253template <typename ST>
254datastream<ST>&
255operator<<(datastream<ST>& ds,
257 return serialize_secondary_index(ds, obj.context, obj.obj);
258}
259
260template <typename ST>
261datastream<ST>&
262operator<<(datastream<ST>& ds,
264 return serialize_secondary_index(ds, obj.context, obj.obj);
265}
266
267template <typename ST>
268datastream<ST>& operator<<(datastream<ST>& ds,
270 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.threshold));
273}
274
275template <typename ST>
276datastream<ST>& operator<<(datastream<ST>& ds,
278 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.producer_name.to_uint64_t()));
280 return ds;
281}
282
283template <typename ST>
284datastream<ST>& operator<<(datastream<ST>& ds,
286 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.version));
289 return ds;
290}
291
292template <typename ST>
293datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::chain_config>& obj) {
295 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.max_block_net_usage));
296 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.target_block_net_usage_pct));
297 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_net_usage));
298 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.base_per_transaction_net_usage));
299 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.net_usage_leeway));
300 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.context_free_discount_net_usage_num));
301 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.context_free_discount_net_usage_den));
302 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_block_cpu_usage));
303 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.target_block_cpu_usage_pct));
304 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_cpu_usage));
305 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.min_transaction_cpu_usage));
306 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_lifetime));
307 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.deferred_trx_expiration_window));
308 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_delay));
309 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_inline_action_size));
310 fc::raw::pack(ds, as_type<uint16_t>(obj.obj.max_inline_action_depth));
311 fc::raw::pack(ds, as_type<uint16_t>(obj.obj.max_authority_depth));
312 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_action_return_value_size));
313 return ds;
314}
315
316template <typename ST>
317datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::wasm_config>& obj) {
319 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_mutable_global_bytes));
320 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_table_elements));
321 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_section_elements));
322 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_linear_memory_init));
323 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_func_local_bytes));
324 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_nested_structures));
325 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_symbol_bytes));
326 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_module_bytes));
327 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_code_bytes));
328 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_pages));
329 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_call_depth));
330 return ds;
331}
332
333template <typename ST>
334datastream<ST>& operator<<(datastream<ST>& ds,
337 fc::raw::pack(ds, as_type<std::optional<sysio::chain::block_num_type>>(obj.obj.proposed_schedule_block_num));
342 fc::raw::pack(ds,
344 return ds;
345}
346
347template <typename ST>
348datastream<ST>& operator<<(datastream<ST>& ds,
351 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.sender.to_uint64_t()));
352 fc::raw::pack(ds, as_type<__uint128_t>(obj.obj.sender_id));
353 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.payer.to_uint64_t()));
356 return ds;
357}
358
359template <typename ST>
360datastream<ST>&
361operator<<(datastream<ST>& ds,
365 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.activation_block_num));
366 return ds;
367}
368
369template <typename ST>
370datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::protocol_state_object>& obj) {
372 history_serialize_container(ds, obj.db, obj.obj.activated_protocol_features);
373 return ds;
374}
375
376template <typename ST>
377datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::shared_key_weight>& obj) {
379 fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
380 return ds;
381}
382
383template <typename ST>
384datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::permission_level>& obj) {
385 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.actor.to_uint64_t()));
386 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.permission.to_uint64_t()));
387 return ds;
388}
389
390template <typename ST>
391datastream<ST>& operator<<(datastream<ST>& ds,
394 fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
395 return ds;
396}
397
398template <typename ST>
399datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::wait_weight>& obj) {
400 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.wait_sec));
401 fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
402 return ds;
403}
404
405template <typename ST>
406datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::shared_authority>& obj) {
407 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.threshold));
408 history_serialize_container(ds, obj.db, obj.obj.keys);
409 history_serialize_container(ds, obj.db, obj.obj.accounts);
410 history_serialize_container(ds, obj.db, obj.obj.waits);
411 return ds;
412}
413
414template <typename ST>
415datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::permission_object>& obj) {
417 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.owner.to_uint64_t()));
418 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.to_uint64_t()));
419 if (obj.obj.parent._id) {
420 auto& index = obj.db.get_index<sysio::chain::permission_index>();
421 const auto* parent = index.find(obj.obj.parent);
422 if (!parent) {
423 auto undo = index.last_undo_session();
424 auto it = std::find_if(undo.removed_values.begin(), undo.removed_values.end(),
425 [&](auto& x) { return x.id._id == obj.obj.parent; });
426 SYS_ASSERT(it != undo.removed_values.end(), sysio::chain::plugin_exception,
427 "can not find parent of permission_object");
428 parent = &*it;
429 }
430 fc::raw::pack(ds, as_type<uint64_t>(parent->name.to_uint64_t()));
431 } else {
433 }
434 fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.last_updated));
436 return ds;
437}
438
439template <typename ST>
440datastream<ST>& operator<<(datastream<ST>& ds,
443 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.account.to_uint64_t()));
444 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.code.to_uint64_t()));
445 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.message_type.to_uint64_t()));
446 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.required_permission.to_uint64_t()));
447 return ds;
448}
449
450template <typename ST>
451datastream<ST>& operator<<(datastream<ST>& ds,
453 SYS_ASSERT(!obj.obj.pending, sysio::chain::plugin_exception,
454 "accepted_block sent while resource_limits_object in pending state");
456 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.owner.to_uint64_t()));
457 fc::raw::pack(ds, as_type<int64_t>(obj.obj.net_weight));
458 fc::raw::pack(ds, as_type<int64_t>(obj.obj.cpu_weight));
459 fc::raw::pack(ds, as_type<int64_t>(obj.obj.ram_bytes));
460 return ds;
461}
462
463template <typename ST>
464datastream<ST>& operator<<(datastream<ST>& ds,
467 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.last_ordinal));
468 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.value_ex));
469 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.consumed));
470 return ds;
471}
472
473template <typename ST>
474datastream<ST>& operator<<(datastream<ST>& ds,
477 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.owner.to_uint64_t()));
482 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.ram_usage));
483 return ds;
484}
485
486template <typename ST>
487datastream<ST>&
488operator<<(datastream<ST>& ds,
492 obj.obj.average_block_net_usage)));
494 obj.obj.average_block_cpu_usage)));
495 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.total_net_weight));
496 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.total_cpu_weight));
497 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.total_ram_bytes));
498 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.virtual_net_limit));
499 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.virtual_cpu_limit));
500 return ds;
501}
502
503template <typename ST>
504datastream<ST>& operator<<(datastream<ST>& ds,
507 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.numerator));
508 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.denominator));
509 return ds;
510}
511
512template <typename ST>
513datastream<ST>& operator<<(datastream<ST>& ds,
516 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.target));
517 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.max));
518 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.periods));
519 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_multiplier));
524 return ds;
525}
526
527template <typename ST>
528datastream<ST>&
529operator<<(datastream<ST>& ds,
538 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.account_cpu_usage_average_window));
539 fc::raw::pack(ds, as_type<uint32_t>(obj.obj.account_net_usage_average_window));
540 return ds;
541};
542
543template <typename ST>
544datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::action>& obj) {
545 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.account.to_uint64_t()));
546 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.to_uint64_t()));
547 history_serialize_container(ds, obj.db, as_type<std::vector<sysio::chain::permission_level>>(obj.obj.authorization));
549 return ds;
550}
551
552template <typename ST>
553datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::action_receipt>& obj) {
555 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.receiver.to_uint64_t()));
557 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.global_sequence));
558 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.recv_sequence));
559 history_serialize_container(ds, obj.db, as_type<flat_map<sysio::chain::name, uint64_t>>(obj.obj.auth_sequence));
560 fc::raw::pack(ds, as_type<fc::unsigned_int>(obj.obj.code_sequence));
561 fc::raw::pack(ds, as_type<fc::unsigned_int>(obj.obj.abi_sequence));
562 return ds;
563}
564
565template <typename ST>
566datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<sysio::chain::account_delta>& obj) {
567 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.account.to_uint64_t()));
568 fc::raw::pack(ds, as_type<int64_t>(obj.obj.delta));
569 return ds;
570}
571
572inline std::optional<uint64_t> cap_error_code(const std::optional<uint64_t>& error_code) {
573 std::optional<uint64_t> result;
574
575 if (!error_code)
576 return result;
577
579
580 if (*error_code >= upper_limit) {
581 result = upper_limit;
582 return result;
583 }
584
585 result = error_code;
586 return result;
587}
588
589template <typename ST>
590datastream<ST>& operator<<(datastream<ST>& ds, const history_context_wrapper<bool, sysio::chain::action_trace>& obj) {
591 bool debug_mode = obj.context;
593 fc::raw::pack(ds, as_type<fc::unsigned_int>(obj.obj.action_ordinal));
594 fc::raw::pack(ds, as_type<fc::unsigned_int>(obj.obj.creator_action_ordinal));
595 fc::raw::pack(ds, bool(obj.obj.receipt));
596 if (obj.obj.receipt) {
598 }
599 fc::raw::pack(ds, as_type<uint64_t>(obj.obj.receiver.to_uint64_t()));
601 fc::raw::pack(ds, as_type<bool>(obj.obj.context_free));
602 fc::raw::pack(ds, as_type<int64_t>(debug_mode ? obj.obj.elapsed.count() : 0));
603 if (debug_mode)
604 fc::raw::pack(ds, as_type<std::string>(obj.obj.console));
605 else
606 fc::raw::pack(ds, std::string{});
607 history_serialize_container(ds, obj.db, as_type<flat_set<sysio::chain::account_delta>>(obj.obj.account_ram_deltas));
608
609 std::optional<std::string> e;
610 if (obj.obj.except) {
611 if (debug_mode)
612 e = obj.obj.except->to_string();
613 else
614 e = "Y";
615 }
616 fc::raw::pack(ds, as_type<std::optional<std::string>>(e));
617 fc::raw::pack(ds,
618 as_type<std::optional<uint64_t>>(debug_mode ? obj.obj.error_code : cap_error_code(obj.obj.error_code)));
619 fc::raw::pack(ds, as_type<sysio::chain::bytes>(obj.obj.return_value));
620
621 return ds;
622}
623
624template <typename ST>
625datastream<ST>& operator<<(
626 datastream<ST>& ds,
628 auto& trace = *obj.obj.trace;
629 bool debug_mode = obj.context.second;
632 if (trace.receipt) {
633 if (trace.failed_dtrx_trace && trace.receipt->status.value == sysio::chain::transaction_receipt_header::soft_fail)
635 else
636 fc::raw::pack(ds, as_type<uint8_t>(trace.receipt->status.value));
637 fc::raw::pack(ds, as_type<uint32_t>(trace.receipt->cpu_usage_us));
638 fc::raw::pack(ds, as_type<fc::unsigned_int>(trace.receipt->net_usage_words));
639 } else {
640 fc::raw::pack(ds, uint8_t(obj.context.first));
641 fc::raw::pack(ds, uint32_t(0));
643 }
644 fc::raw::pack(ds, as_type<int64_t>(debug_mode ? trace.elapsed.count() : 0));
645 fc::raw::pack(ds, as_type<uint64_t>(trace.net_usage));
646 fc::raw::pack(ds, as_type<bool>(trace.scheduled));
647 history_context_serialize_container(ds, obj.db, debug_mode,
648 as_type<std::vector<sysio::chain::action_trace>>(trace.action_traces));
649
650 fc::raw::pack(ds, bool(trace.account_ram_delta));
651 if (trace.account_ram_delta) {
653 ds, make_history_serial_wrapper(obj.db, as_type<sysio::chain::account_delta>(*trace.account_ram_delta)));
654 }
655
656 std::optional<std::string> e;
657 if (trace.except) {
658 if (debug_mode)
659 e = trace.except->to_string();
660 else
661 e = "Y";
662 }
663 fc::raw::pack(ds, as_type<std::optional<std::string>>(e));
664 fc::raw::pack(ds, as_type<std::optional<uint64_t>>(debug_mode ? trace.error_code : cap_error_code(trace.error_code)));
665
666 fc::raw::pack(ds, bool(trace.failed_dtrx_trace));
667 if (trace.failed_dtrx_trace) {
669 if (trace.receipt && trace.receipt->status.value == sysio::chain::transaction_receipt_header::soft_fail)
671 std::pair<uint8_t, bool> context = std::make_pair(stat, debug_mode);
672 fc::raw::pack( //
674 obj.db, context,
675 sysio::state_history::augmented_transaction_trace{trace.failed_dtrx_trace, obj.obj.partial}));
676 }
677
678 bool include_partial = obj.obj.partial && !trace.failed_dtrx_trace;
679 fc::raw::pack(ds, include_partial);
680 if (include_partial) {
681 auto& partial = *obj.obj.partial;
684 fc::raw::pack(ds, as_type<uint16_t>(partial.ref_block_num));
685 fc::raw::pack(ds, as_type<uint32_t>(partial.ref_block_prefix));
686 fc::raw::pack(ds, as_type<fc::unsigned_int>(partial.max_net_usage_words));
687 fc::raw::pack(ds, as_type<uint8_t>(partial.max_cpu_usage_ms));
688 fc::raw::pack(ds, as_type<fc::unsigned_int>(partial.delay_sec));
689 fc::raw::pack(ds, as_type<sysio::chain::extensions_type>(partial.transaction_extensions));
690 fc::raw::pack(ds, as_type<std::vector<sysio::chain::signature_type>>(partial.signatures));
691 fc::raw::pack(ds, as_type<std::vector<sysio::chain::bytes>>(partial.context_free_data));
692 }
693
694 return ds;
695}
696
697template <typename ST>
698datastream<ST>&
699operator<<(datastream<ST>& ds,
701 std::pair<uint8_t, bool> context = std::make_pair(sysio::chain::transaction_receipt_header::hard_fail, obj.context);
703 return ds;
704}
705
706template <typename ST>
707datastream<ST>& operator<<(datastream<ST>& ds, const sysio::state_history::get_blocks_result_v0& obj) {
708 fc::raw::pack(ds, obj.head);
710 fc::raw::pack(ds, obj.this_block);
711 fc::raw::pack(ds, obj.prev_block);
715 return ds;
716}
717
718} // namespace fc
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
const generic_index< MultiIndexType > & get_index() const
The table_id_object class tracks the mapping of (scope, code, table) to an opaque identifier.
#define P
Definition dtoa.c:437
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
static const Segment ds(Segment::ds)
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
namespace sysio::chain
Definition authority.cpp:3
datastream< ST > & history_context_serialize_container(datastream< ST > &ds, const chainbase::database &db, const P &context, const std::vector< T > &v)
void history_pack_varuint64(datastream< ST > &ds, uint64_t val)
const T & as_type(const T &x)
std::optional< uint64_t > cap_error_code(const std::optional< uint64_t > &error_code)
void history_pack_big_bytes(datastream< ST > &ds, const sysio::chain::bytes &v)
datastream< ST > & history_serialize_container(datastream< ST > &ds, const chainbase::database &db, const T &v)
datastream< ST > & operator<<(datastream< ST > &s, const sysio::chain::may_not_exist< T > &v)
Definition abi_def.hpp:146
void serialize_secondary_index_data(datastream< ST > &ds, const T &obj)
datastream< ST > & serialize_secondary_index(datastream< ST > &ds, const sysio::chain::table_id_object &context, const T &obj)
checksum_type digest_type
Definition types.hpp:237
std::array< uint128_t, 2 > key256_t
chainbase::shared_multi_index_container< permission_object, indexed_by< ordered_unique< tag< by_id >, member< permission_object, permission_object::id_type, &permission_object::id > >, ordered_unique< tag< by_parent >, composite_key< permission_object, member< permission_object, permission_object::id_type, &permission_object::parent >, member< permission_object, permission_object::id_type, &permission_object::id > > >, ordered_unique< tag< by_owner >, composite_key< permission_object, member< permission_object, account_name, &permission_object::owner >, member< permission_object, permission_name, &permission_object::name > > >, ordered_unique< tag< by_name >, composite_key< permission_object, member< permission_object, permission_name, &permission_object::name >, member< permission_object, permission_object::id_type, &permission_object::id > > > > > permission_index
boost::interprocess::vector< T, allocator< T > > shared_vector
Definition types.hpp:85
#define T(meth, val, expected)
sysio::client::http::http_context context
Definition main.cpp:200
history_context_wrapper< std::decay_t< P >, std::decay_t< T > > make_history_context_wrapper(const chainbase::database &db, const P &context, const T &obj)
history_serial_wrapper< std::decay_t< T > > make_history_serial_wrapper(const chainbase::database &db, const T &obj)
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
const chainbase::database & db
const chainbase::database & db
@ executed
succeed, no error handler executed
Definition block.hpp:14
@ soft_fail
objectively failed (not executed), error handler executed
Definition block.hpp:15
@ hard_fail
objectively failed and error handler objectively failed thus no state change
Definition block.hpp:16
std::optional< block_position > prev_block
Definition types.hpp:108
std::optional< block_position > this_block
Definition types.hpp:107
memcpy((char *) pInfo->slotDescription, s, l)