Rename bad references to delegate -> witness; #147

This commit is contained in:
Vikram Rajkumar 2015-07-13 15:41:50 -04:00
parent 70b77be3bc
commit 6043586d15
19 changed files with 131 additions and 135 deletions

View file

@ -271,7 +271,7 @@ signed_block database::_generate_block(
const auto& witness_obj = witness_id(*this);
if( !(skip & skip_delegate_signature) )
if( !(skip & skip_witness_signature) )
FC_ASSERT( witness_obj.signing_key == block_signing_private_key.get_public_key() );
_pending_block.timestamp = when;
@ -297,7 +297,7 @@ signed_block database::_generate_block(
_pending_block.transaction_merkle_root = _pending_block.calculate_merkle_root();
_pending_block.witness = witness_id;
if( !(skip & skip_delegate_signature) ) _pending_block.sign( block_signing_private_key );
if( !(skip & skip_witness_signature) ) _pending_block.sign( block_signing_private_key );
FC_ASSERT( fc::raw::pack_size(_pending_block) <= get_global_properties().parameters.maximum_block_size );
signed_block tmp = _pending_block;
@ -645,7 +645,7 @@ const witness_object& database::validate_block_header( uint32_t skip, const sign
const witness_object& witness = next_block.witness(*this);
FC_ASSERT( secret_hash_type::hash( next_block.previous_secret ) == witness.next_secret_hash, "",
("previous_secret", next_block.previous_secret)("next_secret_hash", witness.next_secret_hash));
if( !(skip&skip_delegate_signature) ) FC_ASSERT( next_block.validate_signee( witness.signing_key ) );
if( !(skip&skip_witness_signature) ) FC_ASSERT( next_block.validate_signee( witness.signing_key ) );
uint32_t slot_num = get_slot_at_time( next_block.timestamp );
FC_ASSERT( slot_num > 0 );

View file

@ -51,7 +51,7 @@ void database::reindex(fc::path data_dir, const genesis_state_type& initial_allo
//_undo_db.disable();
for( uint32_t i = 1; i <= last_block_num; ++i )
{
apply_block(*_block_id_to_block.fetch_by_number(i), skip_delegate_signature |
apply_block(*_block_id_to_block.fetch_by_number(i), skip_witness_signature |
skip_transaction_signatures |
skip_undo_block |
skip_undo_transaction |

View file

@ -79,18 +79,18 @@ namespace graphene { namespace chain {
enum validation_steps
{
skip_nothing = 0x00,
skip_delegate_signature = 0x01, ///< used while reindexing
skip_transaction_signatures = 0x02, ///< used by non-witness nodes
skip_undo_block = 0x04, ///< used while reindexing
skip_undo_transaction = 0x08, ///< used while applying block
skip_transaction_dupe_check = 0x10, ///< used while reindexing
skip_fork_db = 0x20, ///< used while reindexing
skip_block_size_check = 0x40, ///< used when applying locally generated transactions
skip_tapos_check = 0x80, ///< used while reindexing -- note this skips expiration check as well
skip_authority_check = 0x100, ///< used while reindexing -- disables any checking of authority on transactions
skip_merkle_check = 0x200, ///< used while reindexing
skip_assert_evaluation = 0x400 ///< used while reindexing
skip_nothing = 0,
skip_witness_signature = 1 << 0, ///< used while reindexing
skip_transaction_signatures = 1 << 1, ///< used by non-witness nodes
skip_undo_block = 1 << 2, ///< used while reindexing
skip_undo_transaction = 1 << 3, ///< used while applying block
skip_transaction_dupe_check = 1 << 4, ///< used while reindexing
skip_fork_db = 1 << 5, ///< used while reindexing
skip_block_size_check = 1 << 6, ///< used when applying locally generated transactions
skip_tapos_check = 1 << 7, ///< used while reindexing -- note this skips expiration check as well
skip_authority_check = 1 << 8, ///< used while reindexing -- disables any checking of authority on transactions
skip_merkle_check = 1 << 9, ///< used while reindexing
skip_assert_evaluation = 1 << 10 ///< used while reindexing
};
/**

View file

@ -15,7 +15,7 @@ namespace graphene { namespace chain {
struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
/// The account which owns the delegate. This account pays the fee for this operation.
/// The account which owns the witness. This account pays the fee for this operation.
account_id_type witness_account;
string url;
public_key_type block_signing_key;

View file

@ -25,12 +25,12 @@
* used for automated testing (creating artificial net splits,
* tracking where messages came from and when)
*/
#define ENABLE_P2P_DEBUGGING_API 1
#define ENABLE_P2P_DEBUGGING_API 1
/**
* 2MiB
*/
#define MAX_MESSAGE_SIZE 1024*1024*2
#define MAX_MESSAGE_SIZE 1024*1024*2
#define GRAPHENE_NET_DEFAULT_PEER_CONNECTION_RETRY_TIME 30 // seconds
/**
@ -47,7 +47,6 @@
#define GRAPHENE_NET_TEST_P2P_PORT 1700
#define GRAPHENE_NET_DEFAULT_P2P_PORT 1776
#define GRAPHENE_NET_DEFAULT_DESIRED_CONNECTIONS 20
#define GRAPHENE_NET_DELEGATE_DESIRED_CONNECTIONS 50
#define GRAPHENE_NET_DEFAULT_MAX_CONNECTIONS 200
#define GRAPHENE_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES (1024 * 1024)

View file

@ -1,4 +1,4 @@
file(GLOB HEADERS "include/graphene/delegate/*.hpp")
file(GLOB HEADERS "include/graphene/witness/*.hpp")
add_library( graphene_witness
witness.cpp

View file

@ -64,4 +64,4 @@ private:
fc::future<void> _block_production_task;
};
} } //graphene::delegate
} } //graphene::witness_plugin

View file

@ -150,7 +150,7 @@ void witness_plugin::plugin_shutdown()
void witness_plugin::schedule_next_production(const graphene::chain::chain_parameters& global_parameters)
{
//Get next production time for *any* delegate
//Get next production time for *any* witness
auto block_interval = global_parameters.block_interval;
fc::time_point next_block_time = fc::time_point_sec() +
(graphene::time::now().sec_since_epoch() / block_interval + 1) * block_interval;
@ -158,7 +158,7 @@ void witness_plugin::schedule_next_production(const graphene::chain::chain_param
if( graphene::time::ntp_time().valid() )
next_block_time -= graphene::time::ntp_error();
//Sleep until the next production time for *any* delegate
//Sleep until the next production time for *any* witness
_block_production_task = fc::schedule([this]{block_production_loop();},
next_block_time, "Witness Block Production");
}

View file

@ -83,9 +83,9 @@ BOOST_AUTO_TEST_CASE( genesis_and_persistence_bench )
BOOST_CHECK(db.get_balance(account_id_type(i), asset_id_type()).amount == GRAPHENE_MAX_SHARE_SUPPLY / account_count);
int blocks_out = 0;
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
auto witness_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
auto aw = db.get_global_properties().active_witnesses;
auto b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 );
auto b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, witness_priv_key, ~0 );
start_time = fc::time_point::now();
/* TODO: get this buliding again
@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE( genesis_and_persistence_bench )
db.push_transaction(trx, ~0);
aw = db.get_global_properties().active_witnesses;
b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 );
b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, witness_priv_key, ~0 );
}
*/
ilog("Pushed ${c} blocks (1 op each, no validation) in ${t} milliseconds.",

View file

@ -62,7 +62,7 @@ database_fixture::database_fixture()
}
auto ahplugin = app.register_plugin<graphene::account_history::account_history_plugin>();
auto mhplugin = app.register_plugin<graphene::market_history::market_history_plugin>();
delegate_pub_key = delegate_priv_key.get_public_key();
init_account_pub_key = init_account_priv_key.get_public_key();
boost::program_options::variables_map options;
@ -79,11 +79,11 @@ database_fixture::database_fixture()
{
auto name = "init"+fc::to_string(i);
genesis_state.initial_accounts.emplace_back(name,
delegate_priv_key.get_public_key(),
delegate_priv_key.get_public_key(),
init_account_priv_key.get_public_key(),
init_account_priv_key.get_public_key(),
true);
genesis_state.initial_committee_candidates.push_back({name});
genesis_state.initial_witness_candidates.push_back({name, delegate_priv_key.get_public_key()});
genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()});
}
genesis_state.initial_parameters.current_fees->zero_all_fees();
db.init_genesis(genesis_state);
@ -315,7 +315,7 @@ void database_fixture::generate_blocks(fc::time_point_sec timestamp, bool miss_i
generate_block();
auto slots_to_miss = db.get_slot_at_time(timestamp) - 1;
if( slots_to_miss <= 0 ) return;
generate_block(~0, delegate_priv_key, slots_to_miss);
generate_block(~0, init_account_priv_key, slots_to_miss);
return;
}
while( db.head_block_time() < timestamp )

View file

@ -144,8 +144,8 @@ struct database_fixture {
public_key_type committee_key;
account_id_type committee_account;
fc::ecc::private_key private_key = fc::ecc::private_key::generate();
fc::ecc::private_key delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key;
fc::ecc::private_key init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type init_account_pub_key;
optional<fc::temp_directory> data_dir;
bool skip_key_index_test = false;

View file

@ -43,13 +43,13 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
const asset_object& core = asset_id_type()(db);
uint32_t skip_flags =
database::skip_transaction_dupe_check
| database::skip_delegate_signature
| database::skip_witness_signature
| database::skip_transaction_signatures
| database::skip_authority_check
;
// Sam is the creator of accounts
private_key_type committee_key = delegate_priv_key;
private_key_type committee_key = init_account_priv_key;
private_key_type sam_key = generate_private_key("sam");
//
@ -239,14 +239,14 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
/**
* To have a secure random number we need to ensure that the same
* delegate does not get to produce two blocks in a row. There is
* always a chance that the last delegate of one round will be the
* first delegate of the next round.
* witness does not get to produce two blocks in a row. There is
* always a chance that the last witness of one round will be the
* first witness of the next round.
*
* This means that when we shuffle delegates we need to make sure
* that there is at least N/2 delegates between consecutive turns
* of the same delegate. This means that durring the random
* shuffle we need to restrict the placement of delegates to maintain
* This means that when we shuffle witness we need to make sure
* that there is at least N/2 witness between consecutive turns
* of the same witness. This means that durring the random
* shuffle we need to restrict the placement of witness to maintain
* this invariant.
*
* This test checks the requirement using Monte Carlo approach
@ -316,14 +316,14 @@ BOOST_FIXTURE_TEST_CASE( witness_order_mc_test, database_fixture )
/**
* To have a secure random number we need to ensure that the same
* delegate does not get to produce two blocks in a row. There is
* always a chance that the last delegate of one round will be the
* first delegate of the next round.
* witness does not get to produce two blocks in a row. There is
* always a chance that the last witness of one round will be the
* first witness of the next round.
*
* This means that when we shuffle delegates we need to make sure
* that there is at least N/2 delegates between consecutive turns
* of the same delegate. This means that durring the random
* shuffle we need to restrict the placement of delegates to maintain
* This means that when we shuffle witness we need to make sure
* that there is at least N/2 witness between consecutive turns
* of the same witness. This means that durring the random
* shuffle we need to restrict the placement of witness to maintain
* this invariant.
*
* This test checks the requirement using Monte Carlo approach

View file

@ -5,7 +5,6 @@
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/db/simple_index.hpp>

View file

@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts )
trx.operations.push_back(op);
sign(trx, parent2_key);
sign(trx, grandparent_key);
sign(trx, delegate_priv_key);
sign(trx, init_account_priv_key);
//Fails due to recursion depth.
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception);
BOOST_TEST_MESSAGE( "verify child key can override recursion checks" );
@ -293,12 +293,12 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
try {
INVOKE(any_two_of_three);
fc::ecc::private_key committee_key = delegate_priv_key;
fc::ecc::private_key committee_key = init_account_priv_key;
fc::ecc::private_key nathan_key1 = fc::ecc::private_key::regenerate(fc::digest("key1"));
fc::ecc::private_key nathan_key2 = fc::ecc::private_key::regenerate(fc::digest("key2"));
fc::ecc::private_key nathan_key3 = fc::ecc::private_key::regenerate(fc::digest("key3"));
const account_object& moneyman = create_account("moneyman", delegate_pub_key);
const account_object& moneyman = create_account("moneyman", init_account_pub_key);
const account_object& nathan = get_account("nathan");
const asset_object& core = asset_id_type()(db);
@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
trx.set_expiration(db.head_block_id());
//idump((moneyman));
trx.sign( delegate_priv_key );
trx.sign( init_account_priv_key );
const proposal_object& proposal = db.get<proposal_object>(PUSH_TX( db, trx ).operation_results.front().get<object_id_type>());
BOOST_CHECK_EQUAL(proposal.required_active_approvals.size(), 1);
@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
BOOST_AUTO_TEST_CASE( committee_authority )
{ try {
fc::ecc::private_key nathan_key = fc::ecc::private_key::generate();
fc::ecc::private_key committee_key = delegate_priv_key;
fc::ecc::private_key committee_key = init_account_priv_key;
const account_object nathan = create_account("nathan", nathan_key.get_public_key());
const auto& global_params = db.get_global_properties().parameters;
@ -476,7 +476,7 @@ BOOST_AUTO_TEST_CASE( committee_authority )
BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
{ try {
generate_block();
fc::ecc::private_key committee_key = delegate_priv_key;
fc::ecc::private_key committee_key = init_account_priv_key;
fc::ecc::private_key delegate_key = fc::ecc::private_key::generate();
//Meet nathan. He has a little money.
@ -516,7 +516,7 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
proposal_update_operation uop;
uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
uop.proposal = pid;
uop.key_approvals_to_add.emplace(delegate_pub_key);
uop.key_approvals_to_add.emplace(init_account_pub_key);
/* TODO: what should this really be?
uop.key_approvals_to_add.emplace(2);
uop.key_approvals_to_add.emplace(3);
@ -882,7 +882,7 @@ BOOST_FIXTURE_TEST_CASE( max_authority_membership, database_fixture )
transaction tx;
processed_transaction ptx;
private_key_type committee_key = delegate_priv_key;
private_key_type committee_key = init_account_priv_key;
// Sam is the creator of accounts
private_key_type sam_key = generate_private_key("sam");
@ -968,7 +968,7 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture )
{
try
{
private_key_type committee_key = delegate_priv_key;
private_key_type committee_key = init_account_priv_key;
// Sam is the creator of accounts
private_key_type alice_key = generate_private_key("alice");
private_key_type bob_key = generate_private_key("bob");

View file

@ -23,7 +23,6 @@
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp>
#include <graphene/chain/witness_scheduler_rng.hpp>
#include <graphene/chain/exceptions.hpp>

View file

@ -39,17 +39,17 @@ genesis_state_type make_genesis() {
genesis_state.initial_timestamp = time_point_sec( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
genesis_state.initial_active_witnesses = 10;
for( int i = 0; i < genesis_state.initial_active_witnesses; ++i )
{
auto name = "init"+fc::to_string(i);
genesis_state.initial_accounts.emplace_back(name,
delegate_priv_key.get_public_key(),
delegate_priv_key.get_public_key(),
init_account_priv_key.get_public_key(),
init_account_priv_key.get_public_key(),
true);
genesis_state.initial_committee_candidates.push_back({name});
genesis_state.initial_witness_candidates.push_back({name, delegate_priv_key.get_public_key()});
genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()});
}
genesis_state.initial_parameters.current_fees->zero_all_fees();
return genesis_state;
@ -126,11 +126,11 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
now += GRAPHENE_DEFAULT_BLOCK_INTERVAL;
// TODO: Don't generate this here
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
{
database db;
db.open(data_dir.path(), make_genesis );
b = db.generate_block(now, db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
b = db.generate_block(now, db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
for( uint32_t i = 1; i < 200; ++i )
{
@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
now += db.block_interval();
witness_id_type cur_witness = db.get_scheduled_witness(1).first;
BOOST_CHECK( cur_witness != prev_witness );
b = db.generate_block(now, cur_witness, delegate_priv_key, database::skip_nothing);
b = db.generate_block(now, cur_witness, init_account_priv_key, database::skip_nothing);
BOOST_CHECK( b.witness == cur_witness );
}
db.close();
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
now += db.block_interval();
witness_id_type cur_witness = db.get_scheduled_witness(1).first;
BOOST_CHECK( cur_witness != prev_witness );
b = db.generate_block(now, cur_witness, delegate_priv_key, database::skip_nothing);
b = db.generate_block(now, cur_witness, init_account_priv_key, database::skip_nothing);
}
BOOST_CHECK_EQUAL( db.head_block_num(), 400 );
}
@ -174,11 +174,11 @@ BOOST_AUTO_TEST_CASE( undo_block )
db.open(data_dir.path(), make_genesis);
fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
for( uint32_t i = 0; i < 5; ++i )
{
now += db.block_interval();
auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, delegate_priv_key, database::skip_nothing );
auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, init_account_priv_key, database::skip_nothing );
}
BOOST_CHECK( db.head_block_num() == 5 );
db.pop_block();
@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE( undo_block )
for( uint32_t i = 0; i < 5; ++i )
{
now += db.block_interval();
auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, delegate_priv_key, database::skip_nothing );
auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, init_account_priv_key, database::skip_nothing );
}
BOOST_CHECK( db.head_block_num() == 7 );
}
@ -215,11 +215,11 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
database db2;
db2.open(data_dir2.path(), make_genesis);
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
for( uint32_t i = 0; i < 10; ++i )
{
now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
try {
PUSH_BLOCK( db2, b );
} FC_CAPTURE_AND_RETHROW( ("db2") );
@ -227,13 +227,13 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
for( uint32_t i = 10; i < 13; ++i )
{
now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
}
string db1_tip = db1.head_block_id().str();
for( uint32_t i = 13; i < 16; ++i )
{
now += db2.block_interval();
auto b = db2.generate_block(now, db2.get_scheduled_witness(db2.get_slot_at_time(now)).first, delegate_priv_key, database::skip_nothing);
auto b = db2.generate_block(now, db2.get_scheduled_witness(db2.get_slot_at_time(now)).first, init_account_priv_key, database::skip_nothing);
// notify both databases of the new block.
// only db2 should switch to the new fork, db1 should not
PUSH_BLOCK( db1, b );
@ -248,11 +248,11 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
BOOST_CHECK_EQUAL(db2.head_block_num(), 13);
{
now += db2.block_interval();
auto b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
auto b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
good_block = b;
b.transactions.emplace_back(signed_transaction());
b.transactions.back().operations.emplace_back(transfer_operation());
b.sign(delegate_priv_key);
b.sign(init_account_priv_key);
BOOST_CHECK_EQUAL(b.block_num(), 14);
GRAPHENE_CHECK_THROW(PUSH_BLOCK( db1, b ), fc::exception);
}
@ -278,8 +278,8 @@ BOOST_AUTO_TEST_CASE( undo_pending )
database db;
db.open(data_dir.path(), make_genesis);
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key();
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db.get_index(protocol_ids, account_object_type);
transfer_operation t;
@ -292,7 +292,7 @@ BOOST_AUTO_TEST_CASE( undo_pending )
PUSH_TX( db, trx, ~0 );
now += db.block_interval();
auto b = db.generate_block(now, db.get_scheduled_witness(1).first, delegate_priv_key, ~0);
auto b = db.generate_block(now, db.get_scheduled_witness(1).first, init_account_priv_key, ~0);
}
signed_transaction trx;
@ -301,13 +301,13 @@ BOOST_AUTO_TEST_CASE( undo_pending )
account_create_operation cop;
cop.registrar = GRAPHENE_TEMP_ACCOUNT;
cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1);
cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop);
//trx.sign( delegate_priv_key );
//trx.sign( init_account_priv_key );
PUSH_TX( db, trx );
now += db.block_interval();
auto b = db.generate_block(now, db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
auto b = db.generate_block(now, db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
BOOST_CHECK(nathan_id(db).name == "nathan");
@ -345,8 +345,8 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
db2.open(dir2.path(), make_genesis);
fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key();
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type);
signed_transaction trx;
@ -355,23 +355,23 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
account_create_operation cop;
cop.registrar = GRAPHENE_TEMP_ACCOUNT;
cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1);
cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop);
PUSH_TX( db1, trx );
auto aw = db1.get_global_properties().active_witnesses;
now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
BOOST_CHECK(nathan_id(db1).name == "nathan");
now = fc::time_point_sec( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
now += db2.block_interval();
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
db1.push_block(b);
aw = db2.get_global_properties().active_witnesses;
now += db2.block_interval();
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
db1.push_block(b);
GRAPHENE_CHECK_THROW(nathan_id(db1), fc::exception);
@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
aw = db2.get_global_properties().active_witnesses;
now += db2.block_interval();
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
db1.push_block(b);
BOOST_CHECK(nathan_id(db1).name == "nathan");
@ -404,8 +404,8 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
auto skip_sigs = database::skip_transaction_signatures | database::skip_authority_check;
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key();
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type);
signed_transaction trx;
@ -413,9 +413,9 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
account_id_type nathan_id = account_idx.get_next_id();
account_create_operation cop;
cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1);
cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop);
trx.sign( delegate_priv_key );
trx.sign( init_account_priv_key );
PUSH_TX( db1, trx, skip_sigs );
trx = decltype(trx)();
@ -424,13 +424,13 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
t.to = nathan_id;
t.amount = asset(500);
trx.operations.push_back(t);
trx.sign( delegate_priv_key );
trx.sign( init_account_priv_key );
PUSH_TX( db1, trx, skip_sigs );
GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception);
now += db1.block_interval();
auto b = db1.generate_block( now, db1.get_scheduled_witness( 1 ).first, delegate_priv_key, skip_sigs );
auto b = db1.generate_block( now, db1.get_scheduled_witness( 1 ).first, init_account_priv_key, skip_sigs );
PUSH_BLOCK( db2, b, skip_sigs );
GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception);
@ -456,12 +456,12 @@ BOOST_AUTO_TEST_CASE( tapos )
const account_object& init1 = *db1.get_index_type<account_index>().indices().get<by_name>().find("init1");
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key();
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type);
now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness( 1 ).first, delegate_priv_key, database::skip_nothing);
auto b = db1.generate_block(now, db1.get_scheduled_witness( 1 ).first, init_account_priv_key, database::skip_nothing);
signed_transaction trx;
//This transaction must be in the next block after its reference, or it is invalid.
@ -471,24 +471,24 @@ BOOST_AUTO_TEST_CASE( tapos )
account_create_operation cop;
cop.registrar = init1.id;
cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1);
cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop);
trx.sign(delegate_priv_key);
trx.sign(init_account_priv_key);
db1.push_transaction(trx);
now += db1.block_interval();
b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
trx.clear();
transfer_operation t;
t.to = nathan_id;
t.amount = asset(50);
trx.operations.push_back(t);
trx.sign(delegate_priv_key);
trx.sign(init_account_priv_key);
//relative_expiration is 1, but ref block is 2 blocks old, so this should fail.
GRAPHENE_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ), fc::exception);
trx.set_expiration(db1.head_block_id(), 2);
trx.signatures.clear();
trx.sign(delegate_priv_key);
trx.sign(init_account_priv_key);
db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check);
} catch (fc::exception& e) {
edump((e.to_detail_string()));
@ -664,15 +664,15 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
get_account("init4").get_id(), get_account("init5").get_id(),
get_account("init6").get_id(), get_account("init7").get_id()};
trx.operations.push_back(uop);
trx.sign(delegate_priv_key);
trx.sign(init_account_priv_key);
/*
trx.sign(get_account("init1").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init2").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init3").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init4").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init5").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init6").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init7").active.get_keys().front(),delegate_priv_key);
trx.sign(get_account("init1").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init2").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init3").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init4").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init5").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init6").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init7").active.get_keys().front(),init_account_priv_key);
*/
db.push_transaction(trx);
BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(db));
@ -709,7 +709,7 @@ BOOST_FIXTURE_TEST_CASE( unimp_force_settlement, database_fixture )
BOOST_FAIL( "TODO" );
/*
try {
auto private_key = delegate_priv_key;
auto private_key = init_account_priv_key;
auto private_key = generate_private_key("committee");
>>>>>>> short_refactor
account_id_type nathan_id = create_account("nathan").get_id();
@ -840,7 +840,7 @@ BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture )
try
{
uint32_t skip_flags = (
database::skip_delegate_signature
database::skip_witness_signature
| database::skip_transaction_signatures
| database::skip_authority_check
);
@ -848,7 +848,7 @@ BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture )
const asset_object& core = asset_id_type()(db);
// Sam is the creator of accounts
private_key_type committee_key = delegate_priv_key;
private_key_type committee_key = init_account_priv_key;
private_key_type sam_key = generate_private_key("sam");
account_object sam_account_object = create_account("sam", sam_key);
@ -893,7 +893,7 @@ BOOST_FIXTURE_TEST_CASE( witness_scheduler_missed_blocks, database_fixture )
});
near_schedule = db.get_near_witness_schedule();
generate_block(0, delegate_priv_key, 2);
generate_block(0, init_account_priv_key, 2);
BOOST_CHECK(db.get_dynamic_global_properties().current_witness == near_schedule[2]);
near_schedule.erase(near_schedule.begin(), near_schedule.begin() + 3);

View file

@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE( create_account_test )
op.owner = auth_bak;
trx.operations.back() = op;
trx.sign( delegate_priv_key);
trx.sign( init_account_priv_key);
trx.validate();
PUSH_TX( db, trx, ~0 );
@ -357,7 +357,7 @@ BOOST_AUTO_TEST_CASE( create_account_test )
BOOST_AUTO_TEST_CASE( update_account )
{
try {
const account_object& nathan = create_account("nathan", delegate_pub_key);
const account_object& nathan = create_account("nathan", init_account_pub_key);
const fc::ecc::private_key nathan_new_key = fc::ecc::private_key::generate();
const public_key_type key_id = nathan_new_key.get_public_key();
const auto& active_delegates = db.get_global_properties().active_delegates;
@ -367,8 +367,8 @@ BOOST_AUTO_TEST_CASE( update_account )
trx.operations.clear();
account_update_operation op;
op.account = nathan.id;
op.owner = authority(2, key_id, 1, delegate_pub_key, 1);
op.active = authority(2, key_id, 1, delegate_pub_key, 1);
op.owner = authority(2, key_id, 1, init_account_pub_key, 1);
op.active = authority(2, key_id, 1, init_account_pub_key, 1);
op.new_options = nathan.options;
op.new_options->votes = flat_set<vote_id_type>({active_delegates[0](db).vote_id, active_delegates[5](db).vote_id});
op.new_options->num_committee = 2;
@ -376,15 +376,15 @@ BOOST_AUTO_TEST_CASE( update_account )
BOOST_TEST_MESSAGE( "Updating account" );
PUSH_TX( db, trx, ~0 );
BOOST_CHECK(nathan.options.memo_key == delegate_pub_key);
BOOST_CHECK(nathan.options.memo_key == init_account_pub_key);
BOOST_CHECK(nathan.active.weight_threshold == 2);
BOOST_CHECK(nathan.active.num_auths() == 2);
BOOST_CHECK(nathan.active.key_auths.at(key_id) == 1);
BOOST_CHECK(nathan.active.key_auths.at(delegate_pub_key) == 1);
BOOST_CHECK(nathan.active.key_auths.at(init_account_pub_key) == 1);
BOOST_CHECK(nathan.owner.weight_threshold == 2);
BOOST_CHECK(nathan.owner.num_auths() == 2);
BOOST_CHECK(nathan.owner.key_auths.at(key_id) == 1);
BOOST_CHECK(nathan.owner.key_auths.at(delegate_pub_key) == 1);
BOOST_CHECK(nathan.owner.key_auths.at(init_account_pub_key) == 1);
BOOST_CHECK(nathan.options.votes.size() == 2);
enable_fees();
@ -974,7 +974,7 @@ BOOST_AUTO_TEST_CASE( cancel_limit_order_test )
}
}
BOOST_AUTO_TEST_CASE( delegate_feeds )
BOOST_AUTO_TEST_CASE( witness_feeds )
{
using namespace graphene::chain;
try {
@ -1019,7 +1019,7 @@ BOOST_AUTO_TEST_CASE( delegate_feeds )
op.publisher = active_witnesses[2];
op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40));
// But this delegate is an idiot.
// But this witness is an idiot.
op.feed.maintenance_collateral_ratio = 1001;
trx.operations.back() = op;
PUSH_TX( db, trx, ~0 );
@ -1107,7 +1107,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test )
generate_block();
// Make an account and upgrade it to prime, so that witnesses get some pay
create_account("nathan", delegate_pub_key);
create_account("nathan", init_account_pub_key);
transfer(account_id_type()(db), get_account("nathan"), asset(20000*CORE));
transfer(account_id_type()(db), get_account("init3"), asset(20*CORE));
generate_block();
@ -1147,7 +1147,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test )
trx.operations.push_back(uop);
for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op);
trx.validate();
trx.sign(delegate_priv_key);
trx.sign(init_account_priv_key);
db.push_transaction(trx);
trx.clear();
BOOST_CHECK_EQUAL(get_balance(*nathan, *core), 20000*CORE - account_upgrade_operation::fee_parameters_type().membership_lifetime_fee );;

View file

@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE( unimp_force_settlement_unavailable )
BOOST_FAIL( "TODO - Reimplement this" );
/*
try {
auto private_key = delegate_priv_key;
auto private_key = init_account_priv_key;
auto private_key = generate_private_key("committee");
>>>>>>> short_refactor
account_id_type nathan_id = create_account("nathan").get_id();
@ -1026,7 +1026,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
BOOST_CHECK(db.find_object(balance_id_type(1)) != nullptr);
auto slot = db.get_slot_at_time(starting_time);
db.generate_block(starting_time, db.get_scheduled_witness(slot).first, delegate_priv_key, database::skip_nothing);
db.generate_block(starting_time, db.get_scheduled_witness(slot).first, init_account_priv_key, database::skip_nothing);
trx.set_expiration(db.head_block_id());
const balance_object& vesting_balance_1 = balance_id_type(2)(db);
@ -1077,9 +1077,9 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
// Attempting to claim twice within a day
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often);
db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
slot = db.get_slot_at_time(vesting_balance_1.vesting_policy->begin_timestamp + 60);
db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, delegate_priv_key, database::skip_nothing);
db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, init_account_priv_key, database::skip_nothing);
trx.set_expiration(db.head_block_id());
op.balance_to_claim = vesting_balance_1.id;
@ -1103,9 +1103,9 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
// Attempting to claim twice within a day
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often);
db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing);
db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
slot = db.get_slot_at_time(db.head_block_time() + fc::days(1));
db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, delegate_priv_key, database::skip_nothing);
db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, init_account_priv_key, database::skip_nothing);
trx.set_expiration(db.head_block_id());
op.total_claimed = vesting_balance_2.balance;

View file

@ -23,7 +23,6 @@
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp>
#include <fc/crypto/digest.hpp>