Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

dev: ensure consistency in EVM storage #828

Open
enitrat opened this issue Aug 19, 2024 · 0 comments
Open

dev: ensure consistency in EVM storage #828

enitrat opened this issue Aug 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@enitrat
Copy link
Contributor

enitrat commented Aug 19, 2024

In CairoZero, the address of an EVM storage is computed as

    // @notice Compute the storage address of the given key when the storage var interface is
    //         Account_storage(key: Uint256)
    // @dev    Just the generated addr method when compiling the account_contract
    func _storage_addr{pedersen_ptr: HashBuiltin*, range_check_ptr}(key: Uint256*) -> (res: felt) {
        let res = 0x0127c52d6fa812547d8a5b435341b8c12e82048913e7193c0e318e8a6642876d;
        let (res) = hash2{hash_ptr=pedersen_ptr}(res, cast(key, felt*)[0]);
        let (res) = hash2{hash_ptr=pedersen_ptr}(res, cast(key, felt*)[1]);
        let (res) = normalize_address(addr=res);
        return (res=res);
    }

Ensure that

        fn write_storage(ref self: ContractState, key: u256, value: u256) {
            self.ownable.assert_only_owner();
            self.Account_storage.write(key, value);
        }

is computing the same key and compatibility is kept.

@enitrat enitrat added the enhancement New feature or request label Aug 19, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Aug 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
No open projects
Status: 🆕 Backlog
Development

No branches or pull requests

1 participant