Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/remove smart ref #396

Merged
merged 17 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build:
- rm -rf build
- mkdir build
- cd build
- cmake ..
- cmake -DCMAKE_BUILD_TYPE=Release ..
- make -j$(nproc)
artifacts:
untracked: true
Expand Down
1 change: 0 additions & 1 deletion libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <graphene/chain/tournament_object.hpp>

#include <fc/crypto/hex.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/rpc/api_connection.hpp>
#include <fc/thread/future.hpp>

Expand Down
4 changes: 1 addition & 3 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/chain/worker_evaluator.hpp>

#include <fc/smart_ref_impl.hpp>

#include <fc/io/fstream.hpp>
#include <fc/rpc/api_connection.hpp>
#include <fc/rpc/websocket_api.hpp>
Expand Down Expand Up @@ -80,7 +78,7 @@ namespace detail {
auto nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key)));
genesis_state_type initial_state;
initial_state.initial_parameters.current_fees = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION);
initial_state.initial_parameters.current_fees = std::make_shared<fee_schedule>(fee_schedule::get_default());
initial_state.initial_active_witnesses = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT;
initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() /
initial_state.initial_parameters.block_interval *
Expand Down
1 change: 0 additions & 1 deletion libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <graphene/chain/pts_address.hpp>

#include <fc/bloom_filter.hpp>
#include <fc/smart_ref_impl.hpp>

