Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Removing transactions that failed to be pushed to block. #752

Merged
merged 6 commits into from Mar 18, 2016

Conversation

tomusdrw
Copy link
Collaborator

  1. Currently transactions that couldn't be imported were just silently ignored (only trace message)
  2. We wan't to remove invalid transactions from queue
  3. But we also need to keep track of gas_limit (cause they might have not been imported because of reaching block gas_limit).

@tomusdrw tomusdrw added the A0-pleasereview 🤓 Pull request needs code review. label Mar 17, 2016
@arkpar arkpar added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 17, 2016
@gavofyork gavofyork added A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. A8-looksgood 🦄 Pull request is reviewed well. and removed A8-looksgood 🦄 Pull request is reviewed well. A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. labels Mar 17, 2016
let gas_limit = *b.block().header().gas_limit();
let mut gas_left = gas_limit;
let mut invalid_transactions = HashSet::new();

for tx in transactions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stop when gas_left < min transaction gas (21000). There should be a constant for it in the Schedule I believe

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@arkpar arkpar added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Mar 17, 2016
@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Mar 17, 2016
@arkpar arkpar added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 17, 2016
@@ -132,7 +132,20 @@ impl MinerService for Miner {
self.extra_data(),
transactions,
);
*self.sealing_block.lock().unwrap() = b;

match b {
Copy link
Contributor

Choose a reason for hiding this comment

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

could be done more succinctly as:

*self.sealing_block.lock().unwrap() = b.map(|x| {
    let (block, invalid_transactions) = x;
    let mut queue ...
    block
});

no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True - in this case it looks much better. However in general I'm trying to avoid side effects in map.

@gavofyork gavofyork added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Mar 17, 2016
@gavofyork gavofyork added A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. and removed A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. labels Mar 17, 2016
@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. and removed A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. labels Mar 18, 2016

// TODO [todr] It seems that calculating gas_left here doesn't look nice. After moving this function
// to miner crate we should consider rewriting this logic in some better way.
if tx.gas > gas_left {
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason to duplicate this check here rather than just checking import later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, I guess it would be possible to unwrap error, check if it's BlockGasLimitReached, check minimal transaction gas.

Will refactor, because calculating gas here is not particularly appealing.

@gavofyork gavofyork added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. A0-pleasereview 🤓 Pull request needs code review. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 18, 2016
@gavofyork gavofyork removed the A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. label Mar 18, 2016
@tomusdrw tomusdrw added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 18, 2016
@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Mar 18, 2016
gavofyork added a commit that referenced this pull request Mar 18, 2016
Removing transactions that failed to be pushed to block.
@gavofyork gavofyork merged commit a1fb061 into master Mar 18, 2016
@gavofyork gavofyork deleted the tx_queue_invalid branch March 18, 2016 17:03
@arkpar arkpar added this to the 1.0 Parity milestone Mar 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants