Abstract
This PR enhances error handling in the Pyth oracle contract on TON by implementing a “soft throw” mechanism. Instead of failing transactions with hard exceptions, the contract now catches errors and returns structured error responses to callers. This approach maintains transaction success while providing detailed error information, allowing clients to handle failures gracefully.
Rationale
TON’s transaction model treats exceptions as fatal errors that revert the entire transaction. This behavior creates challenges for client applications that need to handle potential failures in price feed updates or parsing operations.
The soft throw implementation:
- Wraps critical functions in try-catch blocks to capture exceptions
- Introduces a standardized error response format that includes:
- Error code for programmatic handling
- Original operation code for context
- Custom payload preservation for request correlation
This approach offers several advantages:
- Transactions complete successfully even when price feed operations encounter errors
- Clients receive detailed error information rather than generic transaction failures
- Custom payloads are preserved, maintaining request context for asynchronous processing
- Applications can implement more sophisticated error handling and recovery strategies
Description
This proposal upgrades the Pyth oracle program on TON with the following major change:
- soft throw instead of revert - PR 2413
Implementation Plan
Proposal id: BNHWWtZpZGWVv8i6WhjZKnneUkqVufcRAQy19ssLECKh
Verify the implementation by comparing the hash:
- checkout the pyth-crosschain repo
pnpm install --frozen-lockfile
pnpm turbo build --filter "@pythnetwork/pyth-ton"
- check that the
hash
in the output matches with thepackage hash
in the proposal
After this upgrade has been implemented and tested, a subsequent OP-PIP for the TON Mainnet will be introduced.