diff --git a/packages/statemanager/src/rpcStateManager.ts b/packages/statemanager/src/rpcStateManager.ts index 885fa5168b..f1a8298b66 100644 --- a/packages/statemanager/src/rpcStateManager.ts +++ b/packages/statemanager/src/rpcStateManager.ts @@ -252,10 +252,8 @@ export class RPCStateManager implements EVMStateManagerInterface { } /** - * Gets the code corresponding to the provided `address`. - * @param address - Address to get the `account` for - * @returns {Promise} - Resolves with the code corresponding to the provided address. - * Returns an empty `Uint8Array` if the account has no associated code. + * Gets the account associated with `address` or `undefined` if account does not exist + * @param address - Address of the `account` to get */ async getAccount(address: Address): Promise { const elem = this._accountCache?.get(address) @@ -265,11 +263,13 @@ export class RPCStateManager implements EVMStateManagerInterface { : undefined } - const rlp = (await this.getAccountFromProvider(address)).serialize() + const accountFromProvider = await this.getAccountFromProvider(address) const account = - equalsBytes(rlp, KECCAK256_RLP_EMPTY_ACCOUNT) === false - ? Account.fromRlpSerializedAccount(rlp) - : undefined + equalsBytes(accountFromProvider.codeHash, new Uint8Array(32).fill(0)) || + equalsBytes(accountFromProvider.serialize(), KECCAK256_RLP_EMPTY_ACCOUNT) + ? undefined + : Account.fromRlpSerializedAccount(accountFromProvider.serialize()) + this._accountCache?.put(address, account) return account diff --git a/packages/statemanager/test/testdata/providerData/mockProvider.ts b/packages/statemanager/test/testdata/providerData/mockProvider.ts index 7683c9a6b9..4e56e4d128 100644 --- a/packages/statemanager/test/testdata/providerData/mockProvider.ts +++ b/packages/statemanager/test/testdata/providerData/mockProvider.ts @@ -68,9 +68,9 @@ const getProofValues = async (params: [address: string, _: [], blockTag: bigint return { address, balance: '0x0', - codeHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470', + codeHash: '0x0000000000000000000000000000000000000000000000000000000000000000', nonce: '0x0', - storageHash: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + storageHash: '0x0000000000000000000000000000000000000000000000000000000000000000', storageProof: [], } }