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

bug: support deprecated v0 declare txns #470

Open
1 of 2 tasks
whichqua opened this issue Feb 13, 2025 · 3 comments
Open
1 of 2 tasks

bug: support deprecated v0 declare txns #470

whichqua opened this issue Feb 13, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@whichqua
Copy link
Collaborator

whichqua commented Feb 13, 2025

Describe the Feature Request

Currently we don't support v0 declare txns.
We need to:

  • Support DECLARE V0 on snos
  • Fetch and re-execute these txns with blockifier

Related Code

thread 'main' panicked at ~/snos/crates/rpc-replay/src/transactions.rs:368:42:
not implemented: starknet_rs_to_blockifier with DeclareTransaction::V0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional Context

@whichqua whichqua added the enhancement New feature or request label Feb 13, 2025
@whichqua
Copy link
Collaborator Author

whichqua commented Feb 13, 2025

We can execute txns on snos successfully.
This test passes:

#[rstest]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn declare_v0_cairo0_account(block_context: BlockContext) {
    use starknet_api::core::{ContractAddress, PatriciaKey};
    use starknet_api::{felt, patricia_key};

    let initial_state = StarknetStateBuilder::new(&block_context).build().await;

    let tx_version = TransactionVersion::ZERO;

    let blockifier_class = BlockifierDeprecatedClass::default();
    let class_info = calculate_class_info_for_testing(blockifier_class.into());

    let sender_address = contract_address!("0x1");
    let declare_tx = blockifier::test_utils::declare::declare_tx(
        declare_tx_args! {
            max_fee: Fee(0),
            sender_address,
            version: tx_version
        },
        class_info,
    );

    let txs = vec![declare_tx].into_iter().map(Into::into).collect();
    let _result = execute_txs_and_run_os(
        crate::common::DEFAULT_COMPILED_OS,
        initial_state.cached_state,
        block_context,
        txs,
        Default::default(),
        Default::default(),
        HashMap::default(),
    )
    .await
    .expect("OS run failed");
}

@whichqua
Copy link
Collaborator Author

** Problem 1 **
Implementing the expected converters and trying to execute the txns, the first failure occurs in the following code samples:

  1. Class hash for contract_address!("0x1") is missing. The default class hash is returned
pub async fn get_class_hash_at_async(&self, contract_address: ContractAddress) -> StateResult<ClassHash> {
        let class_hash =
            match self.rpc_client.starknet_rpc().get_class_hash_at(self.block_id, *contract_address.key()).await {
                Ok(class_hash) => Ok(class_hash),
                Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => Ok(ClassHash::default().0),
                Err(e) => Err(provider_error_to_state_error(e)),
            }?;

        Ok(ClassHash(class_hash))
}
  1. Execution fails:
impl CallEntryPoint {
    pub fn execute(
        mut self,
        state: &mut dyn State,
        resources: &mut ExecutionResources,
        context: &mut EntryPointExecutionContext,
    ) -> EntryPointExecutionResult<CallInfo> {
        let tx_context = &context.tx_context;
        let mut decrement_when_dropped = RecursionDepthGuard::new(
            context.current_recursion_depth.clone(),
            context.versioned_constants().max_recursion_depth,
        );
        decrement_when_dropped.try_increment_and_check_depth()?;

        // Validate contract is deployed.
        let storage_class_hash = state.get_class_hash_at(self.storage_address)?;
        if storage_class_hash == ClassHash::default() {
            return Err(PreExecutionError::UninitializedStorageAddress(self.storage_address).into());
        }
       .....

Fixing the return in 1 since we know the contract address doesnt seem to help.

@whichqua whichqua changed the title feat: support deprecated v0 declare txns bug: support deprecated v0 declare txns Feb 20, 2025
@whichqua
Copy link
Collaborator Author

Resolved in #471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant