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

Add diagnostics and handle errors gracefully / Upgrade Cairo. #1590

Merged
merged 28 commits into from
Oct 14, 2024

Conversation

wawel37
Copy link
Member

@wawel37 wawel37 commented Sep 11, 2024

Please, during review check if the speed of diagnostics during doc generation is acceptable.

@wawel37 wawel37 changed the title Add diagnostics and handle errors gracefully. Add diagnostics and handle errors gracefully / Upgrade Cairo. Sep 12, 2024
@wawel37 wawel37 marked this pull request as ready for review September 12, 2024 13:33
@wawel37 wawel37 force-pushed the doc/handle-errors-gracefully branch from 74d5183 to f614f01 Compare September 12, 2024 13:42
@maciektr
Copy link
Contributor

Hi!

I've managed to run some benchmarks. For openzeppelin/cairo-contracts I get:

Test run Time
Without diagnostics 366 ms
With diagnostics 8.37 s
With diagnostics, without lowering group 5.48 s

I tried to run parallel diagnostics warmup (inspired with https://github.com/starkware-libs/cairo/blob/e4136a412b03aff3ba1dec3eb8d8d22356cd67ae/crates/cairo-lang-compiler/src/diagnostics.rs#L220), but it didn't really help to bring the time down at all, resulting in 6.7 s (without lowering group).

Please note that compilation of the cairo-contracts project takes about 22 s.

Given that, the cost of running diagnostics is obviously high, but nothing concerning. We should do that.

I would opt for trying to expose an API in the compiler repository, that does not require LoweringGroup, as adding it to the ScarbDocDatabase even if we don't use it seems quite uncalled for.

@wawel37
Copy link
Member Author

wawel37 commented Sep 30, 2024

A PR was created in Cairo repository, to extend the API of diagnostics, so the LoweringGroup will no longer be required

@maciektr
Copy link
Contributor

I've tried hard to find some input which would result in diagnostics, and this caused it

            #[starknet::contract]
            pub(crate) mod DualCaseERC20Mock {
                use starknet::ContractAddress;

                component!(path: ERC20Component, storage: erc20, event: ERC20Event);

                #[storage]
                pub struct Storage {
                    #[substorage(v0)]
                    pub erc20: ERC20Component::Storage
                }

                #[event]
                enum Event {
                    #[flat]
                    ERC20Event: ERC20Component::Event
                }
            }

Do you think we should have a test case like that? 🤔

@wawel37
Copy link
Member Author

wawel37 commented Oct 14, 2024

I've tried hard to find some input which would result in diagnostics, and this caused it

            #[starknet::contract]
            pub(crate) mod DualCaseERC20Mock {
                use starknet::ContractAddress;

                component!(path: ERC20Component, storage: erc20, event: ERC20Event);

                #[storage]
                pub struct Storage {
                    #[substorage(v0)]
                    pub erc20: ERC20Component::Storage
                }

                #[event]
                enum Event {
                    #[flat]
                    ERC20Event: ERC20Component::Event
                }
            }

Do you think we should have a test case like that? 🤔

Done

@wawel37 wawel37 force-pushed the doc/handle-errors-gracefully branch from 5c0e4ce to 02e96d6 Compare October 14, 2024 09:46
Copy link
Contributor

@maciektr maciektr left a comment

Choose a reason for hiding this comment

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

Great stuff!
Minor comments attached below.

Cargo.lock Outdated Show resolved Hide resolved
extensions/scarb-doc/src/db.rs Outdated Show resolved Hide resolved
extensions/scarb-doc/src/errors.rs Outdated Show resolved Hide resolved
extensions/scarb-doc/src/lib.rs Outdated Show resolved Hide resolved
@wawel37 wawel37 force-pushed the doc/handle-errors-gracefully branch from 795b66e to 35c6dee Compare October 14, 2024 15:09
@maciektr maciektr enabled auto-merge October 14, 2024 15:55
@maciektr maciektr added this pull request to the merge queue Oct 14, 2024
Merged via the queue into main with commit 4d91be7 Oct 14, 2024
22 checks passed
@maciektr maciektr deleted the doc/handle-errors-gracefully branch October 14, 2024 21:13
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.

2 participants