-
Notifications
You must be signed in to change notification settings - Fork 6
[issues/318] Added support for cheat code 'vm.fee' in PVM mode #331
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
Changes from 3 commits
b42921a
b702d8b
157455a
df8e848
9de3c77
6bac815
d569ac4
a641443
842e38a
129625e
6702843
b3cea92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,10 @@ use foundry_cheatcodes::{ | |
| Broadcast, BroadcastableTransactions, CheatcodeInspectorStrategy, | ||
| CheatcodeInspectorStrategyContext, CheatcodeInspectorStrategyRunner, CheatsConfig, CheatsCtxt, | ||
| CommonCreateInput, DealRecord, Ecx, EvmCheatcodeInspectorStrategyRunner, Result, | ||
| Vm::{dealCall, getNonce_0Call, pvmCall, rollCall, setNonceCall, setNonceUnsafeCall, warpCall}, | ||
| Vm::{ | ||
| dealCall, feeCall, getNonce_0Call, pvmCall, rollCall, setNonceCall, setNonceUnsafeCall, | ||
| warpCall, | ||
| }, | ||
| }; | ||
| use foundry_common::sh_err; | ||
| use foundry_compilers::resolc::dual_compiled_contracts::DualCompiledContracts; | ||
|
|
@@ -164,6 +167,11 @@ fn set_timestamp(new_timestamp: U256, ecx: Ecx<'_, '_, '_>) { | |
| }); | ||
| } | ||
|
|
||
| fn set_basefee(new_basefee: U256, ecx: Ecx<'_, '_, '_>) { | ||
|
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. okay, so i assume it's not possible to modify the value of 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. and do we have anyone who's up to date on gas mapping? 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. Not really |
||
| // Set basefee in EVM context. | ||
| ecx.block.basefee = new_basefee.try_into().expect("Basefee exceeds u64"); | ||
|
||
| } | ||
|
|
||
| /// Implements [CheatcodeInspectorStrategyRunner] for PVM. | ||
| #[derive(Debug, Default, Clone)] | ||
| pub struct PvmCheatcodeInspectorStrategyRunner; | ||
|
|
@@ -246,6 +254,14 @@ impl CheatcodeInspectorStrategyRunner for PvmCheatcodeInspectorStrategyRunner { | |
|
|
||
| Ok(Default::default()) | ||
| } | ||
| t if using_pvm && is::<feeCall>(t) => { | ||
| let &feeCall { newBasefee } = cheatcode.as_any().downcast_ref().unwrap(); | ||
|
|
||
| tracing::info!(cheatcode = ?cheatcode.as_debug() , using_pvm = ?using_pvm); | ||
| set_basefee(newBasefee, ccx.ecx); | ||
|
|
||
| Ok(Default::default()) | ||
| } | ||
| // Not custom, just invoke the default behavior | ||
| _ => cheatcode.dyn_apply(ccx, executor), | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try calling
block.basefeefrom a contract that's deployed on pvm sideThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some more tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the pallet-revive's basefee opcode implementation doesn't read from the effective_gas_price, but has a hardcoded default value of 1 gwei.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fill out an issue on foundry-polkadot to implement the functionality for pallet-revive/foundry-polkadot
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the ticket with a comment and created this issue related to the default value of BASEFEE opcode