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
send back gas to relayer #2373
Conversation
process/smartContract/process.go
Outdated
return err | ||
} | ||
|
||
err = sc.accounts.SaveAccount(userAcc) |
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.
return sc.accounts.SaveAccount(userAcc)
?
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.
done
process/smartContract/process.go
Outdated
var refundGasToRelayer *smartContractResult.SmartContractResult | ||
relayedSCR, isRelayed := isRelayedTx(tx) | ||
if isRelayed && callType != vmcommon.AsynchronousCall && refundErd.Cmp(zero) > 0 { | ||
refundGasToRelayer = &smartContractResult.SmartContractResult{ |
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.
append a SCR
suffix to the variable name
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.
also maybe rename refundErd
variable to something else
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.
done
lockedGas uint64, | ||
) (*smartContractResult.SmartContractResult, error) { | ||
) (*smartContractResult.SmartContractResult, *smartContractResult.SmartContractResult, error) { |
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.
Although this works, returning 2 consecutive elements of the same type is always prone to faults (caused by switching variables)
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.
any better idea ?
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.
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 { |
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.
test relayedSCR.Value for 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.
no need. it is always set.
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.
ok
vmOutput *vmcommon.VMOutput, | ||
tx data.TransactionHandler, | ||
txHash []byte, | ||
callType vmcommon.CallType, | ||
) *smartContractResult.SmartContractResult { | ||
) (*smartContractResult.SmartContractResult, *smartContractResult.SmartContractResult) { |
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.
same thing about multiple, same-type variables.
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.
any better idea ? :)
The base branch was changed.
Improved the gas usage in case of relayed transactions. The unused gas will be sent back to the relayer itself.