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

Check if a proposal is alive before removing #1481

Closed
wants to merge 1 commit into from

Conversation

abitmore
Copy link
Member

Another attempt for issue #1479.

// then be re-inserted to database when undo session destructs,
// in this case the address would be different, which means the reference would be invalidated already.
const proposal_object* po = find(proposal_id);
FC_ASSERT( po, "Proposal ${p} was removed unexpectedly", ("p",proposal_id) ); // make sure the proposal still exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this assertion throws the session will be rolled back, which reconstructs the proposal.
This means the enclosing proposal_update succeeds, which leads to the proposal being removed again.
This will cause the enclosing push_proposal to throw at the same point, which again reconstructs it.

This alternating success/failure looks dirty to me. Does it mean the ultimate success or failure depends on the nesting depth?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is generic defensive logic -- only tries to remove an object if it exists. In addition, to be defensive, locate the object again. The rationale is a proposal can be removed and then reconstructed not only due to self-approving (I believe we can make a test case for this). I do agree the self-approving proposal makes the situation more complicated, and we do need to avoid the situation in the first place as #1480 tries to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a proposal can be removed and then reconstructed not only due to self-approving (I believe we can make a test case for this)

Update:
I may be wrong. When pushing a proposal, the proposal itself should not be removed if we've avoided self-approving as well as loops.

@@ -156,6 +156,8 @@ void database::clear_expired_proposals()
while( !proposal_expiration_index.empty() && proposal_expiration_index.begin()->expiration_time <= head_block_time() )
{
const proposal_object& proposal = *proposal_expiration_index.begin();
proposal_object proposal_copy = proposal; // make a copy for logging
proposal_id_type proposal_id = proposal.id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use proposal_copy.id instead of introducing proposal_id

@@ -229,7 +229,9 @@ void_result proposal_update_evaluator::do_evaluate(const proposal_update_operati
} FC_CAPTURE_AND_RETHROW( (o) ) }

void_result proposal_update_evaluator::do_apply(const proposal_update_operation& o)
{ try {
{
auto o_copy = o; // make a copy for logging
Copy link
Contributor

@pmconrad pmconrad Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that necessary? o lives longer than o_copy. Got it - in the special case of a self-approving proposal, the proposal containing o can be removed, which deletes o.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need self-approving proposals ? maybe we should not accept & apply self-approving proposals ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cogutvalera #1480 rejects self-approving proposals.

@pmconrad
Copy link
Contributor

@abitmore do you think this is still worth changing? If not please close.

@abitmore abitmore closed this Jan 1, 2019
@abitmore abitmore deleted the issue_1479_abit_patch branch January 1, 2019 11:31
@abitmore abitmore added this to the Hotfix-201812-1 milestone Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants