Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the max_chunks limit to support large messages. #2110

Closed
dlin-me opened this issue May 9, 2023 · 2 comments
Closed

Increase the max_chunks limit to support large messages. #2110

dlin-me opened this issue May 9, 2023 · 2 comments
Assignees
Labels
bug Something isn't working community

Comments

@dlin-me
Copy link

dlin-me commented May 9, 2023

Problem description

Topic messages are limited to 20 chunks maximum by default. Each chunk is limited to 1024b (limited by HCS message size). We need a way to increase the max_chunks limit to support large messages.

Our system records MRVs with small values. Then, those MRVs aggregate to mint tokens.
In some of our use cases, It hit the limit of 20 chunks per message when more than 1000 MRVs aggregated to mint one token..

The default 20 chunks limit is set by default at:
https://vscode.dev/github/hashgraph/hedera-sdk-js/blob/develop/src/topic/TopicMessageSubmitTransaction.js#L84

But this can be set by the setMaxChunks method.

Step to reproduce

Our system records MRVs with small values. Then, those MRVs aggregate to mint tokens.
In some of our use cases, it takes over 1000 MRVs aggregated to mint one token. When this happened, we came across the following error:

{
...
severity: "ERROR"
textPayload: "2023-05-08T06:37:49.705Z [guardian-service,5e07e18b-6cab-4280-8db7-871c3691b4b2,mintDocumentBlock,block-runtime,63dc7cbd6105ab8065a4b34c]: Message with size 21306 too long for 20 chunks NR-LINKING|MzQ5NzYzMXxBUE18QVBQTElDQVRJT058MTQxMDQ2NTM0Mg|guardian-guardian-service-5ffcfddcfc-c688s|||guardian-guardian-service|"
timestamp: "2023-05-08T06:37:49.706283529Z"
}

It hit the limit of 20 chunks per message.

Expected behavior

We need a way ( maybe an environment variable) to increase this limit to support large token mint messages.

@dlin-me dlin-me changed the title We need a way to increase the max_chunks limit to support large messages. Increase the max_chunks limit to support large messages. May 9, 2023
@prernaadev01 prernaadev01 added bug Something isn't working community labels May 11, 2023
@samuraitruong
Copy link
Contributor

samuraitruong commented May 18, 2023

we can use the setMaxChunks function to fix this issue. I have tested this approach and it can mint tokens with > 1000 dmrv. Of course, we can introduce the env var to set maxChunks of just make it become a bigger number than 20. I think 100 maybe good enough

@timeout(HederaSDKHelper.MAX_TIMEOUT)
    public async submitMessage(
        topicId: string | TopicId,
        message: string,
        privateKey?: string | PrivateKey,
        transactionMemo?: string
    ): Promise<string> {
        const client = this.client;

        let messageTransaction: Transaction = new TopicMessageSubmitTransaction({
            topicId,
            message,
        }).setMaxTransactionFee(MAX_FEE)
        .setMaxChunks(50)


       ......
    }

@prernaadev01
Copy link
Collaborator

@samuraitruong Thank you for the suggestion. We have fixed this issue by adding the maxChunks parameter to .env of worker-service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community
Projects
None yet
Development

No branches or pull requests

4 participants