Skip to content

Commit

Permalink
Make RAV value threshold per sender
Browse files Browse the repository at this point in the history
Fixes #93

Signed-off-by: Alexis Asseman <[email protected]>
  • Loading branch information
aasseman committed Feb 16, 2024
1 parent d3b58eb commit 57afc67
Show file tree
Hide file tree
Showing 12 changed files with 1,706 additions and 1,216 deletions.

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

This file was deleted.

7 changes: 3 additions & 4 deletions tap-agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use indexer_common::prelude::{
};

use crate::{
aggregator_endpoints, config, database,
tap::sender_allocation_relationships_manager::SenderAllocationRelationshipsManager,
aggregator_endpoints, config, database, tap::sender_accounts_manager::SenderAccountsManager,
};

pub async fn start_agent(config: &'static config::Cli) -> SenderAllocationRelationshipsManager {
pub async fn start_agent(config: &'static config::Cli) -> SenderAccountsManager {
let pgpool = database::connect(&config.postgres).await;

let http_client = reqwest::Client::new();
Expand Down Expand Up @@ -80,7 +79,7 @@ pub async fn start_agent(config: &'static config::Cli) -> SenderAllocationRelati
verifying_contract: config.receipts.receipts_verifier_address,
};

SenderAllocationRelationshipsManager::new(
SenderAccountsManager::new(
config,
pgpool,
indexer_allocations,
Expand Down
6 changes: 4 additions & 2 deletions tap-agent/src/tap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ mod escrow_adapter;
mod rav_storage_adapter;
mod receipt_checks_adapter;
mod receipt_storage_adapter;
mod sender_allocation_relationship;
pub mod sender_allocation_relationships_manager;
mod sender_account;
pub mod sender_accounts_manager;
mod sender_allocation;
mod unaggregated_receipts;

#[cfg(test)]
pub mod test_utils;
Expand Down
8 changes: 4 additions & 4 deletions tap-agent/src/tap/rav_storage_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ impl RAVStorageAdapter {
#[cfg(test)]
mod test {
use super::*;
use crate::tap::test_utils::{create_rav, ALLOCATION_ID, SENDER, SIGNER};
use crate::tap::test_utils::{create_rav, ALLOCATION_ID_0, SENDER, SIGNER};
use tap_core::adapters::rav_storage_adapter::RAVStorageAdapter as RAVStorageAdapterTrait;

#[sqlx::test(migrations = "../migrations")]
async fn update_and_retrieve_rav(pool: PgPool) {
let timestamp_ns = u64::MAX - 10;
let value_aggregate = u128::MAX;
let rav_storage_adapter = RAVStorageAdapter::new(pool.clone(), *ALLOCATION_ID, SENDER.1);
let rav_storage_adapter = RAVStorageAdapter::new(pool.clone(), *ALLOCATION_ID_0, SENDER.1);

// Insert a rav
let mut new_rav = create_rav(
*ALLOCATION_ID,
*ALLOCATION_ID_0,
SIGNER.0.clone(),
timestamp_ns,
value_aggregate,
Expand All @@ -121,7 +121,7 @@ mod test {
// Update the RAV 3 times in quick succession
for i in 0..3 {
new_rav = create_rav(
*ALLOCATION_ID,
*ALLOCATION_ID_0,
SIGNER.0.clone(),
timestamp_ns + i,
value_aggregate - (i as u128),
Expand Down
14 changes: 7 additions & 7 deletions tap-agent/src/tap/receipt_storage_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mod test {

use super::*;
use crate::tap::test_utils::{
create_received_receipt, store_receipt, ALLOCATION_ID, ALLOCATION_ID_IRRELEVANT, SENDER,
create_received_receipt, store_receipt, ALLOCATION_ID_0, ALLOCATION_ID_IRRELEVANT, SENDER,
SENDER_IRRELEVANT, SIGNER, TAP_EIP712_DOMAIN_SEPARATOR,
};
use anyhow::Result;
Expand Down Expand Up @@ -381,7 +381,7 @@ mod test {

let storage_adapter = ReceiptStorageAdapter::new(
pgpool.clone(),
*ALLOCATION_ID,
*ALLOCATION_ID_0,
SENDER.1,
get_full_list_of_checks(),
escrow_accounts.clone(),
Expand All @@ -392,7 +392,7 @@ mod test {
for i in 0..10 {
received_receipt_vec.push(
create_received_receipt(
&ALLOCATION_ID,
&ALLOCATION_ID_0,
&SIGNER.0,
i + 684,
i + 42,
Expand All @@ -416,7 +416,7 @@ mod test {
);
received_receipt_vec.push(
create_received_receipt(
&ALLOCATION_ID,
&ALLOCATION_ID_0,
&SENDER_IRRELEVANT.0,
i + 684,
i + 42,
Expand Down Expand Up @@ -525,7 +525,7 @@ mod test {

let storage_adapter = ReceiptStorageAdapter::new(
pgpool,
*ALLOCATION_ID,
*ALLOCATION_ID_0,
SENDER.1,
get_full_list_of_checks(),
escrow_accounts.clone(),
Expand All @@ -536,7 +536,7 @@ mod test {
for i in 0..10 {
received_receipt_vec.push(
create_received_receipt(
&ALLOCATION_ID,
&ALLOCATION_ID_0,
&SIGNER.0,
i + 684,
i + 42,
Expand All @@ -560,7 +560,7 @@ mod test {
);
received_receipt_vec.push(
create_received_receipt(
&ALLOCATION_ID,
&ALLOCATION_ID_0,
&SENDER_IRRELEVANT.0,
i + 684,
i + 42,
Expand Down
Loading

0 comments on commit 57afc67

Please sign in to comment.