Unexpected Behaviour Hex-Encoding Negative `BigInt`s
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- rust
- Domaine
- api, blockchain
Piste de recherche
Commencez par lire l’implémentation de typeConversions.bigIntToHex dans HostExports ainsi que le comportement de num::BigInt::to_bytes_be. Comparez la référence d’encodage documentée de go-ethereum avec les trois comportements proposés pour les valeurs négatives, puis déterminez quelle politique est acceptable sans rompre la compatibilité des fonctions d’hôte. C’est terminé lorsque le comportement et les implications en matière de compatibilité sont décidés et couverts par les tests ou la documentation pertinents.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
I would like to report some behaviour that seems unexpected to me.
What is the current behavior?
Encoding a negative BigInt value will return the hex of its absolute value. So -42 will be encoded as 0x2a.
What is the expected behavior?
Looking into the code, it looks like num::BigInt::to_bytes_be returns the big-endian bytes for its absolute value. This causes typeConversions.bigIntToHex to encode absolute values of its BigInt parameter.
This is a bit unexpected to me, and I would have expected either:
- To sign prefix the hex value (so
42becomes0x2aand-42becomes-0x2a). This is more inline with hownum::BigIntwould hex-format values. - To hex encode the value in 2's compliment notation. (so
42becomes0x2aand-42becomes0xd6). In looking at the code, this encoding implementation requires no leading 0s in the hex representation. This would mean that with 2's compliment, there would be multiple numbers with the same hex representation (for example255would be0xffand-1would also be0xff). - Disallow hex-encoding negative big integers. From the documentation for the
typeConversions.bigIntToHeximplementation in theHostExports, it mentionsgo-ethereumencoding rules as the reference. By those rules, hex marshalling for negative numbers is explicitly prohibited, so following that here would also make sense:Negative integers are not supported at this time. Attempting to marshal them will return an error. Values larger than 256bits are rejected by Unmarshal but will be marshaled without error.
Unfortunately, all of these suggestions would be breaking changes (which I imagine should be avoided for subgraph host function implementations).
- Langage dominant
- Rust
- Étoiles
- 3.2k
- Forks
- 1.1k
- Merge moyen
- 4 j 1 h
- PR mergées (30 j)
- 1
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de graphprotocol/graph-node
-
current: include emits an all-null bucket for dimensionless aggregations, nulling the whole response Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
graphprotocol/graph-node#6719 ·
-
RUSTSEC-2026-0194: Quadratic run time when checking a start tag for duplicate attribute names Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
graphprotocol/graph-node#6673 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
graphprotocol/graph-node#6650 · 1 commentaire ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
graphprotocol/graph-node#6722 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
graphprotocol/graph-node#6721 ·
Toutes les issues de graphprotocol/graph-node
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100