Skip to content

Commit

Permalink
celestia contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferret-san committed Oct 4, 2024
1 parent c60b18d commit 8e5836b
Show file tree
Hide file tree
Showing 28 changed files with 2,314 additions and 93 deletions.
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ test = 'test/foundry'
cache_path = 'forge-cache/sol'
optimizer = true
optimizer_runs = 100
via_ir = false
solc_version = '0.8.9'
via_ir = true
solc_version = '0.8.19'
remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
'forge-std/=lib/forge-std/src/',
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',
Expand Down
19 changes: 17 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ dotenv.config()
const solidity = {
compilers: [
{
version: '0.8.9',
version: '0.8.19',
settings: {
optimizer: {
enabled: true,
runs: 100,
runs: 1,
},
viaIR: true
},
},
],
Expand Down Expand Up @@ -134,6 +135,12 @@ module.exports = {
? [process.env['DEVNET_PRIVKEY']]
: [],
},
baseSepolia: {
url: 'https://base-sepolia.g.alchemy.com/v2/XGpartgZXFCFedUcnvJP40usFO33wM1l',
accounts: process.env['DEVNET_PRIVKEY']
? [process.env['DEVNET_PRIVKEY']]
: [],
},
arb1: {
url: 'https://arb1.arbitrum.io/rpc',
accounts: process.env['MAINNET_PRIVKEY']
Expand Down Expand Up @@ -187,6 +194,14 @@ module.exports = {
browserURL: 'https://sepolia-explorer.arbitrum.io/',
},
},
{
network: 'baseSepolia',
chainId: 84532,
urls: {
apiURL: 'https://api-sepolia.basescan.org/api',
browserURL: 'https://sepolia.basescan.org/',
},
},
],
},
mocha: {
Expand Down
5 changes: 5 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
openzeppelin-contracts/=node_modules/@openzeppelin/contracts/
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/
102 changes: 102 additions & 0 deletions scripts/deploymentCelestiaReuseExisting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { ethers } from 'hardhat'
import { ContractFactory, Contract, Overrides } from 'ethers'
import '@nomiclabs/hardhat-ethers'
import { deployContract } from './deploymentUtils'
import { ArbSys__factory } from '../build/types'
import { ARB_SYS_ADDRESS } from '@arbitrum/sdk/dist/lib/dataEntities/constants'
import { Toolkit4844 } from '../test/contract/toolkit4844'

async function _isRunningOnArbitrum(signer: any): Promise<Boolean> {
const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer)
try {
await arbSys.arbOSVersion()
return true
} catch (error) {
return false
}
}

async function main() {
const [signer] = await ethers.getSigners()

try {

const rollupCreator = await deployContract('RollupCreator', signer)
// deploy Sequencer Inbox,
const isOnArb = await _isRunningOnArbitrum(signer)
const reader4844 = isOnArb
? ethers.constants.AddressZero
: (await Toolkit4844.deployReader4844(signer)).address

// NOTE: maxDataSize is set for an L3, if deploying an L2 use "const maxDataSize = 117964"
const maxDataSize = 104857
const ethSequencerInbox = await deployContract('SequencerInbox', signer, [
maxDataSize,
reader4844,
false,
])

const erc20SequencerInbox = await deployContract('SequencerInbox', signer, [
maxDataSize,
reader4844,
true,
])

const bridgeCreator = await deployContract('BridgeCreator', signer, [
[
// BRIDGE_ADDRESS,
ethSequencerInbox.address,
// INBOX_ADDRESS,
// RollupEventInbox,
// Outbox,
],
[
// ERC20Bridge address,
erc20SequencerInbox.address,
// ERC20Inbox address ,
// ERC20RollupEventInbox address ,
// ERC20Outbox address ,
],
])

// deploy OSP

const prover0 = await deployContract('OneStepProver0', signer)
const proverMem = await deployContract('OneStepProverMemory', signer)
const proverMath = await deployContract('OneStepProverMath', signer)
const proverHostIo = await deployContract('OneStepProverHostIo', signer)
const osp: Contract = await deployContract('OneStepProofEntry', signer, [
prover0.address,
proverMem.address,
proverMath.address,
proverHostIo.address,
])

// Call setTemplates with the deployed contract addresses
console.log('Waiting for the Template to be set on the Rollup Creator')
await rollupCreator.setTemplates(
bridgeCreator.address,
osp,
// ChallengeManager address,
// RollupAdmin address,
// RollupUser address,
// UpgradeExecutor address,
// ValidatorUtils address,
// ValidatorWalletCreator address,
// deployHelper address
)
console.log('Template is set on the Rollup Creator')
} catch (error) {
console.error(
'Deployment failed:',
error instanceof Error ? error.message : error
)
}
}

main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})
2 changes: 2 additions & 0 deletions scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const INIT_DECAY = 10322197911
const ARB_OWNER_ADDRESS = '0x0000000000000000000000000000000000000070'
const ARB_SYS_ADDRESS = '0x0000000000000000000000000000000000000064'

// NOTE: maxDataSize is set for an L3, if deploying an L2 use "const maxDataSize = 117964"
export const maxDataSize = 104857
// Define a verification function
export async function verifyContract(
contractName: string,
Expand Down
6 changes: 6 additions & 0 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ interface ISequencerInbox is IDelayedMessageProvider {
// solhint-disable-next-line func-name-mixedcase
function DAS_MESSAGE_HEADER_FLAG() external view returns (bytes1);

/// @dev If the first data byte after the header has this bit set,
/// then the batch data is a celestia message
/// See: https://github.com/celestiaorg/nitro/blob/blobstream-v2.2.2/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function CELESTIA_MESSAGE_HEADER_FLAG() external view returns (bytes1);

/// @dev If the first data byte after the header has this bit set,
/// then the batch data is a das message that employs a merklesization strategy
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
Expand Down
Loading

0 comments on commit 8e5836b

Please sign in to comment.