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

Improve Unused arguments rule #1

Open
fcasal opened this issue Jan 3, 2022 · 0 comments
Open

Improve Unused arguments rule #1

fcasal opened this issue Jan 3, 2022 · 0 comments

Comments

@fcasal
Copy link
Collaborator

fcasal commented Jan 3, 2022

Currently, the rule finds unused function arguments. However, Cairo programs commonly use the pattern:

struct BatchConfig:
    member general_config : GeneralConfig*
    member signed_min_oracle_prices : OraclePrice*
    member signed_max_oracle_prices : OraclePrice*
    member n_oracle_prices : felt
    member min_expiration_timestamp : felt
end

func batch_config_new(
        general_config : GeneralConfig*, signed_min_oracle_prices : OraclePrice*,
        signed_max_oracle_prices : OraclePrice*, n_oracle_prices, min_expiration_timestamp) -> (
        batch_config : BatchConfig*):
    let (fp_val, pc_val) = get_fp_and_pc()
    return (batch_config=cast(fp_val - 2 - BatchConfig.SIZE, BatchConfig*))
end

https://github.com/starkware-libs/stark-perpetual/blob/9327c640e59bd15764833505560478d33aa6a8b1/src/services/perpetual/cairo/transactions/batch_config.cairo#L1-L19

We need to

  • check the usage of cast(fp_val - 2 - STRUCT.SIZE, STRUCT*)
  • check that all struct members and function parameters match in number and type
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

No branches or pull requests

1 participant