Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: update rav attributes to camel case #213

Merged
merged 1 commit into from
Feb 26, 2024
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
24 changes: 12 additions & 12 deletions tap_aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub async fn check_and_aggregate_receipts(

// Check that the rav has the correct allocation id
if let Some(previous_rav) = &previous_rav {
let prev_id = previous_rav.message.allocation_id;
let prev_id = previous_rav.message.allocationId;
if prev_id != allocation_id {
return Err(tap_core::Error::RavAllocationIdMismatch {
prev_id: format!("{prev_id:#X}"),
Expand Down Expand Up @@ -117,9 +117,9 @@ fn check_receipt_timestamps(
if let Some(previous_rav) = &previous_rav {
for receipt in receipts.iter() {
let receipt = &receipt.message;
if previous_rav.message.timestamp_ns >= receipt.timestamp_ns {
if previous_rav.message.timestampNs >= receipt.timestamp_ns {
return Err(tap_core::Error::ReceiptTimestampLowerThanRav {
rav_ts: previous_rav.message.timestamp_ns,
rav_ts: previous_rav.message.timestampNs,
receipt_ts: receipt.timestamp_ns,
}
.into());
Expand Down Expand Up @@ -256,9 +256,9 @@ mod tests {
let rav = EIP712SignedMessage::new(
&domain_separator,
tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher {
allocation_id: allocation_ids[0],
timestamp_ns: receipt_timestamp_range.clone().min().unwrap() - 1,
value_aggregate: 42,
allocationId: allocation_ids[0],
timestampNs: receipt_timestamp_range.clone().min().unwrap() - 1,
valueAggregate: 42,
},
&keys.0,
)
Expand All @@ -271,9 +271,9 @@ mod tests {
let rav = EIP712SignedMessage::new(
&domain_separator,
tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher {
allocation_id: allocation_ids[0],
timestamp_ns: receipt_timestamp_range.clone().min().unwrap(),
value_aggregate: 42,
allocationId: allocation_ids[0],
timestampNs: receipt_timestamp_range.clone().min().unwrap(),
valueAggregate: 42,
},
&keys.0,
)
Expand All @@ -286,9 +286,9 @@ mod tests {
let rav = EIP712SignedMessage::new(
&domain_separator,
tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher {
allocation_id: allocation_ids[0],
timestamp_ns: receipt_timestamp_range.clone().max().unwrap() + 1,
value_aggregate: 42,
allocationId: allocation_ids[0],
timestampNs: receipt_timestamp_range.clone().max().unwrap() + 1,
valueAggregate: 42,
},
&keys.0,
)
Expand Down
6 changes: 3 additions & 3 deletions tap_aggregator/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ mod tests {
ReceiptAggregateVoucher::aggregate_receipts(allocation_ids[0], &receipts, None)
.unwrap();

assert!(remote_rav.message.allocation_id == local_rav.allocation_id);
assert!(remote_rav.message.timestamp_ns == local_rav.timestamp_ns);
assert!(remote_rav.message.value_aggregate == local_rav.value_aggregate);
assert!(remote_rav.message.allocationId == local_rav.allocationId);
assert!(remote_rav.message.timestampNs == local_rav.timestampNs);
assert!(remote_rav.message.valueAggregate == local_rav.valueAggregate);

assert!(remote_rav.recover_signer(&domain_separator).unwrap() == keys_main.address);

Expand Down
16 changes: 8 additions & 8 deletions tap_core/src/receipt_aggregate_voucher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ sol! {
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
struct ReceiptAggregateVoucher {
/// Unique allocation id this RAV belongs to
address allocation_id;
address allocationId;
/// Unix Epoch timestamp in nanoseconds (Truncated to 64-bits)
/// corresponding to max timestamp from receipt batch aggregated
uint64 timestamp_ns;
uint64 timestampNs;
/// Aggregated GRT value from receipt batch and any previous RAV provided (truncate to lower bits)
uint128 value_aggregate;
uint128 valueAggregate;
}
}

Expand All @@ -49,8 +49,8 @@ impl ReceiptAggregateVoucher {
let mut value_aggregate = 0u128;

if let Some(prev_rav) = previous_rav {
timestamp_max = prev_rav.message.timestamp_ns;
value_aggregate = prev_rav.message.value_aggregate;
timestamp_max = prev_rav.message.timestampNs;
value_aggregate = prev_rav.message.valueAggregate;
}

for receipt in receipts {
Expand All @@ -62,9 +62,9 @@ impl ReceiptAggregateVoucher {
}

Ok(Self {
allocation_id,
timestamp_ns: timestamp_max,
value_aggregate,
allocationId: allocation_id,
timestampNs: timestamp_max,
valueAggregate: value_aggregate,
})
}
}
6 changes: 3 additions & 3 deletions tap_core/src/tap_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ where
let previous_rav = self.get_previous_rav().await?;
let min_timestamp_ns = previous_rav
.as_ref()
.map(|rav| rav.message.timestamp_ns + 1)
.map(|rav| rav.message.timestampNs + 1)
.unwrap_or(0);

let (valid_receipts, invalid_receipts) = self
Expand All @@ -208,7 +208,7 @@ where
let expected_rav = Self::generate_expected_rav(&valid_receipts, previous_rav.clone())?;

self.receipt_auditor
.update_min_timestamp_ns(expected_rav.timestamp_ns)
.update_min_timestamp_ns(expected_rav.timestampNs)
.await;
let valid_receipts = valid_receipts
.into_iter()
Expand Down Expand Up @@ -260,7 +260,7 @@ where
match self.get_previous_rav().await? {
Some(last_rav) => {
self.executor
.remove_receipts_in_timestamp_range(..=last_rav.message.timestamp_ns)
.remove_receipts_in_timestamp_range(..=last_rav.message.timestampNs)
.await
.map_err(|err| Error::AdapterError {
source_error: anyhow::Error::new(err),
Expand Down
8 changes: 4 additions & 4 deletions tap_core/src/tap_manager/test/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ mod manager_unit_test {
assert_eq!(rav_request.invalid_receipts.len(), 0);
// accumulated value is correct
assert_eq!(
rav_request.expected_rav.value_aggregate,
rav_request.expected_rav.valueAggregate,
expected_accumulated_value
);
// no previous rav
Expand Down Expand Up @@ -335,7 +335,7 @@ mod manager_unit_test {
assert_eq!(rav_request.invalid_receipts.len(), 0);
// accumulated value is correct
assert_eq!(
rav_request.expected_rav.value_aggregate,
rav_request.expected_rav.valueAggregate,
expected_accumulated_value
);
// Verify there is a previous rav
Expand Down Expand Up @@ -415,7 +415,7 @@ mod manager_unit_test {
assert_eq!(rav_request_1.invalid_receipts.len(), 0);
// accumulated value is correct
assert_eq!(
rav_request_1.expected_rav.value_aggregate,
rav_request_1.expected_rav.valueAggregate,
expected_accumulated_value
);
// no previous rav
Expand Down Expand Up @@ -481,7 +481,7 @@ mod manager_unit_test {
assert_eq!(rav_request_2.invalid_receipts.len(), 0);
// accumulated value is correct
assert_eq!(
rav_request_2.expected_rav.value_aggregate,
rav_request_2.expected_rav.valueAggregate,
expected_accumulated_value
);
// Verify there is a previous rav
Expand Down
2 changes: 1 addition & 1 deletion tap_integration_tests/tests/showcase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ async fn test_tap_aggregator_rav_timestamp_cuttoff(
for (receipt, _) in first_batch.iter().chain(second_batch.iter()) {
expected_value += receipt.message.value;
}
assert!(expected_value == second_rav_response.data.message.value_aggregate);
assert!(expected_value == second_rav_response.data.message.valueAggregate);

sender_handle.stop()?;
Ok(())
Expand Down
Loading