Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
77e14d3d
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,发现更多精彩内容 >>
提交
77e14d3d
编写于
5月 14, 2018
作者:
K
Khaled Al-Hassanieh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed abi issues, part of producer pay tests
上级
b4407434
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
70 addition
and
57 deletion
+70
-57
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+24
-24
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+4
-4
contracts/eosio.system/producer_pay.cpp
contracts/eosio.system/producer_pay.cpp
+1
-1
contracts/eosiolib/datastream.hpp
contracts/eosiolib/datastream.hpp
+6
-6
unittests/eosio.system_tests.cpp
unittests/eosio.system_tests.cpp
+35
-22
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
77e14d3d
...
...
@@ -87,15 +87,15 @@
"name": "blockchain_parameters",
"base": "",
"fields": [
{"name":"max_block_net_usage",
"type": "uint32
"},
{"name":"target_block_net_usage_pct",
"type":
"uint32"},
{"name":"max_block_net_usage",
"type":"uint64
"},
{"name":"target_block_net_usage_pct",
"type":
"uint32"},
{"name":"max_transaction_net_usage", "type":"uint32"},
{"name":"base_per_transaction_net_usage", "type":"uint32"},
{"name":"net_usage_leeway", "type":"uint32"},
{"name":"context_free_discount_net_usage_num", "type":"uint32"},
{"name":"context_free_discount_net_usage_den", "type":"uint32"},
{"name":"max_block_cpu_usage",
"type": "uint64
"},
{"name":"target_block_cpu_usage_pct",
"type":
"uint32"},
{"name":"max_block_cpu_usage",
"type":"uint32
"},
{"name":"target_block_cpu_usage_pct",
"type":
"uint32"},
{"name":"max_transaction_cpu_usage", "type":"uint32"},
{"name":"base_per_transaction_cpu_usage", "type":"uint32"},
{"name":"base_per_action_cpu_usage", "type":"uint32"},
...
...
@@ -123,16 +123,16 @@
"base": "eosio_parameters",
"fields": [
{"name":"total_ram_bytes_reserved", "type":"uint64"},
{"name":"total_ram_stake", "type":"
u
int64"},
{"name":"total_ram_stake", "type":"int64"},
{"name":"last_producer_schedule_update", "type":"time"},
{"name":"last_pervote_bucket_fill", "type":"uint64"},
{"name":"pervote_bucket", "type":"int64"},
{"name":"perblock_bucket", "type":"int64"},
{"name":"savings", "type":"int64"},
{"name":"last_producer_schedule_id", "type":"checksum160"},
{"name":"total_activatied_stake", "type":"int64"},
{"name":"total_producer_vote_weight", "type":"float64"},
{"name":"total_unpaid_blocks", "type":"uint32"}
{"name":"total_activated_stake", "type":"int64"},
{"name":"last_producer_schedule_id", "type":"checksum160"},
{"name":"total_producer_vote_weight", "type":"float64"}
]
},{
"name": "producer_info",
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
77e14d3d
...
...
@@ -36,17 +36,17 @@ namespace eosiosystem {
int64_t
pervote_bucket
;
int64_t
perblock_bucket
;
int64_t
savings
;
checksum160
last_producer_schedule_id
;
uint32_t
total_unpaid_blocks
=
0
;
/// all blocks which have been produced but not paid
int64_t
total_activated_stake
=
0
;
checksum160
last_producer_schedule_id
;
double
total_producer_vote_weight
=
0
;
/// the sum of all producer votes
int32_t
total_unpaid_blocks
=
0
;
/// all blocks which have been produced but not paid
// checksum160 last_producer_schedule_id;
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE_DERIVED
(
eosio_global_state
,
eosio_parameters
,
(
total_ram_bytes_reserved
)(
total_ram_stake
)
(
last_producer_schedule_update
)
(
last_pervote_bucket_fill
)
(
pervote_bucket
)(
perblock_bucket
)(
savings
)(
last_producer_schedule_id
)(
total_activated_stake
)(
total_producer_vote_weight
)(
total_unpaid_blocks
)
)
(
pervote_bucket
)(
perblock_bucket
)(
savings
)(
total_unpaid_blocks
)(
total_activated_stake
)(
last_producer_schedule_id
)(
total_producer_vote_weight
)
)
};
struct
producer_info
{
...
...
contracts/eosio.system/producer_pay.cpp
浏览文件 @
77e14d3d
...
...
@@ -85,7 +85,7 @@ namespace eosiosystem {
int64_t
producer_per_vote_pay
=
int64_t
((
_gstate
.
pervote_bucket
*
prod
.
total_votes
)
/
_gstate
.
total_producer_vote_weight
);
int64_t
total_pay
=
producer_per_block_pay
+
producer_per_vote_pay
;
eosio_assert
(
total_pay
>
100
'0000
,
"insufficient pay to claim, require at least 100.0000 EOS"
);
eosio_assert
(
total_pay
>
100
0000
/* 100'0000 */
,
"insufficient pay to claim, require at least 100.0000 EOS"
);
_gstate
.
pervote_bucket
-=
producer_per_vote_pay
;
_gstate
.
perblock_bucket
-=
producer_per_block_pay
;
...
...
contracts/eosiolib/datastream.hpp
浏览文件 @
77e14d3d
...
...
@@ -209,7 +209,7 @@ inline datastream<Stream>& operator>>(datastream<Stream>& ds, bool& d) {
*/
template
<
typename
Stream
>
inline
datastream
<
Stream
>&
operator
<<
(
datastream
<
Stream
>&
ds
,
const
checksum256
&
d
)
{
ds
.
write
(
(
const
char
*
)
&
d
,
sizeof
(
d
)
);
ds
.
write
(
(
const
char
*
)
&
d
.
hash
[
0
],
sizeof
(
d
.
hash
)
);
return
ds
;
}
/**
...
...
@@ -220,7 +220,7 @@ inline datastream<Stream>& operator<<(datastream<Stream>& ds, const checksum256&
*/
template
<
typename
Stream
>
inline
datastream
<
Stream
>&
operator
>>
(
datastream
<
Stream
>&
ds
,
checksum256
&
d
)
{
ds
.
read
((
char
*
)
&
d
,
sizeof
(
d
)
);
ds
.
read
((
char
*
)
&
d
.
hash
[
0
],
sizeof
(
d
.
hash
)
);
return
ds
;
}
...
...
@@ -514,25 +514,25 @@ bytes pack( const T& value ) {
template
<
typename
Stream
>
inline
datastream
<
Stream
>&
operator
<<
(
datastream
<
Stream
>&
ds
,
const
checksum160
&
cs
)
{
ds
.
write
((
const
char
*
)
&
cs
,
sizeof
(
cs
));
ds
.
write
((
const
char
*
)
&
cs
.
hash
[
0
],
sizeof
(
cs
.
hash
));
return
ds
;
}
template
<
typename
Stream
>
inline
datastream
<
Stream
>&
operator
>>
(
datastream
<
Stream
>&
ds
,
checksum160
&
cs
)
{
ds
.
read
((
char
*
)
&
cs
,
sizeof
(
cs
));
ds
.
read
((
char
*
)
&
cs
.
hash
[
0
],
sizeof
(
cs
.
hash
));
return
ds
;
}
template
<
typename
Stream
>
inline
datastream
<
Stream
>&
operator
<<
(
datastream
<
Stream
>&
ds
,
const
checksum512
&
cs
)
{
ds
.
write
((
const
char
*
)
&
cs
,
sizeof
(
cs
));
ds
.
write
((
const
char
*
)
&
cs
.
hash
[
0
],
sizeof
(
cs
.
hash
));
return
ds
;
}
template
<
typename
Stream
>
inline
datastream
<
Stream
>&
operator
>>
(
datastream
<
Stream
>&
ds
,
checksum512
&
cs
)
{
ds
.
read
((
char
*
)
&
cs
,
sizeof
(
cs
));
ds
.
read
((
char
*
)
&
cs
.
hash
[
0
],
sizeof
(
cs
.
hash
));
return
ds
;
}
...
...
unittests/eosio.system_tests.cpp
浏览文件 @
77e14d3d
...
...
@@ -1299,6 +1299,10 @@ BOOST_FIXTURE_TEST_CASE( proxy_actions_affect_producers, eosio_system_tester, *
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
producer_pay
,
eosio_system_tester
,
*
boost
::
unit_test
::
tolerance
(
1e-10
))
try
{
const
double
continuous_rate
=
4.879
/
100.
;
const
double
usecs_per_year
=
52
*
7
*
24
*
3600
*
1000000ll
;
const
asset
large_asset
=
asset
::
from_string
(
"80.0000 EOS"
);
create_account_with_resources
(
N
(
inita
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 EOS"
),
false
,
large_asset
,
large_asset
);
create_account_with_resources
(
N
(
initb
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 EOS"
),
false
,
large_asset
,
large_asset
);
...
...
@@ -1311,7 +1315,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
BOOST_REQUIRE_EQUAL
(
"inita"
,
prod
[
"owner"
].
as_string
());
BOOST_REQUIRE_EQUAL
(
0
,
prod
[
"total_votes"
].
as_double
());
issue
(
"vota"
,
"400000000.0000 EOS"
,
config
::
system_account_name
);
transfer
(
config
::
system_account_name
,
"vota"
,
"400000000.0000 EOS"
,
config
::
system_account_name
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"vota"
,
"100000000.0000 EOS"
,
"100000000.0000 EOS"
));
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
vota
),
N
(
voteproducer
),
mvo
()
...
...
@@ -1329,12 +1333,17 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
int64_t
initial_pervote_bucket
=
initial_global_state
[
"pervote_bucket"
].
as
<
int64_t
>
();
const
int64_t
initial_perblock_bucket
=
initial_global_state
[
"perblock_bucket"
].
as
<
int64_t
>
();
const
int64_t
initial_savings
=
initial_global_state
[
"savings"
].
as
<
int64_t
>
();
const
uint32_t
initial_tot_unpaid_blocks
=
initial_global_state
[
"total_unpaid_blocks"
].
as
<
uint32_t
>
();
prod
=
get_producer_info
(
"inita"
);
const
uint32_t
produce
d_blocks
=
prod
[
"produced_blocks"
].
as
<
uint32_t
>
();
BOOST_REQUIRE
(
1
<
produce
d_blocks
);
const
uint32_t
unpai
d_blocks
=
prod
[
"produced_blocks"
].
as
<
uint32_t
>
();
BOOST_REQUIRE
(
1
<
unpai
d_blocks
);
BOOST_REQUIRE_EQUAL
(
0
,
prod
[
"last_claim_time"
].
as
<
uint64_t
>
());
BOOST_REQUIRE_EQUAL
(
initial_tot_unpaid_blocks
,
unpaid_blocks
);
const
asset
initial_supply
=
get_token_supply
();
const
asset
initial_balance
=
get_balance
(
N
(
inita
));
...
...
@@ -1343,24 +1352,29 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
int64_t
pervote_bucket
=
global_state
[
"pervote_bucket"
].
as
<
int64_t
>
();
const
int64_t
perblock_bucket
=
global_state
[
"perblock_bucket"
].
as
<
int64_t
>
();
const
int64_t
savings
=
global_state
[
"savings"
].
as
<
int64_t
>
();
const
uint32_t
tot_unpaid_blocks
=
global_state
[
"total_unpaid_blocks"
].
as
<
uint32_t
>
();
prod
=
get_producer_info
(
"inita"
);
BOOST_REQUIRE_EQUAL
(
1
,
prod
[
"produced_blocks"
].
as
<
uint32_t
>
());
BOOST_REQUIRE_EQUAL
(
1
,
tot_unpaid_blocks
);
const
asset
supply
=
get_token_supply
();
const
asset
balance
=
get_balance
(
N
(
inita
));
BOOST_REQUIRE_EQUAL
(
claim_time
,
prod
[
"last_claim_time"
].
as
<
uint64_t
>
());
const
int32_t
secs_between_fills
=
static_cast
<
int32_t
>
((
claim_time
-
initial_claim_time
)
/
1000000
)
;
auto
usecs_between_fills
=
claim_time
-
initial_claim_time
;
BOOST_REQUIRE_EQUAL
(
0
,
initial_pervote_bucket
);
BOOST_REQUIRE_EQUAL
(
int64_t
(
(
initial_supply
.
amount
*
double
(
usecs_between_fills
)
*
continuous_rate
)
/
usecs_per_year
),
supply
.
amount
-
initial_supply
.
amount
);
BOOST_REQUIRE_EQUAL
(
int64_t
(
(
initial_supply
.
amount
*
double
(
usecs_between_fills
)
*
(
4.
*
continuous_rate
/
5.
)
/
usecs_per_year
)
),
savings
-
initial_savings
);
// BOOST_REQUIRE_EQUAL(int64_t( (initial_supply.amount * secs_between_fills * ((4.879-1.0)/100.0)) / (52*7*24*3600) ),
// savings - initial_savings
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
unpaid_blocks
*
(
0.25
/
100.0
)
/
(
52
*
7
*
24
*
3600
*
2
)
);
int64_t
from_pervote_bucket
=
int64_t
(
initial_supply
.
amount
*
usecs_between_fills
*
(
0.75
/
100.0
)
/
(
52
*
7
*
24
*
3600
)
);
return
;
/*
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * (0.25/100.0) / (52*7*24*3600*2) );
int64_t from_pervote_bucket = int64_t( initial_supply.amount * secs_between_fills * (0.75/100.0) / (52*7*24*3600) );
if (from_pervote_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_pervote_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(0, pervote_bucket);
...
...
@@ -1369,9 +1383,8 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
BOOST_REQUIRE_EQUAL(from_pervote_bucket, pervote_bucket);
}
*/
const
int64_t
max_supply_growth
=
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
(
4.879
/
100.0
))
/
(
52
*
7
*
24
*
3600
)
);
BOOST_REQUIRE
(
max_supply_growth
>=
supply
.
amount
-
initial_supply
.
amount
);
// const int64_t max_supply_growth = int64_t( (initial_supply.amount * usecs_between_fills * (4.879/100.0)) / (52*7*24*3600) );
// BOOST_REQUIRE(max_supply_growth >= supply.amount - initial_supply.amount);
}
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录