Skip to content

apollo_staking: reorganize contract_types.rs into TryFromIterator and TryFrom<Retdata> sections#13064

Merged
dafnamatsry merged 1 commit intomainfrom
dafna/contract-types-reorganize
Mar 30, 2026
Merged

apollo_staking: reorganize contract_types.rs into TryFromIterator and TryFrom<Retdata> sections#13064
dafnamatsry merged 1 commit intomainfrom
dafna/contract-types-reorganize

Conversation

@dafnamatsry
Copy link
Copy Markdown
Collaborator

@dafnamatsry dafnamatsry commented Mar 8, 2026

Note

Medium Risk
Moderate risk because it moves Cairo retdata deserialization types (RetdataDeserializationError, CairoArray, CairoOption) into a new shared crate and updates staking to depend on it; mistakes here could break contract-return parsing at runtime, though the logic is largely a direct extraction/refactor.

Overview
Extracts Cairo retdata parsing helpers into a new shared crate. Adds apollo_cairo_utils to the workspace, providing TryFromIterator, CairoArray, CairoOption, and RetdataDeserializationError for deserializing Cairo1 return values (Retdata) into Rust types.

Updates staking to use the shared utilities. apollo_staking now depends on apollo_cairo_utils and removes the duplicated parsing/error definitions from contract_types.rs, switching imports in cairo_staking_contract.rs, staking_contract.rs, and tests accordingly (with no intended behavior change aside from the refactor).

Written by Cursor Bugbot for commit 58e11d2. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from ef7e6b7 to 1b8eaa2 Compare March 8, 2026 08:50
@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch 3 times, most recently from 7ddd109 to 8cd5a82 Compare March 8, 2026 08:55
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from 1b8eaa2 to 6611dda Compare March 8, 2026 08:55
@dafnamatsry dafnamatsry changed the base branch from dafna/apollo-staking-get-previous-epoch to graphite-base/13064 March 8, 2026 09:04
@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch from 8cd5a82 to ab5f80c Compare March 8, 2026 09:09
@dafnamatsry dafnamatsry force-pushed the graphite-base/13064 branch from 6611dda to afe3cc6 Compare March 8, 2026 09:09
@dafnamatsry dafnamatsry changed the base branch from graphite-base/13064 to dafna/apollo-staking-get-previous-epoch March 8, 2026 09:09
Copy link
Copy Markdown
Collaborator

@matanl-starkware matanl-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matanl-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on dafnamatsry).


crates/apollo_staking/src/contract_types.rs line 38 at r1 (raw file):

// Represents a Cairo1 `Option` containing an element that can be deserialized to `T`.
#[derive(Debug)]
pub(crate) struct CairoOption<T>(pub(crate) Option<T>);

Also from prev PR.
These are generic and unrelated to staking.

Code quote:

// Represents a Cairo1 `Array` containing elements that can be deserialized to `T`.
// `T` must implement `TryFrom<[Felt; N]>`, where `N` is the size of `T`'s Cairo equivalent.
#[derive(Debug, PartialEq, Eq)]
struct CairoArray<T>(Vec<T>);

// Represents a Cairo1 `Option` containing an element that can be deserialized to `T`.
#[derive(Debug)]
pub(crate) struct CairoOption<T>(pub(crate) Option<T>);

@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from afe3cc6 to 61f60d0 Compare March 11, 2026 07:52
@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch 2 times, most recently from 2308017 to c9436c9 Compare March 16, 2026 08:29
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator Author

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dafnamatsry made 1 comment.
Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion (waiting on matanl-starkware).


crates/apollo_staking/src/contract_types.rs line 38 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Also from prev PR.
These are generic and unrelated to staking.

Done.

Copy link
Copy Markdown
Collaborator

@matanl-starkware matanl-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matanl-starkware reviewed 9 files and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on dafnamatsry).

@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch from e2a0fe1 to e3353da Compare March 30, 2026 06:51
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from 233a2e9 to 530c383 Compare March 30, 2026 06:51
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from 530c383 to 3d6d953 Compare March 30, 2026 07:29
@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch 2 times, most recently from 06b67c2 to 0dd895c Compare March 30, 2026 07:43
Copy link
Copy Markdown
Collaborator Author

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dafnamatsry reviewed 9 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on dafnamatsry).

@dafnamatsry dafnamatsry changed the base branch from dafna/apollo-staking-get-previous-epoch to main March 30, 2026 08:10
@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch from 0dd895c to f6f4be6 Compare March 30, 2026 08:11
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Mar 30, 2026

Merge activity

  • Mar 30, 8:12 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

@dafnamatsry dafnamatsry force-pushed the dafna/contract-types-reorganize branch from f6f4be6 to 58e11d2 Compare March 30, 2026 08:17
Copy link
Copy Markdown
Collaborator Author

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dafnamatsry reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on dafnamatsry).

@dafnamatsry dafnamatsry added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit 872e2a6 Mar 30, 2026
40 of 66 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants