Skip to content

Commit 8dc80d8

Browse files
committed
feat: add new types to ValidityResponseMessage
1 parent 75297ce commit 8dc80d8

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

batcher/aligned-batcher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ impl Batcher {
968968
let merkle_root = hex::encode(batch_merkle_tree.root);
969969
send_message(
970970
ws_sink.clone(),
971-
ResponseMessage::CreateNewTaskError(merkle_root),
971+
ResponseMessage::CreateNewTaskError(merkle_root, format!("{:?}", e)),
972972
)
973973
.await
974974
} else {

batcher/aligned-sdk/src/communication/messaging.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ pub async fn send_messages(
133133
expected_addr,
134134
));
135135
}
136+
ValidityResponseMessage::BatchInclusionData(data) => {
137+
debug!("Message was valid and included with the following BatchInclusionData: {:?}", data);
138+
139+
}
140+
ValidityResponseMessage::CreateNewTaskError(merkle_root, error) => {
141+
return Err(SubmitError::BatchSubmissionFailed(
142+
"Could not create task with merkle root ".to_owned() + &merkle_root + ", failed with error: " + &error,
143+
));
144+
}
145+
136146
};
137147

138148
sent_verification_data.push(verification_data.clone());
@@ -215,9 +225,9 @@ async fn process_batch_inclusion_data(
215225
Ok(ResponseMessage::Error(e)) => {
216226
error!("Batcher responded with error: {}", e);
217227
}
218-
Ok(ResponseMessage::CreateNewTaskError(merkle_root)) => {
228+
Ok(ResponseMessage::CreateNewTaskError(merkle_root, error)) => {
219229
return Err(SubmitError::BatchSubmissionFailed(
220-
"Could not create task with merkle root ".to_owned() + &merkle_root,
230+
"Could not create task with merkle root ".to_owned() + &merkle_root + ", failed with error: " + &error,
221231
));
222232
}
223233
Ok(ResponseMessage::InvalidProof(reason)) => {

batcher/aligned-sdk/src/core/types.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ pub enum ValidityResponseMessage {
343343
InsufficientBalance(Address),
344344
EthRpcError,
345345
InvalidPaymentServiceAddress(Address, Address),
346+
BatchInclusionData(BatchInclusionData),
347+
CreateNewTaskError(String, String), //merkle-root, error
348+
346349
}
347350

348351
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -379,6 +382,8 @@ impl Display for ValidityResponseMessage {
379382
addr, expected
380383
)
381384
}
385+
ValidityResponseMessage::BatchInclusionData(data) => write!(f, "Received Batch inclusion data, this means the task was processed: {:?}", data),
386+
ValidityResponseMessage::CreateNewTaskError(merkle_root, error) => write!(f, "Create new task error: merkle root: {}, error: {}", merkle_root, error)
382387
}
383388
}
384389
}
@@ -399,7 +404,7 @@ impl Display for ProofInvalidReason {
399404
pub enum ResponseMessage {
400405
BatchInclusionData(BatchInclusionData),
401406
ProtocolVersion(u16),
402-
CreateNewTaskError(String),
407+
CreateNewTaskError(String, String), //merkle-root, error
403408
InvalidProof(ProofInvalidReason),
404409
BatchReset,
405410
Error(String),

0 commit comments

Comments
 (0)