-
Notifications
You must be signed in to change notification settings - Fork 33
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
1568 some last mmio issues second part #1571
Changes from all commits
b23c78e
a235f33
27d5a9d
67ae06d
beaaddc
b326cdc
26491aa
d9f8598
da8f70c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,10 +105,6 @@ public class CallSection extends TraceSection | |
// row i+0 | ||
private final CallScenarioFragment scenarioFragment = new CallScenarioFragment(); | ||
|
||
public boolean isAbortingScenario() { | ||
return scenarioFragment.getScenario().isAbortingScenario(); | ||
} | ||
|
||
// last row | ||
@Setter private ContextFragment finalContextFragment; | ||
|
||
|
@@ -211,7 +207,7 @@ public CallSection(Hub hub, MessageFrame frame) { | |
|
||
value = | ||
opCode.callHasValueArgument() | ||
? Wei.of(currentFrame.frame().getStackItem(2).toUnsignedBigInteger()) | ||
? Wei.of(frame.getStackItem(2).toUnsignedBigInteger()) | ||
letypequividelespoubelles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: Wei.ZERO; | ||
|
||
final CallOobCall oobCall = new CallOobCall(); | ||
|
@@ -224,13 +220,13 @@ public CallSection(Hub hub, MessageFrame frame) { | |
hub.defers().scheduleForPostTransaction(this); | ||
|
||
// The CALL is now unexceptional and un-aborted | ||
refineUndefinedScenario(hub); | ||
CallScenarioFragment.CallScenario scenario = scenarioFragment.getScenario(); | ||
refineUndefinedScenario(hub, frame); | ||
final CallScenarioFragment.CallScenario scenario = scenarioFragment.getScenario(); | ||
switch (scenario) { | ||
case CALL_ABORT_WONT_REVERT -> abortingCall(hub); | ||
case CALL_EOA_UNDEFINED -> eoaProcessing(hub); | ||
case CALL_PRC_UNDEFINED -> prcProcessing(hub); | ||
case CALL_SMC_UNDEFINED -> smcProcessing(hub, frame); | ||
case CALL_PRC_UNDEFINED -> prcProcessing(hub); | ||
case CALL_ABORT_WONT_REVERT -> abortingCall(hub); | ||
letypequividelespoubelles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default -> throw new RuntimeException("Illegal CALL scenario"); | ||
} | ||
} | ||
|
@@ -313,21 +309,18 @@ private void abortingCall(Hub hub) { | |
* | ||
* @param hub | ||
*/ | ||
private void refineUndefinedScenario(Hub hub) { | ||
private void refineUndefinedScenario(Hub hub, MessageFrame frame) { | ||
|
||
final boolean aborts = hub.pch().abortingConditions().any(); | ||
if (aborts) { | ||
scenarioFragment.setScenario(CALL_ABORT_WONT_REVERT); | ||
return; | ||
} | ||
|
||
final WorldUpdater world = hub.currentFrame().frame().getWorldUpdater(); | ||
final WorldUpdater world = frame.getWorldUpdater(); | ||
letypequividelespoubelles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (isPrecompile(calleeAddress)) { | ||
precompileAddress = Optional.of(calleeAddress); | ||
scenarioFragment.setScenario(CALL_PRC_UNDEFINED); | ||
|
||
precompileSubsection = | ||
ADDRESS_TO_PRECOMPILE.get(preOpcodeCalleeSnapshot.address()).apply(hub, this); | ||
} else { | ||
Optional.ofNullable(world.get(calleeAddress)) | ||
.ifPresentOrElse( | ||
|
@@ -361,8 +354,17 @@ private void smcProcessing(Hub hub, MessageFrame frame) { | |
} | ||
|
||
private void prcProcessing(Hub hub) { | ||
precompileSubsection = | ||
ADDRESS_TO_PRECOMPILE.get(preOpcodeCalleeSnapshot.address()).apply(hub, this); | ||
hub.defers().scheduleForContextEntry(this); | ||
hub.defers().scheduleForContextReEntry(this, hub.currentFrame()); | ||
// In case of arguments too large for MODEXP, transaction will be popped anyway, and resolving | ||
// some defers will create NPE | ||
if (precompileSubsection instanceof ModexpSubsection | ||
&& ((ModexpSubsection) precompileSubsection).transactionWillBePopped) { | ||
hub.defers().unscheduleForContextReEntry(this, hub.currentFrame()); | ||
hub.defers().unscheduleForPostTransaction(this); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it make more sense to
You are scheduling and unscheduling but you already have all requisite information to decide whether you will need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree, but I find it way more readable to do it in any case, and undo it in some (very rare) case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plus when we schedule for postTransaction, we still don't have the information as the precompile subsection is created after. So in any case we'll have to unschedule it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that both should be equivalent. Your call |
||
} | ||
|
||
@Override | ||
|
@@ -375,7 +377,7 @@ public void resolvePostExecution( | |
@Override | ||
public void resolveUponContextEntry(Hub hub) { | ||
|
||
CallScenarioFragment.CallScenario scenario = scenarioFragment.getScenario(); | ||
final CallScenarioFragment.CallScenario scenario = scenarioFragment.getScenario(); | ||
checkState(scenario == CALL_SMC_UNDEFINED | scenario == CALL_PRC_UNDEFINED); | ||
|
||
postOpcodeCallerSnapshot = preOpcodeCallerSnapshot.deepCopy(); | ||
|
@@ -462,33 +464,29 @@ public void resolveAtContextReEntry(Hub hub, CallFrame frame) { | |
} | ||
|
||
case CALL_SMC_UNDEFINED -> { | ||
|
||
// CALL_SMC_SUCCESS_XXX case | ||
if (successBit) { | ||
scenarioFragment.setScenario(CALL_SMC_SUCCESS_WONT_REVERT); | ||
return; | ||
} | ||
|
||
AccountSnapshot beforeFailureCallerSnapshot = | ||
final AccountSnapshot beforeFailureCallerSnapshot = | ||
postOpcodeCallerSnapshot.deepCopy().setDeploymentInfo(hub); | ||
AccountSnapshot afterFailureCallerSnapshot = | ||
final AccountSnapshot afterFailureCallerSnapshot = | ||
preOpcodeCallerSnapshot.deepCopy().setDeploymentInfo(hub); | ||
AccountSnapshot beforeFailureCalleeSnapshot = | ||
final AccountSnapshot beforeFailureCalleeSnapshot = | ||
postOpcodeCalleeSnapshot.deepCopy().setDeploymentInfo(hub); | ||
AccountSnapshot afterFailureCalleeSnapshot = | ||
final AccountSnapshot afterFailureCalleeSnapshot = | ||
preOpcodeCalleeSnapshot.deepCopy().setDeploymentInfo(hub).turnOnWarmth(); | ||
|
||
// CALL_SMC_FAILURE_XXX case | ||
scenarioFragment.setScenario(CALL_SMC_FAILURE_WONT_REVERT); | ||
|
||
if (isNonzeroValueSelfCall()) { | ||
childContextExitCallerSnapshot.decrementBalanceBy(value); | ||
reEntryCalleeSnapshot.decrementBalanceBy(value); | ||
} | ||
|
||
int childId = hub.currentFrame().childFrameIds().getLast(); | ||
CallFrame childFrame = hub.callStack().getById(childId); | ||
int childContextRevertStamp = childFrame.revertStamp(); | ||
final int childId = hub.currentFrame().childFrameIds().getLast(); | ||
final CallFrame childFrame = hub.callStack().getById(childId); | ||
final int childContextRevertStamp = childFrame.revertStamp(); | ||
|
||
final AccountFragment postReEntryCallerAccountFragment = | ||
hub.factories() | ||
|
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.
As explained below I'm not convinced we need this.
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.
see other comment. We schedule for postTx at the creation of the callSection, when the (modexp) subsection is still not created, so we don't have the info at the time of the schedulling.
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.
So wouldn't we have to unscheduled the postTransaction stuff, 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.
this is the postTx we unschedule !
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.
The one we don't unSchedule (because it doesn't create NPE) is contextEntry