diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/util.asm b/evm_arithmetization/src/cpu/kernel/asm/core/util.asm index 6b48428ef..26478d0da 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/util.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/util.asm @@ -12,6 +12,17 @@ // stack: (empty) %mload_global_metadata(@GLOBAL_METADATA_LARGEST_CONTEXT) %add_const(0x10000000000000000) // scale each context by 2^64 + // stack: new_ctx + DUP1 + + // Memory addresses are represented as `ctx.2^64 + segment.2^32 + offset`, + // each address component expected to fit in a 32-bit limb. + // We enforce here that the new context id won't overflow. + PUSH 0xffffffffffffffffffffffff // 2^96 - 1 + // stack: max, new_ctx, new_ctx + LT + %jumpi(fault_exception) + // stack: new_ctx DUP1 %mstore_global_metadata(@GLOBAL_METADATA_LARGEST_CONTEXT)