Skip to content

Commit

Permalink
vm: unduplify 3607 error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Sep 2, 2024
1 parent 0d77c3f commit 4287e95
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/vm/src/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,15 @@ async function _runTx(vm: VM, opts: RunTxOpts): Promise<RunTxResult> {
}
// EIP-3607: Reject transactions from senders with deployed code
if (vm.common.isActivatedEIP(3607) && !equalsBytes(fromAccount.codeHash, KECCAK256_NULL)) {
if (vm.common.isActivatedEIP(7702)) {
const code = await state.getCode(caller)
if (!equalsBytes(code.slice(0, 3), DELEGATION_7702_FLAG)) {
const isActive7702 = vm.common.isActivatedEIP(7702)
switch (isActive7702) {
case true: {
const code = await state.getCode(caller)
// If the EOA is 7702-delegated, sending txs from this EOA is fine
if (equalsBytes(code.slice(0, 3), DELEGATION_7702_FLAG)) break
// Trying to send TX from account with code (which is not 7702-delegated), falls through and throws
}
default: {
const msg = _errorMsg(
'invalid sender address, address is not EOA (EIP-3607)',
vm,
Expand All @@ -302,9 +308,6 @@ async function _runTx(vm: VM, opts: RunTxOpts): Promise<RunTxResult> {
)
throw new Error(msg)
}
} else {
const msg = _errorMsg('invalid sender address, address is not EOA (EIP-3607)', vm, block, tx)
throw new Error(msg)
}
}

Expand Down

0 comments on commit 4287e95

Please sign in to comment.