Skip to content

Creating new account with empty storage map fails #2076

@PhilippGackstatter

Description

@PhilippGackstatter

There is a bug closely related to #2072 where a new account with an empty storage map is not included in the AccountDelta because this is treated as a "nothing has changed" case.

The following test reproduces this:

/// Tests that creating a new account with a slot whose map is empty is correctly included in the
/// delta.
#[tokio::test]
async fn delta_for_new_account_retains_empty_map_storage_slots() -> anyhow::Result<()> {
    let init_seed: [u8; 32] = rand::random();
    let account = AccountBuilder::new(init_seed)
        .account_type(AccountType::RegularAccountUpdatableCode)
        .storage_mode(AccountStorageMode::Network)
        .with_component(MockAccountComponent::with_slots(vec![
            StorageSlot::empty_map(),
        ]))
        .with_auth_component(Auth::IncrNonce)
        .build()?;

    let tx = TransactionContextBuilder::new(account.clone()).build()?.execute().await?;

    let proven_tx = LocalTransactionProver::default().prove_dummy(tx.clone())?;

    let AccountUpdateDetails::Delta(delta) = proven_tx.account_update().details() else {
        panic!("expected delta");
    };

    assert_eq!(delta.storage().maps().len(), 1);
    assert!(delta.storage().maps().get(&0).unwrap().is_empty());

    Ok(())
}

Fails with error:

    Caused by:
        proven transaction's final account commitment 0x60c8666b589181d50a75364fce5e790c2ac31a5ff827b4977afb8a9284f675bc and account details commitment 0xf7ae8601b7a722083ace4e9e0df672a24065868f641a50a4ff6bb87822e3901f must match

I believe this requires updating the account delta commitment computation to commit to the storage map even if the number of changed entries is 0 to cover this special case. I'm working on this now.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions