Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GraphQL] Add a mutation payload size (#18017)
## Description The mutation payload can be a lot higher than a query payload, due to the possibility of passing a large transaction data (e.g., publishing a package). This PR adds a different check for when a mutation is requested, and adds a `max_tx_payload_size` variable that holds the max bytes that can be sent through a GraphQL mutation request. The total sum of `txBytes + signatures` of all GraphQL mutation or `txBytes` in a `dryRunTransactionBlock` query have to be below the `max_tx_payload_size`. The `max_tx_payload_size` is computed based on the `protocol_version -> max_tx_bytes` and a Base64 overhead as follows: `max_tx_bytes * 4 / 3` ## Test plan Added several tests. `cd crates/sui-graphql-rpc` `cargo nextest run --features pg_integration -- test_query test_mutation test_dry_run_transaction test_transaction_dry_run` --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [x] GraphQL: Added a `max_tx_payload_size` variable to protect against large transaction queries. The sum of `txBytes + signatures` in all GraphQL mutation `executeTransactionBlock` nodes or `txBytes` in `dryRunTransactionBlock` nodes from a query have to be below the `max_tx_payload_size`. The `max_tx_payload_size` is computed based on the `protocol_version -> max_tx_bytes` and a Base64 overhead as follows: `max_tx_bytes * 4 / 3` Added also a check that the overall query size is not larger than `max_tx_payload_size` + `max_query_payload_size`, where `max_query_payload_size` is the `read` part of the query. - [ ] CLI: - [ ] Rust SDK: --------- Co-authored-by: Ashok Menon <[email protected]>
- Loading branch information