Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testnet X-Mas Sneak Preview Release #1489

Merged
merged 158 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
7d44c3a
initial fix for verify_account_authority
jmjatlanta Oct 16, 2018
7dc0de7
Capture Ctrl+C in cli_wallet when not in daemon mode #1193
cogutvalera Oct 19, 2018
824ed4f
improved way to verify account and keys
jmjatlanta Oct 19, 2018
48fa400
Removed unneeded method definition
jmjatlanta Oct 19, 2018
0eebc1e
Merge pull request #1232 from cogutvalera/issue_1193
pmconrad Oct 20, 2018
c2b63f5
Added multiple signatures to test
jmjatlanta Oct 23, 2018
5db31f5
shorten line length
jmjatlanta Oct 23, 2018
7e4e033
add test for multisig
jmjatlanta Oct 23, 2018
e03d329
improved multisig test
jmjatlanta Oct 23, 2018
673ac2b
fix short line
jmjatlanta Oct 23, 2018
f523ad6
moved tests, fixed comments
jmjatlanta Oct 23, 2018
b078310
clarify comment
jmjatlanta Oct 24, 2018
8d09a46
Merge pull request #1395 from bitshares/release
oxarbitrage Oct 24, 2018
2e15e77
Merge pull request #1384 from bitshares/jmj_1366
pmconrad Oct 25, 2018
c293b40
bump fc and fix node
oxarbitrage Oct 26, 2018
3fb6c44
try to fix dockercloud
oxarbitrage Oct 28, 2018
3e1de10
remove DGRAPHENE_DISABLE_UNITY_BUILD
oxarbitrage Oct 28, 2018
2ed2bc9
Merge pull request #1405 from oxarbitrage/fix_rand_bytes
oxarbitrage Oct 29, 2018
c6ca2c8
Initial HTLC commit
jmjatlanta Sep 5, 2018
bab9fb7
Fix compile errors
jmjatlanta Sep 5, 2018
81996c4
Fix tests
jmjatlanta Sep 5, 2018
3afa87e
added signature test
jmjatlanta Sep 7, 2018
6e960ef
Intermediate commit for adding htlc to wallet api
jmjatlanta Sep 14, 2018
f470aa3
Improvements to cli_wallet test
jmjatlanta Sep 16, 2018
b5510ac
Added update_htlc to wallet api
jmjatlanta Sep 17, 2018
40d22aa
Removed debugging code
jmjatlanta Sep 17, 2018
eb1225e
add htlc to switch-case
jmjatlanta Sep 27, 2018
d367c2c
Change method names to match spec
jmjatlanta Oct 12, 2018
6ded688
Boost 1.58 compatibility
jmjatlanta Oct 13, 2018
9a502a3
add get_typename for enum
jmjatlanta Oct 15, 2018
dc82610
Addition of SHA1 and committee parameters
jmjatlanta Oct 15, 2018
49822e1
Refactor committee parameters
jmjatlanta Oct 24, 2018
3ac8323
Test cleanup. Hardfork protection still needed.
jmjatlanta Oct 24, 2018
a30df56
modified name of optional committee parameters
jmjatlanta Oct 26, 2018
b5dae57
beginning of hardfork protection
jmjatlanta Oct 26, 2018
bc48b36
Code cleanup and comments
jmjatlanta Oct 29, 2018
5c5a0d7
Beginning of fee implementation
jmjatlanta Oct 29, 2018
ac29e84
committee fee flexibility and bug fixes
jmjatlanta Oct 30, 2018
50f6584
Calculate fees based on # days
jmjatlanta Oct 30, 2018
ca884e2
Change description of delayed_node option
HarukaMa Oct 30, 2018
9237a71
Bump fc after re-improving compile time resource usage
pmconrad Nov 5, 2018
59105fa
Merge pull request #1415 from bitshares/release
oxarbitrage Nov 5, 2018
55aa07e
Skip tests if compile time is too long
pmconrad Nov 7, 2018
1695076
Bump fc again for fc#88
pmconrad Nov 7, 2018
3aa689e
Fixed travis.yml
pmconrad Nov 7, 2018
e8faf81
Added hardfork protection to proposal_create
jmjatlanta Nov 7, 2018
2c7f7f9
Removed debugging code
jmjatlanta Nov 7, 2018
082f0ef
Merge pull request #1417 from bitshares/bump_fc
pmconrad Nov 8, 2018
15e9037
refactor es_objects to use templates
oxarbitrage Nov 9, 2018
86fb006
Fix warning
nathanielhourt Nov 2, 2018
3d24032
Fix build errors
nathanielhourt Oct 26, 2018
9952121
Include smart_ref_impl from fork_database.cpp
nathanielhourt Nov 7, 2018
32d8d08
Merge pull request #1426 from oxarbitrage/fix-build-errors
oxarbitrage Nov 10, 2018
6225ee4
remove not needed include
oxarbitrage Nov 10, 2018
81c2769
change variable name
oxarbitrage Nov 10, 2018
5d1c15c
add last_vote_time
oxarbitrage Nov 26, 2018
3619a1c
Merge pull request #1446 from bitshares/release
jmjatlanta Nov 26, 2018
5909b13
add option elasticsearch-start-es-after-block
oxarbitrage Nov 28, 2018
ee4cc4b
move start_es_after_block check more deeper
oxarbitrage Nov 28, 2018
5e24f65
change last_vote_time to do_apply
oxarbitrage Nov 30, 2018
5688e7b
minor spacing changes
oxarbitrage Nov 30, 2018
8fb3dd0
Merge pull request #1460 from bitshares/release
pmconrad Dec 3, 2018
d8323d4
Introduced direct_index
pmconrad Dec 2, 2018
6d79167
Use new derived_index for some
pmconrad Dec 2, 2018
c367219
Fixed casts
pmconrad Dec 2, 2018
bcbf5d3
Fixed wrong reserve() calls
pmconrad Dec 2, 2018
59db3f5
Do not ignore exceptions while reading object_database
pmconrad Dec 2, 2018
91eb971
Merge pull request #1461 from bitshares/fixes
pmconrad Dec 4, 2018
8999eac
Removed unused _unlinked_index
pmconrad Oct 8, 2018
6849984
Fixed fork_db handling in pop_block
pmconrad Oct 8, 2018
73d8b08
Added --revalidate-blockchain
pmconrad Oct 7, 2018
34baaed
Use externally provided skip flags for replay
pmconrad Oct 11, 2018
bd8ed04
Removed skip_authority flag because its used interchangably with skip…
pmconrad Oct 11, 2018
56dfa9c
Removed unused skip_validate flag introduced in #dca5c95 2016-01-04
pmconrad Oct 11, 2018
1a78e1b
Add warning when revalidating with checkpoints
pmconrad Oct 11, 2018
cf2d6e7
Make distinction between skip_flag cases clearer
pmconrad Oct 12, 2018
d644f20
Prove that irrelevant signature detection depends on sorting order
pmconrad Oct 26, 2018
0c4c133
Fixed typo
pmconrad Oct 25, 2018
e5ba271
Parallelize loading/saving object_database
pmconrad Sep 27, 2018
033ddea
Introduce precomputable_transaction, and clearable_block in tests
pmconrad Oct 4, 2018
d2d8b29
Preprocess blocks + transactions in parallel, working version
pmconrad Sep 27, 2018
9946bde
Get rid of possibly uninitialized local variable
pmconrad Oct 5, 2018
cb2244f
Changed push_transaction to accept precomputable_transaction instead …
pmconrad Oct 8, 2018
883ec6a
Avoid one level of indirection on precompute block
pmconrad Oct 11, 2018
d032890
Make pubkey comparator generally available
pmconrad Oct 11, 2018
2c01109
Address some review comments
pmconrad Nov 7, 2018
c4b584c
direct_index: Added clarifying comment, ensure that object ID is not …
pmconrad Dec 9, 2018
9117c85
Added unit test for direct_index
pmconrad Dec 9, 2018
68982ca
Added base16 to htlc hash for cli wallet
jmjatlanta Dec 11, 2018
44d4134
fix for redeem
jmjatlanta Dec 11, 2018
13926f5
Added details to history for HTLC create and redeem
jmjatlanta Dec 12, 2018
5103f7e
clearer text in account history
jmjatlanta Dec 12, 2018
2e5d74f
Adjust history lines
jmjatlanta Dec 13, 2018
d2dfa69
Modified wallet get_htlc to return pretty format
jmjatlanta Dec 13, 2018
4af8e6c
hash format fix
jmjatlanta Dec 13, 2018
5492797
Add pending info to HTLC in account history
jmjatlanta Dec 13, 2018
742f025
Fix htlc_prepare method signature
jmjatlanta Dec 13, 2018
b5b8dfc
Add virtual op for refund
jmjatlanta Dec 13, 2018
fe24161
Make refund appear in proper account
jmjatlanta Dec 13, 2018
956f1c9
bump database
oxarbitrage Dec 14, 2018
1fc6dc1
Merge pull request #1410 from HarukaMa/patch-1
pmconrad Dec 14, 2018
1471c05
Merge pull request #1360 from bitshares/performance_opt
pmconrad Dec 14, 2018
115ed51
clarify proxy vote test times
oxarbitrage Dec 14, 2018
4a3f45b
Fixed code smell
pmconrad Dec 14, 2018
0171861
Merge branch 'develop' into issue1393
oxarbitrage Dec 15, 2018
27e2e75
Code cleanup pmconrad suggestions
jmjatlanta Dec 15, 2018
dd6c7fc
Properly initialize inner vectors, support nested modifications
pmconrad Dec 15, 2018
69c4011
Removed obsolete hardfork code to avoid problems with next commit
pmconrad Dec 15, 2018
2409104
Added direct_index-like replacement for by_account_asset subindex
pmconrad Dec 15, 2018
e563899
cleanup, consistent variable naming
jmjatlanta Dec 15, 2018
6239564
More consistent naming
jmjatlanta Dec 15, 2018
e914a37
Switch htlc object from implementation to protocol
jmjatlanta Dec 15, 2018
c808e61
Move committee parameter hardfork validation to visitor
jmjatlanta Dec 15, 2018
ae1cbfa
Merge pull request #1449 from oxarbitrage/issue1393
oxarbitrage Dec 16, 2018
fe4c4e9
add link to hackthedex.io to README
oxarbitrage Dec 17, 2018
fea41d7
htlc_prepare is now htlc_create, plus start of fee testing (wip)
jmjatlanta Dec 17, 2018
e2e571a
1 day and 1kb mins on fees
jmjatlanta Dec 17, 2018
5c7a9e8
still trying to get fees working
jmjatlanta Dec 18, 2018
1e8ccab
change adaptor response to be mutable_variant_object
oxarbitrage Dec 18, 2018
9dbc880
Merge pull request #1470 from bitshares/oxarbitrage-patch-3
oxarbitrage Dec 18, 2018
e5978ca
Merge pull request #1474 from bitshares/release
oxarbitrage Dec 18, 2018
a2192ec
fix htlc fee tests
jmjatlanta Dec 19, 2018
f7d7f5c
Making fees work with htlc tests
jmjatlanta Dec 19, 2018
96ec5f3
move hash_algoritm enum plus misc
jmjatlanta Dec 19, 2018
5c7fd22
Merge pull request #1429 from oxarbitrage/es_objects_templates
oxarbitrage Dec 19, 2018
d3ba372
Merge pull request #1462 from bitshares/direct_index
pmconrad Dec 19, 2018
0244ff5
Added missing (?) includes
pmconrad Dec 19, 2018
5ffa2a0
Get rid of floating point calculations
pmconrad Dec 19, 2018
145d790
Added hf protection for htlc_operations in proposals
pmconrad Dec 19, 2018
e255f39
Validate that preimage hash length matches algorithm hash length
pmconrad Dec 19, 2018
da6fbef
Refactoring: use a static_variant instead of separate enum + hash vector
pmconrad Dec 19, 2018
f4dcd9b
Fix for node crash #1479
pmconrad Dec 20, 2018
d3cab53
Fixed hf date
pmconrad Dec 20, 2018
80e9664
Revert fix attempt
pmconrad Dec 20, 2018
793220e
added extend test + smaller misc
jmjatlanta Dec 20, 2018
57248da
handle fee multiplication overflow
jmjatlanta Dec 20, 2018
e8172e9
added messages to asserts
jmjatlanta Dec 20, 2018
9c7f693
Different approach - detect nested proposal_update with invalid id an…
pmconrad Dec 20, 2018
2f08968
virtual op for notifications
jmjatlanta Dec 21, 2018
062613c
Catch nested delete as well
pmconrad Dec 21, 2018
46daa67
Bump db version
pmconrad Dec 21, 2018
36cb35c
Switched impossible authority to null account
pmconrad Dec 21, 2018
5cb908e
Bumped hf date by 24 hours
pmconrad Dec 21, 2018
b0ada12
Log as warning not info
pmconrad Dec 21, 2018
35bc344
Added self-deletion test case
pmconrad Dec 21, 2018
3c76228
Merge pull request #1458 from oxarbitrage/issue1455
oxarbitrage Dec 21, 2018
3eb2cfa
Merge pull request #1480 from bitshares/issue_1479
pmconrad Dec 21, 2018
bc85e17
Resolve conflicts release/develop
pmconrad Dec 21, 2018
205dc88
Merge pull request #1486 from pmconrad/resolve_conflicts
pmconrad Dec 21, 2018
22ea563
More overflow protection + wording changes
jmjatlanta Dec 21, 2018
8e77fff
fix bug in fee calculation
jmjatlanta Dec 21, 2018
1195aef
Merge pull request #1370 from jmjatlanta/htlc2
pmconrad Dec 21, 2018
6809b8d
Merge pull request #1487 from bitshares/develop
pmconrad Dec 21, 2018
19375f7
Fixed build error
pmconrad Dec 21, 2018
a9606ef
Merge pull request #1488 from pmconrad/fix_hardfork_branch
pmconrad Dec 21, 2018
f4f0e22
Merge remote-tracking branch 'origin/hardfork' into testnet_release
pmconrad Dec 21, 2018
c4c8e41
Set testnet hardfork date to 2018-12-21T20:00:00Z
pmconrad Dec 21, 2018
c5fa14d
Generalized testcase for testnet
pmconrad Dec 21, 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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ script:
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON .
- 'which build-wrapper-linux-x86-64 && build-wrapper-linux-x86-64 --out-dir bw-output make -j 2 cli_wallet witness_node chain_test cli_test || make -j 2 cli_wallet witness_node chain_test cli_test'
- set -o pipefail
- '[ $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && touch _empty_cache || true'
- '[ -r _empty_cache ] || tests/chain_test 2>&1 | cat'
- '[ -r _empty_cache ] || tests/cli_test 2>&1 | cat'
- 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null'
- '( [ -r _empty_cache -o $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && echo "WARNING! Skipping sonar scanner due to time constraints!" ) || ( which sonar-scanner && sonar-scanner || true )'
- '[ ! -r _empty_cache ] || ( echo "Please restart with populated cache" && false )'
- '[ -r _empty_cache ] || ( which sonar-scanner && sonar-scanner || true )'
- '[ ! -r _empty_cache ] || ( echo "WARNING! Skipped some tests due to compile time! Please restart with populated cache." && false )'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Visit [BitShares.org](https://bitshares.org/) to learn about BitShares and join

Information for developers can be found in the [Bitshares Developer Portal](https://dev.bitshares.works/). Users interested in how bitshares works can go to the [BitShares Documentation](https://how.bitshares.works/) site.

For security issues and bug bounty program please visit [Hack the DEX](https://hackthedex.io).

Getting Started
---------------
Build instructions and additional documentation are available in the
Expand Down
13 changes: 7 additions & 6 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,18 @@ namespace graphene { namespace app {
}
}

void network_broadcast_api::broadcast_transaction(const signed_transaction& trx)
void network_broadcast_api::broadcast_transaction(const precomputable_transaction& trx)
{
trx.validate();
_app.chain_database()->precompute_parallel( trx ).wait();
_app.chain_database()->push_transaction(trx);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast_transaction(trx);
}

fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
fc::variant network_broadcast_api::broadcast_transaction_synchronous(const precomputable_transaction& trx)
{
fc::promise<fc::variant>::ptr prom( new fc::promise<fc::variant>() );
broadcast_transaction_with_callback( [=]( const fc::variant& v ){
broadcast_transaction_with_callback( [prom]( const fc::variant& v ){
prom->set_value(v);
}, trx );

Expand All @@ -179,14 +179,15 @@ namespace graphene { namespace app {

void network_broadcast_api::broadcast_block( const signed_block& b )
{
_app.chain_database()->precompute_parallel( b ).wait();
_app.chain_database()->push_block(b);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast( net::block_message( b ));
}

void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction& trx)
void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const precomputable_transaction& trx)
{
trx.validate();
_app.chain_database()->precompute_parallel( trx ).wait();
_callbacks[trx.id()] = cb;
_app.chain_database()->push_transaction(trx);
if( _app.p2p_node() != nullptr )
Expand Down
51 changes: 40 additions & 11 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <graphene/app/application.hpp>
#include <graphene/app/plugin.hpp>

#include <graphene/chain/db_with.hpp>
#include <graphene/chain/genesis_state.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/protocol/types.hpp>
Expand Down Expand Up @@ -379,12 +380,34 @@ void application_impl::startup()
_chain_db->enable_standby_votes_tracking( _options->at("enable-standby-votes-tracking").as<bool>() );
}

if( _options->count("replay-blockchain") )
if( _options->count("replay-blockchain") || _options->count("revalidate-blockchain") )
_chain_db->wipe( _data_dir / "blockchain", false );

try
{
_chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION );
// these flags are used in open() only, i. e. during replay
uint32_t skip;
if( _options->count("revalidate-blockchain") ) // see also handle_block()
{
if( !loaded_checkpoints.empty() )
wlog( "Warning - revalidate will not validate before last checkpoint" );
if( _options->count("force-validate") )
skip = graphene::chain::database::skip_nothing;
else
skip = graphene::chain::database::skip_transaction_signatures;
}
else // no revalidate, skip most checks
skip = graphene::chain::database::skip_witness_signature |
graphene::chain::database::skip_block_size_check |
graphene::chain::database::skip_merkle_check |
graphene::chain::database::skip_transaction_signatures |
graphene::chain::database::skip_transaction_dupe_check |
graphene::chain::database::skip_tapos_check |
graphene::chain::database::skip_witness_schedule_check;

graphene::chain::detail::with_skip_flags( *_chain_db, skip, [this,&initial_state] () {
_chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION );
});
}
catch( const fc::exception& e )
{
Expand Down Expand Up @@ -502,13 +525,17 @@ bool application_impl::handle_block(const graphene::net::block_message& blk_msg,
FC_ASSERT( (latency.count()/1000) > -5000, "Rejecting block with timestamp in the future" );

try {
// TODO: in the case where this block is valid but on a fork that's too old for us to switch to,
// you can help the network code out by throwing a block_older_than_undo_history exception.
// when the net code sees that, it will stop trying to push blocks from that chain, but
// leave that peer connected so that they can get sync blocks from us
bool result = _chain_db->push_block( blk_msg.block,
(_is_block_producer | _force_validate) ?
database::skip_nothing : database::skip_transaction_signatures );
const uint32_t skip = (_is_block_producer | _force_validate) ?
database::skip_nothing : database::skip_transaction_signatures;
bool result = valve.do_serial( [this,&blk_msg,skip] () {
_chain_db->precompute_parallel( blk_msg.block, skip ).wait();
}, [this,&blk_msg,skip] () {
// TODO: in the case where this block is valid but on a fork that's too old for us to switch to,
// you can help the network code out by throwing a block_older_than_undo_history exception.
// when the net code sees that, it will stop trying to push blocks from that chain, but
// leave that peer connected so that they can get sync blocks from us
return _chain_db->push_block( blk_msg.block, skip );
});

// the block was accepted, so we now know all of the transactions contained in the block
if (!sync_mode)
Expand Down Expand Up @@ -558,6 +585,7 @@ void application_impl::handle_transaction(const graphene::net::trx_message& tran
trx_count = 0;
}

_chain_db->precompute_parallel( transaction_message.trx ).wait();
_chain_db->push_transaction( transaction_message.trx );
} FC_CAPTURE_AND_RETHROW( (transaction_message) ) }

Expand Down Expand Up @@ -947,9 +975,10 @@ void application::set_program_options(boost::program_options::options_descriptio
"Path to create a Genesis State at. If a well-formed JSON file exists at the path, it will be parsed and any "
"missing fields in a Genesis State will be added, and any unknown fields will be removed. If no file or an "
"invalid file is found, it will be replaced with an example Genesis State.")
("replay-blockchain", "Rebuild object graph by replaying all blocks")
("replay-blockchain", "Rebuild object graph by replaying all blocks without validation")
("revalidate-blockchain", "Rebuild object graph by replaying all blocks with full validation")
("resync-blockchain", "Delete all blocks and re-sync with network from scratch")
("force-validate", "Force validation of all transactions")
("force-validate", "Force validation of all transactions during normal operation")
("genesis-timestamp", bpo::value<uint32_t>(),
"Replace timestamp from genesis.json with current time plus this many seconds (experts only!)")
;
Expand Down
4 changes: 4 additions & 0 deletions libraries/app/application_impl.hxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <fc/network/http/websocket.hpp>
#include <fc/thread/parallel.hpp>

#include <graphene/app/application.hpp>
#include <graphene/app/api_access.hpp>
#include <graphene/chain/genesis_state.hpp>
Expand Down Expand Up @@ -194,6 +196,8 @@ class application_impl : public net::node_delegate
std::map<string, std::shared_ptr<abstract_plugin>> _available_plugins;

bool _is_finished_syncing = false;
private:
fc::serial_valve valve;
};

}}} // namespace graphene namespace app namespace detail
69 changes: 39 additions & 30 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
map< pair<asset_id_type,asset_id_type>, std::function<void(const variant&)> > _market_subscriptions;
graphene::chain::database& _db;
const application_options* _app_options = nullptr;

};

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -548,6 +547,10 @@ vector<vector<account_id_type>> database_api::get_key_references( vector<public_
*/
vector<vector<account_id_type>> database_api_impl::get_key_references( vector<public_key_type> keys )const
{
const auto& idx = _db.get_index_type<account_index>();
const auto& aidx = dynamic_cast<const base_primary_index&>(idx);
const auto& refs = aidx.get_secondary_index<graphene::chain::account_member_index>();

vector< vector<account_id_type> > final_result;
final_result.reserve(keys.size());

Expand All @@ -567,28 +570,25 @@ vector<vector<account_id_type>> database_api_impl::get_key_references( vector<pu
subscribe_to_item( a4 );
subscribe_to_item( a5 );

const auto& idx = _db.get_index_type<account_index>();
const auto& aidx = dynamic_cast<const primary_index<account_index>&>(idx);
const auto& refs = aidx.get_secondary_index<graphene::chain::account_member_index>();
auto itr = refs.account_to_key_memberships.find(key);
vector<account_id_type> result;

for( auto& a : {a1,a2,a3,a4,a5} )
{
auto itr = refs.account_to_address_memberships.find(a);
if( itr != refs.account_to_address_memberships.end() )
{
result.reserve( itr->second.size() );
result.reserve( result.size() + itr->second.size() );
for( auto item : itr->second )
{
result.push_back(item);
}
}
}

auto itr = refs.account_to_key_memberships.find(key);
if( itr != refs.account_to_key_memberships.end() )
{
result.reserve( itr->second.size() );
result.reserve( result.size() + itr->second.size() );
for( auto item : itr->second ) result.push_back(item);
}
final_result.emplace_back( std::move(result) );
Expand Down Expand Up @@ -621,7 +621,7 @@ bool database_api_impl::is_public_key_registered(string public_key) const
return false;
}
const auto& idx = _db.get_index_type<account_index>();
const auto& aidx = dynamic_cast<const primary_index<account_index>&>(idx);
const auto& aidx = dynamic_cast<const base_primary_index&>(idx);
const auto& refs = aidx.get_secondary_index<graphene::chain::account_member_index>();
auto itr = refs.account_to_key_memberships.find(key);
bool is_known = itr != refs.account_to_key_memberships.end();
Expand Down Expand Up @@ -756,6 +756,10 @@ std::map<string,full_account> database_api::get_full_accounts( const vector<stri

std::map<std::string, full_account> database_api_impl::get_full_accounts( const vector<std::string>& names_or_ids, bool subscribe)
{
const auto& proposal_idx = _db.get_index_type<proposal_index>();
const auto& pidx = dynamic_cast<const base_primary_index&>(proposal_idx);
const auto& proposals_by_account = pidx.get_secondary_index<graphene::chain::required_approval_index>();

std::map<std::string, full_account> results;

for (const std::string& account_name_or_id : names_or_ids)
Expand Down Expand Up @@ -785,9 +789,6 @@ std::map<std::string, full_account> database_api_impl::get_full_accounts( const
acnt.cashback_balance = account->cashback_balance(_db);
}
// Add the account's proposals
const auto& proposal_idx = _db.get_index_type<proposal_index>();
const auto& pidx = dynamic_cast<const primary_index<proposal_index>&>(proposal_idx);
const auto& proposals_by_account = pidx.get_secondary_index<graphene::chain::required_approval_index>();
auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id );
if( required_approvals_itr != proposals_by_account._account_to_proposals.end() )
{
Expand All @@ -798,11 +799,9 @@ std::map<std::string, full_account> database_api_impl::get_full_accounts( const


// Add the account's balances
auto balance_range = _db.get_index_type<account_balance_index>().indices().get<by_account_asset>().equal_range(boost::make_tuple(account->id));
std::for_each(balance_range.first, balance_range.second,
[&acnt](const account_balance_object& balance) {
acnt.balances.emplace_back(balance);
});
const auto& balances = _db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( account->id );
for( const auto balance : balances )
acnt.balances.emplace_back( *balance.second );

// Add the account's vesting balances
auto vesting_range = _db.get_index_type<vesting_balance_index>().indices().get<by_account>().equal_range(account->id);
Expand Down Expand Up @@ -870,7 +869,7 @@ vector<account_id_type> database_api::get_account_references( const std::string
vector<account_id_type> database_api_impl::get_account_references( const std::string account_id_or_name )const
{
const auto& idx = _db.get_index_type<account_index>();
const auto& aidx = dynamic_cast<const primary_index<account_index>&>(idx);
const auto& aidx = dynamic_cast<const base_primary_index&>(idx);
const auto& refs = aidx.get_secondary_index<graphene::chain::account_member_index>();
const account_id_type account_id = get_account_from_string(account_id_or_name)->id;
auto itr = refs.account_to_account_memberships.find(account_id);
Expand Down Expand Up @@ -954,10 +953,10 @@ vector<asset> database_api_impl::get_account_balances(const std::string& account
if (assets.empty())
{
// if the caller passes in an empty list of assets, return balances for all assets the account owns
const account_balance_index& balance_index = _db.get_index_type<account_balance_index>();
auto range = balance_index.indices().get<by_account_asset>().equal_range(boost::make_tuple(acnt));
for (const account_balance_object& balance : boost::make_iterator_range(range.first, range.second))
result.push_back(asset(balance.get_balance()));
const auto& balance_index = _db.get_index_type< primary_index< account_balance_index > >();
const auto& balances = balance_index.get_secondary_index< balances_by_account_index >().get_account_balances( acnt );
for( const auto balance : balances )
result.push_back( balance.second->get_balance() );
}
else
{
Expand Down Expand Up @@ -2068,17 +2067,27 @@ bool database_api::verify_account_authority( const string& account_name_or_id, c
return my->verify_account_authority( account_name_or_id, signers );
}

bool database_api_impl::verify_account_authority( const string& account_name_or_id, const flat_set<public_key_type>& keys )const
bool database_api_impl::verify_account_authority( const string& account_name_or_id,
const flat_set<public_key_type>& keys )const
{
const account_object* account = get_account_from_string(account_name_or_id);

/// reuse trx.verify_authority by creating a dummy transfer
signed_transaction trx;
// create a dummy transfer
transfer_operation op;
op.from = account->id;
trx.operations.emplace_back(op);
op.from = get_account_from_string(account_name_or_id)->id;
std::vector<operation> ops;
ops.emplace_back(op);

try
{
graphene::chain::verify_authority(ops, keys,
[this]( account_id_type id ){ return &id(_db).active; },
[this]( account_id_type id ){ return &id(_db).owner; } );
}
catch (fc::exception& ex)
{
return false;
}

return verify_authority( trx );
return true;
}

processed_transaction database_api::validate_transaction( const signed_transaction& trx )const
Expand Down Expand Up @@ -2439,7 +2448,7 @@ void database_api_impl::on_applied_block()
}
if( market.valid() && _market_subscriptions.count(*market) )
// FIXME this may cause fill_order_operation be pushed before order creation
subscribed_markets_ops[*market].emplace_back( std::move( std::make_pair( op.op, op.result ) ) );
subscribed_markets_ops[*market].emplace_back(std::make_pair(op.op, op.result));
}
/// we need to ensure the database_api is not deleted for the life of the async operation
auto capture_this = shared_from_this();
Expand Down
6 changes: 3 additions & 3 deletions libraries/app/include/graphene/app/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,19 @@ namespace graphene { namespace app {
* The transaction will be checked for validity in the local database prior to broadcasting. If it fails to
* apply locally, an error will be thrown and the transaction will not be broadcast.
*/
void broadcast_transaction(const signed_transaction& trx);
void broadcast_transaction(const precomputable_transaction& trx);

/** this version of broadcast transaction registers a callback method that will be called when the transaction is
* included into a block. The callback method includes the transaction id, block number, and transaction number in the
* block.
*/
void broadcast_transaction_with_callback( confirmation_callback cb, const signed_transaction& trx);
void broadcast_transaction_with_callback( confirmation_callback cb, const precomputable_transaction& trx);

/** this version of broadcast transaction registers a callback method that will be called when the transaction is
* included into a block. The callback method includes the transaction id, block number, and transaction number in the
* block.
*/
fc::variant broadcast_transaction_synchronous(const signed_transaction& trx);
fc::variant broadcast_transaction_synchronous(const precomputable_transaction& trx);

/**
* @brief Broadcast a signed block to the network
Expand Down
Loading