[Deployment] zkSync era testnet randomly gives not enough gas to publish compressed bytecodes
#550
-
EnvironmentTestnet zkSolc Version1.4.1 zksync-ethers Version6.7.0 Hardhat.config.tsimport { HardhatUserConfig } from "hardhat/config"
import "@matterlabs/hardhat-zksync-node"
import "@matterlabs/hardhat-zksync-deploy"
import "@matterlabs/hardhat-zksync-solc"
import "@matterlabs/hardhat-zksync-verify"
import "@nomicfoundation/hardhat-toolbox"
const config: HardhatUserConfig = {
networks: {
zkSyncSepoliaTestnet: {
url: process.env.ZKSYNC_SEPOLIA_RPC_URL!,
ethNetwork: "sepolia",
zksync: true,
verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification",
accounts: [process.env.ZKSYNC_SEPOLIA_KEY!],
},
zkSyncMainnet: {
url: process.env.ZKSYNC_RPC_URL!,
ethNetwork: "mainnet",
zksync: true,
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
accounts: [process.env.ZKSYNC_KEY!],
},
zkSyncGoerliTestnet: { // deprecated network
url: "https://testnet.era.zksync.dev",
ethNetwork: "goerli",
zksync: true,
verifyURL: "https://zksync2-testnet-explorer.zksync.dev/contract_verification",
},
dockerizedNode: {
url: "http://localhost:3050",
ethNetwork: "http://localhost:8545",
zksync: true,
},
inMemoryNode: {
url: "http://127.0.0.1:8011",
ethNetwork: "localhost", // in-memory node doesn't support eth node; removing this line will cause an error
zksync: true,
},
hardhat: {
zksync: true,
},
},
zksolc: {
version: "latest",
settings: {
// find all available options in the official documentation
// https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-solc.html#configuration
},
},
solidity: {
version: "0.8.24",
},
}
export default config Deployment Script (WITHOUT PRIVATE KEY)import { deployContract, DeployContractOptions, getWallet } from "./utils"
import * as zk from 'zksync-ethers'
export default async function deploy(): Promise<zk.Contract> {
const result = await deploySecurityRegistry()
return result
}
export async function deploySecurityRegistry(): Promise<zk.Contract> {
let wallet = getWallet()
let deployOptions: DeployContractOptions | undefined = { wallet: wallet }
/*//////////////////////////////////////////////////////////////
Registry
//////////////////////////////////////////////////////////////*/
const securityCourseRegistry: string = "CyfrinSecurityCourseNft"
const securityCourseArgs: string[] = []
// This will also verify
const securityCourseContract = await deployContract(securityCourseRegistry, securityCourseArgs, deployOptions)
const securityCourseAddress = await securityCourseContract.getAddress()
console.log(`Deployed registry contract to: ${securityCourseAddress}`)
return securityCourseContract
}
Contract Code// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {CTFRegistry} from "ctf/src/protocol/CTFRegistry.sol";
contract CyfrinSecurityCourseNft is CTFRegistry {
constructor() CTFRegistry("Cyfrin Security Course NFT", "CSCN") {}
} Does this work on other EVMs? (If yes, please list at least 1 of them)Yes. Arbitrum. Description of What Your Contract DoesIt allows people to mint NFTs after solving solidity challenges Repo Link (Optional)No response Additional DetailsSo, typically, I don't recommend "just keep trying it again until it works", but that's what ended up solving this. I had gotten this to work on another similar script in the past by "just trying it again" and after like 6 tries of changing absolutely nothing this script ended up working and the code deployed successfully. Have others had issues where they get an error like this?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This might be due to not being able to fit in the block and by trying until it works if finally got all into a block. Will double check to see if that's the case |
Beta Was this translation helpful? Give feedback.
-
TL;DR - this was probably caused by sepolia's (L1) blob price spike. Longer description: ZKsync is a rollup, so our users have to pay a fee for pubdata that is then sent to L1. As L1 price (to be exact blob price) can be volatile, we model this volatility by changing the amount of gas that the L2 transaction has to pay when writing a byte to storage (or for example publishing the bytecode). We rolled out the feature last week to To show this on a concrete example:
... This means that the the users pay 4'736'052'432 L1 wei per byte (so 4.7 Gwei). As the L2 gas price is 25'000'000 wei (0.025 Gwei) - this means that they pay 4.7 / 0.025 = 188 gas per byte published. So what probably happened in your case, was a spike in this 'gas per byte' - which caused your transaction to run out of gas. |
Beta Was this translation helpful? Give feedback.
TL;DR - this was probably caused by sepolia's (L1) blob price spike.
(@bxpana - we should add also a field (next to environment), where user can mention the current block height - would help with explaining issues like this).
Longer description:
ZKsync is a rollup, so our users have to pay a fee for pubdata that is then sent to L1. As L1 price (to be exact blob price) can be volatile, we model this volatility by changing the amount of gas that the L2 transaction has to pay when writing a byte to storage (or for example publishing the bytecode).
We rolled out the feature last week to
zks_getBlockDetails
that returns the current cost of pubdata publishing.To show this on a concrete example: