Skip to content

Commit

Permalink
feat: v4 (#73)
Browse files Browse the repository at this point in the history
* feat: v4

* wip: add

* v4 changes

* fix: proof bytes

* wip

* fix

* add

* add

* feat: update

* add

* add

* feat: update

* add

* fix

* add

* add

* add

---------

Co-authored-by: jtguibas <[email protected]>
  • Loading branch information
ratankaliani and jtguibas authored Jan 8, 2025
1 parent 047a72b commit e396ecb
Show file tree
Hide file tree
Showing 18 changed files with 1,932 additions and 1,780 deletions.
3,390 changes: 1,758 additions & 1,632 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ itertools = "0.10.5"
alloy = { version = "0.8.0", features = ["full"] }
chrono = "0.4.39"


sp1-sdk = "3.0.0"
sp1-build = "3.0.0"
sp1-sdk = "4.0.0-rc.8"
sp1-build = "4.0.0-rc.8"

reqwest = { version = "0.11.20", features = ["json"] }
futures = "0.3.30"
Expand Down Expand Up @@ -56,6 +55,6 @@ sp-core = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "pol
sp-io = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch-5" }
sp-runtime = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch-5" }
sp-std = { git = "https://github.com/availproject/polkadot-sdk.git", tag = "polkadot-1.7.1-patch-5" }
ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" }
sha2-v0-9-9 = { git = "https://github.com/sp1-patches/RustCrypto-hashes-fork", package = "sha2", branch = "patch-sha2-v0.9.9" }
sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" }

sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", tag = "patch-0.10.8-sp1-4.0.0-rc.3" }
curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", tag = "patch-4.1.1-sp1-4.0.0-rc.3" }
10 changes: 6 additions & 4 deletions book/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ Here's how to deploy an SP1 Vector contract for an Avail chain.
export PRIVATE_KEY=<PRIVATE_KEY>
# Optional
# If you're using the Succinct network, set SP1_PROVER to "network". Otherwise, set it to "local" or "mock".
export SP1_PROVER={network|local|mock}
# Only required if SP1_PROVER is set "network".
export SP1_PRIVATE_KEY=<SP1_PRIVATE_KEY>
# If you're generating proofs on the Succinct Network, set NETWORK_PRIVATE_KEY to the private key of the account you want to use.
export NETWORK_PRIVATE_KEY=<NETWORK_PRIVATE_KEY>
# If you're using a custom endpoint, set NETWORK_RPC_URL to the URL of the endpoint you want to use.
export NETWORK_RPC_URL=<NETWORK_RPC_URL>
# If you're generating proofs in mock mode, set SP1_PROVER to "mock".
export SP1_PROVER={mock}
```

5. Run the SP1 Vector operator to update the LC continuously.
Expand Down
4 changes: 2 additions & 2 deletions book/reproducible-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Then build the binaries:
```bash
cd program

# Builds the SP1 Vector binary using the corresponding Docker tag, output directory and ELF name.
cargo prove build --docker --tag v3.0.0 --output-directory ../script --elf-name sp1-vector-docker
# Builds the SP1 Vector binary using the corresponding Docker tag and ELF name.
cargo prove build --docker --tag v3.0.0 --elf-name vector-elf
```

Now, verify the binaries by confirming the output of `vkey` matches the vkeys on the contract. The `vkey` program outputs the verification key
Expand Down
29 changes: 29 additions & 0 deletions contracts/script/UpdateVkey.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;

import {stdJson} from "forge-std/StdJson.sol";
import {SP1Vector} from "../src/SP1Vector.sol";
import {BaseScript} from "./Base.s.sol";

// Required environment variables:
// - CHAINS (comma separated list of chain names)
// - CONTRACT_ADDRESS_{CHAIN_ID}

contract UpdateVkeyScript is BaseScript {
using stdJson for string;

function setUp() public {}

string internal constant KEY = "UpdateVkey";

/// Reads CONTRACT_ADDRESS_<CHAIN_ID> from the environment variables and updates the SP1 Verifier and program vkey.
function run() external multichain(KEY) broadcaster {
string memory contractAddressKey = string.concat("CONTRACT_ADDRESS_", vm.toString(block.chainid));
address existingProxyAddress = vm.envAddress(contractAddressKey);

SP1Vector sp1Vector = SP1Vector(address(existingProxyAddress));

// v4 program vkey
sp1Vector.updateVectorXProgramVkey(0x0085e1f9e1bcc361ba6edc00209f453addcbcaf71c1e63d174472f8df5e56875);
}
}
1 change: 0 additions & 1 deletion contracts/script/Upgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {BaseScript} from "./Base.s.sol";
// - CHAINS (comma separated list of chain names)
// - CONTRACT_ADDRESS_{CHAIN_ID}
// - SP1_VECTOR_PROGRAM_VKEY
// - SP1_VERIFIER_ADDRESS

contract UpgradeScript is BaseScript {
using stdJson for string;
Expand Down
Binary file removed elf/sp1-vector-docker
Binary file not shown.
Binary file added elf/vector-elf
Binary file not shown.
2 changes: 1 addition & 1 deletion program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
[dependencies]
sp1-vector-primitives.workspace = true
alloy-sol-types.workspace = true
sp1-zkvm = "3.0.0"
sp1-zkvm = "4.0.0-rc.8"
2 changes: 1 addition & 1 deletion render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ services:
rootDir: script
buildCommand: rm -rf build.rs && cargo build --bin operator --release
startCommand: cargo run --bin operator --release
autoDeploy: true
autoDeploy: false
envVars:
- key: CHAIN_ID
value: 1
Expand Down
7 changes: 6 additions & 1 deletion script/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ AVAIL_CHAIN_ID={hex, turing, mainnet}
VECTORX_QUERY_URL=https://vectorx-query.succinct.xyz

# SP1 Config
NETWORK_PRIVATE_KEY=

# Optional
NETWORK_RPC_URL=

# If in mock mode, set SP1_PROVER to "mock".
SP1_PROVER=
SP1_PRIVATE_KEY=

## If set to true, fill out the KMS config. Else, fill out the local relayer config.
USE_KMS_RELAYER=
Expand Down
10 changes: 6 additions & 4 deletions script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ tokio = { workspace = true }
dotenv = { workspace = true }
avail-subxt = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
clap = { workspace = true, features = ["derive", "env"] }
reqwest = { workspace = true }
futures = { workspace = true }

alloy = { workspace = true }
serde_json = { workspace = true }
serde = { workspace = true }
reqwest = { workspace = true }
futures = { workspace = true }
chrono = { workspace = true }
csv = "1.3.1"
rand = "0.8.5"
sp1-build = { workspace = true }

[build-dependencies]
sp1-build = { workspace = true }
sp1-build = { workspace = true }
4 changes: 2 additions & 2 deletions script/bin/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use avail_subxt::config::Header;
use clap::Parser;
use services::input::RpcDataFetcher;
use sp1_sdk::{HashableKey, ProverClient};
use sp1_sdk::{HashableKey, Prover, ProverClient};
use sp1_vectorx_script::SP1_VECTOR_ELF;

#[derive(Parser, Debug, Clone)]
Expand All @@ -20,7 +20,7 @@ const HEADER_RANGE_COMMITMENT_TREE_SIZE: u32 = 1024;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let fetcher = RpcDataFetcher::new().await;
let client = ProverClient::new();
let client = ProverClient::builder().mock().build();
let (_pk, vk) = client.setup(SP1_VECTOR_ELF);

let args = GenesisArgs::parse();
Expand Down
Loading

0 comments on commit e396ecb

Please sign in to comment.