In order to allow smart contracts to query runtime storage, a new ext_ function is required:
fn ext_runtime_get_storage(key_ptr: u32, key_len: u32) -> u32
I've implemented a quick prototype: https://github.com/paritytech/substrate/compare/aj-contracts-get-storage.
However this is hard coded to hash the key twox_128(key)
Assuming we don't expect the contract itself to perform the key hashing, the remaining problem to solve is the API for correct hashing of keys for different storage types:
twox_128(key)blake2_256(prefix + key)twox_128(prefix + key)blake2_256(prefix + key)twox_128(prefix + key)blake2_256(prefix + key) + blake2_256(key2)twox_128(prefix + key) + twox_128(key2)Related previous discussion: #2214
Access the storage directly will make it very hard / impossible to upgrade runtime module storage format because it means all the contracts have to upgrade as well, which is just not going to happen in a generic smart contract chain.