parent
70b34aa5d8
commit
68744c9de0
9 changed files with 30 additions and 35 deletions
|
|
@ -59,10 +59,6 @@ namespace detail {
|
|||
dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key)));
|
||||
genesis_state_type initial_state;
|
||||
initial_state.initial_parameters.current_fees.set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION);
|
||||
secret_hash_type::encoder enc;
|
||||
fc::raw::pack(enc, nathan_key);
|
||||
fc::raw::pack(enc, secret_hash_type());
|
||||
auto secret = secret_hash_type::hash(enc.result());
|
||||
initial_state.initial_active_witnesses = 10;
|
||||
for( int i = 0; i < initial_state.initial_active_witnesses; ++i )
|
||||
{
|
||||
|
|
@ -72,7 +68,7 @@ namespace detail {
|
|||
nathan_key.get_public_key(),
|
||||
true);
|
||||
initial_state.initial_committee_candidates.push_back({name});
|
||||
initial_state.initial_witness_candidates.push_back({name, nathan_key.get_public_key(), secret});
|
||||
initial_state.initial_witness_candidates.push_back({name, nathan_key.get_public_key()});
|
||||
}
|
||||
|
||||
initial_state.initial_accounts.emplace_back("nathan", nathan_key.get_public_key());
|
||||
|
|
|
|||
|
|
@ -274,10 +274,18 @@ signed_block database::_generate_block(
|
|||
|
||||
_pending_block.timestamp = when;
|
||||
|
||||
secret_hash_type::encoder last_enc;
|
||||
fc::raw::pack( last_enc, block_signing_private_key );
|
||||
fc::raw::pack( last_enc, witness_obj.last_secret );
|
||||
_pending_block.previous_secret = last_enc.result();
|
||||
// Genesis witnesses start with a default initial secret
|
||||
if( witness_obj.next_secret_hash == secret_hash_type::hash( secret_hash_type() ) )
|
||||
{
|
||||
_pending_block.previous_secret = secret_hash_type();
|
||||
}
|
||||
else
|
||||
{
|
||||
secret_hash_type::encoder last_enc;
|
||||
fc::raw::pack( last_enc, block_signing_private_key );
|
||||
fc::raw::pack( last_enc, witness_obj.previous_secret );
|
||||
_pending_block.previous_secret = last_enc.result();
|
||||
}
|
||||
|
||||
secret_hash_type::encoder next_enc;
|
||||
fc::raw::pack( next_enc, block_signing_private_key );
|
||||
|
|
@ -618,8 +626,8 @@ const witness_object& database::validate_block_header( uint32_t skip, const sign
|
|||
FC_ASSERT( _pending_block.previous == next_block.previous, "", ("pending.prev",_pending_block.previous)("next.prev",next_block.previous) );
|
||||
FC_ASSERT( _pending_block.timestamp <= next_block.timestamp, "", ("_pending_block.timestamp",_pending_block.timestamp)("next",next_block.timestamp)("blocknum",next_block.block_num()) );
|
||||
const witness_object& witness = next_block.witness(*this);
|
||||
FC_ASSERT( secret_hash_type::hash(next_block.previous_secret) == witness.next_secret, "",
|
||||
("previous_secret", next_block.previous_secret)("next_secret", witness.next_secret));
|
||||
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 ) );
|
||||
|
||||
uint32_t slot_num = get_slot_at_time( next_block.timestamp );
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
[&](const genesis_state_type::initial_witness_type& witness) {
|
||||
witness_create_operation op;
|
||||
op.block_signing_key = witness.block_signing_key;
|
||||
op.initial_secret = witness.initial_secret;
|
||||
op.initial_secret = secret_hash_type::hash( secret_hash_type() );
|
||||
op.witness_account = get_account_id(witness.owner_name);
|
||||
apply_operation(genesis_eval_state, op);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ void database::update_signing_witness(const witness_object& signing_witness, con
|
|||
|
||||
modify( signing_witness, [&]( witness_object& _wit )
|
||||
{
|
||||
_wit.last_secret = new_block.previous_secret;
|
||||
_wit.next_secret = new_block.next_secret_hash;
|
||||
_wit.previous_secret = new_block.previous_secret;
|
||||
_wit.next_secret_hash = new_block.next_secret_hash;
|
||||
_wit.accumulated_income += witness_pay;
|
||||
} );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ struct genesis_state_type {
|
|||
/// Must correspond to one of the initial accounts
|
||||
string owner_name;
|
||||
public_key_type block_signing_key;
|
||||
secret_hash_type initial_secret;
|
||||
};
|
||||
struct initial_committee_member_type {
|
||||
/// Must correspond to one of the initial accounts
|
||||
|
|
@ -98,7 +97,7 @@ FC_REFLECT(graphene::chain::genesis_state_type::initial_balance_type,
|
|||
(owner)(asset_symbol)(amount))
|
||||
FC_REFLECT(graphene::chain::genesis_state_type::initial_vesting_balance_type,
|
||||
(owner)(asset_symbol)(amount)(begin_timestamp)(vesting_duration_seconds)(begin_balance))
|
||||
FC_REFLECT(graphene::chain::genesis_state_type::initial_witness_type, (owner_name)(block_signing_key)(initial_secret))
|
||||
FC_REFLECT(graphene::chain::genesis_state_type::initial_witness_type, (owner_name)(block_signing_key))
|
||||
FC_REFLECT(graphene::chain::genesis_state_type::initial_committee_member_type, (owner_name))
|
||||
FC_REFLECT(graphene::chain::genesis_state_type::initial_asset_type::initial_bitasset_options::initial_collateral_position,
|
||||
(collateral)(debt))
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ namespace graphene { namespace chain {
|
|||
|
||||
account_id_type witness_account;
|
||||
public_key_type signing_key;
|
||||
secret_hash_type next_secret;
|
||||
secret_hash_type last_secret;
|
||||
secret_hash_type next_secret_hash;
|
||||
secret_hash_type previous_secret;
|
||||
share_type accumulated_income;
|
||||
vote_id_type vote_id;
|
||||
string url;
|
||||
|
|
@ -60,8 +60,8 @@ namespace graphene { namespace chain {
|
|||
FC_REFLECT_DERIVED( graphene::chain::witness_object, (graphene::db::object),
|
||||
(witness_account)
|
||||
(signing_key)
|
||||
(next_secret)
|
||||
(last_secret)
|
||||
(next_secret_hash)
|
||||
(previous_secret)
|
||||
(accumulated_income)
|
||||
(vote_id)
|
||||
(url) )
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio
|
|||
});
|
||||
|
||||
const auto& new_witness_object = db().create<witness_object>( [&]( witness_object& obj ){
|
||||
obj.witness_account = op.witness_account;
|
||||
obj.vote_id = vote_id;
|
||||
obj.signing_key = op.block_signing_key;
|
||||
obj.next_secret = op.initial_secret;
|
||||
obj.url = op.url;
|
||||
obj.witness_account = op.witness_account;
|
||||
obj.signing_key = op.block_signing_key;
|
||||
obj.next_secret_hash = op.initial_secret;
|
||||
obj.vote_id = vote_id;
|
||||
obj.url = op.url;
|
||||
});
|
||||
return new_witness_object.id;
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@ database_fixture::database_fixture()
|
|||
mhplugin->plugin_set_app(&app);
|
||||
mhplugin->plugin_initialize(options);
|
||||
|
||||
secret_hash_type::encoder enc;
|
||||
fc::raw::pack(enc, delegate_priv_key);
|
||||
fc::raw::pack(enc, secret_hash_type());
|
||||
auto secret = secret_hash_type::hash(enc.result());
|
||||
genesis_state.initial_active_witnesses = 10;
|
||||
for( int i = 0; i < genesis_state.initial_active_witnesses; ++i )
|
||||
{
|
||||
|
|
@ -73,7 +69,7 @@ database_fixture::database_fixture()
|
|||
delegate_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(), secret});
|
||||
genesis_state.initial_witness_candidates.push_back({name, delegate_priv_key.get_public_key()});
|
||||
}
|
||||
genesis_state.initial_parameters.current_fees.set_all_fees(0);
|
||||
db.init_genesis(genesis_state);
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@ using namespace graphene::chain;
|
|||
genesis_state_type make_genesis() {
|
||||
genesis_state_type genesis_state;
|
||||
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
||||
secret_hash_type::encoder enc;
|
||||
fc::raw::pack(enc, delegate_priv_key);
|
||||
fc::raw::pack(enc, secret_hash_type());
|
||||
auto secret = secret_hash_type::hash(enc.result());
|
||||
genesis_state.initial_active_witnesses = 10;
|
||||
for( int i = 0; i < genesis_state.initial_active_witnesses; ++i )
|
||||
{
|
||||
|
|
@ -50,7 +46,7 @@ genesis_state_type make_genesis() {
|
|||
delegate_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(), secret});
|
||||
genesis_state.initial_witness_candidates.push_back({name, delegate_priv_key.get_public_key()});
|
||||
}
|
||||
genesis_state.initial_parameters.current_fees.set_all_fees(0);
|
||||
return genesis_state;
|
||||
|
|
|
|||
Loading…
Reference in a new issue