Skip to content

Commit

Permalink
fix(pg): set max block gas limit in Forge script during collection
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Feb 10, 2024
1 parent 4db89dd commit e1445ae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/twelve-baboons-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sphinx-labs/plugins': patch
'@sphinx-labs/core': patch
---

Set max block gas limit in Forge script during collection
2 changes: 2 additions & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ export enum ExecutionMode {
LiveNetworkCLI,
Platform,
}

export const MAX_UINT64 = BigInt(2) ** BigInt(64) - BigInt(1)
9 changes: 8 additions & 1 deletion packages/plugins/src/cli/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
fetchChainIdForNetwork,
writeDeploymentArtifacts,
isLegacyTransactionsRequiredForNetwork,
MAX_UINT64,
} from '@sphinx-labs/core'
import { red } from 'chalk'
import ora from 'ora'
Expand Down Expand Up @@ -189,7 +190,13 @@ export const deploy = async (
}

// Collect the transactions.
const spawnOutput = await spawnAsync('forge', forgeScriptCollectArgs)
const spawnOutput = await spawnAsync('forge', forgeScriptCollectArgs, {
// Set the block gas limit to the max amount allowed by Foundry. This overrides lower block
// gas limits specified in the user's `foundry.toml`, which can cause the script to run out of
// gas. We use the `FOUNDRY_BLOCK_GAS_LIMIT` environment variable because it has a higher
// priority than `DAPP_BLOCK_GAS_LIMIT`.
FOUNDRY_BLOCK_GAS_LIMIT: MAX_UINT64.toString(),
})

if (spawnOutput.code !== 0) {
spinner.stop()
Expand Down
9 changes: 8 additions & 1 deletion packages/plugins/src/cli/propose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
isLegacyTransactionsRequiredForNetwork,
SphinxJsonRpcProvider,
isFile,
MAX_UINT64,
} from '@sphinx-labs/core'
import ora from 'ora'
import { blue, red } from 'chalk'
Expand Down Expand Up @@ -131,7 +132,13 @@ export const buildParsedConfigArray: BuildParsedConfigArray = async (
}

// Collect the transactions for the current network.
const spawnOutput = await spawnAsync('forge', forgeScriptCollectArgs)
const spawnOutput = await spawnAsync('forge', forgeScriptCollectArgs, {
// Set the block gas limit to the max amount allowed by Foundry. This overrides lower block
// gas limits specified in the user's `foundry.toml`, which can cause the script to run out of
// gas. We use the `FOUNDRY_BLOCK_GAS_LIMIT` environment variable because it has a higher
// priority than `DAPP_BLOCK_GAS_LIMIT`.
FOUNDRY_BLOCK_GAS_LIMIT: MAX_UINT64.toString(),
})

if (spawnOutput.code !== 0) {
spinner?.stop()
Expand Down

0 comments on commit e1445ae

Please sign in to comment.