-
Notifications
You must be signed in to change notification settings - Fork 7
Skip auto-funding for accounts that were explicitly dealt #496
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
Skip auto-funding for accounts that were explicitly dealt #496
Conversation
|
Can you add a repro test case? |
Added testcase for this |
|
what is going to happen when vm.deal was executed exclusively within foundry side? |
| /// their balance is 0. This is intentional - vm.deal() is an explicit user action that | ||
| /// should be respected, while internal contract creations should still get auto-funding. | ||
| pub(crate) fn fund_pranked_accounts(&self, account: Address) { | ||
| // Fuzzed prank addresses have no balance, so they won't exist in revive, and |
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.
how does it work in REVM if prank addresses do not have any balance?
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.
It works, in REVM they don't need balance to execute
Balance changes don't sync back when executed in pallet-revive, it's a different issue though, we can look separately into this |
they do. ie but i digress, it can be changed in other PR. |
…github.com/paritytech/foundry-polkadot into filip/fund-pranked-accounts-dealt-tracking
|
hint from Claude AI, I did not check it in details but is worth to consider, I think: |
| pub mocked_calls: HashMap<Address, BTreeMap<MockCallDataContext, VecDeque<MockCallReturnData>>>, | ||
| pub mocked_functions: HashMap<Address, HashMap<Bytes, Address>>, | ||
| /// Records of accounts that were explicitly dealt to via vm.deal(). | ||
| pub eth_deals: Vec<DealRecord>, |
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.
why do we need this field if we can just pass it to fund_pranked_accounts?
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.
Addressed
|
|
||
| // Skip accounts that were explicitly dealt to via vm.deal() | ||
| if mock_inner.eth_deals.iter().any(|deal| deal.address == account) { | ||
| return; |
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.
maybe we should check if the balance aligns between foundry's REVM and pallet-revive and then align them if they are divergent in case of e.g vm.deal execution within a callback as it will not set the balance within pallet-revive but will be present in eth_deals.
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.
Also addressed, and we default to max if there is no deal
Should this be addressed in the scope of this PR? |
… directly instead of cloning
Fix fund_pranked_accounts overwriting dealt account balances.
Track accounts explicitly funded via vm.deal() and skip auto-funding them in fund_pranked_accounts. Previously, pranking an account that had spent its balance to zero would incorrectly set it to u128::MAX, breaking balance assertions in tests.