Skip to content

Commit 87e0a64

Browse files
committed
chore: refactor + new debug address
1 parent 24077ac commit 87e0a64

File tree

13 files changed

+33
-59
lines changed

13 files changed

+33
-59
lines changed

Cargo.lock

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ members = [
1212
"crates/sound_run",
1313
"crates/syscall_handler",
1414
"crates/types",
15-
"crates/shared_syscall_handlers",
1615
"tests",
1716
]
1817

@@ -66,4 +65,3 @@ pathfinder_gateway_types = { git = "https://github.com/eqlabs/pathfinder", packa
6665
sound_hint_processor = { path = "crates/sound_hint_processor" }
6766
syscall_handler = { path = "crates/syscall_handler" }
6867
types = { path = "crates/types" }
69-
shared_syscall_handlers = { path = "crates/shared_syscall_handlers" }

crates/dry_hint_processor/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ starknet-types-core.workspace = true
1515
starknet.workspace = true
1616
strum_macros.workspace = true
1717
syscall_handler.workspace = true
18-
shared_syscall_handlers.workspace = true
1918
tokio.workspace = true
2019
types.workspace = true

crates/dry_hint_processor/src/syscall_handler/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use cairo_vm::{
1212
use evm::CallContractHandler as EvmCallContractHandler;
1313
use hints::vars;
1414
use serde::{Deserialize, Serialize};
15-
use shared_syscall_handlers::debug_handler::DebugHandler;
1615
use starknet::CallContractHandler as StarknetCallContractHandler;
1716
use syscall_handler::{
18-
felt_from_ptr, keccak::KeccakHandler, run_handler, traits, SyscallExecutionError, SyscallResult, SyscallSelector, WriteResponseResult,
17+
felt_from_ptr, keccak::KeccakHandler, debug::DebugHandler, run_handler, traits, SyscallExecutionError, SyscallResult, SyscallSelector, WriteResponseResult,
1918
};
2019
use tokio::{sync::RwLock, task};
2120
use types::{
@@ -96,16 +95,17 @@ impl traits::SyscallHandler for CallContractHandlerRelay {
9695
}
9796

9897
async fn execute(&mut self, request: Self::Request, vm: &mut VirtualMachine) -> SyscallResult<Self::Response> {
99-
if request.contract_address == Felt252::from(99) {
100-
self.debug_handler.execute(request, vm).await
101-
} else {
102-
let chain_id = <Felt252 as TryInto<u128>>::try_into(*vm.get_integer((request.calldata_start + 2)?)?)
103-
.map_err(|e| SyscallExecutionError::InternalError(e.to_string().into()))?;
104-
105-
match chain_id {
106-
ETHEREUM_MAINNET_CHAIN_ID | ETHEREUM_TESTNET_CHAIN_ID => self.evm_call_contract_handler.execute(request, vm).await,
107-
STARKNET_MAINNET_CHAIN_ID | STARKNET_TESTNET_CHAIN_ID => self.starknet_call_contract_handler.execute(request, vm).await,
108-
_ => Err(SyscallExecutionError::InternalError(Box::from("Unknown chain id"))),
98+
match request.contract_address {
99+
addr if addr == Felt252::from_bytes_be_slice(b"debug") => self.debug_handler.execute(request, vm).await,
100+
_ => {
101+
let chain_id = <Felt252 as TryInto<u128>>::try_into(*vm.get_integer((request.calldata_start + 2)?)?)
102+
.map_err(|e| SyscallExecutionError::InternalError(e.to_string().into()))?;
103+
104+
match chain_id {
105+
ETHEREUM_MAINNET_CHAIN_ID | ETHEREUM_TESTNET_CHAIN_ID => self.evm_call_contract_handler.execute(request, vm).await,
106+
STARKNET_MAINNET_CHAIN_ID | STARKNET_TESTNET_CHAIN_ID => self.starknet_call_contract_handler.execute(request, vm).await,
107+
_ => Err(SyscallExecutionError::InternalError(Box::from("Unknown chain id"))),
108+
}
109109
}
110110
}
111111
}

crates/shared_syscall_handlers/Cargo.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

crates/shared_syscall_handlers/src/lib.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

crates/sound_hint_processor/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ starknet-types-core.workspace = true
1414
strum_macros.workspace = true
1515
syscall_handler.workspace = true
1616
tokio.workspace = true
17-
types.workspace = true
18-
shared_syscall_handlers.workspace = true
17+
types.workspace = true

crates/sound_hint_processor/src/syscall_handler/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ use cairo_vm::{
1616
};
1717
use hints::vars;
1818
use serde::{Deserialize, Serialize};
19-
use shared_syscall_handlers::debug_handler::DebugHandler;
2019
use syscall_handler::{
21-
felt_from_ptr, keccak::KeccakHandler, run_handler, traits, SyscallExecutionError, SyscallResult, SyscallSelector, WriteResponseResult,
20+
felt_from_ptr, keccak::KeccakHandler, debug::DebugHandler, run_handler, traits, SyscallExecutionError, SyscallResult, SyscallSelector, WriteResponseResult,
2221
};
2322
use tokio::{sync::RwLock, task};
2423
use types::{
@@ -110,16 +109,17 @@ impl traits::SyscallHandler for CallContractHandlerRelay {
110109
}
111110

112111
async fn execute(&mut self, request: Self::Request, vm: &mut VirtualMachine) -> SyscallResult<Self::Response> {
113-
if request.contract_address == Felt252::from(99) {
114-
self.debug_handler.execute(request, vm).await
115-
} else {
116-
let chain_id = <Felt252 as TryInto<u128>>::try_into(*vm.get_integer((request.calldata_start + 2)?)?)
117-
.map_err(|e| SyscallExecutionError::InternalError(e.to_string().into()))?;
118-
119-
match chain_id {
120-
ETHEREUM_MAINNET_CHAIN_ID | ETHEREUM_TESTNET_CHAIN_ID => self.evm_call_contract_handler.execute(request, vm).await,
121-
STARKNET_MAINNET_CHAIN_ID | STARKNET_TESTNET_CHAIN_ID => self.starknet_call_contract_handler.execute(request, vm).await,
122-
_ => Err(SyscallExecutionError::InternalError(Box::from("Unknown chain id"))),
112+
match request.contract_address {
113+
addr if addr == Felt252::from_bytes_be_slice(b"debug") => self.debug_handler.execute(request, vm).await,
114+
_ => {
115+
let chain_id = <Felt252 as TryInto<u128>>::try_into(*vm.get_integer((request.calldata_start + 2)?)?)
116+
.map_err(|e| SyscallExecutionError::InternalError(e.to_string().into()))?;
117+
118+
match chain_id {
119+
ETHEREUM_MAINNET_CHAIN_ID | ETHEREUM_TESTNET_CHAIN_ID => self.evm_call_contract_handler.execute(request, vm).await,
120+
STARKNET_MAINNET_CHAIN_ID | STARKNET_TESTNET_CHAIN_ID => self.starknet_call_contract_handler.execute(request, vm).await,
121+
_ => Err(SyscallExecutionError::InternalError(Box::from("Unknown chain id"))),
122+
}
123123
}
124124
}
125125
}

crates/syscall_handler/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ num-integer.workspace = true
1111
keccak.workspace = true
1212
num-bigint.workspace = true
1313
num-traits.workspace = true
14-
serde.workspace = true
14+
serde.workspace = true
15+
strum_macros.workspace = true

crates/shared_syscall_handlers/src/debug_handler.rs renamed to crates/syscall_handler/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine, Felt252};
22
use serde::{Deserialize, Serialize};
33
use strum_macros::FromRepr;
4-
use syscall_handler::{traits, SyscallExecutionError, SyscallResult, WriteResponseResult};
4+
use crate::{traits, SyscallExecutionError, SyscallResult, WriteResponseResult};
55
use types::cairo::{
66
new_syscalls::{CallContractRequest, CallContractResponse},
77
traits::CairoType,

0 commit comments

Comments
 (0)