mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Fix storage array abi encoding
Fix incorrect abi encoding of storage array of data type that occupy multiple storage slots
This commit is contained in:
		
							parent
							
								
									7187a3e5ca
								
							
						
					
					
						commit
						bfe074b2b1
					
				| @ -1,5 +1,9 @@ | ||||
| ### 0.5.10 (unreleased) | ||||
| 
 | ||||
| Important Bugfixes: | ||||
|  * Fix incorrect abi encoding of storage array of data type that occupy multiple storage slots | ||||
| 
 | ||||
| 
 | ||||
| Language Features: | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -154,7 +154,7 @@ private: | ||||
| 		EncodingOptions const& _options | ||||
| 	); | ||||
| 	/// Part of @a abiEncodingFunction for array target type and given memory array or
 | ||||
| 	/// a given storage array with one item per slot.
 | ||||
| 	/// a given storage array with every item occupies one or multiple full slots.
 | ||||
| 	std::string abiEncodingFunctionSimpleArray( | ||||
| 		ArrayType const& _givenType, | ||||
| 		ArrayType const& _targetType, | ||||
|  | ||||
| @ -589,18 +589,29 @@ string YulUtilFunctions::nextArrayElementFunction(ArrayType const& _type) | ||||
| 			} | ||||
| 		)"); | ||||
| 		templ("functionName", functionName); | ||||
| 		if (_type.location() == DataLocation::Memory) | ||||
| 		switch (_type.location()) | ||||
| 		{ | ||||
| 		case DataLocation::Memory: | ||||
| 			templ("advance", "0x20"); | ||||
| 		else if (_type.location() == DataLocation::Storage) | ||||
| 			templ("advance", "1"); | ||||
| 		else if (_type.location() == DataLocation::CallData) | ||||
| 			templ("advance", toCompactHexWithPrefix( | ||||
| 			break; | ||||
| 		case DataLocation::Storage: | ||||
| 		{ | ||||
| 			u256 size = _type.baseType()->storageSize(); | ||||
| 			solAssert(size >= 1, ""); | ||||
| 			templ("advance", toCompactHexWithPrefix(size)); | ||||
| 			break; | ||||
| 		} | ||||
| 		case DataLocation::CallData: | ||||
| 		{ | ||||
| 			u256 size = | ||||
| 				_type.baseType()->isDynamicallyEncoded() ? | ||||
| 				32 : | ||||
| 				_type.baseType()->calldataEncodedSize() | ||||
| 			)); | ||||
| 		else | ||||
| 			solAssert(false, ""); | ||||
| 				_type.baseType()->calldataEncodedSize(); | ||||
| 			solAssert(size >= 32 && size % 32 == 0, ""); | ||||
| 			templ("advance", toCompactHexWithPrefix(size)); | ||||
| 			break; | ||||
| 		} | ||||
| 		} | ||||
| 		return templ.render(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| @ -113,7 +113,7 @@ public: | ||||
| 	/// for the data position of an array which is stored in that slot / memory area / calldata area.
 | ||||
| 	std::string arrayDataAreaFunction(ArrayType const& _type); | ||||
| 	/// @returns the name of a function that advances an array data pointer to the next element.
 | ||||
| 	/// Only works for memory arrays, calldata arrays and storage arrays that store one item per slot.
 | ||||
| 	/// Only works for memory arrays, calldata arrays and storage arrays that every item occupies one or multiple full slots.
 | ||||
| 	std::string nextArrayElementFunction(ArrayType const& _type); | ||||
| 
 | ||||
| 	/// @returns the name of a function that performs index access for mappings.
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user