Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Optimize transaction signature recovery #6471

Merged
merged 23 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3095d85
Switch interface from packed_transaction_ptr to transaction_metadata_ptr
heifner Dec 12, 2018
49a9c55
Thread pool does not need to be optional
heifner Dec 12, 2018
4a4a80a
Add transaction_metadata create_signing_keys_future method
heifner Dec 12, 2018
f71d490
Start transaction signature earily in thread pool
heifner Dec 12, 2018
96fb1e5
Refactor packed_transaction for better encapsulation
heifner Dec 13, 2018
20ffa70
Add transaction_metadata create_signing_keys_future method
heifner Dec 12, 2018
f64da40
Start transaction signature earily in thread pool
heifner Dec 12, 2018
22ab63c
Update txn_test_gen_plugin to overlap transaction submit @taokayan
heifner Dec 14, 2018
64537c5
Remove redundant signing_keys check
heifner Dec 17, 2018
ca8e5bc
Add deadline to key recovery
heifner Dec 17, 2018
b8a5659
Modify producer_plugin to have its own thead_pool instead of using ch…
heifner Dec 17, 2018
957db7f
Move thread_pool join/stop to plugin shutdown so that they are joined…
heifner Dec 17, 2018
9270c9c
Fix signature future deadline from starting too early
heifner Dec 17, 2018
3e733f5
Fix overflow of deadline and deadline check
heifner Dec 17, 2018
6e9b441
initial setup of billing CPU for signatures recovered earlier
arhag Dec 18, 2018
2b6a88a
Make recovery cache non-thread local and guard by mutex
heifner Dec 18, 2018
94ad2d1
Calculate cpu usage of signature recovery
heifner Dec 18, 2018
48bf2d4
Add signature-cpu-billable-pct option to chain_plugin
heifner Dec 18, 2018
1ecb7cc
Add missing include of mutex
heifner Dec 18, 2018
75587d0
Assert signature-cpu-billable-pct is 0-100
heifner Dec 18, 2018
21d20a8
Fix capture of cpu_usage. move flat_set<public_key_type> into attribute
heifner Dec 18, 2018
058d4ac
clear recovered_pub_keys to preserve previous behaviour
heifner Dec 18, 2018
1c8640b
Add move into tuple creation
heifner Dec 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions libraries/chain/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ flat_set<public_key_type> transaction::get_signature_keys( const vector<signatur

constexpr size_t recovery_cache_size = 1000;
static thread_local recovery_cache_type recovery_cache;
fc::time_point start = fc::time_point::now();
const digest_type digest = sig_digest(chain_id, cfd);

flat_set<public_key_type> recovered_pub_keys;
for(const signature_type& sig : signatures) {
auto now = fc::time_point::now();
EOS_ASSERT( start + now <= deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long",
("now", now)("deadline", deadline)("start", start) );
EOS_ASSERT( fc::time_point::now() < deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long",
arhag marked this conversation as resolved.
Show resolved Hide resolved
("now", fc::time_point::now())("deadline", deadline) );
public_key_type recov;
recovery_cache_type::index<by_sig>::type::iterator it = recovery_cache.get<by_sig>().find( sig );
const auto& tid = id();
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/transaction_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void transaction_metadata::create_signing_keys_future( const transaction_metadat

std::weak_ptr<transaction_metadata> mtrx_wp = mtrx;
mtrx->signing_keys_future = async_thread_pool( thread_pool, [timelimit, chain_id, mtrx_wp]() {
fc::time_point deadline = fc::time_point::now() + timelimit;
fc::time_point deadline = timelimit == fc::microseconds::maximum() ?
fc::time_point::maximum() : fc::time_point::now() + timelimit;
auto mtrx = mtrx_wp.lock();
return mtrx ?
std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id, deadline ) ) :
Expand Down