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

feat(ct): add SphinxGnosisSafeProxyFactory #1700

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
561ca83
chore: remove repetitive words
fanqiaojun Apr 13, 2024
01f4d34
feat(pg): Include rollup stack information on all relevant networks
RPate97 Apr 11, 2024
e8b278b
Merge branch 'develop' into main
sam-goldman Apr 16, 2024
dd761cc
a
sam-goldman Apr 17, 2024
51ccf7d
a
sam-goldman Apr 17, 2024
d10fdda
a
sam-goldman Apr 17, 2024
59b7da0
a
sam-goldman Apr 18, 2024
b7144cf
a
sam-goldman Apr 19, 2024
8e41999
a
sam-goldman Apr 19, 2024
1e41b54
a
sam-goldman Apr 24, 2024
8e71f01
feat(pg): Switch to registration via the website
RPate97 Apr 3, 2024
27394ba
Merge pull request #1666 from sphinx-labs/pate/add-rollup-stack-info
RPate97 Apr 25, 2024
aca1a00
a
sam-goldman Apr 25, 2024
58ccea4
Merge pull request #1673 from fanqiaojun/main
RPate97 Apr 26, 2024
81390f7
a
sam-goldman Apr 26, 2024
c59fd6e
a
sam-goldman Apr 27, 2024
a8c87a7
a
sam-goldman Apr 27, 2024
c4f94fc
a
sam-goldman Apr 27, 2024
543c5ac
a
sam-goldman Apr 29, 2024
89d421b
feat(pg): Support Astar zkEVM, Mantle, Crab, Darwinia
RPate97 Apr 23, 2024
dff64c2
Merge pull request #1694 from sphinx-labs/pate/chu-945-support-darwin…
RPate97 Apr 29, 2024
d466edb
Merge pull request #1695 from sphinx-labs/develop
RPate97 Apr 29, 2024
e048abb
Version Packages
github-actions[bot] Apr 29, 2024
56529c7
Merge pull request #1697 from sphinx-labs/changeset-release/main
RPate97 Apr 29, 2024
ba7de45
Merge pull request #1698 from sphinx-labs/main
RPate97 Apr 29, 2024
e4278c8
a
sam-goldman Apr 30, 2024
d834752
a
sam-goldman Apr 30, 2024
c3f85ce
Merge branch 'develop' into samgoldman12/chu-567-fix-gnosis-safe-sphi…
sam-goldman May 1, 2024
6e719f0
Merge branch 'develop' of https://github.com/sphinx-labs/sphinx into …
sam-goldman May 1, 2024
a36bfa9
a
sam-goldman May 1, 2024
89c2113
a
sam-goldman May 1, 2024
9e568ee
a
sam-goldman May 3, 2024
3e294f8
a
sam-goldman May 3, 2024
60576df
Merge branch 'pate/chu-634-require-explicit-project-registration-inst…
sam-goldman May 3, 2024
a50bf3a
a
sam-goldman May 4, 2024
542498c
a
sam-goldman May 4, 2024
2c6f738
a
sam-goldman May 4, 2024
cd3122a
a
sam-goldman May 4, 2024
9bf549e
a
sam-goldman May 4, 2024
a09bf65
Merge branch 'samgoldman12/chu-567-fix-gnosis-safe-sphinx-module-depl…
sam-goldman May 4, 2024
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
6 changes: 0 additions & 6 deletions .changeset/poor-bats-draw.md

This file was deleted.

8 changes: 8 additions & 0 deletions .changeset/short-cycles-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@sphinx-labs/contracts': minor
'@sphinx-labs/plugins': minor
'@sphinx-labs/core': minor
'@sphinx-labs/demo': minor
---

