Skip to content

Commit

Permalink
create v1beta2.proto and set heatbeat with a bool
Browse files Browse the repository at this point in the history
  • Loading branch information
musitdev committed Jan 20, 2025
1 parent 69f4d9a commit acfd786
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 26 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion networks/movement/movement-client/bin/basic_alice_bob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use aptos_sdk::{
rest_client::{Client, FaucetClient},
types::LocalAccount,
};
use movement_client::load_soak_testing::{execute_test, init_test, ExecutionConfig, Scenario};
use std::str::FromStr;
use std::sync::Arc;
use movement_client::load_soak_testing::{execute_test, init_test, ExecutionConfig, Scenario};
use url::Url;

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ message BlobResponse {
Blob passed_through_blob = 1;
Blob sequenced_blob_intent = 2;
Blob sequenced_blob_block = 3;
Blob heartbeat_blob = 4;
}
}

Expand Down
99 changes: 99 additions & 0 deletions proto/movementlabs/protocol_units/da/light_node/v1beta2.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
syntax = "proto3";
package movementlabs.protocol_units.da.light_node.v1beta2;


// Request and response messages
message Blob {
bytes blob_id = 1;
bytes data = 2;
uint64 height = 3;
bytes signature = 4;
uint64 timestamp = 5;
bytes signer = 6;
}

message BlobResponse {
oneof blob_type {
Blob passed_through_blob = 1;
Blob sequenced_blob_intent = 2;
Blob sequenced_blob_block = 3;
bool heartbeat_blob = 4;
}
}

message BlobWrite {
bytes data = 1;
}

// StreamReadAtHeight
message StreamReadFromHeightRequest {
uint64 height = 1;
}

message StreamReadFromHeightResponse {
BlobResponse blob = 1;
}

// StreamReadLatest
message StreamReadLatestRequest {

}

message StreamReadLatestResponse {
BlobResponse blob = 1;
}

// StreamWriteBlob
message StreamWriteBlobRequest {
BlobWrite blob = 1;
}

message StreamWriteBlobResponse {
BlobResponse blob = 1;
}

// ReadAtHeight
message ReadAtHeightRequest {
uint64 height = 1;
}

message ReadAtHeightResponse {
repeated BlobResponse blobs = 1;
}

// BatchRead
message BatchReadRequest {
repeated uint64 heights = 1;
}

message BatchReadResponse {
repeated ReadAtHeightResponse responses = 1;
}

message BatchWriteRequest {
repeated BlobWrite blobs = 1;
}

message BatchWriteResponse {
repeated BlobResponse blobs = 1;
}



// LightNode service definition
service LightNodeService {
// Stream blobs from a specified height or from the latest height.
rpc StreamReadFromHeight (StreamReadFromHeightRequest) returns (stream StreamReadFromHeightResponse);
rpc StreamReadLatest (StreamReadLatestRequest) returns (stream StreamReadLatestResponse);

// Stream blobs out, either individually or in batches.
rpc StreamWriteBlob (stream StreamWriteBlobRequest) returns (stream StreamWriteBlobResponse);

// Read blobs at a specified height.
rpc ReadAtHeight (ReadAtHeightRequest) returns (ReadAtHeightResponse);

// Batch read and write operations for efficiency.
rpc BatchRead (BatchReadRequest) returns (BatchReadResponse);
rpc BatchWrite (BatchWriteRequest) returns (BatchWriteResponse);

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,15 @@ where

while let Some(blob) = blob_stream.next().await {
let (height, da_blob) = blob.map_err(|e| tonic::Status::internal(e.to_string()))?;
let blob = if height.as_u64() == 0 {
//Heart beat blob
// No need to verify the data are removed.
da_blob.to_blob_heartbeat_response()
let response_content = if height.as_u64() == 0 {
//Heart beat. The value can be use to indicate some status.
BlobResponse { blob_type: Some(movement_da_light_node_proto::blob_response::BlobType::HeartbeatBlob(true)) }
} else {
let verifed_blob = verifier.verify(da_blob, height.as_u64()).await.map_err(|e| tonic::Status::internal(e.to_string()))?;
verifed_blob.into_inner().to_blob_passed_through_read_response(height.as_u64()).map_err(|e| tonic::Status::internal(e.to_string()))?
};
let response = StreamReadFromHeightResponse {
blob: Some(blob)
blob: Some(response_content)
};
yield response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ where
let sequenced_block = match blob_type {
BlobType::PassedThroughBlob(blob) => BlobType::SequencedBlobBlock(blob),
BlobType::SequencedBlobBlock(blob) => BlobType::SequencedBlobBlock(blob),
BlobType::HeartbeatBlob(blob) => BlobType::HeartbeatBlob(blob),
BlobType::HeartbeatBlob(val) => BlobType::HeartbeatBlob(val),
_ => {
anyhow::bail!("Invalid blob type")
}
Expand Down
5 changes: 4 additions & 1 deletion protocol-units/da/movement/protocol/proto/build.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
buildtime::proto_build_main!("movementlabs/protocol_units/da/light_node/v1beta1.proto");
buildtime::proto_build_main!(
"movementlabs/protocol_units/da/light_node/v1beta1.proto",
"movementlabs/protocol_units/da/light_node/v1beta2.proto"
);
15 changes: 12 additions & 3 deletions protocol-units/da/movement/protocol/proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
pub mod v1beta1 {
tonic::include_proto!("movementlabs.protocol_units.da.light_node.v1beta1"); // The string specified here
// pub mod v1beta1 {
// tonic::include_proto!("movementlabs.protocol_units.da.light_node.v1beta1"); // The string specified here
// pub const FILE_DESCRIPTOR_SET: &[u8] =
// tonic::include_file_descriptor_set!("movement-da-light-node-proto-descriptor");
// }

// Re-export the latest version at the crate root
//pub use v1beta1::*;

pub mod v1beta2 {
tonic::include_proto!("movementlabs.protocol_units.da.light_node.v1beta2"); // The string specified here
pub const FILE_DESCRIPTOR_SET: &[u8] =
tonic::include_file_descriptor_set!("movement-da-light-node-proto-descriptor");
}

// Re-export the latest version at the crate root
pub use v1beta1::*;
pub use v1beta2::*;
14 changes: 0 additions & 14 deletions protocol-units/da/movement/protocol/util/src/blob/ir/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,6 @@ impl DaBlob {
Ok(BlobResponse { blob_type: Some(blob_response::BlobType::SequencedBlobBlock(blob)) })
}

/// Converts a [DaBlob] into a [BlobResponse] with the blob passed through.
pub fn to_blob_heartbeat_response(self) -> BlobResponse {
//for heartbeat blob the data are removed.
let blob = Blob {
data: vec![],
signature: self.signature().to_vec(),
timestamp: self.timestamp(),
signer: self.signer().to_vec(),
blob_id: self.id().to_vec(),
height: 0,
};
BlobResponse { blob_type: Some(blob_response::BlobType::HeartbeatBlob(blob)) }
}

/// Converts a [DaBlob] into a [BlobResponse] with the blob passed through.
pub fn to_blob_passed_through_read_response(
self,
Expand Down

0 comments on commit acfd786

Please sign in to comment.