-
Notifications
You must be signed in to change notification settings - Fork 41
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
Call gas work #1570
Call gas work #1570
Conversation
@@ -446,6 +446,9 @@ public void resolveAtContextReEntry(Hub hub, CallFrame frame) { | |||
checkState(successBit); | |||
scenarioFragment.setScenario(CALL_EOA_SUCCESS_WONT_REVERT); | |||
emptyCodeFirstCoupleOfAccountFragments(hub); | |||
long gasAfterCall = frame.frame().getRemainingGas(); | |||
commonValues.gasNext(gasAfterCall); | |||
hub.currentFrame().lastValidGasNext(gasAfterCall); |
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.
For EOA's and SMC's we grab the gasRemaining
in the frame when it resumes execution. This frees us from having to compute it by hand and fixes many of the gas issues we were having with CALL-type instructions.
@@ -455,6 +458,9 @@ public void resolveAtContextReEntry(Hub hub, CallFrame frame) { | |||
scenarioFragment.setScenario(CALL_PRC_FAILURE); | |||
} | |||
emptyCodeFirstCoupleOfAccountFragments(hub); | |||
long gasAfterCall = frame.frame().getRemainingGas(); | |||
commonValues.gasNext(gasAfterCall); | |||
hub.currentFrame().lastValidGasNext(gasAfterCall); |
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.
same
if (callWouldLeadToAccountCreation) upfrontGasCost += GAS_CONST_G_NEW_ACCOUNT; | ||
upfrontGasCost += nonzeroValueTransfer() ? GAS_CONST_G_CALL_VALUE : 0; | ||
upfrontGasCost += warm ? GAS_CONST_G_WARM_ACCESS : GAS_CONST_G_COLD_ACCOUNT_ACCESS; | ||
upfrontGasCost += callWouldLeadToAccountCreation() ? GAS_CONST_G_NEW_ACCOUNT : 0; |
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.
bugfix + streamlining of the computation.
The bug was that the transafer value of 9000 was only paid for CALL
, while both CALL
and CALLCODE
can trigger it.
@@ -94,7 +94,7 @@ public int getCodeFragmentIndex(Hub hub) { | |||
@Getter @Setter private MemoryRange outputDataRange = MemoryRange.EMPTY; // set at exit time | |||
|
|||
@Getter private boolean executionPaused = false; | |||
@Getter private long lastValidGasNext = 0; | |||
@Getter @Setter private long lastValidGasNext = 0; |
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.
Used to set the GAS_NEXT after the fact for EOA and PRC calls.
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.
LGTM, made a little formatting commit + small question
@@ -455,6 +458,9 @@ public void resolveAtContextReEntry(Hub hub, CallFrame frame) { | |||
scenarioFragment.setScenario(CALL_PRC_FAILURE); | |||
} | |||
emptyCodeFirstCoupleOfAccountFragments(hub); | |||
long gasAfterCall = frame.frame().getRemainingGas(); | |||
commonValues.gasNext(gasAfterCall); | |||
hub.currentFrame().lastValidGasNext(gasAfterCall); |
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.
doesn't at this point hub.currentFrame == frame ?
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 mean the frame of resolveAtContextReEntry(Hub hub, CallFrame frame)
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'm not sure ...
Signed-off-by: F Bojarski <ceciestunepoubelle@protonmail.ch>
No description provided.