fix(methods): validate contract events size limit in simulateTransaction (#964) - #992
Open
Tyagiquamar wants to merge 2 commits into
Open
Tyagiquamar wants to merge 2 commits into
Tyagiquamar wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds contract-event size-limit validation to simulateTransaction.
Changes:
- Calculates simulated event size and reports overflow.
- Adds unit coverage for oversized events.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
simulate_transaction.go |
Adds event-size validation. |
simulate_transaction_test.go |
Tests overflow reporting. |
Suppressed comments (1)
cmd/stellar-rpc/internal/methods/simulate_transaction.go:235
- The maximum is a ledger network setting, not a fixed protocol constant. This repository already runs networks where
contract_events_v0.tx_max_contract_events_size_bytesis4294967295(integrationtest/infrastructure/docker/upgrades/unlimited.p27.json:39-41), so this code would reject simulations that those networks accept; it would also miss any network configured below 16 KiB. Please propagate the currentConfigSettingContractEventsV0limit loaded for the simulated ledger and compare against that value.
const defaultMaxContractEventsSizeBytes uint64 = 16384
if simResp.Error == "" && totalEventsSize > defaultMaxContractEventsSizeBytes {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…d events size limit Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
Comment on lines
+247
to
+249
| const defaultMaxContractEventsSizeBytes uint64 = 16384 | ||
| if simResp.Error == "" && totalEventsSize > defaultMaxContractEventsSizeBytes { | ||
| simResp.Error = fmt.Sprintf("total contract events size (%d bytes) exceeds maximum limit (%d bytes)", totalEventsSize, defaultMaxContractEventsSizeBytes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #964 by validating contract events size limit in \simulateTransaction\ formatting step (\ormatResponse).
When contract events generated during simulation exceed \maxContractEventsSizeBytes\ (default 16384 bytes / 16 KiB), \simulateTransaction\ now returns an explicit error stating that the total contract events size limit was exceeded.
Changes
Verification