Skip to content

Commit

Permalink
Add additional traits and methods to DeprecatedSyscallSelector (#24)
Browse files Browse the repository at this point in the history
<!-- Reference any GitHub issues resolved by this PR -->

Implements #10 

## Introduced changes

<!-- A brief description of the changes -->

- add missing traits and methods to DeprecatedSyscallSelector

## Checklist

<!-- Make sure all of these are complete -->

- [X] Linked relevant issue
- [ ] Updated relevant documentation
- [ ] Added relevant tests
- [X] Performed self-review of the code
- [X] Added changes to `CHANGELOG.md`
  • Loading branch information
THenry14 authored Nov 7, 2024
1 parent e5d3676 commit d8321bd
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

- removed syscall_counter from ExecutionResources
- Wrapped CallTraceV1 into Box for better performance
- wrapped CallTraceV1 into Box for better performance
- implemented method `DeprecatedSyscallSelector::all()` for getting all possible libfuncs
- added traits for `DeprecatedSyscallSelector` to allow its conversion from/to a string
29 changes: 28 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
assert_fs = "1.1.2"
snapbox = "0.6.19"
strum = "0.26"
strum_macros = "0.26"
2 changes: 2 additions & 0 deletions crates/cairo-annotations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ thiserror.workspace = true
derive_more.workspace = true
serde.workspace = true
serde_json.workspace = true
strum.workspace = true
strum_macros.workspace = true

[dev-dependencies]
assert_fs.workspace = true
Expand Down
23 changes: 22 additions & 1 deletion crates/cairo-annotations/src/trace_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use camino::Utf8PathBuf;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::ops::{AddAssign, Sub, SubAssign};
use strum::VariantArray;
use strum_macros::{Display, EnumString, VariantArray};

#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct ClassHash(pub String);
Expand Down Expand Up @@ -110,7 +112,19 @@ impl SubAssign<&VmExecutionResources> for VmExecutionResources {
}
}

#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, Hash, PartialEq)]
#[derive(
Clone,
Copy,
Debug,
Display,
Deserialize,
Serialize,
Eq,
Hash,
PartialEq,
EnumString,
VariantArray,
)]
pub enum DeprecatedSyscallSelector {
CallContract,
DelegateCall,
Expand Down Expand Up @@ -146,6 +160,13 @@ pub enum DeprecatedSyscallSelector {
Sha256ProcessBlock,
}

impl DeprecatedSyscallSelector {
#[must_use]
pub fn all() -> &'static [Self] {
Self::VARIANTS
}
}

#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct CallEntryPoint {
pub class_hash: Option<ClassHash>,
Expand Down

0 comments on commit d8321bd

Please sign in to comment.