Skip to content

Commit

Permalink
feat: bump overhead when sending to zkSync chains (#5103)
Browse files Browse the repository at this point in the history
### Description

Context:
https://discord.com/channels/935678348330434570/1319115367167033399/1319442102454849639

zkSync chains have non standard EVM gas metering, and their
eth_estimateGas RPC returns abnormally high estimates compared to the
actual usage. As a semi-temporary workaround, we bump the overhead to
result in more gas paid for. The impact of this is actually not
meaningful when it comes to cost borne by users - because the zkSync
chains are cheap, our min fee logic means that applying this still
results in a ~20c cost to users

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
  • Loading branch information
tkporter authored Jan 3, 2025
1 parent d35502f commit 99c91d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions typescript/infra/config/environments/mainnet3/igp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ChainMap,
ChainName,
ChainTechnicalStack,
HookType,
IgpConfig,
getTokenExchangeRateFromValues,
Expand All @@ -14,6 +15,7 @@ import {
getOverhead,
} from '../../../src/config/gas-oracle.js';
import { mustGetChainNativeToken } from '../../../src/utils/utils.js';
import { getChain } from '../../registry.js';

import { ethereumChainNames } from './chains.js';
import gasPrices from './gasPrices.json';
Expand All @@ -25,9 +27,15 @@ const tokenPrices: ChainMap<string> = rawTokenPrices;

export function getOverheadWithOverrides(local: ChainName, remote: ChainName) {
let overhead = getOverhead(local, remote, ethereumChainNames);
// Moonbeam gas usage can be up to 4x higher than vanilla EVM
if (remote === 'moonbeam') {
overhead *= 4;
}
// ZkSync gas usage is different from the EVM and tends to give high
// estimates. We double the overhead to help account for this.
if (getChain(remote).technicalStack === ChainTechnicalStack.ZkSync) {
overhead *= 2;
}
return overhead;
}

Expand Down

0 comments on commit 99c91d8

Please sign in to comment.