Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ COPY arbitrator/bench/Cargo.toml arbitrator/bench/
COPY arbitrator/jit/Cargo.toml arbitrator/jit/
COPY arbitrator/stylus/Cargo.toml arbitrator/stylus/
COPY arbitrator/tools/wasmer arbitrator/tools/wasmer
COPY arbitrator/wasm-libraries/forward arbitrator/wasm-libraries/forward
COPY arbitrator/wasm-libraries/user-host-trait/Cargo.toml arbitrator/wasm-libraries/user-host-trait/Cargo.toml
RUN bash -c 'mkdir arbitrator/{prover,jit,stylus}/src arbitrator/wasm-libraries/user-host-trait/src'
RUN echo "fn test() {}" > arbitrator/jit/src/lib.rs && \
Expand Down
9 changes: 9 additions & 0 deletions arbitrator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions arbitrator/prover/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/forward_stub.wat
3 changes: 3 additions & 0 deletions arbitrator/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ lru = "0.12.3"
once_cell = "1.19.0"
enum-iterator = "2.0.1"

[build-dependencies]
forward = { path = "../wasm-libraries/forward" }

[dev-dependencies]
criterion = { version = "0.5.0", features = ["html_reports"] }
rand = "0.8.4"
Expand Down
10 changes: 10 additions & 0 deletions arbitrator/prover/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use std::fs::File;
use std::io::Write;

fn main() {
println!("cargo:rerun-if-changed=../wasm-libraries/forward");
let mut out = Vec::new();
forward::forward_stub(&mut out).expect("Failed to write stub");
let mut file = File::create("src/forward_stub.wat").unwrap();
file.write_all(&out).unwrap();
}
6 changes: 4 additions & 2 deletions arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,10 @@ lazy_static! {
static ref USER_IMPORTS: HashMap<String, AvailableImport> = {
let mut imports = HashMap::default();

let forward = include_bytes!("../../../target/machines/latest/forward_stub.wasm");
let forward = binary::parse(forward, Path::new("forward")).unwrap();
let forward = include_bytes!("forward_stub.wat");
let forward = wat::parse_bytes(forward).expect("failed to parse forward_stub.wat");
let forward = binary::parse(&forward, Path::new("forward"))
.expect("failed to parse forward_stub.wasm");

for (name, &(export, kind)) in &forward.exports {
if kind == ExportKind::Func {
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/prover/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn reject_ambiguous_imports() {

#[test]
pub fn test_compress() -> Result<()> {
let data = include_bytes!("../../../target/machines/latest/forward_stub.wasm");
let data = include_bytes!("forward_stub.wat");
let mut last = vec![];

for dict in [Dictionary::Empty, Dictionary::StylusProgram] {
Expand Down
1 change: 1 addition & 0 deletions arbitrator/wasm-libraries/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions arbitrator/wasm-libraries/forward/src/bin/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2022-2024, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md

use eyre::Result;
use forward::{forward, forward_stub};
use std::{fs::File, path::PathBuf};
use structopt::StructOpt;

#[derive(StructOpt)]
#[structopt(name = "arbitrator-prover")]
struct Opts {
#[structopt(long)]
path: PathBuf,
#[structopt(long)]
stub: bool,
}

fn main() -> Result<()> {
let opts = Opts::from_args();
let file = &mut File::options()
.create(true)
.write(true)
.truncate(true)
.open(opts.path)?;

match opts.stub {
true => forward_stub(file),
false => forward(file),
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2022-2024, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md

use std::io::Write;

use eyre::Result;
use std::{fs::File, io::Write, path::PathBuf};
use structopt::StructOpt;

/// order matters!
const HOSTIOS: [[&str; 3]; 42] = [
Expand Down Expand Up @@ -51,30 +51,7 @@ const HOSTIOS: [[&str; 3]; 42] = [
["pay_for_memory_grow", "i32", ""],
];

#[derive(StructOpt)]
#[structopt(name = "arbitrator-prover")]
struct Opts {
#[structopt(long)]
path: PathBuf,
#[structopt(long)]
stub: bool,
}

fn main() -> Result<()> {
let opts = Opts::from_args();
let file = &mut File::options()
.create(true)
.write(true)
.truncate(true)
.open(opts.path)?;

match opts.stub {
true => forward_stub(file),
false => forward(file),
}
}

fn forward(file: &mut File) -> Result<()> {
pub fn forward<W: Write>(file: &mut W) -> Result<()> {
macro_rules! wln {
($($text:tt)*) => {
writeln!(file, $($text)*)?;
Expand Down Expand Up @@ -149,7 +126,7 @@ fn forward(file: &mut File) -> Result<()> {
Ok(())
}

fn forward_stub(file: &mut File) -> Result<()> {
pub fn forward_stub<W: Write>(file: &mut W) -> Result<()> {
macro_rules! wln {
($($text:tt)*) => {
writeln!(file, $($text)*)?;
Expand Down