Skip to content

Commit

Permalink
fix(pg): Bump Merkle leaf gas values on networks other than Rootstock
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Apr 11, 2024
1 parent 28bc6ce commit cc5e9e6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .changeset/fresh-timers-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sphinx-labs/contracts': patch
'@sphinx-labs/plugins': patch
'@sphinx-labs/core': patch
---

Bump Merkle leaf gas values on networks other than Rootstock
14 changes: 10 additions & 4 deletions packages/contracts/contracts/foundry/SphinxUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1170,10 +1170,16 @@ contract SphinxUtils is SphinxConstants {
// impact the Merkle leaf gas fields because we use `vm.snapshot`/`vm.revertTo`. Also,
// state changes on one fork do not impact the gas cost on other forks.
//
// We chose to multiply the gas by 1.1 because multiplying it by a higher number could
// make a very large transaction unexecutable on-chain. Since the 1.1x multiplier
// doesn't impact small transactions very much, we add a constant amount of 60k too.
gasEstimates[i] = 60_000 + ((startGas - finalGas) * 11) / 10;
// We chose to multiply the gas by 10-20% because multiplying it by a higher number
// could make a very large transaction unexecutable on-chain. Since this multiplier
// doesn't impact small transactions very much, we add a constant amount too. We use
// smaller buffers on Rootstock because gas costs are slightly lower on these networks
// compared to the EVM. Also, the block gas limit is significantly lower on Rootstock.
if (_deploymentInfo.chainId == 30 || _deploymentInfo.chainId == 31) {
gasEstimates[i] = 60_000 + ((startGas - finalGas) * 11) / 10;
} else {
gasEstimates[i] = 120_000 + ((startGas - finalGas) * 12) / 10;
}
}

vm.stopPrank();
Expand Down
80 changes: 61 additions & 19 deletions packages/contracts/test/SphinxInitCode.sol

Large diffs are not rendered by default.

0 comments on commit cc5e9e6

Please sign in to comment.