Skip to content

Fresh runtime api instance per call estimation#565

Merged
sorpaas merged 4 commits intopolkadot-evm:masterfrom
moonbeam-foundation:tgm-fix-runtimeapi-reuse
Feb 24, 2022
Merged

Fresh runtime api instance per call estimation#565
sorpaas merged 4 commits intopolkadot-evm:masterfrom
moonbeam-foundation:tgm-fix-runtimeapi-reuse

Conversation

@tgmichel
Copy link
Copy Markdown
Contributor

@tgmichel tgmichel commented Feb 4, 2022

A new ApiRef instance needs to be used per execution to avoid the overlayed state to affect the estimation result of subsequent calls.

Note that this would have a performance penalty if we introduce gas estimation for past blocks - and thus, past runtime versions - in the future. Substrate has a runtime_cache_size (introduced in paritytech/substrate#10177) which defaults to 2 slots LRU-style, meaning if users were to access multiple runtime versions (more than 2) in a short period of time, the RPC response time would degrade a lot, as the VersionedRuntime needs to be compiled to occupy a slot.

To solve that, and if we introduce historical gas estimation, we'd need to increase value.

@tgmichel tgmichel requested a review from sorpaas as a code owner February 4, 2022 09:52
@sorpaas
Copy link
Copy Markdown
Member

sorpaas commented Feb 15, 2022

LGTM, but need to resolve conflicts.

@tgmichel
Copy link
Copy Markdown
Contributor Author

done

@sorpaas sorpaas merged commit bc07f7b into polkadot-evm:master Feb 24, 2022
boundless-forest pushed a commit to darwinia-network/frontier that referenced this pull request Mar 2, 2022
* Fresh runtime api instance per call estimation

* rustfmt skip

* fmt
jordy25519 pushed a commit to cennznet/frontier that referenced this pull request Apr 6, 2022
* Fresh runtime api instance per call estimation

* rustfmt skip

* fmt
boundless-forest pushed a commit to darwinia-network/frontier that referenced this pull request May 11, 2022
* Fresh runtime api instance per call estimation

* rustfmt skip

* fmt
@tgmichel tgmichel deleted the tgm-fix-runtimeapi-reuse branch June 24, 2022 07:39
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
* Fresh runtime api instance per call estimation

* rustfmt skip

* fmt
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