Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
8d0417fd
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,发现更多精彩内容 >>
提交
8d0417fd
编写于
5月 30, 2018
作者:
K
Khaled Al-Hassanieh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove producer deactivation code and testing
上级
f7a17ee8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
98 deletion
+11
-98
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+8
-10
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+1
-4
contracts/eosio.system/producer_pay.cpp
contracts/eosio.system/producer_pay.cpp
+0
-1
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+0
-30
unittests/eosio.system_tests.cpp
unittests/eosio.system_tests.cpp
+2
-53
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
8d0417fd
...
...
@@ -270,16 +270,14 @@
"name": "producer_info",
"base": "",
"fields": [
{"name":"owner", "type":"account_name"},
{"name":"total_votes", "type":"float64"},
{"name":"producer_key", "type":"public_key"},
{"name":"is_active", "type":"bool"},
{"name":"url", "type":"string"},
{"name":"unpaid_blocks", "type":"uint32"},
{"name":"last_claim_time", "type":"uint64"},
{"name":"location", "type":"uint16"},
{"name":"time_became_active", "type":"uint32"},
{"name":"last_produced_block_time", "type":"uint32"}
{"name":"owner", "type":"account_name"},
{"name":"total_votes", "type":"float64"},
{"name":"producer_key", "type":"public_key"},
{"name":"is_active", "type":"bool"},
{"name":"url", "type":"string"},
{"name":"unpaid_blocks", "type":"uint32"},
{"name":"last_claim_time", "type":"uint64"},
{"name":"location", "type":"uint16"}
]
},{
"name": "regproducer",
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
8d0417fd
...
...
@@ -78,8 +78,6 @@ namespace eosiosystem {
uint32_t
unpaid_blocks
=
0
;
uint64_t
last_claim_time
=
0
;
uint16_t
location
=
0
;
block_timestamp
time_became_active
;
block_timestamp
last_produced_block_time
;
uint64_t
primary_key
()
const
{
return
owner
;
}
double
by_votes
()
const
{
return
is_active
?
-
total_votes
:
total_votes
;
}
...
...
@@ -88,8 +86,7 @@ namespace eosiosystem {
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE
(
producer_info
,
(
owner
)(
total_votes
)(
producer_key
)(
is_active
)(
url
)
(
unpaid_blocks
)(
last_claim_time
)(
location
)
(
time_became_active
)(
last_produced_block_time
)
)
(
unpaid_blocks
)(
last_claim_time
)(
location
)
)
};
struct
voter_info
{
...
...
contracts/eosio.system/producer_pay.cpp
浏览文件 @
8d0417fd
...
...
@@ -39,7 +39,6 @@ namespace eosiosystem {
_gstate
.
total_unpaid_blocks
++
;
_producers
.
modify
(
prod
,
0
,
[
&
](
auto
&
p
)
{
p
.
unpaid_blocks
++
;
p
.
last_produced_block_time
=
timestamp
;
});
}
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
8d0417fd
...
...
@@ -80,30 +80,7 @@ namespace eosiosystem {
std
::
vector
<
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
>
top_producers
;
top_producers
.
reserve
(
21
);
std
::
vector
<
decltype
(
idx
.
cbegin
())
>
inactive_iters
;
for
(
auto
it
=
idx
.
cbegin
();
it
!=
idx
.
cend
()
&&
top_producers
.
size
()
<
21
&&
0
<
it
->
total_votes
&&
it
->
active
();
++
it
)
{
/**
If it's the first time or it's been over a day since a producer was last voted in,
update his info. Otherwise, a producer gets a grace period of 7 hours after which
he gets deactivated if he hasn't produced in 24 hours.
*/
if
(
it
->
time_became_active
.
slot
==
0
||
block_time
.
slot
>
it
->
time_became_active
.
slot
+
23
*
blocks_per_hour
)
{
_producers
.
modify
(
*
it
,
0
,
[
&
](
auto
&
p
)
{
p
.
time_became_active
=
block_time
;
});
}
else
if
(
block_time
.
slot
>
(
2
*
21
*
12
*
100
)
+
it
->
time_became_active
.
slot
&&
block_time
.
slot
>
it
->
last_produced_block_time
.
slot
+
blocks_per_day
)
{
// save producers that will be deactivated
inactive_iters
.
push_back
(
it
);
continue
;
}
else
{
_producers
.
modify
(
*
it
,
0
,
[
&
](
auto
&
p
)
{
p
.
time_became_active
=
block_time
;
});
}
top_producers
.
emplace_back
(
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
it
->
owner
,
it
->
producer_key
},
it
->
location
})
);
}
...
...
@@ -111,13 +88,6 @@ namespace eosiosystem {
return
;
}
for
(
const
auto
&
it
:
inactive_iters
)
{
_producers
.
modify
(
*
it
,
0
,
[
&
](
auto
&
p
)
{
p
.
deactivate
();
p
.
time_became_active
.
slot
=
0
;
});
}
/// sort by producer name
std
::
sort
(
top_producers
.
begin
(),
top_producers
.
end
()
);
...
...
unittests/eosio.system_tests.cpp
浏览文件 @
8d0417fd
...
...
@@ -1517,9 +1517,8 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
push_action
(
prod_name
,
N
(
claimrewards
),
mvo
()(
"owner"
,
prod_name
)));
}
// wait for 23 hours which is not enough for producers to get deactivated
// payment calculations don't change. By now, pervote_bucket has grown enough
// that a producer's share is more than 100 tokens
// Wait for 23 hours. By now, pervote_bucket has grown enough
// that a producer's share is more than 100 tokens.
produce_block
(
fc
::
seconds
(
23
*
3600
));
{
...
...
@@ -1593,56 +1592,6 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
push_action
(
prod_name
,
N
(
claimrewards
),
mvo
()(
"owner"
,
prod_name
)));
}
// wait two more hours, now most producers haven't produced in a day and will
// be deactivated
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvotera
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvotera"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
(
producer_names
.
begin
(),
producer_names
.
begin
()
+
21
))
)
);
produce_block
(
fc
::
hours
(
9
));
produce_blocks
(
8
*
21
*
12
);
{
bool
all_newly_elected_produced
=
true
;
for
(
uint32_t
i
=
21
;
i
<
producer_names
.
size
();
++
i
)
{
if
(
0
==
get_producer_info
(
producer_names
[
i
])[
"unpaid_blocks"
].
as
<
uint32_t
>
())
{
all_newly_elected_produced
=
false
;
}
}
BOOST_REQUIRE
(
all_newly_elected_produced
);
}
{
uint32_t
survived_active_producers
=
0
;
uint32_t
one_inactive_index
=
0
;
for
(
uint32_t
i
=
0
;
i
<
21
;
++
i
)
{
if
(
fc
::
crypto
::
public_key
()
!=
fc
::
crypto
::
public_key
(
get_producer_info
(
producer_names
[
i
])[
"producer_key"
].
as_string
()))
{
++
survived_active_producers
;
}
else
{
one_inactive_index
=
i
;
}
}
BOOST_REQUIRE
(
3
>=
survived_active_producers
);
auto
inactive_prod_info
=
get_producer_info
(
producer_names
[
one_inactive_index
]);
BOOST_REQUIRE_EQUAL
(
0
,
inactive_prod_info
[
"time_became_active"
].
as
<
uint32_t
>
());
BOOST_REQUIRE_EQUAL
(
wasm_assert_msg
(
"producer does not have an active key"
),
push_action
(
producer_names
[
one_inactive_index
],
N
(
claimrewards
),
mvo
()(
"owner"
,
producer_names
[
one_inactive_index
])));
// re-register deactivated producer and let him produce blocks again
const
uint32_t
initial_unpaid_blocks
=
inactive_prod_info
[
"unpaid_blocks"
].
as
<
uint32_t
>
();
regproducer
(
producer_names
[
one_inactive_index
]);
produce_blocks
(
8
*
21
*
12
);
auto
reactivated_prod_info
=
get_producer_info
(
producer_names
[
one_inactive_index
]);
const
uint32_t
unpaid_blocks
=
reactivated_prod_info
[
"unpaid_blocks"
].
as
<
uint32_t
>
();
BOOST_REQUIRE
(
initial_unpaid_blocks
+
12
<=
unpaid_blocks
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
producer_names
[
one_inactive_index
],
N
(
claimrewards
),
mvo
()(
"owner"
,
producer_names
[
one_inactive_index
])));
}
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
producers_upgrade_system_contract
,
eosio_system_tester
)
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录