Skip to content
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: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d
uses: foundry-rs/foundry-toolchain@dba66c27052e63476d886f22216e119ba7e615bf # v1.9.2
with:
version: nightly

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/non-via-ir-compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: recursive
- run: yarn install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d
uses: foundry-rs/foundry-toolchain@dba66c27052e63476d886f22216e119ba7e615bf # v1.9.2
with:
version: nightly

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/solc-version-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: recursive
- run: yarn install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d
uses: foundry-rs/foundry-toolchain@dba66c27052e63476d886f22216e119ba7e615bf # v1.9.2
with:
version: nightly

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: recursive
- run: yarn install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d
uses: foundry-rs/foundry-toolchain@dba66c27052e63476d886f22216e119ba7e615bf # v1.9.2
with:
version: nightly

Expand Down
61 changes: 59 additions & 2 deletions docs/Management.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This document describes how to manage deployed `Scribe` and `ScribeOptimistic` i
- [`IToll::diss`](#itolldiss)
- [Offboarding](#offboarding)
- [Offboard via `ScribeOffboarder`](#offboard-via-scribeoffboarder)
- [Offboard via `ScribeOptimisticOffboarder`](#offboard-via-scribeoptimisticoffboarder)
- [Deactivation](#deactivation)
- [Fund Rescue](#fund-resuce)
- [Killing](#killing)
Expand Down Expand Up @@ -287,15 +288,20 @@ Offboarding a Scribe(Optimistic) instance simply means _Chronicle Protocol_ is n

However, to ensure an offboarded Scribe(Optimistic) instance may not behave unexpectedly it needs to be deactivated. Furthermore, if the contract is a ScribeOptimistic instance ETH held by the contract may need to be rescued. If its certain the contract will never be used again it is recommended to kill it.

A Scribe(Optimistic) instance can be deactivated in two ways:
A Scribe(Optimistic) instance can be deactivated in three ways:

- In a single transaction via a deployed [`ScribeOffboarder`](#offboard-via-scribeoffboarder) contract that holds `auth` on the instance.
- In a single transaction via a deployed [`ScribeOffboarder`](#offboard-via-scribeoffboarder) contract that holds `auth` on the instance. Note that this is only supported for Scribe instances.
- In two transactions via a deployed [`ScribeOptimisticOffboarder`](#offboard-via-scribeoptimisticoffboarder) contract that holds `auth` on the instance. Note that this is only supported for ScribeOptimistic instances.
- Via two distinct `forge script` [deactivation](#deactivation) commands signed by an `auth`'ed EOA.

### Offboard via `ScribeOffboarder`

Offboarding through a `ScribeOffboarder` instance drops every currently-lifted feed, sets `bar` to `1`, and pokes value `0` in a single transaction. After the call, `read()` reverts and no feed is lifted, so no future poke can verify.

> [!IMPORTANT]
>
> `ScribeOffboarder` only supports Scribe instances. ScribeOptimistic instances set their value's age to the current timestamp on every `drop` and `setBar`, leading the value `0` poke in the same transaction to revert. Use [`ScribeOptimisticOffboarder`](#offboard-via-scribeoptimisticoffboarder) instead.

Expects:

- `OFFBOARDER` is a deployed `ScribeOffboarder` instance that holds `auth` on `SCRIBE`.
Expand All @@ -320,6 +326,57 @@ $ forge script \

Note that `auth`'ed addresses on `SCRIBE` are untouched by `offboard` — to make the deactivation permanent, follow up with [`kill`](#killing).

### Offboard via `ScribeOptimisticOffboarder`

Offboarding through a `ScribeOptimisticOffboarder` instance drops every currently-lifted feed and sets `bar` to `1` in a first transaction, and pokes value `0` in a second transaction. After the second call, `read()` reverts and no feed is lifted, so no future poke can verify.

Note that no feed is lifted between both transactions, so no poke or opPoke can verify. However, between both transactions the instance still provides its last value with the first transaction's timestamp as age. Therefore, the second transaction should be executed in the next block.

> [!IMPORTANT]
>
> Offboarding requires running two distinct `forge script` commands, with step 2 being executed in a later block than step 1.
>
> It is of utmost importance to run both commands and NOT leave the ScribeOptimistic instance in an undefined state.

Expects:

- `OFFBOARDER` is a deployed `ScribeOptimisticOffboarder` instance that holds `auth` on `SCRIBE`.
- The caller holds `auth` on `OFFBOARDER`.

Set the additional environment variable:

- `OFFBOARDER`: The `ScribeOptimisticOffboarder` instance to offboard `SCRIBE` with.

Step 1:

```bash
$ forge script \
--keystore "$KEYSTORE" \
--password "$KEYSTORE_PASSWORD" \
--broadcast \
--rpc-url "$RPC_URL" \
--sig $(cast calldata "offboard_Step1(address,address)" "$OFFBOARDER" "$SCRIBE") \
-vvv \
script/ScribeOptimistic.s.sol:ScribeOptimisticScript
```

Step 2:

```bash
$ forge script \
--keystore "$KEYSTORE" \
--password "$KEYSTORE_PASSWORD" \
--broadcast \
--rpc-url "$RPC_URL" \
--sig $(cast calldata "offboard_Step2(address,address)" "$OFFBOARDER" "$SCRIBE") \
-vvv \
script/ScribeOptimistic.s.sol:ScribeOptimisticScript
```

Note that ETH held by `SCRIBE` is not rescued by offboarding — follow up with [fund rescue](#fund-rescue).

Note that `auth`'ed addresses on `SCRIBE` are untouched by `offboard_Step2` — to make the deactivation permanent, follow up with [`kill`](#killing).

### Deactivation

Deactivating a Scribe(Optimistic) instance means its value is set to zero, leading all `read()` calls to revert/fail, no feeds are lifted, and `bar` is set to `255`.
Expand Down
4 changes: 0 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,3 @@ runs = 100
runs = 100

# See more config options https://github.com/foundry-rs/foundry/tree/master/config


[profile.default.zksync]
zksolc = "1.5.1"
2 changes: 1 addition & 1 deletion script/Scribe.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ contract ScribeScript is Script {
///
/// @dev Note that `auth`'ed addresses on `scribe` are untouched. To make
/// the deactivation permanent, follow up with `kill(scribe)`.
function offboard(address offboarder, address scribe) public {
function offboard(address offboarder, address scribe) public virtual {
vm.startBroadcast();
ScribeOffboarder(offboarder).offboard(scribe);
vm.stopBroadcast();
Expand Down
49 changes: 49 additions & 0 deletions script/ScribeOptimistic.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import {LibFeed} from "./libs/LibFeed.sol";

import {Rescuer} from "./rescue/Rescuer.sol";

import {
ScribeOptimisticOffboarder
} from "./offboard/ScribeOptimisticOffboarder.sol";

/**
* @title ScribeOptimistic Management Script
*/
Expand Down Expand Up @@ -118,6 +122,51 @@ contract ScribeOptimisticScript is ScribeScript {
vm.stopBroadcast();
}

// -- Offboarding Functions --

/// @dev Note that `ScribeOffboarder` cannot offboard a ScribeOptimistic
/// instance. Use `offboard_Step1` and `offboard_Step2` instead.
function offboard(address, address) public pure override(ScribeScript) {
revert("Use offboard_Step1 and offboard_Step2");
}

/// @dev Step 1 of offboarding instance `scribe` via
/// `ScribeOptimisticOffboarder` instance `offboarder`.
///
/// @dev Step 1 drops every currently-lifted feed and sets bar to 1.
///
/// @dev Expects:
/// - `offboarder` to hold `auth` on `scribe`
/// - `msg.sender` to hold `auth` on `offboarder`
///
/// @dev Note that offboarding MUST be executed via two distinct
/// `forge script` commands with step 2 being executed in a later
/// block than step 1.
function offboard_Step1(address offboarder, address scribe) public {
vm.startBroadcast();
ScribeOptimisticOffboarder(offboarder).offboard_Step1(scribe);
vm.stopBroadcast();

console2.log("Offboarded Step 1", scribe);
}

/// @dev Step 2 of offboarding instance `scribe` via
/// `ScribeOptimisticOffboarder` instance `offboarder`.
///
/// @dev Step 2 pokes value 0, sets bar to type(uint8).max, and denies
/// `offboarder` on `scribe`. After the call `scribe.read()` reverts
/// and no feed is lifted, so no future poke can verify.
///
/// @dev Note that `auth`'ed addresses on `scribe` are untouched. To make
/// the deactivation permanent, follow up with `kill(scribe)`.
function offboard_Step2(address offboarder, address scribe) public {
vm.startBroadcast();
ScribeOptimisticOffboarder(offboarder).offboard_Step2(scribe);
vm.stopBroadcast();

console2.log("Offboarded Step 2", scribe);
}

/// @dev Rescues ETH held in deactivated `self`.
///
/// @dev Call via:
Expand Down
1 change: 1 addition & 0 deletions script/offboard/ScribeOffboarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ contract ScribeOffboarder is Auth {
})
);

// Drop offboarder again.
target.drop(FEED_ID);

// Set bar to max.
Expand Down
Loading
Loading