Skip to content

dibit hint not equivalent with Python implementation #1245

@kkovaacs

Description

@kkovaacs

Describe the bug
While re-executing some transactions from mainnet there are a lot of errors that fail with the following error: Got an exception while executing a hint: Attempt to subtract with overflow: ids.m - 1. To see more context please see #1244

To Reproduce
Re-execute the following transaction with the appropriate mainnet state: https://starkscan.co/tx/0x025f6d032930a7d1b115ea89aac2ce731dd0c5fd00c1e0ff94e648ce46f44bbd

Expected behavior
Transaction execution to finish without an error.

Additional context

It looks like the dibit hint implementation is not quite equivalent to the Python one.

The original hint is:
"ids.dibit = ((ids.scalar_u >> ids.m) & 1) + 2 * ((ids.scalar_v >> ids.m) & 1)"

This code works perfectly even if ids.m is zero. The cairo-rs implementation just stops with the error above: https://github.com/lambdaclass/cairo-rs/blob/8a72ddc20a8881c965d082d96db31a378925fdea/vm/src/hint_processor/builtin_hint_processor/secp/ec_utils.rs#L501

I don't fully understand why this check is there in the code but simply removing it seems to "fix" the transaction execution error.

Metadata

Metadata

Assignees

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