Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIT-2609] Compute and validate wasmModuleRoot while building docker #2479

Merged
merged 7 commits into from
Jul 15, 2024
Merged
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
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ COPY --from=node-builder /workspace/target/bin/nitro /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/relay /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/nitro-val /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/seq-coordinator-manager /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/prover /usr/local/bin/
COPY --from=machine-versions /workspace/machines /home/user/target/machines
COPY ./scripts/validate-wasm-module-root.sh .
RUN ./validate-wasm-module-root.sh /home/user/target/machines /usr/local/bin/prover
USER root
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
Expand Down
15 changes: 15 additions & 0 deletions arbitrator/prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ struct Opts {
#[structopt(long)]
/// print modules to the console
print_modules: bool,
#[structopt(long)]
/// print wasm module root to the console
print_wasmmoduleroot: bool,
/// profile output instead of generting proofs
#[structopt(short = "p", long)]
profile_run: bool,
Expand Down Expand Up @@ -122,6 +125,18 @@ const DELAYED_HEADER_LEN: usize = 112; // also in test-case's host-io.rs & contr
fn main() -> Result<()> {
let opts = Opts::from_args();

if opts.print_wasmmoduleroot {
match Machine::new_from_wavm(&opts.binary) {
Ok(mach) => {
println!("0x{}", mach.get_modules_root());
return Ok(());
}
Err(err) => {
eprintln!("Error loading binary: {err}");
return Err(err);
}
}
}
let mut inbox_contents = HashMap::default();
let mut inbox_position = opts.inbox_position;
let mut delayed_position = opts.delayed_inbox_position;
Expand Down
16 changes: 16 additions & 0 deletions scripts/validate-wasm-module-root.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e

MACHINES_DIR=$1
PROVER=$2

for machine in "$MACHINES_DIR"/*/ ; do
if [ -d "$machine" ]; then
expectedWasmModuleRoot=$(cat "$machine/module-root.txt")
actualWasmModuleRoot=$(cd "$machine" && "$PROVER" machine.wavm.br --print-wasmmoduleroot)
if [ "$expectedWasmModuleRoot" != "$actualWasmModuleRoot" ]; then
echo "Error: Expected module root $expectedWasmModuleRoot but found $actualWasmModuleRoot in $machine"
exit 1
fi
fi
done
Loading