jolt: Guest program compilation with stock rust compiler. (#116)

This commit is contained in:
rodiazet
2025-08-30 00:43:27 +02:00
committed by GitHub
parent 664dc62c9f
commit c772b1ff2c
9 changed files with 271 additions and 25 deletions

View File

@@ -0,0 +1,11 @@
[package]
name = "addition_no_std"
edition = "2021"
[features]
guest = []
[dependencies]
jolt-sdk = { git = "https://github.com/a16z/jolt", rev = "55b9830a3944dde55d33a55c42522b81dd49f87a" }
[workspace]

View File

@@ -0,0 +1,26 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]
extern crate alloc;
use alloc::vec::Vec;
use core::sync::atomic::Ordering;
use core::sync::atomic::AtomicU16;
use jolt_sdk as jolt;
#[jolt::provable]
fn foo() {
let a: AtomicU16 = core::hint::black_box(AtomicU16::new(5));
let b: AtomicU16 = core::hint::black_box(AtomicU16::new(7));
if a.load(Ordering::SeqCst) + b.load(Ordering::SeqCst) != 12 {
panic!("Something went wrong!");
}
let mut v: Vec<AtomicU16> = Vec::new();
v.push(AtomicU16::new(5));
v.push(AtomicU16::new(7));
if v[0].load(Ordering::SeqCst) + v[1].load(Ordering::SeqCst) != 12 {
panic!("Something went wrong!");
}
}