Move project registration onto website
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ Please feel free to reach out to us in our [Discord](https://discord.gg/7Gc3DK33
- Rootstock
- Blast
- Mode
- Mantle
- Darwinia
- Crab
- Astar zkEVM

Test networks:

Expand All @@ -135,6 +139,8 @@ Test networks:
- Blast Sepolia
- Darwinia Pangolin
- Taiko Katla
- Mantle Sepolia
- Astar zKyoto

More networks are on the way! Please reach out to us in our [Discord](https://discord.gg/7Gc3DK33Np) if there are networks you'd like us to add.

Expand Down
48 changes: 48 additions & 0 deletions docs/breaking/registration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Project Registration Update
Sphinx is updating the way that you register projects. Instead of specifying your Gnosis Safe owners, threshold and salt nonce in your Solidity scripts, you will now register your projects via the Sphinx UI. In your script, you will simply specify the name of your project.

This change is intended to improve the UX of using Sphinx and to open the door for us to implement other feature requests such as sharing Gnosis Safes between Sphinx projects and importing Gnosis Safes that were deployed using alternative interfaces (such as the Gnosis Safe UI) into Sphinx.

## Update Guide
These steps will walk you through the process of getting upgraded to the new version. It should only take a few minutes for you to complete.

### 1. Update your Sphinx Plugin and Sphinx Solidity Library

Update the Sphinx plugin version by bumping the version in your `package.json` file to the latest version `0.32.0`.

Then update the Sphinx Solidity library by running `sphinx install`:
```
npx sphinx install
```

### 2. Fetch your `sphinx.lock` file and commit it to version control
Sphinx now stores information about your projects in a `sphinx.lock` file. This is an autogenerated file. You should not modify it manually. To generate this file for the first time run:
```
npx sphinx sync --org-id <ORG_ID>
```

Whenever you register a new project with Sphinx, you'll want to update your `sphinx.lock` file by running the following command:
```
npx sphinx sync
```

Commit the file to version control:
```
git add sphinx.lock
git commit -m "maint: Creating Sphinx lock file"
```

### 4. Remove legacy configuration options
Sphinx now only requires that you specify the `sphinxConfig.projectName` field in your script. You will need to remove the following configuration options from your deployment scripts:
- `sphinxConfig.orgId`
- `sphinxConfig.owners`
- `sphinxConfig.threshold`
- `sphinxConfig.saltNonce`

If you are using the `sphinxConfig.mainnets` or `sphinxConfig.testnets` options, you can leave both of them as they are.

### 5. Try proposing with your updated script
```
npx sphinx propose ./path/to/Script.s.sol --networks sepolia --dry-run
```

64 changes: 34 additions & 30 deletions docs/cli-existing-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ In this guide, you'll propose the deployment on the command line and then approv
4. [Install Sphinx Foundry library](#4-install-sphinx-foundry-library)
5. [Update `.gitignore`](#5-update-gitignore)
6. [Add remapping](#6-add-remapping)
7. [Update your deployment script](#7-update-your-deployment-script)\
7. [Create a new Sphinx project](#7-create-a-new-sphinx-project)
8. [Generate your sphinx.lock file](#8-generate-your-sphinxlock-file)
9. [Update your deployment script](#9-update-your-deployment-script)\
a. [Import Sphinx](#a-import-sphinx)\
b. [Inherit from `Sphinx`](#b-inherit-from-sphinx)\
c. [Add the `sphinx` modifier](#c-add-the-sphinx-modifier)\
d. [Remove broadcasts](#d-remove-broadcasts)\
e. [Handle new sender address](#e-handle-new-sender-address)\
f. [Add configuration options](#e-add-configuration-options)
8. [Add environment variables](#8-add-environment-variables)
9. [Update `foundry.toml` settings](#9-update-foundrytoml-settings)
10. [Run tests](#10-run-tests)
11. [Propose on testnets](#11-propose-on-testnets)
12. [Next steps](#12-next-steps)
f. [Configure project name](#f-configure-project-name)
10. [Add environment variables](#10-add-environment-variables)
11. [Update `foundry.toml` settings](#11-update-foundrytoml-settings)
12. [Propose on testnets](#12-propose-on-testnets)
13. [Next steps](#13-next-steps)

## 1. Prerequisites

Expand Down Expand Up @@ -103,7 +104,24 @@ Configure the following remapping in either your `foundry.toml` file or `remappi
@sphinx-labs/contracts/=lib/sphinx/packages/contracts/contracts/foundry
```

## 7. Update your deployment script
## 7. Create a new Sphinx project
Go to the [Sphinx website](https://sphinx.dev), sign up, and click the "Create Project" button. After you've finished creating the project, you'll see your Org ID, API Key, and Project Name on the website. You'll need these values for the rest of the guide.

## 8. Generate your `sphinx.lock` file
Sphinx uses a lock file to track your project configuration options. To generate this file, run the command:
```
npx sphinx sync --org-id <ORG_ID>
```

Commit the file to version control:
```
git add sphinx.lock
git commit -m "maint: Creating Sphinx lock file"
```

> When you create new projects, you'll want to update this file by running `npx sphinx sync`. Don't worry if you forget, we'll detect if the file may be out of date and let you know.

## 9. Update your deployment script

Navigate to your deployment script. In this section, we'll update it to be compatible with Sphinx.

Expand Down Expand Up @@ -153,28 +171,21 @@ For example, you may need to:
- Update hardcoded contract addresses
- Assign permissions using your Gnosis Safe address

### f. Add configuration options

There are a few configuration options that you must specify inside a `configureSphinx()` function in your deployment script. The options all exist on the `sphinxConfig` struct, which is inherited from `Sphinx.sol`.
### f. Configure Project Name

Copy and paste the following `configureSphinx()` function template into your script:

```sol
function configureSphinx() public override {
sphinxConfig.owners = [<your address>];
sphinxConfig.orgId = <Sphinx org ID>;
sphinxConfig.projectName = "My_First_Project";
sphinxConfig.threshold = 1;
sphinxConfig.projectName = <your_project_name>;
}
```

You'll need to update the following fields in this template:
* Enter your address in the `owners` array.
* Enter your Sphinx Organization ID in the `orgId` field. It's a public field, so you don't need to keep it secret. You can find it in the Sphinx UI.
You'll need to update the `projectName` field to match the Project Name you created in the Sphinx UI.

## 8. Add environment variables
## 10. Add environment variables

Get your Sphinx API Key from the Sphinx UI, then enter it as an environment variable:
Get your Sphinx API Key from the Sphinx UI and add it as an environment variable:
```
SPHINX_API_KEY=<your_api_key>
```
Expand All @@ -184,22 +195,15 @@ Also, if you haven't added your node provider API key as an environment variable
ALCHEMY_API_KEY=<your_api_key>
```

## 9. Update `foundry.toml` settings
## 11. Update `foundry.toml` settings

Update your `foundry.toml` file to include a few settings required by Sphinx. We recommend putting them in `[profile.default]`.

```
extra_output = ['storageLayout']
fs_permissions = [{ access = "read-write", path = "./"}]
```

## 10. Run tests

You've finished integrating Sphinx! Your next step is to check that your existing tests are passing. Go ahead and run your Forge tests.

If you can't get your test suite to pass, we're more than happy to help! Reach out to us in our [Discord](https://discord.gg/7Gc3DK33Np).

## 11. Propose on testnets
## 12. Propose on testnets

Use one of the command templates below to propose your deployment. Make sure to update the following parts of the command:
* Replace `<PATH_TO_FORGE_SCRIPT>` with the path to your Forge script.
Expand All @@ -225,6 +229,6 @@ Here are the steps that occur when you run this command:

When the proposal is finished, go to the [Sphinx UI](https://sphinx.dev) to approve the deployment. After you approve it, you can monitor the deployment's status in the UI while it's executed.

## 12. Next steps
## 13. Next steps

Before you use Sphinx in production, we recommend reading the [Writing Deployment Scripts with Sphinx guide](https://github.com/sphinx-labs/sphinx/blob/main/docs/writing-scripts.md), which covers essential information for using Sphinx.
23 changes: 10 additions & 13 deletions docs/cli-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ In this guide, you'll create a sample project, propose it on the command line, a
2. [Create a new directory](#2-create-a-new-directory)
3. [Update Foundry](#3-update-foundry)
4. [Install dependencies](#4-install-dependencies)
5. [Initialize a project](#5-initialize-a-project)
6. [Test the deployment](#6-test-the-deployment)
5. [Create a new Sphinx project](#5-create-a-new-sphinx-project)
6. [Initialize Sphinx](#6-initialize-sphinx)
7. [Propose on testnets](#7-propose-on-testnets)
8. [Next steps](#8-next-steps)

Expand Down Expand Up @@ -66,27 +66,30 @@ pnpm:
pnpm add -D @sphinx-labs/plugins https://github.com/foundry-rs/forge-std.git#v1.7.1 https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0
```

## 5. Initialize a project
## 5. Create a new Sphinx project
Go to the [Sphinx website](https://sphinx.dev), sign up, and click the "Create Project" button. After you've finished creating the project, you'll see your Org ID, API Key, and Project Name on the website. You'll need these values for the rest of the guide.

## 6. Initialize Sphinx

Run one of the following commands on your command line, replacing the placeholders with your values. We've included a description of each command line argument below.

Using Yarn or npm:

```
npx sphinx init --org-id <SPHINX_ORG_ID> --sphinx-api-key <API_KEY> --alchemy-api-key <API_KEY> --owner <YOUR_ADDRESS>
npx sphinx init --org-id <ORG_ID> --sphinx-api-key <API_KEY> --project <PROJECT_NAME> --alchemy-api-key <API_KEY>
```

Using pnpm:

```
pnpm sphinx init --org-id <SPHINX_ORG_ID> --sphinx-api-key <API_KEY> --alchemy-api-key <API_KEY> --owner <YOUR_ADDRESS> --pnpm
pnpm sphinx init --org-id <ORG_ID> --sphinx-api-key <API_KEY> --project <PROJECT_NAME> --alchemy-api-key <API_KEY> --pnpm
```

Command line argument descriptions:
* `--org-id <SPHINX_ORG_ID>`: Your organization ID from the Sphinx UI (under "Options" -> "API Credentials").
* `--org-id <ORG_ID>`: Your organization ID from the Sphinx UI (under "Options" -> "API Credentials").
* `--sphinx-api-key <API_KEY>`: Your API key from the Sphinx UI (under "Options" -> "API Credentials").
* `--alchemy-api-key <API_KEY>`: Your Alchemy API Key.
* `--owner <YOUR_ADDRESS>`: The address of an account you own on live networks.
* `--project <PROJECT_NAME>`: Your project name from the Sphinx UI.
* `--pnpm`: An optional flag that creates remappings for pnpm.

After you run the command, you'll notice several new files:
Expand All @@ -97,12 +100,6 @@ After you run the command, you'll notice several new files:
- `.env`: A sample `.env` file that contains your credentials.
- `.gitignore`: A sample `.gitignore` file that contains files and directories generated by Sphinx, Foundry, and Node.

## 6. Test the deployment

```
forge test
```

## 7. Propose on testnets

Copy and paste one of the following commands to propose your deployment with the DevOps Platform.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"clean": "yarn workspaces run clean",
"lint": "yarn workspaces run lint",
"lint:fix": "yarn workspaces run lint:fix",
"changeset:version:custom": "yarn changeset version && yarn workspace @sphinx-labs/contracts run write-version"
"changeset:version:custom": "yarn changeset version && yarn workspace @sphinx-labs/contracts run write-version && yarn workspace @sphinx-labs/plugins run write-version"
},
"devDependencies": {
"@babel/eslint-parser": "^7.18.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sphinx-labs/contracts

## 0.21.11

### Patch Changes

- 01f4d34: Include rollup stack information for all relevant networks
- 89d421b: Support Astart zkEVM, Mantle, Crab

## 0.21.10

### Patch Changes
Expand Down
13 changes: 8 additions & 5 deletions packages/contracts/contracts/core/ManagedService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ contract ManagedService is AccessControl, ReentrancyGuard {
* @param dataHash A keccak256 hash of the input data.
*/
event Called(
address indexed relayer,
address payable indexed to,
uint256 value,
bytes32 indexed dataHash
address indexed relayer, address payable indexed to, uint256 value, bytes32 indexed dataHash
);

/**
Expand All @@ -55,7 +52,13 @@ contract ManagedService is AccessControl, ReentrancyGuard {
function exec(
address payable _to,
bytes calldata _data
) public payable nonReentrant onlyRole(RELAYER_ROLE) returns (bytes memory) {
)
public
payable
nonReentrant
onlyRole(RELAYER_ROLE)
returns (bytes memory)
{
require(_to != address(0), "ManagedService: target is address(0)");

emit Called(msg.sender, _to, msg.value, keccak256(_data));
Expand Down
9 changes: 9 additions & 0 deletions packages/contracts/contracts/core/SphinxDataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ struct MerkleRootState {
bool arbitraryChain;
}

// TODO(docs): explain why we're keeping enum members that aren't used by the current module
// version. (it's to maintain backwards compatibility in off-chain logic).
// TODO(docs): document which fields are deprecated.
/**
* @notice Enum that represents the status of a Merkle root in a `SphinxModuleProxy`.
*
Expand All @@ -92,3 +95,9 @@ enum MerkleRootStatus {
CANCELED,
FAILED
}

enum PreconditionResult {
REVERT,
EXECUTE,
SKIP
}
Loading