Skip to content
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
26 changes: 26 additions & 0 deletions .vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"servers": {
"io.github.upstash/context7": {
"type": "stdio",
"command": "npx",
"args": ["@upstash/context7-mcp@1.0.31"],
"env": {
"CONTEXT7_API_KEY": "${input:CONTEXT7_API_KEY}"
},
"gallery": "https://api.mcp.github.com",
"version": "1.0.31"
},
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
}
},
"inputs": [
{
"id": "CONTEXT7_API_KEY",
"type": "promptString",
"description": "API key for authentication",
"password": true
}
]
}
137 changes: 137 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "CRISP: Start All",
"detail": "Starts all 10 CRISP services in parallel (each in its own dedicated VS Code terminal). Terminate Task works on the compound task.",
"dependsOn": [
"CRISP: Anvil",
"CRISP: Deploy + Setup",
"CRISP: cn1",
"CRISP: cn2",
"CRISP: cn3",
"CRISP: cn4",
"CRISP: cn5",
"CRISP: Program Server",
"CRISP: Server",
"CRISP: Client"
],
"dependsOrder": "parallel",
"problemMatcher": []
},
{
"label": "CRISP: Anvil",
"type": "shell",
"command": "anvil",
"args": [
"--host",
"0.0.0.0",
"--chain-id",
"31337",
"--block-time",
"1",
"--mnemonic",
"test test test test test test test test test test test junk"
],
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-anvil" },
"problemMatcher": {
"pattern": { "regexp": "^$" },
"background": {
"activeOnStart": true,
"beginsPattern": "^.*$",
"endsPattern": "^.*Listening on.*$"
}
}
},
{
"label": "CRISP: Deploy + Setup",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "deploy"],
"options": { "cwd": "${workspaceFolder}" },
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-deploy" },
"problemMatcher": []
},
{
"label": "CRISP: cn1",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "cn1"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-cn1", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: cn2",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "cn2"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-cn2", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: cn3",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "cn3"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-cn3", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: cn4",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "cn4"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-cn4", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: cn5",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "cn5"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-cn5", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: Program Server",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "program"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-program", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: Server",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "server"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-server", "clear": false },
"problemMatcher": []
},
{
"label": "CRISP: Client",
"type": "shell",
"command": "bash",
"args": ["${workspaceFolder}/deploy/local/run_service.sh", "client"],
"options": { "cwd": "${workspaceFolder}" },
"isBackground": true,
"presentation": { "reveal": "always", "panel": "dedicated", "group": "crisp-client", "clear": false },
"problemMatcher": []
}
]
}
1 change: 1 addition & 0 deletions crates/events/src/enclave_event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ impl EnclaveEventData {
EnclaveEventData::ProofVerificationPassed(ref data) => Some(data.e3_id.clone()),
EnclaveEventData::KeyshareCreated(ref data) => Some(data.e3_id.clone()),
EnclaveEventData::E3Requested(ref data) => Some(data.e3_id.clone()),
EnclaveEventData::E3RequestComplete(ref data) => Some(data.e3_id.clone()),
Comment thread
hmzakhalid marked this conversation as resolved.
EnclaveEventData::PublicKeyAggregated(ref data) => Some(data.e3_id.clone()),
EnclaveEventData::CiphertextOutputPublished(ref data) => Some(data.e3_id.clone()),
EnclaveEventData::DecryptionKeyShared(ref data) => Some(data.e3_id.clone()),
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/src/actors/evm_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tracing::debug;
use crate::domain::log_timestamp::from_log_chain_id_to_ts;
use crate::messages::{EnclaveEvmEvent, EvmEvent, EvmEventProcessor, EvmLog};

pub type ExtractorFn<E> = fn(&LogData, Option<&B256>, u64) -> Option<E>;
pub type ExtractorFn<E> = fn(&LogData, &[B256], u64) -> Option<E>;

pub struct EvmParser {
next: EvmEventProcessor,
Expand Down Expand Up @@ -49,7 +49,7 @@ impl Handler<EnclaveEvmEvent> for EvmParser {
debug!("processing event({})", msg.get_id());
let extractor = self.extractor;

if let Some(event) = extractor(log.data(), log.topic0(), chain_id) {
if let Some(event) = extractor(log.data(), log.topics(), chain_id) {
let err = "Log should always have metadata because we listen to non-pending blocks. If you are seeing this it is likely because there is an issue with how we are subscribing to blocks";
let block = log.block_number.expect(err);
let log_index = log.log_index.expect(err);
Expand Down
12 changes: 6 additions & 6 deletions crates/evm/src/domain/bonding_registry_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ impl From<OperatorActivationChangedWithChainId> for EnclaveEventData {

pub(crate) fn extractor(
data: &LogData,
topic: Option<&B256>,
topics: &[B256],
chain_id: u64,
) -> Option<EnclaveEventData> {
match topic {
match topics.first() {
Some(&IBondingRegistry::TicketBalanceUpdated::SIGNATURE_HASH) => {
let Ok(event) = IBondingRegistry::TicketBalanceUpdated::decode_log_data(data) else {
error!("Error parsing event TicketBalanceUpdated after topic was matched!");
Expand Down Expand Up @@ -121,9 +121,9 @@ pub(crate) fn extractor(
event, chain_id,
)))
}
_topic => {
_ => {
trace!(
topic=?_topic,
topic=?topics.first(),
"Unknown event was received by BondingRegistry.sol parser but was ignored"
);
None
Expand All @@ -145,7 +145,7 @@ mod tests {
let log_data = event.encode_log_data();
let out = extractor(
&log_data,
Some(&IBondingRegistry::OperatorActivationChanged::SIGNATURE_HASH),
&[IBondingRegistry::OperatorActivationChanged::SIGNATURE_HASH],
55,
);
match out {
Expand Down Expand Up @@ -175,6 +175,6 @@ mod tests {
#[test]
fn test_extractor_ignores_unknown_topic() {
let log_data = LogData::default();
assert!(extractor(&log_data, Some(&B256::ZERO), 1).is_none());
assert!(extractor(&log_data, &[B256::ZERO], 1).is_none());
}
}
12 changes: 6 additions & 6 deletions crates/evm/src/domain/ciphernode_registry_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ impl From<CommitteeMemberExpelledWithChainId> for EnclaveEventData {

pub(crate) fn extractor(
data: &LogData,
topic: Option<&B256>,
topics: &[B256],
chain_id: u64,
) -> Option<EnclaveEventData> {
match topic {
match topics.first() {
Some(&ICiphernodeRegistry::CiphernodeAdded::SIGNATURE_HASH) => {
let Ok(event) = ICiphernodeRegistry::CiphernodeAdded::decode_log_data(data) else {
error!("Error parsing event CiphernodeAdded after topic was matched!");
Expand Down Expand Up @@ -234,9 +234,9 @@ pub(crate) fn extractor(
event, chain_id,
)))
}
_topic => {
_ => {
trace!(
topic=?_topic,
topic=?topics.first(),
"Unknown event was received by CiphernodeRegistry.sol parser but was ignored"
);
None
Expand All @@ -260,7 +260,7 @@ mod tests {
let log_data = event.encode_log_data();
let out = extractor(
&log_data,
Some(&ICiphernodeRegistry::CiphernodeAdded::SIGNATURE_HASH),
&[ICiphernodeRegistry::CiphernodeAdded::SIGNATURE_HASH],
10,
);
match out {
Expand Down Expand Up @@ -294,6 +294,6 @@ mod tests {
#[test]
fn test_extractor_ignores_unknown_topic() {
let log_data = LogData::default();
assert!(extractor(&log_data, Some(&B256::ZERO), 1).is_none());
assert!(extractor(&log_data, &[B256::ZERO], 1).is_none());
}
}
36 changes: 27 additions & 9 deletions crates/evm/src/domain/enclave_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ impl From<E3StageChangedWithChainId> for EnclaveEventData {

pub(crate) fn extractor(
data: &LogData,
topic: Option<&B256>,
topics: &[B256],
chain_id: u64,
) -> Option<EnclaveEventData> {
match topic {
let topic0 = topics.first();
match topic0 {
Some(&IEnclave::E3Requested::SIGNATURE_HASH) => {
let Ok(event) = IEnclave::E3Requested::decode_log_data(data) else {
error!("Error parsing event E3Requested after topic matched!");
Expand All @@ -211,10 +212,17 @@ pub(crate) fn extractor(
}
}
Some(&IEnclave::CiphertextOutputPublished::SIGNATURE_HASH) => {
let Ok(event) = IEnclave::CiphertextOutputPublished::decode_log_data(data) else {
let Ok(mut event) = IEnclave::CiphertextOutputPublished::decode_log_data(data) else {
error!("Error parsing event CiphertextOutputPublished after topic matched!");
return None;
};
// e3Id is indexed → extract from topics[1], not log data
if let Some(e3_id_topic) = topics.get(1) {
event.e3Id = alloy::primitives::U256::from_be_bytes(e3_id_topic.0);
} else {
error!("CiphertextOutputPublished missing indexed e3Id in topics!");
return None;
}
Some(EnclaveEventData::from(
CiphertextOutputPublishedWithChainId(event, chain_id),
))
Expand All @@ -231,10 +239,17 @@ pub(crate) fn extractor(
Some(EnclaveEventData::from(E3FailedWithChainId(event, chain_id)))
}
Some(&IEnclave::E3StageChanged::SIGNATURE_HASH) => {
let Ok(event) = IEnclave::E3StageChanged::decode_log_data(data) else {
let Ok(mut event) = IEnclave::E3StageChanged::decode_log_data(data) else {
error!("Error parsing event E3StageChanged after topic matched!");
return None;
};
// e3Id is indexed → extract from topics[1], not log data
if let Some(e3_id_topic) = topics.get(1) {
event.e3Id = alloy::primitives::U256::from_be_bytes(e3_id_topic.0);
} else {
error!("E3StageChanged missing indexed e3Id in topics!");
return None;
}
trace!(
"E3StageChanged event received: e3_id={}, {:?} -> {:?}",
event.e3Id,
Expand All @@ -245,9 +260,9 @@ pub(crate) fn extractor(
event, chain_id,
)))
}
_topic => {
_ => {
trace!(
topic=?_topic,
topic=?topic0,
"Unknown event received by Enclave.sol parser but was ignored"
);
None
Expand Down Expand Up @@ -286,9 +301,12 @@ mod tests {
newStage: 6, // Failed
};
let log_data = event.encode_log_data();
// e3Id is indexed → it must be in topics[1] (not in log data)
let e3_id_bytes: [u8; 32] = U256::from(42u64).to_be_bytes();
let e3_id_topic = B256::from(e3_id_bytes);
let out = extractor(
&log_data,
Some(&IEnclave::E3StageChanged::SIGNATURE_HASH),
&[IEnclave::E3StageChanged::SIGNATURE_HASH, e3_id_topic],
7,
);
match out {
Expand All @@ -304,7 +322,7 @@ mod tests {
#[test]
fn test_extractor_ignores_unknown_topic() {
let log_data = LogData::default();
assert!(extractor(&log_data, Some(&B256::ZERO), 1).is_none());
assert!(extractor(&log_data, None, 1).is_none());
assert!(extractor(&log_data, &[B256::ZERO], 1).is_none());
assert!(extractor(&log_data, &[], 1).is_none());
}
}
12 changes: 6 additions & 6 deletions crates/evm/src/domain/slashing_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ fn safe_u256_to_u128(val: U256) -> Option<u128> {

pub(crate) fn extractor(
data: &LogData,
topic: Option<&B256>,
topics: &[B256],
chain_id: u64,
) -> Option<EnclaveEventData> {
match topic {
match topics.first() {
Some(&ISlashingManager::SlashExecuted::SIGNATURE_HASH) => {
let Ok(event) = ISlashingManager::SlashExecuted::decode_log_data(data) else {
error!("Error parsing event SlashExecuted after topic was matched!");
Expand Down Expand Up @@ -74,9 +74,9 @@ pub(crate) fn extractor(
},
}))
}
_topic => {
_ => {
trace!(
topic=?_topic,
topic=?topics.first(),
"Unknown event was received by SlashingManager.sol parser but was ignored"
);
None
Expand All @@ -103,7 +103,7 @@ mod tests {
#[test]
fn test_extractor_ignores_unknown_topic() {
let log_data = LogData::default();
assert!(extractor(&log_data, Some(&B256::ZERO), 1).is_none());
assert!(extractor(&log_data, None, 1).is_none());
assert!(extractor(&log_data, &[B256::ZERO], 1).is_none());
assert!(extractor(&log_data, &[], 1).is_none());
}
}
Loading
Loading