Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Jun 24, 2024
1 parent e5b5be7 commit aacf153
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 13 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,59 @@

- Allows for permissionless rebalance's based on the `minimumBuffer`.


# Deployments


**L1 Deployer**: `0x`
**STB Role Manager**: `0x`


In order to integrate your Polygon CDK chain with STB you will need to

1. Deploy an `L2Deployer` on your rollup.
2. Register the rollup and the L2 Deployer address with the L1 Deployer.

Once done it is permsissionless for anyone to use the STB to bridge from mainnet to your rollup.

There is a pre-built [script](https://github.com/yearn/yearn-stb/blob/master/scripts/RegisterRollup.s.sol) that can be run from this repo in order to complete the full setup.

**NOTE**: The script assumes the rollups `admin` on the L1 is a Gnosis Safe and the private key input maps to either a singer or a delegate of that safe in order to post the txn that registers the rollup.

```shell
$ git clone --recursive https://github.com/yearn/yearn-stb

$ cd yearn-stb

$ cp .env.example .env
```

Fill in the ful .env with your specific rollup RPC, Polygon CDK based rollup ID, and the desired addresses.

**NOTE**: To deploy a L2 Deployer during the script leave the `L2_DEPLOYER` variable as address(0). If one is already deployed, insert the address in that variable to not re-deploy.

If you have not added a keystore private key to foundry before add your address to use

```shell
$ cast wallet import --interactive <wallet_name>
```

Run the script
```shell
$ make register account=<wallet_name> sender=<wallet_address>
```

If successful the txn will both deploy the L2 Deployer on the specified rollup and post a Safe txn to register the Rollup in the L1 Deployer.


### Verification

The L2 Deployer will deploy 3 other implementation contracts with it when deployed.

You can find the flatten version of all contracts deployed on the L2 in the repo https://github.com/yearn/yearn-stb/tree/master/flat

The encoded constructor arguments used for the L2 deployer should be logged in the console on deployment as well.

## Foundry Documentation

https://book.getfoundry.sh/
Expand Down
25 changes: 12 additions & 13 deletions scripts/RegisterRollup.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;

import "forge-std/console.sol";
import {BatchScript, console2} from "./lib/BatchScript.sol";

import {L1Deployer, IPolygonRollupContract, IPolygonRollupManager} from "../src/L1Deployer.sol";
Expand All @@ -20,11 +19,11 @@ contract RegisterRollup is BatchScript {
console2.log("Using Signer:", msg.sender);


console.log("---------------------------------------");
console2.log("---------------------------------------");

if(l2Deployer == address(0)) {

console.log("Deploying an L2 Deployer...");
console2.log("Deploying an L2 Deployer...");

address l2Admin = vm.envAddress("L2_ADMIN");
require(l2Admin != address(0), "L2 Admin ZERO_ADDRESS");
Expand All @@ -36,7 +35,7 @@ contract RegisterRollup is BatchScript {
// Start L2 RPC
vm.createSelectFork(vm.envString("L2_RPC_URL"));
vm.startBroadcast();

// Deploy L2 Deployer
l2Deployer = address(new L2Deployer(
l2Admin,
Expand All @@ -48,17 +47,17 @@ contract RegisterRollup is BatchScript {

vm.stopBroadcast();

console.log("L2 Deployer deployed to ", address(l2Deployer));
console2.log("L2 Deployer deployed to ", address(l2Deployer));
bytes memory constructorArgs = abi.encode(
l2Admin,
address(L1_DEPLOYER),
l2RiskManager,
l2EscrowManager,
ZK_EVM_BRIDGE
);
console.log("Constructor Arguments for verification were:");
console2.log("Constructor Arguments for verification were:");
console2.logBytes(constructorArgs);
console.log("----");
console2.log("----");
}

// Take L2 deployer address
Expand All @@ -68,16 +67,16 @@ contract RegisterRollup is BatchScript {
uint32 rollupID = uint32(vm.envUint("ROLLUP_ID"));
address l1EscrowManager = vm.envAddress("L1_ESCROW_MANAGER");

console.log("Registering Rollup with ID ", rollupID, "to L1 Deployer");
console.log("Using ", l2Deployer, " as the L2 Deployer");
console2.log("Registering Rollup with ID ", rollupID, "to L1 Deployer");
console2.log("Using ", l2Deployer, " as the L2 Deployer");

require(L1_DEPLOYER.getRollupContract(rollupID) == address(0), "Already registered");

address safe = L1_DEPLOYER.rollupManager()
.rollupIDToRollupData(rollupID)
.rollupContract.admin();

console.log("Posting txn to the SAFE at ", safe);
console2.log("Posting txn to the SAFE at ", safe);

bytes memory txn = abi.encodeCall(
L1Deployer.registerRollup,
Expand All @@ -90,8 +89,8 @@ contract RegisterRollup is BatchScript {

require(L1_DEPLOYER.getRollupContract(rollupID) != address(0), "txn failed");

console.log("TXN posted");
console.log("Visit https://app.safe.global/transactions/queue?safe=eth:", safe);
console.log("---------------------------------------");
console2.log("TXN posted");
console2.log("Visit https://app.safe.global/transactions/queue?safe=eth:", safe);
console2.log("---------------------------------------");
}
}

0 comments on commit aacf153

Please sign in to comment.