Skip to content

Commit

Permalink
ci: cargo check build on targets (#115)
Browse files Browse the repository at this point in the history
## Overview

Fixes #114
  • Loading branch information
tuxcanfly authored Jan 30, 2025
1 parent f6a1e0d commit 3b70c47
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 45 deletions.
12 changes: 12 additions & 0 deletions .github/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: setup

runs:
using: composite
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"
- name: Install nightly toolchain
shell: bash
run: rustup update 1.81 && rustup default 1.81 && rustup component add rustfmt && rustup component add clippy
- name: Setup Protoc
uses: taiki-e/install-action@protoc
111 changes: 111 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: rust

on:
push:
branches: [main]
pull_request:

jobs:
lint-celestia-prover:
name: lint-celestia-prover
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: "Set up environment"
uses: ./.github/setup

- name: Install SP1 toolchain
shell: bash
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up --version 3.4.0 --token ${{ secrets.GITHUB_TOKEN }}
~/.sp1/bin/cargo-prove prove --version
rustc +succinct --version
- name: Run cargo fmt
run: cargo fmt --check
working-directory: ./provers/celestia-prover/

lint-blevm:
name: lint-blevm
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: "Set up environment"
uses: ./.github/setup

- name: Install SP1 toolchain
shell: bash
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up --token ${{ secrets.GITHUB_TOKEN }}
~/.sp1/bin/cargo-prove prove --version
rustc +succinct --version
- name: Run cargo fmt
run: cargo fmt --check
working-directory: ./provers/blevm/

build-blevm:
name: build-blevm
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: "Set up environment"
uses: ./.github/setup
- name: Install SP1 toolchain
shell: bash
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up --token ${{ secrets.GITHUB_TOKEN }}
~/.sp1/bin/cargo-prove prove --version
rustc +succinct --version
- name: Build
run: cargo build --release --locked
working-directory: ./provers/blevm/blevm/

build-blevm-script:
name: build-blevm-script
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: "Set up environment"
uses: ./.github/setup
- name: Install SP1 toolchain
shell: bash
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up --token ${{ secrets.GITHUB_TOKEN }}
~/.sp1/bin/cargo-prove prove --version
rustc +succinct --version
- name: Build
run: cargo build --release --locked
working-directory: ./provers/blevm/script/

build-celestia-prover:
name: build-celestia-prover
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: "Set up environment"
uses: ./.github/setup
- name: Install SP1 toolchain
shell: bash
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up --version 3.4.0 --token ${{ secrets.GITHUB_TOKEN }}
~/.sp1/bin/cargo-prove prove --version
rustc +succinct --version
- name: Build
run: cargo build --release --locked
working-directory: ./provers/celestia-prover/
10 changes: 4 additions & 6 deletions programs/sp1/mock-membership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ pub fn membership(
request_iter: impl Iterator<Item = (Vec<Vec<u8>>, Vec<u8>)>,
) -> MembershipOutput {
let kv_pairs = request_iter
.map(|(path, value)| {
KVPair {
path: path.into_iter().map(Into::into).collect(),
value: value.into(),
}
.map(|(path, value)| KVPair {
path: path.into_iter().map(Into::into).collect(),
value: value.into(),
})
.collect();

MembershipOutput {
commitmentRoot: app_hash.into(),
kvPairs: kv_pairs,
}
}
}
15 changes: 7 additions & 8 deletions programs/sp1/mock-update-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
sp1_zkvm::entrypoint!(main);

use alloy_sol_types::SolValue;
use ibc_client_tendermint_types::{Header, ConsensusState};
use ibc_client_tendermint_types::{ConsensusState, Header};
use ibc_eureka_solidity_types::sp1_ics07::{
IICS07TendermintMsgs::{
ClientState as SolClientState, ConsensusState as SolConsensusState,
},
IICS07TendermintMsgs::{ClientState as SolClientState, ConsensusState as SolConsensusState},
IUpdateClientMsgs::UpdateClientOutput,
};

Expand All @@ -29,9 +27,10 @@ pub fn main() {
// input 1: the client state
let client_state = bincode::deserialize::<SolClientState>(&encoded_1).unwrap();
// input 2: the trusted consensus state
let trusted_consensus_state: ConsensusState = bincode::deserialize::<SolConsensusState>(&encoded_2)
.unwrap()
.into();
let trusted_consensus_state: ConsensusState =
bincode::deserialize::<SolConsensusState>(&encoded_2)
.unwrap()
.into();
// input 3: the proposed header
let proposed_header = serde_cbor::from_slice::<Header>(&encoded_3).unwrap();
// input 4: time
Expand All @@ -52,4 +51,4 @@ pub fn main() {
};

sp1_zkvm::io::commit_slice(&output.abi_encode());
}
}
1 change: 0 additions & 1 deletion provers/blevm/blevm-aggregator/src/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bincode;
use serde::{de::DeserializeOwned, Deserialize, Serialize};

/// A buffer of serializable/deserializable objects.
Expand Down
13 changes: 4 additions & 9 deletions provers/blevm/blevm-prover/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bincode;
use celestia_rpc::{BlobClient, Client, HeaderClient};
use celestia_types::nmt::NamespacedHash;
use celestia_types::AppVersion;
Expand Down Expand Up @@ -59,7 +58,7 @@ impl CelestiaClient {
) -> Result<(Blob, ExtendedHeader), Box<dyn Error>> {
let blob_from_chain = self
.client
.blob_get(height, self.namespace, blob.commitment.clone())
.blob_get(height, self.namespace, blob.commitment)
.await
.map_err(|e| format!("Failed getting blob: {}", e))?;

Expand All @@ -79,7 +78,7 @@ impl CelestiaClient {
) -> Result<Vec<NamespaceProof>, Box<dyn Error>> {
Ok(self
.client
.blob_get_proof(height, self.namespace, blob.commitment.clone())
.blob_get_proof(height, self.namespace, blob.commitment)
.await
.map_err(|e| format!("Failed getting NMT proofs: {}", e))?)
}
Expand Down Expand Up @@ -107,7 +106,7 @@ pub fn generate_header_proofs(

pub fn prepare_header_fields(header: &ExtendedHeader) -> Vec<Vec<u8>> {
vec![
Protobuf::<RawConsensusVersion>::encode_vec(header.header.version.clone()),
Protobuf::<RawConsensusVersion>::encode_vec(header.header.version),
header.header.chain_id.clone().encode_vec(),
header.header.height.encode_vec(),
header.header.time.encode_vec(),
Expand Down Expand Up @@ -187,11 +186,7 @@ impl BlockProver {
// Create blob from L2 block data
let block: ClientExecutorInput = bincode::deserialize(&input.l2_block_data)?;
let block_bytes = bincode::serialize(&block.current_block)?;
let blob = Blob::new(
self.celestia_client.namespace.clone(),
block_bytes,
AppVersion::V3,
)?;
let blob = Blob::new(self.celestia_client.namespace, block_bytes, AppVersion::V3)?;

// Get blob and header from Celestia
let (blob_from_chain, header) = self
Expand Down
12 changes: 2 additions & 10 deletions provers/blevm/blevm/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#![no_main]
sp1_zkvm::entrypoint!(main);

use celestia_types::nmt::{NamespaceProof, NamespacedHashExt};
use celestia_types::{nmt::Namespace, AppVersion, Blob};
use celestia_types::{
nmt::{NamespaceProof, NamespacedHashExt},
ExtendedHeader,
};
use nmt_rs::simple_merkle::tree::MerkleHash;
use std::io::Read;
//use nmt_rs::{simple_merkle::proof::Proof, TmSha2Hasher};
use blevm_common::BlevmOutput;
use nmt_rs::{simple_merkle::proof::Proof, NamespacedHash, TmSha2Hasher};
use reth_primitives::Block;
use rsp_client_executor::{
io::ClientExecutorInput, ChainVariant, ClientExecutor, EthereumVariant, CHAIN_ID_ETH_MAINNET,
CHAIN_ID_LINEA_MAINNET, CHAIN_ID_OP_MAINNET,
};
use rsp_client_executor::{io::ClientExecutorInput, ClientExecutor, EthereumVariant};
use tendermint::Hash as TmHash;
use tendermint_proto::Protobuf;

Expand Down
4 changes: 2 additions & 2 deletions provers/blevm/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
version = "0.1.0"
name = "blevm-script"
edition = "2021"
default-run = "blevm"
default-run = "blevm-script"

[[bin]]
name = "blevm"
name = "blevm-script"
path = "src/bin/main.rs"

[dependencies]
Expand Down
7 changes: 2 additions & 5 deletions provers/celestia-prover/src/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ pub struct UpdateClientProgram;
/// SP1 ICS07 Tendermint verify (non)membership program.
pub struct MembershipProgram;


impl SP1Program for UpdateClientProgram {
const ELF: &'static [u8] =
include_bytes!("../../../elf/mock-update-client-elf");
const ELF: &'static [u8] = include_bytes!("../../../elf/mock-update-client-elf");
}

impl SP1Program for MembershipProgram {
const ELF: &'static [u8] =
include_bytes!("../../../elf/mock-membership-elf");
const ELF: &'static [u8] = include_bytes!("../../../elf/mock-membership-elf");
}
5 changes: 1 addition & 4 deletions provers/celestia-prover/src/prover.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Prover for SP1 ICS07 Tendermint programs.
use crate::programs::{
MembershipProgram, SP1Program,
UpdateClientProgram,
};
use crate::programs::{MembershipProgram, SP1Program, UpdateClientProgram};
use ibc_client_tendermint_types::Header;
use ibc_core_commitment_types::merkle::MerkleProof;
use ibc_eureka_solidity_types::sp1_ics07::{
Expand Down

0 comments on commit 3b70c47

Please sign in to comment.