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

modify rpcStataManager getAccount #3345

Merged
merged 6 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/statemanager/src/rpcStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint8Array>} - 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<Account | undefined> {
const elem = this._accountCache?.get(address)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
}
}
Expand Down
Loading