Offchain scaffolding.
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
onchain/cache/
|
onchain/cache/
|
||||||
onchain/out/
|
onchain/out/
|
||||||
|
|
||||||
|
offchain/target/
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
# ... any other dependencies we need
|
# ... any other dependencies we need
|
||||||
solc
|
solc
|
||||||
|
cargo
|
||||||
|
rustc
|
||||||
];
|
];
|
||||||
|
|
||||||
# Decorative prompt override so we know when we're in a dev shell
|
# Decorative prompt override so we know when we're in a dev shell
|
||||||
|
|||||||
Generated
+1729
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "offchain"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
revm = "18.0.0"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum Expr {
|
||||||
|
IntLiteral(i32),
|
||||||
|
Instruction(InstructionKind, Vec<Expr>),
|
||||||
|
// You might have a variant for sublists if needed,
|
||||||
|
// or keep it all in the same structure.
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum InstructionKind {
|
||||||
|
// e.g. Plus, Minus, Mult, etc.
|
||||||
|
Plus,
|
||||||
|
Minus,
|
||||||
|
Mult,
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
use super::ast::{Expr, InstructionKind};
|
||||||
|
|
||||||
|
pub fn ast_to_bytecode(expr: &Expr) -> Vec<u8> {
|
||||||
|
// for now, just a stub
|
||||||
|
// eventually we produce push3 tokens
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
use super::ast::{Expr};
|
||||||
|
|
||||||
|
pub fn bytecode_to_ast(data: &[u8]) -> Expr {
|
||||||
|
// parse tokens, produce expr
|
||||||
|
// stub for now
|
||||||
|
Expr::IntLiteral(0)
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
pub mod ast;
|
||||||
|
pub mod bytecode_generator;
|
||||||
|
pub mod bytecode_parser;
|
||||||
|
|
||||||
|
// In the future, we'll define or `pub use` them.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pub mod revm_runner;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
pub fn run_in_revm(bytecode: &[u8]) -> Result<Vec<i64>, String> {
|
||||||
|
// set up revm, load the code, call push3
|
||||||
|
// for now just stub
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use crate::compiler::ast::{Expr};
|
||||||
|
|
||||||
|
pub fn crossover(a: &Expr, b: &Expr) -> (Expr, Expr) {
|
||||||
|
// stub
|
||||||
|
(a.clone(), b.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mutate(expr: &mut Expr) {
|
||||||
|
// stub
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
pub mod population;
|
||||||
|
pub mod genetic_ops;
|
||||||
|
// pub mod fitness;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_dummy() {
|
||||||
|
assert_eq!(2+2, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Individual {
|
||||||
|
pub fitness: f64,
|
||||||
|
// your Expr or bytecode or both
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Population {
|
||||||
|
pub individuals: Vec<Individual>,
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
mod compiler;
|
||||||
|
mod gp;
|
||||||
|
mod evm_integration;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Welcome to My GP System CLI");
|
||||||
|
// e.g., parse arguments, run a small demonstration?
|
||||||
|
// For now just a stub.
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user