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(contracts): ensure gasPrice has sufficient value #1703

Merged
merged 1 commit into from
Jul 27, 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
13 changes: 4 additions & 9 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import type { HardhatUserConfig } from "hardhat/config";

// Don't forget to import new tasks here
import "./tasks/deploy";
import {
EChainId,
ESupportedChains,
NETWORKS_DEFAULT_GAS,
getEtherscanApiKeys,
getNetworkRpcUrls,
} from "./tasks/helpers/constants";
import { EChainId, ESupportedChains, getEtherscanApiKeys, getNetworkRpcUrls } from "./tasks/helpers/constants";
import "./tasks/runner/deployFull";
import "./tasks/runner/deployPoll";
import "./tasks/runner/merge";
Expand All @@ -28,13 +22,14 @@ const DEFAULT_BLOCK_GAS_LIMIT = 30_000_000;
const DEFAULT_GAS_MUL = 2;
const TEST_MNEMONIC = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
const NETWORKS_RPC_URL = getNetworkRpcUrls();
const GAS_PRICE: number | "auto" = process.env.GAS_PRICE ? Number(process.env.GAS_PRICE) : "auto";
const ETHERSCAN_API_KEYS = getEtherscanApiKeys();

const getCommonNetworkConfig = (networkName: ESupportedChains, chainId: number, mnemonic?: string) => ({
url: NETWORKS_RPC_URL[networkName],
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: process.env.GAS_PRICE ? Number(process.env.GAS_PRICE) : NETWORKS_DEFAULT_GAS[networkName],
gasPrice: GAS_PRICE,
saveDeployments: true,
chainId,
accounts: {
Expand Down Expand Up @@ -72,7 +67,7 @@ const config: HardhatUserConfig = {
hardhat: {
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: NETWORKS_DEFAULT_GAS[ESupportedChains.Hardhat],
gasPrice: "auto",
chainId: EChainId.Hardhat,
accounts: {
mnemonic: TEST_MNEMONIC,
Expand Down
25 changes: 0 additions & 25 deletions contracts/tasks/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,8 @@ export enum EChainId {
Coverage = 1337,
}

const GWEI = 1e9;

export const STATE_TREE_ARITY = 5;

/**
* Convert gas price from gweguari to wei
*
* @param value - gas price in gwei
* @returns gas price in wei
*/
const gasPrice = (value: number) => value * GWEI;

/**
* Gas price settings for supported network
*/
export const NETWORKS_DEFAULT_GAS: Record<ESupportedChains, number | "auto"> = {
[ESupportedChains.Sepolia]: gasPrice(1),
[ESupportedChains.Optimism]: gasPrice(1),
[ESupportedChains.OptimismSepolia]: gasPrice(1),
[ESupportedChains.Scroll]: gasPrice(1),
[ESupportedChains.ScrollSepolia]: gasPrice(1),
[ESupportedChains.Coverage]: gasPrice(1),
[ESupportedChains.Hardhat]: gasPrice(1),
[ESupportedChains.Arbitrum]: gasPrice(1),
[ESupportedChains.ArbitrumSepolia]: gasPrice(1),
};

/**
* Get network rpc urls object
*
Expand Down
Loading