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

chore: VisitedPcs trait in CachedState #3

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

Eagle941
Copy link
Collaborator

@Eagle941 Eagle941 commented Aug 31, 2024

This change introduces the trait VisitedPcs in CachedState for flexibility in the handling of visited program counters returned from an entry point call in cairo_vm.

The structure CachedState contains the field visited_pcs of type HashSet<usize> to contain the set of visited program counters. The development of a Cairo 1 profiler requires storage of the full list of program counters. To add this flexibility in the blockifier, the type of visited_pcs has been replaced with the trait VisitedPcs and an implementation replicating the current behaviour, using HashSet, has been added with the name VisitedPcsSet.

The default instantiation of CachedState in unit tests uses VisitedPcsSet.

Native blockifier is hardcoded to use VisitedPcsSet because it's only a bridge the legacy Python sequencer.

@Eagle941 Eagle941 force-pushed the visited_pcs_trait branch 7 times, most recently from 7ade621 to 111668e Compare September 2, 2024 00:26
@Eagle941 Eagle941 changed the title Visited pcs trait VisitedPcs trait in CachedState Sep 2, 2024
@Eagle941 Eagle941 marked this pull request as ready for review September 2, 2024 01:02
Copy link

@iamrecursion iamrecursion left a comment

Choose a reason for hiding this comment

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

Great start, but definitely needs some tweaks.

There are a lot of type annotations that good API design should make unnecessary as inference should work, and generally there are a few places that are missing docs that absolutely need them.

There are also a bunch of places where there is a type with VisitedPcsSet specified. It probably makes sense to have aliases for most of these: DefaultStatefulValidator, DefaultCachedState and so on. We don't want it to be inconvenient for the Starkware folks to use the default case in the Blockifier.

crates/blockifier/src/blockifier/transaction_executor.rs Outdated Show resolved Hide resolved
crates/blockifier/src/blockifier/transaction_executor.rs Outdated Show resolved Hide resolved
crates/blockifier/src/bouncer_test.rs Outdated Show resolved Hide resolved
crates/blockifier/src/concurrency/flow_test.rs Outdated Show resolved Hide resolved
crates/blockifier/src/state/visited_pcs.rs Outdated Show resolved Hide resolved
crates/blockifier/src/state/visited_pcs.rs Show resolved Hide resolved
crates/blockifier/src/state/visited_pcs.rs Outdated Show resolved Hide resolved
crates/blockifier/src/transaction/account_transaction.rs Outdated Show resolved Hide resolved
@iamrecursion
Copy link

Also note that some of your CI is failing; not sure what "commitlint" is meant to do, but clippy should absolutely be passing.

@Eagle941 Eagle941 force-pushed the visited_pcs_trait branch 2 times, most recently from df55eed to 2ea8e1c Compare September 3, 2024 22:37
@Eagle941 Eagle941 changed the title VisitedPcs trait in CachedState chore: VisitedPcs trait in CachedState Sep 3, 2024
@Eagle941 Eagle941 force-pushed the visited_pcs_trait branch 3 times, most recently from 7042bd1 to 12f942e Compare September 4, 2024 01:52
@Eagle941 Eagle941 force-pushed the visited_pcs_trait branch 2 times, most recently from 23d8fbc to 9ba3e92 Compare September 17, 2024 11:25
@Eagle941 Eagle941 force-pushed the visited_pcs_trait branch 9 times, most recently from 2e739ea to f41cd77 Compare September 18, 2024 20:58
Copy link

@iamrecursion iamrecursion left a comment

Choose a reason for hiding this comment

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

You'll definitely need to re-wrap the lines after applying my edits! Please also fill in anything I've left obviously unfinished.

docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
docs/BENCHMARK.md Outdated Show resolved Hide resolved
@Eagle941 Eagle941 force-pushed the visited_pcs_trait branch 7 times, most recently from 59a5f1d to 65f30bc Compare September 18, 2024 23:20
Copy link

@iamrecursion iamrecursion left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few comments inline.

VisitedPcs_Trait_Benchmark.md Outdated Show resolved Hide resolved
VisitedPcs_Trait_Benchmark.md Outdated Show resolved Hide resolved
crates/blockifier/src/state/cached_state.rs Show resolved Hide resolved
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