-
Notifications
You must be signed in to change notification settings - Fork 26
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
Log events fixes #778
Conversation
…-vm into logEvents-fixes
Codecov ReportPatch coverage:
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
☔ View full report in Codecov by Sentry. |
vmhost/contexts/output.go
Outdated
"errors" | ||
"github.com/multiversx/mx-chain-vm-common-go/parsers" |
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.
go imports
runtime.GetVMInput().GasProvided = 0 | ||
|
||
// if vmOutput == nil { |
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.
so I guess we no longer need the commented code :D
vmhost/contexts/output.go
Outdated
@@ -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) { |
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.
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...) |
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.
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
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.
that is not possible.
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"), | ||
) |
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.
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 { |
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.
Consider renaming to getExecutionTypeString()
, to make it clearer it's for the log, not for the VM logic.
// | ||
// that should be called when all these async calls are resolved |
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.
Indentation changed?
No description provided.