Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4f7a188f
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,发现更多精彩内容 >>
提交
4f7a188f
编写于
4月 27, 2018
作者:
K
Khaled Al-Hassanieh
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'slim' of github.com:EOSIO/eos into slim
上级
0eca825f
342738c2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
6 deletion
+46
-6
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+39
-2
libraries/chain/include/eosio/chain/authority.hpp
libraries/chain/include/eosio/chain/authority.hpp
+4
-0
libraries/chain/include/eosio/chain/config.hpp
libraries/chain/include/eosio/chain/config.hpp
+0
-3
unittests/special_accounts_tests.cpp
unittests/special_accounts_tests.cpp
+3
-1
未找到文件。
libraries/chain/controller.cpp
浏览文件 @
4f7a188f
...
@@ -490,7 +490,10 @@ struct controller_impl {
...
@@ -490,7 +490,10 @@ struct controller_impl {
transaction_context
trx_context
(
self
,
trx
->
trx
,
trx
->
id
);
transaction_context
trx_context
(
self
,
trx
->
trx
,
trx
->
id
);
trace
=
trx_context
.
trace
;
trace
=
trx_context
.
trace
;
auto
required_delay
=
limit_delay
(
authorization
.
check_authorization
(
trx
->
trx
.
actions
,
trx
->
recover_keys
()
)
);
fc
::
microseconds
required_delay
(
0
);
if
(
!
implicit
)
{
required_delay
=
limit_delay
(
authorization
.
check_authorization
(
trx
->
trx
.
actions
,
trx
->
recover_keys
()
)
);
}
trx_context
.
delay
=
fc
::
seconds
(
trx
->
trx
.
delay_sec
);
trx_context
.
delay
=
fc
::
seconds
(
trx
->
trx
.
delay_sec
);
EOS_ASSERT
(
trx_context
.
delay
>=
required_delay
,
transaction_exception
,
EOS_ASSERT
(
trx_context
.
delay
>=
required_delay
,
transaction_exception
,
"authorization imposes a delay (${required_delay} sec) greater than the delay specified in transaction header (${specified_delay} sec)"
,
"authorization imposes a delay (${required_delay} sec) greater than the delay specified in transaction header (${specified_delay} sec)"
,
...
@@ -761,7 +764,41 @@ struct controller_impl {
...
@@ -761,7 +764,41 @@ struct controller_impl {
void
update_producers_authority
()
{
void
update_producers_authority
()
{
const
auto
&
producers
=
pending
->
_pending_block_state
->
active_schedule
.
producers
;
const
auto
&
producers
=
pending
->
_pending_block_state
->
active_schedule
.
producers
;
//TODO: Complete implementation
auto
update_permission
=
[
&
](
auto
&
permission
,
auto
threshold
)
{
auto
auth
=
authority
(
threshold
,
{},
{});
for
(
auto
&
p
:
producers
)
{
auth
.
accounts
.
push_back
({{
p
.
producer_name
,
config
::
active_name
},
1
});
}
if
(
static_cast
<
authority
>
(
permission
.
auth
)
!=
auth
)
{
// TODO: use a more efficient way to check that authority has not changed
db
.
modify
(
permission
,
[
&
](
auto
&
po
)
{
po
.
auth
=
auth
;
});
}
};
uint32_t
num_producers
=
producers
.
size
();
auto
calculate_threshold
=
[
=
](
uint32_t
numerator
,
uint32_t
denominator
)
{
return
(
(
num_producers
*
numerator
)
/
denominator
)
+
1
;
};
update_permission
(
authorization
.
get_permission
({
config
::
producers_account_name
,
config
::
active_name
}),
calculate_threshold
(
2
,
3
)
/* more than two-thirds */
);
update_permission
(
authorization
.
get_permission
({
config
::
producers_account_name
,
config
::
majority_producers_permission_name
}),
calculate_threshold
(
1
,
2
)
/* more than one-half */
);
update_permission
(
authorization
.
get_permission
({
config
::
producers_account_name
,
config
::
minority_producers_permission_name
}),
calculate_threshold
(
1
,
3
)
/* more than one-third */
);
update_permission
(
authorization
.
get_permission
({
config
::
producers_account_name
,
config
::
any_producer_permission_name
}),
1
);
//TODO: Add tests
}
}
void
create_block_summary
(
const
block_id_type
&
id
)
{
void
create_block_summary
(
const
block_id_type
&
id
)
{
...
...
libraries/chain/include/eosio/chain/authority.hpp
浏览文件 @
4f7a188f
...
@@ -56,6 +56,10 @@ struct authority {
...
@@ -56,6 +56,10 @@ struct authority {
friend
bool
operator
==
(
const
authority
&
lhs
,
const
authority
&
rhs
)
{
friend
bool
operator
==
(
const
authority
&
lhs
,
const
authority
&
rhs
)
{
return
tie
(
lhs
.
threshold
,
lhs
.
delay_sec
,
lhs
.
keys
,
lhs
.
accounts
)
==
tie
(
rhs
.
threshold
,
rhs
.
delay_sec
,
rhs
.
keys
,
rhs
.
accounts
);
return
tie
(
lhs
.
threshold
,
lhs
.
delay_sec
,
lhs
.
keys
,
lhs
.
accounts
)
==
tie
(
rhs
.
threshold
,
rhs
.
delay_sec
,
rhs
.
keys
,
rhs
.
accounts
);
}
}
friend
bool
operator
!=
(
const
authority
&
lhs
,
const
authority
&
rhs
)
{
return
tie
(
lhs
.
threshold
,
lhs
.
delay_sec
,
lhs
.
keys
,
lhs
.
accounts
)
!=
tie
(
rhs
.
threshold
,
rhs
.
delay_sec
,
rhs
.
keys
,
rhs
.
accounts
);
}
};
};
...
...
libraries/chain/include/eosio/chain/config.hpp
浏览文件 @
4f7a188f
...
@@ -25,7 +25,6 @@ const static uint64_t majority_producers_permission_name = N(prod.major); // gre
...
@@ -25,7 +25,6 @@ const static uint64_t majority_producers_permission_name = N(prod.major); // gre
const
static
uint64_t
minority_producers_permission_name
=
N
(
prod
.
minor
);
// greater than 1/3 of producers needed to authorize0
const
static
uint64_t
minority_producers_permission_name
=
N
(
prod
.
minor
);
// greater than 1/3 of producers needed to authorize0
const
static
uint64_t
any_producer_permission_name
=
N
(
prod
.
any
);
// any producer needed to authorize
const
static
uint64_t
any_producer_permission_name
=
N
(
prod
.
any
);
// any producer needed to authorize
const
static
uint64_t
eosio_auth_scope
=
N
(
eosio
.
auth
);
const
static
uint64_t
eosio_auth_scope
=
N
(
eosio
.
auth
);
const
static
uint64_t
eosio_all_scope
=
N
(
eosio
.
all
);
const
static
uint64_t
eosio_all_scope
=
N
(
eosio
.
all
);
...
@@ -66,8 +65,6 @@ const static uint32_t default_max_gen_trx_count = 16; ///< the number of
...
@@ -66,8 +65,6 @@ const static uint32_t default_max_gen_trx_count = 16; ///< the number of
const
static
uint32_t
default_max_trx_delay
=
45
*
24
*
3600
;
// 45 days
const
static
uint32_t
default_max_trx_delay
=
45
*
24
*
3600
;
// 45 days
const
static
uint32_t
rate_limiting_precision
=
1000
*
1000
;
const
static
uint32_t
rate_limiting_precision
=
1000
*
1000
;
const
static
uint32_t
producers_authority_threshold_pct
=
66
*
config
::
percent_1
;
const
static
uint16_t
max_recursion_depth
=
6
;
const
static
uint16_t
max_recursion_depth
=
6
;
const
static
uint32_t
default_base_per_transaction_net_usage
=
48
;
// 48 bytes minimum (for misc overhead)
const
static
uint32_t
default_base_per_transaction_net_usage
=
48
;
// 48 bytes minimum (for misc overhead)
...
...
unittests/special_accounts_tests.cpp
浏览文件 @
4f7a188f
...
@@ -55,7 +55,7 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester)
...
@@ -55,7 +55,7 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester)
const
auto
&
active_producers
=
control
->
head_block_state
()
->
active_schedule
;
const
auto
&
active_producers
=
control
->
head_block_state
()
->
active_schedule
;
const
auto
&
producers_active_authority
=
chain1_db
.
get
<
permission_object
,
by_owner
>
(
boost
::
make_tuple
(
config
::
producers_account_name
,
config
::
active_name
));
const
auto
&
producers_active_authority
=
chain1_db
.
get
<
permission_object
,
by_owner
>
(
boost
::
make_tuple
(
config
::
producers_account_name
,
config
::
active_name
));
auto
expected_threshold
=
EOS_PERCENT_CEIL
(
active_producers
.
producers
.
size
(),
config
::
producers_authority_threshold_pct
)
;
auto
expected_threshold
=
(
active_producers
.
producers
.
size
()
*
2
)
/
3
+
1
;
BOOST_CHECK_EQUAL
(
producers_active_authority
.
auth
.
threshold
,
expected_threshold
);
BOOST_CHECK_EQUAL
(
producers_active_authority
.
auth
.
threshold
,
expected_threshold
);
BOOST_CHECK_EQUAL
(
producers_active_authority
.
auth
.
accounts
.
size
(),
active_producers
.
producers
.
size
());
BOOST_CHECK_EQUAL
(
producers_active_authority
.
auth
.
accounts
.
size
(),
active_producers
.
producers
.
size
());
BOOST_CHECK_EQUAL
(
producers_active_authority
.
auth
.
keys
.
size
(),
0
);
BOOST_CHECK_EQUAL
(
producers_active_authority
.
auth
.
keys
.
size
(),
0
);
...
@@ -79,6 +79,8 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester)
...
@@ -79,6 +79,8 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester)
BOOST_CHECK_EQUAL
(
producers_owner_authority
.
auth
.
accounts
.
size
(),
0
);
BOOST_CHECK_EQUAL
(
producers_owner_authority
.
auth
.
accounts
.
size
(),
0
);
BOOST_CHECK_EQUAL
(
producers_owner_authority
.
auth
.
keys
.
size
(),
0
);
BOOST_CHECK_EQUAL
(
producers_owner_authority
.
auth
.
keys
.
size
(),
0
);
//TODO: Add checks on the other permissions of the producers account
}
FC_LOG_AND_RETHROW
()
}
}
FC_LOG_AND_RETHROW
()
}
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE_END
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录