feat: add native gas pre-flight check and update unit tests#243
Open
DanFrolov wants to merge 1 commit intoOpenGradient:mainfrom
Open
feat: add native gas pre-flight check and update unit tests#243DanFrolov wants to merge 1 commit intoOpenGradient:mainfrom
DanFrolov wants to merge 1 commit intoOpenGradient:mainfrom
Conversation
Collaborator
|
We'll be using OPG as the gas token soon -- so this may not be useful |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a "fail-fast" gas pre-flight check within the
ensure_opg_approvalprocess. Currently, if a user has sufficient OPG tokens but lacks native ETH (Base Sepolia) for gas, the transaction fails late with a generic RPC error from the node.This change ensures that we validate the user's native balance before building or signing the transaction, providing a much clearer error message and saving unnecessary computation.
Key Changes
approvecall and applies a 20% limit buffer to ensure the transaction doesn't run out of gas.native_balanceagainst thetotal_cost(gas limit * gas price), including a 10% safety buffer to account for potential gas price volatility.RuntimeErrorthat includes:Web3.from_wei).tests/opg_token_test.pyto:build_transactionmocks to satisfyeth-accountsigning requirements.Testing Performed
RuntimeErroris raised when the mock balance is0.11 passed, 3 warnings in 3.42s.