Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
2be92c1f
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,发现更多精彩内容 >>
提交
2be92c1f
编写于
9月 18, 2018
作者:
M
Matt Witherspoon
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into wabt_upstream_sync_20180918
上级
ed4966ee
c776e9e7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
259 addition
and
116 deletion
+259
-116
CMakeModules/EosioTester.cmake.in
CMakeModules/EosioTester.cmake.in
+10
-0
CMakeModules/EosioTesterBuild.cmake.in
CMakeModules/EosioTesterBuild.cmake.in
+10
-0
libraries/CMakeLists.txt
libraries/CMakeLists.txt
+1
-0
libraries/fc
libraries/fc
+1
-1
plugins/COMMUNITY.md
plugins/COMMUNITY.md
+14
-0
plugins/history_plugin/history_plugin.cpp
plugins/history_plugin/history_plugin.cpp
+32
-17
plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp
...ry_plugin/include/eosio/history_plugin/history_plugin.hpp
+4
-16
plugins/producer_plugin/producer_plugin.cpp
plugins/producer_plugin/producer_plugin.cpp
+186
-76
programs/cleos/main.cpp
programs/cleos/main.cpp
+1
-6
未找到文件。
CMakeModules/EosioTester.cmake.in
浏览文件 @
2be92c1f
...
...
@@ -50,6 +50,7 @@ endif()
find_library(libbinaryen binaryen @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwasm WASM @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwast WAST @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwabt wabt @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libir IR @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libplatform Platform @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(liblogging Logging @CMAKE_INSTALL_FULL_LIBDIR@)
...
...
@@ -59,6 +60,13 @@ find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib)
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib)
find_library(libchainbase chainbase @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libbuiltins builtins @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libsecp256k1 secp256k1 @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(GMP_LIBRARIES NAMES libgmp.a gmp.lib gmp libgmp-10 mpir
HINTS ENV GMP_LIB_DIR
ENV GMP_DIR
PATH_SUFFIXES lib
DOC "Path to the GMP library"
)
macro(add_eosio_test test_name)
add_executable( ${test_name} ${ARGN} )
...
...
@@ -70,6 +78,7 @@ macro(add_eosio_test test_name)
${libbinaryen}
${libwast}
${libwasm}
${libwabt}
${libruntime}
${libplatform}
${libir}
...
...
@@ -79,6 +88,7 @@ macro(add_eosio_test test_name)
${liblogging}
${libchainbase}
${libbuiltins}
${GMP_LIBRARIES}
${libsecp256k1}
LLVMX86Disassembler
...
...
CMakeModules/EosioTesterBuild.cmake.in
浏览文件 @
2be92c1f
...
...
@@ -51,6 +51,7 @@ find_library(libbinaryen binaryen @CMAKE_BINARY_DIR@/externals/binaryen/lib)
find_library(libwasm WASM @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WASM)
find_library(libwast WAST @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WAST)
find_library(libir IR @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/IR)
find_library(libwabt wabt @CMAKE_BINARY_DIR@/libraries/wabt)
find_library(libplatform Platform @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Platform)
find_library(liblogging Logging @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Logging)
find_library(libruntime Runtime @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Runtime)
...
...
@@ -59,6 +60,13 @@ find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib)
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib)
find_library(libchainbase chainbase @CMAKE_BINARY_DIR@/libraries/chainbase)
find_library(libbuiltins builtins @CMAKE_BINARY_DIR@/libraries/builtins)
find_library(libsecp256k1 secp256k1 @CMAKE_BINARY_DIR@/libraries/fc/secp256k1)
find_library(GMP_LIBRARIES NAMES libgmp.a gmp.lib gmp libgmp-10 mpir
HINTS ENV GMP_LIB_DIR
ENV GMP_DIR
PATH_SUFFIXES lib
DOC "Path to the GMP library"
)
macro(add_eosio_test test_name)
add_executable( ${test_name} ${ARGN} )
...
...
@@ -70,6 +78,7 @@ macro(add_eosio_test test_name)
${libbinaryen}
${libwast}
${libwasm}
${libwabt}
${libruntime}
${libplatform}
${libir}
...
...
@@ -79,6 +88,7 @@ macro(add_eosio_test test_name)
${liblogging}
${libchainbase}
${libbuiltins}
${GMP_LIBRARIES}
${libsecp256k1}
LLVMX86Disassembler
...
...
libraries/CMakeLists.txt
浏览文件 @
2be92c1f
...
...
@@ -11,5 +11,6 @@ add_subdirectory( abi_generator )
#turn these off for now
set
(
BUILD_TESTS OFF CACHE BOOL
"Build GTest-based tests"
)
set
(
BUILD_TOOLS OFF CACHE BOOL
"Build wabt tools"
)
set
(
RUN_RE2C OFF CACHE BOOL
"Run re2c"
)
add_subdirectory
(
wabt
)
fc
@
4dc8375d
比较
8edb92dd
...
4dc8375d
Subproject commit
8edb92dd2310108b8eb66d010b84ca4fc9dce898
Subproject commit
4dc8375d7d3e02ab1177ab5c22835f75b45c845a
plugins/COMMUNITY.md
0 → 100644
浏览文件 @
2be92c1f
# Community Plugin List
This file contains a list of community authored plugins for
`nodeos`
, acting as a directory of the plugins that are available.
Third parties are encouraged to make pull requests to this file (
`develop`
branch please) in order to list new plugins.
| Description | URL |
| ----------- | --- |
| Watch for specific actions and send them to an HTTP URL | https://github.com/eosauthority/eosio-watcher-plugin |
| Kafka | https://github.com/TP-Lab/kafka_plugin |
## DISCLAIMER:
The fact that a plugin is listed in this file does not mean the plugin has been reviewed by this repository's maintainers. No warranties are made, i.e. you are at your own risk if you choose to use them.
plugins/history_plugin/history_plugin.cpp
浏览文件 @
2be92c1f
...
...
@@ -10,7 +10,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/signals2/connection.hpp>
namespace
eosio
{
namespace
eosio
{
using
namespace
chain
;
using
boost
::
signals2
::
scoped_connection
;
...
...
@@ -51,7 +51,7 @@ namespace eosio {
indexed_by
<
ordered_unique
<
tag
<
by_id
>
,
member
<
action_history_object
,
action_history_object
::
id_type
,
&
action_history_object
::
id
>>
,
ordered_unique
<
tag
<
by_action_sequence_num
>
,
member
<
action_history_object
,
uint64_t
,
&
action_history_object
::
action_sequence_num
>>
,
ordered_unique
<
tag
<
by_trx_id
>
,
ordered_unique
<
tag
<
by_trx_id
>
,
composite_key
<
action_history_object
,
member
<
action_history_object
,
transaction_id_type
,
&
action_history_object
::
trx_id
>
,
member
<
action_history_object
,
uint64_t
,
&
action_history_object
::
action_sequence_num
>
...
...
@@ -64,7 +64,7 @@ namespace eosio {
account_history_object
,
indexed_by
<
ordered_unique
<
tag
<
by_id
>
,
member
<
account_history_object
,
account_history_object
::
id_type
,
&
account_history_object
::
id
>>
,
ordered_unique
<
tag
<
by_account_action_seq
>
,
ordered_unique
<
tag
<
by_account_action_seq
>
,
composite_key
<
account_history_object
,
member
<
account_history_object
,
account_name
,
&
account_history_object
::
account
>
,
member
<
account_history_object
,
int32_t
,
&
account_history_object
::
account_sequence_num
>
...
...
@@ -213,7 +213,7 @@ namespace eosio {
uint64_t
asn
=
0
;
if
(
itr
!=
idx
.
begin
()
)
--
itr
;
if
(
itr
->
account
==
n
)
if
(
itr
->
account
==
n
)
asn
=
itr
->
account_sequence_num
+
1
;
//idump((n)(act.receipt.global_sequence)(asn));
...
...
@@ -268,7 +268,7 @@ namespace eosio {
aho
.
block_time
=
chain
.
pending_block_time
();
aho
.
trx_id
=
at
.
trx_id
;
});
auto
aset
=
account_set
(
at
);
for
(
auto
a
:
aset
)
{
record_account_action
(
a
,
at
);
...
...
@@ -366,7 +366,7 @@ namespace eosio {
namespace
history_apis
{
namespace
history_apis
{
read_only
::
get_actions_result
read_only
::
get_actions
(
const
read_only
::
get_actions_params
&
params
)
const
{
edump
((
params
));
auto
&
chain
=
history
->
chain_plug
->
chain
();
...
...
@@ -388,7 +388,7 @@ namespace eosio {
pos
=
itr
->
account_sequence_num
+
1
;
}
else
if
(
itr
!=
idx
.
begin
()
)
--
itr
;
if
(
itr
->
account
==
n
)
if
(
itr
->
account
==
n
)
pos
=
itr
->
account_sequence_num
+
1
;
}
...
...
@@ -440,13 +440,31 @@ namespace eosio {
read_only
::
get_transaction_result
read_only
::
get_transaction
(
const
read_only
::
get_transaction_params
&
p
)
const
{
auto
&
chain
=
history
->
chain_plug
->
chain
();
const
auto
abi_serializer_max_time
=
history
->
chain_plug
->
get_abi_serializer_max_time
();
auto
short_id
=
fc
::
variant
(
p
.
id
).
as_string
().
substr
(
0
,
8
);
transaction_id_type
input_id
;
auto
input_id_length
=
p
.
id
.
size
();
try
{
FC_ASSERT
(
input_id_length
<=
64
,
"hex string is too long to represent an actual transaction id"
);
FC_ASSERT
(
input_id_length
>=
8
,
"hex string representing transaction id should be at least 8 characters long to avoid excessive collisions"
);
input_id
=
transaction_id_type
(
p
.
id
);
}
EOS_RETHROW_EXCEPTIONS
(
transaction_id_type_exception
,
"Invalid transaction ID: ${transaction_id}"
,
(
"transaction_id"
,
p
.
id
))
auto
txn_id_matched
=
[
&
input_id
,
input_id_size
=
input_id_length
/
2
,
no_half_byte_at_end
=
(
input_id_length
%
2
==
0
)]
(
const
transaction_id_type
&
id
)
->
bool
// hex prefix comparison
{
bool
whole_byte_prefix_matches
=
memcmp
(
input_id
.
data
(),
id
.
data
(),
input_id_size
)
==
0
;
if
(
!
whole_byte_prefix_matches
||
no_half_byte_at_end
)
return
whole_byte_prefix_matches
;
// check if half byte at end of specified part of input_id matches
return
(
*
(
input_id
.
data
()
+
input_id_size
)
&
0xF0
)
==
(
*
(
id
.
data
()
+
input_id_size
)
&
0xF0
);
};
const
auto
&
db
=
chain
.
db
();
const
auto
&
idx
=
db
.
get_index
<
action_history_index
,
by_trx_id
>
();
auto
itr
=
idx
.
lower_bound
(
boost
::
make_tuple
(
p
.
id
)
);
auto
itr
=
idx
.
lower_bound
(
boost
::
make_tuple
(
input_id
)
);
bool
in_history
=
(
itr
!=
idx
.
end
()
&&
fc
::
variant
(
itr
->
trx_id
).
as_string
().
substr
(
0
,
8
)
==
short_id
);
bool
in_history
=
(
itr
!=
idx
.
end
()
&&
txn_id_matched
(
itr
->
trx_id
)
);
if
(
!
in_history
&&
!
p
.
block_num_hint
)
{
EOS_THROW
(
tx_not_found
,
"Transaction ${id} not found in history and no block hint was given"
,
(
"id"
,
p
.
id
));
...
...
@@ -454,12 +472,9 @@ namespace eosio {
get_transaction_result
result
;
if
(
in_history
)
{
result
.
id
=
p
.
id
;
result
.
last_irreversible_block
=
chain
.
last_irreversible_block_num
();
if
(
in_history
)
{
result
.
id
=
itr
->
trx_id
;
result
.
last_irreversible_block
=
chain
.
last_irreversible_block_num
();
result
.
block_num
=
itr
->
block_num
;
result
.
block_time
=
itr
->
block_time
;
...
...
@@ -509,7 +524,7 @@ namespace eosio {
if
(
receipt
.
trx
.
contains
<
packed_transaction
>
())
{
auto
&
pt
=
receipt
.
trx
.
get
<
packed_transaction
>
();
auto
mtrx
=
transaction_metadata
(
pt
);
if
(
fc
::
variant
(
mtrx
.
id
).
as_string
().
substr
(
0
,
8
)
==
short_id
)
{
if
(
txn_id_matched
(
mtrx
.
id
)
)
{
result
.
id
=
mtrx
.
id
;
result
.
last_irreversible_block
=
chain
.
last_irreversible_block_num
();
result
.
block_num
=
*
p
.
block_num_hint
;
...
...
@@ -522,7 +537,7 @@ namespace eosio {
}
}
else
{
auto
&
id
=
receipt
.
trx
.
get
<
transaction_id_type
>
();
if
(
fc
::
variant
(
id
).
as_string
().
substr
(
0
,
8
)
==
short_id
)
{
if
(
txn_id_matched
(
id
)
)
{
result
.
id
=
id
;
result
.
last_irreversible_block
=
chain
.
last_irreversible_block_num
();
result
.
block_num
=
*
p
.
block_num_hint
;
...
...
plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp
浏览文件 @
2be92c1f
...
...
@@ -30,18 +30,6 @@ class read_only {
:
history
(
history
)
{}
/*
struct get_transaction_params {
chain::transaction_id_type transaction_id;
};
struct get_transaction_results {
chain::transaction_id_type transaction_id;
fc::variant transaction;
};
get_transaction_results get_transaction(const get_transaction_params& params) const;
*/
struct
get_actions_params
{
chain
::
account_name
account_name
;
optional
<
int32_t
>
pos
;
/// a absolute sequence positon -1 is the end/last action
...
...
@@ -67,7 +55,7 @@ class read_only {
struct
get_transaction_params
{
transaction_id_type
id
;
string
id
;
optional
<
uint32_t
>
block_num_hint
;
};
...
...
@@ -81,7 +69,7 @@ class read_only {
};
get_transaction_result
get_transaction
(
const
get_transaction_params
&
)
const
;
...
...
@@ -120,13 +108,13 @@ class read_only {
/**
* This plugin tracks all actions and keys associated with a set of configured accounts. It enables
* wallets to paginate queries for history.
* wallets to paginate queries for history.
*
* An action will be included in the account's history if any of the following:
* - receiver
* - any account named in auth list
*
* A key will be linked to an account if the key is referneced in authorities of updateauth or newaccount
* A key will be linked to an account if the key is referneced in authorities of updateauth or newaccount
*/
class
history_plugin
:
public
plugin
<
history_plugin
>
{
public:
...
...
plugins/producer_plugin/producer_plugin.cpp
浏览文件 @
2be92c1f
...
...
@@ -49,6 +49,9 @@ namespace fc {
const
fc
::
string
logger_name
(
"producer_plugin"
);
fc
::
logger
_log
;
const
fc
::
string
trx_trace_logger_name
(
"transaction_tracing"
);
fc
::
logger
_trx_trace_log
;
namespace
eosio
{
static
appbase
::
abstract_plugin
&
_producer_plugin
=
app
().
register_plugin
<
producer_plugin
>
();
...
...
@@ -341,12 +344,32 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
auto
block_time
=
chain
.
pending_block_state
()
->
header
.
timestamp
.
to_time_point
();
auto
send_response
=
[
this
,
&
trx
,
&
next
](
const
fc
::
static_variant
<
fc
::
exception_ptr
,
transaction_trace_ptr
>&
response
)
{
auto
send_response
=
[
this
,
&
trx
,
&
chain
,
&
next
](
const
fc
::
static_variant
<
fc
::
exception_ptr
,
transaction_trace_ptr
>&
response
)
{
next
(
response
);
if
(
response
.
contains
<
fc
::
exception_ptr
>
())
{
_transaction_ack_channel
.
publish
(
std
::
pair
<
fc
::
exception_ptr
,
packed_transaction_ptr
>
(
response
.
get
<
fc
::
exception_ptr
>
(),
trx
));
if
(
_pending_block_mode
==
pending_block_mode
::
producing
)
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Block ${block num} for producer ${prod} is REJECTING tx: ${txid} : ${why} "
,
(
"block_num"
,
chain
.
head_block_num
()
+
1
)
(
"prod"
,
chain
.
pending_block_state
()
->
header
.
producer
)
(
"txid"
,
trx
->
id
())
(
"why"
,
response
.
get
<
fc
::
exception_ptr
>
()
->
what
()));
}
else
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Speculative execution is REJECTING tx: ${txid} : ${why} "
,
(
"txid"
,
trx
->
id
())
(
"why"
,
response
.
get
<
fc
::
exception_ptr
>
()
->
what
()));
}
}
else
{
_transaction_ack_channel
.
publish
(
std
::
pair
<
fc
::
exception_ptr
,
packed_transaction_ptr
>
(
nullptr
,
trx
));
if
(
_pending_block_mode
==
pending_block_mode
::
producing
)
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Block ${block num} for producer ${prod} is ACCEPTING tx: ${txid}"
,
(
"block_num"
,
chain
.
head_block_num
()
+
1
)
(
"prod"
,
chain
.
pending_block_state
()
->
header
.
producer
)
(
"txid"
,
trx
->
id
()));
}
else
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Speculative execution is ACCEPTING tx: ${txid}"
,
(
"txid"
,
trx
->
id
()));
}
}
};
...
...
@@ -373,6 +396,15 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
if
(
trace
->
except
)
{
if
(
failure_is_subjective
(
*
trace
->
except
,
deadline_is_subjective
))
{
_pending_incoming_transactions
.
emplace_back
(
trx
,
persist_until_expired
,
next
);
if
(
_pending_block_mode
==
pending_block_mode
::
producing
)
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Block ${block num} for producer ${prod} COULD NOT FIT, tx: ${txid} RETRYING "
,
(
"block_num"
,
chain
.
head_block_num
()
+
1
)
(
"prod"
,
chain
.
pending_block_state
()
->
header
.
producer
)
(
"txid"
,
trx
->
id
()));
}
else
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Speculative execution COULD NOT FIT tx: ${txid} RETRYING"
,
(
"txid"
,
trx
->
id
()));
}
}
else
{
auto
e_ptr
=
trace
->
except
->
dynamic_copy_exception
();
send_response
(
e_ptr
);
...
...
@@ -648,8 +680,13 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_
void
producer_plugin
::
plugin_startup
()
{
try
{
if
(
fc
::
get_logger_map
().
find
(
logger_name
)
!=
fc
::
get_logger_map
().
end
())
{
_log
=
fc
::
get_logger_map
()[
logger_name
];
auto
&
logger_map
=
fc
::
get_logger_map
();
if
(
logger_map
.
find
(
logger_name
)
!=
logger_map
.
end
())
{
_log
=
logger_map
[
logger_name
];
}
if
(
logger_map
.
find
(
trx_trace_logger_name
)
!=
logger_map
.
end
())
{
_trx_trace_log
=
logger_map
[
trx_trace_logger_name
];
}
ilog
(
"producer plugin: plugin_startup() begin"
);
...
...
@@ -983,8 +1020,29 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
// remove all persisted transactions that have now expired
auto
&
persisted_by_id
=
_persistent_transactions
.
get
<
by_id
>
();
auto
&
persisted_by_expiry
=
_persistent_transactions
.
get
<
by_expiry
>
();
while
(
!
persisted_by_expiry
.
empty
()
&&
persisted_by_expiry
.
begin
()
->
expiry
<=
pbs
->
header
.
timestamp
.
to_time_point
())
{
persisted_by_expiry
.
erase
(
persisted_by_expiry
.
begin
());
if
(
!
persisted_by_expiry
.
empty
())
{
int
num_expired_persistent
=
0
;
int
orig_count
=
_persistent_transactions
.
size
();
while
(
!
persisted_by_expiry
.
empty
()
&&
persisted_by_expiry
.
begin
()
->
expiry
<=
pbs
->
header
.
timestamp
.
to_time_point
())
{
auto
const
&
txid
=
persisted_by_expiry
.
begin
()
->
trx_id
;
if
(
_pending_block_mode
==
pending_block_mode
::
producing
)
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Block ${block num} for producer ${prod} is EXPIRING PERSISTED tx: ${txid}"
,
(
"block_num"
,
chain
.
head_block_num
()
+
1
)
(
"prod"
,
chain
.
pending_block_state
()
->
header
.
producer
)
(
"txid"
,
txid
));
}
else
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Speculative execution is EXPIRING PERSISTED tx: ${txid}"
,
(
"txid"
,
txid
));
}
persisted_by_expiry
.
erase
(
persisted_by_expiry
.
begin
());
num_expired_persistent
++
;
}
fc_dlog
(
_log
,
"Processed ${n} persisted transactions, Expired ${expired}"
,
(
"n"
,
orig_count
)
(
"expired"
,
num_expired_persistent
));
}
try
{
...
...
@@ -1015,6 +1073,10 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
for
(
auto
&
trx
:
unapplied_trxs
)
{
auto
category
=
calculate_transaction_category
(
trx
);
if
(
category
==
tx_category
::
EXPIRED
||
(
category
==
tx_category
::
UNEXPIRED_UNPERSISTED
&&
_producers
.
empty
()))
{
if
(
!
_producers
.
empty
())
{
fc_dlog
(
_trx_trace_log
,
"[TRX_TRACE] Node with producers configured is dropping an EXPIRED transaction that was PREVIOUSLY ACCEPTED : ${txid}"
,
(
"txid"
,
trx
->
id
));
}
chain
.
drop_unapplied_transaction
(
trx
);
}
else
if
(
category
==
tx_category
::
PERSISTED
||
(
category
==
tx_category
::
UNEXPIRED_UNPERSISTED
&&
_pending_block_mode
==
pending_block_mode
::
producing
))
{
apply_trxs
.
emplace_back
(
std
::
move
(
trx
));
...
...
@@ -1022,33 +1084,50 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
}
}
for
(
const
auto
&
trx
:
apply_trxs
)
{
if
(
block_time
<=
fc
::
time_point
::
now
())
exhausted
=
true
;
if
(
exhausted
)
{
break
;
}
if
(
!
apply_trxs
.
empty
())
{
int
num_applied
=
0
;
int
num_failed
=
0
;
int
num_processed
=
0
;
try
{
auto
deadline
=
fc
::
time_point
::
now
()
+
fc
::
milliseconds
(
_max_transaction_time_ms
);
bool
deadline_is_subjective
=
false
;
if
(
_max_transaction_time_ms
<
0
||
(
_pending_block_mode
==
pending_block_mode
::
producing
&&
block_time
<
deadline
))
{
deadline_is_subjective
=
true
;
deadline
=
block_time
;
for
(
const
auto
&
trx
:
apply_trxs
)
{
if
(
block_time
<=
fc
::
time_point
::
now
())
exhausted
=
true
;
if
(
exhausted
)
{
break
;
}
auto
trace
=
chain
.
push_transaction
(
trx
,
deadline
);
if
(
trace
->
except
)
{
if
(
failure_is_subjective
(
*
trace
->
except
,
deadline_is_subjective
))
{
exhausted
=
true
;
num_processed
++
;
try
{
auto
deadline
=
fc
::
time_point
::
now
()
+
fc
::
milliseconds
(
_max_transaction_time_ms
);
bool
deadline_is_subjective
=
false
;
if
(
_max_transaction_time_ms
<
0
||
(
_pending_block_mode
==
pending_block_mode
::
producing
&&
block_time
<
deadline
))
{
deadline_is_subjective
=
true
;
deadline
=
block_time
;
}
auto
trace
=
chain
.
push_transaction
(
trx
,
deadline
);
if
(
trace
->
except
)
{
if
(
failure_is_subjective
(
*
trace
->
except
,
deadline_is_subjective
))
{
exhausted
=
true
;
}
else
{
// this failed our configured maximum transaction time, we don't want to replay it
chain
.
drop_unapplied_transaction
(
trx
);
num_failed
++
;
}
}
else
{
// this failed our configured maximum transaction time, we don't want to replay it
chain
.
drop_unapplied_transaction
(
trx
);
num_applied
++
;
}
}
}
catch
(
const
guard_exception
&
e
)
{
app
().
get_plugin
<
chain_plugin
>
().
handle_guard_exception
(
e
);
return
start_block_result
::
failed
;
}
FC_LOG_AND_DROP
();
}
catch
(
const
guard_exception
&
e
)
{
app
().
get_plugin
<
chain_plugin
>
().
handle_guard_exception
(
e
);
return
start_block_result
::
failed
;
}
FC_LOG_AND_DROP
();
}
fc_dlog
(
_log
,
"Processed ${m} of ${n} previously applied transactions, Applied ${applied}, Failed/Dropped ${failed}"
,
(
"m"
,
num_processed
)
(
"n"
,
apply_trxs
.
size
())
(
"applied"
,
num_applied
)
(
"failed"
,
num_failed
));
}
}
...
...
@@ -1056,61 +1135,88 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
auto
&
blacklist_by_id
=
_blacklisted_transactions
.
get
<
by_id
>
();
auto
&
blacklist_by_expiry
=
_blacklisted_transactions
.
get
<
by_expiry
>
();
auto
now
=
fc
::
time_point
::
now
();
while
(
!
blacklist_by_expiry
.
empty
()
&&
blacklist_by_expiry
.
begin
()
->
expiry
<=
now
)
{
blacklist_by_expiry
.
erase
(
blacklist_by_expiry
.
begin
());
if
(
!
blacklist_by_expiry
.
empty
())
{
int
num_expired
=
0
;
int
orig_count
=
_blacklisted_transactions
.
size
();
while
(
!
blacklist_by_expiry
.
empty
()
&&
blacklist_by_expiry
.
begin
()
->
expiry
<=
now
)
{
blacklist_by_expiry
.
erase
(
blacklist_by_expiry
.
begin
());
num_expired
++
;
}
fc_dlog
(
_log
,
"Processed ${n} blacklisted transactions, Expired ${expired}"
,
(
"n"
,
orig_count
)
(
"expired"
,
num_expired
));
}
auto
scheduled_trxs
=
chain
.
get_scheduled_transactions
();
if
(
!
scheduled_trxs
.
empty
())
{
int
num_applied
=
0
;
int
num_failed
=
0
;
int
num_processed
=
0
;
for
(
const
auto
&
trx
:
scheduled_trxs
)
{
if
(
block_time
<=
fc
::
time_point
::
now
())
exhausted
=
true
;
if
(
exhausted
)
{
break
;
}
for
(
const
auto
&
trx
:
scheduled_trxs
)
{
if
(
block_time
<=
fc
::
time_point
::
now
())
exhausted
=
true
;
if
(
exhausted
)
{
break
;
}
// configurable ratio of incoming txns vs deferred txns
while
(
_incoming_trx_weight
>=
1.0
&&
orig_pending_txn_size
&&
_pending_incoming_transactions
.
size
())
{
auto
e
=
_pending_incoming_transactions
.
front
();
_pending_incoming_transactions
.
pop_front
();
--
orig_pending_txn_size
;
_incoming_trx_weight
-=
1.0
;
on_incoming_transaction_async
(
std
::
get
<
0
>
(
e
),
std
::
get
<
1
>
(
e
),
std
::
get
<
2
>
(
e
));
}
num_processed
++
;
if
(
block_time
<=
fc
::
time_point
::
now
())
{
exhausted
=
true
;
break
;
}
// configurable ratio of incoming txns vs deferred txns
while
(
_incoming_trx_weight
>=
1.0
&&
orig_pending_txn_size
&&
_pending_incoming_transactions
.
size
())
{
auto
e
=
_pending_incoming_transactions
.
front
();
_pending_incoming_transactions
.
pop_front
();
--
orig_pending_txn_size
;
_incoming_trx_weight
-=
1.0
;
on_incoming_transaction_async
(
std
::
get
<
0
>
(
e
),
std
::
get
<
1
>
(
e
),
std
::
get
<
2
>
(
e
));
}
if
(
blacklist_by_id
.
find
(
trx
)
!=
blacklist_by_id
.
end
())
{
continue
;
}
if
(
block_time
<=
fc
::
time_point
::
now
())
{
exhausted
=
true
;
break
;
}
try
{
auto
deadline
=
fc
::
time_point
::
now
()
+
fc
::
milliseconds
(
_max_transaction_time_ms
);
bool
deadline_is_subjective
=
false
;
if
(
_max_transaction_time_ms
<
0
||
(
_pending_block_mode
==
pending_block_mode
::
producing
&&
block_time
<
deadline
))
{
deadline_is_subjective
=
true
;
deadline
=
block_time
;
if
(
blacklist_by_id
.
find
(
trx
)
!=
blacklist_by_id
.
end
())
{
continue
;
}
auto
trace
=
chain
.
push_scheduled_transaction
(
trx
,
deadline
);
if
(
trace
->
except
)
{
if
(
failure_is_subjective
(
*
trace
->
except
,
deadline_is_subjective
))
{
exhausted
=
true
;
try
{
auto
deadline
=
fc
::
time_point
::
now
()
+
fc
::
milliseconds
(
_max_transaction_time_ms
);
bool
deadline_is_subjective
=
false
;
if
(
_max_transaction_time_ms
<
0
||
(
_pending_block_mode
==
pending_block_mode
::
producing
&&
block_time
<
deadline
))
{
deadline_is_subjective
=
true
;
deadline
=
block_time
;
}
auto
trace
=
chain
.
push_scheduled_transaction
(
trx
,
deadline
);
if
(
trace
->
except
)
{
if
(
failure_is_subjective
(
*
trace
->
except
,
deadline_is_subjective
))
{
exhausted
=
true
;
}
else
{
auto
expiration
=
fc
::
time_point
::
now
()
+
fc
::
seconds
(
chain
.
get_global_properties
().
configuration
.
deferred_trx_expiration_window
);
// this failed our configured maximum transaction time, we don't want to replay it add it to a blacklist
_blacklisted_transactions
.
insert
(
transaction_id_with_expiry
{
trx
,
expiration
});
num_failed
++
;
}
}
else
{
auto
expiration
=
fc
::
time_point
::
now
()
+
fc
::
seconds
(
chain
.
get_global_properties
().
configuration
.
deferred_trx_expiration_window
);
// this failed our configured maximum transaction time, we don't want to replay it add it to a blacklist
_blacklisted_transactions
.
insert
(
transaction_id_with_expiry
{
trx
,
expiration
});
num_applied
++
;
}
}
}
catch
(
const
guard_exception
&
e
)
{
app
().
get_plugin
<
chain_plugin
>
().
handle_guard_exception
(
e
);
return
start_block_result
::
failed
;
}
FC_LOG_AND_DROP
();
}
catch
(
const
guard_exception
&
e
)
{
app
().
get_plugin
<
chain_plugin
>
().
handle_guard_exception
(
e
);
return
start_block_result
::
failed
;
}
FC_LOG_AND_DROP
();
_incoming_trx_weight
+=
_incoming_defer_ratio
;
if
(
!
orig_pending_txn_size
)
_incoming_trx_weight
=
0.0
;
}
fc_dlog
(
_log
,
"Processed ${m} of ${n} scheduled transactions, Applied ${applied}, Failed/Dropped ${failed}"
,
(
"m"
,
num_processed
)
(
"n"
,
scheduled_trxs
.
size
())
(
"applied"
,
num_applied
)
(
"failed"
,
num_failed
));
_incoming_trx_weight
+=
_incoming_defer_ratio
;
if
(
!
orig_pending_txn_size
)
_incoming_trx_weight
=
0.0
;
}
}
...
...
@@ -1119,12 +1225,16 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
}
else
{
// attempt to apply any pending incoming transactions
_incoming_trx_weight
=
0.0
;
while
(
orig_pending_txn_size
&&
_pending_incoming_transactions
.
size
())
{
auto
e
=
_pending_incoming_transactions
.
front
();
_pending_incoming_transactions
.
pop_front
();
--
orig_pending_txn_size
;
on_incoming_transaction_async
(
std
::
get
<
0
>
(
e
),
std
::
get
<
1
>
(
e
),
std
::
get
<
2
>
(
e
));
if
(
block_time
<=
fc
::
time_point
::
now
())
return
start_block_result
::
exhausted
;
if
(
!
_pending_incoming_transactions
.
empty
())
{
fc_dlog
(
_log
,
"Processing ${n} pending transactions"
);
while
(
orig_pending_txn_size
&&
_pending_incoming_transactions
.
size
())
{
auto
e
=
_pending_incoming_transactions
.
front
();
_pending_incoming_transactions
.
pop_front
();
--
orig_pending_txn_size
;
on_incoming_transaction_async
(
std
::
get
<
0
>
(
e
),
std
::
get
<
1
>
(
e
),
std
::
get
<
2
>
(
e
));
if
(
block_time
<=
fc
::
time_point
::
now
())
return
start_block_result
::
exhausted
;
}
}
return
start_block_result
::
succeeded
;
}
...
...
programs/cleos/main.cpp
浏览文件 @
2be92c1f
...
...
@@ -2133,12 +2133,7 @@ int main( int argc, char** argv ) {
getTransaction
->
add_option
(
"id"
,
transaction_id_str
,
localized
(
"ID of the transaction to retrieve"
))
->
required
();
getTransaction
->
add_option
(
"-b,--block-hint"
,
block_num_hint
,
localized
(
"the block number this transaction may be in"
)
);
getTransaction
->
set_callback
([
&
]
{
transaction_id_type
transaction_id
;
try
{
while
(
transaction_id_str
.
size
()
<
64
)
transaction_id_str
+=
"0"
;
transaction_id
=
transaction_id_type
(
transaction_id_str
);
}
EOS_RETHROW_EXCEPTIONS
(
transaction_id_type_exception
,
"Invalid transaction ID: ${transaction_id}"
,
(
"transaction_id"
,
transaction_id_str
))
auto
arg
=
fc
::
mutable_variant_object
(
"id"
,
transaction_id
);
auto
arg
=
fc
::
mutable_variant_object
(
"id"
,
transaction_id_str
);
if
(
block_num_hint
>
0
)
{
arg
=
arg
(
"block_num_hint"
,
block_num_hint
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录