Skip to content
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

Merged
merged 8 commits into from
Nov 28, 2024
Merged

Call gas work #1570

merged 8 commits into from
Nov 28, 2024

Conversation

OlivierBBB
Copy link
Collaborator

No description provided.

@@ -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);
Copy link
Collaborator Author

@OlivierBBB OlivierBBB Nov 26, 2024

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);
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

@OlivierBBB OlivierBBB Nov 26, 2024

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;
Copy link
Collaborator Author

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.

Copy link
Collaborator

@letypequividelespoubelles letypequividelespoubelles left a 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);
Copy link
Collaborator

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 ?

Copy link
Collaborator

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)

Copy link
Collaborator Author

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>
@OlivierBBB OlivierBBB enabled auto-merge (squash) November 27, 2024 17:13
@OlivierBBB OlivierBBB merged commit 28d6c93 into arith-dev Nov 28, 2024
5 checks passed
@OlivierBBB OlivierBBB deleted the CALL-gas-work branch November 28, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants