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

Implement serialization/deserialization for Operation #1390

Merged
merged 10 commits into from
Jul 11, 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
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ pub mod prettier {

mod operations;
pub use operations::{
AdviceInjector, AssemblyOp, DebugOptions, Decorator, DecoratorIterator, DecoratorList,
Operation, SignatureKind,
opcode_constants::*, AdviceInjector, AssemblyOp, DebugOptions, Decorator, DecoratorIterator,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit hesitant to export this many constants at the root level. Maybe we should export this as:

pub mod opcodes {
    pub use super::operations::opcode_constants::*;
}

DecoratorList, Operation, SignatureKind,
};

pub mod stack;
Expand Down
12 changes: 7 additions & 5 deletions core/src/mast/node/call_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use core::fmt;
use miden_crypto::{hash::rpo::RpoDigest, Felt};
use miden_formatting::prettier::PrettyPrint;

use crate::{chiplets::hasher, Operation};

use crate::mast::{MastForest, MastNodeId, MerkleTreeNode};
use crate::{
chiplets::hasher,
mast::{MastForest, MastNodeId, MerkleTreeNode},
OPCODE_CALL, OPCODE_SYSCALL,
};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CallNode {
Expand All @@ -17,9 +19,9 @@ pub struct CallNode {
/// Constants
impl CallNode {
/// The domain of the call block (used for control block hashing).
pub const CALL_DOMAIN: Felt = Felt::new(Operation::Call.op_code() as u64);
pub const CALL_DOMAIN: Felt = Felt::new(OPCODE_CALL as u64);
/// The domain of the syscall block (used for control block hashing).
pub const SYSCALL_DOMAIN: Felt = Felt::new(Operation::SysCall.op_code() as u64);
pub const SYSCALL_DOMAIN: Felt = Felt::new(OPCODE_SYSCALL as u64);
}

/// Constructors
Expand Down
4 changes: 2 additions & 2 deletions core/src/mast/node/dyn_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use miden_crypto::{hash::rpo::RpoDigest, Felt};

use crate::{
mast::{MastForest, MerkleTreeNode},
Operation,
OPCODE_DYN,
};

#[derive(Debug, Clone, Default, PartialEq, Eq)]
Expand All @@ -13,7 +13,7 @@ pub struct DynNode;
/// Constants
impl DynNode {
/// The domain of the Dyn block (used for control block hashing).
pub const DOMAIN: Felt = Felt::new(Operation::Dyn.op_code() as u64);
pub const DOMAIN: Felt = Felt::new(OPCODE_DYN as u64);
}

impl MerkleTreeNode for DynNode {
Expand Down
11 changes: 7 additions & 4 deletions core/src/mast/node/join_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ use core::fmt;

use miden_crypto::{hash::rpo::RpoDigest, Felt};

use crate::{chiplets::hasher, prettier::PrettyPrint, Operation};

use crate::mast::{MastForest, MastNodeId, MerkleTreeNode};
use crate::{
chiplets::hasher,
mast::{MastForest, MastNodeId, MerkleTreeNode},
prettier::PrettyPrint,
OPCODE_JOIN,
};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct JoinNode {
Expand All @@ -15,7 +18,7 @@ pub struct JoinNode {
/// Constants
impl JoinNode {
/// The domain of the join block (used for control block hashing).
pub const DOMAIN: Felt = Felt::new(Operation::Join.op_code() as u64);
pub const DOMAIN: Felt = Felt::new(OPCODE_JOIN as u64);
}

/// Constructors
Expand Down
10 changes: 6 additions & 4 deletions core/src/mast/node/loop_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use core::fmt;
use miden_crypto::{hash::rpo::RpoDigest, Felt};
use miden_formatting::prettier::PrettyPrint;

use crate::{chiplets::hasher, Operation};

use crate::mast::{MastForest, MastNodeId, MerkleTreeNode};
use crate::{
chiplets::hasher,
mast::{MastForest, MastNodeId, MerkleTreeNode},
OPCODE_LOOP,
};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LoopNode {
Expand All @@ -16,7 +18,7 @@ pub struct LoopNode {
/// Constants
impl LoopNode {
/// The domain of the loop node (used for control block hashing).
pub const DOMAIN: Felt = Felt::new(Operation::Loop.op_code() as u64);
pub const DOMAIN: Felt = Felt::new(OPCODE_LOOP as u64);
}

/// Constructors
Expand Down
10 changes: 6 additions & 4 deletions core/src/mast/node/split_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use core::fmt;
use miden_crypto::{hash::rpo::RpoDigest, Felt};
use miden_formatting::prettier::PrettyPrint;

use crate::{chiplets::hasher, Operation};

use crate::mast::{MastForest, MastNodeId, MerkleTreeNode};
use crate::{
chiplets::hasher,
mast::{MastForest, MastNodeId, MerkleTreeNode},
OPCODE_SPLIT,
};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SplitNode {
Expand All @@ -16,7 +18,7 @@ pub struct SplitNode {
/// Constants
impl SplitNode {
/// The domain of the split node (used for control block hashing).
pub const DOMAIN: Felt = Felt::new(Operation::Split.op_code() as u64);
pub const DOMAIN: Felt = Felt::new(OPCODE_SPLIT as u64);
}

/// Constructors
Expand Down
Loading
Loading