mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not pay new account gas.
If we checked that the target contract exists, we do not have to pay the "new account gas".
This commit is contained in:
parent
341c9436a8
commit
69c175fe22
@ -33,6 +33,7 @@ Features:
|
|||||||
* Commandline interface: Using ``-`` as filename allows reading from stdin.
|
* Commandline interface: Using ``-`` as filename allows reading from stdin.
|
||||||
* Interface Json: Fallback function is now part of the ABI.
|
* Interface Json: Fallback function is now part of the ABI.
|
||||||
* Interface: Version string now semver compatible.
|
* Interface: Version string now semver compatible.
|
||||||
|
* Code generator: Do not provide "new account gas" if we know the called account exists.
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
||||||
|
@ -1524,11 +1524,13 @@ void ExpressionCompiler::appendExternalFunctionCall(
|
|||||||
m_context << u256(0);
|
m_context << u256(0);
|
||||||
m_context << dupInstruction(m_context.baseToCurrentStackOffset(contractStackPos));
|
m_context << dupInstruction(m_context.baseToCurrentStackOffset(contractStackPos));
|
||||||
|
|
||||||
|
bool existenceChecked = false;
|
||||||
// Check the the target contract exists (has code) for non-low-level calls.
|
// Check the the target contract exists (has code) for non-low-level calls.
|
||||||
if (funKind == FunctionKind::External || funKind == FunctionKind::CallCode || funKind == FunctionKind::DelegateCall)
|
if (funKind == FunctionKind::External || funKind == FunctionKind::CallCode || funKind == FunctionKind::DelegateCall)
|
||||||
{
|
{
|
||||||
m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO;
|
m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO;
|
||||||
m_context.appendConditionalJumpTo(m_context.errorTag());
|
m_context.appendConditionalJumpTo(m_context.errorTag());
|
||||||
|
existenceChecked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_functionType.gasSet())
|
if (_functionType.gasSet())
|
||||||
@ -1540,7 +1542,7 @@ void ExpressionCompiler::appendExternalFunctionCall(
|
|||||||
u256 gasNeededByCaller = eth::GasCosts::callGas + 10;
|
u256 gasNeededByCaller = eth::GasCosts::callGas + 10;
|
||||||
if (_functionType.valueSet())
|
if (_functionType.valueSet())
|
||||||
gasNeededByCaller += eth::GasCosts::callValueTransferGas;
|
gasNeededByCaller += eth::GasCosts::callValueTransferGas;
|
||||||
if (!isCallCode && !isDelegateCall)
|
if (!isCallCode && !isDelegateCall && !existenceChecked)
|
||||||
gasNeededByCaller += eth::GasCosts::callNewAccountGas; // we never know
|
gasNeededByCaller += eth::GasCosts::callNewAccountGas; // we never know
|
||||||
m_context <<
|
m_context <<
|
||||||
gasNeededByCaller <<
|
gasNeededByCaller <<
|
||||||
|
Loading…
Reference in New Issue
Block a user