Skip to content
CCPEDIAby Unity Nodes
App Development

Increase max message size in Daml Studio

17 posts803 views9 likesLast activity Apr 2022

  1. georgOP 1

    I’m getting the following error in Daml Studio:

    "Scenario service backend error: BErrorClient (ClientIOError (GRPCIOBadStatusCode StatusResourceExhausted (StatusDetails {unStatusDetails = \"Received message larger than max (4455861 vs. 4194304)\"
    

    Is there a way to increase that limit for the scenario service in Daml Studio?

  2. cocreature 2

    You can! Documented in Daml Assistant (daml) — Daml SDK 1.18.0 documentation

    Inlining the relevant section of daml.yaml:

    scenario-service:
      grpc-max-message-size: yourmaxmessagesizehere
    
  3. georg

    Does this indeed affect the in-IDE scenario service used in Daml Studio? Cause I don’t see the error message go away or change when setting this in daml.yaml. Or does it require SDK v1.8.0 to work?

  4. cocreature

    It has been there for a while, haven’t checked the exact version but definitely the last year or so.

    You do need to restart the IDE scenario service via Control-Shift-P reload window to have it be picked up.

  5. georg

    Double-checked, it doesn’t seem to resolve the issue. The error does seem related to the overall complexity of my test script (or particular do blocks), not to a single submission of a particularly complex transaction. I vaguely remember having hit that previously, where you suggested I might have to split my script into smaller chunks as the only possible option. Do you remember maybe, am I hitting a different limit than what’s being set with this parameter?

  6. cocreature

    The long script can result in nesting errors but not in max message size issues. Would it be possible to share your project?

  7. georg

    Shared in private due to large project size

  8. georg

    I also noticed the following: the documentation says

    grpc-max-message-size: ... If unspecified this defaults to 128MB (134217728 bytes)
    

    But my error message seems to suggest there’s a different default:

    "...Received message larger than max (4455861 vs. 4194304)"
    

    I’m not sure what’s going on here.

  9. cocreature 5

    This turned out to be a bug. The setting applied for messages sent towards the script service (primarily your code) but not towards messages coming back from the script service (the list of transactions). Fixed in Apply grpc-max-message-size in both directions in the script service by cocreature · Pull Request #12149 · digital-asset/daml · GitHub.

    That said, the example is so large that viewing the script results in Daml Studio is pretty slow and it’s impossible to understand anything so I’d still recommend to try to split it up.

  10. brijg11

    HI DAH team
    I am facing this issue and tried different values for grpc-max-message-size in daml.yaml without success with daml 1.18.1 and daml test.
    Which version of daml has this fix? and is there anything I can do without having to change the daml sdk version.

  11. cocreature

    The fix is in SDK 2.0 and newer. There is no real workaround for older versions apart from trying to shorten your scenario to ensure that you don’t exceed the message size so my recommendation is to upgrade.

  12. Turan

    This is still occurring with both the 2.1.0 and 2.0.0 plugin/sdk the config in daml.yaml is not being respected by the plugin when trying to run “Script results”

    daml.yaml (tried with both script-service & scenario-service)

    scenario-service:
      grpc-max-message-size: 134217728
    

    Error in vscode
    "Scenario service backend error: BErrorClient (ClientIOError (GRPCIOBadStatusCode StatusResourceExhausted (StatusDetails {unStatusDetails = \"Received message larger than max (4638343 vs. 4194304)\"})))"

  13. cocreature

    can you share code to reproduce this?

  14. Turan

    Of the config not being respected or the actual script? because for the first you can see in the error message that the config in daml.yaml is not respected by the plugin unless it derives its max from another config value we haven’t put?

  15. cocreature

    The actual script that exceeds the limit.

  16. Turan

    Sure here’s a random example

    module Count where
    
    import Daml.Script
    
    
    template Count
      with
        owner: Party
        value: Int
      where
        signatory owner
        observer owner
    
    example : Script ()
    example = do
    
      human <- allocatePartyWithHint "Human" (PartyIdHint "Human")
      humanId <- validateUserId "human"
      createUser (User humanId (Some human)) [CanActAs human]
    
      forA [0..10000] $ \p -> submit human do createCmd Count with owner = human, value = p
      pure()
    
  17. akrmn 1

    Hi @Turan, thank you for providing the script. I haven’t been able to reproduce your error directly; in my setup I get a timeout instead:

    "Scenario service backend error: BErrorClient (ClientIOError (GRPCIOBadStatusCode StatusDeadlineExceeded (StatusDetails {unStatusDetails = \"Deadline Exceeded\"})))"
    

    However, I was able to get the expected Received message larger than max error by tweaking your script to produce a single large contract rather than 10000 small ones,

    module Count where
    
    import Daml.Script
    
    template Count
      with
        owner: Party
        values: [Int]
      where
        signatory owner
        observer owner
    
    example : Script ()
    example = do
    
      human <- allocatePartyWithHint "Human" (PartyIdHint "Human")
      humanId <- validateUserId "human"
      createUser (User humanId (Some human)) [CanActAs human]
      submit human do createCmd Count with owner = human, values = replicate 1500000 1
      pure()
    
    # daml.yaml
    sdk-version: 2.1.0
    name: count
    version: 1.0.0
    source: Count.daml
    dependencies:
    - daml-prim
    - daml-stdlib
    - daml-script
    

    Soon after clicking on the Script results action, I got the expected error message,

    "Scenario service backend error: BErrorClient (ClientIOError (GRPCIOBadStatusCode StatusResourceExhausted (StatusDetails {unStatusDetails = \"Received message larger than max (6000340 vs. 4194304)\"})))"
    

    Then, I applied the solution offered by @cocreature, namely adding the following two lines to the bottom of the daml.yaml file and restarting the script service with Ctrl/Cmd-Shift-P, Reload Window

    script-service:
      grpc-max-message-size: 6000340
    

    This time around, the Script results action completed successfully and showed me the ledger with a single large contract.

    Now, this makes me think that you either need to make sure to reload the Daml Studio/VS Code window so the changes to your daml.yaml file take effect, or that maybe your daml.yaml file is somehow being completely ignored (though I would need to know more about your project structure to look into this).

    tl;dr: please try reloading the Daml Studio window (Ctrl/Cmd-Shift-P, Reload Window) after changing the daml.yaml file