NethermindEth / blockifier

Blockifier is a Rust implementation for the transaction-executing component in the StarkNet sequencer, in charge of creating state diffs and blocks.
Apache License 2.0
1 stars 4 forks source link

feat: use cached state instead of separate program_cache #117

Closed xrvdg closed 1 month ago

xrvdg commented 1 month ago

By storing the native executor with the contract class we can leverage the cache state reader to do the caching via get_compiled_contract_class instead of having to add another layer of caching. The main changes are in crates/blockifier/src/execution/contract_class.rs,

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 84.90566% with 24 lines in your changes missing coverage. Please review.

Project coverage is 80.73%. Comparing base (6eb75c0) to head (6572fc6).

Files Patch % Lines
crates/blockifier/src/execution/contract_class.rs 64.00% 9 Missing :warning:
...es/blockifier/src/blockifier/stateful_validator.rs 20.00% 0 Missing and 4 partials :warning:
...lockifier/src/execution/deprecated_syscalls/mod.rs 83.33% 3 Missing :warning:
.../blockifier/src/transaction/account_transaction.rs 91.30% 0 Missing and 2 partials :warning:
crates/native_blockifier/src/py_block_executor.rs 0.00% 2 Missing :warning:
...lockifier/src/transaction/transaction_execution.rs 75.00% 0 Missing and 1 partial :warning:
...es/blockifier/src/transaction/transaction_utils.rs 0.00% 1 Missing :warning:
crates/blockifier/src/transaction/transactions.rs 90.90% 0 Missing and 1 partial :warning:
crates/native_blockifier/src/py_validator.rs 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## native2.6.4 #117 +/- ## =============================================== - Coverage 80.90% 80.73% -0.17% =============================================== Files 77 77 Lines 10729 10552 -177 Branches 10729 10552 -177 =============================================== - Hits 8680 8519 -161 + Misses 1582 1569 -13 + Partials 467 464 -3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rodrigo-pino commented 1 month ago

@xrvdg could you link the Juno branch that comes in tandem with this PR here. So far are using the same name for both, but just for reference for the future.

xrvdg commented 1 month ago

@xrvdg could you link the Juno branch that comes in tandem with this PR here. So far are using the same name for both, but just for reference for the future.

https://github.com/NethermindEth/juno/pull/1967

xrvdg commented 1 month ago

It looks good, left some questions. Also, you got me wondering how is cache working. I cannot find the logic but it is a fact that it is happening

get_compiled_contract_class drives the caching and is central to the execution of contracts. The block-level cache that Juno uses is defined in the blockifier (CachedState). CachedState uses interior mutability to satisfy the StateReader trait while still being able to populate the cache.