-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit maxFeePerGas to reasonable value (#2352)
# Description We are seeing a bunch of simulation failures of seasolver on GnosisChain due to `InsufficientBalance`. Those only show up after their solution has been chosen as the winning one and is trying to settle, thus delaying settlements by one auction (or potentially more if their solver keeps winning). This stems from the fact that the current `required_balance` method, which we check during solution simulation, doesn't use the `maxFeePerGas` (which is 1000 gwei) but instead some multiple of the current base fee (<1 gwei on Gnosis Chain). However, the RPC node requires an account to have at least `gasLimit * maxFeePerGas` ETH of balance in order to accept its transaction. This would lead to a balance requirement of ~15xDAI on Gnosis Chain (many orders of magnitude more than is actually needed for a transaction). At the same time, EIP1559 specifies that the base fee can only grow by 12.5% per block. Therefore setting a `maxFeePerGas` very high unnecessarily restricts the balance required to execute a settlement within the expected time frame (2 blocks for the auction + 5 blocks max for inclusion). It was introduced in #2295 to simplify our logic. This PR somewhat reverts those changes by limiting the `maxFeePerGas` to a reasonable upper bound given the current base fee. # Changes <!-- List of detailed changes (how the change is accomplished) --> - [x] When creating a GasPrice take current base fee into account when computing `maxFeePerGas` - [x] Use `maxFeePerGas` in `required_balance` ## How to test Existing unit tests (will look into adding a test for the solver balance check)
- Loading branch information
Showing
9 changed files
with
100 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,46 @@ | ||
use crate::tests::{ | ||
setup, | ||
setup::{ab_order, ab_pool, ab_solution}, | ||
use crate::{ | ||
domain::eth, | ||
tests::{ | ||
setup, | ||
setup::{ab_order, ab_pool, ab_solution, test_solver}, | ||
}, | ||
}; | ||
|
||
/// Test that the `/solve` request errors when solver balance is too low. | ||
#[tokio::test] | ||
#[ignore] | ||
async fn test() { | ||
async fn test_unfunded() { | ||
let test = setup() | ||
.pool(ab_pool()) | ||
.order(ab_order()) | ||
.solution(ab_solution()) | ||
.defund_solvers() | ||
.solvers(vec![test_solver() | ||
.name("unfunded") | ||
.balance(eth::U256::zero())]) | ||
.done() | ||
.await; | ||
|
||
let solve = test.solve().await; | ||
|
||
let solve = test.solve_with_solver("unfunded").await; | ||
solve.ok().empty(); | ||
} | ||
|
||
/// Test that the `/solve` request succeeds when the solver has just enough | ||
/// funds | ||
#[tokio::test] | ||
#[ignore] | ||
async fn test_just_enough_funded() { | ||
let test = setup() | ||
.pool(ab_pool()) | ||
.order(ab_order()) | ||
.solution(ab_solution()) | ||
.solvers(vec![test_solver() | ||
.name("barely_funded") | ||
// The solution uses ~500k gas units | ||
// With gas costs <20gwei, 0.01 ETH should suffice | ||
.balance(eth::U256::exp10(16))]) | ||
.done() | ||
.await; | ||
|
||
test.solve_with_solver("barely_funded").await.ok(); | ||
test.settle_with_solver("barely_funded").await.ok().await; | ||
} |
This file contains 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
This file contains 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