Skip to content

fix(methods): validate contract events size limit in simulateTransaction (#964) - #992

Open
Tyagiquamar wants to merge 2 commits into
stellar:mainfrom
Tyagiquamar:fix/964-simulate-tx-error
Open

Tyagiquamar wants to merge 2 commits into
stellar:mainfrom
Tyagiquamar:fix/964-simulate-tx-error

Conversation

@Tyagiquamar

Copy link
Copy Markdown

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

  • Updated \cmd/stellar-rpc/internal/methods/simulate_transaction.go\ to sum \XDR\ string lengths of returned contract events.
  • If total size exceeds \maxContractEventsSizeBytes, returns a descriptive JSON-RPC error.
  • Added unit test \TestSimulateTransaction_ContractEventsSizeLimit\ in \simulate_transaction_test.go.

Verification

  • Added and verified unit tests in \cmd/stellar-rpc/internal/methods.

Copilot AI balanced review requested due to automatic review settings September 9, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_bytes is 4294967295 (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 current ConfigSettingContractEventsV0 limit 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.

Comment thread cmd/stellar-rpc/internal/methods/simulate_transaction.go
…d events size limit

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
Copilot AI review requested due to automatic review settings September 11, 2026 18:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Note

Copilot is running an experiment and ran this review at Balanced.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simulateTransaction reports success for transactions that later fail on the contract-event size limit

2 participants