Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
6a2eb430
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,发现更多精彩内容 >>
提交
6a2eb430
编写于
4月 18, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tester now works for setting producers and block production
上级
a4b1d0d0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
109 addition
and
44 deletion
+109
-44
libraries/chain/abi_serializer.cpp
libraries/chain/abi_serializer.cpp
+4
-0
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+9
-3
libraries/chain/include/eosio/chain/controller.hpp
libraries/chain/include/eosio/chain/controller.hpp
+3
-3
libraries/chain/include/eosio/chain/trace.hpp
libraries/chain/include/eosio/chain/trace.hpp
+33
-0
libraries/chain/include/eosio/chain/transaction_context.hpp
libraries/chain/include/eosio/chain/transaction_context.hpp
+1
-0
libraries/chain/transaction_context.cpp
libraries/chain/transaction_context.cpp
+1
-0
libraries/testing/CMakeLists.txt
libraries/testing/CMakeLists.txt
+4
-0
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+13
-13
libraries/testing/test.cpp
libraries/testing/test.cpp
+22
-0
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+19
-25
未找到文件。
libraries/chain/abi_serializer.cpp
浏览文件 @
6a2eb430
...
...
@@ -85,6 +85,10 @@ namespace eosio { namespace chain {
built_in_types
.
emplace
(
"int16"
,
pack_unpack
<
int16_t
>
());
built_in_types
.
emplace
(
"int32"
,
pack_unpack
<
int32_t
>
());
built_in_types
.
emplace
(
"int64"
,
pack_unpack
<
int64_t
>
());
built_in_types
.
emplace
(
"uint8"
,
pack_unpack
<
uint8_t
>
());
built_in_types
.
emplace
(
"uint16"
,
pack_unpack
<
uint16_t
>
());
built_in_types
.
emplace
(
"uint32"
,
pack_unpack
<
uint32_t
>
());
built_in_types
.
emplace
(
"uint64"
,
pack_unpack
<
uint64_t
>
());
built_in_types
.
emplace
(
"varint32"
,
pack_unpack
<
fc
::
signed_int
>
());
built_in_types
.
emplace
(
"float64"
,
pack_unpack
<
double
>
());
built_in_types
.
emplace
(
"name"
,
pack_unpack
<
name
>
());
...
...
libraries/chain/controller.cpp
浏览文件 @
6a2eb430
...
...
@@ -336,6 +336,7 @@ struct controller_impl {
transaction_trace_ptr
apply_transaction
(
const
transaction_metadata_ptr
&
trx
,
bool
implicit
=
false
)
{
transaction_context
trx_context
(
self
,
trx
);
trx_context
.
processing_deadline
=
fc
::
time_point
::
now
()
+
conf
.
limits
.
max_push_transaction_us
;
trx_context
.
exec
();
auto
&
acts
=
pending
->
_actions
;
...
...
@@ -455,7 +456,13 @@ struct controller_impl {
void
finalize_block
()
{
try
{
ilog
(
"finalize block"
);
ilog
(
"finalize block ${p} ${t} v: ${v} lib: ${lib} ${np}"
,
(
"p"
,
pending
->
_pending_block_state
->
header
.
producer
)
(
"t"
,
pending
->
_pending_block_state
->
header
.
timestamp
)
(
"v"
,
pending
->
_pending_block_state
->
header
.
schedule_version
)
(
"lib"
,
pending
->
_pending_block_state
->
dpos_last_irreversible_blocknum
)
(
"np"
,
pending
->
_pending_block_state
->
header
.
new_producers
)
);
set_action_merkle
();
set_trx_merkle
();
...
...
@@ -657,7 +664,6 @@ chainbase::database& controller::db()const { return my->db; }
void
controller
::
start_block
(
block_timestamp_type
when
)
{
wlog
(
"start_block"
);
FC_ASSERT
(
!
my
->
pending
);
FC_ASSERT
(
my
->
db
.
revision
()
==
my
->
head
->
block_num
);
...
...
@@ -871,7 +877,7 @@ bool controller::check_authorization( account_name account, permission_name perm
void
controller
::
set_active_producers
(
const
producer_schedule_type
&
sch
)
{
FC_ASSERT
(
!
my
->
pending
->
_pending_block_state
->
header
.
new_producers
,
"this block has already set new producers"
);
FC_ASSERT
(
!
my
->
pending
->
_pending_block_state
->
pending_schedule
.
producers
.
size
(),
"there is already a pending schedule, wait for it to become active"
);
my
->
pending
->
_pending_block_state
->
header
.
new_producers
=
sch
;
my
->
pending
->
_pending_block_state
->
set_new_producers
(
sch
)
;
}
const
producer_schedule_type
&
controller
::
active_producers
()
const
{
return
my
->
pending
->
_pending_block_state
->
active_schedule
;
...
...
libraries/chain/include/eosio/chain/controller.hpp
浏览文件 @
6a2eb430
...
...
@@ -30,9 +30,9 @@ namespace eosio { namespace chain {
public:
struct
config
{
struct
runtime_limits
{
fc
::
microseconds
max_push_block_us
=
fc
::
microseconds
(
-
1
);
fc
::
microseconds
max_push_transaction_us
=
fc
::
microseconds
(
-
1
);
fc
::
microseconds
max_deferred_transactions_us
=
fc
::
microseconds
(
-
1
);
fc
::
microseconds
max_push_block_us
=
fc
::
microseconds
(
100000
);
fc
::
microseconds
max_push_transaction_us
=
fc
::
microseconds
(
100000
);
fc
::
microseconds
max_deferred_transactions_us
=
fc
::
microseconds
(
100000
);
};
path
block_log_dir
=
chain
::
config
::
default_block_log_dir
;
...
...
libraries/chain/include/eosio/chain/trace.hpp
0 → 100644
浏览文件 @
6a2eb430
#pragma once
namespace
eosio
{
namespace
chain
{
struct
action_trace
{
action_trace
(
const
action_receipt
&
r
)
:
receipt
(
r
){}
action_trace
(){}
action_receipt
receipt
;
action
act
;
fc
::
microseconds
ellapsed
;
string
console
;
uint64_t
cpu_usage
;
uint64_t
total_inline_cpu_usage
;
vector
<
action_trace
>
inline_traces
;
};
struct
transaction_trace
{
fc
::
microseconds
ellapsed
;
uint64_t
cpu_usage
;
vector
<
action_trace
>
action_traces
;
///< disposable
};
typedef
std
::
shared_ptr
<
transaction_trace
>
transaction_trace_ptr
;
struct
block_trace
{
fc
::
microseconds
ellapsed
;
uint64_t
cpu_usage
;
vector
<
transaction_trace_ptr
>
trx_traces
;
};
typedef
std
::
shared_ptr
<
block_trace
>
block_trace_ptr
;
}
}
/// namespace eosio::chain
libraries/chain/include/eosio/chain/transaction_context.hpp
浏览文件 @
6a2eb430
...
...
@@ -23,6 +23,7 @@ namespace eosio { namespace chain {
transaction_trace_ptr
trace
;
fc
::
time_point
processing_deadline
;
controller
&
control
;
const
transaction_metadata_ptr
&
trx_meta
;
chainbase
::
database
::
session
undo_session
;
...
...
libraries/chain/transaction_context.cpp
浏览文件 @
6a2eb430
...
...
@@ -22,6 +22,7 @@ namespace eosio { namespace chain {
apply_context
acontext
(
control
,
a
,
*
trx_meta
);
acontext
.
context_free
=
context_free
;
acontext
.
receiver
=
receiver
;
acontext
.
processing_deadline
=
processing_deadline
;
acontext
.
exec
();
fc
::
move_append
(
executed
,
move
(
acontext
.
executed
)
);
...
...
libraries/testing/CMakeLists.txt
浏览文件 @
6a2eb430
...
...
@@ -19,3 +19,7 @@ add_dependencies( eosio_testing eosio.bios )
if
(
MSVC
)
set_source_files_properties
(
db_init.cpp db_block.cpp database.cpp block_log.cpp PROPERTIES COMPILE_FLAGS
"/bigobj"
)
endif
(
MSVC
)
add_executable
(
chain_tester test.cpp
)
target_link_libraries
(
chain_tester
PRIVATE eosio_testing eosio_chain fc
${
CMAKE_DL_LIBS
}
${
PLATFORM_SPECIFIC_LIBS
}
${
Intl_LIBRARIES
}
)
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
6a2eb430
...
...
@@ -79,12 +79,12 @@ namespace eosio { namespace testing {
void
produce_blocks
(
uint32_t
n
=
1
);
void
produce_blocks_until_end_of_round
();
signed_block_ptr
push_block
(
signed_block_ptr
b
);
transaction_trace
push_transaction
(
packed_transaction
&
trx
,
uint32_t
skip_flag
=
0
/*skip_nothing */
);
transaction_trace
push_transaction
(
signed_transaction
&
trx
,
uint32_t
skip_flag
=
0
/*skip_nothing*/
);
transaction_trace
_ptr
push_transaction
(
packed_transaction
&
trx
,
uint32_t
skip_flag
=
0
/*skip_nothing */
);
transaction_trace
_ptr
push_transaction
(
signed_transaction
&
trx
,
uint32_t
skip_flag
=
0
/*skip_nothing*/
);
action_result
push_action
(
action
&&
cert_act
,
uint64_t
authorizer
);
transaction_trace
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
account_name
&
actor
,
const
variant_object
&
data
,
uint32_t
expiration
=
DEFAULT_EXPIRATION_DELTA
,
uint32_t
delay_sec
=
0
);
transaction_trace
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
vector
<
account_name
>&
actors
,
const
variant_object
&
data
,
uint32_t
expiration
=
DEFAULT_EXPIRATION_DELTA
,
uint32_t
delay_sec
=
0
);
transaction_trace
_ptr
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
account_name
&
actor
,
const
variant_object
&
data
,
uint32_t
expiration
=
DEFAULT_EXPIRATION_DELTA
,
uint32_t
delay_sec
=
0
);
transaction_trace
_ptr
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
vector
<
account_name
>&
actors
,
const
variant_object
&
data
,
uint32_t
expiration
=
DEFAULT_EXPIRATION_DELTA
,
uint32_t
delay_sec
=
0
);
void
set_tapos
(
signed_transaction
&
trx
,
uint32_t
expiration
=
DEFAULT_EXPIRATION_DELTA
)
const
;
...
...
@@ -92,8 +92,8 @@ namespace eosio { namespace testing {
uint32_t
expiration
=
DEFAULT_EXPIRATION_DELTA
,
uint32_t
delay_sec
=
0
)
const
;
vector
<
transaction_trace
>
create_accounts
(
vector
<
account_name
>
names
,
bool
multisig
=
false
)
{
vector
<
transaction_trace
>
traces
;
vector
<
transaction_trace
_ptr
>
create_accounts
(
vector
<
account_name
>
names
,
bool
multisig
=
false
)
{
vector
<
transaction_trace
_ptr
>
traces
;
traces
.
reserve
(
names
.
size
());
for
(
auto
n
:
names
)
traces
.
emplace_back
(
create_account
(
n
,
config
::
system_account_name
,
multisig
));
return
traces
;
...
...
@@ -111,15 +111,15 @@ namespace eosio { namespace testing {
void
delete_authority
(
account_name
account
,
permission_name
perm
,
const
vector
<
permission_level
>&
auths
,
const
vector
<
private_key_type
>&
keys
);
void
delete_authority
(
account_name
account
,
permission_name
perm
);
transaction_trace
create_account
(
account_name
name
,
account_name
creator
=
config
::
system_account_name
,
bool
multisig
=
false
);
transaction_trace
_ptr
create_account
(
account_name
name
,
account_name
creator
=
config
::
system_account_name
,
bool
multisig
=
false
);
transaction_trace
push_reqauth
(
account_name
from
,
const
vector
<
permission_level
>&
auths
,
const
vector
<
private_key_type
>&
keys
);
transaction_trace
push_reqauth
(
account_name
from
,
string
role
,
bool
multi_sig
=
false
);
transaction_trace
_ptr
push_reqauth
(
account_name
from
,
const
vector
<
permission_level
>&
auths
,
const
vector
<
private_key_type
>&
keys
);
transaction_trace
_ptr
push_reqauth
(
account_name
from
,
string
role
,
bool
multi_sig
=
false
);
// use when just want any old non-context free action
transaction_trace
push_dummy
(
account_name
from
,
const
string
&
v
=
"blah"
);
transaction_trace
transfer
(
account_name
from
,
account_name
to
,
asset
amount
,
string
memo
,
account_name
currency
);
transaction_trace
transfer
(
account_name
from
,
account_name
to
,
string
amount
,
string
memo
,
account_name
currency
);
transaction_trace
issue
(
account_name
to
,
string
amount
,
account_name
currency
);
transaction_trace
_ptr
push_dummy
(
account_name
from
,
const
string
&
v
=
"blah"
);
transaction_trace
_ptr
transfer
(
account_name
from
,
account_name
to
,
asset
amount
,
string
memo
,
account_name
currency
);
transaction_trace
_ptr
transfer
(
account_name
from
,
account_name
to
,
string
amount
,
string
memo
,
account_name
currency
);
transaction_trace
_ptr
issue
(
account_name
to
,
string
amount
,
account_name
currency
);
template
<
typename
ObjectType
>
const
auto
&
get
(
const
chainbase
::
oid
<
ObjectType
>&
key
)
{
...
...
libraries/testing/test.cpp
0 → 100644
浏览文件 @
6a2eb430
#include <eosio/testing/tester.hpp>
using
namespace
eosio
::
chain
;
using
namespace
eosio
::
testing
;
int
main
(
int
argc
,
char
**
argv
)
{
try
{
try
{
tester
c
;
c
.
produce_block
();
c
.
produce_block
();
c
.
produce_block
();
c
.
create_accounts
(
{
N
(
dan
),
N
(
sam
),
N
(
pam
)}
);
c
.
set_producers
(
{
N
(
dan
),
N
(
sam
),
N
(
pam
)},
1
);
c
.
produce_blocks
(
60
);
}
FC_CAPTURE_AND_RETHROW
()
}
catch
(
const
fc
::
exception
&
e
)
{
edump
((
e
.
to_detail_string
()));
}
}
libraries/testing/tester.cpp
浏览文件 @
6a2eb430
...
...
@@ -101,7 +101,8 @@ namespace eosio { namespace testing {
auto
head_time
=
control
->
head_block_time
();
auto
next_time
=
head_time
+
skip_time
;
control
->
start_block
(
next_time
);
if
(
!
control
->
pending_block_state
()
)
control
->
start_block
(
next_time
);
control
->
finalize_block
();
control
->
sign_block
(
[
&
](
digest_type
d
)
{
...
...
@@ -113,13 +114,6 @@ namespace eosio { namespace testing {
control
->
log_irreversible_blocks
();
return
control
->
head_block_state
()
->
block
;
/*
uint32_t slot = control->get_slot_at_time( next_time );
auto sch_pro = control->get_scheduled_producer(slot);
return control->generate_block( next_time, sch_pro, priv_key, skip_flag );
*/
}
void
base_tester
::
produce_blocks
(
uint32_t
n
)
{
...
...
@@ -145,7 +139,7 @@ namespace eosio { namespace testing {
}
transaction_trace
base_tester
::
create_account
(
account_name
a
,
account_name
creator
,
bool
multisig
)
{
transaction_trace
_ptr
base_tester
::
create_account
(
account_name
a
,
account_name
creator
,
bool
multisig
)
{
signed_transaction
trx
;
set_transaction_headers
(
trx
);
...
...
@@ -171,16 +165,16 @@ namespace eosio { namespace testing {
return
push_transaction
(
trx
);
}
transaction_trace
base_tester
::
push_transaction
(
packed_transaction
&
trx
,
uint32_t
skip_flag
)
{
try
{
control
->
push_transaction
(
std
::
make_shared
<
transaction_metadata
>
(
trx
)
);
return
transaction_trace
();
/// TODO: restore this
transaction_trace_ptr
base_tester
::
push_transaction
(
packed_transaction
&
trx
,
uint32_t
skip_flag
)
{
try
{
if
(
!
control
->
pending_block_state
()
)
control
->
start_block
();
return
control
->
push_transaction
(
std
::
make_shared
<
transaction_metadata
>
(
trx
)
);
}
FC_CAPTURE_AND_RETHROW
(
(
transaction_header
(
trx
.
get_transaction
()))
)
}
transaction_trace
base_tester
::
push_transaction
(
signed_transaction
&
trx
,
uint32_t
skip_flag
)
{
try
{
control
->
push_transaction
(
std
::
make_shared
<
transaction_metadata
>
(
trx
)
);
//auto ptrx = packed_transaction(trx);
//return push_transaction( ptrx, skip_flag );
return
transaction_trace
();
/// TODO: restore this
transaction_trace_ptr
base_tester
::
push_transaction
(
signed_transaction
&
trx
,
uint32_t
skip_flag
)
{
try
{
if
(
!
control
->
pending_block_state
()
)
control
->
start_block
();
return
control
->
push_transaction
(
std
::
make_shared
<
transaction_metadata
>
(
trx
)
);
}
FC_CAPTURE_AND_RETHROW
(
(
transaction_header
(
trx
))
)
}
...
...
@@ -205,7 +199,7 @@ namespace eosio { namespace testing {
}
transaction_trace
base_tester
::
push_action
(
const
account_name
&
code
,
transaction_trace
_ptr
base_tester
::
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
account_name
&
actor
,
const
variant_object
&
data
,
...
...
@@ -217,7 +211,7 @@ namespace eosio { namespace testing {
}
FC_CAPTURE_AND_RETHROW
(
(
code
)(
acttype
)(
actor
)(
data
)(
expiration
)
)
}
transaction_trace
base_tester
::
push_action
(
const
account_name
&
code
,
transaction_trace
_ptr
base_tester
::
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
vector
<
account_name
>&
actors
,
const
variant_object
&
data
,
...
...
@@ -253,7 +247,7 @@ namespace eosio { namespace testing {
}
FC_CAPTURE_AND_RETHROW
(
(
code
)(
acttype
)(
actors
)(
data
)(
expiration
)
)
}
transaction_trace
base_tester
::
push_reqauth
(
account_name
from
,
const
vector
<
permission_level
>&
auths
,
const
vector
<
private_key_type
>&
keys
)
{
transaction_trace
_ptr
base_tester
::
push_reqauth
(
account_name
from
,
const
vector
<
permission_level
>&
auths
,
const
vector
<
private_key_type
>&
keys
)
{
variant
pretty_trx
=
fc
::
mutable_variant_object
()
(
"actions"
,
fc
::
variants
({
fc
::
mutable_variant_object
()
...
...
@@ -276,7 +270,7 @@ namespace eosio { namespace testing {
}
transaction_trace
base_tester
::
push_reqauth
(
account_name
from
,
string
role
,
bool
multi_sig
)
{
transaction_trace
_ptr
base_tester
::
push_reqauth
(
account_name
from
,
string
role
,
bool
multi_sig
)
{
if
(
!
multi_sig
)
{
return
push_reqauth
(
from
,
vector
<
permission_level
>
{{
from
,
config
::
owner_name
}},
{
get_private_key
(
from
,
role
)});
...
...
@@ -287,7 +281,7 @@ namespace eosio { namespace testing {
}
transaction_trace
base_tester
::
push_dummy
(
account_name
from
,
const
string
&
v
)
{
transaction_trace
_ptr
base_tester
::
push_dummy
(
account_name
from
,
const
string
&
v
)
{
// use reqauth for a normal action, this could be anything
variant
pretty_trx
=
fc
::
mutable_variant_object
()
(
"actions"
,
fc
::
variants
({
...
...
@@ -324,12 +318,12 @@ namespace eosio { namespace testing {
}
transaction_trace
base_tester
::
transfer
(
account_name
from
,
account_name
to
,
string
amount
,
string
memo
,
account_name
currency
)
{
transaction_trace
_ptr
base_tester
::
transfer
(
account_name
from
,
account_name
to
,
string
amount
,
string
memo
,
account_name
currency
)
{
return
transfer
(
from
,
to
,
asset
::
from_string
(
amount
),
memo
,
currency
);
}
transaction_trace
base_tester
::
transfer
(
account_name
from
,
account_name
to
,
asset
amount
,
string
memo
,
account_name
currency
)
{
transaction_trace
_ptr
base_tester
::
transfer
(
account_name
from
,
account_name
to
,
asset
amount
,
string
memo
,
account_name
currency
)
{
variant
pretty_trx
=
fc
::
mutable_variant_object
()
(
"actions"
,
fc
::
variants
({
fc
::
mutable_variant_object
()
...
...
@@ -358,7 +352,7 @@ namespace eosio { namespace testing {
}
transaction_trace
base_tester
::
issue
(
account_name
to
,
string
amount
,
account_name
currency
)
{
transaction_trace
_ptr
base_tester
::
issue
(
account_name
to
,
string
amount
,
account_name
currency
)
{
variant
pretty_trx
=
fc
::
mutable_variant_object
()
(
"actions"
,
fc
::
variants
({
fc
::
mutable_variant_object
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录