Skip to content

Commit

Permalink
chore(deps): upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Jan 30, 2024
1 parent ce8a6d3 commit 89dda61
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ rayon = "1.8"
serde = { version = "1", features = ["derive"] }
serde_derive = "1"
serde_json = "1.0"
strum = { version = "0.25", features = ["derive"] }
strum = { version = "0.26", features = ["derive"] }
syn = "2.0"
test-strategy = "0.3.1"
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion triton-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tokio-util = "0.7"
tracing = "0.1"
tracing-error = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter", "serde"] }
triton-vm = "0.36"
triton-vm = { git = "https://github.com/TritonVM/triton-vm.git", rev = "ce8a6d3e" }
tui-textarea = "0.4"

[dev-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions triton-tui/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use arbitrary::Arbitrary;
use itertools::Itertools;
use serde::de::*;
use serde::*;

use triton_vm::instruction::Instruction;
use triton_vm::op_stack::NUM_OP_STACK_REGISTERS;
use triton_vm::BFieldElement;
use triton_vm::prelude::*;

use crate::mode::Mode;

Expand Down
73 changes: 38 additions & 35 deletions triton-tui/src/components/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use itertools::Itertools;
use ratatui::prelude::*;
use ratatui::widgets::block::*;
use ratatui::widgets::*;
use strum::EnumCount;
use triton_vm::instruction::*;
use triton_vm::op_stack::OpStackElement;
use triton_vm::op_stack::NUM_OP_STACK_REGISTERS;

use crate::action::*;
use crate::element_type_hint::ElementTypeHint;
Expand Down Expand Up @@ -136,11 +135,23 @@ impl Home {
let stack_size = op_stack.len();
let title = format!(" Stack (size: {stack_size:>4}) ");
let title = Title::from(title).alignment(Alignment::Left);
let num_padding_lines = (render_area.height as usize).saturating_sub(stack_size + 3);

let border_set = symbols::border::Set {
bottom_left: symbols::line::ROUNDED.vertical_right,
..symbols::border::ROUNDED
};
let block = Block::default()
.padding(Padding::new(1, 1, 1, 0))
.borders(Borders::TOP | Borders::LEFT | Borders::BOTTOM)
.border_set(border_set)
.title(title);

let num_available_lines = block.inner(render_area).height as usize;
let num_padding_lines = num_available_lines.saturating_sub(stack_size);
let mut text = vec![Line::from(""); num_padding_lines];
for (i, st) in op_stack.iter().rev().enumerate() {
let stack_index_style = match i {
i if i < OpStackElement::COUNT => Style::new().bold(),
i if i < NUM_OP_STACK_REGISTERS => Style::new().bold(),
_ => Style::new().dim(),
};
let stack_index = Span::from(format!("{i:>3}")).set_style(stack_index_style);
Expand All @@ -149,16 +160,6 @@ impl Home {
let line = Line::from(vec![stack_index, separator, stack_element]);
text.push(line);
}

let border_set = symbols::border::Set {
bottom_left: symbols::line::ROUNDED.vertical_right,
..symbols::border::ROUNDED
};
let block = Block::default()
.padding(Padding::new(1, 1, 1, 0))
.borders(Borders::TOP | Borders::LEFT | Borders::BOTTOM)
.border_set(border_set)
.title(title);
let paragraph = Paragraph::new(text).block(block).alignment(Alignment::Left);
frame.render_widget(paragraph, render_area);
}
Expand All @@ -167,15 +168,19 @@ impl Home {
if !self.show_type_hints {
return;
}
let block = Block::default()
.padding(Padding::new(0, 1, 1, 0))
.borders(Borders::TOP | Borders::BOTTOM);
let render_area = render_info.areas.type_hint;
let type_hints = &render_info.state.type_hints.stack;

let num_available_lines = block.inner(render_area).height as usize;
let num_padding_lines = num_available_lines.saturating_sub(type_hints.len());
let mut text = vec![Line::from(""); num_padding_lines];

let highest_hint = type_hints.last().cloned().flatten();
let lowest_hint = type_hints.first().cloned().flatten();

let num_padding_lines = (render_area.height as usize).saturating_sub(type_hints.len() + 3);
let mut text = vec![Line::from(""); num_padding_lines];

text.push(ElementTypeHint::render(&highest_hint).into());
for (hint_0, hint_1, hint_2) in type_hints.iter().rev().tuple_windows() {
if ElementTypeHint::is_continuous_sequence(&[hint_0, hint_1, hint_2]) {
Expand All @@ -186,9 +191,6 @@ impl Home {
}
text.push(ElementTypeHint::render(&lowest_hint).into());

let block = Block::default()
.padding(Padding::new(0, 1, 1, 0))
.borders(Borders::TOP | Borders::BOTTOM);
let paragraph = Paragraph::new(text).block(block).alignment(Alignment::Left);
frame.render_widget(paragraph, render_area);
}
Expand Down Expand Up @@ -272,14 +274,27 @@ impl Home {

let state = &render_info.state;
let jump_stack = &state.vm_state.jump_stack;
let render_area = render_info.areas.call_stack;

let jump_stack_depth = jump_stack.len();
let title = format!(" Calls (depth: {jump_stack_depth:>3}) ");
let title = Title::from(title).alignment(Alignment::Left);

let num_padding_lines = (render_area.height as usize).saturating_sub(jump_stack_depth + 3);
let border_set = symbols::border::Set {
top_left: symbols::line::ROUNDED.horizontal_down,
bottom_left: symbols::line::ROUNDED.horizontal_up,
..symbols::border::ROUNDED
};
let block = Block::default()
.padding(Padding::new(1, 1, 1, 0))
.title(title)
.borders(Borders::TOP | Borders::LEFT | Borders::BOTTOM)
.border_set(border_set);
let render_area = render_info.areas.call_stack;

let num_available_lines = block.inner(render_area).height as usize;
let num_padding_lines = num_available_lines.saturating_sub(jump_stack_depth);
let mut text = vec![Line::from(""); num_padding_lines];

let address_width = self.address_render_width(state);
for (return_address, call_address) in jump_stack.iter().rev() {
let return_address = return_address.value();
Expand All @@ -292,17 +307,6 @@ impl Home {
let line = Line::from(vec![addresses, separator, label]);
text.push(line);
}

let border_set = symbols::border::Set {
top_left: symbols::line::ROUNDED.horizontal_down,
bottom_left: symbols::line::ROUNDED.horizontal_up,
..symbols::border::ROUNDED
};
let block = Block::default()
.padding(Padding::new(1, 1, 1, 0))
.title(title)
.borders(Borders::TOP | Borders::LEFT | Borders::BOTTOM)
.border_set(border_set);
let paragraph = Paragraph::new(text).block(block).alignment(Alignment::Left);
frame.render_widget(paragraph, render_area);
}
Expand Down Expand Up @@ -523,8 +527,7 @@ mod tests {
use proptest_arbitrary_interop::arb;
use ratatui::backend::TestBackend;
use test_strategy::proptest;
use triton_vm::vm::VMState;
use triton_vm::Program;
use triton_vm::prelude::*;

use super::*;

Expand Down
8 changes: 3 additions & 5 deletions triton-tui/src/components/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ratatui::prelude::*;
use ratatui::widgets::*;
use ratatui::Frame;
use triton_vm::instruction::Instruction;
use triton_vm::BFieldElement;
use triton_vm::prelude::*;
use tui_textarea::TextArea;

use crate::action::Action;
Expand Down Expand Up @@ -316,13 +316,11 @@ mod tests {
use proptest_arbitrary_interop::arb;
use ratatui::backend::TestBackend;
use test_strategy::proptest;
use triton_vm::vm::VMState;
use triton_vm::BFieldElement;
use triton_vm::Program;
use triton_vm::prelude::*;

use super::*;

/// Since `TextArea` is not `Arbitrary`, we need to implement `Arbitrary` for `Memory` manually.
/// Since `TextArea` is not `Arbitrary`, implement `Arbitrary` for `Memory` manually.
#[derive(Debug, Clone, test_strategy::Arbitrary)]
struct ArbitraryMemory {
#[strategy(arb())]
Expand Down
8 changes: 3 additions & 5 deletions triton-tui/src/shadow_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ use std::iter::once;
use color_eyre::eyre::bail;
use color_eyre::eyre::Result;
use itertools::Itertools;

use triton_vm::instruction::*;
use triton_vm::op_stack::NumberOfWords::*;
use triton_vm::op_stack::*;
use triton_vm::vm::VMState;
use triton_vm::BFieldElement;
use triton_vm::prelude::*;

use crate::action::ExecutedInstruction;
use crate::element_type_hint::ElementTypeHint;
Expand Down Expand Up @@ -43,7 +41,7 @@ impl ShadowMemory {
}

fn initial_program_digest_type_hint() -> TypeHint {
let digest_length = triton_vm::Digest::default().0.len();
let digest_length = tip5::DIGEST_LENGTH;
TypeHint {
type_name: Some("Digest".to_string()),
variable_name: "program_digest".to_string(),
Expand Down Expand Up @@ -209,7 +207,7 @@ impl ShadowMemory {
type_name: Some("Digest".to_string()),
variable_name: format!("{}_hash", hash_type_hint.variable_name),
starting_index: 0,
length: triton_vm::Digest::default().0.len(),
length: Digest::default().0.len(),
};
self.apply_type_hint(type_hint).unwrap();
}
Expand Down
4 changes: 1 addition & 3 deletions triton-tui/src/triton_vm_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ use tokio::sync::mpsc::UnboundedSender;
use tracing::error;
use tracing::info;
use tracing::warn;

use triton_vm::error::InstructionError;
use triton_vm::instruction::*;
use triton_vm::op_stack::NUM_OP_STACK_REGISTERS;
use triton_vm::vm::VMState;
use triton_vm::*;
use triton_vm::prelude::*;

use crate::action::*;
use crate::args::TuiArgs;
Expand Down

0 comments on commit 89dda61

Please sign in to comment.