Skip to content

Conversation

@miiu96
Copy link
Contributor

@miiu96 miiu96 commented Aug 5, 2025

Reasoning behind the pull request

  • This PR addresses an issue with the /transaction/cost endpoint, which failed when handling relayed v3 transactions — specifically when the sender had no EGLD balance. The current behavior incorrectly simulates the transaction execution, causing invalid cost estimations in certain relayed transaction flows.

Proposed changes

  • Replaced the existing smart contract processor component with one that accurately simulates relayed transaction execution.

Testing procedure

1.	Call /transaction/cost with a v3 relayed transaction where the sender has zero EGLD.
2.	Confirm that the cost estimation completes successfully and returns a valid gas cost.
3.	Ensure existing non-relayed flows remain unaffected.

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 535b725927c500a1992083f1ec81cca10276d88d
  • Current Branch: fix-tx-cost-endpoint-sc-processor-proxy
  • mx-chain-go Target Branch: master
  • mx-chain-simulator-go Target Branch: main
  • mx-chain-testing-suite Target Branch: main
  • mx-chain-simulator-go Commit Hash: 615e55d9f82a1d2f59d5d3e0cd7234bdec6a9ada

🚀 Environment Variables:

  • TIMESTAMP: 2025_AUGUST_05__12_18_16
  • PYTEST_EXIT_CODE: ``

@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.03%. Comparing base (32b3365) to head (f424599).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7169      +/-   ##
==========================================
- Coverage   75.03%   75.03%   -0.01%     
==========================================
  Files         808      808              
  Lines      133760   133760              
==========================================
- Hits       100371   100362       -9     
- Misses      27689    27697       +8     
- Partials     5700     5701       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@sstanculeanu sstanculeanu left a comment

Choose a reason for hiding this comment

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

TBD the target branch

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: f424599f3edacd63afaa2d5af867cc79ae335a1b
  • Current Branch: fix-tx-cost-endpoint-sc-processor-proxy
  • mx-chain-go Target Branch: master
  • mx-chain-simulator-go Target Branch: main
  • mx-chain-testing-suite Target Branch: main
  • mx-chain-simulator-go Commit Hash: 615e55d9f82a1d2f59d5d3e0cd7234bdec6a9ada

🚀 Environment Variables:

  • TIMESTAMP: 2025_AUGUST_05__12_28_20
  • PYTEST_EXIT_CODE: ``

@andreibancioiu andreibancioiu requested a review from Copilot August 5, 2025 12:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the /transaction/cost endpoint to properly handle relayed v3 transactions when the sender has zero EGLD balance by replacing the smart contract processor with a proxy version that correctly simulates relayed transaction execution.

  • Replaces SmartContractProcessor with SmartContractProcessorProxy in transaction simulation
  • Adds comprehensive test coverage for relayed v3 transactions with zero balance senders
  • Ensures proper cost estimation for relayed transactions across different epochs

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
factory/processing/txSimulatorProcessComponents.go Updates transaction simulator to use SmartContractProcessorProxy for proper relayed transaction handling
integrationTests/chainSimulator/simulate/simulate_test.go Adds test case verifying cost estimation works for relayed v3 transactions with zero balance senders

err = cs.GenerateBlocks(1)
require.NoError(t, err)

dataTx := "ESDTTransfer@53484f572d633961633237@3e80@5061796d656e7420746f20504f5334@317820564f444b41204d495820323530204d4c20782033322e3030202b20317820574849534b59204d495820323530204d4c20782033322e3030202b203178204a4147455220434f4c4120323530204d4c20782033322e3030202b2031782047494e20544f4e494320323530204d4c20782033322e3030202b2031782043554241204c49425245203235304d4c20782033322e3030"
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The hex-encoded transaction data is a magic string that makes the test difficult to understand and maintain. Consider defining this as a constant with a descriptive name or extracting it to a helper function that builds the ESDT transfer data.

Suggested change
dataTx := "ESDTTransfer@53484f572d633961633237@3e80@5061796d656e7420746f20504f5334@317820564f444b41204d495820323530204d4c20782033322e3030202b20317820574849534b59204d495820323530204d4c20782033322e3030202b203178204a4147455220434f4c4120323530204d4c20782033322e3030202b2031782047494e20544f4e494320323530204d4c20782033322e3030202b2031782043554241204c49425245203235304d4c20782033322e3030"
dataTx := buildESDTTransferData(
"SHOW-c9ac27", // Token identifier (hex: 53484f572d633961633237)
"3e80", // Amount (hex, 16000 decimal)
"Payment to POS4", // Payment data (hex: 5061796d656e7420746f20504f5334)
"1x VODKA MIX 250 ML x 32.00 + 1x WHISKY MIX 250 ML x 32.00 + 1x JAGER COLA 250 ML x 32.00 + 1x GIN TONIC 250 ML x 32.00 + 1x CUBA LIBRE 250ML x 32.00", // Comment (hex: 317820564f444b41204d495820323530204d4c20782033322e3030202b20317820574849534b59204d495820323530204d4c20782033322e3030202b203178204a4147455220434f4c4120323530204d4c20782033322e3030202b2031782047494e20544f4e494320323530204d4c20782033322e3030202b2031782043554241204c49425245203235304d4c20782033322e3030
)

Copilot uses AI. Check for mistakes.
Address: sender.Bech32,
Balance: "0",
Pairs: map[string]string{
"454c524f4e446573647453484f572d633961633237": "12040002d820",
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The hex-encoded key-value pair for account state is a magic string that reduces test readability. Consider using constants or helper functions to make the ESDT token identifier and balance values more explicit.

Suggested change
"454c524f4e446573647453484f572d633961633237": "12040002d820",
hexEncode(esdtTokenIdentifier): esdtTokenBalanceHex,

Copilot uses AI. Check for mistakes.

cost, err = cs.GetNodeHandler(0).GetFacadeHandler().ComputeTransactionGasLimit(tx)
require.NoError(t, err)
require.Equal(t, uint64(855001), cost.GasUnits)
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The expected gas units value (855001) is a magic number that makes the test brittle and unclear. Consider defining this as a named constant or adding a comment explaining how this value was determined.

Suggested change
require.Equal(t, uint64(855001), cost.GasUnits)
require.Equal(t, uint64(expectedGasUnitsAfterEpochChange), cost.GasUnits)

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: f424599f3edacd63afaa2d5af867cc79ae335a1b
  • Current Branch: fix-tx-cost-endpoint-sc-processor-proxy
  • mx-chain-go Target Branch: master
  • mx-chain-simulator-go Target Branch: main
  • mx-chain-testing-suite Target Branch: main
  • mx-chain-simulator-go Commit Hash: 615e55d9f82a1d2f59d5d3e0cd7234bdec6a9ada

🚀 Environment Variables:

  • TIMESTAMP: 2025_AUGUST_07__08_40_30
  • PYTEST_EXIT_CODE: 1

@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: f424599f3edacd63afaa2d5af867cc79ae335a1b
  • Current Branch: fix-tx-cost-endpoint-sc-processor-proxy
  • mx-chain-go Target Branch: master
  • mx-chain-simulator-go Target Branch: main
  • mx-chain-testing-suite Target Branch: main
  • mx-chain-simulator-go Commit Hash: 615e55d9f82a1d2f59d5d3e0cd7234bdec6a9ada

🚀 Environment Variables:

  • TIMESTAMP: 2025_AUGUST_07__10_25_55
  • PYTEST_EXIT_CODE: ``

@github-actions
Copy link

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: f424599f3edacd63afaa2d5af867cc79ae335a1b
  • Current Branch: fix-tx-cost-endpoint-sc-processor-proxy
  • mx-chain-go Target Branch: master
  • mx-chain-simulator-go Target Branch: main
  • mx-chain-testing-suite Target Branch: main
  • mx-chain-simulator-go Commit Hash: 615e55d9f82a1d2f59d5d3e0cd7234bdec6a9ada

🚀 Environment Variables:

  • TIMESTAMP: 2025_AUGUST_18__07_31_54
  • PYTEST_EXIT_CODE: 1

@github-actions
Copy link

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: f424599f3edacd63afaa2d5af867cc79ae335a1b
  • Current Branch: fix-tx-cost-endpoint-sc-processor-proxy
  • mx-chain-go Target Branch: master
  • mx-chain-simulator-go Target Branch: main
  • mx-chain-testing-suite Target Branch: main
  • mx-chain-simulator-go Commit Hash: 615e55d9f82a1d2f59d5d3e0cd7234bdec6a9ada

🚀 Environment Variables:

  • TIMESTAMP: 2025_AUGUST_18__10_23_12
  • PYTEST_EXIT_CODE: 1

@sstanculeanu sstanculeanu merged commit bd0267e into master Sep 9, 2025
13 of 19 checks passed
@sstanculeanu sstanculeanu deleted the fix-tx-cost-endpoint-sc-processor-proxy branch September 9, 2025 06:30
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.

5 participants