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

Link inner txs to results #6529

Open
wants to merge 13 commits into
base: rc/v1.7.next1
Choose a base branch
from
Open

Conversation

sstanculeanu
Copy link
Collaborator

Reasoning behind the pull request

  • missing link between tx results and inner txs

Proposed changes

  • linked results to inner txs through prevTxHash of generated scrs

Testing procedure

  • standard system test + full relayed v3 testing with lots of scenarios + relayed v1/v2 tests that confirm no change happened in terms of generated scrs/logs

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?

@AdoAdoAdo AdoAdoAdo self-requested a review October 11, 2024 10:04
@@ -1412,19 +1412,19 @@ func (sc *scProcessor) isCrossShardESDTTransfer(sender []byte, receiver []byte,
func (sc *scProcessor) getOriginalTxHashIfIntraShardRelayedSCR(
tx data.TransactionHandler,
txHash []byte,
Copy link
Contributor

Choose a reason for hiding this comment

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

which txHash is this, is it the hash of the tx given as argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the hash of the initial SCR, which is the tx param

@@ -4083,21 +4083,24 @@ func TestProcessGetOriginalTxHashForRelayedIntraShard(t *testing.T) {
scr := &smartContractResult.SmartContractResult{Value: big.NewInt(1), SndAddr: bytes.Repeat([]byte{1}, 32)}
scrHash := []byte("hash")
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a bad naming for the relay tx hash? or this really represents the scr hash?

Copy link
Collaborator Author

@sstanculeanu sstanculeanu Oct 11, 2024

Choose a reason for hiding this comment

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

it is the hash of the provided scr

assert.Equal(t, scrHash, logHash)
assert.Equal(t, scrHash, originalTxHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check is not correct if the scrHash is indeed the hash of the scr.
Is this just a bad naming?
The originalTxHash should be the relay tx hash, or a transaction hash, not a scr hash.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the check is correct, the naming of the returned value is not perfect.. renamed

Copy link

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 072a375241e5b6d3803487cd05f06d850bcc96a2
  • Current Branch: inner_hash_on_scr_prev
  • 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: 11102024-121458
  • PYTEST_EXIT_CODE: 1
    🎉 MultiversX CI/CD Workflow Complete!

@multiversx multiversx deleted a comment from github-actions bot Oct 11, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 11, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 11, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 11, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 11, 2024
@sstanculeanu
Copy link
Collaborator Author

Run Tests:
mx-chain-simulator-go: link_inner_tx_to_results
mx-chain-testing-suite: fix-failed-test

AdoAdoAdo
AdoAdoAdo previously approved these changes Oct 11, 2024
@@ -15,9 +15,9 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5
github.com/mitchellh/mapstructure v1.5.0
github.com/multiversx/mx-chain-communication-go v1.1.0
github.com/multiversx/mx-chain-core-go v1.2.22
github.com/multiversx/mx-chain-core-go v1.2.23-0.20241010094929-2bbea4371d73
Copy link
Contributor

Choose a reason for hiding this comment

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

do not forget the proper release

@@ -4083,21 +4083,25 @@ func TestProcessGetOriginalTxHashForRelayedIntraShard(t *testing.T) {
scr := &smartContractResult.SmartContractResult{Value: big.NewInt(1), SndAddr: bytes.Repeat([]byte{1}, 32)}
scrHash := []byte("hash")

logHash, isRelayed := sc.getOriginalTxHashIfIntraShardRelayedSCR(scr, scrHash)
logHash, originalTxHash, isRelayed := sc.getOriginalTxHashIfIntraShardRelayedSCR(scr, scrHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is actually a scrHash, not a logHash, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

might be either a scr hash or the relayed tx hash, renamed to hashForLogSave

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

// even for intra-shard sc calls
if !bytes.Equal(relayedSCR.PrevTxHash, relayedSCR.OriginalTxHash) {
return txHash, relayedSCR.OriginalTxHash, isRelayed

Copy link
Contributor

Choose a reason for hiding this comment

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

empty line can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

Copy link
Contributor

Choose a reason for hiding this comment

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

ok


for _, innerTx := range tx.InnerTransactions {
innerTx.Epoch = tx.Epoch
innerTx.Round = tx.Round
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for the miniblockHash here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added, forgot from the last review

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@@ -789,6 +789,20 @@ func (txProc *txProcessor) processInnerTx(

txFee := txProc.computeInnerTxFee(innerTx)

prevTxHash, err := txProc.getPrevTxHashForInnerTxOfRelayedV3(originalTxHash, innerTx)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is added without any flags and it might not be backwards compatible if an error occurs. Previously no error was returned here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the flag is inside getPrevTxHashForInnerTxOfRelayedV3.. if the flag is not active yet, it will simply return originalTxHash and nil, as it is currently on devnet.. thus it should work as intended

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@multiversx multiversx deleted a comment from github-actions bot Oct 12, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 12, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 12, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 12, 2024
AdoAdoAdo
AdoAdoAdo previously approved these changes Oct 14, 2024
@@ -1412,16 +1412,17 @@ func (sc *scProcessor) isCrossShardESDTTransfer(sender []byte, receiver []byte,
func (sc *scProcessor) getOriginalTxHashIfIntraShardRelayedSCR(
tx data.TransactionHandler,
txHash []byte,
) ([]byte, []byte, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

todo: use a struct for the return values

raduchis
raduchis previously approved these changes Oct 14, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 17, 2024
@multiversx multiversx deleted a comment from github-actions bot Oct 17, 2024
Copy link

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 5389337a3ecede76cf8072be0b57f7f1cf9af0d5
  • Current Branch: inner_hash_on_scr_prev
  • 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: 17102024-092418
  • PYTEST_EXIT_CODE: 1
    🎉 MultiversX CI/CD Workflow Complete!

@multiversx multiversx deleted a comment from github-actions bot Oct 17, 2024
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.

3 participants