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

Commit

Permalink
Merge pull request #177 from EOSIO/skip-sig-173
Browse files Browse the repository at this point in the history
Fix for issue 173, --skip-transaction-signatures to eosd
  • Loading branch information
bytemaster authored Aug 18, 2017
2 parents d5c30e5 + b976510 commit 8ff41f2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
8 changes: 7 additions & 1 deletion contracts/eoslib/eosc.dox
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 27 additions & 2 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t,block_id_type> loaded_checkpoints;

Expand Down Expand Up @@ -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.")
;
}

Expand Down Expand Up @@ -107,6 +110,20 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
app().get_plugin<database_plugin>().wipe_database();
fc::remove_all(my->block_log_dir);
}
if (options.at("skip-transaction-signatures").as<bool>()) {
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"))
{
Expand Down Expand Up @@ -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}",
Expand All @@ -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) {
Expand All @@ -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; }

Expand Down Expand Up @@ -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 };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -172,13 +173,16 @@ class chain_plugin : public plugin<chain_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()!
Expand Down
3 changes: 3 additions & 0 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<chain_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 )
{
Expand Down

0 comments on commit 8ff41f2

Please sign in to comment.