Skip to content

Conversation

@sstanculeanu
Copy link
Collaborator

Reasoning behind the pull request

  • node api does not take into account the latest fix for base cost of relayed when computing fees with refund

Proposed changes

  • proper fix

Testing procedure

  • system test + scenarios

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?

@sstanculeanu sstanculeanu added the ignore-for-release-notes Do not include item in release notes label Oct 23, 2024
@sstanculeanu sstanculeanu self-assigned this Oct 23, 2024
continue
}

if isSCRForSenderWithRefund(scr, txHashHex, txWithResults.GetTxHandler()) || isRefundForRelayed(scr, txWithResults.GetTxHandler()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you check if this fix also works for a relayed TX with a cross-shard inner transaction and the refund SCR is generated a few blocks later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated as discussed


for _, event := range txWithResults.log.GetLogEvents() {
if core.WriteLogIdentifier == string(event.GetIdentifier()) && !hasRefund {
if !check.IfNilReflect(userTx) && tep.enableEpochsHandler.IsFlagEnabledInEpoch(common.FixRelayedBaseCostFlag, epoch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need check.IfNilReflect ? don't you have simple check.IfNil ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

}

if isSCRForSenderWithRefund(scr, txHashHex, txWithResults.GetTxHandler()) || isRefundForRelayed(scr, txWithResults.GetTxHandler()) {
if !check.IfNilReflect(userTx) && tep.enableEpochsHandler.IsFlagEnabledInEpoch(common.FixRelayedBaseCostFlag, epoch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need check.IfNilReflect ? don't you have simple check.IfNil ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

gasUsed, fee := gfp.feeComputer.ComputeGasUsedAndFeeBasedOnRefundValue(tx, big.NewInt(0))
tx.GasUsed = gasUsed
tx.Fee = fee.String()
if !check.IfNilReflect(userTx) && gfp.enableEpochsHandler.IsFlagEnabledInEpoch(common.FixRelayedBaseCostFlag, tx.Epoch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check.IfNil

userTx *transaction.ApiTransactionResult,
refund *big.Int,
) {
if !check.IfNilReflect(userTx) && gfp.enableEpochsHandler.IsFlagEnabledInEpoch(common.FixRelayedBaseCostFlag, tx.Epoch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check.IfNil

@sstanculeanu sstanculeanu merged commit 676807a into revert_relayedv3 Oct 24, 2024
2 checks passed
@sstanculeanu sstanculeanu deleted the fix_gasused_and_fee branch October 24, 2024 08:36
tx.GasUsed = gasUsed
tx.Fee = fee.String()
if !check.IfNilReflect(userTx) && gfp.enableEpochsHandler.IsFlagEnabledInEpoch(common.FixRelayedBaseCostFlag, tx.Epoch) {
gasUsed, fee := gfp.feeComputer.ComputeGasUsedAndFeeBasedOnRefundValue(userTx, big.NewInt(0))
Copy link
Contributor

Choose a reason for hiding this comment

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

the code block L162-L174 is very similar to L189-L206, can you extract it in a function and call it in both places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in #6546


for _, event := range txWithResults.log.GetLogEvents() {
if core.WriteLogIdentifier == string(event.GetIdentifier()) && !hasRefund {
if !check.IfNil(userTx) && tep.enableEpochsHandler.IsFlagEnabledInEpoch(common.FixRelayedBaseCostFlag, epoch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here the two code blocks inside prepareTxWithResultsBasedOnLogs and in prepareScrsNoTx are similar

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in #6546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release-notes Do not include item in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants