Skip to content

Commit 4f8c65c

Browse files
committed
celestia contracts
2 parents 7396313 + e4bb865 commit 4f8c65c

28 files changed

+2314
-93
lines changed

foundry.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ test = 'test/foundry'
66
cache_path = 'forge-cache/sol'
77
optimizer = true
88
optimizer_runs = 100
9-
via_ir = false
10-
solc_version = '0.8.9'
9+
via_ir = true
10+
solc_version = '0.8.19'
1111
remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
1212
'forge-std/=lib/forge-std/src/',
1313
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',

hardhat.config.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ dotenv.config()
1515
const solidity = {
1616
compilers: [
1717
{
18-
version: '0.8.9',
18+
version: '0.8.19',
1919
settings: {
2020
optimizer: {
2121
enabled: true,
22-
runs: 100,
22+
runs: 1,
2323
},
24+
viaIR: true
2425
},
2526
},
2627
],
@@ -134,6 +135,12 @@ module.exports = {
134135
? [process.env['DEVNET_PRIVKEY']]
135136
: [],
136137
},
138+
baseSepolia: {
139+
url: 'https://base-sepolia.g.alchemy.com/v2/XGpartgZXFCFedUcnvJP40usFO33wM1l',
140+
accounts: process.env['DEVNET_PRIVKEY']
141+
? [process.env['DEVNET_PRIVKEY']]
142+
: [],
143+
},
137144
arb1: {
138145
url: 'https://arb1.arbitrum.io/rpc',
139146
accounts: process.env['MAINNET_PRIVKEY']
@@ -201,6 +208,14 @@ module.exports = {
201208
browserURL: 'https://sepolia.arbiscan.io/',
202209
},
203210
},
211+
{
212+
network: 'baseSepolia',
213+
chainId: 84532,
214+
urls: {
215+
apiURL: 'https://api-sepolia.basescan.org/api',
216+
browserURL: 'https://sepolia.basescan.org/',
217+
},
218+
},
204219
],
205220
},
206221
mocha: {

remappings.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ds-test/=lib/forge-std/lib/ds-test/src/
2+
forge-std/=lib/forge-std/src/
3+
openzeppelin-contracts/=node_modules/@openzeppelin/contracts/
4+
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
5+
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { ethers } from 'hardhat'
2+
import { ContractFactory, Contract, Overrides } from 'ethers'
3+
import '@nomiclabs/hardhat-ethers'
4+
import { deployContract } from './deploymentUtils'
5+
import { ArbSys__factory } from '../build/types'
6+
import { ARB_SYS_ADDRESS } from '@arbitrum/sdk/dist/lib/dataEntities/constants'
7+
import { Toolkit4844 } from '../test/contract/toolkit4844'
8+
9+
async function _isRunningOnArbitrum(signer: any): Promise<Boolean> {
10+
const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer)
11+
try {
12+
await arbSys.arbOSVersion()
13+
return true
14+
} catch (error) {
15+
return false
16+
}
17+
}
18+
19+
async function main() {
20+
const [signer] = await ethers.getSigners()
21+
22+
try {
23+
24+
const rollupCreator = await deployContract('RollupCreator', signer)
25+
// deploy Sequencer Inbox,
26+
const isOnArb = await _isRunningOnArbitrum(signer)
27+
const reader4844 = isOnArb
28+
? ethers.constants.AddressZero
29+
: (await Toolkit4844.deployReader4844(signer)).address
30+
31+
// NOTE: maxDataSize is set for an L3, if deploying an L2 use "const maxDataSize = 117964"
32+
const maxDataSize = 104857
33+
const ethSequencerInbox = await deployContract('SequencerInbox', signer, [
34+
maxDataSize,
35+
reader4844,
36+
false,
37+
])
38+
39+
const erc20SequencerInbox = await deployContract('SequencerInbox', signer, [
40+
maxDataSize,
41+
reader4844,
42+
true,
43+
])
44+
45+
const bridgeCreator = await deployContract('BridgeCreator', signer, [
46+
[
47+
// BRIDGE_ADDRESS,
48+
ethSequencerInbox.address,
49+
// INBOX_ADDRESS,
50+
// RollupEventInbox,
51+
// Outbox,
52+
],
53+
[
54+
// ERC20Bridge address,
55+
erc20SequencerInbox.address,
56+
// ERC20Inbox address ,
57+
// ERC20RollupEventInbox address ,
58+
// ERC20Outbox address ,
59+
],
60+
])
61+
62+
// deploy OSP
63+
64+
const prover0 = await deployContract('OneStepProver0', signer)
65+
const proverMem = await deployContract('OneStepProverMemory', signer)
66+
const proverMath = await deployContract('OneStepProverMath', signer)
67+
const proverHostIo = await deployContract('OneStepProverHostIo', signer)
68+
const osp: Contract = await deployContract('OneStepProofEntry', signer, [
69+
prover0.address,
70+
proverMem.address,
71+
proverMath.address,
72+
proverHostIo.address,
73+
])
74+
75+
// Call setTemplates with the deployed contract addresses
76+
console.log('Waiting for the Template to be set on the Rollup Creator')
77+
await rollupCreator.setTemplates(
78+
bridgeCreator.address,
79+
osp,
80+
// ChallengeManager address,
81+
// RollupAdmin address,
82+
// RollupUser address,
83+
// UpgradeExecutor address,
84+
// ValidatorUtils address,
85+
// ValidatorWalletCreator address,
86+
// deployHelper address
87+
)
88+
console.log('Template is set on the Rollup Creator')
89+
} catch (error) {
90+
console.error(
91+
'Deployment failed:',
92+
error instanceof Error ? error.message : error
93+
)
94+
}
95+
}
96+
97+
main()
98+
.then(() => process.exit(0))
99+
.catch((error: Error) => {
100+
console.error(error)
101+
process.exit(1)
102+
})

scripts/deploymentUtils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const ARB_OWNER_ADDRESS = '0x0000000000000000000000000000000000000070'
2020
const ARB_OWNER_PUBLIC_ADDRESS = '0x000000000000000000000000000000000000006b'
2121
const ARB_SYS_ADDRESS = '0x0000000000000000000000000000000000000064'
2222

23+
// NOTE: maxDataSize is set for an L3, if deploying an L2 use "const maxDataSize = 117964"
24+
export const maxDataSize = 104857
2325
// Define a verification function
2426
export async function verifyContract(
2527
contractName: string,

src/bridge/ISequencerInbox.sol

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ interface ISequencerInbox is IDelayedMessageProvider {
6565
// solhint-disable-next-line func-name-mixedcase
6666
function DAS_MESSAGE_HEADER_FLAG() external view returns (bytes1);
6767

68+
/// @dev If the first data byte after the header has this bit set,
69+
/// then the batch data is a celestia message
70+
/// See: https://github.com/celestiaorg/nitro/blob/blobstream-v2.2.2/arbstate/das_reader.go
71+
// solhint-disable-next-line func-name-mixedcase
72+
function CELESTIA_MESSAGE_HEADER_FLAG() external view returns (bytes1);
73+
6874
/// @dev If the first data byte after the header has this bit set,
6975
/// then the batch data is a das message that employs a merklesization strategy
7076
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go

0 commit comments

Comments
 (0)