Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a55c134e
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,发现更多精彩内容 >>
提交
a55c134e
编写于
5月 23, 2018
作者:
A
arhag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
basic validation of blockchain parameters #3343
上级
0f84d7f8
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
52 addition
and
0 deletion
+52
-0
libraries/chain/CMakeLists.txt
libraries/chain/CMakeLists.txt
+1
-0
libraries/chain/chain_config.cpp
libraries/chain/chain_config.cpp
+43
-0
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+1
-0
libraries/chain/include/eosio/chain/chain_config.hpp
libraries/chain/include/eosio/chain/chain_config.hpp
+2
-0
libraries/chain/include/eosio/chain/config.hpp
libraries/chain/include/eosio/chain/config.hpp
+4
-0
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+1
-0
未找到文件。
libraries/chain/CMakeLists.txt
浏览文件 @
a55c134e
...
...
@@ -19,6 +19,7 @@ add_library( eosio_chain
transaction_context.cpp
eosio_contract.cpp
eosio_contract_abi.cpp
chain_config.cpp
# chain_config.cpp
# block_trace.cpp
...
...
libraries/chain/chain_config.cpp
0 → 100644
浏览文件 @
a55c134e
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosio/chain/chain_config.hpp>
#include <eosio/chain/exceptions.hpp>
namespace
eosio
{
namespace
chain
{
void
chain_config
::
validate
()
const
{
EOS_ASSERT
(
target_block_net_usage_pct
<=
config
::
percent_100
,
action_validate_exception
,
"target block net usage percentage cannot exceed 100%"
);
EOS_ASSERT
(
target_block_net_usage_pct
>=
config
::
percent_1
/
10
,
action_validate_exception
,
"target block net usage percentage must be at least 0.1%"
);
EOS_ASSERT
(
target_block_cpu_usage_pct
<=
config
::
percent_100
,
action_validate_exception
,
"target block cpu usage percentage cannot exceed 100%"
);
EOS_ASSERT
(
target_block_cpu_usage_pct
>=
config
::
percent_1
/
10
,
action_validate_exception
,
"target block cpu usage percentage must be at least 0.1%"
);
EOS_ASSERT
(
max_transaction_net_usage
<
max_block_net_usage
,
action_validate_exception
,
"max transaction net usage must be less than max block net usage"
);
EOS_ASSERT
(
max_transaction_cpu_usage
<
max_block_cpu_usage
,
action_validate_exception
,
"max transaction cpu usage must be less than max block cpu usage"
);
EOS_ASSERT
(
base_per_transaction_net_usage
<
max_transaction_net_usage
,
action_validate_exception
,
"base net usage per transaction must be less than the max transaction net usage"
);
EOS_ASSERT
(
(
max_transaction_net_usage
-
base_per_transaction_net_usage
)
>=
config
::
min_net_usage_delta_between_base_and_max_for_trx
,
action_validate_exception
,
"max transaction net usage must be at least ${delta} bytes larger than base net usage per transaction"
,
(
"delta"
,
config
::
min_net_usage_delta_between_base_and_max_for_trx
)
);
EOS_ASSERT
(
context_free_discount_net_usage_den
>
0
,
action_validate_exception
,
"net usage discount ratio for context free data cannot have a 0 denominator"
);
EOS_ASSERT
(
context_free_discount_net_usage_num
<=
context_free_discount_net_usage_den
,
action_validate_exception
,
"net usage discount ratio for context free data cannot exceed 1"
);
EOS_ASSERT
(
min_transaction_cpu_usage
<=
max_transaction_cpu_usage
,
action_validate_exception
,
"min transaction cpu usage cannot exceed max transaction cpu usage"
);
EOS_ASSERT
(
max_transaction_cpu_usage
<
(
max_block_cpu_usage
-
min_transaction_cpu_usage
),
action_validate_exception
,
"max transaction cpu usage must be at less than the difference between the max block cpu usage and the min transaction cpu usage"
);
}
}
}
// namespace eosio::chain
libraries/chain/controller.cpp
浏览文件 @
a55c134e
...
...
@@ -365,6 +365,7 @@ struct controller_impl {
bs
.
block_id
=
head
->
id
;
});
conf
.
genesis
.
initial_configuration
.
validate
();
db
.
create
<
global_property_object
>
([
&
](
auto
&
gpo
){
gpo
.
configuration
=
conf
.
genesis
.
initial_configuration
;
});
...
...
libraries/chain/include/eosio/chain/chain_config.hpp
浏览文件 @
a55c134e
...
...
@@ -38,6 +38,8 @@ struct chain_config {
uint16_t
max_authority_depth
;
///< recursion depth limit for checking if an authority is satisfied
uint32_t
max_generated_transaction_count
;
///< the number of generated transactions per action (TODO: implement?)
void
validate
()
const
;
template
<
typename
Stream
>
friend
Stream
&
operator
<<
(
Stream
&
out
,
const
chain_config
&
c
)
{
return
out
<<
"Max Block Net Usage: "
<<
c
.
max_block_net_usage
<<
", "
...
...
libraries/chain/include/eosio/chain/config.hpp
浏览文件 @
a55c134e
...
...
@@ -81,6 +81,10 @@ const static uint16_t default_max_inline_action_depth = 4;
const
static
uint16_t
default_max_auth_depth
=
6
;
const
static
uint32_t
default_max_gen_trx_count
=
16
;
const
static
uint32_t
min_net_usage_delta_between_base_and_max_for_trx
=
10
*
1024
;
// Should be large enough to allow recovery from badly set blockchain parameters without a hard fork
// (unless net_usage_leeway is set to 0 and so are the net limits of all accounts that can help with resetting blockchain parameters).
const
static
uint32_t
fixed_net_overhead_of_packed_trx
=
16
;
// TODO: is this reasonable?
const
static
uint32_t
fixed_overhead_shared_vector_ram_bytes
=
16
;
///< overhead accounts for fixed portion of size of shared_vector field
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
a55c134e
...
...
@@ -179,6 +179,7 @@ class privileged_api : public context_aware_api {
datastream
<
const
char
*>
ds
(
packed_blockchain_parameters
,
datalen
);
chain
::
chain_config
cfg
;
fc
::
raw
::
unpack
(
ds
,
cfg
);
cfg
.
validate
();
context
.
db
.
modify
(
context
.
control
.
get_global_properties
(),
[
&
](
auto
&
gprops
)
{
gprops
.
configuration
=
cfg
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录