Closed kpp closed 2 weeks ago
storage and keys are not unique accross evm, it's unique for an address
DbAccount before:
[crates/evm/src/evm/db_commit.rs:70:13] s = "{\"info\":{\"balance\":\"0xa36bf0\",\"code_hash\":\"0x335b63591435d5cda20c42302c2a9df48f668c519642e35f07098fcd655b5b82\",\"nonce\":1},\"storage\":{\"_phantom\":[null,null],\"codec\":null,\"prefix\":{\"prefix\":{\"inner\":[99,105,116,114,101,97,95,101,118,109,47,69,118,109,47,97,99,99,111,117,110,116,115,47,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5]}}},\"keys\":{\"_phantom\":null,\"prefix\":{\"prefix\":{\"inner\":[99,105,116,114,101,97,95,101,118,109,47,69,118,109,47,97,99,99,111,117,110,116,115,47,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5]}},\"len_value\":{\"_phantom\":null,\"codec\":null,\"prefix\":{\"prefix\":{\"inner\":[99,105,116,114,101,97,95,101,118,109,47,69,118,109,47,97,99,99,111,117,110,116,115,47,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,108]}}},\"elems\":{\"_phantom\":[null,null],\"codec\":null,\"prefix\":{\"prefix\":{\"inner\":[99,105,116,114,101,97,95,101,118,109,47,69,118,109,47,97,99,99,111,117,110,116,115,47,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,101]}}}}}"
After:
thread 'tests::call_tests::call_multiple_test' panicked at crates/evm/src/tests/call_tests.rs:108:5:
assertion `left == right` failed
left: 74
right: 256
Evm::accounts: StateMap<Address, DbAccount>
is roughly equal to:Each time we serde DbAccount (we do it in
EvmDB.accounts set(&address, &db_account, self.working_set)
) we also serde its children prefixes which is not needed at all, because we already have address and we can reconstruct prefixes if that's needed:storage: StateMap
andkeys: StateVec<U256>
with the given prefixmodule_prefix/address
.Also because DbAccountstorage: StateMap<U256, U256>
andkeys: StateVec<U256, BcsCodec>
are unique by keys across all EVM we don't need to storemodule_prefix.address/
prefix at all, because we may create one unique storage prefix which all storage and keys can use. Let's name itEVMS
and save a lot of bytes.