-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: Configurable sync_notifs backoff #3278
feat: Configurable sync_notifs backoff #3278
Conversation
8e0fc8f
to
22ad437
Compare
1c0d514
to
1f8008c
Compare
1f8008c
to
962c28f
Compare
core/payment/src/dao/payment.rs
Outdated
pub async fn mark_sent(&self, payment_id: String, owner_id: NodeId) -> DbResult<()> { | ||
do_with_transaction(self.pool, "payment_dao_mark_sent", move |conn| { | ||
diesel::update(dsl::pay_payment.filter(dsl::id.eq(payment_id))) | ||
.filter(dsl::role.eq(Role::Requestor)) | ||
.set(dsl::send_payment.eq(false)) | ||
.execute(conn)?; | ||
diesel::update( | ||
dsl::pay_payment.filter(dsl::id.eq(payment_id).and(dsl::owner_id.eq(owner_id))), | ||
) | ||
.filter(dsl::role.eq(Role::Requestor)) | ||
.set(dsl::send_payment.eq(false)) | ||
.execute(conn)?; | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous version was correct, since payment_id and role should be unique. Your version should be correct as well, but I would restore previous, for 2 reasons:
- To keep function signature more pleasant
- To avoid risk of breaking something
core/payment/src/payment_sync.rs
Outdated
fn remove_allocation_ids_from_payment(payment: &Payment) -> Payment { | ||
// We remove allocation ID from syncs because allocations are not transferred to peers and | ||
// their IDs would be unknown to the recipient. | ||
let mut payment = payment.clone(); | ||
for agreement_payment in &mut payment.agreement_payments.iter_mut() { | ||
agreement_payment.allocation_id = None; | ||
} | ||
|
||
for activity_payment in &mut payment.activity_payments.iter_mut() { | ||
activity_payment.allocation_id = None; | ||
} | ||
|
||
payment | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same functionality as
yagna/core/payment/src/processor.rs
Lines 493 to 499 in 09ee56f
// Allocation IDs are requestor's private matter and should not be sent to provider | |
for agreement_payment in payment.agreement_payments.iter_mut() { | |
agreement_payment.allocation_id = None; | |
} | |
for activity_payment in payment.activity_payments.iter_mut() { | |
activity_payment.allocation_id = None; | |
} |
so should be handled by the same code.
Payment
struct is defined in ya-client, so I wouldn't modify it there, but probably you could define trait with function remove_private_info
or something like that and implement this trait for Payment
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll reuse the code. However I'd refrain from creating a trait (an abstraction) for a single use case and stick with a free function in core/payment/utils.rs
if this is OK for you.
core/payment/src/payment_sync.rs
Outdated
@@ -45,6 +62,8 @@ async fn payment_sync( | |||
let platform_components = payment.payment_platform.split('-').collect::<Vec<_>>(); | |||
let driver = &platform_components[0]; | |||
|
|||
let payment = remove_allocation_ids_from_payment(&payment); | |||
|
|||
let signature = typed::service(driver_bus_id(driver)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could query signature from database probably and sign only if we need to rely on fallback.
But this code was already implemented this way, so let's leave it as is
let mut result = ya_net::from(default_identity) | ||
.to(peer) | ||
.service(ya_core_model::payment::public::BUS_ID) | ||
.call(msg_with_bytes.clone()) | ||
.await; | ||
|
||
if matches!(&result, Err(Error::GsbBadRequest(_))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You comment made me realize, that those mechanisms broke because of transition to central net.
We shouldn't remove previous version, because we will break hybrid net this way
core/payment/src/payment_sync.rs
Outdated
secs | ||
}; | ||
capped | ||
}; | ||
let cutoff = Utc::now(); | ||
|
||
let default_identity = typed::service(identity::BUS_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can list identities instead of taking default. Check identity::List
core/payment/src/payment_sync.rs
Outdated
async fn payment_sync( | ||
db: &DbExecutor, | ||
current_node_id: NodeId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it current. Not sure what it means in this context. Maybe just node_id
or owner_id`
resolves: golemfactory/gamerhash-facade#183
scenarios: https://github.com/golemfactory/gamerhash-facade/wiki/Payments-sync-testing-scenarios