-
Notifications
You must be signed in to change notification settings - Fork 1k
pallet_revive: Change EVM call opcodes to respect the gas limit passed #10018
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
base: master
Are you sure you want to change the base?
Changes from 8 commits
0d70f68
ef44b11
b2e9b0d
197c72a
1ab0dd1
686efb3
8a355ae
90bfadd
7e1a8e3
b96ac78
67814db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
title: 'pallet_revive: Change EVM call opcodes to respect the gas limit passed' | ||
doc: | ||
- audience: Runtime Dev | ||
description: |- | ||
So far the EVM family of call opcodes did ignore the `gas` argument passed to them. The consequence was that we were not able to limit the resource usage of sub contract calls. This PR changes that. **Gas is now fully functional on the EVM backend.** | ||
|
||
The resources of any sub contract call are now effectively limited. This is both true for `Weight` and storage deposit. The algorithm works in a way that if you pass `x%` of the current `GAS` the the `CALL` opcode the sub call will have `x%` of currently available `Weight` and storage deposit available. This allows the caller to always make sure to execute code after retuning from a sub call. | ||
|
||
### Changes to the gas meter | ||
|
||
I needed to change the gas meter to track `gas_consumed` instead of `gas_left`. Otherwise it is not possible to know the total amount of gas spent for a call stack that is not unwinded, yet. | ||
|
||
### Followup | ||
- Implement a new PVM syscall that takes the new unified gas instead of `Weight` and storage deposit limit | ||
- Change resolc to use this new syscall | ||
- Enable the test added here to run on resolc | ||
crates: | ||
- name: pallet-revive | ||
bump: major | ||
- name: pallet-revive-eth-rpc | ||
bump: major | ||
- name: pallet-revive-fixtures | ||
bump: major |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,8 @@ contract Callee { | |
stop() | ||
} | ||
} | ||
|
||
function consumeAllReftime() external { | ||
while (true) {} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ use jsonrpsee::{ | |
types::{ErrorCode, ErrorObjectOwned}, | ||
}; | ||
use pallet_revive::evm::*; | ||
use sp_arithmetic::Permill; | ||
use sp_core::{keccak_256, H160, H256, U256}; | ||
use thiserror::Error; | ||
use tokio::time::Duration; | ||
|
@@ -265,9 +264,9 @@ impl EthRpcServer for EthRpcServerImpl { | |
} | ||
|
||
async fn max_priority_fee_per_gas(&self) -> RpcResult<U256> { | ||
// TODO: Provide better estimation | ||
let gas_price = self.gas_price().await?; | ||
Ok(Permill::from_percent(20).mul_ceil(gas_price)) | ||
// We do not support tips. Hence the recommended priority fee is | ||
// always zero. The effective gas price will always be the base price. | ||
Ok(Default::default()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any data points on wallets being confused by the fact that this is zero? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this (eth_maxPriorityFeePerGas) is not really used in practice, wallets and library like alloy will usually use Since we don't support this concept for now anyway we are better off with this change anyway |
||
} | ||
|
||
async fn get_code(&self, address: H160, block: BlockNumberOrTagOrHash) -> RpcResult<Bytes> { | ||
|
Uh oh!
There was an error while loading. Please reload this page.