Skip to content

Gas fixes#83

Merged
rakita merged 2 commits intobluealloy:mainfrom
onbjerg:onbjerg/gas-fixes
Mar 17, 2022
Merged

Gas fixes#83
rakita merged 2 commits intobluealloy:mainfrom
onbjerg:onbjerg/gas-fixes

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

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.

}

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.

👍

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?

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

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