mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +00:00
Util for assembling EVM code to hex (#586)
This is just for debugging the kernel. It's fully disposable.
This commit is contained in:
parent
34e73db42b
commit
e3834a5335
@ -10,6 +10,7 @@ plonky2_util = { path = "../util" }
|
|||||||
anyhow = "1.0.40"
|
anyhow = "1.0.40"
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
ethereum-types = "0.13.1"
|
ethereum-types = "0.13.1"
|
||||||
|
hex = { version = "0.4.3", optional = true }
|
||||||
itertools = "0.10.3"
|
itertools = "0.10.3"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
pest = "2.1.3"
|
pest = "2.1.3"
|
||||||
@ -18,3 +19,10 @@ rayon = "1.5.1"
|
|||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
rand_chacha = "0.3.1"
|
rand_chacha = "0.3.1"
|
||||||
keccak-rust = { git = "https://github.com/npwardberkeley/keccak-rust" }
|
keccak-rust = { git = "https://github.com/npwardberkeley/keccak-rust" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
asmtools = ["hex"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "assemble"
|
||||||
|
required-features = ["asmtools"]
|
||||||
|
|||||||
13
evm/src/bin/assemble.rs
Normal file
13
evm/src/bin/assemble.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
|
use hex::encode;
|
||||||
|
use plonky2_evm::cpu::kernel::assemble_to_bytes;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut args = env::args();
|
||||||
|
args.next();
|
||||||
|
let file_contents: Vec<_> = args.map(|path| fs::read_to_string(path).unwrap()).collect();
|
||||||
|
let assembled = assemble_to_bytes(&file_contents[..]);
|
||||||
|
println!("{}", encode(&assembled));
|
||||||
|
}
|
||||||
@ -13,7 +13,7 @@ const BYTES_PER_OFFSET: u8 = 3;
|
|||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
pub struct Kernel {
|
pub struct Kernel {
|
||||||
code: Vec<u8>,
|
pub code: Vec<u8>,
|
||||||
global_labels: HashMap<String, usize>,
|
global_labels: HashMap<String, usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,3 +3,14 @@ mod assembler;
|
|||||||
mod ast;
|
mod ast;
|
||||||
mod opcodes;
|
mod opcodes;
|
||||||
mod parser;
|
mod parser;
|
||||||
|
|
||||||
|
use assembler::assemble;
|
||||||
|
use parser::parse;
|
||||||
|
|
||||||
|
/// Assemble files, outputting bytes.
|
||||||
|
/// This is for debugging the kernel only.
|
||||||
|
pub fn assemble_to_bytes(files: &[String]) -> Vec<u8> {
|
||||||
|
let parsed_files: Vec<_> = files.iter().map(|f| parse(f)).collect();
|
||||||
|
let kernel = assemble(parsed_files);
|
||||||
|
kernel.code
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user