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

feat(blockifier): replace the aliases in the state diff #2766

Open
wants to merge 1 commit into
base: yoav/compression/alias_compressor
Choose a base branch
from

Conversation

yoavGrs
Copy link
Contributor

@yoavGrs yoavGrs commented Dec 18, 2024

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

yoavGrs commented Dec 18, 2024

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.

Copy link

Artifacts upload workflows:

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @nimrod-starkware and @yoavGrs)


crates/blockifier/src/state/stateful_compression_test.rs line 0 at r1 (raw file):
can you implement a decompress test util and use it to compare original and compressed+decompressed diff?


crates/blockifier/src/state/stateful_compression_test.rs line 271 at r1 (raw file):

            .into_iter()
            .collect(),
        declared_contracts: vec![(ClassHash(Felt::THREE), true)].into_iter().collect(),

put large values here? to make sure these are not compressed, but for the correct reason

Code quote:

        compiled_class_hashes: vec![(ClassHash(Felt::ONE), CompiledClassHash(Felt::ZERO))]
            .into_iter()
            .collect(),
        declared_contracts: vec![(ClassHash(Felt::THREE), true)].into_iter().collect(),

crates/blockifier/src/state/stateful_compression.rs line 161 at r1 (raw file):

            .class_hashes
            .insert(alias_compressor.compress_address(address)?, *class_hash);
    }

we always compress class hashes? @Yoni-Starkware @nimrod-starkware

Code quote:

    for (address, class_hash) in state_diff.class_hashes.iter() {
        compressed_state_diff
            .class_hashes
            .insert(alias_compressor.compress_address(address)?, *class_hash);
    }

crates/blockifier/src/state/stateful_compression.rs line 174 at r1 (raw file):

    compressed_state_diff.declared_contracts.extend(state_diff.declared_contracts.iter());

    Ok(compressed_state_diff)

for forward-compatibility (if fields are added to the state diff) better to use .. notation and explicitly replace specific compressed fields. WDYT?

Suggestion:

    let alias_compressor = AliasCompressor { state, alias_contract_address };

    let nonces: ... = state_diff.nonces.iter().map(|(address, nonce)| {
        (alias_compressor.compress_address(address)?, *nonce)
    }).collect();
    let class_hashes: ... = state_diff.class_hashes.iter().map(|(address, class_hash)| {
        (alias_compressor.compress_address(address)?, *class_hash)
    }).collect();
    let storage: ... = state_diff.storage.iter().map(|((address, key), value)| {
        (
            (
                alias_compressor.compress_address(address)?,
                alias_compressor.compress_storage_key(key, address)?,
            ),
            *value,
        )
    }).collect();

    Ok(StateMaps {
        nonces,
        class_hashes,
        storage,
        ..state_diff
    })

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