#include <fc/crypto/hex.hpp>
#include <fc/rpc/api_connection.hpp>
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ add_library( graphene_chain
protocol/assert.cpp
protocol/account.cpp
protocol/transfer.cpp
protocol/chain_parameters.cpp
protocol/committee_member.cpp
protocol/witness.cpp
protocol/market.cpp
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/account_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* THE SOFTWARE.
*/

#include <fc/smart_ref_impl.hpp>

#include <graphene/chain/account_evaluator.hpp>
#include <graphene/chain/buyback.hpp>
#include <graphene/chain/buyback_object.hpp>
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/betting_market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#define DEFAULT_LOGGER "betting"
#include <fc/smart_ref_impl.hpp>

#include <graphene/chain/betting_market_evaluator.hpp>
#include <graphene/chain/betting_market_object.hpp>
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/block_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <graphene/chain/block_database.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/io/raw.hpp>
#include <fc/smart_ref_impl.hpp>

namespace graphene { namespace chain {

Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/committee_member_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <graphene/chain/protocol/vote.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>

#include <fc/smart_ref_impl.hpp>

namespace graphene { namespace chain {

void_result committee_member_create_evaluator::do_evaluate( const committee_member_create_operation& op )
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/confidential_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include <graphene/chain/fba_accumulator_id.hpp>
#include <graphene/chain/hardfork.hpp>

#include <fc/smart_ref_impl.hpp>

namespace graphene { namespace chain {

void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o )
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <fc/smart_ref_impl.hpp>
#include "db_balance.cpp"
#include "db_bet.cpp"
#include "db_block.cpp"
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <graphene/chain/witness_schedule_object.hpp>
#include <fc/crypto/digest.hpp>

#include <fc/smart_ref_impl.hpp>

namespace {

Expand Down
4 changes: 1 addition & 3 deletions libraries/chain/db_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_proposal_object.hpp>

#include <fc/smart_ref_impl.hpp>

#include <ctime>
#include <algorithm>

Expand Down Expand Up @@ -68,7 +66,7 @@ const dynamic_global_property_object& database::get_dynamic_global_properties()

const fee_schedule& database::current_fee_schedule()const
{
return get_global_properties().parameters.current_fees;
return std::ref( *get_global_properties().parameters.current_fees );
}

time_point_sec database::head_block_time()const
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/db_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@

#include <graphene/chain/protocol/fee_schedule.hpp>

#include <fc/smart_ref_impl.hpp>
#include <fc/uint128.hpp>
#include <fc/crypto/digest.hpp>

Expand Down
1 change: 0 additions & 1 deletion libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include <boost/multiprecision/integer.hpp>

#include <fc/smart_ref_impl.hpp>
#include <fc/uint128.hpp>

#include <graphene/chain/database.hpp>
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/fork_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <graphene/chain/fork_database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>

namespace graphene { namespace chain {
fork_database::fork_database()
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/genesis_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <graphene/chain/genesis_state.hpp>

// these are required to serialize a genesis_state
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode
#include <graphene/chain/protocol/fee_schedule.hpp>

namespace graphene { namespace chain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
* THE SOFTWARE.
*/
#pragma once
#include <memory>
#include <graphene/chain/protocol/base.hpp>
#include <graphene/chain/protocol/ext.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <fc/smart_ref_fwd.hpp>

#include <graphene/chain/hardfork.hpp>
#include <../hardfork.d/GPOS.hf>
Expand Down Expand Up @@ -72,8 +72,13 @@ namespace graphene { namespace chain {

struct chain_parameters
{
chain_parameters();
chain_parameters(const chain_parameters& other);
chain_parameters(chain_parameters&& other);
chain_parameters& operator=(const chain_parameters& other);
chain_parameters& operator=(chain_parameters&& other);
/** using a smart ref breaks the circular dependency created between operations and the fee schedule */
smart_ref<fee_schedule> current_fees; ///< current schedule of fees
std::shared_ptr<fee_schedule> current_fees; ///< current schedule of fees
uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks
uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events
uint8_t maintenance_skip_slots = GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS; ///< number of block_intervals to skip at maintenance time
Expand Down Expand Up @@ -207,6 +212,8 @@ namespace graphene { namespace chain {
inline uint16_t maximum_son_count()const {
return extensions.value.maximum_son_count.valid() ? *extensions.value.maximum_son_count : GRAPHENE_DEFAULT_MAX_SONS;
}
private:
static void safe_copy(chain_parameters& to, const chain_parameters& from);
};

} } // graphene::chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#pragma once
#include <fc/smart_ref_fwd.hpp>
#include <graphene/chain/protocol/operations.hpp>

namespace graphene { namespace chain {
Expand Down Expand Up @@ -84,6 +83,10 @@ namespace graphene { namespace chain {

} } // graphene::chain

namespace fc {
template<> struct get_typename<std::shared_ptr<graphene::chain::fee_schedule>> { static const char* name() { return "shared_ptr<fee_schedule>"; } };
}

FC_REFLECT_TYPENAME( graphene::chain::fee_parameters )
FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) )

Expand Down
1 change: 0 additions & 1 deletion libraries/chain/include/graphene/chain/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <fc/io/raw_fwd.hpp>
#include <fc/uint128.hpp>
#include <fc/static_variant.hpp>
#include <fc/smart_ref_fwd.hpp>

#include <memory>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <graphene/chain/protocol/market.hpp>

#include <fc/uint128.hpp>
#include <fc/smart_ref_impl.hpp>

namespace graphene { namespace chain {
void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_operation& op)
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/proposal_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>

#include <fc/smart_ref_impl.hpp>

namespace graphene { namespace chain {

struct proposal_operation_hardfork_visitor
Expand Down
92 changes: 92 additions & 0 deletions libraries/chain/protocol/chain_parameters.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include <graphene/chain/protocol/chain_parameters.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>

namespace graphene { namespace chain {
chain_parameters::chain_parameters() {
current_fees = std::make_shared<fee_schedule>();
}

// copy constructor
chain_parameters::chain_parameters(const chain_parameters& other)
{
current_fees = std::make_shared<fee_schedule>(*other.current_fees);
safe_copy(*this, other);
}

// copy assignment
chain_parameters& chain_parameters::operator=(const chain_parameters& other)
{
if (&other != this)
{
current_fees = std::make_shared<fee_schedule>(*other.current_fees);
safe_copy(*this, other);
}
return *this;
}

// copies the easy stuff
void chain_parameters::safe_copy(chain_parameters& to, const chain_parameters& from)
{
to.block_interval = from.block_interval;
to.maintenance_interval = from.maintenance_interval;
to.maintenance_skip_slots = from.maintenance_skip_slots;
to.committee_proposal_review_period = from.committee_proposal_review_period;
to.maximum_transaction_size = from.maximum_transaction_size;
to.maximum_block_size = from.maximum_block_size;
to.maximum_time_until_expiration = from.maximum_time_until_expiration;
to.maximum_proposal_lifetime = from.maximum_proposal_lifetime;
to.maximum_asset_whitelist_authorities = from.maximum_asset_whitelist_authorities;
to.maximum_asset_feed_publishers = from.maximum_asset_feed_publishers;
to.maximum_witness_count = from.maximum_witness_count;
to.maximum_committee_count = from.maximum_committee_count;
to.maximum_authority_membership = from.maximum_authority_membership;
to.reserve_percent_of_fee = from.reserve_percent_of_fee;
to.network_percent_of_fee = from.network_percent_of_fee;
to.lifetime_referrer_percent_of_fee = from.lifetime_referrer_percent_of_fee;
to.cashback_vesting_period_seconds = from.cashback_vesting_period_seconds;
to.cashback_vesting_threshold = from.cashback_vesting_threshold;
to.count_non_member_votes = from.count_non_member_votes;
to.allow_non_member_whitelists = from.allow_non_member_whitelists;
to.witness_pay_per_block = from.witness_pay_per_block;
to.witness_pay_vesting_seconds = from.witness_pay_vesting_seconds;
to.worker_budget_per_day = from.worker_budget_per_day;
to.max_predicate_opcode = from.max_predicate_opcode;
to.fee_liquidation_threshold = from.fee_liquidation_threshold;
to.accounts_per_fee_scale = from.accounts_per_fee_scale;
to.account_fee_scale_bitshifts = from.account_fee_scale_bitshifts;
to.max_authority_depth = from.max_authority_depth;
to.witness_schedule_algorithm= from.witness_schedule_algorithm;
to.min_round_delay = from.min_round_delay;
to.max_round_delay = from.max_round_delay;
to.min_time_per_commit_move = from.min_time_per_commit_move;
to.max_time_per_commit_move = from.max_time_per_commit_move;
to.min_time_per_reveal_move = from.min_time_per_reveal_move;
to.max_time_per_reveal_move = from.max_time_per_reveal_move;
to.rake_fee_percentage = from.rake_fee_percentage;
to.maximum_registration_deadline = from.maximum_registration_deadline;
to.maximum_players_in_tournament = from.maximum_players_in_tournament;
to.maximum_tournament_whitelist_length = from.maximum_tournament_whitelist_length;
to.maximum_tournament_start_time_in_future= from.maximum_tournament_start_time_in_future;
to.maximum_tournament_start_delay = from.maximum_tournament_start_delay;
to.maximum_tournament_number_of_wins = from.maximum_tournament_number_of_wins;
to.extensions = from.extensions;
}

// move constructor
chain_parameters::chain_parameters(chain_parameters&& other)
{
current_fees = std::move(other.current_fees);
safe_copy(*this, other);
}

// move assignment
chain_parameters& chain_parameters::operator=(chain_parameters&& other)
{
if (&other != this)
{
current_fees = std::move(other.current_fees);
safe_copy(*this, other);
}
return *this;
}
}}
1 change: 0 additions & 1 deletion libraries/chain/protocol/committee_member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <fc/smart_ref_impl.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/protocol/committee_member.hpp>

Expand Down
15 changes: 0 additions & 15 deletions libraries/chain/protocol/fee_schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,13 @@
*/
#include <algorithm>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>

namespace fc
{
// explicitly instantiate the smart_ref, gcc fails to instantiate it in some release builds
//template graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator=(smart_ref<graphene::chain::fee_schedule>&&);
//template graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator=(U&&);
//template graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator=(const smart_ref&);
//template smart_ref<graphene::chain::fee_schedule>::smart_ref();
//template const graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator*() const;
}

#include <fc/io/raw.hpp>

#define MAX_FEE_STABILIZATION_ITERATION 4

namespace graphene { namespace chain {

typedef fc::smart_ref<fee_schedule> smart_fee_schedule;

static smart_fee_schedule tmp;

fee_schedule::fee_schedule()
{
}
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/protocol/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <fc/smart_ref_impl.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/io/raw.hpp>
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/protocol/proposal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>

#include <fc/io/raw.hpp>

Expand Down
1 change: 0 additions & 1 deletion libraries/chain/protocol/small_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* THE SOFTWARE.
*/

#include <fc/smart_ref_impl.hpp>
#include <graphene/chain/protocol/balance.hpp>
#include <graphene/chain/protocol/buyback.hpp>
#include <graphene/chain/protocol/fba.hpp>
Expand Down
Loading