diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java index 2962e79f18..29d911ac63 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java @@ -47,7 +47,7 @@ public class AccountSnapshot { private boolean deploymentStatus; // TODO: is there a "canonical" way to take a snapshot fo an account - // where getWorldUpdater().getAccount(address) return null ? + // where getWorldUpdater().get(address) return null ? /** * Canonical way of creating an account snapshot. diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romlex/RomLex.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romlex/RomLex.java index fafcd5a562..0e8e157cbf 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romlex/RomLex.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romlex/RomLex.java @@ -219,8 +219,8 @@ public void callRomLex(final MessageFrame frame) { !hub.deploymentStatusOf(foreignCodeAddress), "EXTCODECOPY should only trigger a ROM_LEX chunk if its target isn't currently deploying"); checkArgument( - !frame.getWorldUpdater().getAccount(foreignCodeAddress).isEmpty() - && frame.getWorldUpdater().getAccount(foreignCodeAddress).hasCode()); + !frame.getWorldUpdater().get(foreignCodeAddress).isEmpty() + && frame.getWorldUpdater().get(foreignCodeAddress).hasCode()); Optional.ofNullable(frame.getWorldUpdater().get(foreignCodeAddress)) .map(AccountState::getCode) diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/SStore.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/SStore.java index 039c329a02..a7fcc79538 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/SStore.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/SStore.java @@ -31,7 +31,7 @@ public SStore(MessageFrame frame) { this.frame = frame; if (frame.stackSize() > 1) { this.key = UInt256.fromBytes(frame.getStackItem(0)); - final Account account = frame.getWorldUpdater().getAccount(frame.getRecipientAddress()); + final Account account = frame.getWorldUpdater().get(frame.getRecipientAddress()); if (account == null) { return; } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/types/Bytecode.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/types/Bytecode.java index f916ef74be..a10acb77a0 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/types/Bytecode.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/types/Bytecode.java @@ -38,8 +38,8 @@ public final class Bytecode { /** The bytecode. */ @Getter private final Bytes bytecode; - /** The bytecode hash; precomputed & memoized asynchronously. */ - private Future hash; + /** The bytecode hash; is null by default and computed & memoized on the fly when required. */ + private Hash hash; /** * Create an instance from {@link Bytes}. @@ -48,7 +48,6 @@ public final class Bytecode { */ public Bytecode(Bytes bytes) { this.bytecode = Objects.requireNonNullElse(bytes, Bytes.EMPTY); - hash = executorService.submit(() -> computeCodeHash()); } /** @@ -58,7 +57,7 @@ public Bytecode(Bytes bytes) { */ public Bytecode(Code code) { this.bytecode = code.getBytes(); - this.hash = CompletableFuture.completedFuture(code.getCodeHash()); + this.hash = code.getCodeHash(); } /** @@ -85,21 +84,13 @@ public boolean isEmpty() { * @return the bytecode hash */ public Hash getCodeHash() { - try { - return hash.get(); - } catch (Exception e) { - log.error("Error while precomputing code hash", e); - Hash computedHash = computeCodeHash(); - hash = CompletableFuture.completedFuture(computedHash); - return computedHash; - } - } - - private Hash computeCodeHash() { - if (this.bytecode.isEmpty()) { - return Hash.EMPTY; - } else { - return Hash.hash(this.bytecode); + if (this.hash == null) { + if (this.bytecode.isEmpty()) { + this.hash = Hash.EMPTY; + } else { + this.hash = Hash.hash(this.bytecode); + } } + return this.hash; } } diff --git a/testing/src/main/java/net/consensys/linea/testing/ToyWorld.java b/testing/src/main/java/net/consensys/linea/testing/ToyWorld.java index acb652c7f3..41c3f2008e 100644 --- a/testing/src/main/java/net/consensys/linea/testing/ToyWorld.java +++ b/testing/src/main/java/net/consensys/linea/testing/ToyWorld.java @@ -135,7 +135,7 @@ public MutableAccount getAccount(final Address address) { if (addressAccountMap.containsKey(address)) { return addressAccountMap.get(address); } else if (parent != null) { - Account parentAccount = parent.getAccount(address); + Account parentAccount = parent.get(address); if (parentAccount == null) { return null; } else {