mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Add assembly support for EXTCODEHASH (EIP-1052)
This commit is contained in:
		
							parent
							
								
									a86e1d187b
								
							
						
					
					
						commit
						c6bd2979b1
					
				| @ -90,6 +90,7 @@ Language Features: | ||||
| Compiler Features: | ||||
|  * C API (``libsolc``): Export the ``solidity_license``, ``solidity_version`` and ``solidity_compile`` methods. | ||||
|  * Code Generator: ``CREATE2`` instruction has been updated to match EIP1014 (aka "Skinny CREATE2"). It also is accepted as part of Constantinople. | ||||
|  * Code Generator: ``EXTCODEHASH`` instruction has been added based on EIP1052. | ||||
|  * Type Checker: Nicer error message when trying to reference overloaded identifiers in inline assembly. | ||||
|  * Type Checker: Show named argument in case of error. | ||||
|  * Type System: IntegerType is split into IntegerType and AddressType internally. | ||||
|  | ||||
| @ -112,6 +112,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ | ||||
| 			gas += wordGas(GasCosts::copyGas, m_state->relativeStackElement(-2)); | ||||
| 			break; | ||||
| 		case Instruction::EXTCODESIZE: | ||||
| 		case Instruction::EXTCODEHASH: | ||||
| 			gas = GasCosts::extCodeGas(m_evmVersion); | ||||
| 			break; | ||||
| 		case Instruction::EXTCODECOPY: | ||||
|  | ||||
| @ -73,6 +73,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions = | ||||
| 	{ "EXTCODECOPY", Instruction::EXTCODECOPY }, | ||||
| 	{ "RETURNDATASIZE", Instruction::RETURNDATASIZE }, | ||||
| 	{ "RETURNDATACOPY", Instruction::RETURNDATACOPY }, | ||||
| 	{ "EXTCODEHASH", Instruction::EXTCODEHASH }, | ||||
| 	{ "BLOCKHASH", Instruction::BLOCKHASH }, | ||||
| 	{ "COINBASE", Instruction::COINBASE }, | ||||
| 	{ "TIMESTAMP", Instruction::TIMESTAMP }, | ||||
| @ -216,6 +217,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo = | ||||
| 	{ Instruction::EXTCODECOPY,	{ "EXTCODECOPY",	0, 4, 0, true, Tier::ExtCode } }, | ||||
| 	{ Instruction::RETURNDATASIZE,	{"RETURNDATASIZE",	0, 0, 1, false, Tier::Base } }, | ||||
| 	{ Instruction::RETURNDATACOPY,	{"RETURNDATACOPY",	0, 3, 0, true, Tier::VeryLow } }, | ||||
| 	{ Instruction::EXTCODEHASH,	{ "EXTCODEHASH",	0, 1, 1, false, Tier::ExtCode } }, | ||||
| 	{ Instruction::BLOCKHASH,	{ "BLOCKHASH",		0, 1, 1, false, Tier::Ext } }, | ||||
| 	{ Instruction::COINBASE,	{ "COINBASE",		0, 0, 1, false, Tier::Base } }, | ||||
| 	{ Instruction::TIMESTAMP,	{ "TIMESTAMP",		0, 0, 1, false, Tier::Base } }, | ||||
|  | ||||
| @ -82,6 +82,7 @@ enum class Instruction: uint8_t | ||||
| 	EXTCODECOPY,		///< copy external code (from another contract)
 | ||||
| 	RETURNDATASIZE = 0x3d,	///< get size of return data buffer
 | ||||
| 	RETURNDATACOPY = 0x3e,	///< copy return data in current environment to memory
 | ||||
| 	EXTCODEHASH = 0x3f,	///< get external code hash (from another contract)
 | ||||
| 
 | ||||
| 	BLOCKHASH = 0x40,	///< get hash of most recent complete block
 | ||||
| 	COINBASE,			///< get the block's coinbase address
 | ||||
|  | ||||
| @ -151,6 +151,7 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item) | ||||
| 	case Instruction::MSIZE: // depends on previous writes and reads, not only on content
 | ||||
| 	case Instruction::BALANCE: // depends on previous calls
 | ||||
| 	case Instruction::EXTCODESIZE: | ||||
| 	case Instruction::EXTCODEHASH: | ||||
| 	case Instruction::RETURNDATACOPY: // depends on previous calls
 | ||||
| 	case Instruction::RETURNDATASIZE: | ||||
| 		return false; | ||||
| @ -172,6 +173,7 @@ bool SemanticInformation::movable(Instruction _instruction) | ||||
| 	case Instruction::KECCAK256: | ||||
| 	case Instruction::BALANCE: | ||||
| 	case Instruction::EXTCODESIZE: | ||||
| 	case Instruction::EXTCODEHASH: | ||||
| 	case Instruction::RETURNDATASIZE: | ||||
| 	case Instruction::SLOAD: | ||||
| 	case Instruction::PC: | ||||
| @ -233,6 +235,7 @@ bool SemanticInformation::invalidInPureFunctions(Instruction _instruction) | ||||
| 	case Instruction::GASPRICE: | ||||
| 	case Instruction::EXTCODESIZE: | ||||
| 	case Instruction::EXTCODECOPY: | ||||
| 	case Instruction::EXTCODEHASH: | ||||
| 	case Instruction::BLOCKHASH: | ||||
| 	case Instruction::COINBASE: | ||||
| 	case Instruction::TIMESTAMP: | ||||
|  | ||||
| @ -568,7 +568,17 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio | ||||
| 	// Similarly we assume bitwise shifting and create2 go together.
 | ||||
| 	solAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), ""); | ||||
| 
 | ||||
| 	if (( | ||||
| 	if (_instr == solidity::Instruction::EXTCODEHASH) | ||||
| 		m_errorReporter.warning( | ||||
| 			_location, | ||||
| 			"The \"" + | ||||
| 			boost::to_lower_copy(instructionInfo(_instr).name) | ||||
| 			+ "\" instruction is not supported by the VM version \"" + | ||||
| 			"" + m_evmVersion.name() + | ||||
| 			"\" you are currently compiling for. " + | ||||
| 			"It will be interpreted as an invalid instruction on this VM." | ||||
| 		); | ||||
| 	else if (( | ||||
| 		_instr == solidity::Instruction::RETURNDATACOPY || | ||||
| 		_instr == solidity::Instruction::RETURNDATASIZE || | ||||
| 		_instr == solidity::Instruction::STATICCALL | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user