Skip to content

Commit

Permalink
L2 Verification & Tests, Documentation Updates (#17)
Browse files Browse the repository at this point in the history
* update package.json for hardhat test dependencies

* add optimism verifier lib

* lint optimism verifier

* wget relevant arb and opt contracts and interfaces

* re-retrieve outbox and rollupcore contracts from raw

* export committee address in hardhat test

* add common lib, breakout arbitrum and optimism verifier contracts

* tentatively reduce outbox/interface mock contracts to minimum

* add opt types contract to mock

* remove rollupcore and interface mock contracts

* add spdx licence identifier to mock contracts

* import common in lagrangeservice contract

* begin reducing imports and definitions in l2outputoracle

* prettier evidenceverifier

* snapshot, diagnosing unused bytecode deploy error

* snapshot: deploy_lgr before investigating lagrangeservice deploy error

* readme updates/corrections

* update lagrangeservice config

* introduce lagrangeservice hardhat test

* deploy arb/opt verifiers as standalone contracts to reduce lagrangeservice compilation size

* arb/opt/evidenceverifier interfacing refactoring

* common.sol updates

* Update README.md with new local deployment process

* tentatively remove common from lagrangeservice

* lagrangeservice test snapshot before cleanup

* remove raw blockheader sequence test, arb/opt verifier address setters, cleanup optimism output verification test

* rewrite output proof verifier, introduce l2outputoracle interface

* update arbitrum mock contracts, add unit test for arbitrum checkpoint block retrieval and prelim header verification

---------

Co-authored-by: root <root@debian-BULLSEYE-live-builder-AMD64>
  • Loading branch information
mnlesane and root authored Aug 3, 2023
1 parent 75b4c23 commit b994701
Show file tree
Hide file tree
Showing 20 changed files with 1,016 additions and 84 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@
After cloning the repository, run the following command to install the dependencies

```bash
# Update forge packages
foundryup

# Install or update dependencies
forge install
```

## Local Deployment

The following walks through the necessary steps to deploy the Lagrange contracts, interfacing with mock contracts for EigenLayer, as well as Arbitrum Nitro and Optimism Bedrock settlement mock contracts.
```
bash make all-mock
```

## Local Deployment

**Note**: *The following steps are deprecated as of July 2023.*

1. Eigenlayer Deployment

- Run the `geth` node using the following command
Expand All @@ -25,7 +38,7 @@ forge install

- Execute `make init-accounts` to initialize the accounts

- Deploy the mock `WETH9` smart contract and update the `strategies/token_address` of `localnet/script/M1_deploy.config.json` with the deployed address
- Deploy the mock `WETH9` smart contract and update the `strategies/token_address` of `script/localnet/M1_deploy.config.json` with the deployed address

```bash
make deploy-weth9
Expand Down
8 changes: 6 additions & 2 deletions config/LagrangeService.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@
"epoch_period": 43200,
"freeze_duration": 6000
}
]
}
],
"settlement": {
"opt_l2outputoracle": "0x4200000000000000000000000000000000000016",
"arb_outbox": "0x45Af9Ed1D03703e480CE7d328fB684bb67DA5049"
}
}
129 changes: 117 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"dependencies": {
"big.js": "^6.2.1",
"bls-eth-wasm": "^1.0.6",
"circomlibjs": "^0.1.7",
"dotenv": "^16.3.1",
"hermez-contracts": "github:hermeznetwork/contracts",
"js-sha3": "^0.8.0",
"rlp": "^3.0.0",
"solidity-rlp": "github:hamdiallam/Solidity-RLP"
},
"devDependencies": {
Expand Down
40 changes: 36 additions & 4 deletions script/Deploy_LGR.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ import {LagrangeService} from "src/protocol/LagrangeService.sol";
import {LagrangeServiceManager} from "src/protocol/LagrangeServiceManager.sol";
import {LagrangeCommittee} from "src/protocol/LagrangeCommittee.sol";

import {EvidenceVerifier} from "src/library/EvidenceVerifier.sol";
import {OptimismVerifier} from "src/library/OptimismVerifier.sol";
import {ArbitrumVerifier} from "src/library/ArbitrumVerifier.sol";

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import {IOutbox} from "src/mock/arbitrum/IOutbox.sol";
import {Outbox} from "src/mock/arbitrum/Outbox.sol";
import {L2OutputOracle} from "src/mock/optimism/L2OutputOracle.sol";
import {IL2OutputOracle} from "src/mock/optimism/IL2OutputOracle.sol";

contract Deploy is Script, Test {
string public deployDataPath =
string(bytes("script/output/deployed_mock.json"));
// string(bytes("script/output/M1_deployment_data.json"));
//string(bytes("script/output/M1_deployment_data.json"));
string public poseidonDataPath =
string(bytes("script/output/deployed_poseidon.json"));
string public serviceDataPath =
string(bytes("script/LagrangeService.json"));
string(bytes("config/LagrangeService.json"));

address slasherAddress;
address strategyManagerAddress;
Expand All @@ -39,8 +48,16 @@ contract Deploy is Script, Test {

EmptyContract public emptyContract;

EvidenceVerifier public evidenceVerifier;
OptimismVerifier public optimismVerifier;
ArbitrumVerifier public arbitrumVerifier;

Outbox public outbox;
L2OutputOracle public l2oo;

function run() public {
string memory deployData = vm.readFile(deployDataPath);
string memory configData = vm.readFile(serviceDataPath);
slasherAddress = stdJson.readAddress(deployData, ".addresses.slasher");
strategyManagerAddress = stdJson.readAddress(
deployData,
Expand All @@ -51,7 +68,7 @@ contract Deploy is Script, Test {

// deploy proxy admin for ability to upgrade proxy contracts
proxyAdmin = new ProxyAdmin();

// deploy upgradeable proxy contracts
emptyContract = new EmptyContract();
lagrangeCommittee = LagrangeCommittee(
Expand Down Expand Up @@ -88,11 +105,27 @@ contract Deploy is Script, Test {
lagrangeServiceManagerImp = new LagrangeServiceManager(
ISlasher(slasherAddress)
);

lagrangeServiceImp = new LagrangeService(
lagrangeServiceManager,
lagrangeCommittee,
IStrategyManager(strategyManagerAddress)
);

outbox = new Outbox();
IL2OutputOracle opt_L2OutputOracle = IL2OutputOracle(stdJson.readAddress(configData, ".settlement.opt_l2outputoracle"));
//L2OutputOracle l2oo = new L2OutputOracle();
//IL2OutputOracle opt_L2OutputOracle = IL2OutputOracle(l2oo.address);
//IOutbox arb_Outbox = IOutbox(stdJson.readAddress(configData, ".settlement.arb_outbox"));
IOutbox arb_Outbox = IOutbox(address(outbox));

// deploy evidence verifier
arbitrumVerifier = new ArbitrumVerifier(outbox);
optimismVerifier = new OptimismVerifier(opt_L2OutputOracle);
//evidenceVerifier = new EvidenceVerifier();

lagrangeServiceImp.setOptAddr(optimismVerifier);
lagrangeServiceImp.setArbAddr(arbitrumVerifier);

// upgrade proxy contracts
proxyAdmin.upgradeAndCall(
Expand Down Expand Up @@ -132,7 +165,6 @@ contract Deploy is Script, Test {
ISlasher(slasherAddress).optIntoSlashing(
address(lagrangeServiceManager)
);

vm.stopBroadcast();

// write deployment data to file
Expand Down
Loading

0 comments on commit b994701

Please sign in to comment.