diff options
author | chriseth <chris@ethereum.org> | 2018-04-12 00:30:20 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-04-12 02:42:34 +0800 |
commit | 928ce088456987431143262dcde2d02553b68192 (patch) | |
tree | 6c5ca27bac6d81d7df19ce27e662de08edf1da9f /libsolidity | |
parent | d50d1f0ac1841a1d287a216451e93573fc07474e (diff) | |
download | dexon-solidity-928ce088456987431143262dcde2d02553b68192.tar.gz dexon-solidity-928ce088456987431143262dcde2d02553b68192.tar.zst dexon-solidity-928ce088456987431143262dcde2d02553b68192.zip |
Correctly ignore costs of fallback for other functions.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/interface/GasEstimator.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index 2139395f..a496cc21 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -136,12 +136,19 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation( ExpressionClasses& classes = state->expressionClasses(); using Id = ExpressionClasses::Id; using Ids = vector<Id>; + // div(calldataload(0), 1 << 224) equals to hashValue Id hashValue = classes.find(u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(_signature))))); Id calldata = classes.find(Instruction::CALLDATALOAD, Ids{classes.find(u256(0))}); classes.forceEqual(hashValue, Instruction::DIV, Ids{ calldata, - classes.find(u256(1) << (8 * 28)) + classes.find(u256(1) << 224) }); + // lt(calldatasize(), 4) equals to 0 (ignore the shortcut for fallback functions) + classes.forceEqual( + classes.find(u256(0)), + Instruction::LT, + Ids{classes.find(Instruction::CALLDATASIZE), classes.find(u256(4))} + ); } PathGasMeter meter(_items, m_evmVersion); |