Description
Which packages are impacted by your issue?
@graphprotocol/graph-ts
Describe the issue
Starting with v0.37.0, using Address.fromString
with a hardcoded string seems to be break the WASM bundle, which prevents the Subgraph from indexing
The problem can reflect as one of many fatal errors
I have personally encountered:
- Heap overflow
- Index out of bounds while reading memory
- Strings replaced with garbage data
- Valid entity names not found in the store
- Nothing (rarely, the Subgraph miraculously still works)
The actual error raised depends on all factors which impact the WASM bundle such as the Subgraph manifest, the mapping code, the hardcoded strings themselves, etc.
Reproduction
Steps to Reproduce the Bug or Issue
- Take a perfectly fine existing Subgraph
- Embed a hardcoded address in a mapping file
- Deploy the Subgraph (either locally, with Subgraph Studio or any other provider)
- Check the indexing status
Using the repo above, the indexing fails with:
failed to process trigger: block #6175295 (0x0a00…923a), transaction 39cc1b35aec4018757928b34fe5f5bac790c5dcfa0cb97415be633556bd14e6e: error while executing at wasm backtrace:\t 0: 0x3077 - <unknown>!generated/schema/Gravatar#save\t 1: 0x316c - <unknown>!src/mapping/handleNewGravatar: Entity Gravatar[example.com]: missing value for non-nullable field `owner`: Entity Gravatar[example.com]: missing value for non-nullable field `owner`
Adding another line:
Address.fromString("0x0000000000000000000000000000000000000000");
Address.fromString("0x0000000000000000000000000000000000000000");
Then it fails with:
transaction 39cc1b35aec4018757928b34fe5f5bac790c5dcfa0cb97415be633556bd14e6e: error while executing at wasm backtrace:\t 0: 0x3077 - <unknown>!generated/schema/Gravatar#save\t 1: 0x316c - <unknown>!src/mapping/handleNewGravatar: Attempted to read past end of string content bytes chunk in handler `handleNewGravatar` at block #6175295 (0a00bbb445a002a6d152c2e8660e2ad32d9b1a97eb094fdf80c1d7052e8c923a)
If you instead move that same line inside the first handler:
Address.fromString("0x0000000000000000000000000000000000000000");
export function handleNewGravatar(event: NewGravatar): void {
Address.fromString("0x0000000000000000000000000000000000000000");
...
}
Then the error becomes:
transaction 39cc1b35aec4018757928b34fe5f5bac790c5dcfa0cb97415be633556bd14e6e: error while executing at wasm backtrace:\t 0: 0x308b - <unknown>!src/mapping/handleNewGravatar: Failed to convert string to Address/H160: 'Ԥդ֤< 찹㔛쒮蜁鉗㒋忾걛౹콝쮠䆗唳텫湎\u001c\u0007\fؔؔ \u001c\u0001\u0002\u001c\u0007\fٴٴ\u0001<\u0014肬ﻸ῾/狼ၢ뒥൮⛽\u001c\u0007\fڴڴ\u0014<\u0014搮楔哳侻詜댅ળ鎒콡\u001c\u0007\fܔܔ\u0014\u001c\u0001\u001c\u0007\fݴݴ\u0001\u001c\u0003ႏ\u0002\u001c\u0007\f\u0003\u001c\u0005娀诊\t\u001c\u0007\fߴߴ\u0005üÄ돍䨴䀀耀祭慮敭硥浡汰潣m\u001c\u0007\f࠴࠴Ä\u001c\u0001\u000b\u001c\u0007\f॔॔\u0001<F,ٔڔ۴ݔޔߔࠔऴॴ\u001c\u0001\u0004id\u001c\u0001\u0002\u001c\u0007\f৴৴\u0001,0\u001c\u0004ਔ\u001c6\f\u001c\u0001\towner<\u0014肬ﻸ῾/狼ၢ뒥൮⛽\u001c': Invalid character 'Ԥ' at position 0 in handler `handleNewGravatar` at block #6175295 (0a00bbb445a002a6d152c2e8660e2ad32d9b1a97eb094fdf80c1d7052e8c923a)
Expected behavior
I expect valid Subgraphs which work fine on v0.36.0 to continue working on v0.37.0
Screenshots or Videos
No response
Platform
@graphprotocol/graph-ts
versions v0.37.0
and v0.38.0
Subgraph Manifest
No response
Subgraph GraphQL Schema
No response
Additional context
No response