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
24 changes: 18 additions & 6 deletions libraries/chain/proposal_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ 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 Expand Up @@ -95,6 +89,18 @@ struct proposal_operation_hardfork_visitor
}
};

struct hardfork_visitor_214 // non-recursive proposal visitor
{
typedef void result_type;

template<typename T>
void operator()(const T &v) const {}

void operator()(const proposal_update_operation &v) const {
FC_ASSERT(false, "Not allowed until hardfork 214");
}
};

void_result proposal_create_evaluator::do_evaluate(const proposal_create_operation& o)
{ try {
const database& d = db();
Expand All @@ -103,6 +109,12 @@ void_result proposal_create_evaluator::do_evaluate(const proposal_create_operati
const fc::time_point_sec block_time = d.head_block_time();
proposal_operation_hardfork_visitor vtor(block_time);
vtor( o );
if( block_time < HARDFORK_CORE_214_TIME )
{ // cannot be removed after hf, unfortunately
hardfork_visitor_214 hf214;
for (const op_wrapper &op : o.proposed_ops)
op.op.visit( hf214 );
}

const auto& global_parameters = d.get_global_properties().parameters;

Expand Down
27 changes: 26 additions & 1 deletion tests/tests/authority_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,35 @@ BOOST_AUTO_TEST_CASE( issue_214 )
BOOST_REQUIRE_THROW( PUSH_TX( db, trx ), fc::assert_exception );
trx.signatures.clear();

{ // Bob can create a proposal nesting the one containing the proposal_update
proposal_create_operation npop;
npop.proposed_ops.emplace_back(pop);
npop.fee_paying_account = bob_id;
npop.expiration_time = db.head_block_time() + fc::days(2);
signed_transaction ntx;
set_expiration( db, ntx );
ntx.operations.push_back(npop);
sign( ntx, bob_private_key );
const proposal_id_type pid1a = PUSH_TX( db, ntx ).operation_results[0].get<object_id_type>();
ntx.clear();

// But execution after confirming it fails
proposal_update_operation npup;
npup.fee_paying_account = bob_id;
npup.proposal = pid1a;
npup.active_approvals_to_add.insert( bob_id );
ntx.operations.push_back(npup);
sign( ntx, bob_private_key );
PUSH_TX( db, ntx );
ntx.clear();

db.get<proposal_object>( pid1a ); // still exists
}

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

Expand Down