Skip to content

Commit

Permalink
chore: runtime version is upgraded and bucket response is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Oct 10, 2024
1 parent 11d3ff3 commit d719fd3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 24 deletions.
12 changes: 10 additions & 2 deletions pallets/ddc-verification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,15 @@ pub mod pallet {
pub(crate) struct BucketAggregateResponse {
/// Bucket id
pub(crate) bucket_id: BucketId,
/// SubAggregates.
/// Total amount of stored bytes.
pub(crate) stored_bytes: i64,
/// Total amount of transferred bytes.
pub(crate) transferred_bytes: u64,
/// Total number of puts.
pub(crate) number_of_puts: u64,
/// Total number of gets.
pub(crate) number_of_gets: u64,
/// Bucket sub aggregates.
pub(crate) sub_aggregates: Vec<BucketSubAggregateResponse>,
}

Expand Down Expand Up @@ -1930,7 +1938,7 @@ pub mod pallet {
let mut buckets_sub_aggregates: Vec<BucketSubAggregate> = Vec::new();

log::info!(
"🏠⏳ Starting fetching bucket node aggregates for cluster_id: {:?} for era_id: {:?}",
"🏠⏳ Starting fetching bucket sub-aggregates for cluster_id: {:?} for era_id: {:?}",
cluster_id,
era_id
);
Expand Down
84 changes: 64 additions & 20 deletions pallets/ddc-verification/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ fn fetch_bucket_aggregates_works() {
let era_id = 1;

// Create a sample NodeAggregateResponse instance
let customer_activity1 = BucketAggregateResponse {
let bucket_aggregate1 = BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 111,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -199,7 +203,11 @@ fn fetch_bucket_aggregates_works() {
number_of_gets: 20,
}],
};
let customer_activity2 = BucketAggregateResponse {
let bucket_aggregate2 = BucketAggregateResponse {
stored_bytes: 1000,
transferred_bytes: 500,
number_of_puts: 100,
number_of_gets: 200,
bucket_id: 222,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -210,7 +218,7 @@ fn fetch_bucket_aggregates_works() {
}],
};
let customers_activity_json =
serde_json::to_string(&vec![customer_activity1.clone(), customer_activity2.clone()])
serde_json::to_string(&vec![bucket_aggregate1.clone(), bucket_aggregate2.clone()])
.unwrap();

// Mock HTTP request and response
Expand Down Expand Up @@ -241,36 +249,36 @@ fn fetch_bucket_aggregates_works() {
let activities = result.unwrap();
assert_eq!(
activities[0].sub_aggregates[0].number_of_gets,
customer_activity1.sub_aggregates[0].number_of_gets
bucket_aggregate1.sub_aggregates[0].number_of_gets
);
assert_eq!(
activities[0].sub_aggregates[0].number_of_puts,
customer_activity1.sub_aggregates[0].number_of_puts
bucket_aggregate1.sub_aggregates[0].number_of_puts
);
assert_eq!(
activities[0].sub_aggregates[0].transferred_bytes,
customer_activity1.sub_aggregates[0].transferred_bytes
bucket_aggregate1.sub_aggregates[0].transferred_bytes
);
assert_eq!(
activities[0].sub_aggregates[0].stored_bytes,
customer_activity1.sub_aggregates[0].stored_bytes
bucket_aggregate1.sub_aggregates[0].stored_bytes
);

assert_eq!(
activities[1].sub_aggregates[0].number_of_gets,
customer_activity2.sub_aggregates[0].number_of_gets
bucket_aggregate2.sub_aggregates[0].number_of_gets
);
assert_eq!(
activities[1].sub_aggregates[0].number_of_puts,
customer_activity2.sub_aggregates[0].number_of_puts
bucket_aggregate2.sub_aggregates[0].number_of_puts
);
assert_eq!(
activities[1].sub_aggregates[0].transferred_bytes,
customer_activity2.sub_aggregates[0].transferred_bytes
bucket_aggregate2.sub_aggregates[0].transferred_bytes
);
assert_eq!(
activities[1].sub_aggregates[0].stored_bytes,
customer_activity2.sub_aggregates[0].stored_bytes
bucket_aggregate2.sub_aggregates[0].stored_bytes
);
});
}
Expand Down Expand Up @@ -324,6 +332,10 @@ fn buckets_sub_aggregates_in_consensus_merged() {
let resp1 = (
aggregator1,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -338,6 +350,10 @@ fn buckets_sub_aggregates_in_consensus_merged() {
let resp2 = (
aggregator2,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -352,6 +368,10 @@ fn buckets_sub_aggregates_in_consensus_merged() {
let resp3 = (
aggregator3,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand Down Expand Up @@ -434,6 +454,10 @@ fn buckets_sub_aggregates_in_quorum_merged() {
let resp1 = (
aggregator1,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -448,6 +472,10 @@ fn buckets_sub_aggregates_in_quorum_merged() {
let resp2 = (
aggregator2,
vec![BucketAggregateResponse {
stored_bytes: 200,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -462,6 +490,10 @@ fn buckets_sub_aggregates_in_quorum_merged() {
let resp3 = (
aggregator3,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand Down Expand Up @@ -544,6 +576,10 @@ fn buckets_sub_aggregates_in_others_merged() {
let resp1 = (
aggregator1,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -558,6 +594,10 @@ fn buckets_sub_aggregates_in_others_merged() {
let resp2 = (
aggregator2,
vec![BucketAggregateResponse {
stored_bytes: 200,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand All @@ -572,6 +612,10 @@ fn buckets_sub_aggregates_in_others_merged() {
let resp3 = (
aggregator3,
vec![BucketAggregateResponse {
stored_bytes: 100,
transferred_bytes: 50,
number_of_puts: 10,
number_of_gets: 20,
bucket_id: 1,
sub_aggregates: vec![BucketSubAggregateResponse {
NodeID: "1".to_string(),
Expand Down Expand Up @@ -2528,71 +2572,71 @@ fn test_single_ocw_pallet_integration() {
let bucket_pending_request1 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host1, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"bucket_id": 90235,"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request2 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host2, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request3 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host3, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request4 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host4, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request5 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host5, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request6 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host6, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request7 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host7, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request8 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host8, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"bucket_id": 90235,"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};

let bucket_pending_request9 = PendingRequest {
method: "GET".to_string(),
uri: format!("http://{}:{}/activity/buckets?eraId=476814", host9, port),
response: Some(br#"[{"bucket_id": 90235,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
response: Some(br#"[{"bucket_id": 90235,"stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1,"sub_aggregates": [{"NodeID": "0xbe26b2458fb0c9df4ec26ec5ba083051402b2a3b9d4a7fe6106fe9f8b5efde2c","stored_bytes": 0,"transferred_bytes": 38,"number_of_puts": 0,"number_of_gets": 1}]}]"#.to_vec()),
sent: true,
..Default::default()
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 54128,
spec_version: 54129,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 19,
Expand Down
2 changes: 1 addition & 1 deletion runtime/cere/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 54128,
spec_version: 54129,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 19,
Expand Down

0 comments on commit d719fd3

Please sign in to comment.