From 439ccee34932ec6f1a82bef1b02b7f2641853380 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Wed, 28 Feb 2024 15:48:18 +0100 Subject: [PATCH] Deploy blob reader and SequencerInbox --- foundry.toml | 3 +- .../DeployOspAndChallengeManagerScript.s.sol | 32 ---------- scripts/foundry/upgrade/1.2.1/Deployer.s.sol | 63 +++++++++++++++++++ 3 files changed, 65 insertions(+), 33 deletions(-) delete mode 100644 scripts/foundry/1.2.1/DeployOspAndChallengeManagerScript.s.sol create mode 100644 scripts/foundry/upgrade/1.2.1/Deployer.s.sol diff --git a/foundry.toml b/foundry.toml index 262b145..dbc4727 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,4 +5,5 @@ libs = ['node_modules', 'lib'] test = 'test' cache_path = 'cache_forge' solc_version = '0.8.16' -optimizer_runs = 2000 \ No newline at end of file +optimizer_runs = 2000 +fs_permissions = [{ access = "read", path = "node_modules/@arbitrum/nitro-contracts/out/yul/Reader4844.yul/Reader4844.json"}] diff --git a/scripts/foundry/1.2.1/DeployOspAndChallengeManagerScript.s.sol b/scripts/foundry/1.2.1/DeployOspAndChallengeManagerScript.s.sol deleted file mode 100644 index 473d781..0000000 --- a/scripts/foundry/1.2.1/DeployOspAndChallengeManagerScript.s.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -pragma solidity 0.8.16; - -import "forge-std/Script.sol"; -import {OneStepProver0} from "@arbitrum/nitro-contracts/src/osp/OneStepProver0.sol"; -import {OneStepProverMemory} from "@arbitrum/nitro-contracts/src/osp/OneStepProverMemory.sol"; -import {OneStepProverMath} from "@arbitrum/nitro-contracts/src/osp/OneStepProverMath.sol"; -import {OneStepProverHostIo} from "@arbitrum/nitro-contracts/src/osp/OneStepProverHostIo.sol"; -import {OneStepProofEntry} from "@arbitrum/nitro-contracts/src/osp/OneStepProofEntry.sol"; -import {ChallengeManager} from "@arbitrum/nitro-contracts/src/challenge/ChallengeManager.sol"; - -/** - * @title DeployScript - * @notice This script deploys OSPs and ChallengeManager templates, - */ -contract DeployOspAndChallengeManagerScript is Script { - function run() public { - vm.startBroadcast(); - - // deploy OSP templates - OneStepProver0 osp0 = new OneStepProver0(); - OneStepProverMemory ospMemory = new OneStepProverMemory(); - OneStepProverMath ospMath = new OneStepProverMath(); - OneStepProverHostIo ospHostIo = new OneStepProverHostIo(); - new OneStepProofEntry(osp0, ospMemory, ospMath, ospHostIo); - - // deploy new challenge manager templates - new ChallengeManager(); - - vm.stopBroadcast(); - } -} diff --git a/scripts/foundry/upgrade/1.2.1/Deployer.s.sol b/scripts/foundry/upgrade/1.2.1/Deployer.s.sol new file mode 100644 index 0000000..d88245d --- /dev/null +++ b/scripts/foundry/upgrade/1.2.1/Deployer.s.sol @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity 0.8.16; + +import "forge-std/Script.sol"; +import {OneStepProver0} from "@arbitrum/nitro-contracts/src/osp/OneStepProver0.sol"; +import {OneStepProverMemory} from "@arbitrum/nitro-contracts/src/osp/OneStepProverMemory.sol"; +import {OneStepProverMath} from "@arbitrum/nitro-contracts/src/osp/OneStepProverMath.sol"; +import {OneStepProverHostIo} from "@arbitrum/nitro-contracts/src/osp/OneStepProverHostIo.sol"; +import {OneStepProofEntry} from "@arbitrum/nitro-contracts/src/osp/OneStepProofEntry.sol"; +import {ChallengeManager} from "@arbitrum/nitro-contracts/src/challenge/ChallengeManager.sol"; +import {SequencerInbox} from "@arbitrum/nitro-contracts/src/bridge/SequencerInbox.sol"; +import {IReader4844} from "@arbitrum/nitro-contracts/src/libraries/IReader4844.sol"; + +/** + * @title DeployScript + * @notice This script deploys OSPs and ChallengeManager templates, + */ +contract DeployScript is Script { + function run() public { + uint256 _chainId = block.chainid; + if (_chainId == 42161 || _chainId == 42170 || _chainId == 421614) { + revert("Chain ID not supported"); + } + + vm.startBroadcast(); + + // deploy OSP templates + OneStepProver0 osp0 = new OneStepProver0(); + OneStepProverMemory ospMemory = new OneStepProverMemory(); + OneStepProverMath ospMath = new OneStepProverMath(); + OneStepProverHostIo ospHostIo = new OneStepProverHostIo(); + new OneStepProofEntry(osp0, ospMemory, ospMath, ospHostIo); + + // deploy new challenge manager templates + new ChallengeManager(); + + // deploy blob reader + bytes memory reader4844Bytecode = _getReader4844Bytecode(); + address reader4844Address; + assembly { + reader4844Address := create(0, add(reader4844Bytecode, 0x20), mload(reader4844Bytecode)) + } + require(reader4844Address != address(0), "Reader4844 could not be deployed"); + + // deploy sequencer inbox template + new SequencerInbox({_maxDataSize: 117964, reader4844_: IReader4844(reader4844Address), _isUsingFeeToken: false}); + + vm.stopBroadcast(); + } + + /** + * @notice Read Reader4844 bytecode from JSON file at ${root}/out/yul/Reader4844.yul/Reader4844.json + */ + function _getReader4844Bytecode() internal returns (bytes memory) { + string memory readerBytecodeFilePath = string( + abi.encodePacked( + vm.projectRoot(), "/node_modules/@arbitrum/nitro-contracts/out/yul/Reader4844.yul/Reader4844.json" + ) + ); + string memory json = vm.readFile(readerBytecodeFilePath); + return vm.parseJsonBytes(json, ".bytecode.object"); + } +}