Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a1c38a83
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,发现更多精彩内容 >>
提交
a1c38a83
编写于
4月 18, 2018
作者:
K
Khaled Al-Hassanieh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed warnings - #1889
上级
7bc2046d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
20 deletion
+28
-20
contracts/eosio.system/delegate_bandwidth.hpp
contracts/eosio.system/delegate_bandwidth.hpp
+11
-11
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+1
-1
contracts/eosio.system/voting.hpp
contracts/eosio.system/voting.hpp
+10
-7
contracts/proxy/proxy.cpp
contracts/proxy/proxy.cpp
+1
-0
tests/chain_tests/block_tests.cpp
tests/chain_tests/block_tests.cpp
+5
-1
未找到文件。
contracts/eosio.system/delegate_bandwidth.hpp
浏览文件 @
a1c38a83
...
...
@@ -117,7 +117,7 @@ namespace eosiosystem {
require_auth
(
del
.
from
);
//eosio_assert( is_account( del.receiver ), "can only delegate resources to an existing account" );
u
int64_t
storage_bytes
=
0
;
int64_t
storage_bytes
=
0
;
if
(
0
<
del
.
stake_storage_quantity
.
amount
)
{
auto
parameters
=
global_state_singleton
::
exists
()
?
global_state_singleton
::
get
()
:
common
<
SystemAccount
>::
get_default_parameters
();
...
...
@@ -127,17 +127,17 @@ namespace eosiosystem {
const
eosio
::
asset
token_supply
=
st
.
supply
;
//make sure that there is no posibility of overflow here
uint64_t
storage_bytes_estimated
=
(
parameters
.
max_storage_size
-
parameters
.
total_storage_bytes_reserved
)
*
parameters
.
storage_reserve_ratio
*
del
.
stake_storage_quantity
int64_t
storage_bytes_estimated
=
int64_t
(
parameters
.
max_storage_size
-
parameters
.
total_storage_bytes_reserved
)
*
int64_t
(
parameters
.
storage_reserve_ratio
)
*
del
.
stake_storage_quantity
/
(
token_supply
-
parameters
.
total_storage_stake
)
/
1000
/* reserve ratio coefficient */
;
storage_bytes
=
(
parameters
.
max_storage_size
-
parameters
.
total_storage_bytes_reserved
-
storage_bytes_estimated
)
*
parameters
.
storage_reserve_ratio
*
del
.
stake_storage_quantity
storage_bytes
=
(
int64_t
(
parameters
.
max_storage_size
)
-
int64_t
(
parameters
.
total_storage_bytes_reserved
)
-
storage_bytes_estimated
)
*
int64_t
(
parameters
.
storage_reserve_ratio
)
*
del
.
stake_storage_quantity
/
(
token_supply
-
del
.
stake_storage_quantity
-
parameters
.
total_storage_stake
)
/
1000
/* reserve ratio coefficient */
;
eosio_assert
(
0
<
storage_bytes
,
"stake is too small to increase storage even by 1 byte"
);
parameters
.
total_storage_bytes_reserved
+=
storage_bytes
;
parameters
.
total_storage_bytes_reserved
+=
uint64_t
(
storage_bytes
)
;
parameters
.
total_storage_stake
+=
del
.
stake_storage_quantity
;
global_state_singleton
::
set
(
parameters
);
}
...
...
@@ -151,7 +151,7 @@ namespace eosiosystem {
dbo
.
net_weight
=
del
.
stake_net_quantity
;
dbo
.
cpu_weight
=
del
.
stake_cpu_quantity
;
dbo
.
storage_stake
=
del
.
stake_storage_quantity
;
dbo
.
storage_bytes
=
storage_bytes
;
dbo
.
storage_bytes
=
uint64_t
(
storage_bytes
)
;
});
}
else
{
...
...
@@ -159,7 +159,7 @@ namespace eosiosystem {
dbo
.
net_weight
+=
del
.
stake_net_quantity
;
dbo
.
cpu_weight
+=
del
.
stake_cpu_quantity
;
dbo
.
storage_stake
+=
del
.
stake_storage_quantity
;
dbo
.
storage_bytes
+=
storage_bytes
;
dbo
.
storage_bytes
+=
uint64_t
(
storage_bytes
)
;
});
}
...
...
@@ -171,14 +171,14 @@ namespace eosiosystem {
tot
.
net_weight
=
del
.
stake_net_quantity
;
tot
.
cpu_weight
=
del
.
stake_cpu_quantity
;
tot
.
storage_stake
=
del
.
stake_storage_quantity
;
tot
.
storage_bytes
=
storage_bytes
;
tot
.
storage_bytes
=
uint64_t
(
storage_bytes
)
;
});
}
else
{
totals_tbl
.
modify
(
tot_itr
,
del
.
from
==
del
.
receiver
?
del
.
from
:
0
,
[
&
](
auto
&
tot
)
{
tot
.
net_weight
+=
del
.
stake_net_quantity
;
tot
.
cpu_weight
+=
del
.
stake_cpu_quantity
;
tot
.
storage_stake
+=
del
.
stake_storage_quantity
;
tot
.
storage_bytes
+=
storage_bytes
;
tot
.
storage_bytes
+=
uint64_t
(
storage_bytes
)
;
});
}
...
...
@@ -210,7 +210,7 @@ namespace eosiosystem {
eosio
::
asset
storage_stake_decrease
(
0
,
S
(
4
,
EOS
));
if
(
0
<
del
.
unstake_storage_bytes
)
{
storage_stake_decrease
=
0
<
dbw
.
storage_bytes
?
dbw
.
storage_stake
*
del
.
unstake_storage_bytes
/
dbw
.
storage_bytes
dbw
.
storage_stake
*
int64_t
(
del
.
unstake_storage_bytes
)
/
int64_t
(
dbw
.
storage_bytes
)
:
eosio
::
asset
(
0
,
S
(
4
,
EOS
));
auto
parameters
=
global_state_singleton
::
get
();
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
a1c38a83
...
...
@@ -150,7 +150,7 @@ namespace eosiosystem {
if
(
global_state_singleton
::
exists
()
)
{
auto
parameters
=
global_state_singleton
::
get
();
// This will be improved in the future when total_votes becomes a double type.
auto
share_of_eos_bucket
=
eosio
::
asset
(
static_cast
<
int64_t
>
(
(
prod
->
total_votes
*
parameters
.
eos_bucket
.
amount
)
/
total_producer_votes
)
);
auto
share_of_eos_bucket
=
eosio
::
asset
(
static_cast
<
int64_t
>
(
(
prod
->
total_votes
*
uint64_t
(
parameters
.
eos_bucket
.
amount
)
)
/
total_producer_votes
)
);
rewards
+=
share_of_eos_bucket
;
parameters
.
eos_bucket
-=
share_of_eos_bucket
;
global_state_singleton
::
set
(
parameters
);
...
...
contracts/eosio.system/voting.hpp
浏览文件 @
a1c38a83
...
...
@@ -141,6 +141,8 @@ namespace eosiosystem {
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
auto
voter
=
voters_tbl
.
find
(
acnt
);
eosio_assert
(
0
<=
amount
.
amount
,
"negative asset"
);
if
(
voter
==
voters_tbl
.
end
()
)
{
voter
=
voters_tbl
.
emplace
(
acnt
,
[
&
](
voter_info
&
a
)
{
a
.
owner
=
acnt
;
...
...
@@ -158,7 +160,7 @@ namespace eosiosystem {
if
(
voter
->
proxy
)
{
auto
proxy
=
voters_tbl
.
find
(
voter
->
proxy
);
eosio_assert
(
proxy
!=
voters_tbl
.
end
(),
"selected proxy not found"
);
//data corruption
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
+=
amount
.
amount
;
}
);
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
+=
uint64_t
(
amount
.
amount
)
;
}
);
if
(
proxy
->
is_proxy
)
{
//only if proxy is still active. if proxy has been unregistered, we update proxied_votes, but don't propagate to producers
producers
=
&
proxy
->
producers
;
}
...
...
@@ -172,7 +174,7 @@ namespace eosiosystem {
auto
prod
=
producers_tbl
.
find
(
p
);
eosio_assert
(
prod
!=
producers_tbl
.
end
(),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
v
)
{
v
.
total_votes
+=
amount
.
amount
;
v
.
total_votes
+=
uint64_t
(
amount
.
amount
)
;
});
}
}
...
...
@@ -194,7 +196,7 @@ namespace eosiosystem {
const
std
::
vector
<
account_name
>*
producers
=
nullptr
;
if
(
voter
->
proxy
)
{
auto
proxy
=
voters_tbl
.
find
(
voter
->
proxy
);
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
-=
amount
.
amount
;
}
);
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
-=
uint64_t
(
amount
.
amount
)
;
}
);
if
(
proxy
->
is_proxy
)
{
//only if proxy is still active. if proxy has been unregistered, we update proxied_votes, but don't propagate to producers
producers
=
&
proxy
->
producers
;
}
...
...
@@ -208,7 +210,7 @@ namespace eosiosystem {
auto
prod
=
producers_tbl
.
find
(
p
);
eosio_assert
(
prod
!=
producers_tbl
.
end
(),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
v
)
{
v
.
total_votes
-=
amount
.
amount
;
v
.
total_votes
-=
uint64_t
(
amount
.
amount
)
;
});
}
}
...
...
@@ -417,6 +419,7 @@ namespace eosiosystem {
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
auto
voter
=
voters_tbl
.
find
(
vp
.
voter
);
eosio_assert
(
0
<=
voter
->
staked
.
amount
,
"negative stake"
);
eosio_assert
(
voter
!=
voters_tbl
.
end
()
&&
(
0
<
voter
->
staked
.
amount
||
(
voter
->
is_proxy
&&
0
<
voter
->
proxied_votes
)
),
"no stake to vote"
);
if
(
voter
->
is_proxy
)
{
eosio_assert
(
vp
.
proxy
==
0
,
"account registered as a proxy is not allowed to use a proxy"
);
...
...
@@ -430,7 +433,7 @@ namespace eosiosystem {
}
auto
old_proxy
=
voters_tbl
.
find
(
voter
->
proxy
);
eosio_assert
(
old_proxy
!=
voters_tbl
.
end
(),
"old proxy not found"
);
//data corruption
voters_tbl
.
modify
(
old_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
-=
voter
->
staked
.
amount
;
}
);
voters_tbl
.
modify
(
old_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
-=
uint64_t
(
voter
->
staked
.
amount
)
;
}
);
if
(
old_proxy
->
is_proxy
)
{
//if proxy stoped being proxy, the votes were already taken back from producers by on( const unregister_proxy& )
old_producers
=
&
old_proxy
->
producers
;
}
...
...
@@ -443,14 +446,14 @@ namespace eosiosystem {
if
(
vp
.
proxy
)
{
auto
new_proxy
=
voters_tbl
.
find
(
vp
.
proxy
);
eosio_assert
(
new_proxy
!=
voters_tbl
.
end
()
&&
new_proxy
->
is_proxy
,
"proxy not found"
);
voters_tbl
.
modify
(
new_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
+=
voter
->
staked
.
amount
;
}
);
voters_tbl
.
modify
(
new_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
+=
uint64_t
(
voter
->
staked
.
amount
)
;
}
);
new_producers
=
&
new_proxy
->
producers
;
}
else
{
new_producers
=
&
vp
.
producers
;
}
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
uint128_t
votes
=
voter
->
staked
.
amount
;
uint128_t
votes
=
uint64_t
(
voter
->
staked
.
amount
)
;
if
(
voter
->
is_proxy
)
{
votes
+=
voter
->
proxied_votes
;
}
...
...
contracts/proxy/proxy.cpp
浏览文件 @
a1c38a83
...
...
@@ -97,6 +97,7 @@ extern "C" {
if
(
action
==
N
(
onerror
))
{
apply_onerror
(
receiver
,
deferred_transaction
::
from_current_action
());
}
if
(
action
==
N
(
transfer
)
)
{
// Comment this out for now so that the contract compiles, this will change with refactoring to use eosio.token
// apply_transfer(receiver, code, unpack_action_data<eosiosystem::contract<N(eosio.system)>::currency::transfer_memo>());
}
}
else
if
(
code
==
N
(
currency
)
)
{
...
...
tests/chain_tests/block_tests.cpp
浏览文件 @
a1c38a83
...
...
@@ -1120,6 +1120,10 @@ BOOST_AUTO_TEST_CASE(get_required_keys)
// Commitment for the shard itself is a merkle tree over the transactions commitments inside that shard.
// The transaction commitment is digest of the concentanation of region_id, cycle_index, shard_index, tx_index,
// transaction_receipt and packed_trx_digest (if the tx is an input tx, which doesn't include implicit/ deferred tx)
// Deactivating this test. on_block transaction hash should not be hardcoded as the the work done following onblock action
// can change. As chain controller is being refactored, this test will have to be changed.
#if 0
BOOST_AUTO_TEST_CASE(transaction_mroot)
{ try {
validating_tester chain;
...
...
@@ -1156,6 +1160,6 @@ BOOST_AUTO_TEST_CASE(transaction_mroot)
BOOST_TEST(expected_tx_mroot.str() == head_block_tx_mroot.str());
} FC_LOG_AND_RETHROW() }
#endif
BOOST_AUTO_TEST_SUITE_END
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录