Skip to content

Commit

Permalink
docs: contracts (#3)
Browse files Browse the repository at this point in the history
* contracts readme

* foundry project

* docs: README
  • Loading branch information
ratankaliani authored May 29, 2024
1 parent dd0a1bb commit 2ca7f3b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 89 deletions.
35 changes: 6 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
# SP1 Contracts

## Update with New SP1 Version
This repository contains the smart contracts for verifying [SP1](https://github.com/succinctlabs/sp1) EVM proofs.

This section outlines the steps required to update the SP1 contracts repository with a new SP1 version. Follow these instructions to ensure the SP1 contracts are correctly updated and aligned with the latest version.
## For Developers: Integrate SP1 Contracts

This repository contains the EVM contracts for verifying SP1 PLONK EVM proofs.

1. Change the version tag in `Cargo.toml` to the target `sp1` version.
You can find more details on the contracts and how to install them in the contracts [`README`](./contracts/README.md).

```toml
[dependencies]
sp1-sdk = { git = "https://github.com/succinctlabs/sp1", tag = "<SP1_TAG>" }
```

2. Update `contracts/src` with the new verifier contracts.

```bash
cargo update

cargo run --bin artifacts
```

3. Change `VERSION` in both `SP1MockVerifier.sol` and `SP1Verifier.sol` to match the target `sp1` version tag.

```solidity
function VERSION() external pure returns (string memory) {
return "<SP1_TAG>";
}
```

4. Open a PR to commit the changes to `main`.
5. After merging to `main`, create a release tag with the same version as the `sp1` tag used.

## Miscellaneous
The SP1 Solidity contract artifacts are included in each release of `sp1`. You can see how these are included in the `sp1` repository [here](https://github.com/succinctlabs/sp1/blob/21455d318ae383b317c92e10709bbfc313d8f1df/recursion/gnark-ffi/src/plonk_bn254.rs#L57-L96).
## For Contributors

To update the SP1 contracts, please refer to the [`update`](./UPDATE_CONTRACTS.md) file.
35 changes: 35 additions & 0 deletions UPDATE_CONTRACTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# Update SP1 Contracts with New SP1 Version

This section outlines the steps required to update the SP1 contracts repository with a new SP1 version. Follow these instructions to ensure the SP1 contracts are correctly updated and aligned with the latest version.


1. Change the version tag in `Cargo.toml` to the target `sp1` version.

```toml
[dependencies]
sp1-sdk = { git = "https://github.com/succinctlabs/sp1", tag = "<SP1_TAG>" }
```

2. Update `contracts/src` with the new verifier contracts.

```bash
cargo update

cargo run --bin artifacts
```

3. Change `VERSION` in both `SP1MockVerifier.sol` and `SP1Verifier.sol` to match the target `sp1` version tag.

```solidity
function VERSION() external pure returns (string memory) {
return "<SP1_TAG>";
}
```

4. Open a PR to commit the changes to `main`.
5. After merging to `main`, create a release tag with the same version as the `sp1` tag used.

## Miscellaneous
The SP1 Solidity contract artifacts are included in each release of `sp1`. You can see how these are included in the `sp1` repository [here](https://github.com/succinctlabs/sp1/blob/21455d318ae383b317c92e10709bbfc313d8f1df/recursion/gnark-ffi/src/plonk_bn254.rs#L57-L96).

71 changes: 11 additions & 60 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,17 @@
## Foundry
# SP1 Contracts

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
This repository contains the smart contracts for verifying [SP1](https://github.com/succinctlabs/sp1) EVM proofs.

Foundry consists of:
## Overview
- [`SP1Verifier`](./src/SP1Verifier.sol): The main contract for verifying SP1 EVM proofs.
- [`SP1MockVerifier`](./src/SP1MockVerifier.sol): A mock contract for testing SP1 EVM proofs.
- [`ISP1Verifier`](./src/ISP1Verifier.sol): Interface for SP1Verifier.
- [`PlonkVerifier`](./src/PlonkVerifier.sol): Core logic for verifying Plonk EVM proofs.

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
## Development

## Documentation
Install these contracts for a Foundry project using `forge install`.

https://book.getfoundry.sh/

## Usage

### Build

```shell
$ forge build
```

### Test

```shell
$ forge test
```

### Format

```shell
$ forge fmt
```

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil

```shell
$ anvil
```

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```bash
forge install succinctlabs/sp1-contracts@<version>
```

0 comments on commit 2ca7f3b

Please sign in to comment.