Description
Currently, when adding signature pairs to self._signature_map, duplicate entries can be inserted for the same body_bytes and pubKeyPrefix.
This happens because the code directly appends sigPair without verifying whether a signature from the same public key already exists.
Expected behavior:
Each (body_bytes, pubKeyPrefix) combination should have only one corresponding SignaturePair.
Actual behavior:
Duplicate signatures are appended, leading to redundant entries and potential inconsistencies.
Steps to reproduce
- Create a transaction and sign it multiple times using the same private key
- Inspect
self._signature_map[body_bytes].sigPair
- Observe duplicate
SignaturePair entries with the same pubKeyPrefix
Additional context
- This issue can lead to unnecessary payload size increase
- May cause inefficiencies or unexpected behavior in downstream processing
Proposed Fix
Add a deduplication check before appending:
self._signature_map.setdefault(body_bytes, basic_types_pb2.SignatureMap())
already_signed = any(
sp.pubKeyPrefix == public_key_bytes
for sp in self._signature_map[body_bytes].sigPair
)
if not already_signed:
self._signature_map[body_bytes].sigPair.append(sig_pair)
Hedera network
No response
Version
v0.2.5
Operating system
Windows
Description
Currently, when adding signature pairs to
self._signature_map, duplicate entries can be inserted for the samebody_bytesandpubKeyPrefix.This happens because the code directly appends
sigPairwithout verifying whether a signature from the same public key already exists.Expected behavior:
Each
(body_bytes, pubKeyPrefix)combination should have only one correspondingSignaturePair.Actual behavior:
Duplicate signatures are appended, leading to redundant entries and potential inconsistencies.
Steps to reproduce
self._signature_map[body_bytes].sigPairSignaturePairentries with the samepubKeyPrefixAdditional context
Proposed Fix
Add a deduplication check before appending:
Hedera network
No response
Version
v0.2.5
Operating system
Windows