Skip to content

Allow recording gas costs in is_precompile#157

Merged
sorpaas merged 3 commits intorust-ethereum:masterfrom
moonbeam-foundation:jeremy-charge-for-is-precompile
Mar 10, 2023
Merged

Allow recording gas costs in is_precompile#157
sorpaas merged 3 commits intorust-ethereum:masterfrom
moonbeam-foundation:jeremy-charge-for-is-precompile

Conversation

@nanocryk
Copy link
Copy Markdown
Contributor

@nanocryk nanocryk commented Mar 8, 2023

In Moonbeam we have dynamic precompile sets to provice ERC20 interface to substrate assets, which require a storage read to know if an address corresponds to an existing asset. This cost is however ignored currently as there is no way to record such cost inside is_precompile.

This PR changes that by providing an handle to record gas to is_precompile, and update the code path using is_precompile (is_cold) to take &mut instead of &. This change doesn't increase any cost by itself, but will allow precompile sets to record costs if needed.

@sorpaas
Copy link
Copy Markdown
Member

sorpaas commented Mar 8, 2023

Can we just make is_precompile to return an extra cost value? Would that already fit your use cases?

It's unlikely we'll need the GasometerHandle for anything else than recording cost, so I'm afraid that the current interface adds unnecessary complexity.

@nanocryk
Copy link
Copy Markdown
Contributor Author

nanocryk commented Mar 9, 2023

Followed your suggestion but also added the remaining gas as parameter, as we don't want to do some costly operation if it cannot be paid for.

@sorpaas sorpaas merged commit faeb242 into rust-ethereum:master Mar 10, 2023
zjb0807 added a commit to AcalaNetwork/Acala that referenced this pull request Jan 22, 2024
zjb0807 added a commit to AcalaNetwork/Acala that referenced this pull request Jan 29, 2024
* update PrecompileHandle ref: rust-ethereum/evm#122

* update fee calculation ref: rust-ethereum/evm#132

* add code_size/code_hash fn in StackState trait ref: rust-ethereum/evm#140

* update evm call stack ref: rust-ethereum/evm#136

* update evm call stack ref: rust-ethereum/evm#155

* add shanghai eips 3651, 3855, 3860 ref: rust-ethereum/evm#152

* update is_precompile ref: rust-ethereum/evm#157

* fix eip-3860 ref: rust-ethereum/evm#160

* update runtime config ref: rust-ethereum/evm#161

* add eip-4399 ref: rust-ethereum/evm#162

* fix eip-2618 ref: rust-ethereum/evm#163

* fix nonce back to U256 ref: rust-ethereum/evm#166

* remove exit_substate in create functions ref: rust-ethereum/evm#168

* record external cost ref: rust-ethereum/evm#170

* add record_external_operation ref: rust-ethereum/evm#171

* add storage_growth ref: rust-ethereum/evm#173

* update evm

* switch to shanghai hardfork

* update ecrecover ref: polkadot-evm/frontier#964 (#2696)
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