diff options
author | chriseth <c@ethdev.com> | 2016-11-14 23:02:57 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-11-14 23:02:57 +0800 |
commit | c2c39239d6f1d51addad97c0c5128983ef58011f (patch) | |
tree | 2771c88076f1f15a50baccd5533ae50d04fa308b /libevmasm | |
parent | 68e776338701f6140d0e58470c503fabc35bc5dc (diff) | |
download | dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.tar dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.tar.gz dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.tar.bz2 dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.tar.lz dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.tar.xz dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.tar.zst dexon-solidity-c2c39239d6f1d51addad97c0c5128983ef58011f.zip |
Report infinite gas for calls.
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/GasMeter.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 51f3cf1d..51dc34f4 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -128,24 +128,28 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item) case Instruction::CALLCODE: case Instruction::DELEGATECALL: { - gas = GasCosts::callGas; - if (u256 const* value = classes.knownConstant(m_state->relativeStackElement(0))) - gas += (*value); - else - gas = GasConsumption::infinite(); - if (_item.instruction() == Instruction::CALL) - gas += GasCosts::callNewAccountGas; // We very rarely know whether the address exists. - int valueSize = _item.instruction() == Instruction::DELEGATECALL ? 0 : 1; - if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize))) - gas += GasCosts::callValueTransferGas; - gas += memoryGas(-2 - valueSize, -3 - valueSize); - gas += memoryGas(-4 - valueSize, -5 - valueSize); +// We assume that we do not know the target contract and thus, the consumption is infinite. + gas = GasConsumption::infinite(); +// gas = GasCosts::callGas; +// if (u256 const* value = classes.knownConstant(m_state->relativeStackElement(0))) +// gas += (*value); +// else +// gas = GasConsumption::infinite(); +// if (_item.instruction() == Instruction::CALL) +// gas += GasCosts::callNewAccountGas; // We very rarely know whether the address exists. +// int valueSize = _item.instruction() == Instruction::DELEGATECALL ? 0 : 1; +// if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize))) +// gas += GasCosts::callValueTransferGas; +// gas += memoryGas(-2 - valueSize, -3 - valueSize); +// gas += memoryGas(-4 - valueSize, -5 - valueSize); break; } case Instruction::CREATE: - gas = GasCosts::createGas; - gas += memoryGas(-1, -2); - break; +// We assume that we do not know the target contract and thus, the consumption is infinite. +// gas = GasConsumption::infinite(); +// gas = GasCosts::createGas; +// gas += memoryGas(-1, -2); +// break; case Instruction::EXP: gas = GasCosts::expGas; if (u256 const* value = classes.knownConstant(m_state->relativeStackElement(-1))) |