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

Log events fixes #778

Merged
merged 16 commits into from
Sep 13, 2023
Merged

Log events fixes #778

merged 16 commits into from
Sep 13, 2023

Conversation

sasurobert
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Patch coverage: 34.72% and project coverage change: +0.05% 🎉

Comparison is base (0bd0a54) 42.06% compared to head (54c6101) 42.12%.

❗ Current head 54c6101 differs from pull request most recent head a047c8e. Consider uploading reports for the commit a047c8e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #778      +/-   ##
==========================================
+ Coverage   42.06%   42.12%   +0.05%     
==========================================
  Files          49       49              
  Lines        9180     9201      +21     
==========================================
+ Hits         3862     3876      +14     
- Misses       4876     4881       +5     
- Partials      442      444       +2     
Files Changed Coverage Δ
vmhost/common.go 0.00% <ø> (ø)
vmhost/hostCore/execution.go 0.00% <0.00%> (ø)
vmhost/hostCore/host.go 6.34% <ø> (ø)
vmhost/contexts/output.go 58.65% <44.89%> (+2.76%) ⬆️
vmhost/contexts/asyncLocal.go 78.80% <60.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iulianpascalau iulianpascalau self-requested a review September 12, 2023 07:43
"errors"
"github.com/multiversx/mx-chain-vm-common-go/parsers"
Copy link
Contributor

Choose a reason for hiding this comment

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

go imports

runtime.GetVMInput().GasProvided = 0

// if vmOutput == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

so I guess we no longer need the commented code :D

@@ -387,9 +393,44 @@ func (context *outputContext) Transfer(destination []byte, sender []byte, gasLim

logOutput.Trace("transfer value added")

function, args, errNotCritical := context.callArgsParser.ParseData(string(input))
if !isBackTransfer && (errNotCritical != nil || !core.IsSmartContractAddress(destination) || gasLimit == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could have been extracted in a bool var

esdtTransferInput.Arguments = append(esdtTransferInput.Arguments, []byte(transfersArgs.Function))
}
if len(transfersArgs.Arguments) > 0 {
esdtTransferInput.Arguments = append(esdtTransferInput.Arguments, transfersArgs.Arguments...)
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 ok? What happens if the esdtTransferInput struct contains the Function field set to empty and it contains a list of arguments? Should we prevent that situation? If yes, we need to move L977-L979 after L975

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is not possible.

CostinCarabas
CostinCarabas previously approved these changes Sep 12, 2023
iulianpascalau
iulianpascalau previously approved these changes Sep 12, 2023
Comment on lines +397 to +415
function, args, errNotCritical := context.callArgsParser.ParseData(string(input))

isSimpleTransfer := errNotCritical != nil || !core.IsSmartContractAddress(destination) || gasLimit == 0
if !isBackTransfer && isSimpleTransfer {
context.WriteLogWithIdentifier(
sender,
[][]byte{value.Bytes(), destination},
[][]byte{[]byte(""), input},
[]byte("transferValueOnly"),
)
return nil
}

context.WriteLogWithIdentifier(
sender,
[][]byte{value.Bytes(), destination},
vmcommon.FormatLogDataForCall(getExecutionType(executionType, isBackTransfer), function, args),
[]byte("transferValueOnly"),
)
Copy link
Contributor

@camilbancioiu camilbancioiu Sep 13, 2023

Choose a reason for hiding this comment

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

Consider rewriting as:

	function, args, errNotCritical := context.callArgsParser.ParseData(string(input))

	var logData [][]byte

	isSimpleTransfer := errNotCritical != nil || !core.IsSmartContractAddress(destination) || gasLimit == 0
	if !isBackTransfer && isSimpleTransfer {
		logData = [][]byte{[]byte(""), input}
	} else {
		executionTypeString := getExecutionType(executionType, isBackTransfer)
		logData = vmcommon.FormatLogDataForCall(executionTypeString, function, args)
	}

	context.WriteLogWithIdentifier(
		sender,
		[][]byte{value.Bytes(), destination},
		logData,
		[]byte("transferValueOnly"),
	)

return nil
}

func getExecutionType(callType vm.CallType, isBackTransfer bool) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming to getExecutionTypeString(), to make it clearer it's for the log, not for the VM logic.

Comment on lines +228 to +229
//
// that should be called when all these async calls are resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation changed?

@sasurobert sasurobert merged commit 8bc981a into master Sep 13, 2023
3 checks passed
@sasurobert sasurobert deleted the logEvents-fixes branch September 13, 2023 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants