add external transient_storage to pallet_revive::ExecConfig#10493
add external transient_storage to pallet_revive::ExecConfig#10493
Conversation
|
/cmd prdoc |
|
haven't revivewed yet, but can you merge and use torsten/gas-fixes as the base branch, as it's a huge refactoring that should land today or tomorrow |
4a8682a to
1908c2d
Compare
1908c2d to
9869425
Compare
|
/cmd fmt |
Differential Tests Results (PolkaVM)Specified Tests
Counts
FailuresThe test specifiers seen in this section have the format 'path::case_idx::compilation_mode' and they're compatible with the revive differential tests framework and can be specified to it directly in the same way that they're provided through the The failures are provided in an expandable section to ensure that the PR does not get polluted with information. Please click on the section below for more information Detailed Differential Tests Failure Information
|
Differential Tests Results (REVM)Specified Tests
Counts
FailuresThe test specifiers seen in this section have the format 'path::case_idx::compilation_mode' and they're compatible with the revive differential tests framework and can be specified to it directly in the same way that they're provided through the The failures are provided in an expandable section to ensure that the PR does not get polluted with information. Please click on the section below for more information Detailed Differential Tests Failure Information
|
25ebc2e to
d9f4b93
Compare
|
/cmd fmt |
athei
left a comment
There was a problem hiding this comment.
Please also remove all the unrelated semicolon changes.
| pub mock_handler: Option<Box<dyn MockHandler<T>>>, | ||
| /// external transient storage useful for testing. should be `None` in production | ||
| /// environments. | ||
| pub transient_storage: Option<Rc<RefCell<TransientStorage<T>>>>, |
There was a problem hiding this comment.
Move into the Stack using take() when the Stack is created.
| pub transient_storage: Option<Rc<RefCell<TransientStorage<T>>>>, | |
| pub initial_transient_storage: Option<TransientStorage<T>>>, |
There was a problem hiding this comment.
we still need to have it back in foundry, so moving into into the stack will not allow us to get the instance back
There was a problem hiding this comment.
Ahh okay got it. But is the Rc needed? The calling code (foundry) owns TransientStorage and can just borrow when it wants to access it.
There was a problem hiding this comment.
I didn't want to introduce lifetimes and possible refactor parts of the interface to avoid an RC. Rc is needed because ownership of ExecConfig goes directly to pallet-revive from the caller so it's a one way trip unless we return parts of ExecConfig at the end of the call if requested.
There was a problem hiding this comment.
Rcis needed because ownership ofExecConfiggoes directly to pallet-revive
Ahh okay. I thought it takes a reference. It should not take exec_config by value. This makes no sense as it is just forwarded as reference to Stack. So this should be refactored to get rid of the Rc.
There was a problem hiding this comment.
No new life times. Just changing the signature of the bare_* calls to take ExecConfig by reference instead of value. This will not require any new explicit life time.
There was a problem hiding this comment.
we cannot pass TransientStorage by reference inside ExecConfig without a lifetime, no? so this would cause us to add lifetime param to every callsite of ExecConfig and to its definition.
Anyways, i'll try and see whether the lifetimes would line up inside exec with it
There was a problem hiding this comment.
we cannot pass TransientStorage by reference inside ExecConfig without a lifetime, no?
I am not asking you to do this. Pass ExecConfig as reference into bare_*. The TransientStorage is passed as RefCell<TransientStorage>.
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
|
/cmd fmt |
|
I think the |
updated |
| self | ||
| } | ||
|
|
||
| pub fn set_enable_pvm_logs(mut self, value: bool) -> Self { |
There was a problem hiding this comment.
yes, it's just replicating the same DebugSettings as we had before the changes to the DebugSettings interface
There was a problem hiding this comment.
can you explain the changes here, these macro are becoming complex and hard to review without more context
There was a problem hiding this comment.
ah I see false mean to not generate the build fn
prdoc/pr_10493.prdoc
Outdated
| This is required by testing in foundry as we only enter `pallet_revive` during a `CALL` or `CREATE` instruction and we need to carryover | ||
| the transient storage to other following calls as they happen within an external tx |
There was a problem hiding this comment.
can you provide an example here and link to usage example, it's not clear to me why / how it's used
There was a problem hiding this comment.
link/example here on in the block comment?
There was a problem hiding this comment.
added example in the prdoc
There was a problem hiding this comment.
you mind updating the PR desc as well it's nicer to read from there
| }; | ||
| // Generate the builder struct and its methods. | ||
| ( | ||
| true, |
There was a problem hiding this comment.
use something more explicit than false/true (e.g with_generate_build_fn, without_generate_build_fn)
There was a problem hiding this comment.
or maybe something like this would be more ergonomic
// Auto-generates build()
builder!(
call(...) -> ...;
pub fn call(...) -> Self { ... }
);
// Manual - you provide build()
builder!(
@no_build_fn,
bare_call(...) -> ...;
pub fn build(self) -> ... { ... }
pub fn bare_call(...) -> Self { ... }
);
There was a problem hiding this comment.
changed to without_build_fn
| ```solidity | ||
| fn example_test() { // this entrypoint is executed on the side of `foundry-polkadot` | ||
| Example contract = new Example(); // happens on pallet-revive | ||
| contract.setTransientStorage(5); // happens on pallet-revive | ||
|
|
||
| uint256 result = contract.getTransientStorage(); // happens on pallet-revive and returns `0` aka the default value | ||
| // `result` above is `0` because `transient_storage` is reset after every call to `pallet-revive` and in `foundry-polkadot` | ||
| // only `CALL` and `CREATE` within function calls(already executed on foundry's revm) are forwarded to `pallet-revive`, | ||
| // so for assertion below to pass we would need to have our external `transient_storage` instance to be manually supplied | ||
| // to pallet-revive and be persistent within the wrapping call | ||
| assertEq(5, result); // fails without this PR with `5 != 0` | ||
| } |
There was a problem hiding this comment.
a link to polkadot-foundry for that kind of test would be useful as well
Description
This PR adds the ability to supply external copy of
TransientStoragetopallet_revive::ExecConfigto be used during execution. This is required by testing in foundry as we only enterpallet_reviveduring aCALLorCREATEinstruction and we need to carryover the transient storage to other following calls as they happen within an external tx. For example this is required to support more testing scenarious insidefoundry-polkadotbecause only a subset of execution happens onpallet-revive.e.g:
link for the test-file inside
foundry-polkadot:Integration
Already being used on a branch of foundry-polkadot
Review Notes
I'm not so fond ofRc<RefCell<TransientStorage>>approach and using a function to decide to which transient storage to dispatch to during execution, so any suggestions would be welcome.changed to plain
RefCell<TransientStorage>as per suggestion from @athei