-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
chainHead: Error on duplicate unpin hashes #3313
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@@ -759,10 +759,13 @@ impl<Block: BlockT, BE: Backend<Block>> SubscriptionsInner<Block, BE> { | |||
return Err(SubscriptionManagementError::SubscriptionAbsent) | |||
}; | |||
|
|||
// Keep only unique hashes. | |||
let hashes = hashes.into_iter().collect::<HashSet<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should error on duplicated hashes instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that sounds good to me, I'll create a small PR in the spec to clarify this (part of paritytech/json-rpc-interface-spec#133)
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
The CI pipeline was cancelled due to failure one of the required jobs. |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious. What is the unintended consequence if there are duplicate hashes?
I ask because the only thing you do after the check is to call self.subscriptions.unpin_blocks()
. And if this is where the unintended behavior is triggered then maybe you should add the check there (i.e. in the called function) as it may be called somewhere else
Co-authored-by: Davide Galassi <davxy@datawok.net>
subscriptions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
The side-effect before this PR was that duplicate hashes could decrement the global counter of the blocks multiple times: polkadot-sdk/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs Lines 778 to 781 in aa68ea5
Have moved the duplicate check in the With this check enforced, we'll return an error before doing any other work. The downside of moving the check in the Thanks for the review everyone! 🙏 |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This PR addresses an issue where calling chainHead_unpin with duplicate hashes could lead to unintended side effects. This backports: paritytech/json-rpc-interface-spec#135 While at it, have added a test to check that the global reference count is decremented only once on unpin. cc @paritytech/subxt-team --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Davide Galassi <davxy@datawok.net>
This PR addresses an issue where calling chainHead_unpin with duplicate hashes could lead to unintended side effects.
This backports: paritytech/json-rpc-interface-spec#135
While at it, have added a test to check that the global reference count is decremented only once on unpin.
cc @paritytech/subxt-team