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

send back gas to relayer #2373

Merged
merged 5 commits into from Oct 14, 2020
Merged

Conversation

sasurobert
Copy link
Contributor

@sasurobert sasurobert commented Oct 13, 2020

Improved the gas usage in case of relayed transactions. The unused gas will be sent back to the relayer itself.

return err
}

err = sc.accounts.SaveAccount(userAcc)
Copy link
Contributor

Choose a reason for hiding this comment

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

return sc.accounts.SaveAccount(userAcc) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

var refundGasToRelayer *smartContractResult.SmartContractResult
relayedSCR, isRelayed := isRelayedTx(tx)
if isRelayed && callType != vmcommon.AsynchronousCall && refundErd.Cmp(zero) > 0 {
refundGasToRelayer = &smartContractResult.SmartContractResult{
Copy link
Contributor

Choose a reason for hiding this comment

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

append a SCR suffix to the variable name

Copy link
Contributor

Choose a reason for hiding this comment

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

also maybe rename refundErd variable to something else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

lockedGas uint64,
) (*smartContractResult.SmartContractResult, error) {
) (*smartContractResult.SmartContractResult, *smartContractResult.SmartContractResult, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this works, returning 2 consecutive elements of the same type is always prone to faults (caused by switching variables)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any better idea ?

Copy link
Contributor

Choose a reason for hiding this comment

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

composite struct containing 3 fields (2 of them of type *smartContractResult.SmartContractResult and one of type error)
Can be left as it is

@@ -835,6 +830,9 @@ func (sc *scProcessor) processForRelayerWhenError(
if !isRelayed {
return nil
}
if relayedSCR.Value.Cmp(zero) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

test relayedSCR.Value for nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need. it is always set.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

vmOutput *vmcommon.VMOutput,
tx data.TransactionHandler,
txHash []byte,
callType vmcommon.CallType,
) *smartContractResult.SmartContractResult {
) (*smartContractResult.SmartContractResult, *smartContractResult.SmartContractResult) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing about multiple, same-type variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any better idea ? :)

iulianpascalau
iulianpascalau previously approved these changes Oct 13, 2020
bogdan-rosianu
bogdan-rosianu previously approved these changes Oct 14, 2020
@sasurobert sasurobert changed the base branch from development to feat/esdt-relayed-arwen October 14, 2020 07:32
@sasurobert sasurobert dismissed bogdan-rosianu’s stale review October 14, 2020 07:32

The base branch was changed.

@sasurobert sasurobert merged commit 11ee267 into feat/esdt-relayed-arwen Oct 14, 2020
@sasurobert sasurobert deleted the send-gas-back-to-relayer branch October 14, 2020 07:47
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.

None yet

3 participants