From 2ca7f3b36b43423492012c5f7be01b31d0d5b3dc Mon Sep 17 00:00:00 2001 From: Ratan Kaliani Date: Wed, 29 May 2024 15:23:50 -0700 Subject: [PATCH] docs: contracts (#3) * contracts readme * foundry project * docs: README --- README.md | 35 ++++------------------ UPDATE_CONTRACTS.md | 35 ++++++++++++++++++++++ contracts/README.md | 71 +++++++-------------------------------------- 3 files changed, 52 insertions(+), 89 deletions(-) create mode 100644 UPDATE_CONTRACTS.md diff --git a/README.md b/README.md index a4631b3..0ee4918 100644 --- a/README.md +++ b/README.md @@ -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 = "" } -``` - -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 ""; -} -``` - -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. \ No newline at end of file diff --git a/UPDATE_CONTRACTS.md b/UPDATE_CONTRACTS.md new file mode 100644 index 0000000..cb65c3e --- /dev/null +++ b/UPDATE_CONTRACTS.md @@ -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 = "" } +``` + +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 ""; +} +``` + +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). + diff --git a/contracts/README.md b/contracts/README.md index 9265b45..af90e3c 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -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 --private-key -``` - -### Cast - -```shell -$ cast -``` - -### Help - -```shell -$ forge --help -$ anvil --help -$ cast --help +```bash +forge install succinctlabs/sp1-contracts@ ```