Skip to content

Commit

Permalink
feat(spec): check for null value before access
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfourzerofour committed Sep 21, 2023
1 parent 8a07935 commit 096b392
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions crates/sim/tracer/src/validationTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface StorageAccess {

interface RelevantStepData {
opcode: string;
stackEnd: BigInt;
stackEnd: BigInt | null;
}

type InternalPhase = Omit<
Expand Down Expand Up @@ -271,18 +271,15 @@ type StringSet = Record<string, boolean | undefined>;

if (secondLast?.opcode.includes("EXT")) {
const opString = `${secondLast.opcode} ${last?.opcode}`;
if (opString !== "EXTCODESIZE ISZERO") {
if (secondLast?.stackEnd && opString !== "EXTCODESIZE ISZERO") {
const addr = toAddress(secondLast.stackEnd.toString(16));
const hexAddr = toHex(addr);
currentPhase.extCodeAccessInfo[hexAddr] = opcode;
}
}

secondLast = last;
const stackEnd =
log.stack.length() > 0
? log.stack.peek(0)
: { value: 0, sign: false, isSmall: false };
const stackEnd = log.stack.length() > 0 ? log.stack.peek(0) : null;
last = { opcode, stackEnd };

if (opcode === "CREATE2") {
Expand Down

0 comments on commit 096b392

Please sign in to comment.