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

Don't remove invalid transactions when skipping. #5121

Merged
merged 6 commits into from
Mar 5, 2020

Conversation

tomusdrw
Copy link
Contributor

@tomusdrw tomusdrw commented Mar 3, 2020

Resolves #5028

@tomusdrw tomusdrw added A0-please_review Pull request needs code review. B0-patchthis labels Mar 3, 2020
@@ -192,6 +192,10 @@ pub fn validate_transaction(utx: Extrinsic) -> TransactionValidity {
/// This doesn't attempt to validate anything regarding the block.
pub fn execute_transaction(utx: Extrinsic) -> ApplyExtrinsicResult {
let extrinsic_index: u32 = storage::unhashed::get(well_known_keys::EXTRINSIC_INDEX).unwrap();
// Arbitrary limit on test-runtime block size.
if extrinsic_index > 15 {
Copy link
Member

Choose a reason for hiding this comment

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

Could we not add a custom extrinsic type here: https://github.com/paritytech/substrate/blob/master/test-utils/runtime/src/lib.rs#L110

That always returns ExhaustsResources in validate_transaction?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on that, I remember several times it was hard figuring out what mocked result is returned and based on what

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea. Addressed.

@@ -230,7 +230,7 @@ impl<A, B, Block, C> ProposerInner<B, Block, C, A>
Ok(()) => {
debug!("[{:?}] Pushed to the block.", pending_tx_hash);
}
Err(sp_blockchain::Error::ApplyExtrinsicFailed(sp_blockchain::ApplyExtrinsicFailed::Validity(e)))
Err(sp_blockchain::Error::ApplyExtrinsicFailed(ApplyExtrinsicFailed::Validity(e)))
Copy link
Member

Choose a reason for hiding this comment

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

We really need to factor this out and make it reusable for Polkadot: https://github.com/paritytech/polkadot/blob/master/validation/src/block_production.rs#L299

Copy link
Contributor Author

@tomusdrw tomusdrw Mar 4, 2020

Choose a reason for hiding this comment

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

Agree, I think it deserves a separate issue though. I'll make a companion PR for now.
EDIT: Seems the companion PR is not necessary, cause the skipping logic is not present there.

@NikVolf NikVolf added this to the 2.0 milestone Mar 4, 2020
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Almost looks good, just some small last changes.

// then
// block should have some extrinsics although we have some more in the pool.
assert_eq!(block.extrinsics().len(), 2);
assert_eq!(txpool.ready().count(), 6);
Copy link
Member

Choose a reason for hiding this comment

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

I still would like to see that we build a second block here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then it means that the transaction cannot always exhaust resources. I guess it's fine, I'll change it so that it exhaust resources if it's not the ONLY/FIRST transaction in the block. Then keeping that variant as Transfer extension makes even more sense to me.

Transfer {
transfer: Transfer,
signature: AccountSignature,
exhaust_resources: bool,
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this just a distinct variant in this enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has to share most of the logic with Transfer, since it has to come from some sender and have some nonce. I could simplify it to:

Extrinsic::ExhaustResources(from, nonce)

but I felt it's too arbitrary and it made more sense to just extend transfer.

@gavofyork gavofyork added A8-looksgood and removed A0-please_review Pull request needs code review. labels Mar 5, 2020
@gavofyork
Copy link
Member

@tomusdrw @bkchr UI tests failing?

@bkchr
Copy link
Member

bkchr commented Mar 5, 2020

@tomusdrw @bkchr UI tests failing?

Just needed master merge, as done by @NikVolf

@gavofyork gavofyork merged commit 9e52443 into master Mar 5, 2020
@gavofyork gavofyork deleted the td-dont-ban-when-skipping branch March 5, 2020 16:00
General-Beck pushed a commit to General-Beck/substrate that referenced this pull request Mar 6, 2020
* Don't remove invalid transactions when skipping.

* Use a special kind of extrinsic instead of arbitrary limit.

* Fix txpool tests.

* Attempt to create more blocks.

* Bump lock

Co-authored-by: Gavin Wood <github@gavwood.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
General-Beck pushed a commit to General-Beck/substrate that referenced this pull request Mar 17, 2020
* Don't remove invalid transactions when skipping.

* Use a special kind of extrinsic instead of arbitrary limit.

* Fix txpool tests.

* Attempt to create more blocks.

* Bump lock

Co-authored-by: Gavin Wood <github@gavwood.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
bkchr added a commit that referenced this pull request Apr 13, 2023
The check was intially added by: #5121

But a later pr fixed it properly: #9789

TLDR: We don't need to check for skipped anymore, as we already remove all transactions that are
being unlocked by an invalid transactions and thus, we will not tag them as invalid directly because
the nonce for example is incorrect.

Fixes: #13911
bkchr added a commit that referenced this pull request Apr 14, 2023
The check was intially added by: #5121

But a later pr fixed it properly: #9789

TLDR: We don't need to check for skipped anymore, as we already remove all transactions that are
being unlocked by an invalid transactions and thus, we will not tag them as invalid directly because
the nonce for example is incorrect.

Fixes: #13911
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
The check was intially added by: paritytech#5121

But a later pr fixed it properly: paritytech#9789

TLDR: We don't need to check for skipped anymore, as we already remove all transactions that are
being unlocked by an invalid transactions and thus, we will not tag them as invalid directly because
the nonce for example is incorrect.

Fixes: paritytech#13911
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test node bans allegedly valid bulk extrinsics
4 participants