Skip to content
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

refactor(plugins/execute): Refactor account refunds logic #1204

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

marioevz
Copy link
Member

🗒️ Description

Makes the following changes to help the refund logic complete in case of a failure during fixture setup:

Move Refund Logic to pre fixture

Previously the sender refund logic was placed in the base_test_parametrizer function, which is responsible for setting up the state_test, blockchain_test, etc, fixtures that are used in tests to actually generate the test.

The problem was that this fixture is not guaranteed to be the first fixture prepared during the pytest routine, so it could be that we had a fixture order preparation of:

pre -> sender -> blockchain_test

If an error occurred during the sender fixture setup, which potentially used pre fixture to fund a sender account, the refund logic would not be reached because the setup failed before reaching blockchain_test

The fix in this case is to put all the refund logic right in the pre fixture, and that way we can make sure that there is no potential fixture setup between the pre and the blockchain_test that could make the refund logic not take place.

Deprecate --sender-funding-txs-gas-price in favor of a single --default-gas-price

Use the same value as --default-gas-price instead of having two separate parameters for each use.

This is done in order to have a better estimation on replacement transactions.

Use A Replacement Transaction For Refunds

In the case of refunds, we now use a replacement transaction because it was difficult to estimate the real remaining balance of the sender account if there was a pending transaction in the mempool, so now we simply reuse the nonce to replace any transaction still present in the mempool.

Handle eth_getTransactionByHash Returning null

Handles the case where the transaction could not be found by the client and a null (None) response is returned.

🔗 Related Issues

None

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@marioevz marioevz added type:bug Something isn't working scope:pytest Scope: Changes EEST's pytest plugins type:refactor Type: Refactor scope:execute Scope: Changes to the execute command labels Feb 11, 2025
@marioevz marioevz changed the title refactor(plugins/execute): Refactor fixture logic refactor(plugins/execute): Refactor account refunds logic Feb 13, 2025
@@ -104,7 +89,7 @@ def sender_key_initial_balance(
assert seed_sender_balance_per_worker > 100, "Seed sender balance too low"
# Subtract the cost of the transaction that is going to be sent to the seed sender
sender_key_initial_balance = seed_sender_balance_per_worker - (
sender_fund_refund_gas_limit * sender_funding_transactions_gas_price
sender_fund_refund_gas_limit * default_gas_price
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sender_funding_transactions_gas_price I think that we should keep previous logic for supporting passing the price funding, the only change only need to pump refunding gas price from funding gas price ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned the parameter, but it now defaults to the same value as --default-gas-price, and we still bump the gas price for the refunds.

@marioevz marioevz force-pushed the execute-refund-refactor branch from 313abf6 to 574c060 Compare February 19, 2025 17:31
@marioevz marioevz requested a review from spencer-tb February 19, 2025 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:execute Scope: Changes to the execute command scope:pytest Scope: Changes EEST's pytest plugins type:bug Something isn't working type:refactor Type: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants