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(tap-agent): make RAV table sequelize-friendly #123

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: set timestamp from code instead of PG
To please sequelize...

Signed-off-by: Alexis Asseman <alexis@semiotic.ai>
aasseman committed Feb 21, 2024
commit 955473f9aa4ed98d5a3a78b426f375e8136a1f86

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

This file was deleted.

4 changes: 4 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions migrations/20230915230734_tap_ravs.up.sql
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ CREATE TABLE IF NOT EXISTS scalar_tap_ravs (
PRIMARY KEY (allocation_id, sender_address),

-- To make indexer-agent's sequelize happy
createdAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
createdAt TIMESTAMP WITH TIME ZONE,
updatedAt TIMESTAMP WITH TIME ZONE
);

-- This table is used to store failed RAV requests.
1 change: 1 addition & 0 deletions tap-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ sqlx = { version = "0.7.2", features = [
"runtime-tokio",
"bigdecimal",
"rust_decimal",
"chrono",
] }
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
11 changes: 7 additions & 4 deletions tap-agent/src/tap/rav_storage_adapter.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use bigdecimal::num_bigint::{BigInt, ToBigInt};
use bigdecimal::ToPrimitive;
use ethers::types::Signature;
use open_fastrlp::{Decodable, Encodable};
use sqlx::types::BigDecimal;
use sqlx::types::{chrono, BigDecimal};
use sqlx::PgPool;
use tap_core::adapters::rav_storage_adapter::RAVStorageAdapter as RAVStorageAdapterTrait;
use tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher;
@@ -45,21 +45,24 @@ impl RAVStorageAdapterTrait for RAVStorageAdapter {
signature,
allocation_id,
timestamp_ns,
value_aggregate
value_aggregate,
createdAt,
updatedAt
)
VALUES ($1, $2, $3, $4, $5)
VALUES ($1, $2, $3, $4, $5, $6, $6)
ON CONFLICT (allocation_id, sender_address)
DO UPDATE SET
signature = $2,
timestamp_ns = $4,
value_aggregate = $5,
updatedAt = default
updatedAt = $6
"#,
self.sender.encode_hex::<String>(),
signature_bytes,
self.allocation_id.encode_hex::<String>(),
BigDecimal::from(rav.message.timestamp_ns),
BigDecimal::from(BigInt::from(rav.message.value_aggregate)),
chrono::Utc::now()
)
.execute(&self.pgpool)
.await