diff --git a/contracts/eoslib/eosc.dox b/contracts/eoslib/eosc.dox index b4f8d08ad26..9ac736791b1 100644 --- a/contracts/eoslib/eosc.dox +++ b/contracts/eoslib/eosc.dox @@ -6,7 +6,13 @@ @section intro Introduction to EOSC `eosc` is a command line tool that interfaces with the REST api exposed by @ref eosd. In order to use `eosc` you will need to - have a local copy of `eosd` running and configured to load the 'eos::chain_api_plugin'. + have a local copy of `eosd` running and configured to load the 'eos::chain_api_plugin'. + + As an easy way for developers to test functionality without dealing with keys, `eosd` can be run so that + Transaction signatures are not required. + ... + ./eosd --skip-transaction-signatures + ... ``` # Plugin(s) to enable, may be specified multiple times diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 8e7c09f8ecb..637129cd52c 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -36,6 +36,7 @@ class chain_plugin_impl { bfs::path block_log_dir; bfs::path genesis_file; chain::Time genesis_timestamp; + uint32_t skip_flags = chain_controller::skip_nothing; bool readonly = false; flat_map loaded_checkpoints; @@ -66,6 +67,8 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip "clear chain database and replay all blocks") ("resync-blockchain", bpo::bool_switch()->default_value(false), "clear chain database and block log") + ("skip-transaction-signatures", bpo::bool_switch()->default_value(false), + "Disable Transaction signature verification. ONLY for TESTING.") ; } @@ -107,6 +110,20 @@ void chain_plugin::plugin_initialize(const variables_map& options) { app().get_plugin().wipe_database(); fc::remove_all(my->block_log_dir); } + if (options.at("skip-transaction-signatures").as()) { + ilog("Setting skip_transaction_signatures"); + elog("Setting skip_transaction_signatures\n" + "\n" + "**************************************\n" + "* *\n" + "* -- EOSD IGNORING SIGNATURES -- *\n" + "* - TEST MODE - *\n" + "* ------------------------------ *\n" + "* *\n" + "**************************************\n"); + + my->skip_flags |= chain_controller::skip_transaction_signatures; + } if(options.count("checkpoint")) { @@ -154,6 +171,10 @@ void chain_plugin::plugin_startup() void chain_plugin::plugin_shutdown() { } +chain_apis::read_write chain_plugin::get_read_write_api() { + return chain_apis::read_write(chain(), my->skip_flags); +} + bool chain_plugin::accept_block(const chain::signed_block& block, bool currently_syncing) { if (currently_syncing && block.block_num() % 10000 == 0) { ilog("Syncing Blockchain --- Got block: #${n} time: ${t} producer: ${p}", @@ -166,7 +187,7 @@ bool chain_plugin::accept_block(const chain::signed_block& block, bool currently } void chain_plugin::accept_transaction(const chain::SignedTransaction& trx) { - chain().push_transaction(trx); + chain().push_transaction(trx, my->skip_flags); } bool chain_plugin::block_is_on_preferred_chain(const chain::block_id_type& block_id) { @@ -177,6 +198,10 @@ bool chain_plugin::block_is_on_preferred_chain(const chain::block_id_type& block return chain().get_block_id_for_num(chain::block_header::num_from_id(block_id)) == block_id; } +bool chain_plugin::is_skipping_transaction_signatures() const { + return my->skip_flags & chain_controller::skip_transaction_signatures; +} + chain_controller& chain_plugin::chain() { return *my->chain; } const chain::chain_controller& chain_plugin::chain() const { return *my->chain; } @@ -301,7 +326,7 @@ read_write::push_block_results read_write::push_block(const read_write::push_blo } read_write::push_transaction_results read_write::push_transaction(const read_write::push_transaction_params& params) { - auto ptrx = db.push_transaction(params); + auto ptrx = db.push_transaction(params, skip_flags); auto pretty_trx = db.transaction_to_variant( ptrx ); return read_write::push_transaction_results{ params.id(), pretty_trx }; } diff --git a/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp b/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp index 82a11ce67c4..26232d269e7 100644 --- a/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp @@ -142,8 +142,9 @@ class read_only { class read_write { chain_controller& db; + uint32_t skip_flags; public: - read_write(chain_controller& db) : db(db) {} + read_write(chain_controller& db, uint32_t skip_flags) : db(db), skip_flags(skip_flags) {} using push_block_params = chain::signed_block; using push_block_results = empty; @@ -172,13 +173,16 @@ class chain_plugin : public plugin { void plugin_shutdown(); chain_apis::read_only get_read_only_api() const { return chain_apis::read_only(chain()); } - chain_apis::read_write get_read_write_api() { return chain_apis::read_write(chain()); } + chain_apis::read_write get_read_write_api(); bool accept_block(const chain::signed_block& block, bool currently_syncing); void accept_transaction(const chain::SignedTransaction& trx); bool block_is_on_preferred_chain(const chain::block_id_type& block_id); + // return true if --skip-transaction-signatures passed to eosd + bool is_skipping_transaction_signatures() const; + // Only call this after plugin_startup()! chain_controller& chain(); // Only call this after plugin_startup()! diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index cdf739542ce..b8edaeaa59f 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -238,6 +238,9 @@ block_production_condition::block_production_condition_enum producer_plugin_impl fc::time_point now_fine = fc::time_point::now(); fc::time_point_sec now = now_fine + fc::microseconds(500000); + if (app().get_plugin().is_skipping_transaction_signatures()) { + _production_skip_flags |= chain_controller::skip_transaction_signatures; + } // If the next block production opportunity is in the present or future, we're synced. if( !_production_enabled ) {