From 2a527e448d3ee75c0d40cdd90b38975db6a0d907 Mon Sep 17 00:00:00 2001 From: cmgCr Date: Mon, 26 Jan 2026 06:04:01 +0000 Subject: [PATCH] fix(evm): fix EXTCODECOPY to handle large offset --- src/compiler/evm_frontend/evm_mir_compiler.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/evm_frontend/evm_mir_compiler.cpp b/src/compiler/evm_frontend/evm_mir_compiler.cpp index f67f028f0..7b6038892 100644 --- a/src/compiler/evm_frontend/evm_mir_compiler.cpp +++ b/src/compiler/evm_frontend/evm_mir_compiler.cpp @@ -3338,9 +3338,13 @@ void EVMMirBuilder::handleExtCodeCopy(Operand AddressComponents, Operand OffsetComponents, Operand SizeComponents) { const auto &RuntimeFunctions = getRuntimeFunctionTable(); - normalizeOperandU64(DestOffsetComponents); - normalizeOperandU64(OffsetComponents); - normalizeOperandU64(SizeComponents); + // Use max uint64_t value if the offset/size is not 64-bit, because the + // extcodecopy will fill zeros when offset is beyond code size or handle large + // size properly. + uint64_t Non64Value = std::numeric_limits::max(); + normalizeOperandU64(DestOffsetComponents, &Non64Value); + normalizeOperandU64(OffsetComponents, &Non64Value); + normalizeOperandU64(SizeComponents, &Non64Value); #ifdef ZEN_ENABLE_EVM_GAS_REGISTER syncGasToMemory(); #endif