-
Notifications
You must be signed in to change notification settings - Fork 202
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
Separate fee handling for inner tx of type move balance #5627
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## feat/relayedv3 #5627 +/- ##
==================================================
- Coverage 80.05% 80.05% -0.01%
==================================================
Files 706 706
Lines 93789 93809 +20
==================================================
+ Hits 75081 75096 +15
- Misses 13369 13372 +3
- Partials 5339 5341 +2
☔ View full report in Codecov by Sentry. |
@@ -286,3 +290,15 @@ func GetUserAccount( | |||
} | |||
return nil | |||
} | |||
func subFeesFromRelayer(tx, userTx *transaction.Transaction, economicsFee process.FeeHandler, relayer *integrationTests.TestWalletAccount) { |
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.
add empty line before
process/transaction/shardProcess.go
Outdated
shouldConsiderMoveBalanceFee := dstShardTxType == process.MoveBalance && | ||
txProc.enableEpochsHandler.IsFixRelayedMoveBalanceFlagEnabled() | ||
if shouldConsiderMoveBalanceFee { | ||
totalCost = txProc.economicsFee.ComputeMoveBalanceFee(tx) |
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.
this is not correct. Rewriting the totalCost to moveBalance - will only add the move balance part, and it will not use the gasLimit of the transaction. So it is only 50K + 1.5K*len(txData). You need to use ComputeTxFee(tx data.TransactionWithFeeHandler) *big.Int function. This handles correctly. Do this on all this implementation
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.
pushed, but as seen after tests it does not reach the desired behavior.. looking for another solution
@@ -962,15 +962,15 @@ func TestGuardAccounts_RelayedTransactionV1(t *testing.T) { | |||
alice, | |||
david, | |||
gasPrice, | |||
transferGas+guardianSigVerificationGas, | |||
1+guardianSigVerificationGas, |
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.
what is that magic 1?
maybe have a variable instead?
@@ -151,3 +149,16 @@ func checkPlayerBalancesWithPenalization( | |||
assert.Equal(t, userAcc.GetNonce(), players[i].Nonce) | |||
} | |||
} | |||
|
|||
func appendFeeToTotalFees(relayerTx, userTx *transaction.Transaction, economicsData process.EconomicsDataHandler, totalFees *big.Int) { | |||
if len(userTx.Data) == 0 { // move balance |
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.
can you remove the else and do a return on the if instead?
@@ -145,7 +146,13 @@ func (txProc *baseTxProcessor) checkTxValues( | |||
if tx.GasLimit < txProc.economicsFee.ComputeGasLimit(tx) { |
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.
can you extract what is inside if isUserTxOfRelayed into a method computeRelayedUserTxFee
you can then use this in the shard process as well.
require.Equal(t, vmcommon.Ok, retCode) | ||
require.Nil(t, err) | ||
rtxData := integrationTests.PrepareRelayedTxDataV1(innerTx) | ||
rTxGasLimit := 1 + gasLimit + uint64(len(rtxData)) |
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 are still some magic 1's here and in other places.
Could you replace with some constant/variable?
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.
done, replaced everywhere
rTxGasLimit := 1 + gasLimit + uint64(len(rtxData)) | ||
rtx := vm.CreateTransaction(0, innerTx.Value, relayerAddr, sndAddr, gasPrice, rTxGasLimit, rtxData) | ||
rtxData := integrationTests.PrepareRelayedTxDataV1(innerTx) | ||
rTxGasLimit := 1 + gasLimit + uint64(len(rtxData)) |
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.
here as well there is a magic 1
@@ -1124,13 +1125,13 @@ func TestGuardAccounts_RelayedTransactionV2(t *testing.T) { | |||
alice, | |||
david, | |||
gasPrice, | |||
transferGas+guardianSigVerificationGas, | |||
1, |
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.
can you replace with some variable?
require.Equal(t, vmcommon.Ok, retCode) | ||
require.Nil(t, err) | ||
rtxData := integrationTests.PrepareRelayedTxDataV1(userTx) | ||
rTxGasLimit := 1 + gasLimit + uint64(len(rtxData)) |
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.
can you replace the 1 with a variable instead?
also valid in other places in this file
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-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
?