Skip to content

Commit

Permalink
fix (again) reading exo Bytes
Browse files Browse the repository at this point in the history
Signed-off-by: Francois Bojarski <[email protected]>
  • Loading branch information
letypequividelespoubelles committed Oct 10, 2024
1 parent c32a012 commit 8e4568b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import static net.consensys.linea.zktracer.module.constants.GlobalConstants.MMU_INST_ANY_TO_RAM_WITH_PADDING;
import static net.consensys.linea.zktracer.module.constants.GlobalConstants.MMU_INST_BLAKE;
import static net.consensys.linea.zktracer.module.constants.GlobalConstants.MMU_INST_EXO_TO_RAM_TRANSPLANTS;
import static net.consensys.linea.zktracer.module.constants.GlobalConstants.MMU_INST_MODEXP_DATA;
import static net.consensys.linea.zktracer.module.constants.GlobalConstants.MMU_INST_MODEXP_ZERO;
import static net.consensys.linea.zktracer.module.constants.GlobalConstants.MMU_INST_RAM_TO_EXO_WITH_PADDING;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,7 +29,6 @@
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.consensys.linea.zktracer.module.constants.GlobalConstants;
import net.consensys.linea.zktracer.module.hub.fragment.imc.mmu.MmuCall;
import net.consensys.linea.zktracer.module.mmu.values.HubToMmuValues;
import net.consensys.linea.zktracer.module.mmu.values.MmuEucCallRecord;
Expand Down Expand Up @@ -62,9 +64,9 @@ public class MmuData {
private static final List<Integer> MMU_INST_EXO_IS_TARGET =
List.of(
MMU_INST_BLAKE,
GlobalConstants.MMU_INST_MODEXP_DATA,
GlobalConstants.MMU_INST_MODEXP_ZERO,
GlobalConstants.MMU_INST_RAM_TO_EXO_WITH_PADDING);
MMU_INST_MODEXP_DATA,
MMU_INST_MODEXP_ZERO,
MMU_INST_RAM_TO_EXO_WITH_PADDING);

public MmuData(final MmuCall mmuCall) {
this(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,17 @@ public void fillLimb() {
? mmioInst.sourceLimbOffset() * LLARGE + mmioInst.sourceByteOffset()
: mmioInst.targetLimbOffset() * LLARGE + mmioInst.targetByteOffset());
final int sizeToExtract = mmioInst.size() == 0 ? LLARGE : mmioInst.size();
final int exoByteOffset =
exoIsSource ? mmioInst.sourceByteOffset() : mmioInst.targetByteOffset();
final Bytes16 exoLimb =
readBytes(mmuData.exoBytes(), offset, sizeToExtract, mmioInst.targetByteOffset());
readBytes(mmuData.exoBytes(), offset, sizeToExtract, exoByteOffset);
;
mmioInst.limb(exoLimb);
}
}
}
}

private boolean exoLimbIsSource() {
return List.of(MMU_INST_ANY_TO_RAM_WITH_PADDING, MMU_INST_EXO_TO_RAM_TRANSPLANTS)
.contains(this.mmuData.hubToMmuValues().mmuInstruction());
}

private void traceFillMmuInstructionFlag(Trace trace) {
trace
.isMload(isMload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class Bytecodes {

public static Bytes16 readBytes(
final Bytes data, final long sourceOffset, final int size, final int targetOffset) {
final Bytes data, final long sourceOffset, final int size, final int exoByteOffset) {
if (sourceOffset >= data.size()) {
return Bytes16.ZERO;
}
Expand All @@ -32,7 +32,7 @@ public static Bytes16 readBytes(

return Bytes16.leftPad(
rightPadTo(
data.slice((int) sourceOffset, (int) dataLengthToExtract), LLARGE - targetOffset));
data.slice((int) sourceOffset, (int) dataLengthToExtract), LLARGE - exoByteOffset));
}

public static Bytes16 readLimb(final Bytes data, final long limbOffset) {
Expand Down

0 comments on commit 8e4568b

Please sign in to comment.