Skip to content

Commit

Permalink
Merge branch 'stylus' into footprint-precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacolvin0 committed Sep 6, 2023
2 parents 4e257d7 + 41f7392 commit 7cc7a9a
Show file tree
Hide file tree
Showing 104 changed files with 645 additions and 294 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ deployments/
/test/prover/proofs/*.json
/test/prover/spec-proofs/*.json
/test/storage/*-old.dot
scripts/config.ts
114 changes: 114 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Business Source License 1.1

License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.

-----------------------------------------------------------------------------

Parameters

Licensor: Offchain Labs

Licensed Work: Arbitrum Nitro Contracts
The Licensed Work is (c) 2021-2023 Offchain Labs

Additional Use Grant: You may use the Licensed Work in a production environment solely
to provide a point of interface to permit end users or applications
utilizing the Covered Arbitrum Chains to interact and query the
state of a Covered Arbitrum Chain, including without limitation
validating the correctness of the posted chain state. For purposes
of this Additional Use Grant, the "Covered Arbitrum Chains" are
means (a) Arbitrum One (chainid:42161), Arbitrum Nova (chainid:42170),
Arbitrum Rinkeby testnet/Rinkarby (chainid:421611), and
Arbitrum Nitro Goerli testnet (chainid:421613) (b) any future
blockchains authorized to be designated as Covered Arbitrum Chains
by the decentralized autonomous organization governing the Arbitrum
network; and (c) any “Layer 3” Arbitrum-based blockchain that is built
on and settles to another Covered Arbitrum Chain.





Change Date: Dec 31, 2027

Change License: Apache License Version 2.0

-----------------------------------------------------------------------------

Terms

The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.

Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.

If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.

All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.

You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.

Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.

This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).

TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.

MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark "Business Source License",
as long as you comply with the Covenants of Licensor below.

-----------------------------------------------------------------------------

Covenants of Licensor

In consideration of the right to use this License’s text and the "Business
Source License" name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:

1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where "compatible" means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.

2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text "None".

3. To specify a Change Date.

4. Not to modify this License in any other way.

-----------------------------------------------------------------------------

Notice

The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
7 changes: 7 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ module.exports = {
? [process.env['DEVNET_PRIVKEY']]
: [],
},
sepolia: {
url: 'https://sepolia.infura.io/v3/' + process.env['INFURA_KEY'],
accounts: process.env['DEVNET_PRIVKEY']
? [process.env['DEVNET_PRIVKEY']]
: [],
},
rinkeby: {
url: 'https://rinkeby.infura.io/v3/' + process.env['INFURA_KEY'],
accounts: process.env['DEVNET_PRIVKEY']
Expand Down Expand Up @@ -126,6 +132,7 @@ module.exports = {
apiKey: {
mainnet: process.env['ETHERSCAN_API_KEY'],
goerli: process.env['ETHERSCAN_API_KEY'],
sepolia: process.env['ETHERSCAN_API_KEY'],
rinkeby: process.env['ETHERSCAN_API_KEY'],
arbitrumOne: process.env['ARBISCAN_API_KEY'],
arbitrumTestnet: process.env['ARBISCAN_API_KEY'],
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"build:0.7": "INTERFACE_TESTER_SOLC_VERSION=0.7.0 yarn run build",
"test:compatibility": "yarn run build:0.6 && yarn run build:0.7",
"test:storage": "./test/storage/test.bash",
"postinstall": "patch-package"
"postinstall": "patch-package",
"deploy-factory": "hardhat run scripts/deployment.ts",
"deploy-rollup": "hardhat run scripts/rollupCreation.ts"
},
"dependencies": {
"@openzeppelin/contracts": "4.5.0",
Expand Down
29 changes: 29 additions & 0 deletions scripts/config.ts.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ethers } from 'ethers'

export const config = {
rollupConfig: {
confirmPeriodBlocks: ethers.BigNumber.from('45818'),
extraChallengeTimeBlocks: ethers.BigNumber.from('200'),
stakeToken: ethers.constants.AddressZero,
baseStake: ethers.utils.parseEther('1'),
wasmModuleRoot:
'0xda4e3ad5e7feacb817c21c8d0220da7650fe9051ece68a3f0b1c5d38bbb27b21',
owner: '0x1234123412341234123412341234123412341234',
loserStakeEscrow: ethers.constants.AddressZero,
chainId: ethers.BigNumber.from('13331370'),
chainConfig:
'{"chainId":13331370,"homesteadBlock":0,"daoForkBlock":null,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"berlinBlock":0,"londonBlock":0,"clique":{"period":0,"epoch":0},"arbitrum":{"EnableArbOS":true,"AllowDebugPrecompiles":false,"DataAvailabilityCommittee":false,"InitialArbOSVersion":10,"InitialChainOwner":"0x1234123412341234123412341234123412341234","GenesisBlockNum":0}}',
genesisBlockNum: ethers.BigNumber.from('0'),
sequencerInboxMaxTimeVariation: {
delayBlocks: ethers.BigNumber.from('5760'),
futureBlocks: ethers.BigNumber.from('12'),
delaySeconds: ethers.BigNumber.from('86400'),
futureSeconds: ethers.BigNumber.from('3600'),
},
},
validators: [
'0x1234123412341234123412341234123412341234',
'0x1234512345123451234512345123451234512345',
],
batchPoster: '0x1234123412341234123412341234123412341234',
}
163 changes: 163 additions & 0 deletions scripts/deployment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import { ethers } from 'hardhat'
import { ContractFactory, Contract } from 'ethers'
import '@nomiclabs/hardhat-ethers'
import { run } from 'hardhat'

// Define a verification function
async function verifyContract(
contractName: string,
contractAddress: string,
constructorArguments: any[] = [],
contractPathAndName?: string // optional
): Promise<void> {
try {
// Define the verification options with possible 'contract' property
const verificationOptions: {
contract?: string
address: string
constructorArguments: any[]
} = {
address: contractAddress,
constructorArguments: constructorArguments,
}

// if contractPathAndName is provided, add it to the verification options
if (contractPathAndName) {
verificationOptions.contract = contractPathAndName
}

await run('verify:verify', verificationOptions)
console.log(`Verified contract ${contractName} successfully.`)
} catch (error: any) {
if (error.message.includes('Already Verified')) {
console.log(`Contract ${contractName} is already verified.`)
} else {
console.error(
`Verification for ${contractName} failed with the following error: ${error.message}`
)
}
}
}

// Function to handle contract deployment
async function deployContract(
contractName: string,
signer: any,
constructorArgs: any[] = []
): Promise<Contract> {
const factory: ContractFactory = await ethers.getContractFactory(contractName)
const connectedFactory: ContractFactory = factory.connect(signer)
const contract: Contract = await connectedFactory.deploy(...constructorArgs)
await contract.deployTransaction.wait()
console.log(`New ${contractName} created at address:`, contract.address)

await verifyContract(contractName, contract.address, constructorArgs)

return contract
}

// Function to handle all deployments of core contracts using deployContract function
async function deployAllContracts(
signer: any
): Promise<Record<string, Contract>> {
const bridgeCreator = await deployContract('BridgeCreator', signer)
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,
])
const challengeManager = await deployContract('ChallengeManager', signer)
const rollupAdmin = await deployContract('RollupAdminLogic', signer)
const rollupUser = await deployContract('RollupUserLogic', signer)
const validatorUtils = await deployContract('ValidatorUtils', signer)
const validatorWalletCreator = await deployContract(
'ValidatorWalletCreator',
signer
)
const rollupCreator = await deployContract('RollupCreator', signer)
return {
bridgeCreator,
prover0,
proverMem,
proverMath,
proverHostIo,
osp,
challengeManager,
rollupAdmin,
rollupUser,
validatorUtils,
validatorWalletCreator,
rollupCreator,
}
}

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

try {
// Deploying all contracts
const contracts = await deployAllContracts(signer)

// Call setTemplates with the deployed contract addresses
console.log('Waiting for the Template to be set on the Rollup Creator')
await contracts.rollupCreator.setTemplates(
contracts.bridgeCreator.address,
contracts.osp.address,
contracts.challengeManager.address,
contracts.rollupAdmin.address,
contracts.rollupUser.address,
contracts.validatorUtils.address,
contracts.validatorWalletCreator.address
)
console.log('Template is set on the Rollup Creator')

const bridgeAddress = await contracts.bridgeCreator.bridgeTemplate()
const sequencerInboxAddress =
await contracts.bridgeCreator.sequencerInboxTemplate()
const inboxAddress = await contracts.bridgeCreator.inboxTemplate()
const outboxAddress = await contracts.bridgeCreator.outboxTemplate()

console.log(
`"bridge implementation contract" created at address:`,
bridgeAddress
)
await verifyContract(
'Bridge',
bridgeAddress,
[],
'src/bridge/Bridge.sol:Bridge'
)
console.log(
`"sequencerInbox implementation contract" created at address:`,
sequencerInboxAddress
)
await verifyContract('SequencerInbox', sequencerInboxAddress, [])
console.log(
`"inbox implementation contract" created at address:`,
inboxAddress
)
await verifyContract('Inbox', inboxAddress, [])
console.log(
`"outbox implementation contract" created at address:`,
outboxAddress
)
await verifyContract('Outbox', outboxAddress, [])
} 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)
})
Loading

0 comments on commit 7cc7a9a

Please sign in to comment.