Skip to content

Commit

Permalink
set fee params for ethereum
Browse files Browse the repository at this point in the history
  • Loading branch information
zkbenny committed Feb 6, 2024
1 parent e5e2ff9 commit f57f42b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/scroll/scripts/4_setValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions script/deploy_arbitrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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`);
});
28 changes: 28 additions & 0 deletions script/zksync_era.js
Original file line number Diff line number Diff line change
@@ -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,
};

0 comments on commit f57f42b

Please sign in to comment.