Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: Removes deployment via greenhouse #42

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@
path = lib/chronicle-std
url = https://github.com/chronicleprotocol/chronicle-std
branch = v2
[submodule "lib/greenhouse"]
path = lib/greenhouse
url = https://github.com/chronicleprotocol/greenhouse
branch = v1
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ $ forge snapshot --nmt "Fuzz" [--check]

- [chronicleprotocol/chronicle-std@v2](https://github.com/chronicleprotocol/chronicle-std/tree/v2)

Deployment via:

- [chronicleprotocol/greenhouse@v1](https://github.com/chronicleprotocol/greenhouse/tree/v1)

## Licensing

The primary license for Scribe is the Business Source License 1.1 (`BUSL-1.1`), see [`LICENSE`](./LICENSE). However, some files are dual licensed under `MIT`:
Expand Down
17 changes: 6 additions & 11 deletions docs/Deployment.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deployment

This document describes how to deploy `Scribe` and `ScribeOptimistic` instance via _Chronicle Protocol_'s [`Greenhouse`](https://github.com/chronicleprotocol/greenhouse) contract factory.
This document describes how to deploy `Scribe` and `ScribeOptimistic` instances.

## Environment Variables

Expand All @@ -14,13 +14,8 @@ The following environment variables must be set:
- Note that the API endpoint varies per Etherscan chain instance
- Note to point to actual API endpoint (e.g. `/api`) and not just host
- `ETHERSCAN_API_KEY`: The Etherscan API key for the Etherscan's chain instance
- `GREENHOUSE`: The `Greenhouse` instance to use for deployment
- `SCRIBE_FLAVOUR`: The `Scribe` flavour to deploy
- Note that value must be either `Scribe` or `ScribeOptimistic`
- `SALT`: The salt to deploy the `Scribe` instance to
- Note to use the salt's string representation
- Note that the salt must not exceed 32 bytes in length
- Note that the salt should match the name of the contract deployed!
- `INITIAL_AUTHED`: The address being auth'ed on the newly deployed `Scribe` instance
- `WAT`: The wat for `Scribe`
- Note to use the wat's string representation
Expand All @@ -31,7 +26,7 @@ Note that an `.env.example` file is provided in the project root. To set all env
To easily check the environment variables, run:

```bash
$ env | grep -e "RPC_URL" -e "KEYSTORE" -e "KEYSTORE_PASSWORD" -e "ETHERSCAN_API_URL" -e "ETHERSCAN_API_KEY" -e "GREENHOUSE" -e "SCRIBE_FLAVOUR" -e "SALT" -e "INITIAL_AUTHED" -e "WAT"
$ env | grep -e "RPC_URL" -e "KEYSTORE" -e "KEYSTORE_PASSWORD" -e "ETHERSCAN_API_URL" -e "ETHERSCAN_API_KEY" -e "SCRIBE_FLAVOUR" -e "INITIAL_AUTHED" -e "WAT"
```

## Code Adjustments
Expand All @@ -48,14 +43,14 @@ The deployment process consists of two steps - the actual deployment and the sub
Deployment:

```bash
$ SALT_BYTES32=$(cast format-bytes32-string $SALT) && \
WAT_BYTES32=$(cast format-bytes32-string $WAT) && \
$ WAT_BYTES32=$(cast format-bytes32-string $WAT) && \
forge script \
--keystore "$KEYSTORE" \
--password "$KEYSTORE_PASSWORD" \
pmerkleplant marked this conversation as resolved.
Show resolved Hide resolved
--sender "$INITIAL_AUTHED" \
--broadcast \
--rpc-url "$RPC_URL" \
--sig "$(cast calldata "deploy(address,bytes32,address,bytes32)" "$GREENHOUSE" "$SALT_BYTES32" "$INITIAL_AUTHED" "$WAT_BYTES32")" \
--sig "$(cast calldata "deploy(address,bytes32)" "$INITIAL_AUTHED" "$WAT_BYTES32")" \
-vvv \
script/${SCRIBE_FLAVOUR}.s.sol:${SCRIBE_FLAVOUR}Script
```
Expand All @@ -72,5 +67,5 @@ $ WAT_BYTES32=$(cast format-bytes32-string $WAT) && \
--etherscan-api-key "$ETHERSCAN_API_KEY" \
--watch \
--constructor-args $(cast abi-encode "constructor(address,bytes32)" "$INITIAL_AUTHED" "$WAT_BYTES32") \
src/${SCRIBE_FLAVOUR}.sol:"$SALT"
src/${SCRIBE_FLAVOUR}.sol:${SCRIBE_FLAVOUR}_1
```
1 change: 0 additions & 1 deletion lib/greenhouse
Submodule greenhouse deleted from 88d3ef
2 changes: 0 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ chronicle-std/=lib/chronicle-std/src/
lib/chronicle-std:src/=lib/chronicle-std/src/
lib/chronicle-std:ds-test/=lib/chronicle-std/lib/forge-std/lib/ds-test/src/
lib/chronicle-std:forge-std/=lib/chronicle-std/lib/forge-std/src/

greenhouse/=lib/greenhouse/src/
27 changes: 5 additions & 22 deletions script/Scribe.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {console2} from "forge-std/console2.sol";
import {IAuth} from "chronicle-std/auth/IAuth.sol";
import {IToll} from "chronicle-std/toll/IToll.sol";

import {IGreenhouse} from "greenhouse/IGreenhouse.sol";

import {IScribe} from "src/IScribe.sol";
import {Chronicle_BASE_QUOTE_COUNTER as Scribe} from "src/Scribe.sol";
// @todo ^^^^ ^^^^^ ^^^^^^^ Adjust name of Scribe instance.
Expand All @@ -25,28 +23,13 @@ contract ScribeScript is Script {
using LibSecp256k1 for LibSecp256k1.Point;
using LibFeed for LibFeed.Feed;

/// @dev Deploys a new Scribe instance via Greenhouse instance `greenhouse`
/// and salt `salt` with `initialAuthed` being the address initially
/// auth'ed. Note that zero address is kissed directly after deployment.
function deploy(
address greenhouse,
bytes32 salt,
address initialAuthed,
bytes32 wat
) public virtual {
// Create creation code with constructor arguments.
bytes memory creationCode = abi.encodePacked(
type(Scribe).creationCode, abi.encode(initialAuthed, wat)
);

// Ensure salt not yet used.
address deployed = IGreenhouse(greenhouse).addressOf(salt);
require(deployed.code.length == 0, "Salt already used");

// Plant creation code via greenhouse and kiss zero address.
/// @dev Deploys a new Scribe instance with `initialAuthed` being the address
/// initially auth'ed. Note that zero address is kissed directly after
/// deployment.
function deploy(address initialAuthed, bytes32 wat) public virtual {
vm.startBroadcast();
require(msg.sender == initialAuthed, "Deployer must be initial auth'ed");
IGreenhouse(greenhouse).plant(salt, creationCode);
address deployed = address(new Scribe(initialAuthed, wat));
IToll(deployed).kiss(address(0));
vm.stopBroadcast();

Expand Down
31 changes: 8 additions & 23 deletions script/ScribeOptimistic.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {console2} from "forge-std/console2.sol";

import {IToll} from "chronicle-std/toll/IToll.sol";

import {IGreenhouse} from "greenhouse/IGreenhouse.sol";

import {IScribe} from "src/IScribe.sol";
import {IScribeOptimistic} from "src/IScribeOptimistic.sol";
import {Chronicle_BASE_QUOTE_COUNTER as ScribeOptimistic} from
Expand All @@ -21,29 +19,16 @@ import {ScribeScript} from "./Scribe.s.sol";
* @title ScribeOptimistic Management Script
*/
contract ScribeOptimisticScript is ScribeScript {
/// @dev Deploys a new ScribeOptimistic instance via Greenhouse instance
/// `greenhouse` and salt `salt` with `initialAuthed` being the address
/// initially auth'ed. Note that zero address is kissed directly after
/// deployment.
function deploy(
address greenhouse,
bytes32 salt,
address initialAuthed,
bytes32 wat
) public override(ScribeScript) {
// Create creation code with constructor arguments.
bytes memory creationCode = abi.encodePacked(
type(ScribeOptimistic).creationCode, abi.encode(initialAuthed, wat)
);

// Ensure salt not yet used.
address deployed = IGreenhouse(greenhouse).addressOf(salt);
require(deployed.code.length == 0, "Salt already used");

// Plant creation code via greenhouse and kiss zero address.
/// @dev Deploys a new ScribeOptimistic instance with `initialAuthed` being
/// the address initially auth'ed. Note that zero address is kissed
/// directly after deployment.
function deploy(address initialAuthed, bytes32 wat)
public
override(ScribeScript)
{
vm.startBroadcast();
require(msg.sender == initialAuthed, "Deployer must be initial auth'ed");
IGreenhouse(greenhouse).plant(salt, creationCode);
address deployed = address(new ScribeOptimistic(initialAuthed, wat));
IToll(deployed).kiss(address(0));
vm.stopBroadcast();

Expand Down
Loading