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

request body too large #6031

Open
scholtz opened this issue Jun 15, 2024 · 5 comments
Open

request body too large #6031

scholtz opened this issue Jun 15, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@scholtz
Copy link

scholtz commented Jun 15, 2024

Subject of the issue

I hit error: "request body too large" when deploying contract

Note that in my case this error has occured after upgrading the tealscript version and algokit which added more comments to the generated client code.

Please increase post body size to the limit where any future build of the contract would rather fail on "teal code too big" instead of the input body is too big.

Also note that Joe fixed the same thing for compiling contract between version of 0.95.0 and 0.95.1 and just removed the comments. But i think the increase of allowed post body in the algod is better solution then to trim comments.

Your environment

algokit localnet status
# algod status
Status: Running
Port: 4001
Last round: 558
Time since last round: 170.8s
Genesis ID: dockernet-v1
Genesis hash: LThUC5TvTwIUgf7bTZNMSZkVdd2iDzCTx4RYNyYQe/M=
Version: 3.24.0
# conduit status
Status: Running
# indexer-db status
Status: Running
# indexer status
Status: Running
Port: 8980
Last round: 558
Version: 3.5.0

Steps to reproduce

  1. git clone https://github.com/scholtz/BiatecCLAMM
  2. cd BiatecCLAMM
  3. git checkout feat/update-tealscript
  4. algokit localnet start
  5. npm i
  6. npm run test

Expected behaviour

If contract is too large i expect to receive contract too large error message.

Actual behaviour

image

URLTokenBaseHTTPError: Network request error. Received status 400 (Bad Request): http: request body too large
        {
      response: {
        body: { message: 'http: request body too large' },
        status: 400,
        headers: {
          '43': 'content-length',
          'application/json; charset=UTF-8': 'content-type',
          'Sat, 15 Jun 2024 09:55:00 GMT': 'date',
          Origin: 'vary'
        },
        text: '{"message":"http: request body too large"}\n',
        ok: false
      },
      status: 400
    }
@scholtz scholtz added the bug Something isn't working label Jun 15, 2024
@jannotti
Copy link
Contributor

jannotti commented Jun 15, 2024

Please increase post body size to the limit where any future build of the contract would rather fail on "teal code too big" instead of the input body is too big.

Are you asking that algod be changed to allow arbitrarily large code (with comments) as long as the generated bytecode is not too large? That would require a complicated change to allow streaming assembly of the TEAL while the request is arriving. That seems very challenging as it would also require changes to perform streaming parsing of the json that wraps the TEAL.

Without such a change, arbitrarily large programs (with huge comments) could crash algod with memory errors.

@joe-p
Copy link
Contributor

joe-p commented Jun 15, 2024

I think there are two more reasonable solutions here

  1. Modify SDKs to strip out comments (but keep the empty line so PC mapping is preserved) to avoid this limit. Is there any reason you'd explicitly want comments in the TEAL sent to algod?

  2. Make MaxTealSourceBytes configurable https://github.com/algorand/go-algorand/blob/master/daemon/algod/api/server/v2/handlers.go#L68

This could also be solved by high-level languages removing comments from emitted TEAL but as a developer comments in the TEAL are useful so just having a local algod with higher limit could be a nice QoL, but I think the SDK solution would be sufficient.

@scholtz
Copy link
Author

scholtz commented Jun 16, 2024

I dont specificly need the comments to be sent to algod in this issue. I opened this issue so that other developers when reaching the max program size and they have some comments in code does not hit the same issue. It is prefered by dev perspective to hit the error "program too large" instead "post body size too large". So just please increse allowed post body size to something more reasonable.

But on the other side, from time to time developers may be interested to write into blockchain also some metadata. For example in c# people have choice to build also symbols package and when decompiling the variable names as well as comments are included in the decompiled code. But i am not asking this feature in this specific issue, but it would be nice feature to have, for example for arc200 assets or arc72 nfts.

@FrankSzendzielarz
Copy link

The confusion here is probably that it is not immediately clear that there is no such server-wide "post body" limit size, as is most often the case when dealing with web apis. The algod code uses http.MaxBytesReader in various contexts with different values depending on the context, while in every case yielding the 'request body too big' type of error. So Scholtz is probably assuming that there is a server scoped post body limit that is too low, preventing the teal compile function from completing its job. In actual fact the teal compile function just checks for a 200k-ish hard coded limit using http.MaxBytesReader.

@scholtz
Copy link
Author

scholtz commented Jul 13, 2024

just increase the
https://github.com/algorand/go-algorand/blob/master/daemon/algod/api/server/v2/handlers.go#L68
MaxTealSourceBytes to 1M instead 200k pls

The error is thrown probably here:

tealDisassembleTest(t, largeProgram, 400, "http: request body too large", true)

scholtz added a commit to scholtz/go-algorand that referenced this issue Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants