-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix /transaction/cost
api route
#5880
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## rc/v1.7.0 #5880 +/- ##
==========================================
Coverage 79.95% 79.96%
==========================================
Files 731 731
Lines 96312 96329 +17
==========================================
+ Hits 77006 77028 +22
+ Misses 13918 13912 -6
- Partials 5388 5389 +1 ☔ View full report in Codecov by Sentry. |
@@ -91,7 +98,9 @@ func (ate *apiTransactionEvaluator) SimulateTransactionExecution(tx *transaction | |||
ate.mutExecution.Unlock() | |||
}() | |||
|
|||
return ate.txSimulator.ProcessTx(tx) | |||
currentHeader := ate.blockChain.GetCurrentBlockHeader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to treat the situation when the currentHeader is nil and take the genesis block. Otherwise the simulation won't work on the exact first block after the genesis :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -140,8 +149,9 @@ func (ate *apiTransactionEvaluator) simulateTransactionCost(tx *transaction.Tran | |||
} | |||
|
|||
costResponse := &transaction.CostResponse{} | |||
currentHeader := ate.blockChain.GetCurrentBlockHeader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -407,3 +407,23 @@ func TestApiTransactionEvaluator_ComputeTransactionGasLimit(t *testing.T) { | |||
require.Nil(t, err) | |||
require.True(t, called) | |||
} | |||
|
|||
func TestApiTransactionEvaluator_GetCurrentHeader(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normal allin test: v1.6.15-dev-config-eb2e06c06d -> fix-tx-cost-api-route-rc-98d49f4624
--- Specific errors ---
block hash does not match 1296
wrong nonce in block 650
miniblocks does not match 0
num miniblocks does not match 0
miniblock hash does not match 0
block bodies does not match 0
receipts hash missmatch 0
/------/
--- Statistics ---
Nr. of all ERRORS: 1
Nr. of all WARNS: 350
Nr. of new ERRORS: 1
Nr. of new WARNS: 2
Nr. of PANICS: 0
/------/
--- ERRORS ---
/------/
Reasoning behind the pull request
BlockChainHook
used inside the components that calculate the transaction cost: BlockChainHook didn't have aCurrentHeader
set.Proposed changes
BlockChainHook
used for transaction cost computation.Testing procedure
devnet
on shard 1 with this branch and ensure the cost is computed correctly for the example from themx-chain-proxy-go
GitHub issuePre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?