Skip to content

Commit

Permalink
Use Trace::length()
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Feb 20, 2024
1 parent eef2453 commit f854979
Show file tree
Hide file tree
Showing 27 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl Prover for WorkProver {

// Our public inputs consist of the first and last value in the execution trace.
fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
PublicInputs {
start: trace.get(0, 0),
result: trace.get(0, last_step),
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(self.sequence_length);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib2/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
trace.get(1, last_step)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(self.sequence_length);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib8/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
trace.get(1, last_step)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib_small/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(self.sequence_length);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib_small/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
trace.get(1, last_step)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/mulfib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(sequence_length);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/mulfib2/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
trace.get(0, last_step)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/mulfib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(sequence_length);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/mulfib8/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
trace.get(6, last_step)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/lamport/aggregate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(&self.messages, &self.signatures);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/lamport/threshold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(&self.pub_key, self.message, &self.signatures);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/merkle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(self.value, &self.path, self.index);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/merkle/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
PublicInputs {
tree_root: [trace.get(0, last_step), trace.get(1, last_step)],
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/rescue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(self.seed, self.chain_length);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/rescue/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
PublicInputs {
seed: [trace.get(0, 0), trace.get(1, 0)],
result: [trace.get(0, last_step), trace.get(1, last_step)],
Expand Down
2 changes: 1 addition & 1 deletion examples/src/rescue_raps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = prover.build_trace(&self.seeds, &self.permuted_seeds, self.result);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/rescue_raps/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
PublicInputs {
result: [
[trace.get(0, last_step), trace.get(1, last_step)],
Expand Down
2 changes: 1 addition & 1 deletion examples/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn print_trace<E: StarkField>(
let trace_width = trace.width();

let mut state = vec![E::ZERO; trace_width];
for i in 0..trace.info().length() {
for i in 0..trace.length() {
if (i.wrapping_sub(offset)) % multiples_of != 0 {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/vdf/exempt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = VdfProver::<H>::build_trace(self.seed, self.num_steps + 1);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/vdf/exempt/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
fn get_pub_inputs(&self, trace: &Self::Trace) -> VdfInputs {
// the result is read from the second to last step because the last last step contains
// garbage
let second_to_last_step = trace.info().length() - 2;
let second_to_last_step = trace.length() - 2;
VdfInputs {
seed: trace.get(0, 0),
result: trace.get(0, second_to_last_step),
Expand Down
2 changes: 1 addition & 1 deletion examples/src/vdf/regular/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ where
info_span!("generate_execution_trace", num_cols = TRACE_WIDTH, steps = field::Empty)
.in_scope(|| {
let trace = VdfProver::<H>::build_trace(self.seed, self.num_steps);
tracing::Span::current().record("steps", trace.info().length());
tracing::Span::current().record("steps", trace.length());
trace
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/vdf/regular/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
DefaultConstraintEvaluator<'a, Self::Air, E>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> VdfInputs {
let last_step = trace.info().length() - 1;
let last_step = trace.length() - 1;
VdfInputs {
seed: trace.get(0, 0),
result: trace.get(0, last_step),
Expand Down
6 changes: 3 additions & 3 deletions prover/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub trait Trace: Sized {

// first, check assertions against the main segment of the execution trace
for assertion in air.get_assertions() {
assertion.apply(self.info().length(), |step, value| {
assertion.apply(self.length(), |step, value| {
assert!(
value == self.main_segment().get(assertion.column(), step),
"trace does not satisfy assertion main_trace({}, {}) == {}",
Expand All @@ -125,7 +125,7 @@ pub trait Trace: Sized {
}

// get the matrix and verify the assertion against it
assertion.apply(self.info().length(), |step, value| {
assertion.apply(self.length(), |step, value| {
assert!(
value == aux_segments[segment_idx].get(column_idx, step),
"trace does not satisfy assertion aux_trace({}, {}) == {}",
Expand Down Expand Up @@ -157,7 +157,7 @@ pub trait Trace: Sized {

// we check transition constraints on all steps except the last k steps, where k is the
// number of steps exempt from transition constraints (guaranteed to be at least 1)
for step in 0..self.info().length() - air.context().num_transition_exemptions() {
for step in 0..self.length() - air.context().num_transition_exemptions() {
// build periodic values
for (p, v) in periodic_values_polys.iter().zip(periodic_values.iter_mut()) {
let num_cycles = air.trace_length() / p.len();
Expand Down
2 changes: 1 addition & 1 deletion prover/src/trace/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn new_trace_table() {
let trace = build_fib_trace(trace_length * 2);

assert_eq!(2, trace.info().main_trace_width());
assert_eq!(8, trace.info().length());
assert_eq!(8, trace.length());

let expected: Vec<BaseElement> = vec![1u32, 2, 5, 13, 34, 89, 233, 610]
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions winterfell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
//!
//! // Our public inputs consist of the first and last value in the execution trace.
//! fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
//! let last_step = trace.info().length() - 1;
//! let last_step = trace.length() - 1;
//! PublicInputs {
//! start: trace.get(0, 0),
//! result: trace.get(0, last_step),
Expand Down Expand Up @@ -488,7 +488,7 @@
//! # DefaultConstraintEvaluator<'a, Self::Air, E>;
//! #
//! # fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
//! # let last_step = trace.info().length() - 1;
//! # let last_step = trace.length() - 1;
//! # PublicInputs {
//! # start: trace.get(0, 0),
//! # result: trace.get(0, last_step),
Expand Down

0 comments on commit f854979

Please sign in to comment.