From 4ba525a641cf04b828312128abcef6d3003b52e6 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:08:06 -0700 Subject: [PATCH 01/14] l3 config and setup script updated --- package.json | 2 +- scripts/l3Configuration.ts | 241 +++++++++++++++++++++++++------------ scripts/setup.ts | 2 +- yarn.lock | 21 +++- 4 files changed, 180 insertions(+), 86 deletions(-) diff --git a/package.json b/package.json index 08aac72..0691e0d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "orbit-setup-script", "dependencies": { "@arbitrum/nitro-contracts": "^1.1.1", - "@arbitrum/orbit-sdk": "^0.8.0", + "@arbitrum/orbit-sdk": "^0.9.0", "@arbitrum/token-bridge-contracts": "^1.2.1", "viem": "^1.20.0" }, diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index 260753c..f479c74 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -1,25 +1,62 @@ -import { abi as ArbOwner__abi } from '@arbitrum/nitro-contracts/build/contracts/src/precompiles/ArbOwner.sol/ArbOwner.json' -import { abi as ArbGasInfo__abi } from '@arbitrum/nitro-contracts/build/contracts/src/precompiles/ArbGasInfo.sol/ArbGasInfo.json' -import { ethers } from 'ethers' import { L3Config } from './l3ConfigType' import fs from 'fs' +import { JsonRpcProvider } from '@ethersproject/providers' + +import { createPublicClient, defineChain, http } from 'viem' +import { privateKeyToAccount } from 'viem/accounts' + +import { arbOwnerPublicActions } from '@arbitrum/orbit-sdk/dist/decorators/arbOwnerPublicActions' +import { arbGasInfoPublicActions } from '@arbitrum/orbit-sdk/dist/decorators/arbGasInfoPublicActions' + +import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils' + +function createPublicClientFromChainInfo({ + id, + name, + rpcUrl, +}: { + id: number + name: string + rpcUrl: string +}) { + const chain = defineChain({ + id: id, + network: name, + name: name, + nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, + rpcUrls: { + default: { + http: [rpcUrl], + }, + public: { + http: [rpcUrl], + }, + }, + testnet: true, + }) + return createPublicClient({ chain, transport: http() }) +} export async function l3Configuration( - privateKey: string, - L2_RPC_URL: string, - L3_RPC_URL: string + baseChainDeployerKey: string, + childChainRpc: string ) { - if (!privateKey || !L2_RPC_URL || !L3_RPC_URL) { + if (!baseChainDeployerKey || !childChainRpc) { throw new Error('Required environment variable not found') } - // Generating providers from RPCs - const L2Provider = new ethers.providers.JsonRpcProvider(L2_RPC_URL) - const L3Provider = new ethers.providers.JsonRpcProvider(L3_RPC_URL) + const l2Provider = new JsonRpcProvider(childChainRpc) + const l2NetworkInfo = await l2Provider.getNetwork() + + const deployer = privateKeyToAccount(sanitizePrivateKey(baseChainDeployerKey)) - // Creating the wallet and signer - const l2signer = new ethers.Wallet(privateKey).connect(L2Provider) - const l3signer = new ethers.Wallet(privateKey).connect(L3Provider) + const orbitChainPublicClient = createPublicClientFromChainInfo({ + id: l2NetworkInfo.chainId, + name: l2NetworkInfo.name, + rpcUrl: childChainRpc, + }) + .extend(arbOwnerPublicActions) + .extend(arbGasInfoPublicActions) // Read the JSON configuration const configRaw = fs.readFileSync( @@ -35,101 +72,147 @@ export async function l3Configuration( const chainOwner = config.chainOwner // Check if the Private Key provided is the chain owner: - if (l3signer.address !== chainOwner) { + if (deployer.address !== chainOwner) { throw new Error('The Private Key you have provided is not the chain owner') } - // ArbOwner precompile setup - const arbOwnerABI = ArbOwner__abi - - // Arb Owner precompile address - const arbOwnerAddress = '0x0000000000000000000000000000000000000070' - const ArbOwner = new ethers.Contract(arbOwnerAddress, arbOwnerABI, l3signer) - // Call the isChainOwner function and check the response - const isSignerChainOwner = await ArbOwner.isChainOwner(l3signer.address) - if (!isSignerChainOwner) { + const isOwnerInitially = await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'isChainOwner', + args: [deployer.address], + }) + + // assert account is not already an owner + if (!isOwnerInitially) { throw new Error('The address you have provided is not the chain owner') } - // Set the network base fee + // Set the network base fee setMinimumL2BaseFee minL2BaseFee console.log('Setting the Minimum Base Fee for the Orbit chain') - const tx = await ArbOwner.setMinimumL2BaseFee(minL2BaseFee) - - // Wait for the transaction to be mined - const receipt = await tx.wait() - console.log( - `Minimum Base Fee is set on the block number ${await receipt.blockNumber} on the Orbit chain` - ) - // Check the status of the transaction: 1 is successful, 0 is failure - if (receipt.status === 0) { - throw new Error('Transaction failed, could not set the Minimum base fee') + const transactionRequest1 = + await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ + functionName: 'setMinimumL2BaseFee', + args: [BigInt(minL2BaseFee)], + upgradeExecutor: false, + account: deployer.address, + }) + + // submit tx to update infra fee receiver + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest1), + }) + + const networkFeeAccount = await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'getNetworkFeeAccount', + }) + + if (networkFeeAccount === infrastructureFeeCollector) { + console.log('network fee receiver is set') + } else { + throw new Error( + 'network fee receiver Setting network fee receiver transaction failed' + ) } // Set the network fee receiver - console.log('Setting the network fee receiver for the Orbit chain') - const tx2 = await ArbOwner.setNetworkFeeAccount(networkFeeReceiver) - - // Wait for the transaction to be mined - const receipt2 = await tx2.wait() - console.log( - `network fee receiver is set on the block number ${await receipt2.blockNumber} on the Orbit chain` - ) + const initialNetworkFeeReceiver = + await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'getInfraFeeAccount', + }) + + // assert account is not already infra fee receiver + if (initialNetworkFeeReceiver !== networkFeeReceiver) { + throw new Error('The network fee receiver is set before') + } - // Check the status of the transaction: 1 is successful, 0 is failure - if (receipt2.status === 0) { + const transactionRequest2 = + await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ + functionName: 'setNetworkFeeAccount', + args: [networkFeeReceiver], + upgradeExecutor: false, + account: deployer.address, + }) + + // submit tx to update infra fee receiver + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest2), + }) + + const networkFeeRecieverAccount = + await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'getNetworkFeeAccount', + }) + + if (networkFeeRecieverAccount === networkFeeReceiver) { + console.log('network fee receiver is set') + } else { throw new Error( 'network fee receiver Setting network fee receiver transaction failed' ) } // Set the infrastructure fee collector - console.log( - 'Setting the infrastructure fee collector address for the Orbit chain' - ) - const tx3 = await ArbOwner.setInfraFeeAccount(infrastructureFeeCollector) - - // Wait for the transaction to be mined - const receipt3 = await tx3.wait() - console.log( - `infrastructure fee collector address is set on the block number ${await receipt3.blockNumber} on the Orbit chain` - ) + const initialInfraFeeReceiver = + await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'getInfraFeeAccount', + }) - // Check the status of the transaction: 1 is successful, 0 is failure - if (receipt3.status === 0) { + // assert account is not already infra fee receiver + if (initialInfraFeeReceiver !== infrastructureFeeCollector) { throw new Error( - 'Setting Set the infrastructure fee collector transaction failed' + 'Setting Set the infrastructure fee collector is set before' ) } - // Setting L1 basefee on L3 - const arbGasInfoAbi = ArbGasInfo__abi - const arbGasInfoAddress = '0x000000000000000000000000000000000000006c' - const ArbOGasInfo = new ethers.Contract( - arbGasInfoAddress, - arbGasInfoAbi, - l2signer - ) + const transactionRequest3 = + await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ + functionName: 'setInfraFeeAccount', + args: [infrastructureFeeCollector], + upgradeExecutor: false, + account: deployer.address, + }) - console.log('Getting L1 base fee estimate') - const l1BaseFeeEstimate = await ArbOGasInfo.getL1BaseFeeEstimate() - console.log(`L1 Base Fee estimate on L2 is ${l1BaseFeeEstimate.toNumber()}`) - const l2Basefee = await L2Provider.getGasPrice() - const totalGasPrice = await l1BaseFeeEstimate.add(l2Basefee) - console.log(`Setting L1 base fee estimate on L3 to ${totalGasPrice}`) - const tx4 = await ArbOwner.setL1PricePerUnit(totalGasPrice) + // submit tx to update infra fee receiver + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest3), + }) - // Wait for the transaction to be mined - const receipt4 = await tx4.wait() - console.log( - `L1 base fee estimate is set on the block number ${await receipt4.blockNumber} on the Orbit chain` - ) + const infraFeeReceiver = await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'getInfraFeeAccount', + }) // Check the status of the transaction: 1 is successful, 0 is failure - if (receipt4.status === 0) { - throw new Error('Base Fee Setting failed') + if (infraFeeReceiver === infrastructureFeeCollector) { + console.log('Infra Fee Collector changed successfully') + } else { + throw new Error('Infra Fee Collector Setting transaction failed') } + // Setting L1 basefee on L3 + console.log('Getting L1 base fee estimate') + const l1BaseFeeEstimate = await orbitChainPublicClient.arbGasInfoReadContract( + { + functionName: 'getL1BaseFeeEstimate', + } + ) + console.log(`L1 Base Fee estimate on L2 is ${Number(l1BaseFeeEstimate)}`) + const l2Basefee = await l2Provider.getGasPrice() + const totalGasPrice = l2Basefee.add(l1BaseFeeEstimate) + console.log(`Setting L1 base fee estimate on L3 to ${totalGasPrice}`) + + const transactionRequest4 = + await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ + functionName: 'setL1PricePerUnit', + args: [BigInt(totalGasPrice.toString())], + upgradeExecutor: false, + account: deployer.address, + }) + + // submit tx to update infra fee receiver + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest4), + }) + console.log('All things done! Enjoy your Orbit chain. LFG 🚀🚀🚀🚀') } diff --git a/scripts/setup.ts b/scripts/setup.ts index 5f325a5..3182d67 100644 --- a/scripts/setup.ts +++ b/scripts/setup.ts @@ -167,7 +167,7 @@ async function main() { console.log( 'Running l3Configuration script to configure your Orbit chain 📝📝📝📝📝' ) - await l3Configuration(privateKey, L2_RPC_URL, L3_RPC_URL) + await l3Configuration(privateKey, L3_RPC_URL) rs.l3config = true } //////////////////////////////// diff --git a/yarn.lock b/yarn.lock index 00a2955..2b89856 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,12 +22,12 @@ "@openzeppelin/contracts-upgradeable" "4.5.2" patch-package "^6.4.7" -"@arbitrum/orbit-sdk@^0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@arbitrum/orbit-sdk/-/orbit-sdk-0.8.0.tgz#67b437afb2b2d17f9ec28391bcbbde9689c42a04" - integrity sha512-UrcCOqDA3crCKIhOW957DmGvglPkpU/VT1QvcgCD+i4UFjkyT0/aMizVoj8AgsLaq5X46trMN2HKBkrAEjhLlg== +"@arbitrum/orbit-sdk@^0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@arbitrum/orbit-sdk/-/orbit-sdk-0.9.0.tgz#681e2c9fe05cf36de326e290481b466ec2f1a2c9" + integrity sha512-alwpZeSaQH/i9j2t6OZ6TO4wrzJM7CbSIwklvkI3vkqnto/1eiS3W0MpkStmZEAwe8EIMJKlkAsuPDIctv2uNQ== dependencies: - "@arbitrum/sdk" "^3.2.0" + "@arbitrum/sdk" "^3.3.2" "@arbitrum/token-bridge-contracts" "^1.2.1" ethers "^5.7.2" @@ -42,6 +42,17 @@ async-mutex "^0.4.0" ethers "^5.1.0" +"@arbitrum/sdk@^3.3.2": + version "3.3.3" + resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.3.3.tgz#9a49e753b9deeee6336f6a43acb0669961b91128" + integrity sha512-Fe/+h2gs78Efl94U7yXkYAN+FQLLAxDGj+kv6+CXbnUytso+PBvKgNj1e4YPwgtWLlDomdcOXFt/yaP4VKsrBQ== + dependencies: + "@ethersproject/address" "^5.0.8" + "@ethersproject/bignumber" "^5.1.1" + "@ethersproject/bytes" "^5.0.8" + async-mutex "^0.4.0" + ethers "^5.1.0" + "@arbitrum/token-bridge-contracts@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@arbitrum/token-bridge-contracts/-/token-bridge-contracts-1.2.1.tgz#4838d70182bc0d6b36adfd733d7b4650e596c979" From cc1d20c257ca5e5d45de4eed4e8113a9ad417df1 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:14:39 -0700 Subject: [PATCH 02/14] min l2 base fee check update --- scripts/l3Configuration.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index f479c74..c7bebda 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -87,7 +87,7 @@ export async function l3Configuration( throw new Error('The address you have provided is not the chain owner') } - // Set the network base fee setMinimumL2BaseFee minL2BaseFee + // Set the network base fee console.log('Setting the Minimum Base Fee for the Orbit chain') const transactionRequest1 = @@ -98,6 +98,14 @@ export async function l3Configuration( account: deployer.address, }) + const minL3BaseFee = await orbitChainPublicClient.arbGasInfoReadContract({ + functionName: 'getMinimumGasPrice', + }) + if (Number(minL3BaseFee) === minL2BaseFee) { + console.log('Minimum L3 base fee is set') + } else { + throw new Error('Failed to set Minimum L3 base fee') + } // submit tx to update infra fee receiver await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest1), From fa306cbeed5870bd51fec6d37a8ea24e9a59d43d Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:50:28 -0700 Subject: [PATCH 03/14] transfer ownership updated --- scripts/setup.ts | 3 +- scripts/transferOwnership.ts | 123 +++++++++++++++++++++++------------ 2 files changed, 83 insertions(+), 43 deletions(-) diff --git a/scripts/setup.ts b/scripts/setup.ts index 3182d67..af9b623 100644 --- a/scripts/setup.ts +++ b/scripts/setup.ts @@ -177,7 +177,7 @@ async function main() { console.log( 'Transferring ownership on L3, from rollup owner to upgrade executor 🔃🔃🔃' ) - await transferOwner(privateKey, L2Provider, L3Provider) + await transferOwner(privateKey, L2Provider, L3_RPC_URL) rs.transferOwnership = true } } catch (error) { @@ -189,7 +189,6 @@ async function main() { ) } } - // Run the script main().catch(error => { console.error(error) diff --git a/scripts/transferOwnership.ts b/scripts/transferOwnership.ts index 3b5d6f6..350daa2 100644 --- a/scripts/transferOwnership.ts +++ b/scripts/transferOwnership.ts @@ -1,12 +1,41 @@ import { ethers, Wallet } from 'ethers' import { JsonRpcProvider } from '@ethersproject/providers' -import UpgradeExecutor from '@arbitrum/nitro-contracts/build/contracts/src/mocks/UpgradeExecutorMock.sol/UpgradeExecutorMock.json' -import ArbOwner from '@arbitrum/nitro-contracts/build/contracts/src/precompiles/ArbOwner.sol/ArbOwner.json' import fs from 'fs' import { L3Config } from './l3ConfigType' import { TOKEN_BRIDGE_CREATOR_Arb_Sepolia } from './createTokenBridge' import L1AtomicTokenBridgeCreator from '@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol/L1AtomicTokenBridgeCreator.json' +import { arbOwnerPublicActions } from '@arbitrum/orbit-sdk/dist/decorators/arbOwnerPublicActions' +import { createPublicClient, defineChain, http } from 'viem' +import { privateKeyToAccount } from 'viem/accounts' +import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils' + +function createPublicClientFromChainInfo({ + id, + name, + rpcUrl, +}: { + id: number + name: string + rpcUrl: string +}) { + const chain = defineChain({ + id: id, + network: name, + name: name, + nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, + rpcUrls: { + default: { + http: [rpcUrl], + }, + public: { + http: [rpcUrl], + }, + }, + testnet: true, + }) + return createPublicClient({ chain, transport: http() }) +} export const getSigner = (provider: JsonRpcProvider, key?: string) => { if (!key && !provider) @@ -15,14 +44,14 @@ export const getSigner = (provider: JsonRpcProvider, key?: string) => { else return provider.getSigner(0) } -const ARB_OWNER_ADDRESS = '0x0000000000000000000000000000000000000070' export async function transferOwner( privateKey: string, l2Provider: ethers.providers.JsonRpcProvider, - l3Provider: ethers.providers.JsonRpcProvider + childChainRpc: string ) { //Generating l2 and l3 deployer signers from privatekey and providers - const l3Deployer = getSigner(l3Provider, privateKey) + const deployer = privateKeyToAccount(sanitizePrivateKey(privateKey)) + //fetching chain id of parent chain const l2ChainId = (await l2Provider.getNetwork()).chainId @@ -34,7 +63,12 @@ export async function transferOwner( 'The Base Chain you have provided is not supported, please put RPC for Arb Sepolia' ) } - + const l2NetworkInfo = await l2Provider.getNetwork() + const orbitChainPublicClient = createPublicClientFromChainInfo({ + id: l2NetworkInfo.chainId, + name: l2NetworkInfo.name, + rpcUrl: childChainRpc, + }).extend(arbOwnerPublicActions) // Read the JSON configuration const configRaw = fs.readFileSync( './config/orbitSetupScriptConfig.json', @@ -55,41 +89,48 @@ export async function transferOwner( await l1TokenBridgeCreator.inboxToL2Deployment(config.inbox) ).upgradeExecutor - //Defining Arb Owner Precompile - const ArbOwner__factory = new ethers.Contract( - ARB_OWNER_ADDRESS, - ArbOwner.abi, - l3Deployer - ) - const ArbOwnerContract = ArbOwner__factory.connect(l3Deployer) console.log('Adding Upgrade Executor contract to the chain owners') - const receipt1 = await ( - await ArbOwnerContract.addChainOwner(executorContractAddress) - ).wait() - console.log( - 'Executor has been added to chain owners on TX:', - receipt1.transactionHash - ) - //Defining upgrade executor contract - const executorContract__factory = new ethers.Contract( - executorContractAddress, - UpgradeExecutor.abi, - l3Deployer - ) - const upgradeExecutor = executorContract__factory.connect(l3Deployer) - //Constructing call data for removing rollup owner from chain owners on L3 - const arbOwnerInterface = new ethers.utils.Interface(ArbOwner.abi) - const targetCallData = arbOwnerInterface.encodeFunctionData( - 'removeChainOwner', - [await l3Deployer.getAddress()] - ) + const transactionRequest1 = + await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ + functionName: 'addChainOwner', + args: [executorContractAddress], + upgradeExecutor: false, + account: deployer.address, + }) - console.log('Executing removeChainOwner through the UpgradeExecutor contract') - const receipt2 = await ( - await upgradeExecutor.executeCall(ARB_OWNER_ADDRESS, targetCallData) - ).wait() - console.log( - 'Transaction complete, rollup owner removed from chain owners on TX:', - receipt2.transactionHash - ) + // submit tx to add chain owner + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest1), + }) + + const isOwner = await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'isChainOwner', + args: [executorContractAddress], + }) + + // assert account is now owner + if (isOwner) { + console.log('Executor has been added to chain owners') + } + // Removing deployer as chain owner + const transactionRequest2 = + await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ + functionName: 'removeChainOwner', + args: [deployer.address], + upgradeExecutor: executorContractAddress, + account: deployer.address, + }) + + // submit tx to remove chain owner + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest2), + }) + + const isOwner2 = await orbitChainPublicClient.arbOwnerReadContract({ + functionName: 'isChainOwner', + args: [deployer.address], + }) + if (!isOwner2) { + console.log('Executor has been added to chain owners') + } } From d62e137cb7dbe9b1a00b4c5a4f10f9ba26273ed1 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:17:18 -0700 Subject: [PATCH 04/14] extra checks for owner tranfership --- scripts/transferOwnership.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/transferOwnership.ts b/scripts/transferOwnership.ts index 350daa2..2655c80 100644 --- a/scripts/transferOwnership.ts +++ b/scripts/transferOwnership.ts @@ -99,19 +99,16 @@ export async function transferOwner( }) // submit tx to add chain owner - await orbitChainPublicClient.sendRawTransaction({ + const txHash1 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest1), }) - - const isOwner = await orbitChainPublicClient.arbOwnerReadContract({ - functionName: 'isChainOwner', - args: [executorContractAddress], + const txReceipt1 = await orbitChainPublicClient.waitForTransactionReceipt({ + hash: txHash1, }) + console.log( + `UpgradeExecutor account has been added to chain owners in ${txReceipt1.transactionHash}` + ) - // assert account is now owner - if (isOwner) { - console.log('Executor has been added to chain owners') - } // Removing deployer as chain owner const transactionRequest2 = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ @@ -122,15 +119,23 @@ export async function transferOwner( }) // submit tx to remove chain owner - await orbitChainPublicClient.sendRawTransaction({ + const txHash2 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest2), }) + const txReceipt2 = await orbitChainPublicClient.waitForTransactionReceipt({ + hash: txHash2, + }) + console.log( + `Deployer account removed from chain owners in ${txReceipt2.transactionHash}` + ) const isOwner2 = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'isChainOwner', args: [deployer.address], }) if (!isOwner2) { - console.log('Executor has been added to chain owners') + console.log( + 'UpgradeExecutor contract has been added to chain owners successfully' + ) } } From 6f5cd9608a8af08cf51d85837cfdc1223a0ff5c8 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:44:46 -0700 Subject: [PATCH 05/14] extra checks for l3 config --- scripts/l3Configuration.ts | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index c7bebda..08b0cba 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -97,7 +97,13 @@ export async function l3Configuration( upgradeExecutor: false, account: deployer.address, }) - + // submit tx to update infra fee receiver + const txHash1 = await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction(transactionRequest1), + }) + await orbitChainPublicClient.waitForTransactionReceipt({ + hash: txHash1, + }) const minL3BaseFee = await orbitChainPublicClient.arbGasInfoReadContract({ functionName: 'getMinimumGasPrice', }) @@ -106,10 +112,6 @@ export async function l3Configuration( } else { throw new Error('Failed to set Minimum L3 base fee') } - // submit tx to update infra fee receiver - await orbitChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(transactionRequest1), - }) const networkFeeAccount = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'getNetworkFeeAccount', @@ -143,10 +145,12 @@ export async function l3Configuration( }) // submit tx to update infra fee receiver - await orbitChainPublicClient.sendRawTransaction({ + const txHash2 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest2), }) - + await orbitChainPublicClient.waitForTransactionReceipt({ + hash: txHash2, + }) const networkFeeRecieverAccount = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'getNetworkFeeAccount', @@ -182,10 +186,12 @@ export async function l3Configuration( }) // submit tx to update infra fee receiver - await orbitChainPublicClient.sendRawTransaction({ + const txHash3 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest3), }) - + await orbitChainPublicClient.waitForTransactionReceipt({ + hash: txHash3, + }) const infraFeeReceiver = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'getInfraFeeAccount', }) @@ -217,10 +223,12 @@ export async function l3Configuration( account: deployer.address, }) - // submit tx to update infra fee receiver - await orbitChainPublicClient.sendRawTransaction({ + // setting L1PricePerUnit + const txHash4 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest4), }) - + await orbitChainPublicClient.waitForTransactionReceipt({ + hash: txHash4, + }) console.log('All things done! Enjoy your Orbit chain. LFG 🚀🚀🚀🚀') } From e895f74cb976517364493bc9a06ffd408d33bae9 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:49:00 -0700 Subject: [PATCH 06/14] sdk path correction --- scripts/l3Configuration.ts | 6 +++--- scripts/transferOwnership.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index 08b0cba..c14fded 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -5,8 +5,8 @@ import { JsonRpcProvider } from '@ethersproject/providers' import { createPublicClient, defineChain, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' -import { arbOwnerPublicActions } from '@arbitrum/orbit-sdk/dist/decorators/arbOwnerPublicActions' -import { arbGasInfoPublicActions } from '@arbitrum/orbit-sdk/dist/decorators/arbGasInfoPublicActions' +import { arbOwnerPublicActions } from '@arbitrum/orbit-sdk' +import { arbGasInfoPublicActions } from '@arbitrum/orbit-sdk' import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils' @@ -223,7 +223,7 @@ export async function l3Configuration( account: deployer.address, }) - // setting L1PricePerUnit + // setting setL1PricePerUnit const txHash4 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest4), }) diff --git a/scripts/transferOwnership.ts b/scripts/transferOwnership.ts index 2655c80..cc9b3a9 100644 --- a/scripts/transferOwnership.ts +++ b/scripts/transferOwnership.ts @@ -5,7 +5,7 @@ import fs from 'fs' import { L3Config } from './l3ConfigType' import { TOKEN_BRIDGE_CREATOR_Arb_Sepolia } from './createTokenBridge' import L1AtomicTokenBridgeCreator from '@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol/L1AtomicTokenBridgeCreator.json' -import { arbOwnerPublicActions } from '@arbitrum/orbit-sdk/dist/decorators/arbOwnerPublicActions' +import { arbOwnerPublicActions } from '@arbitrum/orbit-sdk' import { createPublicClient, defineChain, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils' From 99f0c09d8f4d9c997334c67ae46c7000c32eb9e1 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Mon, 8 Apr 2024 21:48:26 -0700 Subject: [PATCH 07/14] bug fixed --- scripts/l3Configuration.ts | 27 +-------------------------- scripts/setup.ts | 3 ++- scripts/transferOwnership.ts | 8 ++++---- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index c14fded..15b189c 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -67,7 +67,7 @@ export async function l3Configuration( // Reading params for L3 Configuration const minL2BaseFee = config.minL2BaseFee - const networkFeeReceiver = config.networkFeeReceiver + const networkFeeReceiver = config.networkFeeReceiver as `0x${string}` const infrastructureFeeCollector = config.infrastructureFeeCollector const chainOwner = config.chainOwner @@ -125,17 +125,6 @@ export async function l3Configuration( ) } - // Set the network fee receiver - const initialNetworkFeeReceiver = - await orbitChainPublicClient.arbOwnerReadContract({ - functionName: 'getInfraFeeAccount', - }) - - // assert account is not already infra fee receiver - if (initialNetworkFeeReceiver !== networkFeeReceiver) { - throw new Error('The network fee receiver is set before') - } - const transactionRequest2 = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setNetworkFeeAccount', @@ -164,19 +153,6 @@ export async function l3Configuration( ) } - // Set the infrastructure fee collector - const initialInfraFeeReceiver = - await orbitChainPublicClient.arbOwnerReadContract({ - functionName: 'getInfraFeeAccount', - }) - - // assert account is not already infra fee receiver - if (initialInfraFeeReceiver !== infrastructureFeeCollector) { - throw new Error( - 'Setting Set the infrastructure fee collector is set before' - ) - } - const transactionRequest3 = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setInfraFeeAccount', @@ -230,5 +206,4 @@ export async function l3Configuration( await orbitChainPublicClient.waitForTransactionReceipt({ hash: txHash4, }) - console.log('All things done! Enjoy your Orbit chain. LFG 🚀🚀🚀🚀') } diff --git a/scripts/setup.ts b/scripts/setup.ts index af9b623..17d8242 100644 --- a/scripts/setup.ts +++ b/scripts/setup.ts @@ -177,8 +177,9 @@ async function main() { console.log( 'Transferring ownership on L3, from rollup owner to upgrade executor 🔃🔃🔃' ) - await transferOwner(privateKey, L2Provider, L3_RPC_URL) + await transferOwner(privateKey, L2Provider, L3Provider, L3_RPC_URL) rs.transferOwnership = true + console.log('All things done! Enjoy your Orbit chain. LFG 🚀🚀🚀🚀') } } catch (error) { console.error('Error occurred:', error) diff --git a/scripts/transferOwnership.ts b/scripts/transferOwnership.ts index cc9b3a9..4e2a959 100644 --- a/scripts/transferOwnership.ts +++ b/scripts/transferOwnership.ts @@ -47,6 +47,7 @@ export const getSigner = (provider: JsonRpcProvider, key?: string) => { export async function transferOwner( privateKey: string, l2Provider: ethers.providers.JsonRpcProvider, + l3Provider: ethers.providers.JsonRpcProvider, childChainRpc: string ) { //Generating l2 and l3 deployer signers from privatekey and providers @@ -63,10 +64,10 @@ export async function transferOwner( 'The Base Chain you have provided is not supported, please put RPC for Arb Sepolia' ) } - const l2NetworkInfo = await l2Provider.getNetwork() + const l3NetworkInfo = await l3Provider.getNetwork() const orbitChainPublicClient = createPublicClientFromChainInfo({ - id: l2NetworkInfo.chainId, - name: l2NetworkInfo.name, + id: l3NetworkInfo.chainId, + name: l3NetworkInfo.name, rpcUrl: childChainRpc, }).extend(arbOwnerPublicActions) // Read the JSON configuration @@ -97,7 +98,6 @@ export async function transferOwner( upgradeExecutor: false, account: deployer.address, }) - // submit tx to add chain owner const txHash1 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest1), From 4407f42e0ae66991a3e09237d50e0f7a95d06306 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Mon, 8 Apr 2024 23:50:24 -0700 Subject: [PATCH 08/14] bug fixed and some additional comments --- scripts/l3Configuration.ts | 32 +++++++++++++++----------------- scripts/transferOwnership.ts | 4 +++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index 15b189c..3dbdbf4 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -45,11 +45,14 @@ export async function l3Configuration( throw new Error('Required environment variable not found') } + // Generation parent chain provider and network const l2Provider = new JsonRpcProvider(childChainRpc) const l2NetworkInfo = await l2Provider.getNetwork() + //Generating deployer signer const deployer = privateKeyToAccount(sanitizePrivateKey(baseChainDeployerKey)) + // Creating Orbit chain client with arb owner and arb gas info extension const orbitChainPublicClient = createPublicClientFromChainInfo({ id: l2NetworkInfo.chainId, name: l2NetworkInfo.name, @@ -68,7 +71,8 @@ export async function l3Configuration( // Reading params for L3 Configuration const minL2BaseFee = config.minL2BaseFee const networkFeeReceiver = config.networkFeeReceiver as `0x${string}` - const infrastructureFeeCollector = config.infrastructureFeeCollector + const infrastructureFeeCollector = + config.infrastructureFeeCollector as `0x${string}` const chainOwner = config.chainOwner // Check if the Private Key provided is the chain owner: @@ -87,7 +91,7 @@ export async function l3Configuration( throw new Error('The address you have provided is not the chain owner') } - // Set the network base fee + // Set the child chain base fee console.log('Setting the Minimum Base Fee for the Orbit chain') const transactionRequest1 = @@ -97,34 +101,25 @@ export async function l3Configuration( upgradeExecutor: false, account: deployer.address, }) - // submit tx to update infra fee receiver + // submit tx to update minimum child chain base fee const txHash1 = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction(transactionRequest1), }) await orbitChainPublicClient.waitForTransactionReceipt({ hash: txHash1, }) + // Get the updated minL2Basefee from arbGasInfo precompile on child chain const minL3BaseFee = await orbitChainPublicClient.arbGasInfoReadContract({ functionName: 'getMinimumGasPrice', }) + // Check if minL2BaseFee param is set correctly if (Number(minL3BaseFee) === minL2BaseFee) { console.log('Minimum L3 base fee is set') } else { throw new Error('Failed to set Minimum L3 base fee') } - const networkFeeAccount = await orbitChainPublicClient.arbOwnerReadContract({ - functionName: 'getNetworkFeeAccount', - }) - - if (networkFeeAccount === infrastructureFeeCollector) { - console.log('network fee receiver is set') - } else { - throw new Error( - 'network fee receiver Setting network fee receiver transaction failed' - ) - } - + // Set the network fee account const transactionRequest2 = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setNetworkFeeAccount', @@ -140,6 +135,8 @@ export async function l3Configuration( await orbitChainPublicClient.waitForTransactionReceipt({ hash: txHash2, }) + + // check if network fee account is updated correctly const networkFeeRecieverAccount = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'getNetworkFeeAccount', @@ -153,6 +150,7 @@ export async function l3Configuration( ) } + // Set the infra fee account const transactionRequest3 = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setInfraFeeAccount', @@ -172,14 +170,14 @@ export async function l3Configuration( functionName: 'getInfraFeeAccount', }) - // Check the status of the transaction: 1 is successful, 0 is failure + // check if infra fee account is updated correctly if (infraFeeReceiver === infrastructureFeeCollector) { console.log('Infra Fee Collector changed successfully') } else { throw new Error('Infra Fee Collector Setting transaction failed') } - // Setting L1 basefee on L3 + // Setting L1 basefee estimate on L3 console.log('Getting L1 base fee estimate') const l1BaseFeeEstimate = await orbitChainPublicClient.arbGasInfoReadContract( { diff --git a/scripts/transferOwnership.ts b/scripts/transferOwnership.ts index 4e2a959..d482271 100644 --- a/scripts/transferOwnership.ts +++ b/scripts/transferOwnership.ts @@ -50,7 +50,7 @@ export async function transferOwner( l3Provider: ethers.providers.JsonRpcProvider, childChainRpc: string ) { - //Generating l2 and l3 deployer signers from privatekey and providers + //Generating deployer signer const deployer = privateKeyToAccount(sanitizePrivateKey(privateKey)) //fetching chain id of parent chain @@ -65,6 +65,7 @@ export async function transferOwner( ) } const l3NetworkInfo = await l3Provider.getNetwork() + // Creating Orbit chain client const orbitChainPublicClient = createPublicClientFromChainInfo({ id: l3NetworkInfo.chainId, name: l3NetworkInfo.name, @@ -129,6 +130,7 @@ export async function transferOwner( `Deployer account removed from chain owners in ${txReceipt2.transactionHash}` ) + // Checking chain onwers to see if deployer account is removed const isOwner2 = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'isChainOwner', args: [deployer.address], From f47c963f6c937c678b953c8d610e2868ec473a52 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:51:51 -0700 Subject: [PATCH 09/14] terminology in l3 config file --- scripts/l3Configuration.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index 3dbdbf4..c60219a 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -38,25 +38,27 @@ function createPublicClientFromChainInfo({ } export async function l3Configuration( - baseChainDeployerKey: string, - childChainRpc: string + parentChainDeployerKey: string, + orbitChainRpc: string ) { - if (!baseChainDeployerKey || !childChainRpc) { + if (!parentChainDeployerKey || !orbitChainRpc) { throw new Error('Required environment variable not found') } // Generation parent chain provider and network - const l2Provider = new JsonRpcProvider(childChainRpc) + const l2Provider = new JsonRpcProvider(orbitChainRpc) const l2NetworkInfo = await l2Provider.getNetwork() //Generating deployer signer - const deployer = privateKeyToAccount(sanitizePrivateKey(baseChainDeployerKey)) + const deployer = privateKeyToAccount( + sanitizePrivateKey(parentChainDeployerKey) + ) // Creating Orbit chain client with arb owner and arb gas info extension const orbitChainPublicClient = createPublicClientFromChainInfo({ id: l2NetworkInfo.chainId, name: l2NetworkInfo.name, - rpcUrl: childChainRpc, + rpcUrl: orbitChainRpc, }) .extend(arbOwnerPublicActions) .extend(arbGasInfoPublicActions) From 94c02b48fc790967e54911fd26aa45c06b1bb2ed Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:52:30 -0700 Subject: [PATCH 10/14] terminology ownership transfer --- scripts/transferOwnership.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/transferOwnership.ts b/scripts/transferOwnership.ts index d482271..6a65e94 100644 --- a/scripts/transferOwnership.ts +++ b/scripts/transferOwnership.ts @@ -48,7 +48,7 @@ export async function transferOwner( privateKey: string, l2Provider: ethers.providers.JsonRpcProvider, l3Provider: ethers.providers.JsonRpcProvider, - childChainRpc: string + orbitChainRpc: string ) { //Generating deployer signer const deployer = privateKeyToAccount(sanitizePrivateKey(privateKey)) @@ -69,7 +69,7 @@ export async function transferOwner( const orbitChainPublicClient = createPublicClientFromChainInfo({ id: l3NetworkInfo.chainId, name: l3NetworkInfo.name, - rpcUrl: childChainRpc, + rpcUrl: orbitChainRpc, }).extend(arbOwnerPublicActions) // Read the JSON configuration const configRaw = fs.readFileSync( From b130ff85e89112fc6aa8583c603ba589efdab2ce Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:54:51 -0700 Subject: [PATCH 11/14] terminology token bridge eth --- scripts/createTokenBridge.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/createTokenBridge.ts b/scripts/createTokenBridge.ts index 98373ad..1204056 100644 --- a/scripts/createTokenBridge.ts +++ b/scripts/createTokenBridge.ts @@ -91,30 +91,32 @@ async function getNativeToken({ * @returns */ export const createNewTokenBridge = async ( - baseChainRpc: string, - baseChainDeployerKey: string, - childChainRpc: string, + parentChainRpc: string, + parentChainDeployerKey: string, + orbitChainRpc: string, rollupAddress: string ) => { - const l1Provider = new JsonRpcProvider(baseChainRpc) + const l1Provider = new JsonRpcProvider(parentChainRpc) const l1NetworkInfo = await l1Provider.getNetwork() - const l2Provider = new JsonRpcProvider(childChainRpc) + const l2Provider = new JsonRpcProvider(orbitChainRpc) const l2NetworkInfo = await l2Provider.getNetwork() - const deployer = privateKeyToAccount(sanitizePrivateKey(baseChainDeployerKey)) + const deployer = privateKeyToAccount( + sanitizePrivateKey(parentChainDeployerKey) + ) const rollup = RollupAdminLogic__factory.connect(rollupAddress, l1Provider) const parentChainPublicClient = createPublicClientFromChainInfo({ id: l1NetworkInfo.chainId, name: l1NetworkInfo.name, - rpcUrl: baseChainRpc, + rpcUrl: parentChainRpc, }) const orbitChainPublicClient = createPublicClientFromChainInfo({ id: l2NetworkInfo.chainId, name: l2NetworkInfo.name, - rpcUrl: childChainRpc, + rpcUrl: orbitChainRpc, }) const nativeToken = await getNativeToken({ From 0dd4a77deb3a2cad4ea0340637df2bbc4e9a6b98 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:55:43 -0700 Subject: [PATCH 12/14] Update createTokenBridge.ts --- scripts/createTokenBridge.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/createTokenBridge.ts b/scripts/createTokenBridge.ts index 1204056..a057c20 100644 --- a/scripts/createTokenBridge.ts +++ b/scripts/createTokenBridge.ts @@ -325,17 +325,17 @@ export const createNewTokenBridge = async ( } export const createERC20Bridge = async ( - baseChainRpc: string, - baseChainDeployerKey: string, - childChainRpc: string, + parentChainRpc: string, + parentChainDeployerKey: string, + orbitChainRpc: string, rollupAddress: string ) => { console.log('Creating token bridge for rollup', rollupAddress) const { l1Network, l2Network } = await createNewTokenBridge( - baseChainRpc, - baseChainDeployerKey, - childChainRpc, + parentChainRpc, + parentChainDeployerKey, + orbitChainRpc, rollupAddress ) const NETWORK_FILE = 'network.json' From cbfe201d64ec1d0928afe0b07a62247fcc189e87 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:10:22 -0700 Subject: [PATCH 13/14] transaction name correction --- scripts/l3Configuration.ts | 52 +++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index c60219a..2d4f4c7 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -96,7 +96,7 @@ export async function l3Configuration( // Set the child chain base fee console.log('Setting the Minimum Base Fee for the Orbit chain') - const transactionRequest1 = + const setMinimumL2BaseFeeTransactionRequest = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setMinimumL2BaseFee', args: [BigInt(minL2BaseFee)], @@ -104,11 +104,14 @@ export async function l3Configuration( account: deployer.address, }) // submit tx to update minimum child chain base fee - const txHash1 = await orbitChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(transactionRequest1), - }) + const setMinimumL2BaseFeeTransactionHash = + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction( + setMinimumL2BaseFeeTransactionRequest + ), + }) await orbitChainPublicClient.waitForTransactionReceipt({ - hash: txHash1, + hash: setMinimumL2BaseFeeTransactionHash, }) // Get the updated minL2Basefee from arbGasInfo precompile on child chain const minL3BaseFee = await orbitChainPublicClient.arbGasInfoReadContract({ @@ -122,7 +125,7 @@ export async function l3Configuration( } // Set the network fee account - const transactionRequest2 = + const setNetworkFeeAccountTransactionRequest = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setNetworkFeeAccount', args: [networkFeeReceiver], @@ -131,11 +134,14 @@ export async function l3Configuration( }) // submit tx to update infra fee receiver - const txHash2 = await orbitChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(transactionRequest2), - }) + const setNetworkFeeAccountTransactionHash = + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction( + setNetworkFeeAccountTransactionRequest + ), + }) await orbitChainPublicClient.waitForTransactionReceipt({ - hash: txHash2, + hash: setNetworkFeeAccountTransactionHash, }) // check if network fee account is updated correctly @@ -153,7 +159,7 @@ export async function l3Configuration( } // Set the infra fee account - const transactionRequest3 = + const setInfraFeeAccountTransactionRequest = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setInfraFeeAccount', args: [infrastructureFeeCollector], @@ -162,11 +168,14 @@ export async function l3Configuration( }) // submit tx to update infra fee receiver - const txHash3 = await orbitChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(transactionRequest3), - }) + const setInfraFeeAccountTransactionHash = + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction( + setInfraFeeAccountTransactionRequest + ), + }) await orbitChainPublicClient.waitForTransactionReceipt({ - hash: txHash3, + hash: setInfraFeeAccountTransactionHash, }) const infraFeeReceiver = await orbitChainPublicClient.arbOwnerReadContract({ functionName: 'getInfraFeeAccount', @@ -191,7 +200,7 @@ export async function l3Configuration( const totalGasPrice = l2Basefee.add(l1BaseFeeEstimate) console.log(`Setting L1 base fee estimate on L3 to ${totalGasPrice}`) - const transactionRequest4 = + const setL1PricePerUnitTransactionRequest = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setL1PricePerUnit', args: [BigInt(totalGasPrice.toString())], @@ -200,10 +209,13 @@ export async function l3Configuration( }) // setting setL1PricePerUnit - const txHash4 = await orbitChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(transactionRequest4), - }) + const setL1PricePerUnitTransactionHash = + await orbitChainPublicClient.sendRawTransaction({ + serializedTransaction: await deployer.signTransaction( + setL1PricePerUnitTransactionRequest + ), + }) await orbitChainPublicClient.waitForTransactionReceipt({ - hash: txHash4, + hash: setL1PricePerUnitTransactionHash, }) } From 63937ee41715b88eab0dcc275ff84ca9e527500d Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:11:11 -0700 Subject: [PATCH 14/14] l2 basefee correction --- scripts/l3Configuration.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index 2d4f4c7..b0700ec 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -70,8 +70,8 @@ export async function l3Configuration( ) const config: L3Config = JSON.parse(configRaw) - // Reading params for L3 Configuration - const minL2BaseFee = config.minL2BaseFee + // Reading params for Configuration + const minOrbitChainBaseFee = config.minL2BaseFee const networkFeeReceiver = config.networkFeeReceiver as `0x${string}` const infrastructureFeeCollector = config.infrastructureFeeCollector as `0x${string}` @@ -93,32 +93,33 @@ export async function l3Configuration( throw new Error('The address you have provided is not the chain owner') } - // Set the child chain base fee + // Set the orbit chain base fee console.log('Setting the Minimum Base Fee for the Orbit chain') - const setMinimumL2BaseFeeTransactionRequest = + const setMinimumBaseFeeTransactionRequest = await orbitChainPublicClient.arbOwnerPrepareTransactionRequest({ functionName: 'setMinimumL2BaseFee', - args: [BigInt(minL2BaseFee)], + args: [BigInt(minOrbitChainBaseFee)], upgradeExecutor: false, account: deployer.address, }) // submit tx to update minimum child chain base fee - const setMinimumL2BaseFeeTransactionHash = + const setMinimumBaseFeeTransactionHash = await orbitChainPublicClient.sendRawTransaction({ serializedTransaction: await deployer.signTransaction( - setMinimumL2BaseFeeTransactionRequest + setMinimumBaseFeeTransactionRequest ), }) await orbitChainPublicClient.waitForTransactionReceipt({ - hash: setMinimumL2BaseFeeTransactionHash, + hash: setMinimumBaseFeeTransactionHash, }) - // Get the updated minL2Basefee from arbGasInfo precompile on child chain - const minL3BaseFee = await orbitChainPublicClient.arbGasInfoReadContract({ - functionName: 'getMinimumGasPrice', - }) - // Check if minL2BaseFee param is set correctly - if (Number(minL3BaseFee) === minL2BaseFee) { + // Get the updated minimum basefee on orbit chain from arbGasInfo precompile on child chain + const minOrbitChainBaseFeeRead = + await orbitChainPublicClient.arbGasInfoReadContract({ + functionName: 'getMinimumGasPrice', + }) + // Check if minimum basefee param is set correctly on orbit chain + if (Number(minOrbitChainBaseFeeRead) === minOrbitChainBaseFee) { console.log('Minimum L3 base fee is set') } else { throw new Error('Failed to set Minimum L3 base fee')