stellar / stellar-cli

CLI for Stellar developers
Apache License 2.0
74 stars 72 forks source link

Return simulation budget information even in case of error #1019

Open kalepail opened 1 year ago

kalepail commented 1 year ago

There are currently quite a number or fees and limits for Soroban transaction submission https://soroban.stellar.org/docs/fundamentals-and-concepts/fees-and-metering#resource-limits

A transaction can fail on any of them, but in the case of a failure there's no clear way to check which one it failed on or by how much. This makes fixing the failure impossible.

My ideal scenario is that the failure would return information about all these fee types and which one you exceeded and by how much.

A true best case change though would be to actually expand both the success and failure case to map out all the fees and how you stack up against them. So where we currently only have cpu and mem we should be including stats for ALL the cost metrics. This will make it trivial to see where areas for improvement might be considered in the case of success and where to hunt for fixes in cases of failure.

There's a number of discussions on Discord relevant to this issue:

Bosun-Josh121 commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

software engineering/ smart contract development background and contributor in previous hackthons(https://app.onlydust.com/u/Josh-121)

How I plan on tackling this issue

Review Current Fee and Limit Structure:

Analyze the existing fee and limit structure as detailed in the Soroban documentation. Understand the various metrics involved in transaction submissions (CPU, memory, etc.). Modify Transaction Submission Logic:

Implement changes in the transaction submission code to capture and report detailed information regarding all relevant fees and limits. Ensure that the transaction processing logic collects metrics for all fee types, including: CPU usage Memory usage Storage limits Any other applicable cost metrics Enhance Failure Responses:

Update the error handling mechanism to return detailed information about the specific fee type exceeded upon transaction failure. Provide clear messages that indicate which fee was surpassed and by how much, facilitating easier debugging for developers. Success Case Reporting:

Modify success responses to include a comprehensive report of all fees and resource usage metrics. This should detail how the transaction performed against each limit. Structure this report to highlight areas where the transaction was efficient or where it could be optimized further.

implement Testing

work on feedback & recommendation

gregemax commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have experience working with transaction processing systems and debugging failures due to limits and resource constraints. My work with Soroban transactions and other blockchain-based projects has given me a deep understanding of how fees and metering work, especially when it comes to identifying performance bottlenecks and optimizing for resource use. Additionally, I have worked on projects where handling failure cases with comprehensive feedback is crucial, which aligns perfectly with the need for enhanced feedback during transaction failure.

How I plan on tackling this issue

I would first analyze the current error handling structure in Soroban to understand what information is being returned. Then, I would implement logging mechanisms to capture the exceeded limits for all relevant resource categories (beyond just CPU and memory). This would include expanding the error message to reflect the fees or limits exceeded, with precise details for each metric. In case of success, I would enhance the feedback to provide insights into all fees and limits, making it easier to optimize future transactions.