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

feat: manage blob operator key via zk stack command #1769

Merged
merged 5 commits into from Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions infrastructure/zk/src/hyperchain_wizard.ts
Expand Up @@ -123,7 +123,7 @@ async function setHyperchainMetadata(runObservability: boolean) {
const results: any = await enquirer.prompt(questions);
// TODO(EVM-574): add random chainId generation here if user does not want to pick chainId.

let deployer, governor, ethOperator, feeReceiver: ethers.Wallet | undefined;
let deployer, governor, ethOperator, blobOperator, feeReceiver: ethers.Wallet | undefined;
let feeReceiverAddress, l1Rpc, l1Id, databaseUrl, databaseProverUrl;

if (results.l1Chain !== BaseNetwork.LOCALHOST || results.l1Chain !== BaseNetwork.LOCALHOST_CUSTOM) {
Expand Down Expand Up @@ -196,6 +196,7 @@ async function setHyperchainMetadata(runObservability: boolean) {
governor = ethers.Wallet.createRandom();
ethOperator = ethers.Wallet.createRandom();
feeReceiver = ethers.Wallet.createRandom();
blobOperator = ethers.Wallet.createRandom();
feeReceiverAddress = feeReceiver.address;
} else {
console.log(warning('The private keys for these wallets must be different from each other!\n'));
Expand All @@ -218,6 +219,12 @@ async function setHyperchainMetadata(runObservability: boolean) {
type: 'password',
required: true
},
{
message: 'Private key of the L1 blob Operator (the one that pays for blobs)',
name: 'blobOperator',
type: 'password',
required: true
},
{
message: 'Address of L2 fee receiver (the one that collects fees)',
name: 'feeReceiver',
Expand Down Expand Up @@ -246,6 +253,12 @@ async function setHyperchainMetadata(runObservability: boolean) {
throw Error(error('ETH Operator private key is invalid'));
}

try {
blobOperator = new ethers.Wallet(keyResults.blobOperator);
} catch (e) {
throw Error(error('Blob Operator private key is invalid'));
}

if (!utils.isAddress(keyResults.feeReceiver)) {
throw Error(error('Fee Receiver address is not a valid address'));
}
Expand Down Expand Up @@ -278,8 +291,9 @@ async function setHyperchainMetadata(runObservability: boolean) {
deployer = new ethers.Wallet(richWallets[0].privateKey);
governor = new ethers.Wallet(richWallets[1].privateKey);
ethOperator = new ethers.Wallet(richWallets[2].privateKey);
blobOperator = new ethers.Wallet(richWallets[3].privateKey);
feeReceiver = undefined;
feeReceiverAddress = richWallets[3].address;
feeReceiverAddress = richWallets[4].address;

await up(runObservability);
await announced('Ensuring databases are up', db.wait({ core: true, prover: false }));
Expand All @@ -290,6 +304,7 @@ async function setHyperchainMetadata(runObservability: boolean) {
printAddressInfo('Deployer', deployer.address);
printAddressInfo('Governor', governor.address);
printAddressInfo('ETH Operator', ethOperator.address);
printAddressInfo('Blob Operator', blobOperator.address);
printAddressInfo('Fee receiver', feeReceiverAddress);

console.log(
Expand Down Expand Up @@ -351,6 +366,8 @@ async function setHyperchainMetadata(runObservability: boolean) {
env.modify('CHAIN_ETH_ZKSYNC_NETWORK_ID', results.chainId, process.env.ENV_FILE!);
env.modify('ETH_SENDER_SENDER_OPERATOR_PRIVATE_KEY', ethOperator.privateKey, process.env.ENV_FILE!);
env.modify('ETH_SENDER_SENDER_OPERATOR_COMMIT_ETH_ADDR', ethOperator.address, process.env.ENV_FILE!);
env.modify('ETH_SENDER_SENDER_OPERATOR_BLOBS_PRIVATE_KEY', blobOperator.privateKey, process.env.ENV_FILE!);
env.modify('ETH_SENDER_SENDER_OPERATOR_BLOBS_ETH_ADDR', blobOperator.address, process.env.ENV_FILE!);
env.modify('DEPLOYER_PRIVATE_KEY', deployer.privateKey, process.env.ENV_FILE!);
env.modify('GOVERNOR_PRIVATE_KEY', governor.privateKey, process.env.ENV_FILE!);
env.modify('GOVERNOR_ADDRESS', governor.address, process.env.ENV_FILE!);
Expand Down