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

Make RAV value threshold per sender #113

Merged
merged 12 commits into from
Feb 16, 2024
Merged

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

This file was deleted.

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

13 changes: 13 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions tap-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tracing-subscriber = { version = "0.3", features = [
"std",
"json",
] }
enum-as-inner = "0.6.0"

[dev-dependencies]
ethers-signers = "2.0.8"
Expand Down
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
Loading