Skip to content
3 changes: 3 additions & 0 deletions src/cli/dtvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ int main(int argc, char *argv[]) {
#ifdef ZEN_ENABLE_EVM
if (Config.Format == InputFormat::EVM) {
auto MockedEVMHost = std::make_unique<zen::evm::ZenMockedEVMHost>();
// Synchronize the Host and EVMInstance revisions. account_exists and
// precompile handling in the Host use the selected fork's semantics.
MockedEVMHost->setRevision(EvmRevision);
// Set tx_origin from sender address before loading state,
// so loadState() can override it if tx_origin is present in state.json
MockedEVMHost->tx_context.tx_origin =
Expand Down
48 changes: 30 additions & 18 deletions src/compiler/evm_frontend/evm_mir_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4868,9 +4868,11 @@ void EVMMirBuilder::handleCodeCopy(Operand DestOffsetComponents,
reloadGasFromMemory();
}
#endif
if (!UsePreparedMemory) {
reloadMemorySizeFromInstance();
}
// No-expand helpers run on a proven memory range, but the instance memory
// backing buffer may still be materialized or rebased on first use. Keep
// the cached base pointer and size in sync so the next direct memory
// operation never reads a stale base.
reloadMemorySizeFromInstance();
}

typename EVMMirBuilder::Operand
Expand Down Expand Up @@ -6106,9 +6108,11 @@ EVMMirBuilder::handleKeccak256(Operand OffsetComponents,
#ifdef ZEN_ENABLE_EVM_GAS_REGISTER
reloadGasFromMemory();
#endif
if (!UsePreparedMemory) {
reloadMemorySizeFromInstance();
}
// No-expand helpers run on a proven memory range, but the instance memory
// backing buffer may still be materialized or rebased on first use. Keep
// the cached base pointer and size in sync so the next direct memory
// operation never reads a stale base.
reloadMemorySizeFromInstance();
return Result;
}

Expand Down Expand Up @@ -6138,9 +6142,11 @@ EVMMirBuilder::handleKeccak256TwoWord(Operand OffsetComponents, Operand Word0,
#ifdef ZEN_ENABLE_EVM_GAS_REGISTER
reloadGasFromMemory();
#endif
if (!UsePreparedMemory) {
reloadMemorySizeFromInstance();
}
// No-expand helpers run on a proven memory range, but the instance memory
// backing buffer may still be materialized or rebased on first use. Keep
// the cached base pointer and size in sync so the next direct memory
// operation never reads a stale base.
reloadMemorySizeFromInstance();
return Result;
}

Expand Down Expand Up @@ -6171,9 +6177,11 @@ typename EVMMirBuilder::Operand EVMMirBuilder::handleKeccak256CallDataConstSlot(
#ifdef ZEN_ENABLE_EVM_GAS_REGISTER
reloadGasFromMemory();
#endif
if (!UsePreparedMemory) {
reloadMemorySizeFromInstance();
}
// No-expand helpers run on a proven memory range, but the instance memory
// backing buffer may still be materialized or rebased on first use. Keep
// the cached base pointer and size in sync so the next direct memory
// operation never reads a stale base.
reloadMemorySizeFromInstance();
return Result;
}

Expand Down Expand Up @@ -6203,9 +6211,11 @@ EVMMirBuilder::handleKeccak256CallerConstSlot(Operand OffsetComponents,
#ifdef ZEN_ENABLE_EVM_GAS_REGISTER
reloadGasFromMemory();
#endif
if (!UsePreparedMemory) {
reloadMemorySizeFromInstance();
}
// No-expand helpers run on a proven memory range, but the instance memory
// backing buffer may still be materialized or rebased on first use. Keep
// the cached base pointer and size in sync so the next direct memory
// operation never reads a stale base.
reloadMemorySizeFromInstance();
return Result;
}

Expand Down Expand Up @@ -7505,9 +7515,11 @@ void EVMMirBuilder::handleCallDataCopy(Operand DestOffsetComponents,
reloadGasFromMemory();
}
#endif
if (!UsePreparedMemory) {
reloadMemorySizeFromInstance();
}
// No-expand helpers run on a proven memory range, but the instance memory
// backing buffer may still be materialized or rebased on first use. Keep
// the cached base pointer and size in sync so the next direct memory
// operation never reads a stale base.
reloadMemorySizeFromInstance();
}

void EVMMirBuilder::handleExtCodeCopy(Operand AddressComponents,
Expand Down
Loading
Loading