You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the new hook based approach, Protorev now stores swaps to backrun in state when triggered by GAMM and Concentrated Liquidity pool after swap hooks:
The issue is that the upperGasLimitMeter used to delete the swaps to backrun from store on the real ctx is the same upperGasLimitMeter used in the cachectx to perform the rebalancing logic. So, if within the rebalancing logic the upperGasLimitMeter is depleted, the call to DeleteSwapsToBackrun will fail with an out of gas error, resulting in a failed transaction for the user.
Suggested Design
Use an sdk.NewInfiniteGasMeter in the DeleteSwapsToBackrun call so that it never has the chance to run out of gas and fail the user's transaction. Using an infinite gas meter here should be safe as there is no looping logic within the DeleteSwapsToBackrun and the most number of swaps that is allowed to be stored in state in this kv store would be # of swaps the user took + # of swaps protorev performed to backrun.
Alternatively, instead of using an infinite gas meter, we could use a new large gas meter (if using an infinite gas meter is unacceptable)
Acceptance Criteria
Add and pass a test that depletes the gas meter used in the cachectx where protorev performs the rebalancing logic, while still successfully deleting the swaps from the kvstores and not failing the user's transaction.
The text was updated successfully, but these errors were encountered:
Background
osmosis/x/protorev/keeper/hooks.go
Line 56 in b7fe65f
osmosis/x/protorev/keeper/hooks.go
Line 83 in b7fe65f
osmosis/x/protorev/keeper/posthandler.go
Line 66 in b7fe65f
upperGasLimitMeter
used to delete the swaps to backrun from store on the realctx
is the sameupperGasLimitMeter
used in thecachectx
to perform the rebalancing logic. So, if within the rebalancing logic theupperGasLimitMeter
is depleted, the call toDeleteSwapsToBackrun
will fail with an out of gas error, resulting in a failed transaction for the user.Suggested Design
sdk.NewInfiniteGasMeter
in theDeleteSwapsToBackrun
call so that it never has the chance to run out of gas and fail the user's transaction. Using an infinite gas meter here should be safe as there is no looping logic within theDeleteSwapsToBackrun
and the most number of swaps that is allowed to be stored in state in this kv store would be# of swaps the user took + # of swaps protorev performed to backrun
.Acceptance Criteria
The text was updated successfully, but these errors were encountered: