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

vm: fix accountexists bug in pre-SD hardforks #1516

Merged
merged 8 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/vm/src/state/stateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ export default class DefaultStateManager implements StateManager {
async accountExists(address: Address): Promise<boolean> {
const account = this._cache.lookup(address)
if (account && !this._cache.keyIsDeleted(address)) {
if (account.balance.isZero() && !this._common.gteHardfork('spuriousDragon')) {
if (account.isEmpty() && !this._common.gteHardfork('spuriousDragon')) {
// If on hardfork before Spurious Dragon, check zero balance accounts in DB to confirm existence
if (await this._trie.get(address.buf)) {
return true
Expand Down
8 changes: 6 additions & 2 deletions packages/vm/tests/accountexists.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import tape from 'tape'
import VM from '../src'

tape('correctly apply new account gas fee on pre-Spurious Dragon hardforks', async (t) => {
// This transaction https://etherscan.io/tx/0x26ea8719eeca5737f8ca872bca1ac53cea9bf6e11462dd83317c2e66a4e43d7b produced an error
// in our VM where we were not applying the new account gas fee (25k wei) for account creation in hardforks before Spurious Dragon
acolytec3 marked this conversation as resolved.
Show resolved Hide resolved
// This test verifies that issue is now resolved

// setup the accounts for this test
acolytec3 marked this conversation as resolved.
Show resolved Hide resolved
const caller = new Address(Buffer.from('1747de68ae74afa4e00f8ef79b9c875a339cda70', 'hex')) // caller address
const contractAddress = new Address(
Expand Down Expand Up @@ -35,8 +39,8 @@ tape('correctly apply new account gas fee on pre-Spurious Dragon hardforks', asy
'a9059cbb000000000000000000000000f48a1bdc65d9ccb4b569ffd4bffff415b90783d60000000000000000000000000000000000000000000000000000000000000001',
'hex'
),
to: contractAddress, // call to the contract address
value: new BN(0),
to: contractAddress, // call to the contract address
value: new BN(0),
}

const result = await vm.runCall(runCallArgs)
Expand Down