提交 8ff41f24 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #177 from EOSIO/skip-sig-173

Fix for issue 173, --skip-transaction-signatures to eosd
......@@ -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
......
......@@ -36,6 +36,7 @@ public:
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;
......@@ -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<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"))
{
......@@ -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 };
}
......
......@@ -142,8 +142,9 @@ public:
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 @@ public:
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()!
......
......@@ -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 )
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册