chainHead: Error on duplicate unpin hashes (#3313)

This PR addresses an issue where calling chainHead_unpin with duplicate
hashes could lead to unintended side effects.

This backports:
https://github.com/paritytech/json-rpc-interface-spec/pull/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 commit is contained in:
Alexandru Vasile
2024-02-14 16:41:07 +02:00
committed by GitHub
parent 5a50b8b8a3
commit 7ec692d11c
5 changed files with 203 additions and 2 deletions
@@ -424,6 +424,8 @@ where
// Block is not part of the subscription.
Err(ChainHeadRpcError::InvalidBlock)
},
Err(SubscriptionManagementError::DuplicateHashes) =>
Err(ChainHeadRpcError::InvalidDuplicateHashes),
Err(_) => Err(ChainHeadRpcError::InvalidBlock),
}
}