hashgraph / hedera-sdk-js

Hedera™ Hashgraph SDK for JavaScript/TypeScript
https://docs.hedera.com/guides/docs/sdks
Apache License 2.0
276 stars 145 forks source link

FileAppendTransaction() hangs in v2.8.0 #921

Closed ed-marquez closed 2 years ago

ed-marquez commented 2 years ago

Description

When the compiled bytecode from a smart contract is too large to be added to Hedera in a single FileCreateTransaction(), then using FileAppendTransaction() with .setMaxChunks is necessary.

In v2.8.0, FileAppendTransaction() hangs and does not finish adding the contents to an existing file. This functionality worked fine in 2.7.0.

Steps to reproduce

  1. See line 74 in index.js in this code sandbox: https://codesandbox.io/s/hedera-example-contract-mint-associate-transfer-hts-li7cz

  2. Fork the sandbox and enter your testnet credentials in .env

  3. Run index.js using v2.8.0 and see FileAppendTransaction hang without any confirmations... (use 2.7.0 and the example completes successfully)

    Could also try FileAppendTransaction with any other large file using v2.8.0

Additional context

No response

Hedera network

testnet

Version

v2.8.0

Operating system

Windows

3Nigma commented 2 years ago

It looks like the FileAppendTransaction.getReceipt is being continuously mapped here: image to ExecutionState.Retry.

janaakhterov commented 2 years ago

Hmm, that map is correct as 18 means RECEIPT_NOT_FOUND which indicates we should try again. I believe this issue is likely to do with regenerating transaction IDs. Can you try disabling it on the transaction using FileAppendTransaction.setRegenerateTransactionIds(false). This definitely warrants further investigation though.

3Nigma commented 2 years ago

Tried running with .setRegenerateTransactionIds(false), but I'm getting the same continuous retry behavior.

janaakhterov commented 2 years ago

I believe I've now fixed this on develop and this will be part of our next release v2.11.0-beta.1. The reason the RECEIPT_NOT_FOUND was returned every time was because the index for the transaction IDs was incorrectly being left at the last index instead of wrapping back around during FileAppendTransaction.freezeWith(). I added a mocking test https://github.com/hashgraph/hedera-sdk-js/blob/develop/test/unit/FileAppendMocking.js And made sure our e2e test for a chunked FilleAppendTransaction worked https://github.com/hashgraph/hedera-sdk-js/blob/develop/test/integration/FileAppendIntegrationTest.js#L78