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

fix: bundler gets bundler surcharge if all solvers fail #437

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/solady
Submodule solady updated 46 files
+0 −1,310 .gas-snapshot
+0 −1 .github/pull_request_template.md
+11 −10 .github/workflows/ci-all-via-ir.yml
+77 −16 .github/workflows/ci.yml
+3 −0 .gitignore
+5 −1 README.md
+1 −1 foundry.toml
+1 −1 package.json
+58 −0 prep/gen-globalized-libs.js
+3 −0 src/Milady.sol
+166 −0 src/accounts/Pod.sol
+292 −0 src/auth/EnumerableRoles.sol
+152 −39 src/tokens/ERC20.sol
+986 −0 src/utils/DynamicArrayLib.sol
+410 −74 src/utils/DynamicBufferLib.sol
+103 −2 src/utils/EnumerableSetLib.sol
+156 −40 src/utils/LibClone.sol
+12 −12 src/utils/LibRLP.sol
+116 −6 src/utils/LibSort.sol
+350 −355 src/utils/LibString.sol
+3 −3 src/utils/SSTORE2.sol
+990 −0 src/utils/g/DynamicArrayLib.sol
+1,317 −0 src/utils/g/DynamicBufferLib.sol
+739 −0 src/utils/g/EnumerableSetLib.sol
+819 −0 src/utils/g/JSONParserLib.sol
+240 −0 src/utils/g/LibBitmap.sol
+318 −0 src/utils/g/LibMap.sol
+505 −0 src/utils/g/LibPRNG.sol
+387 −0 src/utils/g/LibRLP.sol
+572 −0 src/utils/g/MinHeapLib.sol
+721 −0 src/utils/g/RedBlackTreeLib.sol
+592 −0 test/DynamicArrayLib.t.sol
+27 −14 test/DynamicBufferLib.t.sol
+80 −0 test/ERC20.t.sol
+304 −0 test/EnumerableRoles.t.sol
+140 −0 test/EnumerableSetLib.t.sol
+88 −5 test/LibClone.t.sol
+8 −8 test/LibRLP.t.sol
+3 −0 test/LibSort.t.sol
+178 −0 test/LibString.t.sol
+149 −0 test/Pod.t.sol
+49 −0 test/utils/Brutalizer.sol
+32 −0 test/utils/TestPlus.sol
+16 −0 test/utils/mocks/MockERC20ForPermit2.sol
+67 −0 test/utils/mocks/MockEnumerableRoles.sol
+36 −0 test/utils/mocks/MockPod.sol
11 changes: 9 additions & 2 deletions src/contracts/atlas/GasAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,13 @@ abstract contract GasAccounting is SafetyLocks {
S_cumulativeSurcharge = _surcharge + netAtlasGasSurcharge;
} else {
// If no successful solvers, only collect partial surcharges from solver's fault failures (if any)
netAtlasGasSurcharge = solverSurcharge();
if (netAtlasGasSurcharge > 0) S_cumulativeSurcharge = _surcharge + netAtlasGasSurcharge;
uint256 _solverSurcharge = solverSurcharge();
if (_solverSurcharge > 0) {
// NOTE: This only works when BUNDLER_SURCHARGE > ATLAS_SURCHARGE.
netAtlasGasSurcharge = _solverSurcharge.getAtlasPortionFromTotalSurcharge();
adjustedWithdrawals += netAtlasGasSurcharge;
S_cumulativeSurcharge = _surcharge + netAtlasGasSurcharge;
}
return (adjustedWithdrawals, adjustedDeposits, adjustedClaims, adjustedWriteoffs, netAtlasGasSurcharge);
}

Expand Down Expand Up @@ -430,6 +435,8 @@ abstract contract GasAccounting is SafetyLocks {
if (ctx.solverSuccessful && _winningSolver != ctx.bundler) {
_amountSolverPays += _adjustedClaims;
claimsPaidToBundler = _adjustedClaims;
} else if (_winningSolver == ctx.bundler) {
claimsPaidToBundler = 0;
} else {
claimsPaidToBundler = 0;
_winningSolver = ctx.bundler;
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/libraries/AccountingMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ library AccountingMath {
surcharge = amount * _ATLAS_SURCHARGE_RATE / _SCALE;
}

function getAtlasPortionFromTotalSurcharge(uint256 totalSurcharge) internal pure returns (uint256 atlasSurcharge) {
atlasSurcharge = totalSurcharge * _ATLAS_SURCHARGE_RATE / (_ATLAS_SURCHARGE_RATE + _BUNDLER_SURCHARGE_RATE);
}

function solverGasLimitScaledDown(
uint256 solverOpGasLimit,
uint256 dConfigGasLimit
Expand Down
Loading