Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Client fails on block 51740: Couldn't compute operand op1 #245

Closed
maciejka opened this issue Oct 4, 2024 · 15 comments
Closed

[bug] Client fails on block 51740: Couldn't compute operand op1 #245

maciejka opened this issue Oct 4, 2024 · 15 comments
Labels
advanced blocked Requires other issues to be resolved first bug Something isn't working

Comments

@maciejka
Copy link
Collaborator

maciejka commented Oct 4, 2024

Client fails on block 51740:

scarb cairo-run --verbose --no-build --package client --function test --arguments-file arguments-full_51740_1.json

with error message:

Running client error: failed to run the function Caused by: Couldn't compute operand op1. Unknown value for memory cell 1:65546

where:

same error on block 55861(small block, just 4 txs):

and 70183:

Minimal program on which the error reproduces:

fn main(arguments: Span<felt252>) {}

There seems to be some upper bound for the arguments of type array with length >= 2^15

@maciejka maciejka added bug Something isn't working advanced labels Oct 4, 2024
@Jeanmichel7
Copy link
Collaborator

Can I do it ?

@m-kus
Copy link
Collaborator

m-kus commented Oct 4, 2024

A bit of context:

  • The error is thrown by CairoVM Couldn't compute operand op1. Unknown value for memory cell 1:65546
  • It might be because of pc jumps, so the first suggestion is to try run with Use core::sha256 until we optimize pure Cairo version  #244 (our sha256 impl caused pc outside of program area before)
  • Generally we need to isolate which instruction triggers this error in particular

@maciejka
Copy link
Collaborator Author

maciejka commented Oct 4, 2024

Possible directions of attack:

  • using simple debugging techniques like adding debug messages try locate source of the problem:
    • Is it before, during or after arguments deserialization?
    • If during verification, in which part of verification logic?
    • Which subset of input trigger the problem (bisection search over the transaction set)?
  • run scarb project in debugger(I had good results using RustRover from InteliJ), try to triangulate the problem looking at the cairo-vm internals

@Jeanmichel7 still ready?

@Jeanmichel7
Copy link
Collaborator

@maciejka Yep

@Jeanmichel7
Copy link
Collaborator

Jeanmichel7 commented Oct 5, 2024

@maciejka Sorry, but what exactly is the error?
I can't launch the client
scarb cairo-run --verbose --no-build --package client --function test --arguments-file arguments-full_51740_1.json
is not supposed to work directly, is it? with
full_51740_1.json in client/tests/data and
arguments-full_51740.json in client/.client_cache ?
error: unexpected argument '--arguments-file' found

I can't launch it via client.sh either.
scarb run client is supposed to work?
What did I miss?

@maciejka
Copy link
Collaborator Author

maciejka commented Oct 5, 2024 via email

@maciejka
Copy link
Collaborator Author

maciejka commented Oct 5, 2024 via email

@Jeanmichel7
Copy link
Collaborator

oh already in 2.8.3! ok thanks got it

@maciejka
Copy link
Collaborator Author

maciejka commented Oct 7, 2024

When you comment out body of the test function the error still persists. Which means the cause of the problem is not in Cairo logic, we should look at the way arguments are loaded into the memory.

@m-kus
Copy link
Collaborator

m-kus commented Oct 7, 2024

Seems to be related lambdaclass/cairo-vm#1728

@Jeanmichel7
Copy link
Collaborator

Jeanmichel7 commented Oct 7, 2024

Yes, the problem doesn't come from the Cairo logic, it's the weight of the argument that's too heavy in the cairo-run management. For full block 51740 we're at 641KB, while for full block 757738 we're only at 71KB.

maybe useful:
There's a operating system's limitation, the integration test script doesn't work on block 51740:
test tests/data/full_51740.json ... scarb/2.8.3/bin/scarb: Argument list too long
This Operating System Limitation reveals that we've exceeded the 2MB argument limit, at least on my system
$> getconf ARG_MAX //2097152
This problem can be solved by using a temporary file and use the --arguments-file option in scarb cairo-run

This raises the question of whether we're using the right way of doing things? Will it support the biggest blocks? (4Mo) And even several

I think that's beyond my skills, maybe we need to look at scarb-cairo-run.
scarb/extensions/scarb-cairo-run/src/main.rs l86
&fs::read_to_string(path.clone())
We put all the arguments in memory at once, maybe we should stream them or use a temporary file? Not easy to test

@maciejka maciejka changed the title [bug] Client fails on block 51740 [bug] Client fails on block 51740: Couldn't compute operand op1 Oct 10, 2024
@maciejka
Copy link
Collaborator Author

@Jeanmichel7 Argument list too long is fixed in #195.

I think that the problem is in the way the Cairo runner handles arguments, especially:

Somewhere in the above code, there must be an assumption that the argument length is less than 2^15.

Let me know if you want to continue to work on this issue.

@Jeanmichel7
Copy link
Collaborator

@maciejka Yes, I'll try it.
It could be because of the i16

/// Information about an array argument that has been added to the stack.
struct ArrayDataInfo {
    /// The offset of the pointer to the array data on the stack.
    ptr_offset : i16,
    /// The size of the array data in the stack.
    size : i16,
}

I'll try using a modified version of cairo to see

@maciejka
Copy link
Collaborator Author

@Jeanmichel7 The cause of the issue is in the runner: starkware-libs/cairo#6479. The code is not meant to be used with large arguments.

@maciejka maciejka added the blocked Requires other issues to be resolved first label Oct 14, 2024
@maciejka
Copy link
Collaborator Author

Fixed by: starkware-libs/cairo#6489.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced blocked Requires other issues to be resolved first bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants