Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4ac9898f
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ac9898f
编写于
5月 23, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chain_plugin parameter --contracts-console added #3339
上级
2ca45172
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
90 addition
and
53 deletion
+90
-53
libraries/chain/apply_context.cpp
libraries/chain/apply_context.cpp
+13
-13
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+4
-0
libraries/chain/include/eosio/chain/controller.hpp
libraries/chain/include/eosio/chain/controller.hpp
+3
-0
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+65
-39
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+1
-0
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+4
-1
未找到文件。
libraries/chain/apply_context.cpp
浏览文件 @
4ac9898f
...
@@ -16,18 +16,16 @@ using boost::container::flat_set;
...
@@ -16,18 +16,16 @@ using boost::container::flat_set;
namespace
eosio
{
namespace
chain
{
namespace
eosio
{
namespace
chain
{
static
inline
void
print_debug
(
account_name
receiver
,
const
action_trace
&
ar
)
{
static
inline
void
print_debug
(
account_name
receiver
,
const
action_trace
&
ar
)
{
if
(
fc
::
logger
::
get
(
DEFAULT_LOGGER
).
is_enabled
(
fc
::
log_level
::
debug
))
{
if
(
!
ar
.
console
.
empty
())
{
if
(
!
ar
.
console
.
empty
())
{
auto
prefix
=
fc
::
format_string
(
auto
prefix
=
fc
::
format_string
(
"
\n
[(${a},${n})->${r}]"
,
"
\n
[(${a},${n})->${r}]"
,
fc
::
mutable_variant_object
()
fc
::
mutable_variant_object
()
(
"a"
,
ar
.
act
.
account
)
(
"a"
,
ar
.
act
.
account
)
(
"n"
,
ar
.
act
.
name
)
(
"n"
,
ar
.
act
.
name
)
(
"r"
,
receiver
));
(
"r"
,
receiver
));
dlog
(
prefix
+
": CONSOLE OUTPUT BEGIN =====================
\n
"
dlog
(
prefix
+
": CONSOLE OUTPUT BEGIN =====================
\n
"
+
ar
.
console
+
ar
.
console
+
prefix
+
": CONSOLE OUTPUT END ====================="
);
+
prefix
+
": CONSOLE OUTPUT END ====================="
);
}
}
}
}
}
...
@@ -75,7 +73,9 @@ action_trace apply_context::exec_one()
...
@@ -75,7 +73,9 @@ action_trace apply_context::exec_one()
trx_context
.
executed
.
emplace_back
(
move
(
r
)
);
trx_context
.
executed
.
emplace_back
(
move
(
r
)
);
print_debug
(
receiver
,
t
);
if
(
control
.
contracts_console
()
)
{
print_debug
(
receiver
,
t
);
}
reset_console
();
reset_console
();
...
...
libraries/chain/controller.cpp
浏览文件 @
4ac9898f
...
@@ -1283,6 +1283,10 @@ bool controller::skip_auth_check()const {
...
@@ -1283,6 +1283,10 @@ bool controller::skip_auth_check()const {
return
my
->
replaying_irreversible
&&
!
my
->
conf
.
force_all_checks
;
return
my
->
replaying_irreversible
&&
!
my
->
conf
.
force_all_checks
;
}
}
bool
controller
::
contracts_console
()
const
{
return
my
->
conf
.
contracts_console
;
}
const
apply_handler
*
controller
::
find_apply_handler
(
account_name
receiver
,
account_name
scope
,
action_name
act
)
const
const
apply_handler
*
controller
::
find_apply_handler
(
account_name
receiver
,
account_name
scope
,
action_name
act
)
const
{
{
auto
native_handler_scope
=
my
->
apply_handlers
.
find
(
receiver
);
auto
native_handler_scope
=
my
->
apply_handlers
.
find
(
receiver
);
...
...
libraries/chain/include/eosio/chain/controller.hpp
浏览文件 @
4ac9898f
...
@@ -42,6 +42,7 @@ namespace eosio { namespace chain {
...
@@ -42,6 +42,7 @@ namespace eosio { namespace chain {
uint64_t
shared_memory_size
=
chain
::
config
::
default_shared_memory_size
;
uint64_t
shared_memory_size
=
chain
::
config
::
default_shared_memory_size
;
bool
read_only
=
false
;
bool
read_only
=
false
;
bool
force_all_checks
=
false
;
bool
force_all_checks
=
false
;
bool
contracts_console
=
false
;
genesis_state
genesis
;
genesis_state
genesis
;
wasm_interface
::
vm_type
wasm_runtime
=
chain
::
config
::
default_wasm_runtime
;
wasm_interface
::
vm_type
wasm_runtime
=
chain
::
config
::
default_wasm_runtime
;
...
@@ -151,6 +152,7 @@ namespace eosio { namespace chain {
...
@@ -151,6 +152,7 @@ namespace eosio { namespace chain {
bool
skip_auth_check
()
const
;
bool
skip_auth_check
()
const
;
bool
contracts_console
()
const
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block_header
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block_header
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block
;
...
@@ -206,6 +208,7 @@ FC_REFLECT( eosio::chain::controller::config,
...
@@ -206,6 +208,7 @@ FC_REFLECT( eosio::chain::controller::config,
(
reversible_cache_size
)
(
reversible_cache_size
)
(
shared_memory_dir
)(
shared_memory_size
)(
read_only
)
(
shared_memory_dir
)(
shared_memory_size
)(
read_only
)
(
force_all_checks
)
(
force_all_checks
)
(
contracts_console
)
(
genesis
)
(
genesis
)
(
wasm_runtime
)
(
wasm_runtime
)
)
)
libraries/chain/wasm_interface.cpp
浏览文件 @
4ac9898f
...
@@ -977,68 +977,85 @@ class action_api : public context_aware_api {
...
@@ -977,68 +977,85 @@ class action_api : public context_aware_api {
class
console_api
:
public
context_aware_api
{
class
console_api
:
public
context_aware_api
{
public:
public:
console_api
(
apply_context
&
ctx
)
console_api
(
apply_context
&
ctx
)
:
context_aware_api
(
ctx
,
true
){}
:
context_aware_api
(
ctx
,
true
)
,
ignore
(
!
ctx
.
control
.
contracts_console
())
{}
// Kept as intrinsic rather than implementing on WASM side (using prints_l and strlen) because strlen is faster on native side.
// Kept as intrinsic rather than implementing on WASM side (using prints_l and strlen) because strlen is faster on native side.
void
prints
(
null_terminated_ptr
str
)
{
void
prints
(
null_terminated_ptr
str
)
{
context
.
console_append
<
const
char
*>
(
str
);
if
(
!
ignore
)
{
context
.
console_append
<
const
char
*>
(
str
);
}
}
}
void
prints_l
(
array_ptr
<
const
char
>
str
,
size_t
str_len
)
{
void
prints_l
(
array_ptr
<
const
char
>
str
,
size_t
str_len
)
{
context
.
console_append
(
string
(
str
,
str_len
));
if
(
!
ignore
)
{
context
.
console_append
(
string
(
str
,
str_len
));
}
}
}
void
printi
(
int64_t
val
)
{
void
printi
(
int64_t
val
)
{
context
.
console_append
(
val
);
if
(
!
ignore
)
{
context
.
console_append
(
val
);
}
}
}
void
printui
(
uint64_t
val
)
{
void
printui
(
uint64_t
val
)
{
context
.
console_append
(
val
);
if
(
!
ignore
)
{
context
.
console_append
(
val
);
}
}
}
void
printi128
(
const
__int128
&
val
)
{
void
printi128
(
const
__int128
&
val
)
{
bool
is_negative
=
(
val
<
0
);
if
(
!
ignore
)
{
unsigned
__int128
val_magnitude
;
bool
is_negative
=
(
val
<
0
);
unsigned
__int128
val_magnitude
;
if
(
is_negative
)
if
(
is_negative
)
val_magnitude
=
static_cast
<
unsigned
__int128
>
(
-
val
);
// Works even if val is at the lowest possible value of a int128_t
val_magnitude
=
static_cast
<
unsigned
__int128
>
(
-
val
);
// Works even if val is at the lowest possible value of a int128_t
else
else
val_magnitude
=
static_cast
<
unsigned
__int128
>
(
val
);
val_magnitude
=
static_cast
<
unsigned
__int128
>
(
val
);
fc
::
uint128_t
v
(
val_magnitude
>>
64
,
static_cast
<
uint64_t
>
(
val_magnitude
)
);
fc
::
uint128_t
v
(
val_magnitude
>>
64
,
static_cast
<
uint64_t
>
(
val_magnitude
)
);
if
(
is_negative
)
{
if
(
is_negative
)
{
context
.
console_append
(
"-"
);
context
.
console_append
(
"-"
);
}
}
context
.
console_append
(
fc
::
variant
(
v
).
get_string
());
context
.
console_append
(
fc
::
variant
(
v
).
get_string
());
}
}
}
void
printui128
(
const
unsigned
__int128
&
val
)
{
void
printui128
(
const
unsigned
__int128
&
val
)
{
fc
::
uint128_t
v
(
val
>>
64
,
static_cast
<
uint64_t
>
(
val
)
);
if
(
!
ignore
)
{
context
.
console_append
(
fc
::
variant
(
v
).
get_string
());
fc
::
uint128_t
v
(
val
>>
64
,
static_cast
<
uint64_t
>
(
val
)
);
context
.
console_append
(
fc
::
variant
(
v
).
get_string
());
}
}
}
void
printsf
(
float
val
)
{
void
printsf
(
float
val
)
{
// Assumes float representation on native side is the same as on the WASM side
if
(
!
ignore
)
{
auto
&
console
=
context
.
get_console_stream
();
// Assumes float representation on native side is the same as on the WASM side
auto
orig_prec
=
console
.
precision
();
auto
&
console
=
context
.
get_console_stream
();
auto
orig_prec
=
console
.
precision
();
console
.
precision
(
std
::
numeric_limits
<
float
>::
digits10
);
console
.
precision
(
std
::
numeric_limits
<
float
>::
digits10
);
context
.
console_append
(
val
);
context
.
console_append
(
val
);
console
.
precision
(
orig_prec
);
console
.
precision
(
orig_prec
);
}
}
}
void
printdf
(
double
val
)
{
void
printdf
(
double
val
)
{
// Assumes double representation on native side is the same as on the WASM side
if
(
!
ignore
)
{
auto
&
console
=
context
.
get_console_stream
();
// Assumes double representation on native side is the same as on the WASM side
auto
orig_prec
=
console
.
precision
();
auto
&
console
=
context
.
get_console_stream
();
auto
orig_prec
=
console
.
precision
();
console
.
precision
(
std
::
numeric_limits
<
double
>::
digits10
);
console
.
precision
(
std
::
numeric_limits
<
double
>::
digits10
);
context
.
console_append
(
val
);
context
.
console_append
(
val
);
console
.
precision
(
orig_prec
);
console
.
precision
(
orig_prec
);
}
}
}
void
printqf
(
const
float128_t
&
val
)
{
void
printqf
(
const
float128_t
&
val
)
{
...
@@ -1054,25 +1071,34 @@ class console_api : public context_aware_api {
...
@@ -1054,25 +1071,34 @@ class console_api : public context_aware_api {
* having to deal with long doubles at all.
* having to deal with long doubles at all.
*/
*/
auto
&
console
=
context
.
get_console_stream
();
if
(
!
ignore
)
{
auto
orig_prec
=
console
.
precision
();
auto
&
console
=
context
.
get_console_stream
();
auto
orig_prec
=
console
.
precision
();
console
.
precision
(
std
::
numeric_limits
<
long
double
>::
digits10
);
console
.
precision
(
std
::
numeric_limits
<
long
double
>::
digits10
);
extFloat80_t
val_approx
;
extFloat80_t
val_approx
;
f128M_to_extF80M
(
&
val
,
&
val_approx
);
f128M_to_extF80M
(
&
val
,
&
val_approx
);
context
.
console_append
(
*
(
long
double
*
)(
&
val_approx
)
);
context
.
console_append
(
*
(
long
double
*
)(
&
val_approx
)
);
console
.
precision
(
orig_prec
);
console
.
precision
(
orig_prec
);
}
}
}
void
printn
(
const
name
&
value
)
{
void
printn
(
const
name
&
value
)
{
context
.
console_append
(
value
.
to_string
());
if
(
!
ignore
)
{
context
.
console_append
(
value
.
to_string
());
}
}
}
void
printhex
(
array_ptr
<
const
char
>
data
,
size_t
data_len
)
{
void
printhex
(
array_ptr
<
const
char
>
data
,
size_t
data_len
)
{
context
.
console_append
(
fc
::
to_hex
(
data
,
data_len
));
if
(
!
ignore
)
{
context
.
console_append
(
fc
::
to_hex
(
data
,
data_len
));
}
}
}
private:
bool
ignore
;
};
};
#define DB_API_METHOD_WRAPPERS_SIMPLE_SECONDARY(IDX, TYPE)\
#define DB_API_METHOD_WRAPPERS_SIMPLE_SECONDARY(IDX, TYPE)\
...
...
libraries/testing/tester.cpp
浏览文件 @
4ac9898f
...
@@ -41,6 +41,7 @@ namespace eosio { namespace testing {
...
@@ -41,6 +41,7 @@ namespace eosio { namespace testing {
cfg
.
shared_memory_dir
=
tempdir
.
path
()
/
"shared"
;
cfg
.
shared_memory_dir
=
tempdir
.
path
()
/
"shared"
;
cfg
.
shared_memory_size
=
1024
*
1024
*
8
;
cfg
.
shared_memory_size
=
1024
*
1024
*
8
;
cfg
.
reversible_cache_size
=
1024
*
1024
*
8
;
cfg
.
reversible_cache_size
=
1024
*
1024
*
8
;
cfg
.
contracts_console
=
true
;
cfg
.
genesis
.
initial_timestamp
=
fc
::
time_point
::
from_iso_string
(
"2020-01-01T00:00:00.000"
);
cfg
.
genesis
.
initial_timestamp
=
fc
::
time_point
::
from_iso_string
(
"2020-01-01T00:00:00.000"
);
cfg
.
genesis
.
initial_key
=
get_public_key
(
config
::
system_account_name
,
"active"
);
cfg
.
genesis
.
initial_key
=
get_public_key
(
config
::
system_account_name
,
"active"
);
...
...
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
4ac9898f
...
@@ -139,6 +139,8 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
...
@@ -139,6 +139,8 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
"clear chain database, recover as many blocks as possible from the block log, and then replay those blocks"
)
"clear chain database, recover as many blocks as possible from the block log, and then replay those blocks"
)
(
"resync-blockchain"
,
bpo
::
bool_switch
()
->
default_value
(
false
),
(
"resync-blockchain"
,
bpo
::
bool_switch
()
->
default_value
(
false
),
"clear chain database and block log"
)
"clear chain database and block log"
)
(
"contracts-console"
,
bpo
::
bool_switch
()
->
default_value
(
false
),
"print contract's output to console"
)
;
;
}
}
...
@@ -201,7 +203,8 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
...
@@ -201,7 +203,8 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
if
(
my
->
wasm_runtime
)
if
(
my
->
wasm_runtime
)
my
->
chain_config
->
wasm_runtime
=
*
my
->
wasm_runtime
;
my
->
chain_config
->
wasm_runtime
=
*
my
->
wasm_runtime
;
my
->
chain_config
->
force_all_checks
=
options
.
at
(
"force-all-checks"
).
as
<
bool
>
();
my
->
chain_config
->
force_all_checks
=
options
.
at
(
"force-all-checks"
).
as
<
bool
>
();
my
->
chain_config
->
contracts_console
=
options
.
at
(
"contracts-console"
).
as
<
bool
>
();
if
(
options
.
at
(
"resync-blockchain"
).
as
<
bool
>
()
)
{
if
(
options
.
at
(
"resync-blockchain"
).
as
<
bool
>
()
)
{
ilog
(
"Resync requested: wiping database and blocks"
);
ilog
(
"Resync requested: wiping database and blocks"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录