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

Gas fixes #83

Merged
merged 2 commits into from
Mar 17, 2022
Merged

Gas fixes #83

merged 2 commits into from
Mar 17, 2022

Conversation

onbjerg
Copy link
Collaborator

@onbjerg onbjerg commented Mar 17, 2022

The gas returned by the EVM did not account for refunds, and Interpreter::gas took &mut self without needing to

I also made finalize not return a Result since there was no path where it would return Err

} else {
// touch coinbase
self.data.subroutine.load_account(coinbase, self.data.db);
self.data.subroutine.balance_add(coinbase, U256::zero());
}
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.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good q. @rakita wdyt?

Copy link
Member

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 {
Copy link
Collaborator

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

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

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

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

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)

@rakita rakita merged commit db1812f into bluealloy:main Mar 17, 2022
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.

3 participants