Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Dec 30, 2024
1 parent 650f322 commit 9d046e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ memory representation and Python conversion logic. The Cairo implementation must
follow the established patterns for memory layout and pointer relationships,
while the Python side requires bidirectional conversion handling.

When implementing the Cairo equivalent of a python type, you should always map
the cairo type to the python type in `_cairo_struct_to_python_type` inside
`args_gen.py`.

### Error Types Pattern

Error types should:
Expand All @@ -46,7 +50,8 @@ struct StackOverflowError {
```

3. Return `cast(0, ErrorType*)` for success cases
4. Create a new Bytes with message for error cases. The error message can be empty.
4. Create a new Bytes with message for error cases. The error message can be
empty.

```cairo
tempvar err = StackUnderflowError(Bytes(new BytesStruct(cast(0, felt*), 0)));
Expand All @@ -61,7 +66,7 @@ When working with mutable data structures (stack, memory, state, etc.):

Example:

```cairo
````cairo
func push{stack: Stack}(value: U256) -> StackOverflowError {
# Only return error
}
Expand Down Expand Up @@ -107,7 +112,7 @@ class TestFeature:
cairo_run("operation", ...)
with pytest.raises(ErrorType):
operation(...)
```
````

### Type Wrapping Pattern

Expand Down Expand Up @@ -355,8 +360,8 @@ together in a real-world component. The stack is a fundamental part of the EVM,
requiring both mutable state and error handling.

1. Error Types: First, we define the possible error conditions following the
Errors pattern. The stack can fail in two ways - underflow when popping
from an empty stack, or overflow when pushing beyond the maximum size.
Errors pattern. The stack can fail in two ways - underflow when popping from
an empty stack, or overflow when pushing beyond the maximum size.

```cairo:cairo/ethereum/cancun/vm/exceptions.cairo
struct StackUnderflowError {
Expand Down
15 changes: 10 additions & 5 deletions docs/code_architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ memory representation and Python conversion logic. The Cairo implementation must
follow the established patterns for memory layout and pointer relationships,
while the Python side requires bidirectional conversion handling.

When implementing the Cairo equivalent of a python type, you should always map
the cairo type to the python type in `_cairo_struct_to_python_type` inside
`args_gen.py`.

### Error Types Pattern

Error types should:
Expand All @@ -43,7 +47,8 @@ struct StackOverflowError {
```

3. Return `cast(0, ErrorType*)` for success cases
4. Create a new Bytes with message for error cases. The error message can be empty.
4. Create a new Bytes with message for error cases. The error message can be
empty.

```cairo
tempvar err = StackUnderflowError(Bytes(new BytesStruct(cast(0, felt*), 0)));
Expand All @@ -58,7 +63,7 @@ When working with mutable data structures (stack, memory, state, etc.):

Example:

```cairo
````cairo
func push{stack: Stack}(value: U256) -> StackOverflowError {
# Only return error
}
Expand Down Expand Up @@ -104,7 +109,7 @@ class TestFeature:
cairo_run("operation", ...)
with pytest.raises(ErrorType):
operation(...)
```
````

### Type Wrapping Pattern

Expand Down Expand Up @@ -352,8 +357,8 @@ together in a real-world component. The stack is a fundamental part of the EVM,
requiring both mutable state and error handling.

1. Error Types: First, we define the possible error conditions following the
Errors pattern. The stack can fail in two ways - underflow when popping
from an empty stack, or overflow when pushing beyond the maximum size.
Errors pattern. The stack can fail in two ways - underflow when popping from
an empty stack, or overflow when pushing beyond the maximum size.

```cairo:cairo/ethereum/cancun/vm/exceptions.cairo
struct StackUnderflowError {
Expand Down

0 comments on commit 9d046e2

Please sign in to comment.