Skip to content

[RelayMiner] Improve SafeReadBody concurrency safety by copying buffer data#1650

Merged
red-0ne merged 3 commits intomainfrom
fix/safe-read-body-concurrency
Jul 8, 2025
Merged

[RelayMiner] Improve SafeReadBody concurrency safety by copying buffer data#1650
red-0ne merged 3 commits intomainfrom
fix/safe-read-body-concurrency

Conversation

@red-0ne
Copy link
Copy Markdown
Contributor

@red-0ne red-0ne commented Jul 8, 2025

Summary

Fix concurrency safety issue in SafeReadBody by copying buffer data before returning to prevent race conditions with sync.Pool reuse.

Primary Changes:

  • Add explicit data copy in SafeReadBody function to prevent race conditions
  • Ensure returned data is not affected by buffer pool reuse
  • Add comprehensive test coverage for SafeReadBody function

Secondary changes:

  • Add http_utils_test.go with various test scenarios including edge cases

Issue:

Problem: The SafeReadBody function was returning buffer data directly without copying, which could lead to race conditions when the buffer is returned to the sync.Pool and reused by other goroutines.

Type of change

  • Bug fix
  • New feature, functionality or library
  • Code health or cleanup
  • Documentation
  • Other (specify)

Sanity Checklist

  • I have updated the GitHub Issue Metadata: assignees, reviewers, labels, project, iteration and milestone
  • For docs: make docusaurus_start
  • For small changes: make go_develop_and_test and make test_e2e
  • For major changes: devnet-test-e2e label to run E2E tests in CI
  • For migration changes: make test_e2e_oneshot
  • 'TODO's, configurations and other docs

🤖 Generated with Claude Code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@red-0ne red-0ne changed the title fix: Improve SafeReadBody concurrency safety by copying buffer data [RelayMiner] Improve SafeReadBody concurrency safety by copying buffer data Jul 8, 2025
@red-0ne red-0ne self-assigned this Jul 8, 2025
@red-0ne red-0ne added bug Something isn't working relayminer Changes related to the Relayminer proxy Changes related to the Proxy off-chain Off-chain business logic labels Jul 8, 2025
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Shannon Jul 8, 2025
@red-0ne red-0ne moved this from 📋 Backlog to 🏗 In progress in Shannon Jul 8, 2025
@red-0ne red-0ne added this to the Interoperability & Bridging milestone Jul 8, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 8, 2025

The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks.

You may need to run make trigger_ci to submit an empty commit that'll trigger the tests.

GCP workloads (requires changing the namespace to 1650)
Grafana network dashboard for devnet-issue-1650

@github-actions github-actions bot added devnet push-image CI related - pushes images to ghcr.io labels Jul 8, 2025
@red-0ne red-0ne merged commit 6cbea6b into main Jul 8, 2025
10 of 11 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Shannon Jul 8, 2025
bryanchriswhite added a commit that referenced this pull request Jul 14, 2025
* pokt/main: (34 commits)
  [RelayMiner] feat: relay miner routes to multiple backend URLs based on RPC Type (#1633)
  [Morse Recovery] Added new addresses for recovery (#1667)
  [DOCS][SERVICE] Adding danger for Grove employees on mainnet service creation (#1666)
  [Foundation] Remove `pulsar` (#1661)
  [RelayMiner] Add timeout support and improved logging to query clients (#1657)
  [RelayMiner] Replace buffer copying with explicit cleanup pattern in SafeReadBody (#1658)
  [Testing] Fixing flaky unit tests to make CI more reliable (#1662)
  [Scripts] Notes, events and queries to query `block` events and `tx` events (#1660)
  [Morse Recovery] Add recovery addresses for issue #1654 (#1656)
  Refactor Tiltfile structure and enhance Pocketdex support. (#1640)
  [Morse Recovery] Updated Recovery Allowlist (#1651)
  [RelayMiner] Improve SafeReadBody concurrency safety by copying buffer data (#1650)
  Add a configurable max body size parameter to RelayMiner configuration. (#1566)
  Update upgrade_tx_v0.1.25_alpha.json
  feat: Improve relay request unmarshaling error handling and logging (#1649)
  [Docs] v0.1.25/26 upgrage artifacts (#1648)
  Remove settlement result from `EventClaimSettled` in `v0.127` release. (#1647)
  Revert "feat: Remove settlement result from EventClaimSettled" (#1643)
  [Code Health] Fix linter issues & attempt to fix flaky tests (#1646)
  Updating config-path-x.yaml with: schema header, owned app for config-path-1
  ...
bryanchriswhite added a commit that referenced this pull request Jul 16, 2025
* pokt/main: (69 commits)
  Refactor Tiltfile structure and enhance Pocketdex support. (#1640)
  [Morse Recovery] Updated Recovery Allowlist (#1651)
  [RelayMiner] Improve SafeReadBody concurrency safety by copying buffer data (#1650)
  Add a configurable max body size parameter to RelayMiner configuration. (#1566)
  Update upgrade_tx_v0.1.25_alpha.json
  feat: Improve relay request unmarshaling error handling and logging (#1649)
  [Docs] v0.1.25/26 upgrage artifacts (#1648)
  Remove settlement result from `EventClaimSettled` in `v0.127` release. (#1647)
  Revert "feat: Remove settlement result from EventClaimSettled" (#1643)
  [Code Health] Fix linter issues & attempt to fix flaky tests (#1646)
  Updating config-path-x.yaml with: schema header, owned app for config-path-1
  [Shannon SDK] Update the `shannon-sdk` in prep for `v0.1.26` (#1641)
  [RelayMiner] Add chain version retrieval functionality to block client (#1639)
  [RelayMiner] Avoid concurrent access to shared logger (#1636)
  [Telegram] Add Korbit channel to broadcast workflow (#1634)
  upgrade: Prepare upgrade plan for v0.1.26 (#1635)
  [RelayMiner] Add proper timeout handling for RelayMiner HTTP requests (#1595)
  [Code only] fix: implement backward compatible relay response signatures  (from #1629) (#1630)
  [Misc] Misc fixes & improvements (#1632)
  Added pocket-knife to ecosystem tools (#1622)
  ...
bryanchriswhite added a commit that referenced this pull request Jul 16, 2025
* refs/heads/chore/ibc: (69 commits)
  Refactor Tiltfile structure and enhance Pocketdex support. (#1640)
  [Morse Recovery] Updated Recovery Allowlist (#1651)
  [RelayMiner] Improve SafeReadBody concurrency safety by copying buffer data (#1650)
  Add a configurable max body size parameter to RelayMiner configuration. (#1566)
  Update upgrade_tx_v0.1.25_alpha.json
  feat: Improve relay request unmarshaling error handling and logging (#1649)
  [Docs] v0.1.25/26 upgrage artifacts (#1648)
  Remove settlement result from `EventClaimSettled` in `v0.127` release. (#1647)
  Revert "feat: Remove settlement result from EventClaimSettled" (#1643)
  [Code Health] Fix linter issues & attempt to fix flaky tests (#1646)
  Updating config-path-x.yaml with: schema header, owned app for config-path-1
  [Shannon SDK] Update the `shannon-sdk` in prep for `v0.1.26` (#1641)
  [RelayMiner] Add chain version retrieval functionality to block client (#1639)
  [RelayMiner] Avoid concurrent access to shared logger (#1636)
  [Telegram] Add Korbit channel to broadcast workflow (#1634)
  upgrade: Prepare upgrade plan for v0.1.26 (#1635)
  [RelayMiner] Add proper timeout handling for RelayMiner HTTP requests (#1595)
  [Code only] fix: implement backward compatible relay response signatures  (from #1629) (#1630)
  [Misc] Misc fixes & improvements (#1632)
  Added pocket-knife to ecosystem tools (#1622)
  ...

# Conflicts:
#	Makefile
#	Tiltfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working devnet devnet-test-e2e off-chain Off-chain business logic proxy Changes related to the Proxy push-image CI related - pushes images to ghcr.io relayminer Changes related to the Relayminer

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants