mirror of
https://github.com/eth-act/ere.git
synced 2026-04-25 03:00:10 -04:00
Update Jolt to v0.3.0-alpha (#181)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
name = "ere-jolt-guest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
jolt = { git = "https://github.com/a16z/jolt", package = "jolt-sdk", tag = "v0.3.0-alpha" }
|
||||
ere-test-utils = { path = "../../../crates/test-utils" }
|
||||
|
||||
[features]
|
||||
guest = []
|
||||
|
||||
[dependencies]
|
||||
jolt = { package = "jolt-sdk", git = "https://github.com/a16z/jolt", rev = "55b9830a3944dde55d33a55c42522b81dd49f87a" }
|
||||
|
||||
[workspace]
|
||||
[workspace]
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#![cfg_attr(feature = "guest", no_std)]
|
||||
|
||||
#[jolt::provable]
|
||||
fn fib(n: u32) -> u128 {
|
||||
let mut a: u128 = 0;
|
||||
let mut b: u128 = 1;
|
||||
let mut sum: u128;
|
||||
for _ in 1..n {
|
||||
sum = a + b;
|
||||
a = b;
|
||||
b = sum;
|
||||
}
|
||||
|
||||
b
|
||||
}
|
||||
@@ -1,5 +1,33 @@
|
||||
#![cfg_attr(feature = "guest", no_std)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use guest::*;
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use ere_test_utils::{
|
||||
guest::Platform,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
static mut INPUT: Vec<u8> = Vec::new();
|
||||
static mut OUTPUT: Vec<u8> = Vec::new();
|
||||
|
||||
struct JoltPlatform;
|
||||
|
||||
impl Platform for JoltPlatform {
|
||||
fn read_input() -> Vec<u8> {
|
||||
unsafe { mem::take(&mut INPUT) }
|
||||
}
|
||||
|
||||
fn write_output(output: &[u8]) {
|
||||
unsafe { mem::replace(&mut OUTPUT, output.to_vec()) };
|
||||
}
|
||||
}
|
||||
|
||||
#[jolt::provable(guest_only)]
|
||||
fn main(input: Vec<u8>) -> Vec<u8> {
|
||||
unsafe { mem::replace(&mut INPUT, input) };
|
||||
BasicProgram::run::<JoltPlatform>();
|
||||
unsafe { mem::take(&mut OUTPUT) }
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
name = "addition_no_std"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
jolt = { git = "https://github.com/a16z/jolt", package = "jolt-sdk", tag = "v0.3.0-alpha" }
|
||||
|
||||
[features]
|
||||
guest = []
|
||||
|
||||
[dependencies]
|
||||
jolt-sdk = { git = "https://github.com/a16z/jolt", rev = "55b9830a3944dde55d33a55c42522b81dd49f87a" }
|
||||
|
||||
[workspace]
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#![cfg_attr(feature = "guest", no_std)]
|
||||
#![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;
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
#[jolt::provable]
|
||||
fn foo() {
|
||||
#[jolt::provable(guest_only)]
|
||||
fn main() {
|
||||
let a: AtomicU16 = core::hint::black_box(AtomicU16::new(5));
|
||||
let b: AtomicU16 = core::hint::black_box(AtomicU16::new(7));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user