Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
e01fcbd6
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,发现更多精彩内容 >>
提交
e01fcbd6
编写于
10月 06, 2017
作者:
B
Brian Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added plumbing to pass in the execution time for applying a transation.
上级
af37612e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
14 deletion
+36
-14
libraries/chain/chain_controller.cpp
libraries/chain/chain_controller.cpp
+15
-5
libraries/chain/include/eos/chain/chain_controller.hpp
libraries/chain/include/eos/chain/chain_controller.hpp
+11
-2
libraries/chain/include/eos/chain/wasm_interface.hpp
libraries/chain/include/eos/chain/wasm_interface.hpp
+2
-1
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+8
-6
未找到文件。
libraries/chain/chain_controller.cpp
浏览文件 @
e01fcbd6
...
...
@@ -956,7 +956,13 @@ void chain_controller::apply_message(apply_context& context)
const
auto
&
recipient
=
_db
.
get
<
account_object
,
by_name
>
(
context
.
code
);
if
(
recipient
.
code
.
size
())
{
//idump((context.code)(context.msg.type));
wasm_interface
::
get
().
apply
(
context
);
const
uint32_t
execution_time
=
_skip_flags
|
received_block
?
_rcvd_block_trans_execution_time
:
_skip_flags
|
created_block
?
_create_block_trans_execution_time
:
_trans_execution_time
;
wasm_interface
::
get
().
apply
(
context
,
execution_time
);
}
}
FC_CAPTURE_AND_RETHROW
((
context
.
msg
))
}
...
...
@@ -1158,7 +1164,7 @@ void chain_controller::initialize_chain(chain_initializer_interface& starter)
MessageOutput
output
;
ProcessedTransaction
trx
;
/// dummy tranaction required for scope validation
std
::
sort
(
trx
.
scope
.
begin
(),
trx
.
scope
.
end
()
);
with_skip_flags
(
skip_scope_check
|
skip_transaction_signatures
|
skip_authority_check
,
[
&
](){
with_skip_flags
(
skip_scope_check
|
skip_transaction_signatures
|
skip_authority_check
|
received_block
,
[
&
](){
process_message
(
trx
,
m
.
code
,
m
,
output
);
});
});
...
...
@@ -1167,8 +1173,11 @@ void chain_controller::initialize_chain(chain_initializer_interface& starter)
}
FC_CAPTURE_AND_RETHROW
()
}
chain_controller
::
chain_controller
(
database
&
database
,
fork_database
&
fork_db
,
block_log
&
blocklog
,
chain_initializer_interface
&
starter
,
unique_ptr
<
chain_administration_interface
>
admin
)
:
_db
(
database
),
_fork_db
(
fork_db
),
_block_log
(
blocklog
),
_admin
(
std
::
move
(
admin
))
{
chain_initializer_interface
&
starter
,
unique_ptr
<
chain_administration_interface
>
admin
,
uint32_t
trans_execution_time
,
uint32_t
rcvd_block_trans_execution_time
,
uint32_t
create_block_trans_execution_time
)
:
_db
(
database
),
_fork_db
(
fork_db
),
_block_log
(
blocklog
),
_admin
(
std
::
move
(
admin
)),
_trans_execution_time
(
trans_execution_time
),
_rcvd_block_trans_execution_time
(
rcvd_block_trans_execution_time
),
_create_block_trans_execution_time
(
create_block_trans_execution_time
)
{
initialize_indexes
();
starter
.
register_types
(
*
this
,
_db
);
...
...
@@ -1213,7 +1222,8 @@ void chain_controller::replay() {
skip_transaction_dupe_check
|
skip_tapos_check
|
skip_producer_schedule_check
|
skip_authority_check
);
skip_authority_check
|
received_block
);
}
auto
end
=
fc
::
time_point
::
now
();
ilog
(
"Done replaying ${n} blocks, elapsed time: ${t} sec"
,
...
...
libraries/chain/include/eos/chain/chain_controller.hpp
浏览文件 @
e01fcbd6
...
...
@@ -56,7 +56,9 @@ namespace eos { namespace chain {
class
chain_controller
{
public:
chain_controller
(
database
&
database
,
fork_database
&
fork_db
,
block_log
&
blocklog
,
chain_initializer_interface
&
starter
,
unique_ptr
<
chain_administration_interface
>
admin
);
chain_initializer_interface
&
starter
,
unique_ptr
<
chain_administration_interface
>
admin
,
uint32_t
trans_execution_time
,
uint32_t
rcvd_block_trans_execution_time
,
uint32_t
create_block_trans_execution_time
);
chain_controller
(
chain_controller
&&
)
=
default
;
~
chain_controller
();
...
...
@@ -105,7 +107,10 @@ namespace eos { namespace chain {
skip_producer_schedule_check
=
1
<<
10
,
///< used while reindexing
skip_validate
=
1
<<
11
,
///< used prior to checkpoint, skips validate() call on transaction
skip_scope_check
=
1
<<
12
,
///< used to skip checks for proper scope
skip_output_check
=
1
<<
13
///< used to skip checks for outputs in block exactly matching those created from apply
skip_output_check
=
1
<<
13
,
///< used to skip checks for outputs in block exactly matching those created from apply
pushed_transaction
=
1
<<
14
,
///< used to indicate that the origination of the call was from a push_transaction, to determine time allotment
created_block
=
1
<<
15
,
///< used to indicate that the origination of the call was for creating a block, to determine time allotment
received_block
=
1
<<
16
///< used to indicate that the origination of the call was for a received block, to determine time allotment
};
/**
...
...
@@ -379,6 +384,10 @@ namespace eos { namespace chain {
bool
_currently_applying_block
=
false
;
uint64_t
_skip_flags
=
0
;
const
uint32_t
_trans_execution_time
;
const
uint32_t
_rcvd_block_trans_execution_time
;
const
uint32_t
_create_block_trans_execution_time
;
flat_map
<
uint32_t
,
block_id_type
>
_checkpoints
;
typedef
pair
<
AccountName
,
types
::
Name
>
handler_key
;
...
...
libraries/chain/include/eos/chain/wasm_interface.hpp
浏览文件 @
e01fcbd6
...
...
@@ -32,7 +32,7 @@ class wasm_interface {
static
wasm_interface
&
get
();
void
init
(
apply_context
&
c
);
void
apply
(
apply_context
&
c
);
void
apply
(
apply_context
&
c
,
uint32_t
execution_time
);
void
validate
(
apply_context
&
c
);
void
precondition
(
apply_context
&
c
);
...
...
@@ -47,6 +47,7 @@ class wasm_interface {
ModuleState
*
current_state
=
nullptr
;
wasm_memory
*
current_memory_management
=
nullptr
;
uint32_t
checktime_limit
=
0
;
private:
void
load
(
const
AccountName
&
name
,
const
chainbase
::
database
&
db
);
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
e01fcbd6
...
...
@@ -46,16 +46,16 @@ namespace eos { namespace chain {
const
int
CHECKTIME_LIMIT
=
18000
;
#endif
void
checktime
(
int64_t
duration
)
void
checktime
(
int64_t
duration
,
uint32_t
checktime_limit
)
{
if
(
duration
>
CHECKTIME_LIMIT
)
{
if
(
duration
>
checktime_limit
)
{
wlog
(
"checktime called ${d}"
,
(
"d"
,
duration
));
throw
checktime_exceeded
();
}
}
DEFINE_INTRINSIC_FUNCTION0
(
env
,
checktime
,
checktime
,
none
)
{
checktime
(
wasm_interface
::
get
().
current_execution_time
());
checktime
(
wasm_interface
::
get
().
current_execution_time
()
,
wasm_interface
::
get
().
checktime_limit
);
}
template
<
typename
Function
,
typename
KeyType
,
int
numberOfKeys
>
...
...
@@ -350,7 +350,7 @@ DEFINE_INTRINSIC_FUNCTION1(env,sbrk,sbrk,i32,i32,num_bytes) {
FC_ASSERT
(
num_bytes
>=
0
,
"sbrk can only allocate memory, not reduce"
);
FC_ASSERT
(
wasm
.
current_memory_management
!=
nullptr
,
"sbrk can only be called during the scope of wasm_interface::vm_call"
);
U32
previous_bytes_allocated
=
wasm
.
current_memory_management
->
sbrk
(
num_bytes
);
checktime
(
wasm
.
current_execution_time
());
checktime
(
wasm
.
current_execution_time
()
,
wasm_interface
::
get
().
checktime_limit
);
return
previous_bytes_allocated
;
}
...
...
@@ -615,7 +615,7 @@ DEFINE_INTRINSIC_FUNCTION1(env,free,free,none,i32,ptr) {
Runtime
::
invokeFunction
(
call
,
args
);
wasm_memory_mgmt
.
reset
();
checktime
(
current_execution_time
());
checktime
(
current_execution_time
()
,
checktime_limit
);
}
catch
(
const
Runtime
::
Exception
&
e
)
{
edump
((
std
::
string
(
describeExceptionCause
(
e
.
cause
))));
edump
((
e
.
callStack
));
...
...
@@ -673,11 +673,12 @@ DEFINE_INTRINSIC_FUNCTION1(env,free,free,none,i32,ptr) {
}
FC_CAPTURE_AND_RETHROW
()
}
void
wasm_interface
::
apply
(
apply_context
&
c
)
{
void
wasm_interface
::
apply
(
apply_context
&
c
,
uint32_t
execution_time
)
{
try
{
current_validate_context
=
&
c
;
current_precondition_context
=
&
c
;
current_apply_context
=
&
c
;
checktime_limit
=
execution_time
;
load
(
c
.
code
,
c
.
db
);
vm_apply
();
...
...
@@ -689,6 +690,7 @@ DEFINE_INTRINSIC_FUNCTION1(env,free,free,none,i32,ptr) {
current_validate_context
=
&
c
;
current_precondition_context
=
&
c
;
current_apply_context
=
&
c
;
checktime_limit
=
CHECKTIME_LIMIT
;
load
(
c
.
code
,
c
.
db
);
vm_onInit
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录