Skip to content

Commit

Permalink
HF v0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bravoadam committed Feb 25, 2019
1 parent a9f4799 commit 8d66075
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bravo - The Decentralized Consumer Review Blockchain That Pays Its Community
## Bravo - The Decentralized Consumer Review Blockchain That Pays Its Community

Welcome to the official repository for Bravo, the review blockchain that pays its community!

Expand Down Expand Up @@ -169,4 +169,4 @@ On Linux use the following Virtual Memory configuration for the initial sync and

## No Support & No Warranty

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions contrib/bravod.run
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ if [[ ! -d $HOME/blockchain ]]; then
fi
fi

if [[ "$REPLAY_BLOCKCHAIN" ]]; then
ARGS+=" --replay-blockchain "
fi

# without --data-dir it uses cwd as datadir(!)
# who knows what else it dumps into current dir
cd $HOME
Expand Down
8 changes: 7 additions & 1 deletion libraries/chain/bravo_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ void account_witness_vote_evaluator::do_apply( const account_witness_vote_operat
_db.create<witness_vote_object>( [&]( witness_vote_object& v ) {
v.witness = witness.id;
v.account = voter.id;
if (_db.has_hardfork(BRAVO_HARDFORK_0_22))
v.weight = voter.witness_vote_weight(_db.has_hardfork(BRAVO_HARDFORK_0_21));
});

_db.adjust_witness_vote( witness, voter.witness_vote_weight(_db.has_hardfork(BRAVO_HARDFORK_0_21)));
Expand All @@ -838,7 +840,11 @@ void account_witness_vote_evaluator::do_apply( const account_witness_vote_operat
} else {
FC_ASSERT( !o.approve, "Vote currently exists, user must indicate a desire to reject witness." );

_db.adjust_witness_vote( witness, -voter.witness_vote_weight(_db.has_hardfork(BRAVO_HARDFORK_0_21)) );
if (_db.has_hardfork(BRAVO_HARDFORK_0_22))
_db.adjust_witness_vote( witness, -itr->weight);
else
_db.adjust_witness_vote(witness, -voter.witness_vote_weight(_db.has_hardfork(BRAVO_HARDFORK_0_21)));

_db.modify( voter, [&]( account_object& a ) {
a.witnesses_voted_for--;
});
Expand Down
48 changes: 45 additions & 3 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void database::reindex( const fc::path& data_dir, const fc::path& shared_mem_dir
{
ilog( "Reindexing Blockchain" );
wipe( data_dir, shared_mem_dir, false );
open( data_dir, shared_mem_dir, 0, shared_file_size, chainbase::database::read_write );
open( data_dir, shared_mem_dir, BRAVO_INIT_SUPPLY, shared_file_size, chainbase::database::read_write );
_fork_db.reset(); // override effect of _fork_db.start_block() call in open()

auto start = fc::time_point::now();
Expand Down Expand Up @@ -364,6 +364,13 @@ const account_object& database::get_account( const account_name_type& name )cons
return get< account_object, by_name >( name );
} FC_CAPTURE_AND_RETHROW( (name) ) }

const account_object& database::get_account(const account_id_type& id)const
{
try {
return get< account_object, by_id >(id);
} FC_CAPTURE_AND_RETHROW((id))
}

const account_object* database::find_account( const account_name_type& name )const
{
return find< account_object, by_name >( name );
Expand Down Expand Up @@ -1076,7 +1083,12 @@ void database::adjust_witness_vote( const witness_object& witness, share_type de
w.virtual_position += delta_pos;

w.virtual_last_update = wso.current_virtual_time;
w.votes += delta;

if (has_hardfork(BRAVO_HARDFORK_0_22))
w.votes = std::max((w.votes + delta), (share_type) 0);
else
w.votes += delta;

w.virtual_scheduled_time = w.virtual_last_update + (VIRTUAL_SCHEDULE_LAP_LENGTH2 - w.virtual_position)/(w.votes.value+1);

/** witnesses with a low number of votes could overflow the time field and end up with a scheduled time in the past */
Expand Down Expand Up @@ -2898,7 +2910,9 @@ void database::init_hardforks()
FC_ASSERT(BRAVO_HARDFORK_0_21 == 21, "Invalid hardfork configuration");
_hardfork_times[BRAVO_HARDFORK_0_21] = fc::time_point_sec(BRAVO_HARDFORK_0_21_TIME);
_hardfork_versions[BRAVO_HARDFORK_0_21] = BRAVO_HARDFORK_0_21_VERSION;

FC_ASSERT(BRAVO_HARDFORK_0_22 == 22, "Invalid hardfork configuration");
_hardfork_times[BRAVO_HARDFORK_0_22] = fc::time_point_sec(BRAVO_HARDFORK_0_22_TIME);
_hardfork_versions[BRAVO_HARDFORK_0_22] = BRAVO_HARDFORK_0_22_VERSION;

const auto& hardforks = get_hardfork_property_object();
FC_ASSERT( hardforks.last_hardfork <= BRAVO_NUM_HARDFORKS, "Chain knows of more hardforks than configuration", ("hardforks.last_hardfork",hardforks.last_hardfork)("BRAVO_NUM_HARDFORKS",BRAVO_NUM_HARDFORKS) );
Expand Down Expand Up @@ -3222,6 +3236,34 @@ void database::apply_hardfork( uint32_t hardfork )
#endif
}
break;
case BRAVO_HARDFORK_0_22:
{
#ifdef IS_TEST_NET
{
custom_operation test_op;
string op_msg = "Testnet: Hardfork 22 applied";
test_op.data = vector< char >(op_msg.begin(), op_msg.end());
test_op.required_auths.insert(BRAVO_INIT_MINER_NAME);
operation op = test_op; // we need the operation object to live to the end of this scope
operation_notification note(op);
notify_pre_apply_operation(note);
notify_post_apply_operation(note);
}
#endif
/**
* Add votes weight of existing witness votes.
*/
const auto& witness_vote_idx = get_index< witness_vote_index >().indices().get< by_account_witness >();
for (auto itr = witness_vote_idx.begin(); itr != witness_vote_idx.end(); ++itr) {
const auto& acc = get_account(itr->account);
// set weight based on the existing balance of account
modify(*itr, [&](witness_vote_object& v) {
v.weight = acc.witness_vote_weight(true);
});
}
}
break;

default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/hardfork.d/0-preamble.hf
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ FC_REFLECT( bravo::chain::hardfork_property_object,
(next_hardfork)(next_hardfork_time) )
CHAINBASE_SET_INDEX_TYPE( bravo::chain::hardfork_property_object, bravo::chain::hardfork_property_index )

#define BRAVO_NUM_HARDFORKS 21
#define BRAVO_NUM_HARDFORKS 22
8 changes: 8 additions & 0 deletions libraries/chain/hardfork.d/0_22.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef BRAVO_HARDFORK_0_22
#define BRAVO_HARDFORK_0_22 22

// Monday, Feb 25 2019 11:00:00 UTC
#define BRAVO_HARDFORK_0_22_TIME 1551092400
#define BRAVO_HARDFORK_0_22_VERSION hardfork_version( 0, 22 )

#endif
1 change: 1 addition & 0 deletions libraries/chain/include/bravo/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ namespace bravo { namespace chain {
const witness_object* find_witness( const account_name_type& name )const;

const account_object& get_account( const account_name_type& name )const;
const account_object& get_account(const account_id_type& id)const;
const account_object* find_account( const account_name_type& name )const;

const comment_object& get_comment( const account_name_type& author, const shared_string& permlink )const;
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/bravo/chain/witness_objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ namespace bravo { namespace chain {

witness_id_type witness;
account_id_type account;
share_type weight = 0;
};

class witness_schedule_object : public object< witness_schedule_object_type, witness_schedule_object >
Expand Down Expand Up @@ -250,7 +251,7 @@ FC_REFLECT( bravo::chain::witness_object,
)
CHAINBASE_SET_INDEX_TYPE( bravo::chain::witness_object, bravo::chain::witness_index )

FC_REFLECT( bravo::chain::witness_vote_object, (id)(witness)(account) )
FC_REFLECT( bravo::chain::witness_vote_object, (id)(witness)(account)(weight) )
CHAINBASE_SET_INDEX_TYPE( bravo::chain::witness_vote_object, bravo::chain::witness_vote_index )

FC_REFLECT( bravo::chain::witness_schedule_object,
Expand Down
2 changes: 1 addition & 1 deletion libraries/protocol/include/bravo/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
#pragma once

#define BRAVO_BLOCKCHAIN_VERSION ( version(0, 21, 0) )
#define BRAVO_BLOCKCHAIN_VERSION ( version(0, 22, 0) )
#define BRAVO_BLOCKCHAIN_HARDFORK_VERSION ( hardfork_version( BRAVO_BLOCKCHAIN_VERSION ) )

#ifdef IS_TEST_NET
Expand Down

0 comments on commit 8d66075

Please sign in to comment.