mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #5089 from ethereum/gasmeter
Small pathgasmeter cleanups
This commit is contained in:
		
						commit
						410d94c498
					
				| @ -101,8 +101,8 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ | ||||
| 			break; | ||||
| 		case Instruction::KECCAK256: | ||||
| 			gas = GasCosts::keccak256Gas; | ||||
| 			gas += wordGas(GasCosts::keccak256WordGas, m_state->relativeStackElement(-1)); | ||||
| 			gas += memoryGas(0, -1); | ||||
| 			gas += wordGas(GasCosts::keccak256WordGas, m_state->relativeStackElement(-1)); | ||||
| 			break; | ||||
| 		case Instruction::CALLDATACOPY: | ||||
| 		case Instruction::CODECOPY: | ||||
| @ -214,7 +214,7 @@ GasMeter::GasConsumption GasMeter::memoryGas(ExpressionClasses::Id _position) | ||||
| 	if (!value) | ||||
| 		return GasConsumption::infinite(); | ||||
| 	if (*value < m_largestMemoryAccess) | ||||
| 		return GasConsumption(u256(0)); | ||||
| 		return GasConsumption(0); | ||||
| 	u256 previous = m_largestMemoryAccess; | ||||
| 	m_largestMemoryAccess = *value; | ||||
| 	auto memGas = [=](u256 const& pos) -> u256 | ||||
|  | ||||
| @ -137,6 +137,8 @@ public: | ||||
| 	static unsigned runGas(Instruction _instruction); | ||||
| 
 | ||||
| 	/// @returns the gas cost of the supplied data, depending whether it is in creation code, or not.
 | ||||
| 	/// In case of @a _inCreation, the data is only sent as a transaction and is not stored, whereas
 | ||||
| 	/// otherwise code will be stored and have to pay "createDataGas" cost.
 | ||||
| 	static u256 dataGas(bytes const& _data, bool _inCreation); | ||||
| 
 | ||||
| private: | ||||
|  | ||||
| @ -57,6 +57,16 @@ public: | ||||
| 
 | ||||
| 	GasMeter::GasConsumption estimateMax(size_t _startIndex, std::shared_ptr<KnownState> const& _state); | ||||
| 
 | ||||
| 	static GasMeter::GasConsumption estimateMax( | ||||
| 		AssemblyItems const& _items, | ||||
| 		solidity::EVMVersion _evmVersion, | ||||
| 		size_t _startIndex, | ||||
| 		std::shared_ptr<KnownState> const& _state | ||||
| 	) | ||||
| 	{ | ||||
| 		return PathGasMeter(_items, _evmVersion).estimateMax(_startIndex, _state); | ||||
| 	} | ||||
| 
 | ||||
| private: | ||||
| 	/// Adds a new path item to the queue, but only if we do not already have
 | ||||
| 	/// a higher gas usage at that point.
 | ||||
|  | ||||
| @ -160,8 +160,7 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation( | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| 	PathGasMeter meter(_items, m_evmVersion); | ||||
| 	return meter.estimateMax(0, state); | ||||
| 	return PathGasMeter::estimateMax(_items, m_evmVersion, 0, state); | ||||
| } | ||||
| 
 | ||||
| GasEstimator::GasConsumption GasEstimator::functionalEstimation( | ||||
| @ -183,7 +182,7 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation( | ||||
| 	if (parametersSize > 0) | ||||
| 		state->feedItem(swapInstruction(parametersSize)); | ||||
| 
 | ||||
| 	return PathGasMeter(_items, m_evmVersion).estimateMax(_offset, state); | ||||
| 	return PathGasMeter::estimateMax(_items, m_evmVersion, _offset, state); | ||||
| } | ||||
| 
 | ||||
| set<ASTNode const*> GasEstimator::finestNodesAtLocation( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user