Skip to content

Inconsistent offset calculationΒ #1986

Open
@petscheit

Description

@petscheit

Describe the bug
Consider the following example:

func hash_full_transcript_and_get_Z_4_LIMBS{poseidon_ptr: PoseidonBuiltin*}(
    limbs_ptr: felt*, n: felt
) -> (_s0: felt, _s1: felt, _s2: felt) {
    alloc_locals;
    local BASE = 2 ** 96;

    // n = 768 & N_LIMBS = 4
    local offset = n * N_LIMBS;
    let elements_end_correct = &limbs_ptr[offset];
    let elements_end = &limbs_ptr[n * N_LIMBS];


//...more code here
}

Both references should point to the same relocatable offset. However, when I print these relocatables I get different values:

elements_end: Relocatable { segment_index: 6, offset: 31300 }
elements_end_correct: Relocatable { segment_index: 6, offset: 33604 }

The starting offset in this case is 30532

so: 30532 + (4 * 768) = 33604

and 30532 + 768 = 31300

For some reason the * 4 is not applied

To Reproduce
Hard to reproduce, as this is running deep in the extension field circuit in garaga

Expected behavior
A clear and concise description of what you expected to happen.

What version/commit are you on?
Upgraded to the latest version: v2.0.0

Additional context
this seems related to #1918

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions