Skip to content
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
4 changes: 4 additions & 0 deletions libraries/chain/hardfork.d/CORE_214.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// bitshares-core #214 Proposal cannot contain proposal_update_operation
#ifndef HARDFORK_CORE_214_TIME
#define HARDFORK_CORE_214_TIME (fc::time_point_sec( 1600000000 ))
#endif
6 changes: 6 additions & 0 deletions libraries/chain/proposal_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ struct proposal_operation_hardfork_visitor
FC_ASSERT(false, "Not allowed until hardfork 188");
}
}
// hf_214
void operator()(const graphene::chain::proposal_update_operation &v) const {
if (block_time < HARDFORK_CORE_214_TIME) {
FC_ASSERT(false, "Not allowed until hardfork 214");
}
}
// hf_588
// issue #588
//
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/protocol/proposal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void proposal_update_operation::get_required_authorities( vector<authority>& o )
auth.key_auths[k] = 1;
auth.weight_threshold = auth.key_auths.size();

o.emplace_back( std::move(auth) );
if( auth.weight_threshold > 0 )
o.emplace_back( std::move(auth) );
}

void proposal_update_operation::get_required_active_authorities( flat_set<account_id_type>& a )const
Expand Down
57 changes: 57 additions & 0 deletions tests/tests/authority_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/hardfork.hpp>

#include <graphene/db/simple_index.hpp>

Expand Down Expand Up @@ -1403,4 +1404,60 @@ BOOST_FIXTURE_TEST_CASE( parent_owner_test, database_fixture )
}
}

BOOST_AUTO_TEST_CASE( issue_214 )
{ try {
ACTORS( (alice)(bob) );
fund( alice );

generate_blocks( HARDFORK_CORE_214_TIME - fc::hours(1) );
set_expiration( db, trx );

// Bob proposes that Alice transfer 500 CORE to himself
transfer_operation top;
top.from = alice_id;
top.to = bob_id;
top.amount = asset( 500 );
proposal_create_operation pop;
pop.proposed_ops.emplace_back(top);
pop.fee_paying_account = bob_id;
pop.expiration_time = db.head_block_time() + fc::days(1);
trx.operations.push_back(pop);
sign( trx, bob_private_key );
const proposal_id_type pid1 = PUSH_TX( db, trx ).operation_results[0].get<object_id_type>();
trx.clear();

// Bob wants to propose that Alice confirm the first proposal
proposal_update_operation pup;
pup.fee_paying_account = alice_id;
pup.proposal = pid1;
pup.active_approvals_to_add.insert( alice_id );
pop.proposed_ops.clear();
pop.proposed_ops.emplace_back( pup );
trx.operations.push_back(pop);
sign( trx, bob_private_key );
// before HF_CORE_214, Bob can't do that
BOOST_REQUIRE_THROW( PUSH_TX( db, trx ), fc::assert_exception );
trx.signatures.clear();

generate_blocks( HARDFORK_CORE_214_TIME + fc::hours(1) );
set_expiration( db, trx );
sign( trx, bob_private_key );
// after the HF it works
const proposal_id_type pid2 = PUSH_TX( db, trx ).operation_results[0].get<object_id_type>();
trx.clear();

// For completeness, Alice confirms Bob's second proposal
pup.proposal = pid2;
trx.operations.push_back(pup);
sign( trx, alice_private_key );
PUSH_TX( db, trx );
trx.clear();

// Execution of the second proposal should have confirmed the first,
// which should have been executed by now.
BOOST_CHECK_THROW( db.get<proposal_object>(pid1), fc::assert_exception );
BOOST_CHECK_THROW( db.get<proposal_object>(pid2), fc::assert_exception );
BOOST_CHECK_EQUAL( top.amount.amount.value, get_balance( bob_id, top.amount.asset_id ) );
} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_SUITE_END()