Skip to content

apollo_staking: implement get_previous_epoch in CairoStakingContract#12902

Open
dafnamatsry wants to merge 1 commit intodafna/mock-staking-get-previous-epoch-datafrom
dafna/apollo-staking-get-previous-epoch
Open

apollo_staking: implement get_previous_epoch in CairoStakingContract#12902
dafnamatsry wants to merge 1 commit intodafna/mock-staking-get-previous-epoch-datafrom
dafna/apollo-staking-get-previous-epoch

Conversation

@dafnamatsry
Copy link
Collaborator

@dafnamatsry dafnamatsry commented Feb 26, 2026

Note

Medium Risk
Touches contract-call behavior and low-level retdata deserialization; a mismatch with the contract’s actual ABI/encoding would surface as runtime parsing errors or incorrect epoch handling.

Overview
CairoStakingContract.get_previous_epoch is now implemented to call the on-chain get_previous_epoch_data view and deserialize an optional Epoch result instead of todo!().

To support this, contract_types adds reusable Cairo1 retdata deserialization helpers for Felt, Option<T> and a CairoOption<T> wrapper, refactors Epoch/array parsing to use the iterator-based approach, and expands unit/integration tests to cover Some/None, invalid variants/lengths, and contract-level previous-epoch behavior.

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

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

dafnamatsry commented Feb 26, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dafnamatsry dafnamatsry marked this pull request as ready for review February 26, 2026 11:19
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from 2f7280c to fdb5152 Compare February 26, 2026 12:38
@dafnamatsry dafnamatsry force-pushed the dafna/mock-staking-get-previous-epoch-data branch from fabaf19 to e14599a Compare February 26, 2026 12:38
@dafnamatsry dafnamatsry changed the base branch from dafna/mock-staking-get-previous-epoch-data to graphite-base/12902 March 4, 2026 09:38
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from fdb5152 to e2f4d77 Compare March 4, 2026 09:51
@dafnamatsry dafnamatsry force-pushed the graphite-base/12902 branch from e14599a to d6ad6c9 Compare March 4, 2026 09:51
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from e2f4d77 to ef7e6b7 Compare March 8, 2026 08:10
@dafnamatsry dafnamatsry changed the base branch from graphite-base/12902 to dafna/mock-staking-get-previous-epoch-data March 8, 2026 08:10
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch 2 times, most recently from 1b8eaa2 to 6611dda Compare March 8, 2026 08:55
@dafnamatsry dafnamatsry force-pushed the dafna/apollo-staking-get-previous-epoch branch from 6611dda to afe3cc6 Compare March 8, 2026 09:04
Copy link
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 4 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on dafnamatsry).


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

}

impl TryFromIterator<Felt> for Felt {

I think this, and other "generic non staking related" stuff should be moved to a different location.

Code quote:

impl TryFromIterator<Felt> for Felt {

crates/apollo_staking/src/contract_types_test.rs line 164 at r1 (raw file):

#[case::empty_retdata(vec![])]
#[case::some_wrong_length(vec![Felt::ZERO, Felt::ONE])]
#[case::none_wrong_length(vec![Felt::ONE, Felt::TWO])]

Missing case for "too many args"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants