-
Notifications
You must be signed in to change notification settings - Fork 614
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
Gas fixes #83
Gas fixes #83
Conversation
} else { | ||
// touch coinbase | ||
self.data.subroutine.load_account(coinbase, self.data.db); | ||
self.data.subroutine.balance_add(coinbase, U256::zero()); | ||
} | ||
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.
Unsure if we still want to do the gas refund calculation stuff here? Does crate::USE_GAS
toggle if we even record gas at all?
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.
Good q. @rakita wdyt?
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 fine, USE_GAS in general is to disable gas calculation if evm is needed in some wasm env where pricing is done differently.
@@ -53,7 +53,7 @@ impl Interpreter { | |||
&self.contract | |||
} | |||
|
|||
pub fn gas(&mut self) -> &Gas { | |||
pub fn gas(&self) -> &Gas { |
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.
👍
} else { | ||
// touch coinbase | ||
self.data.subroutine.load_account(coinbase, self.data.db); | ||
self.data.subroutine.balance_add(coinbase, U256::zero()); | ||
} | ||
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.
Good q. @rakita wdyt?
@@ -192,9 +191,9 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, | |||
&mut self, | |||
caller: H160, | |||
gas: &Gas, | |||
) -> Result<(Map<H160, Account>, Vec<Log>), Return> { | |||
) -> (Map<H160, Account>, Vec<Log>, u64) { |
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 function signature change should be OK given that this function is not exposed
@@ -147,10 +147,9 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact | |||
if crate::USE_GAS { | |||
gas.reimburse_unspend(&exit_reason, ret_gas); | |||
} | |||
match self.finalize::<GSPEC>(caller, &gas) { |
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.
Ack - the error branch would never get hit before
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.
nice :)
The gas returned by the EVM did not account for refunds, and
Interpreter::gas
took&mut self
without needing toI also made
finalize
not return aResult
since there was no path where it would returnErr