Hi gurus, I have a question about solidity state variable storage layout.
Does anyone know where in the solidity compiler can I find the reference to these two piece of code that determines the slot index of dynamically sized array of mapping?
Hi gurus, I have a question about solidity state variable storage layout.
Does anyone know where in the solidity compiler can I find the reference to these two piece of code that determines the slot index of dynamically sized array of mapping?
You mean keccak256()
?
It simply translates to EVM’s KECCAK256
opcode. It’s a common hashing function.
Thanks for answering.
Not exactly. I am looking for things like
Keccak256(h(k).p)
where in the solc code that determines the h
function based on different value and where does concatenation of h(k)
and p
happen, whether it’s concatenating string or concatenating bytes etc
my goal is to find the ground truth of implementation details from solc
code so I can add links to an research report I am working on
Without looking into it in detail, in the code base YulUtilFunctions::mappingIndexAccessFunction
in libsolidity/codegen/YulUtilFunctions.cpp would probably be the place to start for via-IR code generation and the Type::Category::Mapping
case of ExpressionCompiler::visit(IndexAccess const& _indexAccess)
in libsolidity/codegen/ExpressionCompiler.cpp
for legacy codegen.
The function h
in question only occurs implicitly in either version, though.