-
Notifications
You must be signed in to change notification settings - Fork 22
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
reconnect MMIO constraints #1388
base: arith-dev
Are you sure you want to change the base?
reconnect MMIO constraints #1388
Conversation
Signed-off-by: Francois Bojarski <[email protected]>
…n trivil inst Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
Signed-off-by: Francois Bojarski <[email protected]>
@@ -445,7 +445,7 @@ public static MmuCall forIdentityExtractCallData( | |||
final Hub hub, PrecompileSubsection precompileSubsection) { | |||
|
|||
return new MmuCall(hub, MMU_INST_RAM_TO_RAM_SANS_PADDING) | |||
.sourceId(precompileSubsection.callSection.hubStamp()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and following are real fixes
.sourceRamBytes(Optional.of(modexpSubsection.callerMemorySnapshot)) | ||
.targetId(modexpSubsection.exoModuleOperationId()) | ||
.exoBytes(Optional.of(modExpMetadata.base())) | ||
.exoBytes(Optional.of(leftPadTo(modExpMetadata.base(), MODEXP_COMPONENT_BYTE_SIZE))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real fix too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is modExpMetadata.base()
also right padded (for short call data) ?
@@ -38,7 +38,7 @@ public CodeCopy(final Hub hub) { | |||
this.hub = hub; | |||
this.contract = hub.currentFrame().metadata(); | |||
|
|||
this.exoBytes(Optional.of(hub.romLex().getCodeByMetadata(contract))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
equivalent, but requires less computation
@@ -60,17 +60,17 @@ public ModexpSubsection(final Hub hub, final CallSection callSection) { | |||
if (modexpMetaData | |||
.bbs() | |||
.toUnsignedBigInteger() | |||
.compareTo(BigInteger.valueOf(PROVER_MAX_INPUT_BYTE_SIZE)) | |||
.compareTo(BigInteger.valueOf(MODEXP_COMPONENT_BYTE_SIZE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had a duplicate for this constant
warmth, | ||
hub.deploymentNumberOf(codeAddress), | ||
hub.deploymentStatusOf(codeAddress)); | ||
AccountSnapshot.canonical(hub, hub.messageFrame().getContractAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fix, just use the canonical way when possible
@@ -87,26 +87,23 @@ public void commit(List<MappedByteBuffer> buffers) { | |||
Trace trace = new Trace(buffers); | |||
int stamp = 0; | |||
for (MmuOperation mmuOperation : mmu.operations().getAll()) { | |||
if (mmuOperation.traceMe()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fix
@@ -59,14 +59,10 @@ public void commit(List<MappedByteBuffer> buffers) { | |||
|
|||
for (MmuOperation mmuOperation : operations.getAll()) { | |||
Preconditions.checkState(mmuOperation.traceMe(), "Cannot compute if traceMe is false"); | |||
if (mmuOperation.traceMe()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fix
final int sizeToExtract = mmioInst.size() == 0 ? LLARGE : mmioInst.size(); | ||
final Bytes16 exoLimb = readBytes(mmuData.exoBytes(), offset, sizeToExtract); | ||
mmioInst.limb(exoLimb); | ||
for (MmuToMmioInstruction mmioInst : mmuData.mmuToMmioInstructions()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
@@ -263,7 +263,9 @@ public MmuData setMicroInstructions(MmuData mmuData) { | |||
middleMicroInstruction(mmuData, sourceLimbOffset, targetLimbOffset); | |||
} | |||
|
|||
lastMicroInstruction(mmuData); | |||
if (initialTotalNonTrivial > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
import org.apache.tuweni.bytes.Bytes; | ||
|
||
public class Bytecodes { | ||
|
||
public static Bytes16 readBytes(final Bytes data, final long offset, final int sizeToRead) { | ||
if (offset >= data.size()) { | ||
public static Bytes16 readBytes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just update to the latest master. MMIO constraints are still not plugged
@@ -445,7 +445,7 @@ public static MmuCall forIdentityExtractCallData( | |||
final Hub hub, PrecompileSubsection precompileSubsection) { | |||
|
|||
return new MmuCall(hub, MMU_INST_RAM_TO_RAM_SANS_PADDING) | |||
.sourceId(precompileSubsection.callSection.hubStamp()) | |||
.sourceId(hub.currentFrame().contextNumber()) // called at ContextReEntry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -706,10 +706,10 @@ public static MmuCall forModexpExtractBase( | |||
final Hub hub, final ModexpSubsection modexpSubsection, final ModexpMetadata modExpMetadata) { | |||
if (modExpMetadata.extractBase()) { | |||
return new MmuCall(hub, MMU_INST_MODEXP_DATA) | |||
.sourceId(modexpSubsection.callSection.hubStamp()) | |||
.sourceId(hub.currentFrame().contextNumber()) // called at ContextReEntry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have to understand the changes labeled with ⭐, could you please give a short description of the intended effect ?
.sourceRamBytes(Optional.of(modexpSubsection.callerMemorySnapshot)) | ||
.targetId(modexpSubsection.exoModuleOperationId()) | ||
.exoBytes(Optional.of(modExpMetadata.base())) | ||
.exoBytes(Optional.of(leftPadTo(modExpMetadata.base(), MODEXP_COMPONENT_BYTE_SIZE))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is modExpMetadata.base()
also right padded (for short call data) ?
@@ -38,7 +38,7 @@ public CodeCopy(final Hub hub) { | |||
this.hub = hub; | |||
this.contract = hub.currentFrame().metadata(); | |||
|
|||
this.exoBytes(Optional.of(hub.romLex().getCodeByMetadata(contract))) | |||
this.exoBytes(Optional.of(hub.currentFrame().code().bytecode())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
import org.apache.tuweni.bytes.Bytes; | ||
|
||
public class Bytecodes { | ||
|
||
public static Bytes16 readBytes(final Bytes data, final long offset, final int sizeToRead) { | ||
if (offset >= data.size()) { | ||
public static Bytes16 readBytes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
@@ -263,7 +263,9 @@ public MmuData setMicroInstructions(MmuData mmuData) { | |||
middleMicroInstruction(mmuData, sourceLimbOffset, targetLimbOffset); | |||
} | |||
|
|||
lastMicroInstruction(mmuData); | |||
if (initialTotalNonTrivial > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
final int sizeToExtract = mmioInst.size() == 0 ? LLARGE : mmioInst.size(); | ||
final Bytes16 exoLimb = readBytes(mmuData.exoBytes(), offset, sizeToExtract); | ||
mmioInst.limb(exoLimb); | ||
for (MmuToMmioInstruction mmioInst : mmuData.mmuToMmioInstructions()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
Partial debugging of reconnecting the MMIO constraints (inner + all lookup touching the MMIO)