diff --git a/examples/scroll/scripts/4_setValidator.js b/examples/scroll/scripts/4_setValidator.js index 8509127..205a2fe 100644 --- a/examples/scroll/scripts/4_setValidator.js +++ b/examples/scroll/scripts/4_setValidator.js @@ -53,8 +53,9 @@ task('setValidator', 'Set validator for zkLink') let tx = await arbitrator.setValidator(scrollL1GatewayAddr, validatorAddr, isActive, adapterParams, { value: hre.ethers.utils.parseEther('0.001'), }); - console.log(`The tx hash: ${tx.hash}`); + console.log(`The tx hash: ${tx.hash} , waiting confirm...`); await tx.wait(); + console.log(`The tx confirmed`); // Waiting for the official Scroll bridge to forward the message to L2 // No user action is required for follow-up. diff --git a/script/deploy_arbitrator.js b/script/deploy_arbitrator.js index 61c8920..d1a4dd8 100644 --- a/script/deploy_arbitrator.js +++ b/script/deploy_arbitrator.js @@ -9,6 +9,7 @@ const { } = require('./utils'); const logName = require('./deploy_log_name'); const { task, types } = require('hardhat/config'); +const { INIT_FEE_PARAMS } = require('./zksync_era'); function getArbitratorContractName(dummy) { return dummy ? 'DummyArbitrator' : 'Arbitrator'; @@ -149,3 +150,25 @@ task('setValidatorForEthereum', 'Set validator for ethereum') await tx.wait(); console.log(`The tx confirmed`); }); + +task('setFeeParamsForEthereum', 'Set fee params for ethereum').setAction(async (taskArgs, hardhat) => { + const arbitratorAddr = readDeployContract(logName.DEPLOY_ARBITRATOR_LOG_PREFIX, logName.DEPLOY_LOG_ARBITRATOR); + if (arbitratorAddr === undefined) { + console.log('The arbitrator address not exist'); + return; + } + console.log(`The arbitrator address: ${arbitratorAddr}`); + + const ethGatewayAddr = readDeployContract(logName.DEPLOY_ETH_GATEWAY_LOG_PREFIX, logName.DEPLOY_GATEWAY); + if (ethGatewayAddr === undefined) { + console.log('The eth gateway address not exist'); + return; + } + console.log(`The eth gateway address: ${ethGatewayAddr}`); + + const arbitrator = await hardhat.ethers.getContractAt('Arbitrator', arbitratorAddr); + let tx = await arbitrator.changeFeeParams(ethGatewayAddr, INIT_FEE_PARAMS, '0x'); + console.log(`The tx hash: ${tx.hash} , waiting confirm...`); + await tx.wait(); + console.log(`The tx confirmed`); +}); diff --git a/script/zksync_era.js b/script/zksync_era.js new file mode 100644 index 0000000..16b3c39 --- /dev/null +++ b/script/zksync_era.js @@ -0,0 +1,28 @@ +const ZKSYNC_HOME = process.env.ZKSYNC_HOME; +if (ZKSYNC_HOME === undefined) { + throw Error('ZKSYNC_HOME not config'); +} + +const SYSTEM_CONFIG_JSON = require(`${ZKSYNC_HOME}/contracts/SystemConfig.json`); + +const SYSTEM_CONFIG = { + requiredL2GasPricePerPubdata: SYSTEM_CONFIG_JSON.REQUIRED_L2_GAS_PRICE_PER_PUBDATA, + priorityTxMinimalGasPrice: SYSTEM_CONFIG_JSON.PRIORITY_TX_MINIMAL_GAS_PRICE, + priorityTxMaxGasPerBatch: SYSTEM_CONFIG_JSON.PRIORITY_TX_MAX_GAS_PER_BATCH, + priorityTxPubdataPerBatch: SYSTEM_CONFIG_JSON.PRIORITY_TX_PUBDATA_PER_BATCH, + priorityTxBatchOverheadL1Gas: SYSTEM_CONFIG_JSON.PRIORITY_TX_BATCH_OVERHEAD_L1_GAS, + priorityTxMaxPubdata: SYSTEM_CONFIG_JSON.PRIORITY_TX_MAX_PUBDATA, +}; + +const INIT_FEE_PARAMS = { + pubdataPricingMode: 0, // rollup + batchOverheadL1Gas: SYSTEM_CONFIG.priorityTxBatchOverheadL1Gas, + maxPubdataPerBatch: SYSTEM_CONFIG.priorityTxPubdataPerBatch, + priorityTxMaxPubdata: SYSTEM_CONFIG.priorityTxMaxPubdata, + maxL2GasPerBatch: SYSTEM_CONFIG.priorityTxMaxGasPerBatch, + minimalL2GasPrice: SYSTEM_CONFIG.priorityTxMinimalGasPrice, +}; + +module.exports = { + INIT_FEE_PARAMS, +};