NethermindEth / cairo-vm-go

A virtual machine for Cairo written in Go
MIT License
73 stars 43 forks source link

`MemcpyEnterScope` hint is wrongly implemented #417

Closed TAdev0 closed 1 month ago

TAdev0 commented 2 months ago

MemcpyEnterScope hint is as follows:

//>  vm_enter_scope({'n': ids.len})

this means we are supposed to store the value len in the scope.

Currently, the hint impl does:

len, err := hinter.ResolveAsFelt(vm, len)
    if err != nil {
        return err
    }

ctx.ScopeManager.EnterScope(map[string]any{"n": len})
return nil

This is not correct as it stores a *fp.Element instead of a fp.Element. Indeed, ResolveAsFelt returns a pointer.

Test is also wrong, checking that the value in scope is equal to feltUint64(1) and feltUint64 also returns a pointer.

Will address this in a dedicated PR.