Skip to content
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

Added fix for relayed move balance to non payables #6382

Merged
merged 8 commits into from
Aug 17, 2024

Conversation

sstanculeanu
Copy link
Collaborator

@sstanculeanu sstanculeanu commented Aug 8, 2024

Reasoning behind the pull request

  • invalid feedback on relayed move balance to non payables

Proposed changes

  • new flag + fix relayed move balance to non payables
  • fix this linter issue

Testing procedure

  • standard system test + scenario

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?

@andreibancioiu andreibancioiu self-requested a review August 9, 2024 07:07
@@ -330,6 +330,9 @@
# MultiESDTNFTTransferAndExecuteByUserEnableEpoch represents the epoch when enshrined sovereign cross chain opcodes are enabled
MultiESDTNFTTransferAndExecuteByUserEnableEpoch = 9999999

# FixRelayedMoveBalanceToNonPayableSCEnableEpoch represents the epoch when the fix for relayed move balance to non payable sc will be enabled
FixRelayedMoveBalanceToNonPayableSCEnableEpoch = 7
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since it also involves meta transaction is invalid, is there a umbrella term to cover both cases, to be used in the flag name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

reason behind it(other than no umbrella term found): although the meta contract is payable, you are not allowed to execute a move balance to it, being on meta, thus making it non payable.

@@ -122,6 +122,7 @@ func createEnableEpochsConfig() config.EnableEpochs {
RelayedTransactionsV3EnableEpoch: 105,
FixRelayedBaseCostEnableEpoch: 106,
MultiESDTNFTTransferAndExecuteByUserEnableEpoch: 107,
FixRelayedMoveBalanceToNonPayableSCEnableEpoch: 107,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe the same as RelayedTransactionsV3EnableEpoch (I know it's just a test)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right, updated to 108

@@ -267,6 +267,76 @@ func TestRelayedTransactionInMultiShardEnvironmentWithChainSimulatorScCalls(t *t
}
}

func TestRelayedTransactionInMultiShardEnvironmentWithChainSimulatorInvalidInnerMoveBalance(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice test!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not "invalid" per se, but "with sending to non-payable contract". Can also stay as it is.

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 name TestRelayedTransactionInMultiShardEnvironmentWithChainSimulatorInnerMoveBalanceToNonPayableSC

@@ -2343,7 +2343,6 @@ func testChainSimulatorChangeMetaData(t *testing.T, issueFn issueTxFunc) {
[]byte(core.ESDTRoleNFTUpdate),
}
tx = setSpecialRoleTx(nonce, addrs[1].Bytes, addrs[0].Bytes, tokenID, roles)
nonce++

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not obvious why the test was changed. Perhaps leave a comment in the PR (directly here on GitHub)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

indeed, this was a linter issue, raised here, added on PR description

@@ -500,14 +500,28 @@ func (txProc *txProcessor) processMoveBalance(

isPayable, err := txProc.scProcessor.IsPayable(tx.SndAddr, tx.RcvAddr)
if err != nil {
errRefund := txProc.removeConsumedValueFromSender(tx, acntSrc, isUserTxOfRelayed)
if errRefund != nil {
log.Warn("failed to return funds to sender after check if receiver is payable", "error", errRefund)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Warn or error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

upgraded to error

@@ -543,6 +557,31 @@ func (txProc *txProcessor) processMoveBalance(
return nil
}

func (txProc *txProcessor) removeConsumedValueFromSender(
Copy link
Collaborator

Choose a reason for hiding this comment

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

refund instead of remove?

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 to revertConsumedValueFromSender

@@ -543,6 +557,31 @@ func (txProc *txProcessor) processMoveBalance(
return nil
}

func (txProc *txProcessor) removeConsumedValueFromSender(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename as remove seems like subtracting
maybe revertConsumedValueFromSender

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

Copy link

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 02057fea33a7b4891c8acbcd861d26a9e80e227b
  • Current Branch: fix_relayed_movebalance_to_nonpayable
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: ``
  • mx-chain-testing-suite Target Branch: ``

🚀 Environment Variables:

  • TIMESTAMP: 13082024-072434
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

Copy link

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 52148713a203148628f07d0fdb084b229c05d753
  • Current Branch: fix_relayed_movebalance_to_nonpayable
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: ``
  • mx-chain-testing-suite Target Branch: ``

🚀 Environment Variables:

  • TIMESTAMP: 14082024-084448
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

Copy link

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 2a3b3310a9ed3b398b720484e03a2e8ac52a2c4e
  • Current Branch: fix_relayed_movebalance_to_nonpayable
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: rc/v1.7.next1
  • mx-chain-testing-suite Target Branch: rc/v1.7.next1

🚀 Environment Variables:

  • TIMESTAMP: 16082024-120521
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

Copy link
Contributor

@elvisboghiu elvisboghiu left a comment

Choose a reason for hiding this comment

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

System Test results

Normal allin test: v1.7.13-dev-config-aebb55e8e0 -> fix_relayed_movebalance_to-760583c822

--- Specific errors ---
block hash does not match 366
wrong nonce in block 376
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: 4
Nr. of all WARNS: 269
Nr. of new ERRORS: 4
Nr. of new WARNS: 44
Nr. of PANICS: 0
/------/
--- ERRORS ---
ovh-p03-observer-2 :
Error: error calling SaveRoundsInfo, will retry driver = *host.hostDriver retrial in = error = connection not open while sending data on route for topic SaveRoundsInfo 1
ovh-p03-observer-3 :
Error: error calling SaveRoundsInfo, will retry driver = *host.hostDriver retrial in = error = connection not open while sending data on route for topic SaveRoundsInfo 1
ovh-p03-observer-1 :
Error: error calling FinalizedBlock, will retry driver = *host.hostDriver retrial in = error = connection not open while sending data on route for topic FinalizedBlock 1
ovh-p03-observer-4 :
Error: error calling FinalizedBlock, will retry driver = *host.hostDriver retrial in = error = connection not open while sending data on route for topic FinalizedBlock 1
/------/
--- WARNINGS ---
ovh-p03-validator-28 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 5
Warn: basePreProcess.saveTransactionToStorage txHash = dataUnit = TransactionUnit error = missing transaction 6
Warn: basePreProcess.createMarshalledData: tx not found hash = 6
ovh-p03-validator-16 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 1
ovh-p03-observer-2 :
Warn: wt.Listen()-> connection problem error = connection not open 1
ovh-p03-validator-35 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 2
ovh-p03-validator-17 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 3
ovh-p03-validator-31 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 3
ovh-p03-validator-26 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 1
ovh-p03-observer-3 :
Warn: wt.Listen()-> connection problem error = connection not open 2
Warn: c.openConnection(), retrying in error = dial tcp connect: connection refused 1
ovh-p03-validator-30 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 3
ovh-p03-validator-12 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 1
ovh-p03-validator-20 :
Warn: shardProcessor.createMiniBlocks error = shard is stuck shard = 2
ovh-p03-observer-1 :
Warn: wt.Listen()-> connection problem error = connection not open 2
Warn: c.openConnection(), retrying in error = dial tcp connect: connection refused 1
ovh-p03-validator-8 :
Warn: processDebugger: node is stuck last committed round = 1
ovh-p03-observer-4 :
Warn: wt.Listen()-> connection problem error = connection not open 2
Warn: c.openConnection(), retrying in error = dial tcp connect: connection refused 1
/------/

@elvisboghiu elvisboghiu merged commit 2474c88 into rc/v1.7.next1 Aug 17, 2024
10 checks passed
@elvisboghiu elvisboghiu deleted the fix_relayed_movebalance_to_nonpayable branch August 17, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants